avformat: use ff_alloc_extradata()

Signed-off-by: Paul B Mahol <onemda@gmail.com>
pull/37/merge
Paul B Mahol 11 years ago
parent 3fd79833e2
commit a807c68253
  1. 3
      libavformat/adxdec.c
  2. 4
      libavformat/afc.c
  3. 4
      libavformat/aiffdec.c
  4. 6
      libavformat/apc.c
  5. 4
      libavformat/ape.c
  6. 5
      libavformat/apetag.c
  7. 12
      libavformat/avidec.c
  8. 8
      libavformat/bink.c
  9. 15
      libavformat/bintext.c
  10. 8
      libavformat/cafdec.c
  11. 4
      libavformat/dfa.c
  12. 8
      libavformat/ffmdec.c
  13. 8
      libavformat/flic.c
  14. 8
      libavformat/flvdec.c
  15. 4
      libavformat/idcin.c
  16. 4
      libavformat/isom.c
  17. 3
      libavformat/libnut.c
  18. 9
      libavformat/matroskadec.c
  19. 24
      libavformat/mov.c
  20. 4
      libavformat/mpc.c
  21. 4
      libavformat/mpc8.c
  22. 4
      libavformat/mpegts.c
  23. 4
      libavformat/mvi.c
  24. 4
      libavformat/mxfdec.c
  25. 4
      libavformat/nutdec.c
  26. 4
      libavformat/nuv.c
  27. 6
      libavformat/oggparseflac.c
  28. 5
      libavformat/oggparseogm.c
  29. 4
      libavformat/oggparsespeex.c
  30. 6
      libavformat/omadec.c
  31. 4
      libavformat/redspark.c
  32. 5
      libavformat/riffdec.c
  33. 4
      libavformat/rl2.c
  34. 4
      libavformat/rmdec.c
  35. 4
      libavformat/rsd.c
  36. 5
      libavformat/rtpdec_latm.c
  37. 4
      libavformat/rtpdec_mpeg4.c
  38. 5
      libavformat/rtpdec_qdm2.c
  39. 5
      libavformat/rtpdec_svq3.c
  40. 5
      libavformat/rtpdec_xiph.c
  41. 6
      libavformat/sbgdec.c
  42. 4
      libavformat/sierravmd.c
  43. 5
      libavformat/smacker.c
  44. 4
      libavformat/smush.c
  45. 6
      libavformat/tta.c
  46. 10
      libavformat/utils.c
  47. 4
      libavformat/vc1test.c
  48. 3
      libavformat/vqf.c
  49. 5
      libavformat/wavdec.c
  50. 8
      libavformat/westwood_vqa.c
  51. 4
      libavformat/xmv.c
  52. 7
      libavformat/yop.c

@ -78,8 +78,7 @@ static int adx_read_header(AVFormatContext *s)
c->header_size = avio_rb16(s->pb) + 4;
avio_seek(s->pb, -4, SEEK_CUR);
avctx->extradata = av_mallocz(c->header_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
if (ff_alloc_extradata(avctx, c->header_size))
return AVERROR(ENOMEM);
if (avio_read(s->pb, avctx->extradata, c->header_size) < c->header_size) {
av_freep(&avctx->extradata);

@ -39,10 +39,8 @@ static int afc_read_header(AVFormatContext *s)
st->codec->codec_id = AV_CODEC_ID_ADPCM_AFC;
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->extradata_size = 1;
st->codec->extradata = av_mallocz(1 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 1))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 8 * st->codec->channels;

@ -276,10 +276,8 @@ static int aiff_read_header(AVFormatContext *s)
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
avio_read(pb, st->codec->extradata, size);
if (st->codec->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codec->block_align) {
st->codec->block_align = AV_RB32(st->codec->extradata+11*4);

@ -23,6 +23,7 @@
#include "libavutil/channel_layout.h"
#include "avformat.h"
#include "internal.h"
static int apc_probe(AVProbeData *p)
{
@ -51,10 +52,7 @@ static int apc_read_header(AVFormatContext *s)
avio_rl32(pb); /* number of samples */
st->codec->sample_rate = avio_rl32(pb);
st->codec->extradata_size = 2 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 2 * 4))
return AVERROR(ENOMEM);
/* initial predictor values for adpcm decoder */

@ -354,8 +354,8 @@ static int ape_read_header(AVFormatContext * s)
st->duration = total_blocks;
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE);
st->codec->extradata_size = APE_EXTRADATA_SIZE;
if (ff_alloc_extradata(st->codec, APE_EXTRADATA_SIZE))
return AVERROR(ENOMEM);
AV_WL16(st->codec->extradata + 0, ape->fileversion);
AV_WL16(st->codec->extradata + 2, ape->compressiontype);
AV_WL16(st->codec->extradata + 4, ape->formatflags);

@ -88,14 +88,13 @@ static int ape_tag_read_field(AVFormatContext *s)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
if (avio_read(pb, st->codec->extradata, size) != size) {
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
return AVERROR(EIO);
}
st->codec->extradata_size = size;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {

@ -648,12 +648,8 @@ static int avi_read_header(AVFormatContext *s)
st->codec->extradata_size = esize - 10 * 4;
} else
st->codec->extradata_size = size - 10 * 4;
st->codec->extradata = av_malloc(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size = 0;
if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
return AVERROR(ENOMEM);
}
avio_read(pb,
st->codec->extradata,
st->codec->extradata_size);
@ -781,12 +777,8 @@ static int avi_read_header(AVFormatContext *s)
st = s->streams[stream_index];
if (size<(1<<30)) {
st->codec->extradata_size= size;
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size= 0;
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
}
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
}

@ -116,10 +116,8 @@ static int read_header(AVFormatContext *s)
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO;
vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata)
if (ff_alloc_extradata(vst->codec, 4))
return AVERROR(ENOMEM);
vst->codec->extradata_size = 4;
avio_read(pb, vst->codec->extradata, 4);
bink->num_audio_tracks = avio_rl32(pb);
@ -152,10 +150,8 @@ static int read_header(AVFormatContext *s)
ast->codec->channels = 1;
ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
}
ast->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ast->codec->extradata)
if (ff_alloc_extradata(ast->codec, 4))
return AVERROR(ENOMEM);
ast->codec->extradata_size = 4;
AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
}

@ -136,9 +136,7 @@ static int bintext_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_BINTEXT;
st->codec->extradata_size = 2;
st->codec->extradata = av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 2))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = 0;
@ -194,8 +192,7 @@ static int xbin_read_header(AVFormatContext *s)
st->codec->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
st->codec->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
st->codec->extradata = av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
return AVERROR(ENOMEM);
st->codec->extradata[0] = fontheight;
st->codec->extradata[1] = flags;
@ -227,9 +224,7 @@ static int adf_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_BINTEXT;
st->codec->extradata_size = 2 + 48 + 4096;
st->codec->extradata = av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
@ -284,9 +279,7 @@ static int idf_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_IDF;
st->codec->extradata_size = 2 + 48 + 4096;
st->codec->extradata = av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;

@ -130,8 +130,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
}
avio_read(pb, preamble, ALAC_PREAMBLE);
st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, ALAC_HEADER))
return AVERROR(ENOMEM);
/* For the old style cookie, we skip 12 bytes, then read 36 bytes.
@ -154,13 +153,10 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12);
avio_skip(pb, size - ALAC_NEW_KUKI);
}
st->codec->extradata_size = ALAC_HEADER;
} else {
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, size);
st->codec->extradata_size = size;
}
return 0;

@ -64,8 +64,8 @@ static int dfa_read_header(AVFormatContext *s)
avio_skip(pb, 128 - 16); // padding
st->duration = frames;
st->codec->extradata = av_malloc(2);
st->codec->extradata_size = 2;
if (ff_alloc_extradata(st->codec, 2))
return AVERROR(ENOMEM);
AV_WL16(st->codec->extradata, version);
if (version == 0x100)
st->sample_aspect_ratio = (AVRational){2, 1};

@ -278,9 +278,7 @@ static int ffm2_read_header(AVFormatContext *s)
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
codec->extradata_size = avio_rb32(pb);
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
if (ff_alloc_extradata(codec, avio_rb32(pb)))
return AVERROR(ENOMEM);
avio_read(pb, codec->extradata, codec->extradata_size);
}
@ -468,9 +466,7 @@ static int ffm_read_header(AVFormatContext *s)
goto fail;
}
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
codec->extradata_size = avio_rb32(pb);
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
if (ff_alloc_extradata(codec, avio_rb32(pb)))
return AVERROR(ENOMEM);
avio_read(pb, codec->extradata, codec->extradata_size);
}

@ -125,10 +125,8 @@ static int flic_read_header(AVFormatContext *s)
}
/* send over the whole 128-byte FLIC header */
st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, FLIC_HEADER_SIZE))
return AVERROR(ENOMEM);
st->codec->extradata_size = FLIC_HEADER_SIZE;
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
@ -178,10 +176,8 @@ static int flic_read_header(AVFormatContext *s)
/* send over abbreviated FLIC header chunk */
av_free(st->codec->extradata);
st->codec->extradata = av_malloc(12);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 12))
return AVERROR(ENOMEM);
st->codec->extradata_size = 12;
memcpy(st->codec->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) {

@ -246,9 +246,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
vcodec->codec_id = AV_CODEC_ID_VP6A;
if (read) {
if (vcodec->extradata_size != 1) {
vcodec->extradata = av_malloc(1 + FF_INPUT_BUFFER_PADDING_SIZE);
if (vcodec->extradata)
vcodec->extradata_size = 1;
ff_alloc_extradata(vcodec, 1);
}
if (vcodec->extradata)
vcodec->extradata[0] = avio_r8(s->pb);
@ -616,10 +614,8 @@ static int flv_read_close(AVFormatContext *s)
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
{
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
st->codec->extradata_size = size;
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}

@ -196,10 +196,8 @@ static int idcin_read_header(AVFormatContext *s)
st->codec->height = height;
/* load up the Huffman tables into extradata */
st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, HUFFMAN_TABLE_SIZE))
return AVERROR(ENOMEM);
st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
if (ret < 0) {
return ret;

@ -452,11 +452,9 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, len))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, len);
st->codec->extradata_size = len;
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg;
avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,

@ -232,8 +232,7 @@ static int nut_read_header(AVFormatContext * avf) {
st->codec->extradata_size = s[i].codec_specific_len;
if (st->codec->extradata_size) {
st->codec->extradata = av_mallocz(st->codec->extradata_size);
if(!st->codec->extradata){
if(ff_alloc_extradata(st->codec, st->codec->extradata_size)){
nut_demuxer_uninit(nut);
priv->nut = NULL;
return AVERROR(ENOMEM);

@ -1819,11 +1819,8 @@ static int matroska_read_header(AVFormatContext *s)
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv.data && track->codec_priv.size > 0){
st->codec->extradata = av_mallocz(track->codec_priv.size +
FF_INPUT_BUFFER_PADDING_SIZE);
if(st->codec->extradata == NULL)
if (ff_alloc_extradata(st->codec, track->codec_priv.size))
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv.size;
memcpy(st->codec->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
@ -1916,10 +1913,8 @@ static int matroska_read_header(AVFormatContext *s)
av_dict_set(&st->metadata, "mimetype", attachements[j].mime, 0);
st->codec->codec_id = AV_CODEC_ID_NONE;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size + FF_INPUT_BUFFER_PADDING_SIZE);
if(st->codec->extradata == NULL)
if (ff_alloc_extradata(st->codec, attachements[j].bin.size))
break;
st->codec->extradata_size = attachements[j].bin.size;
memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
for (i=0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {

@ -1077,11 +1077,8 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st->codec->codec_id == AV_CODEC_ID_SPEEX) {
// pass all frma atom to codec, needed at least for QDMC and QDM2
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, atom.size))
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
avio_read(pb, st->codec->extradata, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */
int ret;
@ -1117,11 +1114,8 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return mov_read_default(c, pb, atom);
}
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, atom.size))
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
avio_read(pb, st->codec->extradata, atom.size);
return 0;
}
@ -1143,11 +1137,8 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size - 7 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, atom.size - 7))
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 7;
avio_seek(pb, 6, SEEK_CUR);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
return 0;
@ -1172,11 +1163,8 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR_INVALIDDATA;
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size - 40 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, atom.size - 40))
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 40;
avio_skip(pb, 40);
avio_read(pb, st->codec->extradata, atom.size - 40);
return 0;
@ -1491,9 +1479,7 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
int size)
{
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, size);
if (size > 16) {

@ -95,8 +95,8 @@ static int mpc_read_header(AVFormatContext *s)
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->bits_per_coded_sample = 16;
st->codec->extradata_size = 16;
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
if (ff_alloc_extradata(st->codec, 16))
return AVERROR(ENOMEM);
avio_read(s->pb, st->codec->extradata, 16);
st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);

@ -241,8 +241,8 @@ static int mpc8_read_header(AVFormatContext *s)
st->codec->codec_id = AV_CODEC_ID_MUSEPACK8;
st->codec->bits_per_coded_sample = 16;
st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (ff_alloc_extradata(st->codec, 2))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
st->codec->channels = (st->codec->extradata[1] >> 4) + 1;

@ -1454,9 +1454,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
if (st->codec->extradata_size == 4 && memcmp(st->codec->extradata, *pp, 4))
avpriv_request_sample(fc, "DVB sub with multiple IDs");
} else {
st->codec->extradata = av_malloc(4 + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
st->codec->extradata_size = 4;
if (!ff_alloc_extradata(st->codec, 4)) {
memcpy(st->codec->extradata, *pp, 4);
}
}

@ -52,9 +52,7 @@ static int read_header(AVFormatContext *s)
if (!vst)
return AVERROR(ENOMEM);
vst->codec->extradata_size = 2;
vst->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata)
if (ff_alloc_extradata(vst->codec, 2))
return AVERROR(ENOMEM);
version = avio_r8(pb);

@ -1599,10 +1599,8 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
}
if (descriptor->extradata) {
st->codec->extradata = av_mallocz(descriptor->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
if (!ff_alloc_extradata(st->codec, descriptor->extradata_size)) {
memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
st->codec->extradata_size = descriptor->extradata_size;
}
} else if(st->codec->codec_id == AV_CODEC_ID_H264) {
ff_generate_avci_extradata(st);

@ -415,9 +415,7 @@ static int decode_stream_header(NUTContext *nut)
GET_V(st->codec->extradata_size, tmp < (1 << 30));
if (st->codec->extradata_size) {
st->codec->extradata = av_mallocz(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
return AVERROR(ENOMEM);
avio_read(bc, st->codec->extradata, st->codec->extradata_size);
}

@ -86,10 +86,8 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
av_freep(&vst->codec->extradata);
vst->codec->extradata_size = 0;
}
vst->codec->extradata = av_malloc(size);
if (!vst->codec->extradata)
if (ff_alloc_extradata(vst->codec, size))
return AVERROR(ENOMEM);
vst->codec->extradata_size = size;
avio_read(pb, vst->codec->extradata, size);
size = 0;
if (!myth)

@ -62,10 +62,8 @@ flac_header (AVFormatContext * s, int idx)
st->codec->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
st->codec->extradata =
av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
ff_alloc_extradata(st->codec, FLAC_STREAMINFO_SIZE);
memcpy(st->codec->extradata, streaminfo_start, st->codec->extradata_size);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {

@ -99,9 +99,8 @@ ogm_header(AVFormatContext *s, int idx)
if (size > 52) {
av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);
size -= 52;
st->codec->extradata_size = size;
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
bytestream2_get_buffer(&p, st->codec->extradata, size);
ff_alloc_extradata(st->codec, size);
bytestream2_get_buffer(&p, st->codec->extradata, st->codec->extradata_size);
}
}
} else if (bytestream2_peek_byte(&p) == 3) {

@ -77,9 +77,7 @@ static int speex_header(AVFormatContext *s, int idx) {
if (frames_per_packet)
spxp->packet_size *= frames_per_packet;
st->codec->extradata_size = os->psize;
st->codec->extradata = av_malloc(st->codec->extradata_size
+ FF_INPUT_BUFFER_PADDING_SIZE);
ff_alloc_extradata(st->codec, os->psize);
memcpy(st->codec->extradata, p, st->codec->extradata_size);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);

@ -349,12 +349,10 @@ static int oma_read_header(AVFormatContext *s)
/* fake the ATRAC3 extradata
* (wav format, makes stream copy to wav work) */
st->codec->extradata_size = 14;
edata = av_mallocz(14 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!edata)
if (ff_alloc_extradata(st->codec, 14))
return AVERROR(ENOMEM);
st->codec->extradata = edata;
edata = st->codec->extradata;
AV_WL16(&edata[0], 1); // always 1
AV_WL32(&edata[2], samplerate); // samples rate
AV_WL16(&edata[6], jsflag); // coding mode

@ -113,9 +113,7 @@ static int redspark_read_header(AVFormatContext *s)
goto fail;
}
codec->extradata_size = 32 * codec->channels;
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata) {
if (ff_alloc_extradata(codec, 32 * codec->channels)) {
ret = AVERROR(ENOMEM);
goto fail;
}

@ -115,12 +115,9 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
cbSize -= 22;
size -= 22;
}
codec->extradata_size = cbSize;
if (cbSize > 0) {
av_free(codec->extradata);
codec->extradata = av_mallocz(codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
if (ff_alloc_extradata(codec, cbSize))
return AVERROR(ENOMEM);
avio_read(pb, codec->extradata, codec->extradata_size);
size -= cbSize;

@ -125,9 +125,7 @@ static av_cold int rl2_read_header(AVFormatContext *s)
if(signature == RLV3_TAG && back_size > 0)
st->codec->extradata_size += back_size;
st->codec->extradata = av_mallocz(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if(!st->codec->extradata)
if(ff_alloc_extradata(st->codec, st->codec->extradata_size))
return AVERROR(ENOMEM);
if(avio_read(pb,st->codec->extradata,st->codec->extradata_size) !=

@ -86,11 +86,9 @@ static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned si
{
if (size >= 1<<24)
return -1;
avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
if (ff_alloc_extradata(avctx, size))
return AVERROR(ENOMEM);
avctx->extradata_size = avio_read(pb, avctx->extradata, size);
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if (avctx->extradata_size != size)
return AVERROR(EIO);
return 0;

@ -101,9 +101,7 @@ static int rsd_read_header(AVFormatContext *s)
/* RSD3GADP is mono, so only alloc enough memory
to store the coeff table for a single channel. */
codec->extradata_size = 32;
codec->extradata = av_malloc(codec->extradata_size);
if (!codec->extradata)
if (ff_alloc_extradata(codec, 32))
return AVERROR(ENOMEM);
start = avio_rl32(pb);

@ -130,10 +130,7 @@ static int parse_fmtp_config(AVStream *st, char *value)
goto end;
}
av_freep(&st->codec->extradata);
st->codec->extradata_size = (get_bits_left(&gb) + 7)/8;
st->codec->extradata = av_mallocz(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
if (ff_alloc_extradata(st->codec, (get_bits_left(&gb) + 7)/8)) {
ret = AVERROR(ENOMEM);
goto end;
}

@ -105,10 +105,8 @@ static int parse_fmtp_config(AVCodecContext *codec, char *value)
/* decode the hexa encoded parameter */
int len = ff_hex_to_data(NULL, value);
av_free(codec->extradata);
codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
if (ff_alloc_extradata(codec, len))
return AVERROR(ENOMEM);
codec->extradata_size = len;
ff_hex_to_data(codec->extradata, value);
return 0;
}

@ -29,6 +29,7 @@
#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/avcodec.h"
#include "internal.h"
#include "rtp.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
@ -104,9 +105,7 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st,
if (item_len < 30)
return AVERROR_INVALIDDATA;
av_freep(&st->codec->extradata);
st->codec->extradata_size = 26 + item_len;
if (!(st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE))) {
st->codec->extradata_size = 0;
if (ff_alloc_extradata(st->codec, 26 + item_len)) {
return AVERROR(ENOMEM);
}
AV_WB32(st->codec->extradata, 12);

@ -28,6 +28,7 @@
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "internal.h"
#include "rtp.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
@ -60,11 +61,9 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv,
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
if (len < 2 || !(st->codec->extradata =
av_malloc(len + 8 + FF_INPUT_BUFFER_PADDING_SIZE)))
if (len < 2 || ff_alloc_extradata(st->codec, len + 8))
return AVERROR_INVALIDDATA;
st->codec->extradata_size = len + 8;
memcpy(st->codec->extradata, "SEQH", 4);
AV_WB32(st->codec->extradata + 4, len);
memcpy(st->codec->extradata + 8, buf, len);

@ -33,6 +33,7 @@
#include "libavutil/base64.h"
#include "libavcodec/bytestream.h"
#include "internal.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
@ -288,11 +289,11 @@ parse_packed_headers(const uint8_t * packed_headers,
* -- FF_INPUT_BUFFER_PADDING_SIZE required */
extradata_alloc = length + length/255 + 3 + FF_INPUT_BUFFER_PADDING_SIZE;
ptr = codec->extradata = av_malloc(extradata_alloc);
if (!ptr) {
if (ff_alloc_extradata(codec, extradata_alloc)) {
av_log(codec, AV_LOG_ERROR, "Out of memory\n");
return AVERROR(ENOMEM);
}
ptr = codec->extradata;
*ptr++ = 2;
ptr += av_xiphlacing(ptr, length1);
ptr += av_xiphlacing(ptr, length2);

@ -1333,11 +1333,9 @@ static int encode_intervals(struct sbg_script *s, AVCodecContext *avc,
if (edata_size < 0)
return AVERROR(ENOMEM);
}
edata = av_malloc(edata_size);
if (!edata)
if (ff_alloc_extradata(avc, edata_size))
return AVERROR(ENOMEM);
avc->extradata = edata;
avc->extradata_size = edata_size;
edata = avc->extradata;
#define ADD_EDATA32(v) do { AV_WL32(edata, (v)); edata += 4; } while(0)
#define ADD_EDATA64(v) do { AV_WL64(edata, (v)); edata += 8; } while(0)

@ -127,10 +127,8 @@ static int vmd_read_header(AVFormatContext *s)
vst->codec->width >>= 1;
vst->codec->height >>= 1;
}
vst->codec->extradata = av_mallocz(VMD_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata)
if (ff_alloc_extradata(vst->codec, VMD_HEADER_SIZE))
return AVERROR(ENOMEM);
vst->codec->extradata_size = VMD_HEADER_SIZE;
memcpy(vst->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
}

@ -217,10 +217,7 @@ static int smacker_read_header(AVFormatContext *s)
/* load trees to extradata, they will be unpacked by decoder */
st->codec->extradata = av_mallocz(smk->treesize + 16 +
FF_INPUT_BUFFER_PADDING_SIZE);
st->codec->extradata_size = smk->treesize + 16;
if(!st->codec->extradata){
if(ff_alloc_extradata(st->codec, smk->treesize + 16)){
av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);

@ -145,11 +145,9 @@ static int smush_read_header(AVFormatContext *ctx)
avpriv_set_pts_info(vst, 64, 66667, 1000000);
if (!smush->version) {
vst->codec->extradata = av_malloc(1024 + 2 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata)
if (ff_alloc_extradata(vst->codec, 1024 + 2))
return AVERROR(ENOMEM);
vst->codec->extradata_size = 1024 + 2;
AV_WL16(vst->codec->extradata, subversion);
for (i = 0; i < 256; i++)
AV_WL32(vst->codec->extradata + 2 + i * 4, palette[i]);

@ -109,12 +109,8 @@ static int tta_read_header(AVFormatContext *s)
framepos = avio_tell(s->pb) + 4*c->totalframes + 4;
st->codec->extradata_size = avio_tell(s->pb) - start_offset;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codec->extradata_size = 0;
if (ff_alloc_extradata(st->codec, avio_tell(s->pb) - start_offset))
return AVERROR(ENOMEM);
}
avio_seek(s->pb, start_offset, SEEK_SET);
avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);

@ -2950,12 +2950,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size= i;
st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, i))
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
@ -4271,10 +4268,7 @@ void ff_generate_avci_extradata(AVStream *st)
if (!size)
return;
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, size))
return;
memcpy(st->codec->extradata, data, size);
st->codec->extradata_size = size;
}

@ -61,8 +61,8 @@ static int vc1t_read_header(AVFormatContext *s)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_WMV3;
st->codec->extradata = av_malloc(VC1_EXTRADATA_SIZE);
st->codec->extradata_size = VC1_EXTRADATA_SIZE;
if (ff_alloc_extradata(st->codec, VC1_EXTRADATA_SIZE))
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, VC1_EXTRADATA_SIZE);
st->codec->height = avio_rl32(pb);
st->codec->width = avio_rl32(pb);

@ -220,9 +220,8 @@ static int vqf_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, size, st->codec->sample_rate);
/* put first 12 bytes of COMM chunk in extradata */
if (!(st->codec->extradata = av_malloc(12 + FF_INPUT_BUFFER_PADDING_SIZE)))
if (ff_alloc_extradata(st->codec, 12))
return AVERROR(ENOMEM);
st->codec->extradata_size = 12;
memcpy(st->codec->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);

@ -353,10 +353,7 @@ static int wav_read_header(AVFormatContext *s)
vst->codec->codec_id = AV_CODEC_ID_SMVJPEG;
vst->codec->width = avio_rl24(pb);
vst->codec->height = avio_rl24(pb);
vst->codec->extradata_size = 4;
vst->codec->extradata = av_malloc(vst->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!vst->codec->extradata) {
if (ff_alloc_extradata(vst->codec, 4)) {
av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n");
return AVERROR(ENOMEM);
}

@ -101,10 +101,8 @@ static int wsvqa_read_header(AVFormatContext *s)
avio_seek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, VQA_HEADER_SIZE))
return AVERROR(ENOMEM);
st->codec->extradata_size = VQA_HEADER_SIZE;
header = (unsigned char *)st->codec->extradata;
if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
@ -221,9 +219,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
break;
case SND2_TAG:
st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
st->codec->extradata_size = 2;
st->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (ff_alloc_extradata(st->codec, 2))
return AVERROR(ENOMEM);
AV_WL16(st->codec->extradata, wsvqa->version);
break;

@ -383,9 +383,7 @@ static int xmv_process_packet_header(AVFormatContext *s)
if (vst->codec->extradata_size < 4) {
av_free(vst->codec->extradata);
vst->codec->extradata =
av_malloc(4 + FF_INPUT_BUFFER_PADDING_SIZE);
vst->codec->extradata_size = 4;
ff_alloc_extradata(vst->codec, 4);
}
memcpy(vst->codec->extradata, xmv->video.extradata, 4);

@ -69,12 +69,7 @@ static int yop_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
// Extra data that will be passed to the decoder
video_stream->codec->extradata_size = 8;
video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!video_stream->codec->extradata)
if (ff_alloc_extradata(video_stream->codec, 8))
return AVERROR(ENOMEM);
// Audio

Loading…
Cancel
Save