avcodec/tak: remove GetBitContext usage from avpriv_tak_parse_streaminfo()
This prevents potential ABI issues with GetBitContext. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
984b882b76
commit
6bd665b7c5
@ -90,7 +90,7 @@ int ff_tak_check_crc(const uint8_t *buf, unsigned int buf_size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)
|
void ff_tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
|
||||||
{
|
{
|
||||||
uint64_t channel_mask = 0;
|
uint64_t channel_mask = 0;
|
||||||
int frame_type, i;
|
int frame_type, i;
|
||||||
@ -125,6 +125,19 @@ void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)
|
|||||||
s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
|
s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size)
|
||||||
|
{
|
||||||
|
GetBitContext gb;
|
||||||
|
int ret = init_get_bits8(&gb, buf, size);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
ff_tak_parse_streaminfo(s, &gb);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
||||||
TAKStreamInfo *ti, int log_level_offset)
|
TAKStreamInfo *ti, int log_level_offset)
|
||||||
{
|
{
|
||||||
@ -144,7 +157,7 @@ int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {
|
if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {
|
||||||
avpriv_tak_parse_streaminfo(gb, ti);
|
ff_tak_parse_streaminfo(ti, gb);
|
||||||
|
|
||||||
if (get_bits(gb, 6))
|
if (get_bits(gb, 6))
|
||||||
skip_bits(gb, 25);
|
skip_bits(gb, 25);
|
||||||
|
@ -143,10 +143,14 @@ int ff_tak_check_crc(const uint8_t *buf, unsigned int buf_size);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the Streaminfo metadata block.
|
* Parse the Streaminfo metadata block.
|
||||||
* @param[in] gb pointer to GetBitContext
|
|
||||||
* @param[out] s storage for parsed information
|
* @param[out] s storage for parsed information
|
||||||
|
* @param[in] buf input buffer
|
||||||
|
* @param[in] size size of input buffer in bytes
|
||||||
|
* @return non-zero on error, 0 if OK
|
||||||
*/
|
*/
|
||||||
void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s);
|
int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size);
|
||||||
|
|
||||||
|
void ff_tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate and decode a frame header.
|
* Validate and decode a frame header.
|
||||||
|
@ -103,7 +103,6 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init_get_bits8(&gb, buffer, size - 3);
|
|
||||||
break;
|
break;
|
||||||
case TAK_METADATA_MD5: {
|
case TAK_METADATA_MD5: {
|
||||||
uint8_t md5[16];
|
uint8_t md5[16];
|
||||||
@ -145,7 +144,9 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
if (type == TAK_METADATA_STREAMINFO) {
|
if (type == TAK_METADATA_STREAMINFO) {
|
||||||
TAKStreamInfo ti;
|
TAKStreamInfo ti;
|
||||||
|
|
||||||
avpriv_tak_parse_streaminfo(&gb, &ti);
|
ret = avpriv_tak_parse_streaminfo(&ti, buffer, size -3);
|
||||||
|
if (ret < 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (ti.samples > 0)
|
if (ti.samples > 0)
|
||||||
st->duration = ti.samples;
|
st->duration = ti.samples;
|
||||||
st->codecpar->bits_per_coded_sample = ti.bps;
|
st->codecpar->bits_per_coded_sample = ti.bps;
|
||||||
@ -161,11 +162,13 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
} else if (type == TAK_METADATA_LAST_FRAME) {
|
} else if (type == TAK_METADATA_LAST_FRAME) {
|
||||||
if (size != 11)
|
if (size != 11)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
init_get_bits8(&gb, buffer, size - 3);
|
||||||
tc->mlast_frame = 1;
|
tc->mlast_frame = 1;
|
||||||
tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
|
tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
|
||||||
get_bits(&gb, TAK_LAST_FRAME_SIZE_BITS);
|
get_bits(&gb, TAK_LAST_FRAME_SIZE_BITS);
|
||||||
av_freep(&buffer);
|
av_freep(&buffer);
|
||||||
} else if (type == TAK_METADATA_ENCODER) {
|
} else if (type == TAK_METADATA_ENCODER) {
|
||||||
|
init_get_bits8(&gb, buffer, size - 3);
|
||||||
av_log(s, AV_LOG_VERBOSE, "encoder version: %0X\n",
|
av_log(s, AV_LOG_VERBOSE, "encoder version: %0X\n",
|
||||||
get_bits_long(&gb, TAK_ENCODER_VERSION_BITS));
|
get_bits_long(&gb, TAK_ENCODER_VERSION_BITS));
|
||||||
av_freep(&buffer);
|
av_freep(&buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user