• Niklas Haas's avatar
    avcodec/h274: add film grain synthesis routine · 6bc29a6b
    Niklas Haas authored
    This could arguably also be a vf, but I decided to put it here since
    decoders are technically required to apply film grain during the output
    step, and I would rather want to avoid requiring users insert the
    correct film grain synthesis filter on their own.
    
    The code, while in C, is written in a way that unrolls/vectorizes fairly
    well under -O3, and is reasonably cache friendly. On my CPU, a single
    thread pushes about 400 FPS at 1080p.
    
    Apart from hand-written assembly, one possible avenue of improvement
    would be to change the access order to compute the grain row-by-row
    rather than in 8x8 blocks. This requires some redundant PRNG calls, but
    would make the algorithm more cache-oblivious.
    
    The implementation has been written to the wording of SMPTE RDD 5-2006
    as faithfully as I can manage. However, apart from passing a visual
    inspection, no guarantee of correctness can be made due to the lack of
    any publicly available reference implementation against which to
    compare it.
    Signed-off-by: 's avatarNiklas Haas <git@haasn.dev>
    Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
    6bc29a6b
h274.h 1.79 KB