Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH v3 8/9] avcodec/h2645_sei: decode AFGS1 T.35 SEI
Date: Fri, 15 Mar 2024 12:59:01 +0100
Message-ID: <20240315120442.73754-9-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20240315120442.73754-1-ffmpeg@haasn.xyz>

From: Niklas Haas <git@haasn.dev>

I restricted this SEI to HEVC for now, until I see a H.264 sample.
---
 libavcodec/Makefile    |  2 +-
 libavcodec/h2645_sei.c | 25 +++++++++++++++++++++++++
 libavcodec/h2645_sei.h |  3 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 708434ac76c..824845276ae 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -105,7 +105,7 @@ OBJS-$(CONFIG_H264_SEI)                += h264_sei.o h2645_sei.o
 OBJS-$(CONFIG_HEVCPARSE)               += hevc_parse.o hevc_ps.o hevc_data.o \
                                           h2645data.o h2645_parse.o h2645_vui.o
 OBJS-$(CONFIG_HEVC_SEI)                += hevc_sei.o h2645_sei.o \
-                                          dynamic_hdr_vivid.o
+                                          dynamic_hdr_vivid.o aom_film_grain.o
 OBJS-$(CONFIG_HPELDSP)                 += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN)                 += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)              += huffyuvdsp.o
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index e60606f43f9..2e79b9ea78b 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -209,6 +209,24 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
         }
         break;
     }
+    case 0x5890: { // aom_provider_code
+        const uint16_t aom_grain_provider_oriented_code = 0x0001;
+        uint16_t provider_oriented_code;
+
+        if (!IS_HEVC(codec_id))
+            goto unsupported_provider_code;
+
+        if (bytestream2_get_bytes_left(gb) < 2)
+            return AVERROR_INVALIDDATA;
+
+        provider_oriented_code = bytestream2_get_byteu(gb);
+        if (provider_oriented_code == aom_grain_provider_oriented_code) {
+            return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
+                                                gb->buffer,
+                                                bytestream2_get_bytes_left(gb));
+        }
+        break;
+    }
     unsupported_provider_code:
 #endif
     default:
@@ -692,6 +710,12 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
             avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
     }
 
+#if CONFIG_HEVC_SEI
+    ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame);
+    if (ret < 0)
+        return ret;
+#endif
+
     if (sei->ambient_viewing_environment.present) {
         H2645SEIAmbientViewingEnvironment *env =
             &sei->ambient_viewing_environment;
@@ -788,4 +812,5 @@ void ff_h2645_sei_reset(H2645SEI *s)
     s->ambient_viewing_environment.present = 0;
     s->mastering_display.present = 0;
     s->content_light.present = 0;
+    s->aom_film_grain.enable = 0;
 }
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 0ebf48011af..b9a6c7587b1 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -23,7 +23,9 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/frame.h"
+#include "libavutil/film_grain_params.h"
 
+#include "aom_film_grain.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_id.h"
@@ -132,6 +134,7 @@ typedef struct H2645SEI {
     H2645SEIAmbientViewingEnvironment ambient_viewing_environment;
     H2645SEIMasteringDisplay mastering_display;
     H2645SEIContentLight content_light;
+    AVFilmGrainAFGS1Params aom_film_grain;
 } H2645SEI;
 
 enum {
-- 
2.44.0

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

  parent reply	other threads:[~2024-03-15 12:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 11:58 [FFmpeg-devel] [PATCH v3 0/9] AFGS1 film grain support Niklas Haas
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 1/9] avutil/film_grain_params: add extra AFGS1 metadata Niklas Haas
2024-03-15 12:18   ` James Almer
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 2/9] avcodec/av1dec: initialize AFGS1 VSC metadata Niklas Haas
2024-03-15 12:20   ` James Almer
2024-03-15 12:23     ` Niklas Haas
2024-03-15 12:25       ` James Almer
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 3/9] avcodec/libdav1d: " Niklas Haas
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 4/9] avutil/frame: clarify AV_FRAME_DATA_FILM_GRAIN_PARAMS usage Niklas Haas
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 5/9] avutil/film_grain_params: add av_film_grain_params_select() Niklas Haas
2024-03-15 12:22   ` Niklas Haas
2024-03-15 11:58 ` [FFmpeg-devel] [PATCH v3 6/9] avcodec/aom_film_grain: add AOM film grain synthesis Niklas Haas
2024-03-15 11:59 ` [FFmpeg-devel] [PATCH v3 7/9] avcodec/aom_film_grain: implement AFGS1 parsing Niklas Haas
2024-03-15 11:59 ` Niklas Haas [this message]
2024-03-15 11:59 ` [FFmpeg-devel] [PATCH v3 9/9] avcodec/hevcdec: apply AOM film grain synthesis Niklas Haas

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=20240315120442.73754-9-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /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