This makes the DCA parser and decoder independent.
Showing the changes to libavcodec/dca_parser.c (1 of 6 files). Show all
Unified · Split
| @@ -24,9 +24,7 @@ · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | #include "parser.h" | 25 | #include "parser.h" |
| 26 | #include "dca.h" | 26 | #include "dca.h" |
| 27 | #include "dca_parser.h" | ||
| 28 | #include "get_bits.h" | 27 | #include "get_bits.h" |
| 29 | #include "put_bits.h" | ||
| 30 | 28 | ||
| 31 | typedef struct DCAParseContext { | 29 | typedef struct DCAParseContext { |
| 32 | ParseContext pc; | 30 | ParseContext pc; |
| @@ -103,41 +101,6 @@ static av_cold int dca_parse_init(AVCodecParserContext * s) · 70 unmodified lines | |||
| 103 | return 0; | 101 | return 0; |
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, | ||
| 107 | int max_size) | ||
| 108 | { | ||
| 109 | uint32_t mrk; | ||
| 110 | int i, tmp; | ||
| 111 | const uint16_t *ssrc = (const uint16_t *) src; | ||
| 112 | uint16_t *sdst = (uint16_t *) dst; | ||
| 113 | PutBitContext pb; | ||
| 114 | |||
| 115 | if ((unsigned) src_size > (unsigned) max_size) | ||
| 116 | src_size = max_size; | ||
| 117 | |||
| 118 | mrk = AV_RB32(src); | ||
| 119 | switch (mrk) { | ||
| 120 | case DCA_MARKER_RAW_BE: | ||
| 121 | memcpy(dst, src, src_size); | ||
| 122 | return src_size; | ||
| 123 | case DCA_MARKER_RAW_LE: | ||
| 124 | for (i = 0; i < (src_size + 1) >> 1; i++) | ||
| 125 | *sdst++ = av_bswap16(*ssrc++); | ||
| 126 | return src_size; | ||
| 127 | case DCA_MARKER_14B_BE: | ||
| 128 | case DCA_MARKER_14B_LE: | ||
| 129 | init_put_bits(&pb, dst, max_size); | ||
| 130 | for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) { | ||
| 131 | tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; | ||
| 132 | put_bits(&pb, 14, tmp); | ||
| 133 | } | ||
| 134 | flush_put_bits(&pb); | ||
| 135 | return (put_bits_count(&pb) + 7) >> 3; | ||
| 136 | default: | ||
| 137 | return AVERROR_INVALIDDATA; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, | 104 | static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, |
| 142 | int *sample_rate) | 105 | int *sample_rate) |
| 143 | { | 106 | { |