avformat: Forward errors where possible

It is not uncommon to find code where the caller thinks to know better
what the return value should be than the callee. E.g. something like
"if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit
changes several instances of this to instead forward the actual error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/328/head
Andreas Rheinhardt 5 years ago committed by Michael Niedermayer
parent cb88cdf773
commit c1e439d7e9
  1. 6
      libavformat/adxdec.c
  2. 5
      libavformat/afc.c
  3. 8
      libavformat/aiffdec.c
  4. 5
      libavformat/apc.c
  5. 22
      libavformat/ape.c
  6. 4
      libavformat/apetag.c
  7. 18
      libavformat/asfenc.c
  8. 10
      libavformat/avidec.c
  9. 12
      libavformat/avisynth.c
  10. 14
      libavformat/bink.c
  11. 24
      libavformat/bintext.c
  12. 4
      libavformat/bit.c
  13. 8
      libavformat/bmv.c
  14. 4
      libavformat/brstm.c
  15. 9
      libavformat/cafdec.c
  16. 4
      libavformat/cdxl.c
  17. 6
      libavformat/dfa.c
  18. 4
      libavformat/dsfdec.c
  19. 9
      libavformat/dxa.c
  20. 10
      libavformat/flic.c
  21. 5
      libavformat/flvdec.c
  22. 19
      libavformat/fsb.c
  23. 18
      libavformat/id3v2enc.c
  24. 10
      libavformat/jvdec.c
  25. 9
      libavformat/libmodplug.c
  26. 9
      libavformat/mm.c
  27. 5
      libavformat/mov.c
  28. 12
      libavformat/mpc8.c
  29. 20
      libavformat/mpegts.c
  30. 2
      libavformat/mpegtsenc.c
  31. 5
      libavformat/mvi.c
  32. 6
      libavformat/nutdec.c
  33. 6
      libavformat/nuv.c
  34. 6
      libavformat/oggparsecelt.c
  35. 6
      libavformat/oggparseflac.c
  36. 5
      libavformat/oggparseogm.c
  37. 5
      libavformat/oggparseopus.c
  38. 5
      libavformat/oggparsespeex.c
  39. 4
      libavformat/omadec.c
  40. 10
      libavformat/paf.c
  41. 4
      libavformat/rawdec.c
  42. 5
      libavformat/rl2.c
  43. 4
      libavformat/rmdec.c
  44. 5
      libavformat/rsd.c
  45. 4
      libavformat/rtpdec_ac3.c
  46. 6
      libavformat/rtpdec_amr.c
  47. 6
      libavformat/rtpdec_h263.c
  48. 4
      libavformat/rtpdec_latm.c
  49. 8
      libavformat/rtpdec_mpa_robust.c
  50. 5
      libavformat/rtpdec_mpeg12.c
  51. 6
      libavformat/rtpdec_mpeg4.c
  52. 6
      libavformat/rtpdec_qdm2.c
  53. 10
      libavformat/rtpdec_qt.c
  54. 15
      libavformat/rtpdec_xiph.c
  55. 11
      libavformat/sbgdec.c
  56. 4
      libavformat/sdr2.c
  57. 9
      libavformat/sierravmd.c
  58. 5
      libavformat/siff.c
  59. 12
      libavformat/smacker.c
  60. 5
      libavformat/smush.c
  61. 5
      libavformat/subtitles.c
  62. 6
      libavformat/tiertexseq.c
  63. 28
      libavformat/ty.c
  64. 6
      libavformat/utils.c
  65. 6
      libavformat/vc1test.c
  66. 9
      libavformat/vividas.c
  67. 6
      libavformat/vqf.c
  68. 10
      libavformat/wavdec.c
  69. 10
      libavformat/westwood_vqa.c
  70. 4
      libavformat/wvdec.c
  71. 8
      libavformat/xwma.c

@ -83,7 +83,7 @@ static int adx_read_header(AVFormatContext *s)
{
ADXDemuxerContext *c = s->priv_data;
AVCodecParameters *par;
int ret;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
@ -94,8 +94,8 @@ 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(s, par, s->pb, c->header_size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, par, s->pb, c->header_size)) < 0)
return ret;
if (par->extradata_size < 12) {
av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");

@ -31,6 +31,7 @@ static int afc_read_header(AVFormatContext *s)
{
AFCDemuxContext *c = s->priv_data;
AVStream *st;
int ret;
st = avformat_new_stream(s, NULL);
if (!st)
@ -40,8 +41,8 @@ static int afc_read_header(AVFormatContext *s)
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
if (ff_alloc_extradata(st->codecpar, 1))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 1)) < 0)
return ret;
st->codecpar->extradata[0] = 8 * st->codecpar->channels;
c->data_end = avio_rb32(s->pb) + 32LL;

@ -301,8 +301,8 @@ 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(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
return ret;
if ( (st->codecpar->codec_id == AV_CODEC_ID_QDMC || 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);
@ -325,8 +325,8 @@ static int aiff_read_header(AVFormatContext *s)
}
break;
case MKTAG('C','H','A','N'):
if(ff_mov_read_chan(s, pb, st, size) < 0)
return AVERROR_INVALIDDATA;
if ((ret = ff_mov_read_chan(s, pb, st, size)) < 0)
return ret;
break;
case MKTAG('A','P','C','M'): /* XA ADPCM compressed sound chunk */
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_XA;

@ -37,6 +37,7 @@ static int apc_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVStream *st;
int ret;
avio_rl32(pb); /* CRYO */
avio_rl32(pb); /* _APC */
@ -53,8 +54,8 @@ static int apc_read_header(AVFormatContext *s)
st->codecpar->sample_rate = avio_rl32(pb);
/* initial predictor values for adpcm decoder */
if (ff_get_extradata(s, st->codecpar, pb, 2 * 4) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, 2 * 4)) < 0)
return ret;
if (avio_rl32(pb)) {
st->codecpar->channels = 2;

@ -163,7 +163,7 @@ static int ape_read_header(AVFormatContext * s)
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
int i;
int i, ret;
int total_blocks, final_size = 0;
int64_t pts, file_size;
@ -358,8 +358,8 @@ static int ape_read_header(AVFormatContext * s)
st->duration = total_blocks;
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
if (ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0)
return ret;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
@ -386,14 +386,16 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
int nblocks;
APEContext *ape = s->priv_data;
uint32_t extra_size = 8;
int64_t ret64;
if (avio_feof(s->pb))
return AVERROR_EOF;
if (ape->currentframe >= ape->totalframes)
return AVERROR_EOF;
if (avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET) < 0)
return AVERROR(EIO);
ret64 = avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
if (ret64 < 0)
return ret64;
/* Calculate how many blocks there are in this frame */
if (ape->currentframe == (ape->totalframes - 1))
@ -409,8 +411,9 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
return AVERROR(EIO);
}
if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0)
return AVERROR(ENOMEM);
ret = av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size);
if (ret < 0)
return ret;
AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
@ -447,12 +450,13 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
AVStream *st = s->streams[stream_index];
APEContext *ape = s->priv_data;
int index = av_index_search_timestamp(st, timestamp, flags);
int64_t ret;
if (index < 0)
return -1;
if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
return -1;
if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0)
return ret;
ape->currentframe = index;
return 0;
}

@ -96,8 +96,8 @@ 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(s, st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
return ret;
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {

@ -357,12 +357,12 @@ static int asf_write_markers(AVFormatContext *s)
int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
uint64_t offset;
int32_t send_time = get_send_time(asf, pres_time, &offset);
int len = 0;
int len = 0, ret;
uint8_t *buf;
AVIOContext *dyn_buf;
if (t) {
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
avio_put_str16le(dyn_buf, t->value);
len = avio_close_dyn_buf(dyn_buf, &buf);
}
@ -579,12 +579,12 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
/* title and other info */
if (has_title) {
int len;
int len, ret;
uint8_t *buf;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
hpos = put_header(pb, &ff_asf_comment_header);
@ -714,10 +714,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
if (desc) {
AVIOContext *dyn_buf;
uint8_t *buf;
int len;
int len, ret;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
avio_put_str16le(dyn_buf, desc);
len = avio_close_dyn_buf(dyn_buf, &buf);

@ -772,8 +772,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_log(s, AV_LOG_WARNING, "New extradata in strf chunk, freeing previous one.\n");
av_freep(&st->codecpar->extradata);
}
if (ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
ret = ff_get_extradata(s, st->codecpar, pb,
st->codecpar->extradata_size);
if (ret < 0)
return ret;
}
// FIXME: check if the encoder really did this correctly
@ -932,8 +934,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_log(s, AV_LOG_WARNING, "New extradata in strd chunk, freeing previous one.\n");
av_freep(&st->codecpar->extradata);
}
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
return ret;
}
if (st->codecpar->extradata_size & 1) //FIXME check if the encoder really did this correctly

@ -640,7 +640,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
AVS_VideoFrame *frame;
unsigned char *dst_p;
const unsigned char *src_p;
int n, i, plane, rowsize, planeheight, pitch, bits;
int n, i, plane, rowsize, planeheight, pitch, bits, ret;
const char *error;
int avsplus av_unused;
@ -676,8 +676,8 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
if (!pkt->size)
return AVERROR_UNKNOWN;
if (av_new_packet(pkt, pkt->size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, pkt->size)) < 0)
return ret;
pkt->pts = n;
pkt->dts = n;
@ -739,7 +739,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
{
AviSynthContext *avs = s->priv_data;
AVRational fps, samplerate;
int samples;
int samples, ret;
int64_t n;
const char *error;
@ -782,8 +782,8 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
if (!pkt->size)
return AVERROR_UNKNOWN;
if (av_new_packet(pkt, pkt->size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, pkt->size)) < 0)
return ret;
pkt->pts = n;
pkt->dts = n;

@ -150,8 +150,8 @@ static int read_header(AVFormatContext *s)
vst->codecpar->codec_id = AV_CODEC_ID_NONE;
}
if (ff_get_extradata(s, vst->codecpar, pb, 4) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, vst->codecpar, pb, 4)) < 0)
return ret;
bink->num_audio_tracks = avio_rl32(pb);
@ -190,8 +190,8 @@ static int read_header(AVFormatContext *s)
ast->codecpar->channels = 1;
ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
}
if (ff_alloc_extradata(ast->codecpar, 4))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(ast->codecpar, 4)) < 0)
return ret;
AV_WL32(ast->codecpar->extradata, vst->codecpar->codec_tag);
}
@ -302,13 +302,15 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
{
BinkDemuxContext *bink = s->priv_data;
AVStream *vst = s->streams[0];
int64_t ret;
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
return -1;
/* seek to the first frame */
if (avio_seek(s->pb, vst->index_entries[0].pos + bink->smush_size, SEEK_SET) < 0)
return -1;
ret = avio_seek(s->pb, vst->index_entries[0].pos + bink->smush_size, SEEK_SET);
if (ret < 0)
return ret;
bink->video_pts = 0;
memset(bink->audio_pts, 0, sizeof(bink->audio_pts));

@ -177,14 +177,14 @@ static int bintext_read_header(AVFormatContext *s)
{
BinDemuxContext *bin = s->priv_data;
AVIOContext *pb = s->pb;
int ret;
AVStream *st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 2)) < 0)
return ret;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = 0;
@ -222,7 +222,7 @@ static int xbin_read_header(AVFormatContext *s)
BinDemuxContext *bin = s->priv_data;
AVIOContext *pb = s->pb;
char fontheight, flags;
int ret;
AVStream *st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
@ -241,8 +241,9 @@ static int xbin_read_header(AVFormatContext *s)
st->codecpar->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
st->codecpar->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size))
return AVERROR(ENOMEM);
ret = ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size);
if (ret < 0)
return ret;
st->codecpar->extradata[0] = fontheight;
st->codecpar->extradata[1] = flags;
if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0)
@ -264,6 +265,7 @@ static int adf_read_header(AVFormatContext *s)
BinDemuxContext *bin = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
int ret;
if (avio_r8(pb) != 1)
return AVERROR_INVALIDDATA;
@ -273,8 +275,8 @@ static int adf_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 2 + 48 + 4096)) < 0)
return ret;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
@ -318,7 +320,7 @@ static int idf_read_header(AVFormatContext *s)
BinDemuxContext *bin = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
int got_width = 0;
int got_width = 0, ret;
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
return AVERROR(EIO);
@ -328,8 +330,8 @@ static int idf_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->codecpar->codec_id = AV_CODEC_ID_IDF;
if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 2 + 48 + 4096)) < 0)
return ret;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;

@ -94,8 +94,8 @@ static int read_packet(AVFormatContext *s,
if(ret != 8 * packet_size * sizeof(uint16_t))
return AVERROR(EIO);
if (av_new_packet(pkt, packet_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, packet_size)) < 0)
return ret;
init_put_bits(&pbo, pkt->data, packet_size);
for(j=0; j < packet_size; j++)

@ -96,8 +96,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
audio_size, c->size);
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, audio_size) < 0)
return AVERROR(ENOMEM);
if ((err = av_new_packet(pkt, audio_size)) < 0)
return err;
memcpy(pkt->data, c->packet + 1, pkt->size);
pkt->stream_index = 1;
pkt->pts = c->audio_pos;
@ -108,8 +108,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
} else
break;
}
if (av_new_packet(pkt, c->size + 1) < 0)
return AVERROR(ENOMEM);
if ((err = av_new_packet(pkt, c->size + 1)) < 0)
return err;
pkt->stream_index = 0;
c->get_next = 1;
memcpy(pkt->data, c->packet, pkt->size);

@ -403,8 +403,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
(32 + 4 + size) > (INT_MAX / par->channels) ||
(32 + 4 + size) * par->channels > INT_MAX - 8)
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels)) < 0)
return ret;
dst = pkt->data;
if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
bytestream_put_le32(&dst, size * par->channels);

@ -100,6 +100,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
{
AVIOContext *pb = s->pb;
AVStream *st = s->streams[0];
int ret;
if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
return -1;
@ -135,8 +136,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
}
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, ALAC_HEADER))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0)
return ret;
/* For the old style cookie, we skip 12 bytes, then read 36 bytes.
* The new style cookie only contains the last 24 bytes of what was
@ -176,8 +177,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
avio_skip(pb, size);
} else {
av_freep(&st->codecpar->extradata);
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
return ret;
}
return 0;

@ -202,8 +202,8 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
}
if (av_new_packet(pkt, video_size + CDXL_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, video_size + CDXL_HEADER_SIZE)) < 0)
return ret;
memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
if (ret < 0) {

@ -40,7 +40,7 @@ static int dfa_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVStream *st;
int frames;
int frames, ret;
int version;
uint32_t mspf;
@ -69,8 +69,8 @@ static int dfa_read_header(AVFormatContext *s)
avio_skip(pb, 128 - 16); // padding
st->duration = frames;
if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 2)) < 0)
return ret;
AV_WL16(st->codecpar->extradata, version);
if (version == 0x100)
st->sample_aspect_ratio = (AVRational){2, 1};

@ -169,8 +169,8 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (packet_size <= 0 || skip_size <= 0)
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, packet_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, packet_size)) < 0)
return ret;
dst = pkt->data;
for (ch = 0; ch < st->codecpar->channels; ch++) {
ret = avio_read(pb, dst, packet_size / st->codecpar->channels);

@ -179,8 +179,8 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
tag = AV_RL32(buf);
switch (tag) {
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, 4 + pal_size)) < 0)
return ret;
pkt->stream_index = 0;
if(pal_size) memcpy(pkt->data, pal, pal_size);
memcpy(pkt->data + pal_size, buf, 4);
@ -204,8 +204,9 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
size);
return AVERROR_INVALIDDATA;
}
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
ret = av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size);
if (ret < 0)
return ret;
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){

@ -89,7 +89,7 @@ static int flic_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
unsigned char header[FLIC_HEADER_SIZE];
AVStream *st, *ast;
int speed;
int speed, ret;
int magic_number;
unsigned char preamble[FLIC_PREAMBLE_SIZE];
@ -125,8 +125,8 @@ static int flic_read_header(AVFormatContext *s)
}
/* send over the whole 128-byte FLIC header */
if (ff_alloc_extradata(st->codecpar, FLIC_HEADER_SIZE))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, FLIC_HEADER_SIZE)) < 0)
return ret;
memcpy(st->codecpar->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
@ -176,8 +176,8 @@ static int flic_read_header(AVFormatContext *s)
/* send over abbreviated FLIC header chunk */
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, 12))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 12)) < 0)
return ret;
memcpy(st->codecpar->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) {

@ -795,12 +795,13 @@ static int flv_read_close(AVFormatContext *s)
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
{
int ret;
if (!size)
return 0;
av_freep(&st->codecpar->extradata);
if (ff_get_extradata(s, st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
return ret;
st->internal->need_context_update = 1;
return 0;
}

@ -41,6 +41,7 @@ static int fsb_read_header(AVFormatContext *s)
int64_t offset;
AVCodecParameters *par;
AVStream *st = avformat_new_stream(s, NULL);
int ret;
avio_skip(pb, 3); // "FSB"
version = avio_r8(pb) - '0';
@ -86,9 +87,9 @@ static int fsb_read_header(AVFormatContext *s)
par->block_align = 8 * par->channels;
if (par->channels > INT_MAX / 32)
return AVERROR_INVALIDDATA;
ff_alloc_extradata(par, 32 * par->channels);
if (!par->extradata)
return AVERROR(ENOMEM);
ret = ff_alloc_extradata(par, 32 * par->channels);
if (ret < 0)
return ret;
avio_seek(pb, 0x68, SEEK_SET);
for (c = 0; c < par->channels; c++) {
avio_read(pb, par->extradata + 32 * c, 32);
@ -130,18 +131,18 @@ static int fsb_read_header(AVFormatContext *s)
switch (par->codec_id) {
case AV_CODEC_ID_XMA2:
ff_alloc_extradata(par, 34);
if (!par->extradata)
return AVERROR(ENOMEM);
ret = ff_alloc_extradata(par, 34);
if (ret < 0)
return ret;
memset(par->extradata, 0, 34);
par->block_align = 2048;
break;
case AV_CODEC_ID_ADPCM_THP:
if (par->channels > INT_MAX / 32)
return AVERROR_INVALIDDATA;
ff_alloc_extradata(par, 32 * par->channels);
if (!par->extradata)
return AVERROR(ENOMEM);
ret = ff_alloc_extradata(par, 32 * par->channels);
if (ret < 0)
return ret;
avio_seek(pb, 0x80, SEEK_SET);
for (c = 0; c < par->channels; c++) {
avio_read(pb, par->extradata + 32 * c, 32);

@ -65,11 +65,11 @@ static void id3v2_encode_string(AVIOContext *pb, const uint8_t *str,
static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext *avioc, const char *str1, const char *str2,
uint32_t tag, enum ID3v2Encoding enc)
{
int len;
int len, ret;
uint8_t *pb;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
/* check if the strings are ASCII-only and use UTF16 only if
* they're not */
@ -103,7 +103,7 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext *avioc, const char *
*/
static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char *key, const char *data)
{
int len;
int len, ret;
uint8_t *pb;
AVIOContext *dyn_buf;
@ -111,8 +111,8 @@ static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char *
return 0;
}
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
// owner + null byte.
avio_write(dyn_buf, key, strlen(key) + 1);
@ -359,7 +359,7 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
const char *mimetype = NULL, *desc = "";
int enc = id3->version == 3 ? ID3v2_ENCODING_UTF16BOM :
ID3v2_ENCODING_UTF8;
int i, len, type = 0;
int i, len, type = 0, ret;
/* get the mimetype*/
while (mime->id != AV_CODEC_ID_NONE) {
@ -393,8 +393,8 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
enc = ID3v2_ENCODING_ISO8859;
/* start writing */
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
return ret;
avio_w8(dyn_buf, enc);
avio_put_str(dyn_buf, mimetype);

@ -168,6 +168,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
JVDemuxContext *jv = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *ast = s->streams[0];
int ret;
while (!avio_feof(s->pb) && jv->pts < ast->nb_index_entries) {
const AVIndexEntry *e = ast->index_entries + jv->pts;
@ -177,8 +178,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
case JV_AUDIO:
jv->state++;
if (jvf->audio_size) {
if (av_get_packet(s->pb, pkt, jvf->audio_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_get_packet(s->pb, pkt, jvf->audio_size)) < 0)
return ret;
pkt->stream_index = 0;
pkt->pts = e->timestamp;
pkt->flags |= AV_PKT_FLAG_KEY;
@ -187,10 +188,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
case JV_VIDEO:
jv->state++;
if (jvf->video_size || jvf->palette_size) {
int ret;
int size = jvf->video_size + jvf->palette_size;
if (av_new_packet(pkt, size + JV_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, size + JV_PREAMBLE_SIZE)) < 0)
return ret;
AV_WL32(pkt->data, jvf->video_size);
pkt->data[4] = jvf->video_type;

@ -270,6 +270,7 @@ static void write_text(uint8_t *dst, const char *s, int linesize, int x, int y)
static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
{
ModPlugContext *modplug = s->priv_data;
int ret;
if (modplug->video_stream) {
modplug->video_switch ^= 1; // one video packet for one audio packet
@ -285,8 +286,8 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
var_values[VAR_PATTERN] = ModPlug_GetCurrentPattern(modplug->f);
var_values[VAR_ROW ] = ModPlug_GetCurrentRow (modplug->f);
if (av_new_packet(pkt, modplug->fsize) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, modplug->fsize)) < 0)
return ret;
pkt->stream_index = 1;
memset(pkt->data, 0, modplug->fsize);
@ -318,8 +319,8 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
}
}
if (av_new_packet(pkt, AUDIO_PKT_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, AUDIO_PKT_SIZE)) < 0)
return ret;
if (modplug->video_stream)
pkt->pts = pkt->dts = modplug->packet_count++ * modplug->ts_per_packet;

@ -142,6 +142,7 @@ static int read_packet(AVFormatContext *s,
AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
int ret;
while(1) {
@ -161,8 +162,8 @@ static int read_packet(AVFormatContext *s,
case MM_TYPE_INTRA_HHV :
case MM_TYPE_INTER_HHV :
/* output preamble + data */
if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) < 0)
return ret;
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
@ -174,8 +175,8 @@ static int read_packet(AVFormatContext *s,
return 0;
case MM_TYPE_AUDIO :
if (av_get_packet(s->pb, pkt, length)<0)
return AVERROR(ENOMEM);
if ((ret = av_get_packet(s->pb, pkt, length)) < 0)
return ret;
pkt->stream_index = 1;
pkt->pts = mm->audio_pts++;
return 0;

@ -6673,6 +6673,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa
static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
const int OPUS_SEEK_PREROLL_MS = 80;
int ret;
AVStream *st;
size_t size;
uint16_t pre_skip;
@ -6693,8 +6694,8 @@ static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
/* OpusSpecificBox size plus magic for Ogg OpusHead header. */
size = atom.size + 8;
if (ff_alloc_extradata(st->codecpar, size))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
return ret;
AV_WL32(st->codecpar->extradata, MKTAG('O','p','u','s'));
AV_WL32(st->codecpar->extradata + 4, MKTAG('H','e','a','d'));

@ -212,7 +212,7 @@ static int mpc8_read_header(AVFormatContext *s)
MPCContext *c = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
int tag = 0;
int tag = 0, ret;
int64_t size, pos;
c->header_pos = avio_tell(pb);
@ -253,8 +253,8 @@ 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(s, st->codecpar, pb, 2) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, 2)) < 0)
return ret;
st->codecpar->channels = (st->codecpar->extradata[1] >> 4) + 1;
st->codecpar->sample_rate = mpc8_rate[st->codecpar->extradata[0] >> 5];
@ -277,7 +277,7 @@ static int mpc8_read_header(AVFormatContext *s)
static int mpc8_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MPCContext *c = s->priv_data;
int tag;
int tag, ret;
int64_t pos, size;
while(!avio_feof(s->pb)){
@ -291,8 +291,8 @@ static int mpc8_read_packet(AVFormatContext *s, AVPacket *pkt)
if (size < 0)
return -1;
if(tag == TAG_AUDIOPACKET){
if(av_get_packet(s->pb, pkt, size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_get_packet(s->pb, pkt, size)) < 0)
return ret;
pkt->stream_index = 0;
pkt->duration = 1;
return 0;

@ -1845,7 +1845,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
case 0x56: /* DVB teletext descriptor */
{
uint8_t *extradata = NULL;
int language_count = desc_len / 5;
int language_count = desc_len / 5, ret;
if (desc_len > 0 && desc_len % 5 != 0)
return AVERROR_INVALIDDATA;
@ -1855,9 +1855,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
av_assert0(language_count <= sizeof(language) / 4);
if (st->codecpar->extradata == NULL) {
if (ff_alloc_extradata(st->codecpar, language_count * 2)) {
return AVERROR(ENOMEM);
}
ret = ff_alloc_extradata(st->codecpar, language_count * 2);
if (ret < 0)
return ret;
}
if (st->codecpar->extradata_size < language_count * 2)
@ -1890,7 +1890,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
* subtitling_type (1 byte),
* composition_page_id (2 bytes),
* ancillary_page_id (2 bytes) */
int language_count = desc_len / 8;
int language_count = desc_len / 8, ret;
if (desc_len > 0 && desc_len % 8 != 0)
return AVERROR_INVALIDDATA;
@ -1906,9 +1906,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
av_assert0(language_count <= sizeof(language) / 4);
if (st->codecpar->extradata == NULL) {
if (ff_alloc_extradata(st->codecpar, language_count * 5)) {
return AVERROR(ENOMEM);
}
ret = ff_alloc_extradata(st->codecpar, language_count * 5);
if (ret < 0)
return ret;
}
if (st->codecpar->extradata_size < language_count * 5)
@ -3128,8 +3128,8 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t pcr_buf[12];
const uint8_t *data;
if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, TS_PACKET_SIZE)) < 0)
return ret;
ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
pkt->pos = avio_tell(s->pb);
if (ret < 0) {

@ -1617,7 +1617,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
ret = avio_open_dyn_buf(&ts_st->amux->pb);
if (ret < 0)
return AVERROR(ENOMEM);
return ret;
ret = av_write_frame(ts_st->amux, &pkt2);
if (ret < 0) {

@ -45,6 +45,7 @@ static int read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
AVStream *ast, *vst;
unsigned int version, frames_count, msecs_per_frame, player_version;
int ret;
ast = avformat_new_stream(s, NULL);
if (!ast)
@ -54,8 +55,8 @@ static int read_header(AVFormatContext *s)
if (!vst)
return AVERROR(ENOMEM);
if (ff_alloc_extradata(vst->codecpar, 2))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(vst->codecpar, 2)) < 0)
return ret;
version = avio_r8(pb);
vst->codecpar->extradata[0] = avio_r8(pb);

@ -427,8 +427,10 @@ 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(s, st->codecpar, bc, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
ret = ff_get_extradata(s, st->codecpar, bc,
st->codecpar->extradata_size);
if (ret < 0)
return ret;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {

@ -74,7 +74,7 @@ static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst,
if (!vst && !myth)
return 1; // no codec data needed
while (!avio_feof(pb)) {
int size, subtype;
int size, subtype, ret;
frametype = avio_r8(pb);
switch (frametype) {
@ -87,8 +87,8 @@ static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst,
av_freep(&vst->codecpar->extradata);
vst->codecpar->extradata_size = 0;
}
if (ff_get_extradata(NULL, vst->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(NULL, vst->codecpar, pb, size)) < 0)
return ret;
size = 0;
if (!myth)
return 0;

@ -37,6 +37,7 @@ static int celt_header(AVFormatContext *s, int idx)
AVStream *st = s->streams[idx];
struct oggcelt_private *priv = os->private;
uint8_t *p = os->buf + os->pstart;
int ret;
if (os->psize == 60 &&
!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {
@ -48,9 +49,10 @@ static int celt_header(AVFormatContext *s, int idx)
priv = av_malloc(sizeof(struct oggcelt_private));
if (!priv)
return AVERROR(ENOMEM);
if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {
ret = ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t));
if (ret < 0) {
av_free(priv);
return AVERROR(ENOMEM);
return ret;
}
version = AV_RL32(p + 28);
/* unused header size field skipped */

@ -34,7 +34,7 @@ flac_header (AVFormatContext * s, int idx)
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
GetBitContext gb;
int mdt;
int mdt, ret;
if (os->buf[os->pstart] == 0xff)
return 0;
@ -61,8 +61,8 @@ flac_header (AVFormatContext * s, int idx)
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE)) < 0)
return ret;
memcpy(st->codecpar->extradata, streaminfo_start, st->codecpar->extradata_size);
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;

@ -43,6 +43,7 @@ ogm_header(AVFormatContext *s, int idx)
uint64_t time_unit;
uint64_t spu;
uint32_t size;
int ret;
bytestream2_init(&p, os->buf + os->pstart, os->psize);
if (!(bytestream2_peek_byte(&p) & 1))
@ -109,8 +110,8 @@ ogm_header(AVFormatContext *s, int idx)
if (bytestream2_get_bytes_left(&p) < size)
return AVERROR_INVALIDDATA;
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
return ret;
bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);
}
}

@ -42,6 +42,7 @@ static int opus_header(AVFormatContext *avf, int idx)
AVStream *st = avf->streams[idx];
struct oggopus_private *priv = os->private;
uint8_t *packet = os->buf + os->pstart;
int ret;
if (!priv) {
priv = os->private = av_mallocz(sizeof(*priv));
@ -63,8 +64,8 @@ static int opus_header(AVFormatContext *avf, int idx)
/*channel_map = AV_RL8 (packet + 18);*/
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, os->psize))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, os->psize)) < 0)
return ret;
memcpy(st->codecpar->extradata, packet, os->psize);

@ -46,6 +46,7 @@ static int speex_header(AVFormatContext *s, int idx) {
struct speex_params *spxp = os->private;
AVStream *st = s->streams[idx];
uint8_t *p = os->buf + os->pstart;
int ret;
if (!spxp) {
spxp = av_mallocz(sizeof(*spxp));
@ -92,8 +93,8 @@ static int speex_header(AVFormatContext *s, int idx) {
if (frames_per_packet)
spxp->packet_size *= frames_per_packet;
if (ff_alloc_extradata(st->codecpar, os->psize) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, os->psize)) < 0)
return ret;
memcpy(st->codecpar->extradata, p, st->codecpar->extradata_size);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);

@ -459,8 +459,8 @@ static int oma_read_header(AVFormatContext *s)
/* fake the ATRAC3 extradata
* (wav format, makes stream copy to wav work) */
if (ff_alloc_extradata(st->codecpar, 14))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 14)) < 0)
return ret;
edata = st->codecpar->extradata;
AV_WL16(&edata[0], 1); // always 1

@ -194,7 +194,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
PAFDemuxContext *p = s->priv_data;
AVIOContext *pb = s->pb;
uint32_t count, offset;
int size, i;
int size, i, ret;
if (p->current_frame >= p->nb_frames)
return AVERROR_EOF;
@ -203,8 +203,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
if (p->got_audio) {
if (av_new_packet(pkt, p->audio_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, p->audio_size)) < 0)
return ret;
memcpy(pkt->data, p->temp_audio_frame, p->audio_size);
pkt->duration = PAF_SOUND_SAMPLES * (p->audio_size / PAF_SOUND_FRAME_SIZE);
@ -244,8 +244,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
size = p->video_size - p->frames_offset_table[p->current_frame];
if (av_new_packet(pkt, size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, size)) < 0)
return ret;
pkt->stream_index = 0;
pkt->duration = 1;

@ -39,8 +39,8 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
size = raw->raw_packet_size;
if (av_new_packet(pkt, size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, size)) < 0)
return ret;
pkt->pos= avio_tell(s->pb);
pkt->stream_index = 0;

@ -127,8 +127,9 @@ 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(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
ret = ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size);
if (ret < 0)
return ret;
/** setup audio stream if present */
if(sound_rate){

@ -87,9 +87,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(s, par, pb, size) < 0)
return AVERROR(ENOMEM);
return 0;
return ff_get_extradata(s, par, pb, size);
}
static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide)

@ -97,9 +97,8 @@ static int rsd_read_header(AVFormatContext *s)
switch (par->codec_id) {
case AV_CODEC_ID_XMA2:
par->block_align = 2048;
ff_alloc_extradata(par, 34);
if (!par->extradata)
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(par, 34)) < 0)
return ret;
memset(par->extradata, 0, 34);
break;
case AV_CODEC_ID_ADPCM_PSX:

@ -62,9 +62,9 @@ static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data,
av_log(ctx, AV_LOG_ERROR, "Invalid AC3 packet data\n");
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, len)) {
if ((err = av_new_packet(pkt, len)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
return err;
}
pkt->stream_index = st->index;

@ -51,7 +51,7 @@ static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
{
const uint8_t *frame_sizes = NULL;
int frames;
int i;
int i, ret;
const uint8_t *speech_data;
uint8_t *ptr;
@ -93,9 +93,9 @@ static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
speech_data = buf + 1 + frames;
/* Everything except the codec mode request byte should be output. */
if (av_new_packet(pkt, len - 1)) {
if ((ret = av_new_packet(pkt, len - 1)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
return AVERROR(ENOMEM);
return ret;
}
pkt->stream_index = st->index;
ptr = pkt->data;

@ -30,7 +30,7 @@ int ff_h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
{
uint8_t *ptr;
uint16_t header;
int startcode, vrc, picture_header;
int startcode, vrc, picture_header, ret;
if (len < 2) {
av_log(ctx, AV_LOG_ERROR, "Too short H.263 RTP packet\n");
@ -73,9 +73,9 @@ int ff_h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, len + startcode)) {
if ((ret = av_new_packet(pkt, len + startcode)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
return AVERROR(ENOMEM);
return ret;
}
pkt->stream_index = st->index;
ptr = pkt->data;

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

@ -90,9 +90,9 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data,
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, adu_size)) {
if ((err = av_new_packet(pkt, adu_size)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
return err;
}
pkt->stream_index = st->index;
@ -120,9 +120,9 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data,
if (!continuation && adu_size <= len) {
/* One or more complete frames */
if (av_new_packet(pkt, adu_size)) {
if ((err = av_new_packet(pkt, adu_size)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
return err;
}
pkt->stream_index = st->index;

@ -29,6 +29,7 @@ static int mpeg_parse_packet(AVFormatContext *ctx, PayloadContext *data,
int flags)
{
unsigned int h;
int ret;
if (len <= 4)
return AVERROR_INVALIDDATA;
h = AV_RB32(buf);
@ -41,8 +42,8 @@ static int mpeg_parse_packet(AVFormatContext *ctx, PayloadContext *data,
buf += 4;
len -= 4;
}
if (av_new_packet(pkt, len) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, len)) < 0)
return ret;
memcpy(pkt->data, buf, len);
pkt->stream_index = st->index;
return 0;

@ -112,10 +112,10 @@ static void close_context(PayloadContext *data)
static int parse_fmtp_config(AVCodecParameters *par, const char *value)
{
/* decode the hexa encoded parameter */
int len = ff_hex_to_data(NULL, value);
int len = ff_hex_to_data(NULL, value), ret;
av_freep(&par->extradata);
if (ff_alloc_extradata(par, len))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(par, len)) < 0)
return ret;
ff_hex_to_data(par->extradata, value);
return 0;
}

@ -78,6 +78,7 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st,
const uint8_t *buf, const uint8_t *end)
{
const uint8_t *p = buf;
int ret;
while (end - p >= 2) {
unsigned int item_len = p[0], config_item = p[1];
@ -105,8 +106,9 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st,
if (item_len < 30)
return AVERROR_INVALIDDATA;
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, 26 + item_len)) {
return AVERROR(ENOMEM);
ret = ff_alloc_extradata(st->codecpar, 26 + item_len);
if (ret < 0) {
return ret;
}
AV_WB32(st->codecpar->extradata, 12);
memcpy(st->codecpar->extradata + 4, "frma", 4);

@ -48,13 +48,13 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
GetBitContext gb;
int packing_scheme, has_payload_desc, has_packet_info, alen,
has_marker_bit = flags & RTP_FLAG_MARKER,
keyframe;
keyframe, ret;
if (qt->remaining) {
int num = qt->pkt.size / qt->bytes_per_frame;
if (av_new_packet(pkt, qt->bytes_per_frame))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, qt->bytes_per_frame)) < 0)
return ret;
pkt->stream_index = st->index;
pkt->flags = qt->pkt.flags;
memcpy(pkt->data,
@ -208,8 +208,8 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
alen % qt->bytes_per_frame != 0)
return AVERROR_INVALIDDATA; /* wrongly padded */
qt->remaining = (alen / qt->bytes_per_frame) - 1;
if (av_new_packet(pkt, qt->bytes_per_frame))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, qt->bytes_per_frame)) < 0)
return ret;
memcpy(pkt->data, buf + avio_tell(&pb), qt->bytes_per_frame);
pkt->flags = keyframe ? AV_PKT_FLAG_KEY : 0;
pkt->stream_index = st->index;

@ -63,7 +63,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
int flags)
{
int ident, fragmented, tdt, num_pkts, pkt_len;
int ident, fragmented, tdt, num_pkts, pkt_len, ret;
if (!buf) {
if (!data->split_buf || data->split_pos + 2 > data->split_buf_len ||
@ -77,9 +77,9 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
av_log(ctx, AV_LOG_ERROR, "Not enough data to return\n");
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, pkt_len)) {
if ((ret = av_new_packet(pkt, pkt_len)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
return ret;
}
pkt->stream_index = st->index;
memcpy(pkt->data, data->split_buf + data->split_pos, pkt_len);
@ -123,9 +123,9 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
len -= 6;
if (fragmented == 0) {
if (av_new_packet(pkt, pkt_len)) {
if ((ret = av_new_packet(pkt, pkt_len)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
return ret;
}
pkt->stream_index = st->index;
memcpy(pkt->data, buf, pkt_len);
@ -228,6 +228,7 @@ parse_packed_headers(AVFormatContext *s,
{
unsigned num_packed, num_headers, length, length1, length2, extradata_alloc;
int ret;
uint8_t *ptr;
if (packed_headers_end - packed_headers < 9) {
@ -264,9 +265,9 @@ parse_packed_headers(AVFormatContext *s,
* -- AV_INPUT_BUFFER_PADDING_SIZE required */
extradata_alloc = length + length/255 + 3 + AV_INPUT_BUFFER_PADDING_SIZE;
if (ff_alloc_extradata(par, extradata_alloc)) {
if ((ret = ff_alloc_extradata(par, extradata_alloc)) < 0) {
av_log(s, AV_LOG_ERROR, "Out of memory\n");
return AVERROR(ENOMEM);
return ret;
}
ptr = par->extradata;
*ptr++ = 2;

@ -1327,7 +1327,7 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
static int encode_intervals(struct sbg_script *s, AVCodecParameters *par,
struct ws_intervals *inter)
{
int i, edata_size = 4;
int i, edata_size = 4, ret;
uint8_t *edata;
for (i = 0; i < inter->nb_inter; i++) {
@ -1336,8 +1336,8 @@ static int encode_intervals(struct sbg_script *s, AVCodecParameters *par,
if (edata_size < 0)
return AVERROR(ENOMEM);
}
if (ff_alloc_extradata(par, edata_size))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(par, edata_size)) < 0)
return ret;
edata = par->extradata;
#define ADD_EDATA32(v) do { AV_WL32(edata, (v)); edata += 4; } while(0)
@ -1446,6 +1446,7 @@ fail:
static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
{
int64_t ts, end_ts;
int ret;
ts = avf->streams[0]->cur_dts;
end_ts = ts + avf->streams[0]->codecpar->frame_size;
@ -1454,8 +1455,8 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
end_ts);
if (end_ts <= ts)
return AVERROR_EOF;
if (av_new_packet(packet, 12) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(packet, 12)) < 0)
return ret;
packet->dts = packet->pts = ts;
packet->duration = end_ts - ts;
AV_WL64(packet->data + 0, ts);

@ -90,8 +90,8 @@ static int sdr2_read_packet(AVFormatContext *s, AVPacket *pkt)
avio_skip(s->pb, 30);
if (pos == FIRST) {
if (av_new_packet(pkt, next - 52 + 24) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, next - 52 + 24)) < 0)
return ret;
memcpy(pkt->data, header, 24);
ret = avio_read(s->pb, pkt->data + 24, next - 52);
if (ret < 0) {

@ -127,8 +127,8 @@ static int vmd_read_header(AVFormatContext *s)
vst->codecpar->width >>= 1;
vst->codecpar->height >>= 1;
}
if (ff_alloc_extradata(vst->codecpar, VMD_HEADER_SIZE))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(vst->codecpar, VMD_HEADER_SIZE)) < 0)
return ret;
memcpy(vst->codecpar->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
}
@ -283,8 +283,9 @@ static int vmd_read_packet(AVFormatContext *s,
if(ffio_limit(pb, frame->frame_size) != frame->frame_size)
return AVERROR(EIO);
if (av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD))
return AVERROR(ENOMEM);
ret = av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD);
if (ret < 0)
return ret;
pkt->pos= avio_tell(pb);
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
if(vmd->is_indeo3 && frame->frame_record[0] == 0x02)

@ -192,6 +192,7 @@ static int siff_read_header(AVFormatContext *s)
static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
{
SIFFContext *c = s->priv_data;
int ret;
if (c->has_video) {
unsigned int size;
@ -213,8 +214,8 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
size = c->pktsize - c->sndsize - c->gmcsize - 2;
size = ffio_limit(s->pb, size);
if (av_new_packet(pkt, size + c->gmcsize + 2) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, size + c->gmcsize + 2)) < 0)
return ret;
AV_WL16(pkt->data, c->flags);
if (c->gmcsize)
memcpy(pkt->data + 2, c->gmc, c->gmcsize);

@ -233,13 +233,13 @@ static int smacker_read_header(AVFormatContext *s)
/* load trees to extradata, they will be unpacked by decoder */
if(ff_alloc_extradata(st->codecpar, smk->treesize + 16)){
if ((ret = ff_alloc_extradata(st->codecpar, smk->treesize + 16)) < 0) {
av_log(s, AV_LOG_ERROR,
"Cannot allocate %"PRIu32" bytes of extradata\n",
smk->treesize + 16);
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(ENOMEM);
return ret;
}
ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_size - 16);
if(ret != st->codecpar->extradata_size - 16){
@ -353,8 +353,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
}
if (frame_size < 0 || frame_size >= INT_MAX/2)
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, frame_size + 769))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, frame_size + 769)) < 0)
return ret;
if(smk->frm_size[smk->cur_frame] & 1)
palchange |= 2;
pkt->data[0] = palchange;
@ -370,8 +370,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
} else {
if (smk->stream_id[smk->curstream] < 0 || !smk->bufs[smk->curstream])
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, smk->buf_sizes[smk->curstream]))
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, smk->buf_sizes[smk->curstream])) < 0)
return ret;
memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]);
pkt->size = smk->buf_sizes[smk->curstream];
pkt->stream_index = smk->stream_id[smk->curstream];

@ -51,6 +51,7 @@ static int smush_read_header(AVFormatContext *ctx)
uint32_t magic, nframes, size, subversion, i;
uint32_t width = 0, height = 0, got_audio = 0, read = 0;
uint32_t sample_rate, channels, palette[256];
int ret;
magic = avio_rb32(pb);
avio_skip(pb, 4); // skip movie size
@ -157,8 +158,8 @@ static int smush_read_header(AVFormatContext *ctx)
vst->codecpar->height = height;
if (!smush->version) {
if (ff_alloc_extradata(vst->codecpar, 1024 + 2))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(vst->codecpar, 1024 + 2)) < 0)
return ret;
AV_WL16(vst->codecpar->extradata, subversion);
for (i = 0; i < 256; i++)

@ -211,11 +211,12 @@ void ff_subtitles_queue_finalize(void *log_ctx, FFDemuxSubtitlesQueue *q)
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
{
AVPacket *sub = q->subs + q->current_sub_idx;
int ret;
if (q->current_sub_idx == q->nb_subs)
return AVERROR_EOF;
if (av_packet_ref(pkt, sub) < 0) {
return AVERROR(ENOMEM);
if ((ret = av_packet_ref(pkt, sub)) < 0) {
return ret;
}
pkt->dts = pkt->pts;

@ -273,8 +273,10 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
/* video packet */
if (seq->current_pal_data_size + seq->current_video_data_size != 0) {
if (av_new_packet(pkt, 1 + seq->current_pal_data_size + seq->current_video_data_size))
return AVERROR(ENOMEM);
rc = av_new_packet(pkt, 1 + seq->current_pal_data_size
+ seq->current_video_data_size);
if (rc < 0)
return rc;
pkt->data[0] = 0;
if (seq->current_pal_data_size) {

@ -454,7 +454,7 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
TYDemuxContext *ty = s->priv_data;
const int subrec_type = rec_hdr->subrec_type;
const int64_t rec_size = rec_hdr->rec_size;
int es_offset1;
int es_offset1, ret;
int got_packet = 0;
if (subrec_type != 0x02 && subrec_type != 0x0c &&
@ -474,8 +474,8 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
int size = rec_hdr->rec_size - VIDEO_PES_LENGTH - es_offset1;
ty->cur_chunk_pos += VIDEO_PES_LENGTH + es_offset1;
if (av_new_packet(pkt, size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, size)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, size);
ty->cur_chunk_pos += size;
pkt->stream_index = 0;
@ -498,8 +498,8 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
}
if (!got_packet) {
if (av_new_packet(pkt, rec_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, rec_size)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 0;
@ -578,7 +578,7 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
TYDemuxContext *ty = s->priv_data;
const int subrec_type = rec_hdr->subrec_type;
const int64_t rec_size = rec_hdr->rec_size;
int es_offset1;
int es_offset1, ret;
if (subrec_type == 2) {
int need = 0;
@ -621,8 +621,8 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
ty->pes_buf_cnt = 0;
}
if (av_new_packet(pkt, rec_size - need) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, rec_size - need)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size - need);
ty->cur_chunk_pos += rec_size - need;
pkt->stream_index = 1;
@ -643,8 +643,8 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
}
}
} else if (subrec_type == 0x03) {
if (av_new_packet(pkt, rec_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, rec_size)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 1;
@ -674,15 +674,15 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
} else if (subrec_type == 0x04) {
/* SA Audio with no PES Header */
/* ================================================ */
if (av_new_packet(pkt, rec_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, rec_size)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 1;
pkt->pts = ty->last_audio_pts;
} else if (subrec_type == 0x09) {
if (av_new_packet(pkt, rec_size) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, rec_size)) < 0)
return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size ;
pkt->stream_index = 1;

@ -5451,7 +5451,7 @@ int ff_generate_avci_extradata(AVStream *st)
};
const uint8_t *data = NULL;
int size = 0;
int ret, size = 0;
if (st->codecpar->width == 1920) {
if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
@ -5481,8 +5481,8 @@ int ff_generate_avci_extradata(AVStream *st)
return 0;
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, size))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
return ret;
memcpy(st->codecpar->extradata, data, size);
return 0;

@ -51,7 +51,7 @@ static int vc1t_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVStream *st;
int frames;
int frames, ret;
uint32_t fps;
uint32_t size;
@ -67,8 +67,8 @@ 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(s, st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, VC1_EXTRADATA_SIZE)) < 0)
return ret;
avio_skip(pb, size - 4);
st->codecpar->height = avio_rl32(pb);

@ -278,7 +278,7 @@ static uint8_t *read_sb_block(AVIOContext *src, unsigned *size,
static int track_header(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *buf, int size)
{
int i,j;
int i, j, ret;
int64_t off;
int val_1;
int num_video;
@ -391,10 +391,9 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *
xd_size += len;
}
st->codecpar->extradata_size = 64 + xd_size + xd_size / 255;
if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size)) {
return AVERROR(ENOMEM);
}
ret = ff_alloc_extradata(st->codecpar, 64 + xd_size + xd_size / 255);
if (ret < 0)
return ret;
p = st->codecpar->extradata;
p[0] = 2;

@ -97,7 +97,7 @@ static int vqf_read_header(AVFormatContext *s)
int rate_flag = -1;
int header_size;
int read_bitrate = 0;
int size;
int size, ret;
uint8_t comm_chunk[12];
if (!st)
@ -222,8 +222,8 @@ static int vqf_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, size, st->codecpar->sample_rate);
/* put first 12 bytes of COMM chunk in extradata */
if (ff_alloc_extradata(st->codecpar, 12))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 12)) < 0)
return ret;
memcpy(st->codecpar->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);

@ -181,7 +181,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
{
AVIOContext *pb = s->pb;
int version, num_streams, i, channels = 0;
int version, num_streams, i, channels = 0, ret;
if (size < 36)
return AVERROR_INVALIDDATA;
@ -221,8 +221,8 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
avio_seek(pb, -size, SEEK_CUR);
av_freep(&(*st)->codecpar->extradata);
if (ff_get_extradata(s, (*st)->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, (*st)->codecpar, pb, size)) < 0)
return ret;
return 0;
}
@ -473,9 +473,9 @@ static int wav_read_header(AVFormatContext *s)
vst->codecpar->codec_id = AV_CODEC_ID_SMVJPEG;
vst->codecpar->width = avio_rl24(pb);
vst->codecpar->height = avio_rl24(pb);
if (ff_alloc_extradata(vst->codecpar, 4)) {
if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n");
return AVERROR(ENOMEM);
return ret;
}
size = avio_rl24(pb);
wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3;

@ -85,7 +85,7 @@ static int wsvqa_read_header(AVFormatContext *s)
uint8_t scratch[VQA_PREAMBLE_SIZE];
uint32_t chunk_tag;
uint32_t chunk_size;
int fps;
int fps, ret;
/* initialize the video decoder stream */
st = avformat_new_stream(s, NULL);
@ -101,8 +101,8 @@ 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(s, st->codecpar, pb, VQA_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_get_extradata(s, st->codecpar, pb, VQA_HEADER_SIZE)) < 0)
return ret;
header = st->codecpar->extradata;
st->codecpar->width = AV_RL16(&header[6]);
st->codecpar->height = AV_RL16(&header[8]);
@ -214,8 +214,8 @@ static int wsvqa_read_packet(AVFormatContext *s,
break;
case SND2_TAG:
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 2)) < 0)
return ret;
AV_WL16(st->codecpar->extradata, wsvqa->version);
break;
}

@ -282,8 +282,8 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
}
pos = wc->pos;
if (av_new_packet(pkt, wc->header.blocksize + WV_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
if ((ret = av_new_packet(pkt, wc->header.blocksize + WV_HEADER_SIZE)) < 0)
return ret;
memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
if (ret != wc->header.blocksize) {

@ -130,15 +130,15 @@ static int xwma_read_header(AVFormatContext *s)
avpriv_request_sample(s, "Unexpected extradata (%d bytes)",
st->codecpar->extradata_size);
} else if (st->codecpar->codec_id == AV_CODEC_ID_WMAPRO) {
if (ff_alloc_extradata(st->codecpar, 18))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 18)) < 0)
return ret;
memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
st->codecpar->extradata[ 0] = st->codecpar->bits_per_coded_sample;
st->codecpar->extradata[14] = 224;
} else {
if (ff_alloc_extradata(st->codecpar, 6))
return AVERROR(ENOMEM);
if ((ret = ff_alloc_extradata(st->codecpar, 6)) < 0)
return ret;
memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
/* setup extradata with our experimentally obtained value */

Loading…
Cancel
Save