FFmpeg
dovi_rpu.h
Go to the documentation of this file.
1 /*
2  * Dolby Vision RPU decoder
3  *
4  * Copyright (C) 2021 Jan Ekström
5  * Copyright (C) 2021 Niklas Haas
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_DOVI_RPU_H
25 #define AVCODEC_DOVI_RPU_H
26 
27 #include "libavutil/dovi_meta.h"
28 #include "libavutil/frame.h"
29 
30 #define DOVI_MAX_DM_ID 15
31 typedef struct DOVIContext {
32  void *logctx;
33 
34  /**
35  * Currently active RPU data header, updates on every dovi_rpu_parse().
36  */
38 
39  /**
40  * Currently active data mappings, or NULL. Points into memory owned by the
41  * corresponding rpu/vdr_ref, which becomes invalid on the next call to
42  * dovi_rpu_parse.
43  */
46 
47  /**
48  * Currently active extension blocks, updates on every ff_dovi_rpu_parse()
49  */
52 
53  /**
54  * Private fields internal to dovi_rpu.c
55  */
56  struct DOVIVdr *vdr[DOVI_MAX_DM_ID+1]; ///< RefStruct references
57  uint8_t *rpu_buf; ///< temporary buffer
58  unsigned rpu_buf_sz;
59  uint8_t dv_profile;
60 
61 } DOVIContext;
62 
64 
65 /**
66  * Completely reset a DOVIContext, preserving only logctx.
67  */
69 
70 /**
71  * Partially reset the internal state. Resets per-frame state while preserving
72  * fields parsed from the configuration record.
73  */
75 
76 /**
77  * Read the contents of an AVDOVIDecoderConfigurationRecord (usually provided
78  * by stream side data) and update internal state accordingly.
79  */
81 
82 /**
83  * Parse the contents of a Dovi RPU NAL and update the parsed values in the
84  * DOVIContext struct.
85  *
86  * Returns 0 or an error code.
87  */
88 int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
89  int err_recognition);
90 
91 /**
92  * Attach the decoded AVDOVIMetadata as side data to an AVFrame.
93  */
95 
96 #endif /* AVCODEC_DOVI_RPU_H */
DOVIContext::ext_blocks
AVDOVIDmData * ext_blocks
Currently active extension blocks, updates on every ff_dovi_rpu_parse()
Definition: dovi_rpu.h:50
ff_dovi_ctx_replace
void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0)
Definition: dovi_rpu.c:74
DOVI_MAX_DM_ID
#define DOVI_MAX_DM_ID
Definition: dovi_rpu.h:30
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.
Definition: dovi_rpu.c:376
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:375
AVDOVIRpuDataHeader
Dolby Vision RPU data header.
Definition: dovi_meta.h:78
DOVIContext
Definition: dovi_rpu.h:31
DOVIContext::dv_profile
uint8_t dv_profile
Definition: dovi_rpu.h:59
AVDOVIDmData
Dolby Vision metadata extension block.
Definition: dovi_meta.h:297
s
#define s(width, name)
Definition: cbs_vp9.c:198
DOVIContext::mapping
const AVDOVIDataMapping * mapping
Currently active data mappings, or NULL.
Definition: dovi_rpu.h:44
DOVIContext::vdr
struct DOVIVdr * vdr[DOVI_MAX_DM_ID+1]
Private fields internal to dovi_rpu.c.
Definition: dovi_rpu.h:56
DOVIContext::color
const AVDOVIColorMetadata * color
Definition: dovi_rpu.h:45
DOVIContext::rpu_buf_sz
unsigned rpu_buf_sz
Definition: dovi_rpu.h:58
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: dovi_rpu.c:93
ff_dovi_ctx_flush
void ff_dovi_ctx_flush(DOVIContext *s)
Partially reset the internal state.
Definition: dovi_rpu.c:59
frame.h
DOVIContext::header
AVDOVIRpuDataHeader header
Currently active RPU data header, updates on every dovi_rpu_parse().
Definition: dovi_rpu.h:37
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
DOVIVdr
Private contents of vdr.
Definition: dovi_rpu.c:42
dovi_meta.h
DOVIContext::rpu_buf
uint8_t * rpu_buf
temporary buffer
Definition: dovi_rpu.h:57
AVDOVIColorMetadata
Dolby Vision RPU colorspace metadata parameters.
Definition: dovi_meta.h:160
DOVIContext::logctx
void * logctx
Definition: dovi_rpu.h:32
s0
#define s0
Definition: regdef.h:37
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 u...
Definition: dovi_rpu.c:85
DOVIContext::num_ext_blocks
int num_ext_blocks
Definition: dovi_rpu.h:51
AVDOVIDataMapping
Dolby Vision RPU data mapping parameters.
Definition: dovi_meta.h:141
AVDOVIDecoderConfigurationRecord
Definition: dovi_meta.h:54
ff_dovi_ctx_unref
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
Definition: dovi_rpu.c:47