From: Leo Izen <leo.izen@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avfilter/ccfifo: remove unnecessary context allocations
Date: Thu, 11 May 2023 14:11:57 -0400
Message-ID: <d23489d7-b0de-7a39-40cd-3aa2f5afb28c@gmail.com> (raw)
In-Reply-To: <20230511180334.14965-1-jamrial@gmail.com>
On 5/11/23 14:03, James Almer wrote:
> This is not public API, no it has no need for an alloc() and free()
> functions. The struct can reside on stack.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavfilter/ccfifo.c | 49 ++++++++++++-------------------------
> libavfilter/ccfifo.h | 42 ++++++++++++++++++-------------
> libavfilter/tinterlace.h | 2 +-
> libavfilter/vf_bwdif.c | 8 +++---
> libavfilter/vf_ccrepack.c | 13 +++++-----
> libavfilter/vf_fps.c | 13 +++++-----
> libavfilter/vf_tinterlace.c | 18 +++++++-------
> libavfilter/vf_yadif.c | 8 +++---
> libavfilter/vf_yadif_cuda.c | 6 ++---
> libavfilter/yadif.h | 2 +-
> libavfilter/yadif_common.c | 6 ++---
> 11 files changed, 81 insertions(+), 86 deletions(-)
>
> diff --git a/libavfilter/ccfifo.c b/libavfilter/ccfifo.c
> index 5fb68ce04c..a3c6a09698 100644
> --- a/libavfilter/ccfifo.c
> +++ b/libavfilter/ccfifo.c
> @@ -23,18 +23,6 @@
>
> #include "ccfifo.h"
>
> -struct AVCCFifo {
> - AVFifo *cc_608_fifo;
> - AVFifo *cc_708_fifo;
> - AVRational framerate;
> - int expected_cc_count;
> - int expected_608;
> - int cc_detected;
> - int passthrough;
> - int passthrough_warning;
> - void *log_ctx;
> -};
> -
> #define MAX_CC_ELEMENTS 128
> #define CC_BYTES_PER_ENTRY 3
>
> @@ -55,25 +43,18 @@ const static struct cc_lookup cc_lookup_vals[] = {
> { 60000, 1001, 10, 1},
> };
>
> -void ff_ccfifo_freep(AVCCFifo **ccf)
> +void ff_ccfifo_uninit(CCFifo *ccf)
> {
> - AVCCFifo *tmp = *ccf;
> - if (tmp) {
> - av_fifo_freep2(&tmp->cc_608_fifo);
> - av_fifo_freep2(&tmp->cc_708_fifo);
> - }
> - av_freep(ccf);
> + av_fifo_freep2(&ccf->cc_608_fifo);
> + av_fifo_freep2(&ccf->cc_708_fifo);
> + memset(&ccf, 0, sizeof(ccf));
See later comment about memset, I have the same question. ccf is a pointer.
> }
>
> -AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx)
> +int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
> {
> - AVCCFifo *ccf;
> int i;
>
> - ccf = av_mallocz(sizeof(*ccf));
> - if (!ccf)
> - return NULL;
> -
> + memset(&ccf, 0, sizeof(ccf));
> ccf->log_ctx = log_ctx;
> ccf->framerate = framerate;
I'm confused by this memset, why isn't it: memset(ccf, 0,
sizeof(CCFifo)); As written it appears to be equivalent to: ccf = NULL;
Unless I'm missing something here, this should immediately pop a null
dereference.
- Leo Izen (Traneptora / thebombzen)
_______________________________________________
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:[~2023-05-11 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 18:03 James Almer
2023-05-11 18:11 ` Leo Izen [this message]
2023-05-11 18:19 ` [FFmpeg-devel] [PATCH v2] " James Almer
2023-05-12 15:17 ` Devin Heitmueller
2023-05-12 19:24 ` James Almer
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=d23489d7-b0de-7a39-40cd-3aa2f5afb28c@gmail.com \
--to=leo.izen@gmail.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