From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6DC69465D1 for ; Mon, 22 May 2023 16:37:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D353A68BE1B; Mon, 22 May 2023 19:37:12 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5441268AE39 for ; Mon, 22 May 2023 19:37:06 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 6638648296; Mon, 22 May 2023 18:37:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1684773425; bh=zHfU5lTCSZ7ZLEfe2rktH0um6SeItSDJMdgIATsD0aY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cNMxPAKixJztA1Ob13IzC7m67eBBmk9+6izc/cPBlNIui16rZqW3ucWIDnrlrPiPM KenJuGzjMw7QMwi2P4jfsQuUUfS1J1xXwPsg5KVUM2pSdBvWFSdFx9WwrR87cNGoe5 AZYzcWfS9U7hKif0o/u+lvTdWqIPDSOYlm5P62tY= Date: Mon, 22 May 2023 18:37:05 +0200 Message-ID: <20230522183705.GB61584@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20230522101433.40493-1-epirat07@gmail.com> References: <20230419104250.21354-1-epirat07@gmail.com> <20230522101433.40493-1-epirat07@gmail.com> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter/vf_tpad: use enum for start/stop_mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 22 May 2023 12:14:32 +0200 Marvin Scholz wrote: > --- > libavfilter/vf_tpad.c | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c > index f0c065f0c3..d0fa7df8be 100644 > --- a/libavfilter/vf_tpad.c > +++ b/libavfilter/vf_tpad.c > @@ -27,6 +27,12 @@ > #include "formats.h" > #include "drawutils.h" > > +enum PadMode { > + MODE_ADD = 0, > + MODE_CLONE, > + NB_MODE > +}; > + > typedef struct TPadContext { > const AVClass *class; > int pad_start; > @@ -51,10 +57,10 @@ typedef struct TPadContext { > static const AVOption tpad_options[] = { > { "start", "set the number of frames to delay input", OFFSET(pad_start), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, VF }, > { "stop", "set the number of frames to add after input finished", OFFSET(pad_stop), AV_OPT_TYPE_INT, {.i64=0}, -1, INT_MAX, VF }, > - { "start_mode", "set the mode of added frames to start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, VF, "mode" }, > - { "add", "add solid-color frames", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, VF, "mode" }, > - { "clone", "clone first/last frame", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, VF, "mode" }, > - { "stop_mode", "set the mode of added frames to end", OFFSET(stop_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, VF, "mode" }, > + { "start_mode", "set the mode of added frames to start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=MODE_ADD}, 0, NB_MODE-1, VF, "mode" }, > + { "add", "add solid-color frames", 0, AV_OPT_TYPE_CONST, {.i64=MODE_ADD}, 0, 0, VF, "mode" }, > + { "clone", "clone first/last frame", 0, AV_OPT_TYPE_CONST, {.i64=MODE_CLONE}, 0, 0, VF, "mode" }, > + { "stop_mode", "set the mode of added frames to end", OFFSET(stop_mode), AV_OPT_TYPE_INT, {.i64=MODE_ADD}, 0, NB_MODE-1, VF, "mode" }, > { "start_duration", "set the duration to delay input", OFFSET(start_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF }, > { "stop_duration", "set the duration to pad input", OFFSET(stop_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF }, > { "color", "set the color of the added frames", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, VF }, > @@ -91,7 +97,7 @@ static int activate(AVFilterContext *ctx) > } > } > > - if (s->start_mode == 0 && s->pad_start > 0 && ff_outlink_frame_wanted(outlink)) { > + if (s->start_mode == MODE_ADD && s->pad_start > 0 && ff_outlink_frame_wanted(outlink)) { > frame = ff_get_video_buffer(outlink, outlink->w, outlink->h); > if (!frame) > return AVERROR(ENOMEM); > @@ -106,7 +112,7 @@ static int activate(AVFilterContext *ctx) > return ff_filter_frame(outlink, frame); > } > > - if (s->start_mode == 1 && s->pad_start > 0) { > + if (s->start_mode == MODE_CLONE && s->pad_start > 0) { > if (s->eof) { > ff_outlink_set_status(outlink, AVERROR_EOF, 0); > return 0; > @@ -133,7 +139,7 @@ static int activate(AVFilterContext *ctx) > if (ret < 0) > return ret; > if (ret > 0) { > - if (s->stop_mode == 1 && s->pad_stop != 0) { > + if (s->stop_mode == MODE_CLONE && s->pad_stop != 0) { > av_frame_free(&s->cache_stop); > s->cache_stop = av_frame_clone(frame); > } > @@ -147,14 +153,14 @@ static int activate(AVFilterContext *ctx) > ff_outlink_set_status(outlink, AVERROR_EOF, s->pts); > return 0; > } > - if (s->stop_mode == 0) { > + if (s->stop_mode == MODE_ADD) { > frame = ff_get_video_buffer(outlink, outlink->w, outlink->h); > if (!frame) > return AVERROR(ENOMEM); > ff_fill_rectangle(&s->draw, &s->color, > frame->data, frame->linesize, > 0, 0, frame->width, frame->height); > - } else if (s->stop_mode == 1) { > + } else if (s->stop_mode == MODE_CLONE) { > if (!s->cache_stop) { > s->pad_stop = 0; > ff_outlink_set_status(outlink, AVERROR_EOF, s->pts); > -- > 2.37.0 (Apple Git-136) > > _______________________________________________ > 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". Tested, LGTM. _______________________________________________ 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".