FFmpeg
Loading...
Searching...
No Matches
h274.c File Reference

H.274 film grain synthesis. More...

#include <stdatomic.h>
#include "libavutil/avassert.h"
#include "libavutil/bswap.h"
#include "libavcodec/bswapdsp.h"
#include "libavutil/crc.h"
#include "libavutil/imgutils.h"
#include "libavutil/md5.h"
#include "libavutil/mem.h"
#include "libavutil/thread.h"
#include "h274.h"

Go to the source code of this file.

Data Structures

struct  H274FilmGrainDatabase
 
struct  H274HashContext
 

Macros

#define MD5_SIZE   16
 
#define CAL_CHECKSUM(pixel)
 

Enumerations

enum  { HASH_MD5SUM , HASH_CRC , HASH_CHECKSUM , HASH_LAST = HASH_CHECKSUM }
 

Functions

static void prng_shift (uint32_t *state)
 
static void init_slice_c (int8_t out[64][64], uint8_t h, uint8_t v)
 
static void init_slice (uint8_t h, uint8_t v)
 
static uint16_t avg_8x8_c (const uint8_t *in, int in_stride)
 
static void synth_grain_8x8_c (int8_t *out, const int out_stride, const int16_t scale, const uint8_t shift, const int8_t *db)
 
static void deblock_8x8_c (int8_t *out, const int out_stride)
 
static av_always_inline void generate (int8_t *out, int out_stride, const uint8_t *in, int in_stride, const AVFilmGrainH274Params *h274, int c, int invert, int deblock, int y_offset, int x_offset)
 
static void add_8x8_clip_c (uint8_t *out, const uint8_t *a, const int8_t *b, int n)
 
int ff_h274_apply_film_grain (AVFrame *out_frame, const AVFrame *in_frame, const AVFilmGrainParams *params)
 
static av_always_inline void bswap16_buf_if_be (H274HashContext *s, const int ps, const uint8_t **src, const int w)
 
static int verify_plane_md5 (H274HashContext *s, const uint8_t *_src, const int w, const int h, const int stride, const int ps, const uint8_t *expected)
 
static int verify_plane_crc (H274HashContext *s, const uint8_t *_src, const int w, const int h, const int stride, const int ps, uint16_t expected)
 
static int verify_plane_checksum (const uint8_t *src, const int w, const int h, const int stride, const int ps, uint32_t expected)
 
void ff_h274_hash_freep (H274HashContext **ctx)
 
int ff_h274_hash_init (H274HashContext **ctx, const int type)
 
int ff_h274_hash_verify (H274HashContext *c, const H274SEIPictureHash *hash, const AVFrame *frame, const int coded_width, const int coded_height)
 

Variables

static H274FilmGrainDatabase film_grain_db
 
static const int8_t Gaussian_LUT [2048+4]
 
static const uint32_t Seed_LUT [256]
 
static const int8_t R64T [64][64]
 

Detailed Description

H.274 film grain synthesis.

Author
Niklas Haas ffmpe.nosp@m.g@ha.nosp@m.asn.x.nosp@m.yz

Definition in file h274.c.

Macro Definition Documentation

◆ MD5_SIZE

#define MD5_SIZE   16

Referenced by verify_plane_md5().

◆ CAL_CHECKSUM

#define CAL_CHECKSUM ( pixel)
Value:
((pixel) ^ xor_mask)
#define pixel

Definition at line 886 of file h274.c.

Referenced by verify_plane_checksum().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HASH_MD5SUM 
HASH_CRC 
HASH_CHECKSUM 
HASH_LAST 

Definition at line 909 of file h274.c.

Function Documentation

◆ prng_shift()

static void prng_shift ( uint32_t * state)
static

Definition at line 53 of file h274.c.

Referenced by ff_h274_apply_film_grain(), and init_slice_c().

◆ init_slice_c()

static void init_slice_c ( int8_t out[64][64],
uint8_t h,
uint8_t v )
static

Definition at line 61 of file h274.c.

Referenced by init_slice().

◆ init_slice()

static void init_slice ( uint8_t h,
uint8_t v )
static

Definition at line 122 of file h274.c.

Referenced by generate().

◆ avg_8x8_c()

static uint16_t avg_8x8_c ( const uint8_t * in,
int in_stride )
static

Definition at line 143 of file h274.c.

Referenced by generate().

◆ synth_grain_8x8_c()

static void synth_grain_8x8_c ( int8_t * out,
const int out_stride,
const int16_t scale,
const uint8_t shift,
const int8_t * db )
static

Definition at line 158 of file h274.c.

Referenced by generate().

◆ deblock_8x8_c()

static void deblock_8x8_c ( int8_t * out,
const int out_stride )
static

Definition at line 172 of file h274.c.

Referenced by generate().

◆ generate()

static av_always_inline void generate ( int8_t * out,
int out_stride,
const uint8_t * in,
int in_stride,
const AVFilmGrainH274Params * h274,
int c,
int invert,
int deblock,
int y_offset,
int x_offset )
static

Definition at line 185 of file h274.c.

Referenced by ff_h274_apply_film_grain().

◆ add_8x8_clip_c()

static void add_8x8_clip_c ( uint8_t * out,
const uint8_t * a,
const int8_t * b,
int n )
static

Definition at line 238 of file h274.c.

Referenced by ff_h274_apply_film_grain().

◆ ff_h274_apply_film_grain()

int ff_h274_apply_film_grain ( AVFrame * out_frame,
const AVFrame * in_frame,
const AVFilmGrainParams * params )

Definition at line 245 of file h274.c.

Referenced by ff_h264_field_end(), frame_end(), and hevc_frame_end().

◆ bswap16_buf_if_be()

static av_always_inline void bswap16_buf_if_be ( H274HashContext * s,
const int ps,
const uint8_t ** src,
const int w )
static

Definition at line 832 of file h274.c.

Referenced by verify_plane_crc(), and verify_plane_md5().

◆ verify_plane_md5()

static int verify_plane_md5 ( H274HashContext * s,
const uint8_t * _src,
const int w,
const int h,
const int stride,
const int ps,
const uint8_t * expected )
static

Definition at line 843 of file h274.c.

Referenced by ff_h274_hash_verify().

◆ verify_plane_crc()

static int verify_plane_crc ( H274HashContext * s,
const uint8_t * _src,
const int w,
const int h,
const int stride,
const int ps,
uint16_t expected )
static

Definition at line 866 of file h274.c.

Referenced by ff_h274_hash_verify().

◆ verify_plane_checksum()

static int verify_plane_checksum ( const uint8_t * src,
const int w,
const int h,
const int stride,
const int ps,
uint32_t expected )
static

Definition at line 887 of file h274.c.

Referenced by ff_h274_hash_verify().

◆ ff_h274_hash_freep()

void ff_h274_hash_freep ( H274HashContext ** ctx)

Definition at line 916 of file h274.c.

Referenced by vvc_decode_free().

◆ ff_h274_hash_init()

int ff_h274_hash_init ( H274HashContext ** ctx,
const int type )

Definition at line 929 of file h274.c.

Referenced by frame_end().

◆ ff_h274_hash_verify()

int ff_h274_hash_verify ( H274HashContext * c,
const H274SEIPictureHash * hash,
const AVFrame * frame,
const int coded_width,
const int coded_height )

Definition at line 964 of file h274.c.

Referenced by frame_end().

Variable Documentation

◆ film_grain_db

H274FilmGrainDatabase film_grain_db
static

Definition at line 47 of file h274.c.

Referenced by generate(), and init_slice().

◆ Gaussian_LUT

static const int8_t Gaussian_LUT
static

Definition at line 49 of file h274.c.

Referenced by init_slice_c().

◆ Seed_LUT

static const uint32_t Seed_LUT
static

Definition at line 50 of file h274.c.

Referenced by ff_h274_apply_film_grain(), and init_slice_c().

◆ R64T

static const int8_t R64T
static

Definition at line 51 of file h274.c.

Referenced by init_slice_c().