Commit 7c9d2ad4 authored by James Almer's avatar James Almer

avcodec/dca: remove GetBitContext usage from avpriv_dca_parse_core_frame_header()

This prevents potential ABI issues with GetBitContext.
Reviewed-by: 's avatarfoo86 <foobaz86@gmail.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 99c5ac20
......@@ -88,7 +88,7 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
}
}
int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h)
int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb)
{
if (get_bits_long(gb, 32) != DCA_SYNCWORD_CORE_BE)
return DCA_PARSE_ERROR_SYNC_WORD;
......@@ -145,3 +145,13 @@ int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h)
h->dn_code = get_bits(gb, 4);
return 0;
}
int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, uint8_t *buf, int size)
{
GetBitContext gb;
if (init_get_bits8(&gb, buf, size) < 0)
return DCA_PARSE_ERROR_INVALIDDATA;
return ff_dca_parse_core_frame_header(h, &gb);
}
......@@ -45,7 +45,8 @@ enum DCAParseError {
DCA_PARSE_ERROR_SAMPLE_RATE = -6,
DCA_PARSE_ERROR_RESERVED_BIT = -7,
DCA_PARSE_ERROR_LFE_FLAG = -8,
DCA_PARSE_ERROR_PCM_RES = -9
DCA_PARSE_ERROR_PCM_RES = -9,
DCA_PARSE_ERROR_INVALIDDATA = -10,
};
typedef struct DCACoreFrameHeader {
......@@ -212,6 +213,8 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
* Parse and validate core frame header
* @return 0 on success, negative DCA_PARSE_ERROR_ code on failure
*/
int avpriv_dca_parse_core_frame_header(GetBitContext *gb, DCACoreFrameHeader *h);
int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, uint8_t *buf, int size);
int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb);
#endif /* AVCODEC_DCA_H */
......@@ -82,7 +82,7 @@ static void get_array(GetBitContext *s, int32_t *array, int size, int n)
static int parse_frame_header(DCACoreDecoder *s)
{
DCACoreFrameHeader h = { 0 };
int err = avpriv_dca_parse_core_frame_header(&s->gb, &h);
int err = ff_dca_parse_core_frame_header(&h, &s->gb);
if (err < 0) {
switch (err) {
......
......@@ -263,9 +263,7 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE,
hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
return ret;
if ((ret = init_get_bits8(&gb, hdr, ret)) < 0)
return ret;
if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
if (avpriv_dca_parse_core_frame_header(&h, hdr, ret) < 0)
return AVERROR_INVALIDDATA;
*duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES;
......
......@@ -101,9 +101,7 @@ static int dts_probe(AVProbeData *p)
if ((ret = avpriv_dca_convert_bitstream(buf - 2, DCA_CORE_FRAME_HEADER_SIZE,
hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
continue;
if (init_get_bits8(&gb, hdr, ret) < 0)
continue;
if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
if (avpriv_dca_parse_core_frame_header(&h, hdr, ret) < 0)
continue;
marker += 4 * h.sr_code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment