[FFmpeg-devel] [PATCH v3] avcodec/h264dec: apply H.274 film grain

James Almer jamrial at gmail.com
Wed Aug 18 01:53:17 EEST 2021


On 8/17/2021 4:54 PM, Niklas Haas wrote:
> From: Niklas Haas <git at haasn.dev>
> 
> Because we need access to ref frames without film grain applied, we have
> to add an extra AVFrame to H264Picture to avoid messing with the
> original. This requires some amount of overhead to make the reference
> moves work out, but it allows us to benefit from frame multithreading
> for film grain application "for free".
> 
> Unfortunately, this approach requires twice as much RAM to be constantly
> allocated for ref frames, due to the need for an extra buffer per
> H264Picture. In theory, we could get away with freeing up this memory as
> soon as it's no longer needed (since ref frames do not need film grain
> buffers any longer), but trying to call ff_thread_release_buffer() from
> output_frame() conflicts with possible later accesses to that same frame
> and I'm not sure how to synchronize that well.
> 
> Tested on all three cases of (no fg), (fg present but exported) and (fg
> present and not exported), with and without threading.
> 
> Signed-off-by: Niklas Haas <git at haasn.dev>
> ---
>   libavcodec/h264_picture.c | 35 +++++++++++++++++++++++--
>   libavcodec/h264_slice.c   | 16 ++++++++++--
>   libavcodec/h264dec.c      | 55 ++++++++++++++++++++++++++-------------
>   libavcodec/h264dec.h      |  6 +++++
>   4 files changed, 90 insertions(+), 22 deletions(-)

Looks good now, so I'll apply it soon.


More information about the ffmpeg-devel mailing list