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

Go to the source code of this file.

Macros

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

Functions

int ff_dovi_get_metadata (DOVIContext *s, AVDOVIMetadata **out_metadata)
 Get the decoded AVDOVIMetadata. More...
 
int ff_dovi_attach_side_data (DOVIContext *s, AVFrame *frame)
 Attach the decoded AVDOVIMetadata as side data to an AVFrame. More...
 
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 int parse_ext_v1 (DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm)
 
static AVCIExy get_cie_xy (GetBitContext *gb)
 
static int 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 compression, int err_recognition)
 
int ff_dovi_rpu_parse (DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
 Parse the contents of a Dolby Vision RPU 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); \
ff_dovi_ctx_unref(s); \
} \
} while (0)

Definition at line 140 of file dovi_rpudec.c.

Function Documentation

◆ ff_dovi_get_metadata()

int ff_dovi_get_metadata ( DOVIContext s,
AVDOVIMetadata **  out_metadata 
)

Get the decoded AVDOVIMetadata.

Ownership passes to the caller.

Returns the size of *out_metadata, a negative error code, or 0 if no metadata is available to return.

Definition at line 33 of file dovi_rpudec.c.

Referenced by ff_dovi_attach_side_data(), and update_rpu().

◆ 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.

Returns 0 or a negative error code.

Definition at line 64 of file dovi_rpudec.c.

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

◆ get_ue_coef()

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

Definition at line 90 of file dovi_rpudec.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 109 of file dovi_rpudec.c.

Referenced by ff_dovi_rpu_parse().

◆ get_variable_bits()

static unsigned get_variable_bits ( GetBitContext gb,
int  n 
)
inlinestatic

Definition at line 128 of file dovi_rpudec.c.

Referenced by ff_dovi_rpu_parse().

◆ parse_ext_v1()

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

Definition at line 150 of file dovi_rpudec.c.

Referenced by parse_ext_blocks().

◆ get_cie_xy()

static AVCIExy get_cie_xy ( GetBitContext gb)
static

Definition at line 198 of file dovi_rpudec.c.

Referenced by parse_ext_v2().

◆ parse_ext_v2()

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

Definition at line 207 of file dovi_rpudec.c.

Referenced by parse_ext_blocks().

◆ parse_ext_blocks()

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

Definition at line 284 of file dovi_rpudec.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 Dolby Vision RPU and update the parsed values in the DOVIContext struct.

This function should receive the decoded unit payload, without any T.35 or NAL unit headers.

Returns 0 or an error code.

Note: DOVIContext.cfg should be initialized before calling into this function. If not done, the profile will be guessed according to HEVC semantics.

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 346 of file dovi_rpudec.c.

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

MAX
#define MAX
Definition: blend_modes.c:44
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
s
#define s(width, name)
Definition: cbs_vp9.c:198
MIN
#define MIN(a, b)
Definition: qt-faststart.c:45
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61