From: Steven Liu <lingjiujianke@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: Re: [FFmpeg-devel] [PATCH 2/8] avformat/flvenc: Add deinit function
Date: Wed, 6 Jul 2022 10:28:57 +0800
Message-ID: <CADxeRwkxPwXY-6E-CeOs9zjMc56O_p-2c7Bw=HxkM5NtqA8-fw@mail.gmail.com> (raw)
In-Reply-To: <DB6PR0101MB22147A9129827D68982E404E8F819@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com>
Andreas Rheinhardt <andreas.rheinhardt@outlook.com> 于2022年7月6日周三 04:27写道:
>
> Fixes memleaks when the trailer is never written or when shift_data()
> fails when writing the trailer.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> This is the same as
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20191023125944.10292-4-andreas.rheinhardt@gmail.com/
>
> libavformat/flvenc.c | 30 ++++++++++++++++--------------
> 1 file changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 4e65ba4066..b6135b25bf 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -733,7 +733,7 @@ static int flv_write_trailer(AVFormatContext *s)
> int64_t cur_pos = avio_tell(s->pb);
>
> if (build_keyframes_idx) {
> - FLVFileposition *newflv_posinfo, *p;
> + FLVFileposition *newflv_posinfo;
>
> avio_seek(pb, flv->videosize_offset, SEEK_SET);
> put_amf_double(pb, flv->videosize);
> @@ -768,19 +768,6 @@ static int flv_write_trailer(AVFormatContext *s)
> put_amf_double(pb, newflv_posinfo->keyframe_timestamp);
> }
>
> - newflv_posinfo = flv->head_filepositions;
> - while (newflv_posinfo) {
> - p = newflv_posinfo->next;
> - if (p) {
> - newflv_posinfo->next = p->next;
> - av_free(p);
> - p = NULL;
> - } else {
> - av_free(newflv_posinfo);
> - newflv_posinfo = NULL;
> - }
> - }
> -
> put_amf_string(pb, "");
> avio_w8(pb, AMF_END_OF_OBJECT);
>
> @@ -1047,6 +1034,20 @@ static int flv_check_bitstream(AVFormatContext *s, AVStream *st,
> return ret;
> }
>
> +static void flv_deinit(AVFormatContext *s)
> +{
> + FLVContext *flv = s->priv_data;
> + FLVFileposition *filepos = flv->head_filepositions;
> +
> + while (filepos) {
> + FLVFileposition *next = filepos->next;
> + av_free(filepos);
> + filepos = next;
> + }
> + flv->filepositions = flv->head_filepositions = NULL;
> + flv->filepositions_count = 0;
> +}
> +
> static const AVOption options[] = {
> { "flvflags", "FLV muxer flags", offsetof(FLVContext, flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
> { "aac_seq_header_detect", "Put AAC sequence header based on stream data", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_AAC_SEQ_HEADER_DETECT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
> @@ -1076,6 +1077,7 @@ const AVOutputFormat ff_flv_muxer = {
> .write_header = flv_write_header,
> .write_packet = flv_write_packet,
> .write_trailer = flv_write_trailer,
> + .deinit = flv_deinit,
> .check_bitstream= flv_check_bitstream,
> .codec_tag = (const AVCodecTag* const []) {
> flv_video_codec_ids, flv_audio_codec_ids, 0
> --
> 2.34.1
>
> _______________________________________________
> 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".
The flvenc part patchset looks ok to me.
Thanks
Steven
_______________________________________________
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:[~2022-07-06 2:29 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 20:09 [FFmpeg-devel] [PATCH 1/8] avutil/mem: Handle fast allocations near UINT_MAX properly Andreas Rheinhardt
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 2/8] avformat/flvenc: Add deinit function Andreas Rheinhardt
2022-07-06 2:28 ` Steven Liu [this message]
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 3/8] avutil/mem: Add av_fast_realloc_array() Andreas Rheinhardt
2022-07-06 14:40 ` Tomas Härdin
2022-07-06 14:46 ` Andreas Rheinhardt
2022-07-06 14:54 ` Tomas Härdin
2022-07-12 14:12 ` Andreas Rheinhardt
2022-07-14 8:14 ` Anton Khirnov
2022-07-14 12:51 ` Andreas Rheinhardt
2022-07-17 8:30 ` Anton Khirnov
2022-09-26 12:25 ` Andreas Rheinhardt
2022-09-26 14:21 ` Andreas Rheinhardt
2022-09-26 14:24 ` Tomas Härdin
2022-09-27 15:23 ` Tomas Härdin
2022-09-28 9:35 ` Tomas Härdin
2022-09-28 11:06 ` Andreas Rheinhardt
2022-09-28 11:41 ` Tomas Härdin
2022-07-21 21:23 ` Tomas Härdin
2022-08-17 15:29 ` Anton Khirnov
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 4/8] avformat/flvenc: Use array instead of linked list for index Andreas Rheinhardt
2022-07-06 14:58 ` Tomas Härdin
2022-07-06 15:03 ` Andreas Rheinhardt
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 5/8] avformat/matroskaenc: Use av_fast_realloc_array for index entries Andreas Rheinhardt
2022-07-06 15:03 ` Tomas Härdin
2022-07-06 15:10 ` Andreas Rheinhardt
2022-07-06 15:21 ` Tomas Härdin
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 6/8] avcodec/movtextenc: Use av_fast_realloc_array Andreas Rheinhardt
2022-07-06 15:06 ` Tomas Härdin
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 7/8] avutil/fifo: Simplify growing FIFO Andreas Rheinhardt
2022-07-05 20:26 ` [FFmpeg-devel] [PATCH 8/8] avutil/fifo: Grow FIFO faster when growing automatically Andreas Rheinhardt
2022-07-06 13:02 ` [FFmpeg-devel] [PATCH 1/8] avutil/mem: Handle fast allocations near UINT_MAX properly Anton Khirnov
2022-07-06 13:08 ` Andreas Rheinhardt
2022-07-06 13:17 ` Anton Khirnov
2022-07-06 14:24 ` Tomas Härdin
2022-07-06 14:40 ` Andreas Rheinhardt
2022-08-17 14:31 ` Tomas Härdin
2022-09-26 11:50 ` Tomas Härdin
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='CADxeRwkxPwXY-6E-CeOs9zjMc56O_p-2c7Bw=HxkM5NtqA8-fw@mail.gmail.com' \
--to=lingjiujianke@gmail.com \
--cc=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