Commit 323b8c95 authored by Paul B Mahol's avatar Paul B Mahol

avformat: add AVFormatContext to ff_get_extradata()

Needed for av_log() inside that function.
Signed-off-by: default avatarPaul B Mahol <onemda@gmail.com>
parent 8e26bdd5
......@@ -94,7 +94,7 @@ static int adx_read_header(AVFormatContext *s)
c->header_size = avio_rb16(s->pb) + 4;
avio_seek(s->pb, -4, SEEK_CUR);
if (ff_get_extradata(par, s->pb, c->header_size) < 0)
if (ff_get_extradata(s, par, s->pb, c->header_size) < 0)
return AVERROR(ENOMEM);
if (par->extradata_size < 12) {
......
......@@ -299,7 +299,7 @@ static int aiff_read_header(AVFormatContext *s)
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
if (ff_get_extradata(st->codecpar, pb, size) < 0)
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if (st->codecpar->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codecpar->block_align) {
st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4);
......
......@@ -77,7 +77,7 @@ static int aix_read_header(AVFormatContext *s)
if (size <= 8)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 8);
ff_get_extradata(s->streams[i]->codecpar, s->pb, size - 8);
ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
}
return 0;
......
......@@ -53,7 +53,7 @@ static int apc_read_header(AVFormatContext *s)
st->codecpar->sample_rate = avio_rl32(pb);
/* initial predictor values for adpcm decoder */
if (ff_get_extradata(st->codecpar, pb, 2 * 4) < 0)
if (ff_get_extradata(s, st->codecpar, pb, 2 * 4) < 0)
return AVERROR(ENOMEM);
if (avio_rl32(pb)) {
......
......@@ -96,7 +96,7 @@ static int ape_tag_read_field(AVFormatContext *s)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
if (ff_get_extradata(st->codecpar, s->pb, size) < 0)
if (ff_get_extradata(s, st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
......
......@@ -762,7 +762,7 @@ static int avi_read_header(AVFormatContext *s)
st->codecpar->extradata_size = esize - 10 * 4;
} else
st->codecpar->extradata_size = size - 10 * 4;
if (ff_get_extradata(st->codecpar, pb, st->codecpar->extradata_size) < 0)
if (ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
}
......@@ -917,7 +917,7 @@ static int avi_read_header(AVFormatContext *s)
st = s->streams[stream_index];
if (size<(1<<30)) {
if (ff_get_extradata(st->codecpar, pb, size) < 0)
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
......
......@@ -129,7 +129,7 @@ static int read_header(AVFormatContext *s)
vst->codecpar->codec_id = AV_CODEC_ID_NONE;
}
if (ff_get_extradata(vst->codecpar, pb, 4) < 0)
if (ff_get_extradata(s, vst->codecpar, pb, 4) < 0)
return AVERROR(ENOMEM);
bink->num_audio_tracks = avio_rl32(pb);
......
......@@ -168,7 +168,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
}
} else {
av_freep(&st->codecpar->extradata);
if (ff_get_extradata(st->codecpar, pb, size) < 0)
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
......
......@@ -659,7 +659,7 @@ static int flv_read_close(AVFormatContext *s)
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
{
av_freep(&st->codecpar->extradata);
if (ff_get_extradata(st->codecpar, s->pb, size) < 0)
if (ff_get_extradata(s, st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
return 0;
}
......
......@@ -205,7 +205,7 @@ static int idcin_read_header(AVFormatContext *s)
st->codecpar->height = height;
/* load up the Huffman tables into extradata */
if ((ret = ff_get_extradata(st->codecpar, pb, HUFFMAN_TABLE_SIZE)) < 0)
if ((ret = ff_get_extradata(s, st->codecpar, pb, HUFFMAN_TABLE_SIZE)) < 0)
return ret;
if (idcin->audio_present) {
......
......@@ -522,7 +522,7 @@ int ff_alloc_extradata(AVCodecParameters *par, int size);
* @param size size of extradata
* @return >= 0 if OK, AVERROR_xxx on error
*/
int ff_get_extradata(AVCodecParameters *par, AVIOContext *pb, int size);
int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size);
/**
* add frame for rfps calculation.
......
......@@ -482,7 +482,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codecpar->extradata);
if ((ret = ff_get_extradata(st->codecpar, pb, len)) < 0)
if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0)
return ret;
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
......
......@@ -1568,7 +1568,7 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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(st->codecpar, pb, atom.size);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
} else if (atom.size > 8) { /* to read frma, esds atoms */
......@@ -1635,7 +1635,7 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(st->codecpar, pb, atom.size);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
......@@ -1661,7 +1661,7 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_seek(pb, 6, SEEK_CUR);
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(st->codecpar, pb, atom.size - 7);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 7);
if (ret < 0)
return ret;
......@@ -1689,7 +1689,7 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_skip(pb, 40);
av_freep(&st->codecpar->extradata);
ret = ff_get_extradata(st->codecpar, pb, atom.size - 40);
ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 40);
if (ret < 0)
return ret;
......@@ -2028,7 +2028,7 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
if ((int)size != size)
return AVERROR(ENOMEM);
ret = ff_get_extradata(st->codecpar, pb, size);
ret = ff_get_extradata(c->fc, st->codecpar, pb, size);
if (ret < 0)
return ret;
if (size > 16) {
......
......@@ -95,7 +95,7 @@ static int mpc_read_header(AVFormatContext *s)
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->bits_per_coded_sample = 16;
if (ff_get_extradata(st->codecpar, s->pb, 16) < 0)
if (ff_get_extradata(s, st->codecpar, s->pb, 16) < 0)
return AVERROR(ENOMEM);
st->codecpar->sample_rate = mpc_rate[st->codecpar->extradata[2] & 3];
avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codecpar->sample_rate);
......
......@@ -252,7 +252,7 @@ static int mpc8_read_header(AVFormatContext *s)
st->codecpar->codec_id = AV_CODEC_ID_MUSEPACK8;
st->codecpar->bits_per_coded_sample = 16;
if (ff_get_extradata(st->codecpar, pb, 2) < 0)
if (ff_get_extradata(s, st->codecpar, pb, 2) < 0)
return AVERROR(ENOMEM);
st->codecpar->channels = (st->codecpar->extradata[1] >> 4) + 1;
......
......@@ -463,7 +463,7 @@ static int decode_stream_header(NUTContext *nut)
GET_V(st->codecpar->extradata_size, tmp < (1 << 30));
if (st->codecpar->extradata_size) {
if (ff_get_extradata(st->codecpar, bc, st->codecpar->extradata_size) < 0)
if (ff_get_extradata(s, st->codecpar, bc, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
}
......
......@@ -87,7 +87,7 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
av_freep(&vst->codecpar->extradata);
vst->codecpar->extradata_size = 0;
}
if (ff_get_extradata(vst->codecpar, pb, size) < 0)
if (ff_get_extradata(NULL, vst->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
size = 0;
if (!myth)
......
......@@ -143,7 +143,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
}
if (cbSize > 0) {
av_freep(&par->extradata);
if (ff_get_extradata(par, pb, cbSize) < 0)
if (ff_get_extradata(s, par, pb, cbSize) < 0)
return AVERROR(ENOMEM);
size -= cbSize;
}
......@@ -156,7 +156,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
size -= 4;
av_freep(&par->extradata);
if (ff_get_extradata(par, pb, size) < 0)
if (ff_get_extradata(s, par, pb, size) < 0)
return AVERROR(ENOMEM);
nb_streams = AV_RL16(par->extradata + 4);
par->sample_rate = AV_RL32(par->extradata + 12);
......
......@@ -127,7 +127,7 @@ static av_cold int rl2_read_header(AVFormatContext *s)
if(signature == RLV3_TAG && back_size > 0)
st->codecpar->extradata_size += back_size;
if(ff_get_extradata(st->codecpar, pb, st->codecpar->extradata_size) < 0)
if(ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
/** setup audio stream if present */
......
......@@ -93,7 +93,7 @@ static int rm_read_extradata(AVFormatContext *s, AVIOContext *pb, AVCodecParamet
av_log(s, AV_LOG_ERROR, "extradata size %u too large\n", size);
return -1;
}
if (ff_get_extradata(par, pb, size) < 0)
if (ff_get_extradata(s, par, pb, size) < 0)
return AVERROR(ENOMEM);
return 0;
}
......
......@@ -127,7 +127,7 @@ static int rsd_read_header(AVFormatContext *s)
start = avio_rl32(pb);
if ((ret = ff_get_extradata(par, s->pb, 32)) < 0)
if ((ret = ff_get_extradata(s, par, s->pb, 32)) < 0)
return ret;
if (pb->seekable)
st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
......
......@@ -3117,7 +3117,7 @@ int ff_alloc_extradata(AVCodecParameters *par, int size)
return ret;
}
int ff_get_extradata(AVCodecParameters *par, AVIOContext *pb, int size)
int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size)
{
int ret = ff_alloc_extradata(par, size);
if (ret < 0)
......@@ -3126,7 +3126,7 @@ int ff_get_extradata(AVCodecParameters *par, AVIOContext *pb, int size)
if (ret != size) {
av_freep(&par->extradata);
par->extradata_size = 0;
av_log(par, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
av_log(s, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
return ret < 0 ? ret : AVERROR_INVALIDDATA;
}
......
......@@ -61,7 +61,7 @@ static int vc1t_read_header(AVFormatContext *s)
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_WMV3;
if (ff_get_extradata(st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
if (ff_get_extradata(s, st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
return AVERROR(ENOMEM);
st->codecpar->height = avio_rl32(pb);
st->codecpar->width = avio_rl32(pb);
......
......@@ -101,7 +101,7 @@ static int wsvqa_read_header(AVFormatContext *s)
avio_seek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */
if (ff_get_extradata(st->codecpar, pb, VQA_HEADER_SIZE) < 0)
if (ff_get_extradata(s, st->codecpar, pb, VQA_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
header = st->codecpar->extradata;
st->codecpar->width = AV_RL16(&header[6]);
......
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