Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support
@ 2024-02-27 13:43 Niklas Haas
  2024-02-27 13:43 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing Niklas Haas
  2024-03-03 15:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Stefano Sabatini
  0 siblings, 2 replies; 4+ messages in thread
From: Niklas Haas @ 2024-02-27 13:43 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

For my own testing purposes.
---
 libavfilter/vf_showinfo.c | 42 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 309de28df91..830170363bc 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -462,8 +462,46 @@ static void dump_sei_film_grain_params_metadata(AVFilterContext *ctx, const AVFr
 
     switch (fgp->type) {
     case AV_FILM_GRAIN_PARAMS_NONE:
-    case AV_FILM_GRAIN_PARAMS_AV1:
-        return;
+        break;
+    case AV_FILM_GRAIN_PARAMS_AV1: {
+        const AVFilmGrainAOMParams *aom = &fgp->codec.aom;
+        const int num_ar_coeffs_y = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1);
+        const int num_ar_coeffs_uv = num_ar_coeffs_y + !!aom->num_y_points;
+        av_log(ctx, AV_LOG_INFO, "y_points={ ");
+        for (int i = 0; i < aom->num_y_points; i++)
+            av_log(ctx, AV_LOG_INFO, "{%d, %d} ", aom->y_points[i][0], aom->y_points[i][1]);
+        av_log(ctx, AV_LOG_INFO, "}; chroma_scaling_from_luma=%d; ", aom->chroma_scaling_from_luma);
+        for (int uv = 0; uv < 2; uv++) {
+            av_log(ctx, AV_LOG_INFO, "uv_points[%d]={ ", uv);
+            for (int i = 0; i < aom->num_uv_points[uv]; i++)
+                av_log(ctx, AV_LOG_INFO, "{%d %d} ", aom->uv_points[uv][i][0], aom->uv_points[uv][i][1]);
+            av_log(ctx, AV_LOG_INFO, "}; ");
+        }
+        av_log(ctx, AV_LOG_INFO, "scaling_shift=%d; ", aom->scaling_shift);
+        av_log(ctx, AV_LOG_INFO, "ar_coeff_lag=%d; ", aom->ar_coeff_lag);
+        if (num_ar_coeffs_y) {
+            av_log(ctx, AV_LOG_INFO, "ar_coeffs_y={ ");
+            for (int i = 0; i < num_ar_coeffs_y; i++)
+                av_log(ctx, AV_LOG_INFO, "%d ", aom->ar_coeffs_y[i]);
+            av_log(ctx, AV_LOG_INFO, "}; ");
+        }
+        for (int uv = 0; num_ar_coeffs_uv && uv < 2; uv++) {
+            av_log(ctx, AV_LOG_INFO, "ar_coeffs_uv[%d]={ ", uv);
+            for (int i = 0; i < num_ar_coeffs_uv; i++)
+                av_log(ctx, AV_LOG_INFO, "%d ", aom->ar_coeffs_uv[uv][i]);
+            av_log(ctx, AV_LOG_INFO, "}; ");
+        }
+        av_log(ctx, AV_LOG_INFO, "ar_coeff_shift=%d; ", aom->ar_coeff_shift);
+        av_log(ctx, AV_LOG_INFO, "grain_scale_shift=%d; ", aom->grain_scale_shift);
+        for (int uv = 0; uv < 2; uv++) {
+            av_log(ctx, AV_LOG_INFO, "uv_mult[%d] = %d; ", uv, aom->uv_mult[uv]);
+            av_log(ctx, AV_LOG_INFO, "uv_mult_luma[%d] = %d; ", uv, aom->uv_mult_luma[uv]);
+            av_log(ctx, AV_LOG_INFO, "uv_offset[%d] = %d; ", uv, aom->uv_offset[uv]);
+        }
+        av_log(ctx, AV_LOG_INFO, "overlap_flag=%d; ", aom->overlap_flag);
+        av_log(ctx, AV_LOG_INFO, "limit_output_range=%d; ", aom->limit_output_range);
+        break;
+    }
     case AV_FILM_GRAIN_PARAMS_H274: {
         const AVFilmGrainH274Params *h274 = &fgp->codec.h274;
         const char *color_range_str     = av_color_range_name(h274->color_range);
-- 
2.43.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing
  2024-02-27 13:43 [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Niklas Haas
@ 2024-02-27 13:43 ` Niklas Haas
  2024-03-03 16:19   ` Stefano Sabatini
  2024-03-03 15:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Stefano Sabatini
  1 sibling, 1 reply; 4+ messages in thread
From: Niklas Haas @ 2024-02-27 13:43 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

So we can add a FATE test for this.
---
 fftools/ffprobe.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index ea225f14ab7..a2e02604dc5 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -39,6 +39,7 @@
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
+#include "libavutil/film_grain_params.h"
 #include "libavutil/hash.h"
 #include "libavutil/hdr_dynamic_metadata.h"
 #include "libavutil/mastering_display_metadata.h"
@@ -2331,6 +2332,120 @@ static void print_ambient_viewing_environment(WriterContext *w,
     print_q("ambient_light_y",     env->ambient_light_y,     '/');
 }
 
+static void print_film_grain_params(WriterContext *w,
+                                    const AVFilmGrainParams *fgp)
+{
+    AVBPrint pbuf;
+    if (!fgp)
+        return;
+
+    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
+
+    switch (fgp->type) {
+    case AV_FILM_GRAIN_PARAMS_NONE:
+        print_str("type", "none");
+        break;
+    case AV_FILM_GRAIN_PARAMS_AV1: {
+        const AVFilmGrainAOMParams *aom = &fgp->codec.aom;
+        const int num_ar_coeffs_y = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1);
+        const int num_ar_coeffs_uv = num_ar_coeffs_y + !!aom->num_y_points;
+        print_str("type", "av1");
+        print_fmt("seed", "%"PRIu64, fgp->seed);
+        print_int("chroma_scaling_from_luma", aom->chroma_scaling_from_luma);
+        print_int("scaling_shift", aom->scaling_shift);
+        print_int("ar_coeff_lag", aom->ar_coeff_lag);
+        print_int("ar_coeff_shift", aom->ar_coeff_shift);
+        print_int("grain_scale_shift", aom->grain_scale_shift);
+        print_int("overlap_flag", aom->overlap_flag);
+        print_int("limit_output_range", aom->limit_output_range);
+
+        writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
+
+        if (aom->num_y_points) {
+            writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
+
+            print_list_fmt("y_points_value", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][0]);
+            print_list_fmt("y_points_scaling", "%"PRIu8, aom->num_y_points, 1, aom->y_points[idx][1]);
+            print_list_fmt("ar_coeffs_y", "%"PRId8, num_ar_coeffs_y, 1, aom->ar_coeffs_y[idx]);
+
+            // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
+            writer_print_section_footer(w);
+        }
+
+        for (int uv = 0; uv < 2; uv++) {
+            if (!aom->num_uv_points[uv] && !aom->chroma_scaling_from_luma)
+                continue;
+
+            writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
+
+            print_list_fmt("uv_points_value", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][0]);
+            print_list_fmt("uv_points_scaling", "%"PRIu8, aom->num_uv_points[uv], 1, aom->uv_points[uv][idx][1]);
+            print_list_fmt("ar_coeffs_uv", "%"PRId8, num_ar_coeffs_uv, 1, aom->ar_coeffs_uv[uv][idx]);
+            print_int("uv_mult", aom->uv_mult[uv]);
+            print_int("uv_mult_luma", aom->uv_mult_luma[uv]);
+            print_int("uv_offset", aom->uv_offset[uv]);
+
+            // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
+            writer_print_section_footer(w);
+        }
+
+        // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
+        writer_print_section_footer(w);
+        break;
+    }
+    case AV_FILM_GRAIN_PARAMS_H274: {
+        const AVFilmGrainH274Params *h274 = &fgp->codec.h274;
+        const char *color_range_str     = av_color_range_name(h274->color_range);
+        const char *color_primaries_str = av_color_primaries_name(h274->color_primaries);
+        const char *color_trc_str       = av_color_transfer_name(h274->color_trc);
+        const char *color_space_str     = av_color_space_name(h274->color_space);
+        print_str("type", "h274");
+        print_fmt("seed", "%"PRIu64, fgp->seed);
+        print_int("model_id", h274->model_id);
+        print_str("color_range", color_range_str ? color_range_str : "unknown");
+        print_str("color_primaries", color_primaries_str ? color_primaries_str : "unknown");
+        print_str("color_trc", color_trc_str ? color_trc_str : "unknown");
+        print_str("color_space", color_space_str ? color_space_str : "unknown");
+        print_int("blending_mode_id", h274->blending_mode_id);
+        print_int("log2_scale_factor", h274->log2_scale_factor);
+
+        writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST);
+
+        for (int c = 0; c < 3; c++) {
+            if (!h274->component_model_present[c])
+                continue;
+
+            writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_COMPONENT);
+            print_int(c ? "bit_depth_chroma" : "bit_depth_luma", c ? h274->bit_depth_chroma : h274->bit_depth_luma);
+
+            writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST);
+            for (int i = 0; i < h274->num_intensity_intervals[c]; i++) {
+
+                writer_print_section_header(w, NULL, SECTION_ID_FRAME_SIDE_DATA_PIECE);
+                print_int("intensity_interval_lower_bound", h274->intensity_interval_lower_bound[c][i]);
+                print_int("intensity_interval_upper_bound", h274->intensity_interval_upper_bound[c][i]);
+                print_list_fmt("comp_model_value", "%"PRId16, h274->num_model_values[c], 1, h274->comp_model_value[c][i][idx]);
+
+                // SECTION_ID_FRAME_SIDE_DATA_PIECE
+                writer_print_section_footer(w);
+            }
+
+            // SECTION_ID_FRAME_SIDE_DATA_PIECE_LIST
+            writer_print_section_footer(w);
+
+            // SECTION_ID_FRAME_SIDE_DATA_COMPONENT
+            writer_print_section_footer(w);
+        }
+
+        // SECTION_ID_FRAME_SIDE_DATA_COMPONENT_LIST
+        writer_print_section_footer(w);
+        break;
+    }
+    }
+
+    av_bprint_finalize(&pbuf, NULL);
+}
+
 static void print_pkt_side_data(WriterContext *w,
                                 AVCodecParameters *par,
                                 const AVPacketSideData *sd,
@@ -2704,6 +2819,9 @@ static void print_frame_side_data(WriterContext *w,
             print_dynamic_hdr_vivid(w, metadata);
         } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
             print_ambient_viewing_environment(w, (const AVAmbientViewingEnvironment *)sd->data);
+        } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
+            AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
+            print_film_grain_params(w, fgp);
         }
         writer_print_section_footer(w);
     }
-- 
2.43.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support
  2024-02-27 13:43 [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Niklas Haas
  2024-02-27 13:43 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing Niklas Haas
@ 2024-03-03 15:53 ` Stefano Sabatini
  1 sibling, 0 replies; 4+ messages in thread
From: Stefano Sabatini @ 2024-03-03 15:53 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Niklas Haas

On date Tuesday 2024-02-27 14:43:12 +0100, Niklas Haas wrote:
> From: Niklas Haas <git@haasn.dev>
> 

> For my own testing purposes.

You can drop "my own".

> ---
>  libavfilter/vf_showinfo.c | 42 +++++++++++++++++++++++++++++++++++++--
>  1 file changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index 309de28df91..830170363bc 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -462,8 +462,46 @@ static void dump_sei_film_grain_params_metadata(AVFilterContext *ctx, const AVFr
>  
>      switch (fgp->type) {
>      case AV_FILM_GRAIN_PARAMS_NONE:
> -    case AV_FILM_GRAIN_PARAMS_AV1:
> -        return;
> +        break;
> +    case AV_FILM_GRAIN_PARAMS_AV1: {
> +        const AVFilmGrainAOMParams *aom = &fgp->codec.aom;
> +        const int num_ar_coeffs_y = 2 * aom->ar_coeff_lag * (aom->ar_coeff_lag + 1);
> +        const int num_ar_coeffs_uv = num_ar_coeffs_y + !!aom->num_y_points;
> +        av_log(ctx, AV_LOG_INFO, "y_points={ ");

> +        for (int i = 0; i < aom->num_y_points; i++)
> +            av_log(ctx, AV_LOG_INFO, "{%d, %d} ", aom->y_points[i][0], aom->y_points[i][1]);

nit++: other instances make use of () to delimit vector values

> +        av_log(ctx, AV_LOG_INFO, "}; chroma_scaling_from_luma=%d; ", aom->chroma_scaling_from_luma);
> +        for (int uv = 0; uv < 2; uv++) {
> +            av_log(ctx, AV_LOG_INFO, "uv_points[%d]={ ", uv);
> +            for (int i = 0; i < aom->num_uv_points[uv]; i++)
> +                av_log(ctx, AV_LOG_INFO, "{%d %d} ", aom->uv_points[uv][i][0], aom->uv_points[uv][i][1]);
> +            av_log(ctx, AV_LOG_INFO, "}; ");
> +        }
> +        av_log(ctx, AV_LOG_INFO, "scaling_shift=%d; ", aom->scaling_shift);
> +        av_log(ctx, AV_LOG_INFO, "ar_coeff_lag=%d; ", aom->ar_coeff_lag);

nit: using "," seems more consistent with other instances, here and below

> +        if (num_ar_coeffs_y) {
> +            av_log(ctx, AV_LOG_INFO, "ar_coeffs_y={ ");
> +            for (int i = 0; i < num_ar_coeffs_y; i++)
> +                av_log(ctx, AV_LOG_INFO, "%d ", aom->ar_coeffs_y[i]);
> +            av_log(ctx, AV_LOG_INFO, "}; ");
> +        }
> +        for (int uv = 0; num_ar_coeffs_uv && uv < 2; uv++) {
> +            av_log(ctx, AV_LOG_INFO, "ar_coeffs_uv[%d]={ ", uv);
> +            for (int i = 0; i < num_ar_coeffs_uv; i++)
> +                av_log(ctx, AV_LOG_INFO, "%d ", aom->ar_coeffs_uv[uv][i]);
> +            av_log(ctx, AV_LOG_INFO, "}; ");
> +        }
> +        av_log(ctx, AV_LOG_INFO, "ar_coeff_shift=%d; ", aom->ar_coeff_shift);
> +        av_log(ctx, AV_LOG_INFO, "grain_scale_shift=%d; ", aom->grain_scale_shift);
> +        for (int uv = 0; uv < 2; uv++) {
> +            av_log(ctx, AV_LOG_INFO, "uv_mult[%d] = %d; ", uv, aom->uv_mult[uv]);
> +            av_log(ctx, AV_LOG_INFO, "uv_mult_luma[%d] = %d; ", uv, aom->uv_mult_luma[uv]);
> +            av_log(ctx, AV_LOG_INFO, "uv_offset[%d] = %d; ", uv, aom->uv_offset[uv]);
> +        }
> +        av_log(ctx, AV_LOG_INFO, "overlap_flag=%d; ", aom->overlap_flag);
> +        av_log(ctx, AV_LOG_INFO, "limit_output_range=%d; ", aom->limit_output_range);
> +        break;
> +    }
>      case AV_FILM_GRAIN_PARAMS_H274: {
>          const AVFilmGrainH274Params *h274 = &fgp->codec.h274;
>          const char *color_range_str     = av_color_range_name(h274->color_range);
> -- 

LGTM otherwise (and no need to send another patch).

Unrelated note: probably we should define a serialization method at
the library level, then we might employ the same code to display the
information here and in ffprobe (this was the work proposed by
Nicolas).
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing
  2024-02-27 13:43 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing Niklas Haas
@ 2024-03-03 16:19   ` Stefano Sabatini
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Sabatini @ 2024-03-03 16:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Niklas Haas

On date Tuesday 2024-02-27 14:43:13 +0100, Niklas Haas wrote:
> From: Niklas Haas <git@haasn.dev>
> 
> So we can add a FATE test for this.
> ---
>  fftools/ffprobe.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 118 insertions(+)

Looks good to me, probably you can add an entry to the Changelog to
advertise the new feature.

Thanks.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-03 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 13:43 [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Niklas Haas
2024-02-27 13:43 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: add AVFilmGrainParams printing Niklas Haas
2024-03-03 16:19   ` Stefano Sabatini
2024-03-03 15:53 ` [FFmpeg-devel] [PATCH 1/2] avfilter/vf_showinfo: add AVFilmGrainAOMParams support Stefano Sabatini

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