Needed for av_log() inside that function.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
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) {
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);
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;
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)) {
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;
}
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);
}
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);
}
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);
}
} 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);
}
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;
}
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) {
* @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.
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};
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 */
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;
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;
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;
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) {
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);
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;
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);
}
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)
}
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;
}
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);
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 */
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;
}
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);
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)
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;
}
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);
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]);