avcodec/h264_slice: compute and export film grain seed
authorNiklas Haas <git@haasn.dev>
Tue, 17 Aug 2021 19:25:31 +0000 (21:25 +0200)
committerJames Almer <jamrial@gmail.com>
Tue, 24 Aug 2021 12:58:52 +0000 (09:58 -0300)
commitcf37c3fb6c84d8eb61079520b4c57e3c969bc25d
treed449ba2158a00e4f606f1ce9faea50811ee32086
parent61b38f7aef8d2f34135eb6a1e1e637d4fef667d2
avcodec/h264_slice: compute and export film grain seed

From SMPTE RDD 5-2006, the grain seed is to be computed from the
following definition of `pic_offset`:

> When decoding H.264 | MPEG-4 AVC bitstreams, pic_offset is defined as
> follows:
>   - pic_offset = PicOrderCnt(CurrPic) + (PicOrderCnt_offset << 5)
> where:
>   - PicOrderCnt(CurrPic) is the picture order count of the current frame,
>     which shall be derived from [the video stream].
>
>   - PicOrderCnt_offset is set to idr_pic_id on IDR frames. idr_pic_id
>     shall be read from the slice header of [the video stream]. On non-IDR I
>     frames, PicOrderCnt_offset is set to 0. A frame shall be classified as I
>     frame when all its slices are I slices, which may be optionally
>     designated by setting primary_pic_type to 0 in the access delimiter NAL
>     unit. Otherwise, PicOrderCnt_offset it not changed. PicOrderCnt_offset is
>     updated in decoding order.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/h264_slice.c
libavcodec/h264dec.c
libavcodec/h264dec.h
libavutil/film_grain_params.h