This makes the DCA parser and decoder independent.
Unified · Split
| @@ -134,7 +134,7 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o · 133 unmodified lines | ||
| 134 | 134 | OBJS-$(CONFIG_CSCD_DECODER) += cscd.o |
| 135 | 135 | OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o |
| 136 | 136 | OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \ |
| 137 | − dca_parser.o synth_filter.o | |
| 137 | + synth_filter.o | |
| 138 | 138 | OBJS-$(CONFIG_DFA_DECODER) += dfa.o |
| 139 | 139 | OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o |
| 140 | 140 | OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o |
| @@ -19,7 +19,9 @@ · 18 unmodified lines | ||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | #include <stdint.h> |
| 22 | +#include <string.h> | |
| 22 | 23 | |
| 24 | +#include "put_bits.h" | |
| 23 | 25 | #include "dca.h" |
| 24 | 26 | |
| 25 | 27 | const uint32_t avpriv_dca_sample_rates[16] = |
| @@ -27,3 +29,38 @@ const uint32_t avpriv_dca_sample_rates[16] = · 1 unmodified line | ||
| 27 | 29 | 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0, |
| 28 | 30 | 12000, 24000, 48000, 96000, 192000 |
| 29 | 31 | }; |
| 32 | + | |
| 33 | +int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, | |
| 34 | + int max_size) | |
| 35 | +{ | |
| 36 | + uint32_t mrk; | |
| 37 | + int i, tmp; | |
| 38 | + const uint16_t *ssrc = (const uint16_t *) src; | |
| 39 | + uint16_t *sdst = (uint16_t *) dst; | |
| 40 | + PutBitContext pb; | |
| 41 | + | |
| 42 | + if ((unsigned) src_size > (unsigned) max_size) | |
| 43 | + src_size = max_size; | |
| 44 | + | |
| 45 | + mrk = AV_RB32(src); | |
| 46 | + switch (mrk) { | |
| 47 | + case DCA_MARKER_RAW_BE: | |
| 48 | + memcpy(dst, src, src_size); | |
| 49 | + return src_size; | |
| 50 | + case DCA_MARKER_RAW_LE: | |
| 51 | + for (i = 0; i < (src_size + 1) >> 1; i++) | |
| 52 | + *sdst++ = av_bswap16(*ssrc++); | |
| 53 | + return src_size; | |
| 54 | + case DCA_MARKER_14B_BE: | |
| 55 | + case DCA_MARKER_14B_LE: | |
| 56 | + init_put_bits(&pb, dst, max_size); | |
| 57 | + for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) { | |
| 58 | + tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; | |
| 59 | + put_bits(&pb, 14, tmp); | |
| 60 | + } | |
| 61 | + flush_put_bits(&pb); | |
| 62 | + return (put_bits_count(&pb) + 7) >> 3; | |
| 63 | + default: | |
| 64 | + return AVERROR_INVALIDDATA; | |
| 65 | + } | |
| 66 | +} | |
| @@ -39,4 +39,10 @@ · 38 unmodified lines | ||
| 39 | 39 | |
| 40 | 40 | extern av_export const uint32_t avpriv_dca_sample_rates[16]; |
| 41 | 41 | |
| 42 | +/** | |
| 43 | + * Convert bitstream to one representation based on sync marker | |
| 44 | + */ | |
| 45 | +int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, | |
| 46 | + int max_size); | |
| 47 | + | |
| 42 | 48 | #endif /* AVCODEC_DCA_H */ |
| @@ -24,9 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | #include "parser.h" |
| 26 | 26 | #include "dca.h" |
| 27 | −#include "dca_parser.h" | |
| 28 | 27 | #include "get_bits.h" |
| 29 | −#include "put_bits.h" | |
| 30 | 28 | |
| 31 | 29 | typedef struct DCAParseContext { |
| 32 | 30 | ParseContext pc; |
| @@ -103,41 +101,6 @@ static av_cold int dca_parse_init(AVCodecParserContext * s) · 70 unmodified lines | ||
| 103 | 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 | 104 | static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, |
| 142 | 105 | int *sample_rate) |
| 143 | 106 | { |
| @@ -1,36 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * DCA parser | |
| 3 | − * Copyright (C) 2004 Gildas Bazin | |
| 4 | − * Copyright (C) 2004 Benjamin Zores | |
| 5 | − * Copyright (C) 2006 Benjamin Larsson | |
| 6 | − * Copyright (C) 2007 Konstantin Shishkov | |
| 7 | − * | |
| 8 | − * This file is part of Libav. | |
| 9 | − * | |
| 10 | − * Libav is free software; you can redistribute it and/or | |
| 11 | − * modify it under the terms of the GNU Lesser General Public | |
| 12 | − * License as published by the Free Software Foundation; either | |
| 13 | − * version 2.1 of the License, or (at your option) any later version. | |
| 14 | − * | |
| 15 | − * Libav is distributed in the hope that it will be useful, | |
| 16 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 | − * Lesser General Public License for more details. | |
| 19 | − * | |
| 20 | − * You should have received a copy of the GNU Lesser General Public | |
| 21 | − * License along with Libav; if not, write to the Free Software | |
| 22 | − * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 23 | − */ | |
| 24 | − | |
| 25 | −#ifndef AVCODEC_DCA_PARSER_H | |
| 26 | −#define AVCODEC_DCA_PARSER_H | |
| 27 | − | |
| 28 | −#include <stdint.h> | |
| 29 | − | |
| 30 | −/** | |
| 31 | − * Convert bitstream to one representation based on sync marker | |
| 32 | − */ | |
| 33 | −int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, | |
| 34 | − int max_size); | |
| 35 | − | |
| 36 | −#endif /* AVCODEC_DCA_PARSER_H */ | |
| @@ -40,7 +40,6 @@ · 39 unmodified lines | ||
| 40 | 40 | #include "dcadata.h" |
| 41 | 41 | #include "dcahuff.h" |
| 42 | 42 | #include "dca.h" |
| 43 | −#include "dca_parser.h" | |
| 44 | 43 | #include "mathops.h" |
| 45 | 44 | #include "synth_filter.h" |
| 46 | 45 | #include "dcadsp.h" |