Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/4] avcodec/aom_film_grain: add AOM film grain synthesis
Date: Wed, 28 Feb 2024 16:45:50 +0100
Message-ID: <AS8P250MB07444A6DC45286BA843A5A198F582@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240226143521.57913-1-ffmpeg@haasn.xyz>

Niklas Haas:
> From: Niklas Haas <git@haasn.dev>
> 
> Implementation copied wholesale from dav1d, sans SIMD, under permissive
> license. This implementation was extensively verified to be bit-exact,
> so it serves as a much better starting point than trying to re-engineer
> this from scratch for no reason. (I also authored the original
> implementation in dav1d, so any "clean room" implementation would end up
> looking much the same, anyway)
> 
> The notable changes I had to make while adapting this from the dav1d
> code-base to the FFmpeg codebase include:
> 
> - replacing bitdepth parameters by preprocessor symbol (BITDEPTH)
> - reordering variable declarations to avoid triggering warnings
> - replacing several inline helpers by avutil equivalents
> - changing code that accesses frame metadata
> - replacing raw plane copying logic by av_image_copy_plane
> 
> Apart from this, the implementation is basically unmodified.
> ---
>  libavcodec/aom_film_grain.c          | 288 +++++++++++++
>  libavcodec/aom_film_grain.h          |  38 ++
>  libavcodec/aom_film_grain_template.c | 599 +++++++++++++++++++++++++++
>  3 files changed, 925 insertions(+)
>  create mode 100644 libavcodec/aom_film_grain.c
>  create mode 100644 libavcodec/aom_film_grain.h
>  create mode 100644 libavcodec/aom_film_grain_template.c
> 
> diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c
> new file mode 100644
> index 00000000000..1bdaafc39f7
> --- /dev/null
> +++ b/libavcodec/aom_film_grain.c
> @@ -0,0 +1,288 @@
> +/*
> + * AOM film grain synthesis
> + * Copyright (c) 2023 Niklas Haas <ffmpeg@haasn.xyz>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file
> + * AOM film grain synthesis.
> + * @author Niklas Haas <ffmpeg@haasn.xyz>
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +
> +#include "aom_film_grain.h"
> +
> +// Common/shared helpers (not dependent on BITDEPTH)
> +static inline int get_random_number(const int bits, unsigned *const state) {
> +    const int r = *state;
> +    unsigned bit = ((r >> 0) ^ (r >> 1) ^ (r >> 3) ^ (r >> 12)) & 1;
> +    *state = (r >> 1) | (bit << 15);
> +
> +    return (*state >> (16 - bits)) & ((1 << bits) - 1);
> +}
> +
> +static inline int round2(const int x, const uint64_t shift) {
> +    return (x + ((1 << shift) >> 1)) >> shift;
> +}
> +
> +static const int16_t gaussian_sequence[2048];
> +
> +#define BITDEPTH 12
> +#include "aom_film_grain_template.c"
> +#undef BITDEPTH
> +
> +#define BITDEPTH 10
> +#include "aom_film_grain_template.c"
> +#undef BITDEPTH
> +
> +#define BITDEPTH 9
> +#include "aom_film_grain_template.c"
> +#undef BITDEPTH
> +
> +#define BITDEPTH 8
> +#include "aom_film_grain_template.c"
> +#undef BITDEPTH

I don't think this should be duplicated for every bitdepth.

- Andreas

_______________________________________________
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-02-28 15:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 14:35 Niklas Haas
2024-02-26 14:35 ` [FFmpeg-devel] [PATCH 2/4] avcodec/aom_film_grain: implement AFGS1 Niklas Haas
2024-02-26 14:35 ` [FFmpeg-devel] [PATCH 3/4] avcodec/h2645_sei: decode AFGS1 T.35 SEI Niklas Haas
2024-02-26 14:35 ` [FFmpeg-devel] [PATCH 4/4] avcodec/hevcdec: apply AOM film grain synthesis Niklas Haas
2024-02-28 15:45 ` Andreas Rheinhardt [this message]
2024-02-28 15:56   ` [FFmpeg-devel] [PATCH 1/4] avcodec/aom_film_grain: add " Niklas Haas
2024-02-28 16:01     ` Andreas Rheinhardt
2024-02-29 11:03       ` Niklas Haas
2024-02-29 11:36         ` Andreas Rheinhardt
2024-02-29 12:13           ` Niklas Haas
2024-02-29 11:52         ` Andreas Rheinhardt
2024-02-29 12:18           ` 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=AS8P250MB07444A6DC45286BA843A5A198F582@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /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