aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfoo86 <foobaz86@gmail.com>2017-07-10 17:11:35 +0300
committerJames Almer <jamrial@gmail.com>2017-07-18 21:04:57 -0300
commite54b9be1ffd669c76458324206935c8927a7c705 (patch)
tree5724955c06a9238e3dba9c058680822b08a24eca
parent33fc6c17a6e76ec2894e656cfeba5bcba9498778 (diff)
downloadffmpeg-e54b9be1ffd669c76458324206935c8927a7c705.tar.gz
avcodec/dca_parser: switch to common frame header parsing function
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/dca_parser.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index e5bea3347c..6107358773 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -192,10 +192,11 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
int buf_size, int *duration, int *sample_rate)
{
GetBitContext gb;
- uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
- int ret, sample_blocks;
+ DCACoreFrameHeader h;
+ uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
+ int ret;
- if (buf_size < 12)
+ if (buf_size < DCA_CORE_FRAME_HEADER_SIZE)
return AVERROR_INVALIDDATA;
if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) {
@@ -255,21 +256,16 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
return AVERROR_INVALIDDATA;
}
- if ((ret = avpriv_dca_convert_bitstream(buf, 12, hdr, 12)) < 0)
+ if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE,
+ hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
return ret;
-
- init_get_bits(&gb, hdr, 96);
-
- skip_bits_long(&gb, 39);
- sample_blocks = get_bits(&gb, 7) + 1;
- if (sample_blocks < 8)
+ if ((ret = init_get_bits8(&gb, hdr, ret)) < 0)
+ return ret;
+ if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
return AVERROR_INVALIDDATA;
- *duration = 256 * (sample_blocks / 8);
- skip_bits(&gb, 20);
- *sample_rate = avpriv_dca_sample_rates[get_bits(&gb, 4)];
- if (*sample_rate == 0)
- return AVERROR_INVALIDDATA;
+ *duration = 256 * (h.npcmblocks / 8);
+ *sample_rate = avpriv_dca_sample_rates[h.sr_code];
return 0;
}