FFmpeg
dolby_e.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 foo86
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVCODEC_DOLBY_E_H
22 #define AVCODEC_DOLBY_E_H
23 
24 #include <stdint.h>
25 #include "get_bits.h"
26 
27 #define FRAME_SAMPLES 1792
28 
29 #define MAX_PROG_CONF 23
30 #define MAX_PROGRAMS 8
31 #define MAX_CHANNELS 8
32 
33 /**
34  * @struct DolbyEHeaderInfo
35  * Coded Dolby E header values up to end_gain element, plus derived values.
36  */
37 typedef struct DolbyEHeaderInfo {
38  /** @name Coded elements
39  * @{
40  */
41  int prog_conf;
44 
45  int fr_code;
47 
51 
55  /** @} */
56 
57  /** @name Derived values
58  * @{
59  */
61 
63 
65  /** @} */
67 
68 /**
69  * @struct DBEContext
70  * Dolby E reading context used by decoder and parser.
71  */
72 typedef struct DBEContext {
73  void *avctx;
75 
76  const uint8_t *input;
78 
79  int word_bits;
82 
84 
85  uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE];
86 } DBEContext;
87 
88 /**
89  * Use the provided key to transform the input into data (put into s->buffer)
90  * suitable for further processing and initialize s->gb to read said data.
91  */
92 int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int key);
93 
94 /**
95  * Initialize DBEContext and parse Dolby E metadata.
96  * Set word_bits/word_bytes, input, input_size, key_present
97  * and parse the header up to the end_gain element.
98  * @param[out] s DBEContext.
99  * @param[in] buf raw input buffer.
100  * @param[in] buf_size must be 3 bytes at least.
101  * @return Returns 0 on success, AVERROR_INVALIDDATA on error
102  */
103 int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size);
104 
105 #endif
MAX_CHANNELS
#define MAX_CHANNELS
Definition: dolby_e.h:31
DolbyEHeaderInfo::end_gain
int end_gain[MAX_CHANNELS]
Definition: dolby_e.h:54
DolbyEHeaderInfo::begin_gain
int begin_gain[MAX_CHANNELS]
Definition: dolby_e.h:53
DolbyEHeaderInfo::nb_programs
int nb_programs
Definition: dolby_e.h:43
ff_dolby_e_parse_header
int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
Initialize DBEContext and parse Dolby E metadata.
Definition: dolby_e_parse.c:97
DolbyEHeaderInfo::multi_prog_warned
int multi_prog_warned
Definition: dolby_e.h:60
DBEContext::buffer
uint8_t buffer[1024 *3+AV_INPUT_BUFFER_PADDING_SIZE]
Definition: dolby_e.h:85
GetBitContext
Definition: get_bits.h:108
DBEContext
Definition: dolby_e.h:72
DBEContext::input_size
int input_size
Definition: dolby_e.h:77
DBEContext::input
const uint8_t * input
Definition: dolby_e.h:76
DBEContext::key_present
int key_present
Definition: dolby_e.h:81
s
#define s(width, name)
Definition: cbs_vp9.c:198
DolbyEHeaderInfo::fr_code
int fr_code
Definition: dolby_e.h:45
DBEContext::word_bits
int word_bits
Definition: dolby_e.h:79
get_bits.h
DolbyEHeaderInfo::fr_code_orig
int fr_code_orig
Definition: dolby_e.h:46
key
const char * key
Definition: hwcontext_opencl.c:189
DolbyEHeaderInfo
Definition: dolby_e.h:37
DolbyEHeaderInfo::meter_size
int meter_size
Definition: dolby_e.h:50
DolbyEHeaderInfo::mtd_ext_size
int mtd_ext_size
Definition: dolby_e.h:49
DBEContext::gb
GetBitContext gb
Definition: dolby_e.h:74
DBEContext::word_bytes
int word_bytes
Definition: dolby_e.h:80
DolbyEHeaderInfo::output_channel_order
int output_channel_order
Definition: dolby_e.h:62
DolbyEHeaderInfo::sample_rate
int sample_rate
Definition: dolby_e.h:64
DolbyEHeaderInfo::rev_id
int rev_id[MAX_CHANNELS]
Definition: dolby_e.h:52
ff_dolby_e_convert_input
int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int key)
Use the provided key to transform the input into data (put into s->buffer) suitable for further proce...
Definition: dolby_e_parse.c:60
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
DolbyEHeaderInfo::ch_size
int ch_size[MAX_CHANNELS]
Definition: dolby_e.h:48
DolbyEHeaderInfo::prog_conf
int prog_conf
Definition: dolby_e.h:41
DBEContext::avctx
void * avctx
Definition: dolby_e.h:73
DolbyEHeaderInfo::nb_channels
int nb_channels
Definition: dolby_e.h:42
DBEContext::metadata
DolbyEHeaderInfo metadata
Definition: dolby_e.h:83