FFmpeg
Data Structures | Macros | Enumerations | Functions
dovi_rpu.h File Reference
#include "libavutil/dovi_meta.h"
#include "libavutil/frame.h"
#include "avcodec.h"

Go to the source code of this file.

Data Structures

struct  DOVIContext
 
struct  DOVIVdr
 

Macros

#define DOVI_MAX_DM_ID   15
 
#define FF_DOVI_AUTOMATIC   -1
 Enable tri-state. More...
 

Enumerations

enum  { RPU_COEFF_FIXED = 0, RPU_COEFF_FLOAT = 1 }
 

Functions

void ff_dovi_ctx_replace (DOVIContext *s, const DOVIContext *s0)
 
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...
 
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...
 
int ff_dovi_attach_side_data (DOVIContext *s, AVFrame *frame)
 Attach the decoded AVDOVIMetadata as side data to an AVFrame. More...
 
int ff_dovi_configure (DOVIContext *s, AVCodecContext *avctx)
 Configure the encoder for Dolby Vision encoding. More...
 
int ff_dovi_rpu_generate (DOVIContext *s, const AVDOVIMetadata *metadata, uint8_t **out_rpu, int *out_size)
 Synthesize a Dolby Vision RPU reflecting the current state. More...
 
int ff_dovi_guess_profile_hevc (const AVDOVIRpuDataHeader *hdr)
 Internal helper function to guess the correct DV profile for HEVC. More...
 

Macro Definition Documentation

◆ DOVI_MAX_DM_ID

#define DOVI_MAX_DM_ID   15

Definition at line 31 of file dovi_rpu.h.

◆ FF_DOVI_AUTOMATIC

#define FF_DOVI_AUTOMATIC   -1

Enable tri-state.

For encoding only. FF_DOVI_AUTOMATIC enables Dolby Vision only if avctx->decoded_side_data contains an AVDOVIMetadata.

Definition at line 39 of file dovi_rpu.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RPU_COEFF_FIXED 
RPU_COEFF_FLOAT 

Definition at line 134 of file dovi_rpu.h.

Function Documentation

◆ ff_dovi_ctx_replace()

void ff_dovi_ctx_replace ( DOVIContext s,
const DOVIContext s0 
)

Definition at line 56 of file dovi_rpu.c.

◆ ff_dovi_ctx_unref()

void ff_dovi_ctx_unref ( DOVIContext s)

Completely reset a DOVIContext, preserving only logctx.

Definition at line 29 of file dovi_rpu.c.

Referenced by aom_free(), av1_decode_free(), eb_enc_close(), ff_dovi_rpu_parse(), hevc_decode_free(), libdav1d_close(), and libx265_encode_close().

◆ ff_dovi_ctx_flush()

void ff_dovi_ctx_flush ( DOVIContext s)

Partially reset the internal state.

Resets per-frame state, but preserves the stream-wide configuration record.

Definition at line 41 of file dovi_rpu.c.

Referenced by hevc_decode_flush().

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

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

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

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

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

◆ ff_dovi_configure()

int ff_dovi_configure ( DOVIContext s,
AVCodecContext avctx 
)

Configure the encoder for Dolby Vision encoding.

Generates a configuration record in s->cfg, and attaches it to avctx->coded_side_data. Sets the correct profile and compatibility ID based on the tagged AVCodecContext colorspace metadata, and the correct level based on the resolution and tagged framerate.

Returns 0 or a negative error code.

Definition at line 55 of file dovi_rpuenc.c.

Referenced by aom_init(), eb_enc_init(), and libx265_encode_init().

◆ ff_dovi_rpu_generate()

int ff_dovi_rpu_generate ( DOVIContext s,
const AVDOVIMetadata metadata,
uint8_t **  out_rpu,
int out_size 
)

Synthesize a Dolby Vision RPU reflecting the current state.

Note that this assumes all previous calls to ff_dovi_rpu_generate have been appropriately signalled, i.e. it will not re-send already transmitted redundant data.

Mutates the internal state of DOVIContext to reflect the change. Returns 0 or a negative error code.

This generates a fully formed RPU ready for inclusion in the bitstream, including the EMDF header (profile 10) or NAL encapsulation (otherwise).

Definition at line 443 of file dovi_rpuenc.c.

Referenced by aom_encode(), eb_send_frame(), and libx265_encode_frame().

◆ ff_dovi_guess_profile_hevc()

int ff_dovi_guess_profile_hevc ( const AVDOVIRpuDataHeader hdr)

Internal helper function to guess the correct DV profile for HEVC.

Returns the profile number or 0 if unknown.

Definition at line 68 of file dovi_rpu.c.

Referenced by ff_dovi_configure(), and ff_dovi_rpu_parse().