Browse Source

avformat: Remove unnecessary av_packet_unref()

Since bae8844e the packet will always be unreferenced when a demuxer
returns an error, so that a lot of calls to av_packet_unref() in lots of
demuxers are now redundant and can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
tags/n4.3
Andreas Rheinhardt Marton Balint 5 years ago
parent
commit
6a67d518d6
52 changed files with 17 additions and 108 deletions
  1. +0
    -6
      libavformat/aacdec.c
  2. +0
    -1
      libavformat/adp.c
  3. +0
    -2
      libavformat/adxdec.c
  4. +0
    -1
      libavformat/amr.c
  5. +0
    -1
      libavformat/ape.c
  6. +0
    -1
      libavformat/avs.c
  7. +1
    -2
      libavformat/brstm.c
  8. +3
    -10
      libavformat/c93.c
  9. +0
    -1
      libavformat/cdxl.c
  10. +1
    -3
      libavformat/concatdec.c
  11. +0
    -3
      libavformat/dfa.c
  12. +0
    -1
      libavformat/dsicin.c
  13. +1
    -5
      libavformat/dss.c
  14. +0
    -1
      libavformat/dxa.c
  15. +0
    -3
      libavformat/electronicarts.c
  16. +0
    -2
      libavformat/fitsdec.c
  17. +1
    -2
      libavformat/flic.c
  18. +0
    -1
      libavformat/g723_1.c
  19. +0
    -1
      libavformat/gdv.c
  20. +0
    -1
      libavformat/gsmdec.c
  21. +0
    -1
      libavformat/hls.c
  22. +0
    -1
      libavformat/icodec.c
  23. +0
    -2
      libavformat/idcin.c
  24. +1
    -2
      libavformat/idroqdec.c
  25. +0
    -1
      libavformat/ilbc.c
  26. +0
    -1
      libavformat/img2dec.c
  27. +0
    -1
      libavformat/iv8.c
  28. +0
    -1
      libavformat/libmodplug.c
  29. +0
    -1
      libavformat/lxfdec.c
  30. +0
    -1
      libavformat/mov.c
  31. +0
    -1
      libavformat/mpc.c
  32. +0
    -1
      libavformat/mpegts.c
  33. +0
    -2
      libavformat/mpjpegdec.c
  34. +0
    -1
      libavformat/ncdec.c
  35. +0
    -1
      libavformat/nuv.c
  36. +2
    -5
      libavformat/oggdec.c
  37. +0
    -1
      libavformat/redspark.c
  38. +0
    -1
      libavformat/rl2.c
  39. +0
    -2
      libavformat/rpl.c
  40. +0
    -2
      libavformat/s337m.c
  41. +0
    -1
      libavformat/sapdec.c
  42. +0
    -1
      libavformat/sdr2.c
  43. +0
    -1
      libavformat/sierravmd.c
  44. +0
    -1
      libavformat/siff.c
  45. +1
    -4
      libavformat/spdifdec.c
  46. +0
    -3
      libavformat/swfdec.c
  47. +0
    -2
      libavformat/thp.c
  48. +5
    -9
      libavformat/vivo.c
  49. +1
    -3
      libavformat/vpk.c
  50. +0
    -1
      libavformat/vqf.c
  51. +0
    -4
      libavformat/wvdec.c
  52. +0
    -1
      libavformat/yuv4mpegdec.c

+ 0
- 6
libavformat/aacdec.c View File

@@ -141,7 +141,6 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt)


ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size); ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }


@@ -174,7 +173,6 @@ retry:
return ret; return ret;


if (ret < ADTS_HEADER_SIZE) { if (ret < ADTS_HEADER_SIZE) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }


@@ -185,7 +183,6 @@ retry:
av_assert2(append > 0); av_assert2(append > 0);
ret = av_append_packet(s->pb, pkt, append); ret = av_append_packet(s->pb, pkt, append);
if (ret != append) { if (ret != append) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) { if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
@@ -201,13 +198,10 @@ retry:


fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF; fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
if (fsize < ADTS_HEADER_SIZE) { if (fsize < ADTS_HEADER_SIZE) {
av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }


ret = av_append_packet(s->pb, pkt, fsize - pkt->size); ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
if (ret < 0)
av_packet_unref(pkt);


return ret; return ret;
} }


+ 0
- 1
libavformat/adp.c View File

@@ -78,7 +78,6 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)


if (ret != size) { if (ret != size) {
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
av_shrink_packet(pkt, ret); av_shrink_packet(pkt, ret);


+ 0
- 2
libavformat/adxdec.c View File

@@ -65,11 +65,9 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO); return ret < 0 ? ret : AVERROR(EIO);
} }
if (AV_RB16(pkt->data) & 0x8000) { if (AV_RB16(pkt->data) & 0x8000) {
av_packet_unref(pkt);
return AVERROR_EOF; return AVERROR_EOF;
} }
pkt->size = size; pkt->size = size;


+ 0
- 1
libavformat/amr.c View File

@@ -153,7 +153,6 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
read = avio_read(s->pb, pkt->data + 1, size - 1); read = avio_read(s->pb, pkt->data + 1, size - 1);


if (read != size - 1) { if (read != size - 1) {
av_packet_unref(pkt);
if (read < 0) if (read < 0)
return read; return read;
return AVERROR(EIO); return AVERROR(EIO);


+ 0
- 1
libavformat/ape.c View File

@@ -419,7 +419,6 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip); AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size); ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }




+ 0
- 1
libavformat/avs.c View File

@@ -114,7 +114,6 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
pkt->data[palette_size + 3] = (size >> 8) & 0xFF; pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4; ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
if (ret < size) { if (ret < size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 1
- 2
libavformat/brstm.c View File

@@ -422,8 +422,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
dst += size; dst += size;
avio_skip(s->pb, skip); avio_skip(s->pb, skip);
if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
break;
return AVERROR(EIO);
} }
} }
pkt->duration = samples; pkt->duration = samples;


+ 3
- 10
libavformat/c93.c View File

@@ -158,22 +158,19 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)


ret = avio_read(pb, pkt->data + 1, datasize); ret = avio_read(pb, pkt->data + 1, datasize);
if (ret < datasize) { if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
return AVERROR(EIO);
} }


datasize = avio_rl16(pb); /* palette size */ datasize = avio_rl16(pb); /* palette size */
if (datasize) { if (datasize) {
if (datasize != 768) { if (datasize != 768) {
av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize); av_log(s, AV_LOG_ERROR, "invalid palette size %u\n", datasize);
ret = AVERROR_INVALIDDATA;
goto fail;
return AVERROR_INVALIDDATA;
} }
pkt->data[0] |= C93_HAS_PALETTE; pkt->data[0] |= C93_HAS_PALETTE;
ret = avio_read(pb, pkt->data + pkt->size, datasize); ret = avio_read(pb, pkt->data + pkt->size, datasize);
if (ret < datasize) { if (ret < datasize) {
ret = AVERROR(EIO);
goto fail;
return AVERROR(EIO);
} }
pkt->size += 768; pkt->size += 768;
} }
@@ -186,10 +183,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] |= C93_FIRST_FRAME; pkt->data[0] |= C93_FIRST_FRAME;
} }
return 0; return 0;

fail:
av_packet_unref(pkt);
return ret;
} }


AVInputFormat ff_c93_demuxer = { AVInputFormat ff_c93_demuxer = {


+ 0
- 1
libavformat/cdxl.c View File

@@ -207,7 +207,6 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE); memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size); ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret); av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);


+ 1
- 3
libavformat/concatdec.c View File

@@ -542,7 +542,6 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
if (ret < 0) { if (ret < 0) {
av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter " av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter "
"failed to send input packet\n"); "failed to send input packet\n");
av_packet_unref(pkt);
return ret; return ret;
} }


@@ -592,7 +591,6 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((ret = match_streams(avf)) < 0) { if ((ret = match_streams(avf)) < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
if (packet_after_outpoint(cat, pkt)) { if (packet_after_outpoint(cat, pkt)) {
@@ -608,7 +606,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
} }
break; break;
} }
if ((ret = filter_packet(avf, cs, pkt)))
if ((ret = filter_packet(avf, cs, pkt)) < 0)
return ret; return ret;


st = cat->avf->streams[pkt->stream_index]; st = cat->avf->streams[pkt->stream_index];


+ 0
- 3
libavformat/dfa.c View File

@@ -93,7 +93,6 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!first) { if (!first) {
ret = av_append_packet(pb, pkt, 12); ret = av_append_packet(pb, pkt, 12);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
} else } else
@@ -101,7 +100,6 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
frame_size = AV_RL32(pkt->data + pkt->size - 8); frame_size = AV_RL32(pkt->data + pkt->size - 8);
if (frame_size > INT_MAX - 4) { if (frame_size > INT_MAX - 4) {
av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size); av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) { if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
@@ -115,7 +113,6 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
ret = av_append_packet(pb, pkt, frame_size); ret = av_append_packet(pb, pkt, frame_size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
} }


+ 0
- 1
libavformat/dsicin.c View File

@@ -200,7 +200,6 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = avio_read(pb, &pkt->data[4], pkt_size); ret = avio_read(pb, &pkt->data[4], pkt_size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
if (ret < pkt_size) if (ret < pkt_size)


+ 1
- 5
libavformat/dss.c View File

@@ -259,14 +259,12 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
dss_sp_byte_swap(ctx, pkt->data, ctx->dss_sp_buf); dss_sp_byte_swap(ctx, pkt->data, ctx->dss_sp_buf);


if (ctx->dss_sp_swap_byte < 0) { if (ctx->dss_sp_swap_byte < 0) {
ret = AVERROR(EAGAIN);
goto error_eof;
return AVERROR(EAGAIN);
} }


return pkt->size; return pkt->size;


error_eof: error_eof:
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF; return ret < 0 ? ret : AVERROR_EOF;
} }


@@ -308,7 +306,6 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = avio_read(s->pb, pkt->data + offset, ret = avio_read(s->pb, pkt->data + offset,
size2 - offset); size2 - offset);
if (ret < size2 - offset) { if (ret < size2 - offset) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF; return ret < 0 ? ret : AVERROR_EOF;
} }


@@ -318,7 +315,6 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = avio_read(s->pb, pkt->data + offset, size - offset); ret = avio_read(s->pb, pkt->data + offset, size - offset);
if (ret < size - offset) { if (ret < size - offset) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF; return ret < 0 ? ret : AVERROR_EOF;
} }




+ 0
- 1
libavformat/dxa.c View File

@@ -210,7 +210,6 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE); memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size); ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){ if(ret != size){
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
if(pal_size) memcpy(pkt->data, pal, pal_size); if(pal_size) memcpy(pkt->data, pal, pal_size);


+ 0
- 3
libavformat/electronicarts.c View File

@@ -633,7 +633,6 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
case AV_CODEC_ID_ADPCM_EA_R3: case AV_CODEC_ID_ADPCM_EA_R3:
if (pkt->size < 4) { if (pkt->size < 4) {
av_log(s, AV_LOG_ERROR, "Packet is too short\n"); av_log(s, AV_LOG_ERROR, "Packet is too short\n");
av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3) if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
@@ -736,8 +735,6 @@ get_video_packet:
} }
} }


if (ret < 0 && partial_packet)
av_packet_unref(pkt);
if (ret >= 0 && hit_end && !packet_read) if (ret >= 0 && hit_end && !packet_read)
return AVERROR(EAGAIN); return AVERROR(EAGAIN);




+ 0
- 2
libavformat/fitsdec.c View File

@@ -183,7 +183,6 @@ static int fits_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = av_bprint_finalize(&avbuf, &buf); ret = av_bprint_finalize(&avbuf, &buf);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }


@@ -192,7 +191,6 @@ static int fits_read_packet(AVFormatContext *s, AVPacket *pkt)
av_freep(&buf); av_freep(&buf);
ret = avio_read(s->pb, pkt->data + pkt->size, size); ret = avio_read(s->pb, pkt->data + pkt->size, size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }




+ 1
- 2
libavformat/flic.c View File

@@ -225,7 +225,6 @@ static int flic_read_packet(AVFormatContext *s,
ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE, ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
size - FLIC_PREAMBLE_SIZE); size - FLIC_PREAMBLE_SIZE);
if (ret != size - FLIC_PREAMBLE_SIZE) { if (ret != size - FLIC_PREAMBLE_SIZE) {
av_packet_unref(pkt);
ret = AVERROR(EIO); ret = AVERROR(EIO);
} }
packet_read = 1; packet_read = 1;
@@ -241,8 +240,8 @@ static int flic_read_packet(AVFormatContext *s,
ret = avio_read(pb, pkt->data, size); ret = avio_read(pb, pkt->data, size);


if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
ret = AVERROR(EIO); ret = AVERROR(EIO);
break;
} }


packet_read = 1; packet_read = 1;


+ 0
- 1
libavformat/g723_1.c View File

@@ -69,7 +69,6 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = avio_read(s->pb, pkt->data + 1, size - 1); ret = avio_read(s->pb, pkt->data + 1, size - 1);
if (ret < size - 1) { if (ret < size - 1) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF; return ret < 0 ? ret : AVERROR_EOF;
} }




+ 0
- 1
libavformat/gdv.c View File

@@ -182,7 +182,6 @@ static int gdv_read_packet(AVFormatContext *ctx, AVPacket *pkt)
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
AVPALETTE_SIZE); AVPALETTE_SIZE);
if (!pal) { if (!pal) {
av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
memcpy(pal, gdv->pal, AVPALETTE_SIZE); memcpy(pal, gdv->pal, AVPALETTE_SIZE);


+ 0
- 1
libavformat/gsmdec.c View File

@@ -62,7 +62,6 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
if (ret < GSM_BLOCK_SIZE) { if (ret < GSM_BLOCK_SIZE) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO); return ret < 0 ? ret : AVERROR(EIO);
} }
pkt->duration = 1; pkt->duration = 1;


+ 0
- 1
libavformat/hls.c View File

@@ -2225,7 +2225,6 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ist->codecpar->codec_id != st->codecpar->codec_id) { if (ist->codecpar->codec_id != st->codecpar->codec_id) {
ret = set_stream_info_from_input_stream(st, pls, ist); ret = set_stream_info_from_input_stream(st, pls, ist);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
} }


+ 0
- 1
libavformat/icodec.c View File

@@ -185,7 +185,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
bytestream_put_le32(&buf, 0); bytestream_put_le32(&buf, 0);


if ((ret = avio_read(pb, buf, image->size)) != image->size) { if ((ret = avio_read(pb, buf, image->size)) != image->size) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_INVALIDDATA; return ret < 0 ? ret : AVERROR_INVALIDDATA;
} }




+ 0
- 2
libavformat/idcin.c View File

@@ -313,7 +313,6 @@ static int idcin_read_packet(AVFormatContext *s,
return ret; return ret;
else if (ret != chunk_size) { else if (ret != chunk_size) {
av_log(s, AV_LOG_ERROR, "incomplete packet\n"); av_log(s, AV_LOG_ERROR, "incomplete packet\n");
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
if (command == 1) { if (command == 1) {
@@ -322,7 +321,6 @@ static int idcin_read_packet(AVFormatContext *s,
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
AVPALETTE_SIZE); AVPALETTE_SIZE);
if (!pal) { if (!pal) {
av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
memcpy(pal, palette, AVPALETTE_SIZE); memcpy(pal, palette, AVPALETTE_SIZE);


+ 1
- 2
libavformat/idroqdec.c View File

@@ -224,8 +224,7 @@ static int roq_read_packet(AVFormatContext *s,
ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE, ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
chunk_size); chunk_size);
if (ret != chunk_size) { if (ret != chunk_size) {
av_packet_unref(pkt);
ret = AVERROR(EIO);
return AVERROR(EIO);
} }


packet_read = 1; packet_read = 1;


+ 0
- 1
libavformat/ilbc.c View File

@@ -111,7 +111,6 @@ static int ilbc_read_packet(AVFormatContext *s,
pkt->pos = avio_tell(s->pb); pkt->pos = avio_tell(s->pb);
pkt->duration = par->block_align == 38 ? 160 : 240; pkt->duration = par->block_align == 38 ? 160 : 240;
if ((ret = avio_read(s->pb, pkt->data, par->block_align)) != par->block_align) { if ((ret = avio_read(s->pb, pkt->data, par->block_align)) != par->block_align) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO); return ret < 0 ? ret : AVERROR(EIO);
} }




+ 0
- 1
libavformat/img2dec.c View File

@@ -542,7 +542,6 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
} }


if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) { if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
av_packet_unref(pkt);
if (ret[0] < 0) { if (ret[0] < 0) {
res = ret[0]; res = ret[0];
} else if (ret[1] < 0) { } else if (ret[1] < 0) {


+ 0
- 1
libavformat/iv8.c View File

@@ -92,7 +92,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_append_packet(s->pb, pkt, size); ret = av_append_packet(s->pb, pkt, size);
if (ret < 0) { if (ret < 0) {
av_log(s, AV_LOG_ERROR, "failed to grow packet\n"); av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
av_packet_unref(pkt);
return ret; return ret;
} }
} }


+ 0
- 1
libavformat/libmodplug.c View File

@@ -327,7 +327,6 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)


pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE); pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE);
if (pkt->size <= 0) { if (pkt->size <= 0) {
av_packet_unref(pkt);
return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO); return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO);
} }
return 0; return 0;


+ 0
- 1
libavformat/lxfdec.c View File

@@ -316,7 +316,6 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret2; return ret2;


if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) { if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
av_packet_unref(pkt);
return ret2 < 0 ? ret2 : AVERROR_EOF; return ret2 < 0 ? ret2 : AVERROR_EOF;
} }




+ 0
- 1
libavformat/mov.c View File

@@ -7890,7 +7890,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = cenc_filter(mov, st, sc, pkt, current_index); ret = cenc_filter(mov, st, sc, pkt, current_index);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }




+ 0
- 1
libavformat/mpc.c View File

@@ -169,7 +169,6 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
if(c->curbits) if(c->curbits)
avio_seek(s->pb, -4, SEEK_CUR); avio_seek(s->pb, -4, SEEK_CUR);
if(ret < size){ if(ret < size){
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO); return ret < 0 ? ret : AVERROR(EIO);
} }
pkt->size = ret + 4; pkt->size = ret + 4;


+ 0
- 1
libavformat/mpegts.c View File

@@ -3133,7 +3133,6 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = read_packet(s, pkt->data, ts->raw_packet_size, &data); ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
pkt->pos = avio_tell(s->pb); pkt->pos = avio_tell(s->pb);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
if (data != pkt->data) if (data != pkt->data)


+ 0
- 2
libavformat/mpjpegdec.c View File

@@ -359,8 +359,6 @@ static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
/* error or EOF occurred */ /* error or EOF occurred */
if (ret == AVERROR_EOF) { if (ret == AVERROR_EOF) {
ret = pkt->size > 0 ? pkt->size : AVERROR_EOF; ret = pkt->size > 0 ? pkt->size : AVERROR_EOF;
} else {
av_packet_unref(pkt);
} }
} }




+ 0
- 1
libavformat/ncdec.c View File

@@ -83,7 +83,6 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
if (ret != size) { if (ret != size) {
if (ret > 0) av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 0
- 1
libavformat/nuv.c View File

@@ -284,7 +284,6 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data, hdr, copyhdrsize); memcpy(pkt->data, hdr, copyhdrsize);
ret = avio_read(pb, pkt->data + copyhdrsize, size); ret = avio_read(pb, pkt->data + copyhdrsize, size);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
if (ret < size) if (ret < size)


+ 2
- 5
libavformat/oggdec.c View File

@@ -851,7 +851,7 @@ retry:
AV_PKT_DATA_SKIP_SAMPLES, AV_PKT_DATA_SKIP_SAMPLES,
10); 10);
if(!side_data) if(!side_data)
goto fail;
return AVERROR(ENOMEM);
AV_WL32(side_data + 4, os->end_trimming); AV_WL32(side_data + 4, os->end_trimming);
os->end_trimming = 0; os->end_trimming = 0;
} }
@@ -861,7 +861,7 @@ retry:
AV_PKT_DATA_METADATA_UPDATE, AV_PKT_DATA_METADATA_UPDATE,
os->new_metadata_size); os->new_metadata_size);
if(!side_data) if(!side_data)
goto fail;
return AVERROR(ENOMEM);


memcpy(side_data, os->new_metadata, os->new_metadata_size); memcpy(side_data, os->new_metadata, os->new_metadata_size);
av_freep(&os->new_metadata); av_freep(&os->new_metadata);
@@ -869,9 +869,6 @@ retry:
} }


return psize; return psize;
fail:
av_packet_unref(pkt);
return AVERROR(ENOMEM);
} }


static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,


+ 0
- 1
libavformat/redspark.c View File

@@ -140,7 +140,6 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)


ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 0
- 1
libavformat/rl2.c View File

@@ -256,7 +256,6 @@ static int rl2_read_packet(AVFormatContext *s,
/** fill the packet */ /** fill the packet */
ret = av_get_packet(pb, pkt, sample->size); ret = av_get_packet(pb, pkt, sample->size);
if(ret != sample->size){ if(ret != sample->size){
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 0
- 2
libavformat/rpl.c View File

@@ -338,7 +338,6 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != frame_size) { if (ret != frame_size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
pkt->duration = 1; pkt->duration = 1;
@@ -355,7 +354,6 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != index_entry->size) { if (ret != index_entry->size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 0
- 2
libavformat/s337m.c View File

@@ -174,7 +174,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = pos; pkt->pos = pos;


if (avio_read(pb, pkt->data, pkt->size) < pkt->size) { if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
av_packet_unref(pkt);
return AVERROR_EOF; return AVERROR_EOF;
} }


@@ -186,7 +185,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!s->nb_streams) { if (!s->nb_streams) {
AVStream *st = avformat_new_stream(s, NULL); AVStream *st = avformat_new_stream(s, NULL);
if (!st) { if (!st) {
av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;


+ 0
- 1
libavformat/sapdec.c View File

@@ -225,7 +225,6 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
int i = s->nb_streams; int i = s->nb_streams;
AVStream *st = avformat_new_stream(s, NULL); AVStream *st = avformat_new_stream(s, NULL);
if (!st) { if (!st) {
av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
st->id = i; st->id = i;


+ 0
- 1
libavformat/sdr2.c View File

@@ -95,7 +95,6 @@ static int sdr2_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data, header, 24); memcpy(pkt->data, header, 24);
ret = avio_read(s->pb, pkt->data + 24, next - 52); ret = avio_read(s->pb, pkt->data + 24, next - 52);
if (ret < 0) { if (ret < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
av_shrink_packet(pkt, ret + 24); av_shrink_packet(pkt, ret + 24);


+ 0
- 1
libavformat/sierravmd.c View File

@@ -295,7 +295,6 @@ static int vmd_read_packet(AVFormatContext *s,
frame->frame_size); frame->frame_size);


if (ret != frame->frame_size) { if (ret != frame->frame_size) {
av_packet_unref(pkt);
ret = AVERROR(EIO); ret = AVERROR(EIO);
} }
pkt->stream_index = frame->stream_index; pkt->stream_index = frame->stream_index;


+ 0
- 1
libavformat/siff.c View File

@@ -220,7 +220,6 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (c->gmcsize) if (c->gmcsize)
memcpy(pkt->data + 2, c->gmc, c->gmcsize); memcpy(pkt->data + 2, c->gmc, c->gmcsize);
if (avio_read(s->pb, pkt->data + 2 + c->gmcsize, size) != size) { if (avio_read(s->pb, pkt->data + 2 + c->gmcsize, size) != size) {
av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
pkt->stream_index = 0; pkt->stream_index = 0;


+ 1
- 4
libavformat/spdifdec.c View File

@@ -197,15 +197,13 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE; pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;


if (avio_read(pb, pkt->data, pkt->size) < pkt->size) { if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
av_packet_unref(pkt);
return AVERROR_EOF; return AVERROR_EOF;
} }
ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1); ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);


ret = spdif_get_offset_and_codec(s, data_type, pkt->data, ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
&offset, &codec_id); &offset, &codec_id);
if (ret) {
av_packet_unref(pkt);
if (ret < 0) {
return ret; return ret;
} }


@@ -216,7 +214,6 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
/* first packet, create a stream */ /* first packet, create a stream */
AVStream *st = avformat_new_stream(s, NULL); AVStream *st = avformat_new_stream(s, NULL);
if (!st) { if (!st) {
av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;


+ 0
- 3
libavformat/swfdec.c View File

@@ -399,7 +399,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)


if (linesize * height > pkt->size) { if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA; res = AVERROR_INVALIDDATA;
av_packet_unref(pkt);
goto bitmap_end; goto bitmap_end;
} }


@@ -489,7 +488,6 @@ bitmap_end_skip:
if ((res = av_new_packet(pkt, len)) < 0) if ((res = av_new_packet(pkt, len)) < 0)
return res; return res;
if (avio_read(pb, pkt->data, 4) != 4) { if (avio_read(pb, pkt->data, 4) != 4) {
av_packet_unref(pkt);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (AV_RB32(pkt->data) == 0xffd8ffd9 || if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
@@ -506,7 +504,6 @@ bitmap_end_skip:
} }
if (res != pkt->size) { if (res != pkt->size) {
if (res < 0) { if (res < 0) {
av_packet_unref(pkt);
return res; return res;
} }
av_shrink_packet(pkt, res); av_shrink_packet(pkt, res);


+ 0
- 2
libavformat/thp.c View File

@@ -181,7 +181,6 @@ static int thp_read_packet(AVFormatContext *s,
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }


@@ -191,7 +190,6 @@ static int thp_read_packet(AVFormatContext *s,
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret != thp->audiosize) { if (ret != thp->audiosize) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 5
- 9
libavformat/vivo.c View File

@@ -273,32 +273,28 @@ restart:
} }


if ((ret = av_get_packet(pb, pkt, vivo->length)) < 0) if ((ret = av_get_packet(pb, pkt, vivo->length)) < 0)
goto fail;
return ret;


// get next packet header // get next packet header
if ((ret = vivo_get_packet_header(s)) < 0) if ((ret = vivo_get_packet_header(s)) < 0)
goto fail;
return ret;


while (vivo->sequence == old_sequence && while (vivo->sequence == old_sequence &&
(((vivo->type - 1) >> 1) == ((old_type - 1) >> 1))) { (((vivo->type - 1) >> 1) == ((old_type - 1) >> 1))) {
if (avio_feof(pb)) { if (avio_feof(pb)) {
ret = AVERROR_EOF;
break;
return AVERROR_EOF;
} }


if ((ret = av_append_packet(pb, pkt, vivo->length)) < 0) if ((ret = av_append_packet(pb, pkt, vivo->length)) < 0)
break;
return ret;


// get next packet header // get next packet header
if ((ret = vivo_get_packet_header(s)) < 0) if ((ret = vivo_get_packet_header(s)) < 0)
break;
return ret;
} }


pkt->stream_index = stream_index; pkt->stream_index = stream_index;


fail:
if (ret < 0)
av_packet_unref(pkt);
return ret; return ret;
} }




+ 1
- 3
libavformat/vpk.c View File

@@ -93,9 +93,7 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = avio_read(s->pb, pkt->data + i * size, size); ret = avio_read(s->pb, pkt->data + i * size, size);
avio_skip(s->pb, skip); avio_skip(s->pb, skip);
if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
ret = AVERROR(EIO);
break;
return AVERROR(EIO);
} }
} }
pkt->stream_index = 0; pkt->stream_index = 0;


+ 0
- 1
libavformat/vqf.c View File

@@ -249,7 +249,6 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = avio_read(s->pb, pkt->data+2, size); ret = avio_read(s->pb, pkt->data+2, size);


if (ret != size) { if (ret != size) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }




+ 0
- 4
libavformat/wvdec.c View File

@@ -287,25 +287,21 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE); memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize); ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
if (ret != wc->header.blocksize) { if (ret != wc->header.blocksize) {
av_packet_unref(pkt);
return AVERROR(EIO); return AVERROR(EIO);
} }
while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) { while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
if ((ret = wv_read_block_header(s, s->pb)) < 0) { if ((ret = wv_read_block_header(s, s->pb)) < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }


off = pkt->size; off = pkt->size;
if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) { if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
av_packet_unref(pkt);
return ret; return ret;
} }
memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE); memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);


ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize); ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
if (ret != wc->header.blocksize) { if (ret != wc->header.blocksize) {
av_packet_unref(pkt);
return (ret < 0) ? ret : AVERROR_EOF; return (ret < 0) ? ret : AVERROR_EOF;
} }
} }


+ 0
- 1
libavformat/yuv4mpegdec.c View File

@@ -314,7 +314,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0) if (ret < 0)
return ret; return ret;
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) { else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
av_packet_unref(pkt);
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
} }
pkt->stream_index = 0; pkt->stream_index = 0;


Loading…
Cancel
Save