From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 12/15] avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references Date: Thu, 16 Dec 2021 02:29:20 +0100 Message-ID: <AM7PR03MB666065518EFBD395C8BB70458F779@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) In-Reply-To: <AM7PR03MB666072BE629D71EFF7053C138F769@AM7PR03MB6660.eurprd03.prod.outlook.com> The packet given to muxers is not used afterwards; it is always unreferenced by libavformat. Ergo muxers are allowed to keep the references in the packets and e.g. move the ownership to a packet list. This is what this commit does. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavformat/aiffenc.c | 2 +- libavformat/flacenc.c | 2 +- libavformat/movenc.c | 4 +++- libavformat/mp3enc.c | 3 ++- libavformat/ttaenc.c | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 24bc17400e..7bb0978a53 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -219,7 +219,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end, - pkt, av_packet_ref, 0); + pkt, NULL, 0); } return 0; diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index f884e5d2c8..e8f043729e 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) if (pkt->stream_index == c->audio_stream_idx) { if (c->waiting_pics) { /* buffer audio packets until we get all the pictures */ - ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, av_packet_ref, 0); + ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n"); c->waiting_pics = 0; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index fc309fb416..033a6a9f52 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6197,9 +6197,11 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } + /* The following will reset pkt and is only allowed to be used + * because we return immediately. afterwards. */ if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue, &trk->squashed_packet_queue_end, - pkt, av_packet_ref, 0)) < 0) { + pkt, NULL, 0)) < 0) { return ret; } diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 71e96a8651..0ffc79c025 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -524,7 +524,8 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->stream_index == mp3->audio_stream_idx) { if (mp3->pics_to_write) { /* buffer audio packets until we get all the pictures */ - int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, pkt, av_packet_ref, 0); + int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, + pkt, NULL, 0); if (ret < 0) { av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n"); diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c index 11855c32d9..5f21fdc144 100644 --- a/libavformat/ttaenc.c +++ b/libavformat/ttaenc.c @@ -95,10 +95,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt) int ret; ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt, - av_packet_ref, 0); + NULL, 0); if (ret < 0) { return ret; } + pkt = &tta->queue_end->pkt; avio_wl32(tta->seek_table, pkt->size); tta->nb_samples += pkt->duration; -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2021-12-16 1:29 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt 2021-12-20 15:03 ` Andreas Rheinhardt 2021-12-30 9:55 ` Anton Khirnov 2022-01-03 5:33 ` Andreas Rheinhardt 2022-01-03 10:38 ` Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 03/11] Makefile: Redo duplicating object files in shared builds Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab Andreas Rheinhardt 2021-12-30 10:12 ` Anton Khirnov 2021-12-31 13:28 ` Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 05/11] avcodec/dca: Unavpriv dca_sample_rates Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 06/11] avcodec/jpegtables: Unavpriv MJPEG-tables Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 07/11] configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 09/11] avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 10/11] avcodec/internal: Remove unused av_export_avcodec Andreas Rheinhardt 2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 11/11] avcodec/utils: Unavpriv avpriv_toupper4() Andreas Rheinhardt 2021-12-16 1:29 ` Andreas Rheinhardt [this message] 2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket) Andreas Rheinhardt 2021-12-21 13:52 ` Tomas Härdin 2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 14/15] avcodec/packet_internal: Add proper PacketList struct Andreas Rheinhardt 2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 15/15] avformat/movenc: Use dedicated pointer for access to MOVTrack Andreas Rheinhardt 2021-12-17 22:52 ` [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AM7PR03MB666065518EFBD395C8BB70458F779@AM7PR03MB6660.eurprd03.prod.outlook.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git