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 av_cold void init_film_grain_db (void)
 
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 AVOnce film_grain_db_once = AV_ONCE_INIT
 
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 905 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 928 of file h274.c.

Function Documentation

◆ init_film_grain_db()

static av_cold void init_film_grain_db ( void )
static

Definition at line 52 of file h274.c.

Referenced by ff_h274_apply_film_grain().

◆ prng_shift()

static void prng_shift ( uint32_t * state)
static

Definition at line 69 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 77 of file h274.c.

Referenced by init_slice().

◆ init_slice()

static void init_slice ( uint8_t h,
uint8_t v )
static

Definition at line 137 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 158 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 173 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 187 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 200 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 253 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 260 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 851 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 862 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 885 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 906 of file h274.c.

Referenced by ff_h274_hash_verify().

◆ ff_h274_hash_freep()

void ff_h274_hash_freep ( H274HashContext ** ctx)

Definition at line 935 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 948 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 983 of file h274.c.

Referenced by frame_end().

Variable Documentation

◆ film_grain_db

H274FilmGrainDatabase* film_grain_db
static

◆ film_grain_db_once

AVOnce film_grain_db_once = AV_ONCE_INIT
static

Definition at line 50 of file h274.c.

Referenced by ff_h274_apply_film_grain().

◆ Gaussian_LUT

static const int8_t Gaussian_LUT
static

Definition at line 65 of file h274.c.

Referenced by init_slice_c().

◆ Seed_LUT

static const uint32_t Seed_LUT
static

Definition at line 66 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 67 of file h274.c.

Referenced by init_slice_c().