Re: [FFmpeg-devel] Fixes #10509
> > > On Mon, Mar 25, 2024 at 2:04 AM Marton Balint wrote: > > > On Sun, 24 Mar 2024, Poorva wrote: > > > From 0874a55ad33bb4df2789cbafc5247c0ae3d97e6a Mon Sep 17 00:00:00 2001 > > From: PoorvaGaikar > > Date: Sat, 9 Mar 2024 00:27:25 +0530 > > Subject: [PATCH v2] avfilter/f_select.c: add support for iw and ih > constants > > You should mention the fixed ticket number in the commit message. > > > > > --- > > doc/filters.texi | 6 ++ > > libavfilter/f_select.c | 14 ++ > > 2 files changed, 20 insertions(+) > > > > diff --git a/doc/filters.texi b/doc/filters.texi > > index 913365671d..e73dc9c1bf 100644 > > --- a/doc/filters.texi > > +++ b/doc/filters.texi > > @@ -30737,6 +30737,12 @@ missing. > > That basically means that an input frame is selected if its pts is > within the > > interval set by the concat demuxer. > > > > +@item iw @emph{(video only)} > > +Represents the width of the input video frame > > + > > +@item ih @emph{(video only)} > > +Represents the height of the input video frame > > + > > @end table > > > > The default value of the select expression is "1". > > diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c > > index 9b330a0673..ccfe915ee1 100644 > > --- a/libavfilter/f_select.c > > +++ b/libavfilter/f_select.c > > @@ -90,6 +90,9 @@ static const char *const var_names[] = { > > > > "concatdec_select", ///< frame is within the interval set by the > concat demuxer > > > > +"ih",///< ih: Represents the height of the input > video frame. > > +"iw",///< iw: Represents the width of the input > video frame. > > + > > NULL > > }; > > > > @@ -144,6 +147,9 @@ enum var_name { > > > > VAR_CONCATDEC_SELECT, > > > > +VAR_IH, > > +VAR_IW, > > + > > VAR_VARS_NB > > }; > > > > @@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink) > > select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; > > select->var_values[VAR_SAMPLES_N] = NAN; > > > > +select->var_values[VAR_IH] = NAN; > > +select->var_values[VAR_IW] = NAN; > > + > > select->var_values[VAR_SAMPLE_RATE] = > > inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; > > > > @@ -370,6 +379,10 @@ FF_ENABLE_DEPRECATION_WARNINGS > > } > > break; > > } > > +if (inlink->type == AVMEDIA_TYPE_VIDEO){ > > +select->var_values[VAR_IH] = frame->height; > > +select->var_values[VAR_IW] = frame->width; > > +} > > There is a switch(inlink->type) just above this, so you should put these > there to the corresponding case AVMEDIA_TYPE_VIDEO, and not create a new > block. > > > > select->select = res = av_expr_eval(select->expr, > select->var_values, NULL); > > av_log(inlink->dst, AV_LOG_DEBUG, > > @@ -546,3 +559,4 @@ const AVFilter ff_vf_select = { > > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | > AVFILTER_FLAG_METADATA_ONLY, > > }; > > #endif /* CONFIG_SELECT_FILTER */ > > + > > This is still an uneeded newline. > Thank you for your feedback on the Git patch I submitted for review. I have rectified the problem by adding the necessary changes . The updated patch file is attached for your review. > > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > v3-0001-avfilter-f_select.c-add-support-for-iw-and-ih-con.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
> On Tue, Mar 26, 2024 at 2:36 AM Poorva <2003gaikarpoo...@gmail.com> wrote: >> >> > > On Mon, Mar 25, 2024 at 2:04 AM Marton Balint wrote: >> >> >> >> On Sun, 24 Mar 2024, Poorva wrote: >> >> > From 0874a55ad33bb4df2789cbafc5247c0ae3d97e6a Mon Sep 17 00:00:00 2001 >> > From: PoorvaGaikar >> > Date: Sat, 9 Mar 2024 00:27:25 +0530 >> > Subject: [PATCH v2] avfilter/f_select.c: add support for iw and ih >> > constants >> >> You should mention the fixed ticket number in the commit message. >> >> > >> > --- >> > doc/filters.texi | 6 ++ >> > libavfilter/f_select.c | 14 ++ >> > 2 files changed, 20 insertions(+) >> > >> > diff --git a/doc/filters.texi b/doc/filters.texi >> > index 913365671d..e73dc9c1bf 100644 >> > --- a/doc/filters.texi >> > +++ b/doc/filters.texi >> > @@ -30737,6 +30737,12 @@ missing. >> > That basically means that an input frame is selected if its pts is within >> > the >> > interval set by the concat demuxer. >> > >> > +@item iw @emph{(video only)} >> > +Represents the width of the input video frame >> > + >> > +@item ih @emph{(video only)} >> > +Represents the height of the input video frame >> > + >> > @end table >> > >> > The default value of the select expression is "1". >> > diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c >> > index 9b330a0673..ccfe915ee1 100644 >> > --- a/libavfilter/f_select.c >> > +++ b/libavfilter/f_select.c >> > @@ -90,6 +90,9 @@ static const char *const var_names[] = { >> > >> > "concatdec_select", ///< frame is within the interval set by the >> > concat demuxer >> > >> > +"ih",///< ih: Represents the height of the input >> > video frame. >> > +"iw",///< iw: Represents the width of the input video >> > frame. >> > + >> > NULL >> > }; >> > >> > @@ -144,6 +147,9 @@ enum var_name { >> > >> > VAR_CONCATDEC_SELECT, >> > >> > +VAR_IH, >> > +VAR_IW, >> > + >> > VAR_VARS_NB >> > }; >> > >> > @@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink) >> > select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; >> > select->var_values[VAR_SAMPLES_N] = NAN; >> > >> > +select->var_values[VAR_IH] = NAN; >> > +select->var_values[VAR_IW] = NAN; >> > + >> > select->var_values[VAR_SAMPLE_RATE] = >> > inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; >> > >> > @@ -370,6 +379,10 @@ FF_ENABLE_DEPRECATION_WARNINGS >> > } >> > break; >> > } >> > +if (inlink->type == AVMEDIA_TYPE_VIDEO){ >> > +select->var_values[VAR_IH] = frame->height; >> > +select->var_values[VAR_IW] = frame->width; >> > +} >> >> There is a switch(inlink->type) just above this, so you should put these >> there to the corresponding case AVMEDIA_TYPE_VIDEO, and not create a new >> block. >> >> > >> > select->select = res = av_expr_eval(select->expr, select->var_values, >> > NULL); >> > av_log(inlink->dst, AV_LOG_DEBUG, >> > @@ -546,3 +559,4 @@ const AVFilter ff_vf_select = { >> > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | >> > AVFILTER_FLAG_METADATA_ONLY, >> > }; >> > #endif /* CONFIG_SELECT_FILTER */ >> > + >> >> This is still an uneeded newline. > > > Thank you for your feedback on the Git patch I submitted for review. > I have rectified the problem by adding the necessary changes . > The updated patch file is attached for your review. >> >> I wanted to follow up on the patch titled "v3-0001-avfilter-f_select.c - Add Support for IW and IH" that I submitted earlier and provide an update based on the feedback received. In response to your suggestion about the switch block, I have integrated the changes into the existing switch block for AVMEDIA_TYPE_VIDEO. Additionally, I have removed an unnecessary new line that was added at the end of the file. Despite these modifications, I have not received any further feedback or comments on the patch. Therefore, I kindly request the community to review the updated patch attached to this email. >> >> Regards, >> Marton >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
> > > On Sun, Mar 31, 2024 at 8:35 PM Marton Balint wrote: > > > On Fri, 29 Mar 2024, Poorva wrote: > > >> > > > > On Tue, Mar 26, 2024 at 2:36 AM Poorva <2003gaikarpoo...@gmail.com> > wrote: > >>> > >>> > >> > >> > >> Thank you for your feedback on the Git patch I submitted for review. > >> I have rectified the problem by adding the necessary changes . > >> The updated patch file is attached for your review. > >>> > >>> > > I wanted to follow up on the patch titled > > "v3-0001-avfilter-f_select.c - Add Support for IW and IH" that I > > submitted earlier and provide an update based on the feedback > > received. > > > > In response to your suggestion about the switch block, I have > > integrated the changes into the existing switch block for > > AVMEDIA_TYPE_VIDEO. Additionally, I have removed an unnecessary new > > line that was added at the end of the file. > > > > Despite these modifications, I have not received any further feedback > > or comments on the patch. Therefore, I kindly request the community to > > review the updated patch attached to this email. > > [..] > > > @@ -371,6 +383,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > > break; > > } > > > > + > > select->select = res = av_expr_eval(select->expr, > select->var_values, NULL); > > av_log(inlink->dst, AV_LOG_DEBUG, > > "n:%f pts:%f t:%f key:%d", > > @@ -545,4 +558,4 @@ const AVFilter ff_vf_select = { > > FILTER_QUERY_FUNC(query_formats), > > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | > AVFILTER_FLAG_METADATA_ONLY, > > }; > > -#endif /* CONFIG_SELECT_FILTER */ > > +#endif /* CONFIG_SELECT_FILTER */ > > \ No newline at end of file > > -- > > 2.43.0.windows.1 > > > > These two whitespace changes are still unnecessary. Please check your > patch before sending. > > I did remove all the unnecessary whitespaces ,rest which are present are to keep the code style . Patch is attached to this email. Thanks, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > v3-0001-avfilter-f_select.c-add-support-for-iw-and-ih-con.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
On Fri, Apr 5, 2024 at 2:08 AM Marton Balint wrote: > > > > On Mon, 1 Apr 2024, Poorva wrote: > > >> > >> > >> > > On Sun, Mar 31, 2024 at 8:35 PM Marton Balint wrote: > > > >> > >> > >> On Fri, 29 Mar 2024, Poorva wrote: > >> > >>>> > >>> > >>> On Tue, Mar 26, 2024 at 2:36 AM Poorva <2003gaikarpoo...@gmail.com> > >> wrote: > >>>>> > >>>>> > >>>> > >>>> > >>>> Thank you for your feedback on the Git patch I submitted for review. > >>>> I have rectified the problem by adding the necessary changes . > >>>> The updated patch file is attached for your review. > >>>>> > >>>>> > >>> I wanted to follow up on the patch titled > >>> "v3-0001-avfilter-f_select.c - Add Support for IW and IH" that I > >>> submitted earlier and provide an update based on the feedback > >>> received. > >>> > >>> In response to your suggestion about the switch block, I have > >>> integrated the changes into the existing switch block for > >>> AVMEDIA_TYPE_VIDEO. Additionally, I have removed an unnecessary new > >>> line that was added at the end of the file. > >>> > >>> Despite these modifications, I have not received any further feedback > >>> or comments on the patch. Therefore, I kindly request the community to > >>> review the updated patch attached to this email. > >> > >> [..] > >> > >>> @@ -371,6 +383,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > >>> break; > >>> } > >>> > >>> + > >>> select->select = res = av_expr_eval(select->expr, > >> select->var_values, NULL); > >>> av_log(inlink->dst, AV_LOG_DEBUG, > >>> "n:%f pts:%f t:%f key:%d", > >>> @@ -545,4 +558,4 @@ const AVFilter ff_vf_select = { > >>> FILTER_QUERY_FUNC(query_formats), > >>> .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | > >> AVFILTER_FLAG_METADATA_ONLY, > >>> }; > >>> -#endif /* CONFIG_SELECT_FILTER */ > >>> +#endif /* CONFIG_SELECT_FILTER */ > >>> \ No newline at end of file > >>> -- > >>> 2.43.0.windows.1 > >>> > >> > >> These two whitespace changes are still unnecessary. Please check your > >> patch before sending. > >> > >> I did remove all the unnecessary whitespaces ,rest which are present are > > to keep the code style . > > Patch is attached to this email. > > No, the last hunk still removes a newline. Sir, as far as I know git does that automatically. > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Fixes #10509
I have attached the git patch containing the changes for your review. This patch is submitted as part of my qualification task for Google Summer of Code (GSoC) 0001-avfilter-f_select.c-add-support-for-iw-and-ih-consta.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
On Mon, Mar 11, 2024 at 1:10 AM Leo Izen wrote: > > On 3/9/24 15:49, Poorva wrote: > > I have attached the git patch containing the changes for your review. > > > > This patch is submitted as part of my qualification task for Google Summer > > of Code (GSoC) > > > > Your editor appears to have stripped the newline at the end of the file. > Thank you for your feedback on the Git patch I submitted for review. I apologize for the newline issue; it seems my editor removed it unintentionally. I have rectified the problem by adding the necessary newline at the end of the file. The updated patch file is attached for your review. 0001-avfilter-f_select.c-add-support-for-iw-and-ih-consta.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
> On Sun, Mar 17, 2024 at 12:26 AM Marton Balint wrote: > > > > On Sun, 17 Mar 2024, Poorva wrote: > > > On Mon, Mar 11, 2024 at 1:10 AM Leo Izen wrote: > >> > >> On 3/9/24 15:49, Poorva wrote: > >>> I have attached the git patch containing the changes for your review. > >>> > >>> This patch is submitted as part of my qualification task for Google Summer > >>> of Code (GSoC) > >>> > >> > >> Your editor appears to have stripped the newline at the end of the file. > > > diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c > > index 9b330a0673..965f5a0b54 100644 > > --- a/libavfilter/f_select.c > > +++ b/libavfilter/f_select.c > > @@ -90,6 +90,9 @@ static const char *const var_names[] = { > > > > "concatdec_select", ///< frame is within the interval set by the > > concat demuxer > > > > +"ih",///< ih: Represents the height of the input video > > frame. > > +"iw",///< iw: Represents the width of the input video > > frame. > > + > > NULL > > }; > > > > @@ -144,6 +147,9 @@ enum var_name { > > > > VAR_CONCATDEC_SELECT, > > > > +VAR_IH, > > +VAR_IW, > > + > > VAR_VARS_NB > > }; > > > > @@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink) > > select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; > > select->var_values[VAR_SAMPLES_N] = NAN; > > > > +select->var_values[VAR_IH] = inlink->h; > > +select->var_values[VAR_IW] = inlink->w; > > Initial valaues should be NAN. This may well be an audio filter, when > ih/iw is not available. > > > + > > select->var_values[VAR_SAMPLE_RATE] = > > inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; > > > > @@ -371,6 +380,9 @@ FF_ENABLE_DEPRECATION_WARNINGS > > break; > > } > > > > +select->var_values[VAR_IH] = frame->height; > > +select->var_values[VAR_IW] = frame->width; > > You shold only set these for the VIDEO case. > > > + > > select->select = res = av_expr_eval(select->expr, select->var_values, > > NULL); > > av_log(inlink->dst, AV_LOG_DEBUG, > > "n:%f pts:%f t:%f key:%d", > > @@ -546,3 +558,4 @@ const AVFilter ff_vf_select = { > > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | > > AVFILTER_FLAG_METADATA_ONLY, > > }; > > #endif /* CONFIG_SELECT_FILTER */ > > + > > Extra added line. > > > -- > > 2.43.0.windows.1 > > Documentation update missing. Sir, I have made the changes as per your suggestions: 1)Initial values are now set to NaN. 2)Values are only set for the VIDEO case. 3)Documentation has been updated to reflect these changes accurately. I have attached the patch with the updated code for your review. > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". v2-0001-avfilter-f_select.c-add-support-for-iw-and-ih-con.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Fixes #10509
> On Mon, Mar 18, 2024 at 10:34 PM Poorva <2003gaikarpoo...@gmail.com> wrote: > > > > > On Sun, Mar 17, 2024 at 12:26 AM Marton Balint wrote: > > > > > > > > On Sun, 17 Mar 2024, Poorva wrote: > > > > > On Mon, Mar 11, 2024 at 1:10 AM Leo Izen wrote: > > >> > > >> On 3/9/24 15:49, Poorva wrote: > > >>> I have attached the git patch containing the changes for your review. > > >>> > > >>> This patch is submitted as part of my qualification task for Google > > >>> Summer > > >>> of Code (GSoC) > > >>> > > >> > > >> Your editor appears to have stripped the newline at the end of the file. > > > > > diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c > > > index 9b330a0673..965f5a0b54 100644 > > > --- a/libavfilter/f_select.c > > > +++ b/libavfilter/f_select.c > > > @@ -90,6 +90,9 @@ static const char *const var_names[] = { > > > > > > "concatdec_select", ///< frame is within the interval set by the > > > concat demuxer > > > > > > +"ih",///< ih: Represents the height of the input > > > video frame. > > > +"iw",///< iw: Represents the width of the input > > > video frame. > > > + > > > NULL > > > }; > > > > > > @@ -144,6 +147,9 @@ enum var_name { > > > > > > VAR_CONCATDEC_SELECT, > > > > > > +VAR_IH, > > > +VAR_IW, > > > + > > > VAR_VARS_NB > > > }; > > > > > > @@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink) > > > select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; > > > select->var_values[VAR_SAMPLES_N] = NAN; > > > > > > +select->var_values[VAR_IH] = inlink->h; > > > +select->var_values[VAR_IW] = inlink->w; > > > > Initial valaues should be NAN. This may well be an audio filter, when > > ih/iw is not available. > > > > > + > > > select->var_values[VAR_SAMPLE_RATE] = > > > inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; > > > > > > @@ -371,6 +380,9 @@ FF_ENABLE_DEPRECATION_WARNINGS > > > break; > > > } > > > > > > +select->var_values[VAR_IH] = frame->height; > > > +select->var_values[VAR_IW] = frame->width; > > > > You shold only set these for the VIDEO case. > > > > > + > > > select->select = res = av_expr_eval(select->expr, > > > select->var_values, NULL); > > > av_log(inlink->dst, AV_LOG_DEBUG, > > > "n:%f pts:%f t:%f key:%d", > > > @@ -546,3 +558,4 @@ const AVFilter ff_vf_select = { > > > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | > > > AVFILTER_FLAG_METADATA_ONLY, > > > }; > > > #endif /* CONFIG_SELECT_FILTER */ > > > + > > > > Extra added line. > > > > > -- > > > 2.43.0.windows.1 > > > > Documentation update missing. > Sir, I have made the changes as per your suggestions: > > 1)Initial values are now set to NaN. > 2)Values are only set for the VIDEO case. > 3)Documentation has been updated to reflect these changes accurately. > I have attached the patch with the updated code for your review. > I wanted to follow up on a patch I submitted earlier and provide an update based on the feedback received. Changes made in the update were: 1)Initial values are now set to NaN. 2)Values are only set for the VIDEO case. 3)Documentation has been updated to reflect these changes accurately. Despite the changes made, I have not received any further feedback or comments on the patch. Therefore, I kindly request the community to review the updated patch attached to this email. Your feedback and suggestions are highly valuable and appreciated. > > > Regards, > > Marton > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". v2-0001-avfilter-f_select.c-add-support-for-iw-and-ih-con.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] GSoC Project Submission: SiTi Filter Update for ITU-T P.910 Compliance and HDR Support
Hello FFmpeg Team, I am submitting the completed work from my Google Summer of Code project, which focuses on updating the SiTi filter for ITU-T P.910 07/22 compliance and adding HDR support. Attached is the patch for your review. I appreciate your feedback and suggestions. From e33fa1928164d986b5b62c02f00fab788a1f2f3b Mon Sep 17 00:00:00 2001 From: PoorvaGaikar <2003gaikarpoorva.com> Date: Wed, 17 Jul 2024 23:36:56 +0530 Subject: [PATCH] libavfilter/siti: Update SITI filter to align with ITU-T P.910 07/22 and add HDR support --- libavfilter/vf_siti.c | 217 -- 1 file changed, 208 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_siti.c b/libavfilter/vf_siti.c index 722e7cecc7..2bbcaa0afd 100644 --- a/libavfilter/vf_siti.c +++ b/libavfilter/vf_siti.c @@ -47,6 +47,19 @@ static const int Y_FILTER[9] = { -1, -2, -1 }; +static const float PU21_MATRICES[4][7] = { +// Reference: "PU21: A novel perceptually uniform encoding for adapting existing quality metrics for HDR" +// Rafał K. Mantiuk and M. Azimi, Picture Coding Symposium 2021 +// https://github.com/gfxdisp/pu21 +{1.070275272f, 0.4088273932f, 0.153224308f, 0.2520326168f, 1.063512885f, 1.14115047f, 521.4527484f}, // BANDING +{0.353487901f, 0.3734658629f, 8.277049286e-05f, 0.9062562627f, 0.09150303166f, 0.9099517204f, 596.3148142f}, // BANDING_GLARE +{1.043882782f, 0.6459495343f, 0.3194584211f, 0.374025247f, 1.114783422f, 1.095360363f, 384.9217577f}, // PEAKS +{816.885024f, 1479.463946f, 0.001253215609f, 0.9329636822f, 0.06746643971f, 1.573435413f, 419.6006374f} // PEAKS_GLARE +}; + +static const float PU21_MIN_VALUES[4] = {-1.5580e-07f, 5.4705e-10f, 1.3674e-07f, -9.7360e-08f}; +static const float PU21_MAX_VALUES[4] = {520.4673f, 595.3939f, 380.9853f, 407.5066f}; + typedef struct SiTiContext { const AVClass *class; int pixel_depth; @@ -63,8 +76,45 @@ typedef struct SiTiContext { float *motion_matrix; int full_range; int print_summary; +int hdr_mode; +int bit_depth; +int color_range; +int eotf_function; +int calculation_domain; +float l_max; +float l_min; +float gamma; +int pu21_mode; } SiTiContext; +enum HdrMode { +SDR, +HDR10, +HLG +}; + +enum ColorRange { +LIMITED, +FULL +}; + +enum EotfFunction { +BT1886, +INV_SRGB +}; + +enum CalculationDomain { +PQ, +PU21 +}; + +enum Pu21Mode { +BANDING, +BANDING_GLARE, +PEAKS, +PEAKS_GLARE +}; + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, @@ -78,6 +128,15 @@ static av_cold int init(AVFilterContext *ctx) SiTiContext *s = ctx->priv; s->max_si = 0; s->max_ti = 0; +s->hdr_mode = SDR; +s->bit_depth = 8; +s->color_range = LIMITED; +s->eotf_function = BT1886; +s->calculation_domain = PQ; +s->l_max = 300.0; +s->l_min = 0.1; +s->gamma = 2.4; +s->pu21_mode = BANDING; return 0; } @@ -166,6 +225,105 @@ static uint16_t convert_full_range(int factor, uint16_t y) return (full_upper * limit_y / limit_upper); } +// EOTF for BT.1886 +static float eotf_1886(float x, float gamma, float l_min, float l_max) +{ +// Reference: ITU-R BT.1886, Annex 1 +// https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.1886-0-201103-I!!PDF-E.pdf +const float l_max_gamma = powf(l_max, 1.0f / gamma); +const float l_min_gamma = powf(l_min, 1.0f / gamma); +const float l_diff_gamma = l_max_gamma - l_min_gamma; +const float a = powf(l_diff_gamma, gamma); +const float b = l_min_gamma / l_diff_gamma; +const float adjusted_x = fmaxf(x + b, 0.0f); + +return a * powf(adjusted_x, gamma); +} + +static float eotf_inv_srgb(float x) +{ +// Inverse sRGB EOTF (Electro-Optical Transfer Function) according to IEC 61966-2-1:1999 +// Section G.2 (Encoding transformation) +// Reference: https://cdn.standards.iteh.ai/samples/10795/ae461684569b402d9a22b1047f05/IEC-61966-2-1-1999-AMD1-2003.pdf +return (x <= 0.04045f) ? x / 12.92f : powf((x + 0.055f) / 1.055f, 2.4f); +} + +static float apply_display_model(SiTiContext *s, float x) +{ +// Apply either BT.1886 or inverse sRGB EOTF based on the context +if (s->eotf_function == BT1886) { +// BT.1886 EOTF +// Reference: ITU-R BT.1886-0, Annex 1 +// https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.1886-0-201103-I!!PDF-E.pdf +return eotf_1886(x, s->gamma, 0.0f, 1.0f); +} else { +// Inverse sRGB EOTF +return eotf_inv_srgb(x); +} +} + +static float oetf_pq(float x) +{ +// PQ (Perceptual Quantizer) OETF according to ITU-R BT.2100-2 +// Reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-2-201807-I!!PDF-E.pdf +// See page 5, Table 4 + +const float m1 = 0.1593017578125f; +const float m2 = 78.84375f; +const float c1 =