FFmpeg
Data Structures | Macros | Enumerations | Functions
dovi_rpu.c File Reference
#include "libavutil/buffer.h"
#include "libavutil/mem.h"
#include "libavutil/crc.h"
#include "avcodec.h"
#include "dovi_rpu.h"
#include "golomb.h"
#include "get_bits.h"
#include "refstruct.h"

Go to the source code of this file.

Data Structures

struct  DOVIVdr
 Private contents of vdr. More...
 

Macros

#define COPY(t, a, b, last)   memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
 
#define VALIDATE(VAR, MIN, MAX)
 

Enumerations

enum  { RPU_COEFF_FIXED = 0, RPU_COEFF_FLOAT = 1 }
 

Functions

void ff_dovi_ctx_unref (DOVIContext *s)
 Completely reset a DOVIContext, preserving only logctx. More...
 
void ff_dovi_ctx_flush (DOVIContext *s)
 Partially reset the internal state. More...
 
void ff_dovi_ctx_replace (DOVIContext *s, const DOVIContext *s0)
 
void ff_dovi_update_cfg (DOVIContext *s, const AVDOVIDecoderConfigurationRecord *cfg)
 Read the contents of an AVDOVIDecoderConfigurationRecord (usually provided by stream side data) and update internal state accordingly. More...
 
int ff_dovi_attach_side_data (DOVIContext *s, AVFrame *frame)
 Attach the decoded AVDOVIMetadata as side data to an AVFrame. More...
 
static int guess_profile (const AVDOVIRpuDataHeader *hdr)
 
static uint64_t get_ue_coef (GetBitContext *gb, const AVDOVIRpuDataHeader *hdr)
 
static int64_t get_se_coef (GetBitContext *gb, const AVDOVIRpuDataHeader *hdr)
 
static unsigned get_variable_bits (GetBitContext *gb, int n)
 
static void parse_ext_v1 (DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm)
 
static AVCIExy get_cie_xy (GetBitContext *gb)
 
static void parse_ext_v2 (DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm, int ext_block_length)
 
static int parse_ext_blocks (DOVIContext *s, GetBitContext *gb, int ver)
 
int ff_dovi_rpu_parse (DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
 Parse the contents of a Dovi RPU NAL and update the parsed values in the DOVIContext struct. More...
 

Macro Definition Documentation

◆ COPY

#define COPY (   t,
  a,
  b,
  last 
)    memcpy(a, b, offsetof(t, last) + sizeof((b)->last))

◆ VALIDATE

#define VALIDATE (   VAR,
  MIN,
  MAX 
)
Value:
do { \
if (VAR < MIN || VAR > MAX) { \
av_log(s->logctx, AV_LOG_ERROR, "RPU validation failed: " \
#MIN" <= "#VAR" = %d <= "#MAX"\n", (int) VAR); \
goto fail; \
} \
} while (0)

Definition at line 203 of file dovi_rpu.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RPU_COEFF_FIXED 
RPU_COEFF_FLOAT 

Definition at line 34 of file dovi_rpu.c.

Function Documentation

◆ ff_dovi_ctx_unref()

void ff_dovi_ctx_unref ( DOVIContext s)

Completely reset a DOVIContext, preserving only logctx.

Definition at line 47 of file dovi_rpu.c.

Referenced by av1_decode_free(), ff_dovi_rpu_parse(), hevc_decode_free(), and libdav1d_close().

◆ ff_dovi_ctx_flush()

void ff_dovi_ctx_flush ( DOVIContext s)

Partially reset the internal state.

Resets per-frame state while preserving fields parsed from the configuration record.

Definition at line 59 of file dovi_rpu.c.

Referenced by hevc_decode_flush().

◆ ff_dovi_ctx_replace()

void ff_dovi_ctx_replace ( DOVIContext s,
const DOVIContext s0 
)

Definition at line 74 of file dovi_rpu.c.

◆ ff_dovi_update_cfg()

void ff_dovi_update_cfg ( DOVIContext s,
const AVDOVIDecoderConfigurationRecord cfg 
)

Read the contents of an AVDOVIDecoderConfigurationRecord (usually provided by stream side data) and update internal state accordingly.

Definition at line 85 of file dovi_rpu.c.

Referenced by av1_decode_init(), hevc_decode_frame(), hevc_decode_init(), and libdav1d_init().

◆ ff_dovi_attach_side_data()

int ff_dovi_attach_side_data ( DOVIContext s,
AVFrame frame 
)

Attach the decoded AVDOVIMetadata as side data to an AVFrame.

Definition at line 93 of file dovi_rpu.c.

Referenced by export_itut_t35(), libdav1d_receive_frame(), and set_side_data().

◆ guess_profile()

static int guess_profile ( const AVDOVIRpuDataHeader hdr)
static

Definition at line 131 of file dovi_rpu.c.

Referenced by ff_dovi_rpu_parse().

◆ get_ue_coef()

static uint64_t get_ue_coef ( GetBitContext gb,
const AVDOVIRpuDataHeader hdr 
)
inlinestatic

Definition at line 153 of file dovi_rpu.c.

Referenced by ff_dovi_rpu_parse().

◆ get_se_coef()

static int64_t get_se_coef ( GetBitContext gb,
const AVDOVIRpuDataHeader hdr 
)
inlinestatic

Definition at line 172 of file dovi_rpu.c.

Referenced by ff_dovi_rpu_parse().

◆ get_variable_bits()

static unsigned get_variable_bits ( GetBitContext gb,
int  n 
)
inlinestatic

Definition at line 191 of file dovi_rpu.c.

Referenced by ff_dovi_rpu_parse().

◆ parse_ext_v1()

static void parse_ext_v1 ( DOVIContext s,
GetBitContext gb,
AVDOVIDmData dm 
)
static

Definition at line 212 of file dovi_rpu.c.

Referenced by parse_ext_blocks().

◆ get_cie_xy()

static AVCIExy get_cie_xy ( GetBitContext gb)
static

Definition at line 257 of file dovi_rpu.c.

Referenced by parse_ext_v2().

◆ parse_ext_v2()

static void parse_ext_v2 ( DOVIContext s,
GetBitContext gb,
AVDOVIDmData dm,
int  ext_block_length 
)
static

Definition at line 266 of file dovi_rpu.c.

Referenced by parse_ext_blocks().

◆ parse_ext_blocks()

static int parse_ext_blocks ( DOVIContext s,
GetBitContext gb,
int  ver 
)
static

Definition at line 341 of file dovi_rpu.c.

Referenced by ff_dovi_rpu_parse().

◆ ff_dovi_rpu_parse()

int ff_dovi_rpu_parse ( DOVIContext s,
const uint8_t *  rpu,
size_t  rpu_size,
int  err_recognition 
)

Parse the contents of a Dovi RPU NAL and update the parsed values in the DOVIContext struct.

Returns 0 or an error code.

The patent mentions another legal value, NLQ_MU_LAW, but it's not documented anywhere how to parse or apply that type of NLQ.

Definition at line 376 of file dovi_rpu.c.

Referenced by decode_nal_units(), export_itut_t35(), and libdav1d_receive_frame().

MAX
#define MAX
Definition: blend_modes.c:45
fail
#define fail()
Definition: checkasm.h:179
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
s
#define s(width, name)
Definition: cbs_vp9.c:198
MIN
#define MIN(a, b)
Definition: qt-faststart.c:45