1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat: Don't free old extradata before ff_alloc/get_extradata

These functions already free it themselves before they allocate the new
extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Andreas Rheinhardt 2019-12-11 12:21:07 +01:00 committed by Michael Niedermayer
parent c1e439d7e9
commit 82d61a9ce3
18 changed files with 4 additions and 37 deletions

View File

@ -770,7 +770,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
st->codecpar->extradata_size = size - 10 * 4;
if (st->codecpar->extradata) {
av_log(s, AV_LOG_WARNING, "New extradata in strf chunk, freeing previous one.\n");
av_freep(&st->codecpar->extradata);
}
ret = ff_get_extradata(s, st->codecpar, pb,
st->codecpar->extradata_size);
@ -932,7 +931,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (size<(1<<30)) {
if (st->codecpar->extradata) {
av_log(s, AV_LOG_WARNING, "New extradata in strd chunk, freeing previous one.\n");
av_freep(&st->codecpar->extradata);
}
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
return ret;

View File

@ -135,7 +135,6 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
return AVERROR_INVALIDDATA;
}
av_freep(&st->codecpar->extradata);
if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0)
return ret;
@ -175,9 +174,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
return AVERROR_PATCHWELCOME;
}
avio_skip(pb, size);
} else {
av_freep(&st->codecpar->extradata);
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
} else if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) {
return ret;
}

View File

@ -171,10 +171,6 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
if (st->codecpar->codec_id || !source_st->codecpar->codec_id) {
if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) {
if (st->codecpar->extradata) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
}
ret = ff_alloc_extradata(st->codecpar,
source_st->codecpar->extradata_size);
if (ret < 0)

View File

@ -175,7 +175,6 @@ static int flic_read_header(AVFormatContext *s)
avio_seek(pb, 12, SEEK_SET);
/* send over abbreviated FLIC header chunk */
av_freep(&st->codecpar->extradata);
if ((ret = ff_alloc_extradata(st->codecpar, 12)) < 0)
return ret;
memcpy(st->codecpar->extradata, header, 12);

View File

@ -799,7 +799,6 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
if (!size)
return 0;
av_freep(&st->codecpar->extradata);
if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
return ret;
st->internal->need_context_update = 1;

View File

@ -2264,7 +2264,6 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
return ret;
if (!output_sample_rate)
output_sample_rate = track->sample_rate; // Space is already reserved, so it's this or a void element.
av_freep(&par->extradata);
ret = ff_alloc_extradata(par, side_data_size);
if (ret < 0)
return ret;

View File

@ -1838,7 +1838,6 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st->codecpar->codec_id == AV_CODEC_ID_QDMC ||
st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
// pass all frma atom to codec, needed at least for QDMC and QDM2
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
@ -1905,7 +1904,6 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_log(c->fc, AV_LOG_WARNING, "ignoring multiple glbl\n");
return 0;
}
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
@ -1938,7 +1936,6 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
avio_seek(pb, 6, SEEK_CUR);
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 7);
if (ret < 0)
return ret;
@ -1966,7 +1963,6 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR_INVALIDDATA;
avio_skip(pb, 40);
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 40);
if (ret < 0)
return ret;

View File

@ -83,10 +83,6 @@ static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst,
avio_skip(pb, 6);
size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
if (vst->codecpar->extradata) {
av_freep(&vst->codecpar->extradata);
vst->codecpar->extradata_size = 0;
}
if ((ret = ff_get_extradata(NULL, vst->codecpar, pb, size)) < 0)
return ret;
size = 0;

View File

@ -109,7 +109,6 @@ ogm_header(AVFormatContext *s, int idx)
size -= 52;
if (bytestream2_get_bytes_left(&p) < size)
return AVERROR_INVALIDDATA;
av_freep(&st->codecpar->extradata);
if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
return ret;
bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);

View File

@ -63,7 +63,6 @@ static int opus_header(AVFormatContext *avf, int idx)
/*gain = AV_RL16(packet + 16);*/
/*channel_map = AV_RL8 (packet + 18);*/
av_freep(&st->codecpar->extradata);
if ((ret = ff_alloc_extradata(st->codecpar, os->psize)) < 0)
return ret;

View File

@ -145,7 +145,6 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
size -= 22;
}
if (cbSize > 0) {
av_freep(&par->extradata);
if (ff_get_extradata(s, par, pb, cbSize) < 0)
return AVERROR(ENOMEM);
size -= cbSize;
@ -158,7 +157,6 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
int nb_streams, i;
size -= 4;
av_freep(&par->extradata);
if (ff_get_extradata(s, par, pb, size) < 0)
return AVERROR(ENOMEM);
nb_streams = AV_RL16(par->extradata + 4);

View File

@ -115,7 +115,6 @@ static int parse_fmtp_config(AVStream *st, const char *value)
ret = AVERROR_PATCHWELCOME;
goto end;
}
av_freep(&st->codecpar->extradata);
ret = ff_alloc_extradata(st->codecpar, (get_bits_left(&gb) + 7)/8);
if (ret < 0) {
goto end;

View File

@ -113,7 +113,7 @@ static int parse_fmtp_config(AVCodecParameters *par, const char *value)
{
/* decode the hexa encoded parameter */
int len = ff_hex_to_data(NULL, value), ret;
av_freep(&par->extradata);
if ((ret = ff_alloc_extradata(par, len)) < 0)
return ret;
ff_hex_to_data(par->extradata, value);

View File

@ -105,7 +105,7 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st,
case 4: /* stream with extradata */
if (item_len < 30)
return AVERROR_INVALIDDATA;
av_freep(&st->codecpar->extradata);
ret = ff_alloc_extradata(st->codecpar, 26 + item_len);
if (ret < 0) {
return ret;

View File

@ -58,10 +58,6 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv,
len -= 2;
if (config_packet) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
if (len < 2 || ff_alloc_extradata(st->codecpar, len + 8))
return AVERROR_INVALIDDATA;

View File

@ -5480,7 +5480,6 @@ int ff_generate_avci_extradata(AVStream *st)
if (!size)
return 0;
av_freep(&st->codecpar->extradata);
if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
return ret;
memcpy(st->codecpar->extradata, data, size);

View File

@ -220,7 +220,6 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
avio_seek(pb, -size, SEEK_CUR);
av_freep(&(*st)->codecpar->extradata);
if ((ret = ff_get_extradata(s, (*st)->codecpar, pb, size)) < 0)
return ret;

View File

@ -397,8 +397,6 @@ static int xmv_process_packet_header(AVFormatContext *s)
av_assert0(xmv->video.stream_index < s->nb_streams);
if (vst->codecpar->extradata_size < 4) {
av_freep(&vst->codecpar->extradata);
if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0)
return ret;
}