From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH v3 9/9] avcodec/hevcdec: apply AOM film grain synthesis Date: Fri, 15 Mar 2024 12:59:02 +0100 Message-ID: <20240315120442.73754-10-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20240315120442.73754-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> Following the usual logic for H.274 film grain. --- libavcodec/Makefile | 2 +- libavcodec/hevcdec.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 824845276ae..7ef2e03ca6a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -432,7 +432,7 @@ OBJS-$(CONFIG_HDR_ENCODER) += hdrenc.o OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \ hevc_cabac.o hevc_refs.o hevcpred.o \ hevcdsp.o hevc_filter.o hevc_data.o \ - h274.o + h274.o aom_film_grain.o OBJS-$(CONFIG_HEVC_AMF_ENCODER) += amfenc_hevc.o OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 76aa6b45882..575836e340c 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -35,6 +35,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/timecode.h" +#include "aom_film_grain.h" #include "bswapdsp.h" #include "cabac_functions.h" #include "codec_internal.h" @@ -388,7 +389,8 @@ static int export_stream_params_from_sei(HEVCContext *s) avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics; } - if (s->sei.common.film_grain_characteristics.present) + if (s->sei.common.film_grain_characteristics.present || + s->sei.common.aom_film_grain.enable) avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; return 0; @@ -2885,11 +2887,13 @@ static int hevc_frame_start(HEVCContext *s) else s->ref->frame->flags &= ~AV_FRAME_FLAG_KEY; - s->ref->needs_fg = s->sei.common.film_grain_characteristics.present && + s->ref->needs_fg = (s->sei.common.film_grain_characteristics.present || + s->sei.common.aom_film_grain.enable) && !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && !s->avctx->hwaccel; if (s->ref->needs_fg && + s->sei.common.film_grain_characteristics.present && !ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id, s->ref->frame->format)) { av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown, @@ -2934,14 +2938,24 @@ fail: static int hevc_frame_end(HEVCContext *s) { HEVCFrame *out = s->ref; - const AVFrameSideData *sd; + const AVFilmGrainParams *fgp; av_unused int ret; if (out->needs_fg) { - sd = av_frame_get_side_data(out->frame, AV_FRAME_DATA_FILM_GRAIN_PARAMS); - av_assert0(out->frame_grain->buf[0] && sd); - ret = ff_h274_apply_film_grain(out->frame_grain, out->frame, &s->h274db, - (AVFilmGrainParams *) sd->data); + av_assert0(out->frame_grain->buf[0]); + fgp = av_film_grain_params_select(out->frame); + switch (fgp->type) { + case AV_FILM_GRAIN_PARAMS_NONE: + av_assert0(0); + return AVERROR_BUG; + case AV_FILM_GRAIN_PARAMS_H274: + ret = ff_h274_apply_film_grain(out->frame_grain, out->frame, + &s->h274db, fgp); + break; + case AV_FILM_GRAIN_PARAMS_AV1: + ret = ff_aom_apply_film_grain(out->frame_grain, out->frame, fgp); + break; + } av_assert1(ret >= 0); } @@ -3596,6 +3610,7 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer; s->sei.common.mastering_display = s0->sei.common.mastering_display; s->sei.common.content_light = s0->sei.common.content_light; + s->sei.common.aom_film_grain = s0->sei.common.aom_film_grain; ret = export_stream_params_from_sei(s); if (ret < 0) -- 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".
prev 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 ` [FFmpeg-devel] [PATCH v3 8/9] avcodec/h2645_sei: decode AFGS1 T.35 SEI Niklas Haas 2024-03-15 11:59 ` Niklas Haas [this message]
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-10-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