]> git.sesse.net Git - ffmpeg/commitdiff
avformat: Remove unnecessary av_packet_unref()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 7 Jan 2020 13:55:40 +0000 (14:55 +0100)
committerMarton Balint <cus@passwd.hu>
Mon, 10 Feb 2020 21:41:38 +0000 (22:41 +0100)
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>
52 files changed:
libavformat/aacdec.c
libavformat/adp.c
libavformat/adxdec.c
libavformat/amr.c
libavformat/ape.c
libavformat/avs.c
libavformat/brstm.c
libavformat/c93.c
libavformat/cdxl.c
libavformat/concatdec.c
libavformat/dfa.c
libavformat/dsicin.c
libavformat/dss.c
libavformat/dxa.c
libavformat/electronicarts.c
libavformat/fitsdec.c
libavformat/flic.c
libavformat/g723_1.c
libavformat/gdv.c
libavformat/gsmdec.c
libavformat/hls.c
libavformat/icodec.c
libavformat/idcin.c
libavformat/idroqdec.c
libavformat/ilbc.c
libavformat/img2dec.c
libavformat/iv8.c
libavformat/libmodplug.c
libavformat/lxfdec.c
libavformat/mov.c
libavformat/mpc.c
libavformat/mpegts.c
libavformat/mpjpegdec.c
libavformat/ncdec.c
libavformat/nuv.c
libavformat/oggdec.c
libavformat/redspark.c
libavformat/rl2.c
libavformat/rpl.c
libavformat/s337m.c
libavformat/sapdec.c
libavformat/sdr2.c
libavformat/sierravmd.c
libavformat/siff.c
libavformat/spdifdec.c
libavformat/swfdec.c
libavformat/thp.c
libavformat/vivo.c
libavformat/vpk.c
libavformat/vqf.c
libavformat/wvdec.c
libavformat/yuv4mpegdec.c

index 00ca2319cae8e88f900fd09871c1bbd9190276d1..ba3f5ccc6dd481d211289e3b5f0af21bdc54dcad 100644 (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);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
 
@@ -174,7 +173,6 @@ retry:
         return ret;
 
     if (ret < ADTS_HEADER_SIZE) {
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
@@ -185,7 +183,6 @@ retry:
         av_assert2(append > 0);
         ret = av_append_packet(s->pb, pkt, append);
         if (ret != append) {
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
@@ -201,13 +198,10 @@ retry:
 
     fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
     if (fsize < ADTS_HEADER_SIZE) {
-        av_packet_unref(pkt);
         return AVERROR_INVALIDDATA;
     }
 
     ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
-    if (ret < 0)
-        av_packet_unref(pkt);
 
     return ret;
 }
index 56f302acfd8db77339606ad91900610dc9ed537f..8668c78fe43c8b835b6b1c27a2733ed00eb99d2a 100644 (file)
@@ -78,7 +78,6 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     if (ret != size) {
         if (ret < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         av_shrink_packet(pkt, ret);
index f80b4b80f0de02ee027eda164e16008f7e7c0bd0..ccd5049acd0454301031f251ebf4ec1976886f89 100644 (file)
@@ -65,11 +65,9 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret != size) {
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     if (AV_RB16(pkt->data) & 0x8000) {
-        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
     pkt->size     = size;
index 650b565b1b9afe7b64a95c7ce7cbc7c5b44c2388..eccbbde5b0218e36fd27920850908d88539b9242 100644 (file)
@@ -153,7 +153,6 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
     read              = avio_read(s->pb, pkt->data + 1, size - 1);
 
     if (read != size - 1) {
-        av_packet_unref(pkt);
         if (read < 0)
             return read;
         return AVERROR(EIO);
index e31a00dc963dcf6b01fb3b0e107d134ab8e83e50..ed6752a41506f2057397a4ba2a0e68ef62e62483 100644 (file)
@@ -419,7 +419,6 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
     AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
     ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
 
index 3f8780d42d8150b43c2f886ddba539d9171e76c0..54b2c3f2a9708923dad64de99bf04dd5301360d7 100644 (file)
@@ -114,7 +114,6 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
     pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
     ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
     if (ret < size) {
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 1470690731e52aa70552b97a754912940a4cff09..ca965ed7e1999f8e76d73a75e0e45bfddeea7aed 100644 (file)
@@ -422,8 +422,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             dst += size;
             avio_skip(s->pb, skip);
             if (ret != size) {
-                av_packet_unref(pkt);
-                break;
+                return AVERROR(EIO);
             }
         }
         pkt->duration = samples;
index 8aa80b5e0b1b8cbbbdd71437680c79ab4a338900..256b9800cafbea59713ef815350362158db9626c 100644 (file)
@@ -158,22 +158,19 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = avio_read(pb, pkt->data + 1, datasize);
     if (ret < datasize) {
-        ret = AVERROR(EIO);
-        goto fail;
+        return AVERROR(EIO);
     }
 
     datasize = avio_rl16(pb); /* palette size */
     if (datasize) {
         if (datasize != 768) {
             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;
         ret = avio_read(pb, pkt->data + pkt->size, datasize);
         if (ret < datasize) {
-            ret = AVERROR(EIO);
-            goto fail;
+            return AVERROR(EIO);
         }
         pkt->size += 768;
     }
@@ -186,10 +183,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         pkt->data[0] |= C93_FIRST_FRAME;
     }
     return 0;
-
-    fail:
-    av_packet_unref(pkt);
-    return ret;
 }
 
 AVInputFormat ff_c93_demuxer = {
index 31f7cb823a89e5d153e7b7d5efe7c6071680a353..5718fc3e21430e8faa0733a6884d8dd44422cc50 100644 (file)
@@ -207,7 +207,6 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
         memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
         ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
         if (ret < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);
index e826821241670c9c80295137a604176d166353ec..2173911ce4504f13caec1adff34f0abeceb14ca8 100644 (file)
@@ -542,7 +542,6 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
         if (ret < 0) {
             av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter "
                    "failed to send input packet\n");
-            av_packet_unref(pkt);
             return ret;
         }
 
@@ -592,7 +591,6 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
         if (ret < 0)
             return ret;
         if ((ret = match_streams(avf)) < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         if (packet_after_outpoint(cat, pkt)) {
@@ -608,7 +606,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
         }
         break;
     }
-    if ((ret = filter_packet(avf, cs, pkt)))
+    if ((ret = filter_packet(avf, cs, pkt)) < 0)
         return ret;
 
     st = cat->avf->streams[pkt->stream_index];
index d667cd6277a74fc2d2ae38b79df7e3fa7e625d01..bd4ef2dafeb009842712bc0ab3226c35e7568c9d 100644 (file)
@@ -93,7 +93,6 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (!first) {
             ret = av_append_packet(pb, pkt, 12);
             if (ret < 0) {
-                av_packet_unref(pkt);
                 return ret;
             }
         } else
@@ -101,7 +100,6 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
         frame_size = AV_RL32(pkt->data + pkt->size - 8);
         if (frame_size > INT_MAX - 4) {
             av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         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);
         if (ret < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
     }
index 244622ee3938814fd5f4f25cb0277dc9e6e2857e..b18f43b9a0e7d2f591f094e5c9146e280839689d 100644 (file)
@@ -200,7 +200,6 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         ret = avio_read(pb, &pkt->data[4], pkt_size);
         if (ret < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         if (ret < pkt_size)
index d7f9cafe47a9e4b3f5df4f83a2e3f96c2f3928f2..8e0b72fbe510e596f912144ac38c34d0fade267f 100644 (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);
 
     if (ctx->dss_sp_swap_byte < 0) {
-        ret = AVERROR(EAGAIN);
-        goto error_eof;
+        return AVERROR(EAGAIN);
     }
 
     return pkt->size;
 
 error_eof:
-    av_packet_unref(pkt);
     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,
                         size2 - offset);
         if (ret < size2 - offset) {
-            av_packet_unref(pkt);
             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);
     if (ret < size - offset) {
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR_EOF;
     }
 
index 994078e6332b0d2defaebc5899cd3ba546deeb2b..27fa6afb6a0cab720a8ad25c335000033df2c6ef 100644 (file)
@@ -210,7 +210,6 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
             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){
-                av_packet_unref(pkt);
                 return AVERROR(EIO);
             }
             if(pal_size) memcpy(pkt->data, pal, pal_size);
index c894663c297b8555fb3e0f7bc3fae699b2f67669..2ee5e1b6fad58d24cec9fda59ba0bafa07f34751 100644 (file)
@@ -633,7 +633,6 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
             case AV_CODEC_ID_ADPCM_EA_R3:
                 if (pkt->size < 4) {
                     av_log(s, AV_LOG_ERROR, "Packet is too short\n");
-                    av_packet_unref(pkt);
                     return AVERROR_INVALIDDATA;
                 }
                 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)
         return AVERROR(EAGAIN);
 
index 30e34fc4d5e0c73f7891364bb97e8be7d7460af0..e52ddc7e790655b5e82989fee5fe8277718e0652 100644 (file)
@@ -183,7 +183,6 @@ static int fits_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_bprint_finalize(&avbuf, &buf);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
 
@@ -192,7 +191,6 @@ static int fits_read_packet(AVFormatContext *s, AVPacket *pkt)
     av_freep(&buf);
     ret = avio_read(s->pb, pkt->data + pkt->size, size);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
 
index d2a5cf995c2adf2148e589aa6420f31e96be1ea2..e65c157777d4a182e583e094a9a45ef7b1824811 100644 (file)
@@ -225,7 +225,6 @@ static int flic_read_packet(AVFormatContext *s,
             ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
                 size - FLIC_PREAMBLE_SIZE);
             if (ret != size - FLIC_PREAMBLE_SIZE) {
-                av_packet_unref(pkt);
                 ret = AVERROR(EIO);
             }
             packet_read = 1;
@@ -241,8 +240,8 @@ static int flic_read_packet(AVFormatContext *s,
             ret = avio_read(pb, pkt->data, size);
 
             if (ret != size) {
-                av_packet_unref(pkt);
                 ret = AVERROR(EIO);
+                break;
             }
 
             packet_read = 1;
index 27c8c3951be00baa0ce1daa4dcab526bb4cf3f76..3af480934788401faf87208a3f3ab4e025119f15 100644 (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);
     if (ret < size - 1) {
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR_EOF;
     }
 
index b698497a6a85df096ccf7c15e359316e808b6673..2ecbb535e7cb75ea4e0fca49a43f6e9a07d776c3 100644 (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,
                                           AVPALETTE_SIZE);
             if (!pal) {
-                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             memcpy(pal, gdv->pal, AVPALETTE_SIZE);
index 1044cde3178f7f60c65582b932ef7955f4cb55db..ec6b2e924ff19ec275619ff3a48aef1d7f8bc748 100644 (file)
@@ -62,7 +62,6 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret < GSM_BLOCK_SIZE) {
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     pkt->duration = 1;
index 31d7f5526ace2a3af9a2706b624c1376d4598426..1f58e745a7b81efc8d8b94c4a55bd551a1ae58cb 100644 (file)
@@ -2225,7 +2225,6 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (ist->codecpar->codec_id != st->codecpar->codec_id) {
             ret = set_stream_info_from_input_stream(st, pls, ist);
             if (ret < 0) {
-                av_packet_unref(pkt);
                 return ret;
             }
         }
index 98684e5e742cc5b22db4720b0b0d8a621375d9ec..b47fa98f8007634915b709e161a04592b33a34bf 100644 (file)
@@ -185,7 +185,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         bytestream_put_le32(&buf, 0);
 
         if ((ret = avio_read(pb, buf, image->size)) != image->size) {
-            av_packet_unref(pkt);
             return ret < 0 ? ret : AVERROR_INVALIDDATA;
         }
 
index 0b1058171b4b3ad1ec338b47e225900b8ece4595..5a6a15aa81dec71b51d44ea98c6528df79d66022 100644 (file)
@@ -313,7 +313,6 @@ static int idcin_read_packet(AVFormatContext *s,
             return ret;
         else if (ret != chunk_size) {
             av_log(s, AV_LOG_ERROR, "incomplete packet\n");
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         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,
                                           AVPALETTE_SIZE);
             if (!pal) {
-                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             memcpy(pal, palette, AVPALETTE_SIZE);
index 16aa2a146e273b7e5ab0f0901ecef767c2e45ba9..519f31d61a09547c12d70e091ff787f51bc00529 100644 (file)
@@ -224,8 +224,7 @@ static int roq_read_packet(AVFormatContext *s,
             ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
                 chunk_size);
             if (ret != chunk_size) {
-                av_packet_unref(pkt);
-                ret = AVERROR(EIO);
+                return AVERROR(EIO);
             }
 
             packet_read = 1;
index 01c7112ad176dfefa759e4cc65d32e4b2d9c5722..d41027174db8c8b6eba92695914040a9a7853968 100644 (file)
@@ -111,7 +111,6 @@ static int ilbc_read_packet(AVFormatContext *s,
     pkt->pos = avio_tell(s->pb);
     pkt->duration = par->block_align == 38 ? 160 : 240;
     if ((ret = avio_read(s->pb, pkt->data, par->block_align)) != par->block_align) {
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
 
index 37ee1bb7463ed1ec92089fc93bdf03a7e84606a9..40f3e3d499eed341d4714b1ff2c81f61e36e3058 100644 (file)
@@ -542,7 +542,6 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     }
 
     if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
-        av_packet_unref(pkt);
         if (ret[0] < 0) {
             res = ret[0];
         } else if (ret[1] < 0) {
index 449a422347dc2c9d598cfafc59e8f4b0ba13a83d..e25f24eeb906e09cfa010f0d4b4097e46dd0ed81 100644 (file)
@@ -92,7 +92,6 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             ret = av_append_packet(s->pb, pkt, size);
             if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
-                av_packet_unref(pkt);
                 return ret;
             }
         }
index 6a32618e6f3e8aa4979b2870b082774db4dbc4bb..6e567f5f988b57a1af3e57db3d7e481fd7abeeae 100644 (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);
     if (pkt->size <= 0) {
-        av_packet_unref(pkt);
         return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO);
     }
     return 0;
index 434518fc592e60def1d8b2680395466b2a33517b..fa84ceea78ea22ca251d1867cbccbc3448e1864f 100644 (file)
@@ -316,7 +316,6 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
         return ret2;
 
     if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
-        av_packet_unref(pkt);
         return ret2 < 0 ? ret2 : AVERROR_EOF;
     }
 
index bbaf266a4b5d091dd209d7083bfc5d7431e6e88e..ff1e5344897181bffac9432bca11ccaa36ac1a5a 100644 (file)
@@ -7890,7 +7890,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = cenc_filter(mov, st, sc, pkt, current_index);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
 
index a7b2e116edb5002b7cd6348ddd86767952c8f054..85036cd118d545039f4ddfd6dce9840022e6b7bd 100644 (file)
@@ -169,7 +169,6 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
     if(c->curbits)
         avio_seek(s->pb, -4, SEEK_CUR);
     if(ret < size){
-        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     pkt->size = ret + 4;
index 5c850bc1e59f817718f7b87a4ee832ed44426661..a90900127ced824970ab2eab1b9235bfd5330ae4 100644 (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);
     pkt->pos = avio_tell(s->pb);
     if (ret < 0) {
-        av_packet_unref(pkt);
         return ret;
     }
     if (data != pkt->data)
index c79a39c69d1d0ef427c5fb0daae6b638d8cf18d9..1e2ab0db1ad71aa4c802d786e90a4139cabe1539 100644 (file)
@@ -359,8 +359,6 @@ static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
         /* error or EOF occurred */
         if (ret == AVERROR_EOF) {
             ret = pkt->size > 0 ? pkt->size : AVERROR_EOF;
-        } else {
-            av_packet_unref(pkt);
         }
     }
 
index bc3d3e82bf5fc3dae292fc36a3ca864c11889ba6..f2066b485a4ab199525edde8308a805c59817787 100644 (file)
@@ -83,7 +83,6 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret != size) {
-        if (ret > 0) av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index bef0ae4860c95671f1784e3689b72bd8ce0b601b..d99770d41d81030303f7c67563ed3b912eaf1ba9 100644 (file)
@@ -284,7 +284,6 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt)
             memcpy(pkt->data, hdr, copyhdrsize);
             ret = avio_read(pb, pkt->data + copyhdrsize, size);
             if (ret < 0) {
-                av_packet_unref(pkt);
                 return ret;
             }
             if (ret < size)
index e815f421348d811c80559adf7951684037f3eef4..4f4b5fe386e9c197a45a069cc87f4660b4991ec7 100644 (file)
@@ -851,7 +851,7 @@ retry:
                                                      AV_PKT_DATA_SKIP_SAMPLES,
                                                      10);
         if(!side_data)
-            goto fail;
+            return AVERROR(ENOMEM);
         AV_WL32(side_data + 4, os->end_trimming);
         os->end_trimming = 0;
     }
@@ -861,7 +861,7 @@ retry:
                                                      AV_PKT_DATA_METADATA_UPDATE,
                                                      os->new_metadata_size);
         if(!side_data)
-            goto fail;
+            return AVERROR(ENOMEM);
 
         memcpy(side_data, os->new_metadata, os->new_metadata_size);
         av_freep(&os->new_metadata);
@@ -869,9 +869,6 @@ retry:
     }
 
     return psize;
-fail:
-    av_packet_unref(pkt);
-    return AVERROR(ENOMEM);
 }
 
 static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
index f1f2b3156d364f7da0ee29bdfa7e664fd29da238..0ce89153119da259ccab740b735cb3e5a8f883a3 100644 (file)
@@ -140,7 +140,6 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret != size) {
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 9e10155838f8f09a57df87e98355b467fa2574f3..cfde23a945b6089ce757cc72fc35a53e0254a391 100644 (file)
@@ -256,7 +256,6 @@ static int rl2_read_packet(AVFormatContext *s,
     /** fill the packet */
     ret = av_get_packet(pb, pkt, sample->size);
     if(ret != sample->size){
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 6afd373810098dd600920d5db8209173a6526782..208c50f00ceea6850a5ae32f26e509465c196c3a 100644 (file)
@@ -338,7 +338,6 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (ret < 0)
             return ret;
         if (ret != frame_size) {
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         pkt->duration = 1;
@@ -355,7 +354,6 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (ret < 0)
             return ret;
         if (ret != index_entry->size) {
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
index 8956afb23fdad13486a0292b3c54849a7134e1c3..36e1047af82429c5c57debd17258e8be836d59b2 100644 (file)
@@ -174,7 +174,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->pos = pos;
 
     if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
-        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
 
@@ -186,7 +185,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
     if (!s->nb_streams) {
         AVStream *st = avformat_new_stream(s, NULL);
         if (!st) {
-            av_packet_unref(pkt);
             return AVERROR(ENOMEM);
         }
         st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
index f8bc0d281c39693e3d1e4e0afff7d8f8da6202bf..b3644b436b51c0f6e7f42606a33898b2257d96bd 100644 (file)
@@ -225,7 +225,6 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
             int i = s->nb_streams;
             AVStream *st = avformat_new_stream(s, NULL);
             if (!st) {
-                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             st->id = i;
index 8893f260d2fe09b684b89aad824bec8853ac6007..3743d59e5867324b9d5215d6a31bf53266fa83ce 100644 (file)
@@ -95,7 +95,6 @@ static int sdr2_read_packet(AVFormatContext *s, AVPacket *pkt)
         memcpy(pkt->data, header, 24);
         ret = avio_read(s->pb, pkt->data + 24, next - 52);
         if (ret < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         av_shrink_packet(pkt, ret + 24);
index 8c2322eda603c9e12a00523d4427bcb1b84fe34d..531fc415316d6a58f3e4c14f510fa728095eaeeb 100644 (file)
@@ -295,7 +295,6 @@ static int vmd_read_packet(AVFormatContext *s,
             frame->frame_size);
 
     if (ret != frame->frame_size) {
-        av_packet_unref(pkt);
         ret = AVERROR(EIO);
     }
     pkt->stream_index = frame->stream_index;
index 56c5b33c768130a6d27cb43b550c542e64f6a375..f6815b2f26988bf0d261e7f7d883bf88ca5965c3 100644 (file)
@@ -220,7 +220,6 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
             if (c->gmcsize)
                 memcpy(pkt->data + 2, c->gmc, c->gmcsize);
             if (avio_read(s->pb, pkt->data + 2 + c->gmcsize, size) != size) {
-                av_packet_unref(pkt);
                 return AVERROR_INVALIDDATA;
             }
             pkt->stream_index = 0;
index d74f58d82baaaac2001853717170ea08aa115cfd..1808fa9d65dc80130f778d3339d079d137ceff06 100644 (file)
@@ -197,15 +197,13 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
 
     if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
-        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
     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,
                                      &offset, &codec_id);
-    if (ret) {
-        av_packet_unref(pkt);
+    if (ret < 0) {
         return ret;
     }
 
@@ -216,7 +214,6 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
         /* first packet, create a stream */
         AVStream *st = avformat_new_stream(s, NULL);
         if (!st) {
-            av_packet_unref(pkt);
             return AVERROR(ENOMEM);
         }
         st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
index a9358f09a90f6fa07ed2b0b3fa9afb5f7f711f77..9a0b27bd8c481aac74637b306961b8684d8e20ab 100644 (file)
@@ -399,7 +399,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
 
             if (linesize * height > pkt->size) {
                 res = AVERROR_INVALIDDATA;
-                av_packet_unref(pkt);
                 goto bitmap_end;
             }
 
@@ -489,7 +488,6 @@ bitmap_end_skip:
             if ((res = av_new_packet(pkt, len)) < 0)
                 return res;
             if (avio_read(pb, pkt->data, 4) != 4) {
-                av_packet_unref(pkt);
                 return AVERROR_INVALIDDATA;
             }
             if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
@@ -506,7 +504,6 @@ bitmap_end_skip:
             }
             if (res != pkt->size) {
                 if (res < 0) {
-                    av_packet_unref(pkt);
                     return res;
                 }
                 av_shrink_packet(pkt, res);
index ee5c78b6d3cab16870d6146ca61389ef8ce1e771..332ed791284ed77a0cb079658d6a6c7ed2b7db3c 100644 (file)
@@ -181,7 +181,6 @@ static int thp_read_packet(AVFormatContext *s,
         if (ret < 0)
             return ret;
         if (ret != size) {
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
@@ -191,7 +190,6 @@ static int thp_read_packet(AVFormatContext *s,
         if (ret < 0)
             return ret;
         if (ret != thp->audiosize) {
-            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
index 9a07c43849f1288bca560df753a113e8f2f155fc..4039cd0fe53832c2afaad11771c9908f6ff8d68b 100644 (file)
@@ -273,32 +273,28 @@ restart:
     }
 
     if ((ret = av_get_packet(pb, pkt, vivo->length)) < 0)
-        goto fail;
+        return ret;
 
     // get next packet header
     if ((ret = vivo_get_packet_header(s)) < 0)
-        goto fail;
+        return ret;
 
     while (vivo->sequence == old_sequence &&
            (((vivo->type - 1) >> 1) == ((old_type - 1) >> 1))) {
         if (avio_feof(pb)) {
-            ret = AVERROR_EOF;
-            break;
+            return AVERROR_EOF;
         }
 
         if ((ret = av_append_packet(pb, pkt, vivo->length)) < 0)
-            break;
+            return ret;
 
         // get next packet header
         if ((ret = vivo_get_packet_header(s)) < 0)
-            break;
+            return ret;
     }
 
     pkt->stream_index = stream_index;
 
-fail:
-    if (ret < 0)
-        av_packet_unref(pkt);
     return ret;
 }
 
index 255d6030b0db26d83b0709b4b48f7b8cc1258f5f..dd9aeb61019e80f97d5ca81f457a341b62c64fbc 100644 (file)
@@ -93,9 +93,7 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
             ret = avio_read(s->pb, pkt->data + i * size, size);
             avio_skip(s->pb, skip);
             if (ret != size) {
-                av_packet_unref(pkt);
-                ret = AVERROR(EIO);
-                break;
+                return AVERROR(EIO);
             }
         }
         pkt->stream_index = 0;
index 2916ee64fad1d7b6dc17728ca287bbc1166bf7df..617a9706f4330b327132f177dc86808bbf77240e 100644 (file)
@@ -249,7 +249,6 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = avio_read(s->pb, pkt->data+2, size);
 
     if (ret != size) {
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index f2bb4c60ba338b4a133690506b5392cfc2cfe0bd..0aa581534d28caf2447aefdf8d325e8f4e290119 100644 (file)
@@ -287,25 +287,21 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
     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) {
-        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
     while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
         if ((ret = wv_read_block_header(s, s->pb)) < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
 
         off = pkt->size;
         if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
-            av_packet_unref(pkt);
             return ret;
         }
         memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);
 
         ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
         if (ret != wc->header.blocksize) {
-            av_packet_unref(pkt);
             return (ret < 0) ? ret : AVERROR_EOF;
         }
     }
index ccd3da1af85ab93c49ade71718a7509155ae90c0..a11567e5ca1da11c7f58d1ac160db8560ea70346 100644 (file)
@@ -314,7 +314,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
     if (ret < 0)
         return ret;
     else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
-        av_packet_unref(pkt);
         return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
     }
     pkt->stream_index = 0;