diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c index 4ce3b26795450c531862e8b09c6175d4d5dc096c..06a98a630e508db6a7d5bd83c6517e83115b52cc 100644 --- a/doc/examples/decoding_encoding.c +++ b/doc/examples/decoding_encoding.c @@ -211,7 +211,7 @@ static void audio_encode_example(const char *filename) } if (got_output) { fwrite(pkt.data, 1, pkt.size, f); - av_free_packet(&pkt); + av_packet_unref(&pkt); } } diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c index e6624076cfe91f7fa0f403d3999e088e4a46d007..59e0ccc986f898b36c6695a1196e4df7c20de1eb 100644 --- a/doc/examples/demuxing_decoding.c +++ b/doc/examples/demuxing_decoding.c @@ -326,7 +326,7 @@ int main (int argc, char **argv) pkt.data += ret; pkt.size -= ret; } while (pkt.size > 0); - av_free_packet(&orig_pkt); + av_packet_unref(&orig_pkt); } /* flush cached frames */ diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index d6fd61335e797a050dc4c7b865615a5ca8f1c734..975189c77d35eecbd64dd0b6ecdedb2c091b02d7 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -167,7 +167,7 @@ int main(int argc, char **argv) pkt.data += ret; pkt.size -= ret; } while (pkt.size > 0); - av_free_packet(&orig_pkt); + av_packet_unref(&orig_pkt); } /* flush cached frames */ diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index 6c74ec326d719ef1f84b188f599f78d49c6de19a..89c80cfd556d8b948d487797e031aa8361d7e28d 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -273,10 +273,10 @@ int main(int argc, char **argv) } if (packet.size <= 0) - av_free_packet(&packet0); + av_packet_unref(&packet0); } else { /* discard non-wanted packets */ - av_free_packet(&packet0); + av_packet_unref(&packet0); } } end: diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c index 5600572dec05a4724c421e777c60cb41b4d530f9..3dabf13b1003b3cf285f85c50475908836e0cac0 100644 --- a/doc/examples/filtering_video.c +++ b/doc/examples/filtering_video.c @@ -262,7 +262,7 @@ int main(int argc, char **argv) av_frame_unref(frame); } } - av_free_packet(&packet); + av_packet_unref(&packet); } end: avfilter_graph_free(&filter_graph); diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c index 33037f77ad3dee1cec4dfa8cac9da50599be27ea..65437d9abd51f71c9a3734c2b59a39cc99082f05 100644 --- a/doc/examples/remuxing.c +++ b/doc/examples/remuxing.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error muxing packet\n"); break; } - av_free_packet(&pkt); + av_packet_unref(&pkt); } av_write_trailer(ofmt_ctx); diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 20c9e272caf023c7d13824a7d3c1631079dcdb4d..d5d410b1684cde410a37aa7089def056a51cb029 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -536,7 +536,7 @@ int main(int argc, char **argv) if (ret < 0) goto end; } - av_free_packet(&packet); + av_packet_unref(&packet); } /* flush filters and encoders */ @@ -560,7 +560,7 @@ int main(int argc, char **argv) av_write_trailer(ofmt_ctx); end: - av_free_packet(&packet); + av_packet_unref(&packet); av_frame_free(&frame); for (i = 0; i < ifmt_ctx->nb_streams; i++) { avcodec_close(ifmt_ctx->streams[i]->codec); diff --git a/ffmpeg.c b/ffmpeg.c index d4c6ec8420f8f9906ffe6356dd4260974a59e39a..f91fb7b7d4c84b21796152e7aa87a57c4f6d0ab5 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -653,7 +653,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) */ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { if (ost->frame_number >= ost->max_frames) { - av_free_packet(pkt); + av_packet_unref(pkt); return; } ost->frame_number++; @@ -700,7 +700,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) if (a > 0) { pkt->side_data = NULL; pkt->side_data_elems = 0; - av_free_packet(pkt); + av_packet_unref(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) @@ -777,7 +777,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) main_return_code = 1; close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); } - av_free_packet(pkt); + av_packet_unref(pkt); } static void close_output_stream(OutputStream *ost) @@ -1754,7 +1754,7 @@ static void flush_encoders(void) break; } if (ost->finished & MUXER_FINISHED) { - av_free_packet(&pkt); + av_packet_unref(&pkt); continue; } av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); @@ -3521,7 +3521,7 @@ static void *input_thread(void *arg) av_log(f->ctx, AV_LOG_ERROR, "Unable to send packet to main thread: %s\n", av_err2str(ret)); - av_free_packet(&pkt); + av_packet_unref(&pkt); av_thread_message_queue_set_err_recv(f->in_thread_queue, ret); break; } @@ -3542,7 +3542,7 @@ static void free_input_threads(void) continue; av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF); while (av_thread_message_queue_recv(f->in_thread_queue, &pkt, 0) >= 0) - av_free_packet(&pkt); + av_packet_unref(&pkt); pthread_join(f->thread, NULL); f->joined = 1; @@ -3945,7 +3945,7 @@ static int process_input(int file_index) process_input_packet(ist, &pkt, 0); discard_packet: - av_free_packet(&pkt); + av_packet_unref(&pkt); return 0; } diff --git a/ffplay.c b/ffplay.c index e0bcc7c392a758763e63c81abfacd31b0414ab81..2c1817ef0b23f3368c7b59868f422f03a2d085b9 100644 --- a/ffplay.c +++ b/ffplay.c @@ -432,7 +432,7 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt) SDL_UnlockMutex(q->mutex); if (pkt != &flush_pkt && ret < 0) - av_free_packet(pkt); + av_packet_unref(pkt); return ret; } @@ -472,7 +472,7 @@ static void packet_queue_flush(PacketQueue *q) SDL_LockMutex(q->mutex); for (pkt = q->first_pkt; pkt; pkt = pkt1) { pkt1 = pkt->next; - av_free_packet(&pkt->pkt); + av_packet_unref(&pkt->pkt); av_freep(&pkt); } q->last_pkt = NULL; @@ -577,7 +577,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { d->next_pts_tb = d->start_pts_tb; } } while (pkt.data == flush_pkt.data || d->queue->serial != d->pkt_serial); - av_free_packet(&d->pkt); + av_packet_unref(&d->pkt); d->pkt_temp = d->pkt = pkt; d->packet_pending = 1; } @@ -641,7 +641,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { } static void decoder_destroy(Decoder *d) { - av_free_packet(&d->pkt); + av_packet_unref(&d->pkt); } static void frame_queue_unref_item(Frame *vp) @@ -3119,7 +3119,7 @@ static int read_thread(void *arg) } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) { packet_queue_put(&is->subtitleq, pkt); } else { - av_free_packet(pkt); + av_packet_unref(pkt); } } diff --git a/ffserver.c b/ffserver.c index 1d4c8dc5b98453f2cc158ac73e3077e804195efc..526cbfcae3cd7a74144a8e63438caebcb6864ceb 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2318,7 +2318,7 @@ static int http_prepare_data(HTTPContext *c) c->packet_stream_index = pkt.stream_index; ctx = c->rtp_ctx[c->packet_stream_index]; if(!ctx) { - av_free_packet(&pkt); + av_packet_unref(&pkt); break; } codec = ctx->streams[0]->codec; @@ -2370,11 +2370,11 @@ static int http_prepare_data(HTTPContext *c) codec->frame_number++; if (len == 0) { - av_free_packet(&pkt); + av_packet_unref(&pkt); goto redo; } } - av_free_packet(&pkt); + av_packet_unref(&pkt); } } break; @@ -3548,7 +3548,7 @@ static void extract_mpeg4_header(AVFormatContext *infile) } mpeg4_count--; } - av_free_packet(&pkt); + av_packet_unref(&pkt); } } diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 648dc10076e92ff03bf63f49ade41799fa5f786d..a87150ed823aac84f163ee30766c9d44ac7ab429 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -179,7 +179,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup) return 0; failed_alloc: - av_free_packet(pkt); + av_packet_unref(pkt); return AVERROR(ENOMEM); } @@ -342,7 +342,7 @@ int av_packet_merge_side_data(AVPacket *pkt){ bytestream_put_be64(&p, FF_MERGE_MARKER); av_assert0(p-pkt->data == pkt->size); memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE); - av_free_packet(&old); + av_packet_unref(&old); pkt->side_data_elems = 0; pkt->side_data = NULL; return 1; diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 8ac02f95205bdfa37bfa719e73c0cf8ed5f68f72..3f3e80d4a01d9dad7a4d0cdf4f29ab8a8457fc95 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -361,7 +361,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, discard_padding = opus->opts.packet_size - avpkt->duration; // Check if subtraction resulted in an overflow if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) { - av_free_packet(avpkt); + av_packet_unref(avpkt); av_free(avpkt); return AVERROR(EINVAL); } @@ -370,7 +370,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if(!side_data) { - av_free_packet(avpkt); + av_packet_unref(avpkt); av_free(avpkt); return AVERROR(ENOMEM); } diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 992122c98276d0fda12f0a6117bc884ec63c9d41..887cc33c202475df5bae5b31426498263569d624 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -733,7 +733,7 @@ FF_ENABLE_DEPRECATION_WARNINGS AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, cx_frame->sz_alpha + 8); if(!side_data) { - av_free_packet(pkt); + av_packet_unref(pkt); av_free(pkt); return AVERROR(ENOMEM); } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index b4709cb3cb3c5ac5118b8a7136d02620e8d39e3c..dca0c9a32c63e8a4bf299bdcaac918a21d7dab85 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2353,7 +2353,7 @@ static int recode_subtitle(AVCodecContext *avctx, ret = FFMIN(AVERROR(errno), -1); av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" " "from %s to UTF-8\n", inpkt->data, avctx->sub_charenc); - av_free_packet(&tmp); + av_packet_unref(&tmp); goto end; } outpkt->size -= outl; @@ -2460,7 +2460,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; - av_free_packet(&pkt_recoded); + av_packet_unref(&pkt_recoded); } if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 0; diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 747f47e582898b5a6aac002f0b57e925c99b1ef6..89f93de4534c01ba913c99882abb321ab0fa6cb8 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -48,7 +48,7 @@ static void avpacket_queue_flush(AVPacketQueue *q) pthread_mutex_lock(&q->mutex); for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { pkt1 = pkt->next; - av_free_packet(&pkt->pkt); + av_packet_unref(&pkt->pkt); av_freep(&pkt); } q->last_pkt = NULL; diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 31764a9637a9ed14657f234b209e285714456e46..b280bc314d9e2c50a0c6cf92a75ff5e2afeb65d3 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -119,7 +119,7 @@ dshow_read_close(AVFormatContext *s) pktl = ctx->pktl; while (pktl) { AVPacketList *next = pktl->next; - av_free_packet(&pktl->pkt); + av_packet_unref(&pktl->pkt); av_free(pktl); pktl = next; } diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c index cab1eb6915cf81374594cdd4aca86f1e68d6b67f..e4daf5325073037f1497107d77b1357e333ed2f4 100644 --- a/libavdevice/openal-dec.c +++ b/libavdevice/openal-dec.c @@ -204,7 +204,7 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt) fail: /* Handle failure */ if (pkt->data) - av_free_packet(pkt); + av_packet_unref(pkt); if (error_msg) av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg); return error; diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c index 9952e6eab6f969d3d03dce3525e587a252cbfac5..706badf63d363d5e473c279bb8617eca11fffcd6 100644 --- a/libavfilter/lavfutils.c +++ b/libavfilter/lavfutils.c @@ -95,7 +95,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4], av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h); end: - av_free_packet(&pkt); + av_packet_unref(&pkt); avcodec_close(codec_ctx); avformat_close_input(&format_ctx); av_frame_free(&frame); diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 0c2ceed316dcaccee6b8f44f8694edeebe8bfaa3..82d2bcda10b8e1e181dd8f816f6418ce969d807e 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -490,7 +490,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 : movie->out_index[pkt->stream_index]; if (pkt_out_id < 0) { - av_free_packet(&movie->pkt0); + av_packet_unref(&movie->pkt0); pkt->size = 0; /* ready for next run */ pkt->data = NULL; return 0; @@ -517,7 +517,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) if (ret < 0) { av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret)); av_frame_free(&frame); - av_free_packet(&movie->pkt0); + av_packet_unref(&movie->pkt0); movie->pkt.size = 0; movie->pkt.data = NULL; return 0; @@ -528,7 +528,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) pkt->data += ret; pkt->size -= ret; if (pkt->size <= 0) { - av_free_packet(&movie->pkt0); + av_packet_unref(&movie->pkt0); pkt->size = 0; /* ready for next run */ pkt->data = NULL; } diff --git a/libavfilter/vf_mcdeint.c b/libavfilter/vf_mcdeint.c index 38a299ea4ca8b3b9027e0bb8dd81b5b6aa1dd9ac..e1c865a30a78233ecf47b0411738a28f8da0c0d8 100644 --- a/libavfilter/vf_mcdeint.c +++ b/libavfilter/vf_mcdeint.c @@ -277,7 +277,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) mcdeint->parity ^= 1; end: - av_free_packet(&pkt); + av_packet_unref(&pkt); av_frame_free(&inpic); if (ret < 0) { av_frame_free(&outpic); diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index b0d016c0e58ac3b0f5f6b6f636bc9c7719001ff4..63b22c3721ee11da94b82ff37d1510cd79cc29d6 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -444,7 +444,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx) } } } - av_free_packet(&pkt); + av_packet_unref(&pkt); avsubtitle_free(&sub); } diff --git a/libavformat/adp.c b/libavformat/adp.c index 8a3661ae1510965fd0872d8d9cf2cedf53947aac..f53375aea07e37ba9a394159946f2686ca7c3b43 100644 --- a/libavformat/adp.c +++ b/libavformat/adp.c @@ -78,7 +78,7 @@ static int adp_read_packet(AVFormatContext *s, AVPacket *pkt) if (ret != size) { if (ret < 0) { - av_free_packet(pkt); + av_packet_unref(pkt); return ret; } av_shrink_packet(pkt, ret); diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 3abd2840f25656f51ddd53ae67d02c04ca959d70..09d91a7e4db6ab05ad0a4b57ebb173b1838e691e 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -293,7 +293,7 @@ static int aiff_write_trailer(AVFormatContext *s) while (pict_list) { AVPacketList *next = pict_list->next; - av_free_packet(&pict_list->pkt); + av_packet_unref(&pict_list->pkt); av_freep(&pict_list); pict_list = next; } diff --git a/libavformat/ape.c b/libavformat/ape.c index 69b001a578d4cc61b8d54c488d1d5109a680d355..352ddc6d7784ded7c24f0cbd2d8c2a56bf0f1044 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -418,7 +418,7 @@ 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_free_packet(pkt); + av_packet_unref(pkt); return ret; } diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c index 9b2c634b9542937186fa8c5224b67de71bfbf429..4326a7cd3becc670832e5345422724d94111d090 100644 --- a/libavformat/apngenc.c +++ b/libavformat/apngenc.c @@ -192,7 +192,7 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet) } ++apng->frame_number; - av_free_packet(apng->prev_packet); + av_packet_unref(apng->prev_packet); if (packet) av_copy_packet(apng->prev_packet, packet); } diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 7c31cfaee470c82784ab335604772a9ce5c3319c..3865b0ed172537915c4e071922d9a503e2aba8e5 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -298,7 +298,7 @@ static int asf_read_picture(AVFormatContext *s, int len) fail: av_freep(&desc); - av_free_packet(&pkt); + av_packet_unref(&pkt); return ret; } @@ -852,7 +852,7 @@ static int asf_read_header(AVFormatContext *s) if ((ret = av_get_packet(pb, &pkt, len)) < 0) return ret; av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); - av_free_packet(&pkt); + av_packet_unref(&pkt); len= avio_rl32(pb); get_tag(s, "ASF_Protection_Type", -1, len, 32); len= avio_rl32(pb); @@ -1288,7 +1288,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) "freeing incomplete packet size %d, new %d\n", asf_st->pkt.size, asf_st->packet_obj_size); asf_st->frag_offset = 0; - av_free_packet(&asf_st->pkt); + av_packet_unref(&asf_st->pkt); } /* new packet */ if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0) @@ -1379,7 +1379,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) if (i == asf_st->pkt.size) { av_log(s, AV_LOG_DEBUG, "discarding ms fart\n"); asf_st->frag_offset = 0; - av_free_packet(&asf_st->pkt); + av_packet_unref(&asf_st->pkt); continue; } } @@ -1476,7 +1476,7 @@ static void asf_reset_header(AVFormatContext *s) for (i = 0; i < 128; i++) { asf_st = &asf->streams[i]; - av_free_packet(&asf_st->pkt); + av_packet_unref(&asf_st->pkt); asf_st->packet_obj_size = 0; asf_st->frag_offset = 0; asf_st->seq = 0; @@ -1538,7 +1538,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, pts = pkt->dts; - av_free_packet(pkt); + av_packet_unref(pkt); if (pkt->flags & AV_PKT_FLAG_KEY) { i = pkt->stream_index; diff --git a/libavformat/avidec.c b/libavformat/avidec.c index d240fa68bdcf83bc710e1d5ecd8d68c0c7afc5f9..b7bd54dedf36a8983288179a5b5f6dc11286b0cd 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1496,7 +1496,7 @@ resync: } if (!avi->non_interleaved && pkt->pos >= 0 && ast->seek_pos > pkt->pos) { - av_free_packet(pkt); + av_packet_unref(pkt); goto resync; } ast->seek_pos= 0; diff --git a/libavformat/brstm.c b/libavformat/brstm.c index a781163f95834a700000c13149c03177b05d1b36..4ac9881c995aa9e04a393fd8807ac741b4c5b673 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -412,7 +412,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) dst += size; avio_skip(s->pb, skip); if (ret != size) { - av_free_packet(pkt); + av_packet_unref(pkt); break; } } diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 7686f28c62191bbbd6c1151b063f11937ecec004..0180a7e50f4edcf40104a53fdd706ab4808e21ee 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -511,7 +511,7 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt) ret = 1; } if (ret > 0) { - av_free_packet(pkt); + av_packet_unref(pkt); pkt2.buf = av_buffer_create(pkt2.data, pkt2.size, av_buffer_default_free, NULL, 0); if (!pkt2.buf) { diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index ae180f6de3205e7062398d3512661cae694a966f..8601782afaa598d2d280306f6a735bfdb94fde79 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -612,7 +612,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) if (partial_packet) { avpriv_request_sample(s, "video header followed by audio packet"); - av_free_packet(pkt); + av_packet_unref(pkt); partial_packet = 0; } @@ -736,7 +736,7 @@ get_video_packet: } if (ret < 0 && partial_packet) - av_free_packet(pkt); + av_packet_unref(pkt); return ret; } diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index b743c872c09a709e838f31b59b3f151a39e7396f..59443b69852a0717a53c67b1d67f2ba8742835b5 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -632,7 +632,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->stream_index = ffm->header[0]; if ((unsigned)pkt->stream_index >= s->nb_streams) { av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index); - av_free_packet(pkt); + av_packet_unref(pkt); ffm->read_state = READ_HEADER; return -1; } @@ -643,7 +643,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt) ffm->read_state = READ_HEADER; if (ffm_read_data(s, pkt->data, size, 0) != size) { /* bad case: desynchronized packet. we cancel all the packet loading */ - av_free_packet(pkt); + av_packet_unref(pkt); return -1; } pkt->pts = AV_RB64(ffm->header+8); diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 4c7ee59ec52a20ef93e59607f9edba024b66bd6b..cc3ed830a96ffcf32c1dbf25f55fafac979c87e3 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -267,7 +267,7 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde &out_pkt.data, &out_pkt.size, pkt.data, pkt.size, pkt.pts, pkt.dts, *ppos); - av_free_packet(&pkt); + av_packet_unref(&pkt); if (out_pkt.size){ int size = out_pkt.size; if (parser->pts != AV_NOPTS_VALUE){ diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 7b434498ea3d2b54291db6b1d23dec79dc9f4b69..ca7396931582a642956c68385e94dbbaa5758f26 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1143,7 +1143,7 @@ leave: av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d\n", last, orig_size + 11); avio_seek(s->pb, pos + 1, SEEK_SET); ret = resync(s); - av_free_packet(pkt); + av_packet_unref(pkt); if (ret >= 0) { goto retry; } diff --git a/libavformat/gif.c b/libavformat/gif.c index e5d558df07b0063a3f96f19f6233b4f592f843d3..6537e557d62fd7b788bdde088f39707a43972efe 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -173,7 +173,7 @@ static int flush_packet(AVFormatContext *s, AVPacket *new) avio_write(pb, pkt->data, pkt->size); - av_free_packet(gif->prev_pkt); + av_packet_unref(gif->prev_pkt); if (new) av_copy_packet(gif->prev_pkt, new); diff --git a/libavformat/iff.c b/libavformat/iff.c index 5973cde8fe48dfc31d04a1c70bba8bec628e115b..28890831512a4ba7a13d697b3a5fa53263d7126b 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -738,7 +738,7 @@ static int iff_read_packet(AVFormatContext *s, bytestream_put_be16(&buf, 2); ret = avio_read(pb, buf, iff->body_size); if (ret<0) { - av_free_packet(pkt); + av_packet_unref(pkt); } else if (ret < iff->body_size) av_shrink_packet(pkt, ret + 2); } else { diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index efc9304fe0a04b8ebeca3e28fc3ea17c9426ac9f..7f0ff19ba37d0acc69861542332936330701429b 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -157,11 +157,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) (ret = avformat_write_header(fmt, NULL)) < 0 || (ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 || (ret = av_write_trailer(fmt)) < 0) { - av_free_packet(&pkt2); + av_packet_unref(&pkt2); avformat_free_context(fmt); return ret; } - av_free_packet(&pkt2); + av_packet_unref(&pkt2); avformat_free_context(fmt); } else { avio_write(pb[0], pkt->data, pkt->size); diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index 158a63039ff68493646a2de05afd1b5e7edd8cc7..75699e89b473e551d59f91c1080e4934db007c94 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -325,7 +325,7 @@ 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_free_packet(pkt); + av_packet_unref(pkt); return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO); } return 0; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 78ab28742e597740cc10f076f6d437e91f4861de..8d7db90e1babc60a9b553e8e1668510226e1af7c 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2750,7 +2750,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, additional_size + 8); if (!side_data) { - av_free_packet(pkt); + av_packet_unref(pkt); av_free(pkt); return AVERROR(ENOMEM); } @@ -2763,7 +2763,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska, AV_PKT_DATA_SKIP_SAMPLES, 10); if (!side_data) { - av_free_packet(pkt); + av_packet_unref(pkt); av_free(pkt); return AVERROR(ENOMEM); } diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 61dcf4c8758aea1cc31a008ca0842dc43eedb63e..3646994c43f59076f9cc24200909ccfaae98664b 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -440,10 +440,10 @@ concatenate: return ret; if (info->num_blocks != 6) return 0; - av_free_packet(pkt); + av_packet_unref(pkt); if ((ret = av_copy_packet(pkt, &info->pkt)) < 0) return ret; - av_free_packet(&info->pkt); + av_packet_unref(&info->pkt); info->num_blocks = 0; } @@ -498,7 +498,7 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track) av_free(buf); end: - av_free_packet(&info->pkt); + av_packet_unref(&info->pkt); av_freep(&track->eac3_priv); return size; @@ -4606,7 +4606,7 @@ static int mov_write_subtitle_end_packet(AVFormatContext *s, end.stream_index = stream_index; ret = mov_write_single_packet(s, &end); - av_free_packet(&end); + av_packet_unref(&end); return ret; } diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 55f2b3fb6872c9a8083d3440a21d7e0bc7880d57..fb77d892d5e9d441bb7025f5943063d5a175bb8f 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -956,12 +956,12 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos = idx_pkt.pos; pkt->stream_index = idx_pkt.stream_index; - av_free_packet(&idx_pkt); + av_packet_unref(&idx_pkt); return 0; fail: - av_free_packet(pkt); - av_free_packet(&idx_pkt); + av_packet_unref(pkt); + av_packet_unref(&idx_pkt); return ret; } diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 28ec43ee983a45675b2a58488b0be37c613f175d..0f0f5036cafa666a7b3151ec591aa30c0f6fef55 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2654,7 +2654,7 @@ static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt) ts->pkt = pkt; ret = handle_packets(ts, 0); if (ret < 0) { - av_free_packet(ts->pkt); + av_packet_unref(ts->pkt); /* flush pes data left */ for (i = 0; i < NB_PID_MAX; i++) if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { @@ -2743,7 +2743,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, ret = av_read_frame(s, &pkt); if (ret < 0) return AV_NOPTS_VALUE; - av_free_packet(&pkt); + av_packet_unref(&pkt); if (pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0) { ff_reduce_index(s, pkt.stream_index); av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index deceb032e573cc4f2b6853744c59732b558f2f94..62427fc09208bb6333d41ef1e4b3e73afd6fa22e 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -1157,7 +1157,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code) return 0; fail: - av_free_packet(pkt); + av_packet_unref(pkt); return ret; } diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 9682ee9fcad9e1444cf579b6d9a2a7c873ecb24d..2d99b4af25c22d3140138732c9919c1f94fea0c5 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -844,7 +844,7 @@ retry: return psize; fail: - av_free_packet(pkt); + av_packet_unref(pkt); return AVERROR(ENOMEM); } diff --git a/libavformat/redspark.c b/libavformat/redspark.c index 66c2dc5aae12b7812bc47e1dc07d1fc5c8cba491..5cea6e96b9b7a77043916d0a648dbc27476c0edd 100644 --- a/libavformat/redspark.c +++ b/libavformat/redspark.c @@ -148,7 +148,7 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt) ret = av_get_packet(s->pb, pkt, size); if (ret != size) { - av_free_packet(pkt); + av_packet_unref(pkt); return AVERROR(EIO); } diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 13702f25fcaa9e24ba958d9524e725975c108382..4ec78efe695763c958a3c53650d5bda1076880cf 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -783,7 +783,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); if ((ret = avio_read(pb, pkt->data + 9, len)) != len) { - av_free_packet(pkt); + av_packet_unref(pkt); av_log(s, AV_LOG_ERROR, "Failed to read %d bytes\n", len); return ret < 0 ? ret : AVERROR(EIO); } diff --git a/libavformat/sdr2.c b/libavformat/sdr2.c index 82405f69d18f69505a3a254d96905a0444019f75..edb454caec3c0db6e03107366660631ad9ec7fe3 100644 --- a/libavformat/sdr2.c +++ b/libavformat/sdr2.c @@ -95,7 +95,7 @@ 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_free_packet(pkt); + av_packet_unref(pkt); return ret; } av_shrink_packet(pkt, ret + 24); diff --git a/libavformat/siff.c b/libavformat/siff.c index b6ea390598b4a9452aad71b2e224a0e47851d914..028f18be16b34102710eb5904a1f46d33ff89f1c 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -219,7 +219,7 @@ 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_free_packet(pkt); + av_packet_unref(pkt); return AVERROR_INVALIDDATA; } pkt->stream_index = 0; diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index bb8976682dc27a1a29f3aabea8d421a6253cdb4a..471d600c1072c6b5039355eb63c8c3954046330c 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -179,7 +179,7 @@ static void drop_dups(void *log_ctx, FFDemuxSubtitlesQueue *q) q->subs[i].stream_index == last->stream_index && !strcmp(q->subs[i].data, last->data)) { - av_free_packet(&q->subs[i]); + av_packet_unref(&q->subs[i]); drop++; } else if (drop) { q->subs[last_id + 1] = q->subs[i]; @@ -302,7 +302,7 @@ void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q) int i; for (i = 0; i < q->nb_subs; i++) - av_free_packet(&q->subs[i]); + av_packet_unref(&q->subs[i]); av_freep(&q->subs); q->nb_subs = q->allocated_size = q->current_sub_idx = 0; } diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index 68cd8561fb52c4a7d174afe891b3c87d71221472..e596ffaa927928d23d5cd5d65be741b8b7b6b7c3 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -479,7 +479,7 @@ bitmap_end_skip: if ((res = av_new_packet(pkt, len)) < 0) return res; if (avio_read(pb, pkt->data, 4) != 4) { - av_free_packet(pkt); + av_packet_unref(pkt); return AVERROR_INVALIDDATA; } if (AV_RB32(pkt->data) == 0xffd8ffd9 || @@ -496,7 +496,7 @@ bitmap_end_skip: } if (res != pkt->size) { if (res < 0) { - av_free_packet(pkt); + av_packet_unref(pkt); return res; } av_shrink_packet(pkt, res); diff --git a/libavformat/tee.c b/libavformat/tee.c index e9fccc17d610a46fd9908928139ca994f244cfea..af52a490c6d4f8b27998bcc80f74bbf1bcf28cb4 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -424,7 +424,7 @@ static int filter_packet(void *log_ctx, AVPacket *pkt, } if (ret > 0) { - av_free_packet(pkt); + av_packet_unref(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4044db32ea220d2fb7da26e8c844023c1b6b4986..3dc64da56f23c6abcfb4030d1d250576c0c9d155 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1403,7 +1403,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) if (pkt->flags & AV_PKT_FLAG_KEY) st->skip_to_keyframe = 0; if (st->skip_to_keyframe) { - av_free_packet(&cur_pkt); + av_packet_unref(&cur_pkt); if (got_packet) { *pkt = cur_pkt; } diff --git a/libavformat/vivo.c b/libavformat/vivo.c index 7287379801e91fc8fd950952a69fe0ed633485a2..10d81b9142401a15de49eab7dc7126a4c1fab87e 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -298,7 +298,7 @@ restart: fail: if (ret < 0) - av_free_packet(pkt); + av_packet_unref(pkt); return ret; } diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 69270c63c4f67840912b5001a03b49492adf91f8..2a21730f1b6b4eecefdd9c4eec76ba9d97e03075 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -140,7 +140,7 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) avio_w8(s->pb, 0); } avio_write(s->pb, w->last_pkt.data + skip, w->last_pkt.size - skip); - av_free_packet(&w->last_pkt); + av_packet_unref(&w->last_pkt); } return 0; diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c index 8aebdddf03300a8831176e6db5e844388a85df34..0894b7fe60875cbc02f6694d05e32b95186f5b35 100644 --- a/libavformat/wtvenc.c +++ b/libavformat/wtvenc.c @@ -826,7 +826,7 @@ static int write_trailer(AVFormatContext *s) av_free(wctx->sp_pairs); av_free(wctx->st_pairs); - av_free_packet(&wctx->thumbnail); + av_packet_unref(&wctx->thumbnail); return 0; } diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c index d0dee64ef8adee37ef90e33403351d3f4e3f87cf..8644e7df9eb680157b1ba50d69680d87cfdb56c2 100644 --- a/tests/api/api-band-test.c +++ b/tests/api/api-band-test.c @@ -190,12 +190,12 @@ static int video_decode(const char *input_filename) return -1; } } - av_free_packet(&pkt); + av_packet_unref(&pkt); av_init_packet(&pkt); } } while (!end_of_stream || got_frame); - av_free_packet(&pkt); + av_packet_unref(&pkt); av_frame_free(&fr); avcodec_close(ctx); avformat_close_input(&fmt_ctx); diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 07030d6ddaff628eaddfe7e8ad1460cbe6b63fa9..7b480594b7dc664ea66a876a167e46cbc7bb630b 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -206,7 +206,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, out_offset += out_frame_bytes; } } - av_free_packet(&enc_pkt); + av_packet_unref(&enc_pkt); } if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) { diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c index e4bc0b816b84b3c34a028146d26b6bf32c46326a..acf1636b399094d8c6b84679e09beabf5ff576cc 100644 --- a/tests/api/api-h264-test.c +++ b/tests/api/api-h264-test.c @@ -134,13 +134,13 @@ static int video_decode_example(const char *input_filename) fr->pkt_pts, fr->pkt_dts, av_frame_get_pkt_duration(fr), number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes)); } - av_free_packet(&pkt); + av_packet_unref(&pkt); av_init_packet(&pkt); } i++; } while (!end_of_stream || got_frame); - av_free_packet(&pkt); + av_packet_unref(&pkt); av_frame_free(&fr); avcodec_close(ctx); avformat_close_input(&fmt_ctx); diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c index 99fe90c242a7c467a6e70475d3428075c7ace612..135b972440dedc16a7ae4d7f976e1413dbbb7540 100644 --- a/tests/api/api-seek-test.c +++ b/tests/api/api-seek-test.c @@ -143,11 +143,11 @@ static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream, } } } - av_free_packet(&pkt); + av_packet_unref(&pkt); av_init_packet(&pkt); } while ((!end_of_stream || got_frame) && (no_seeking || (fr->pkt_pts + av_frame_get_pkt_duration(fr) <= ts_end))); - av_free_packet(&pkt); + av_packet_unref(&pkt); av_freep(&byte_buffer); return 0; diff --git a/tools/seek_print.c b/tools/seek_print.c index c42b28dd449e71c9ff4c2d6770e19738c25c2289..de876b487c5812a08f40c8b326ee52dae9a1f738 100644 --- a/tools/seek_print.c +++ b/tools/seek_print.c @@ -87,7 +87,7 @@ int main(int argc, char **argv) ret, packet.size, packet.stream_index, av_ts2str(packet.dts), av_ts2timestr(packet.dts, tb), av_ts2str(packet.pts), av_ts2timestr(packet.pts, tb)); - av_free_packet(&packet); + av_packet_unref(&packet); } } else if (sscanf(*argv, "seek:%i:%"SCNi64":%"SCNi64":%"SCNi64":%i", &stream, &min_ts, &ts, &max_ts, &flags) == 5) {