FFmpeg
libavcodec
dolby_e_parser.c
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
#include "
libavutil/channel_layout.h
"
22
#include "
avcodec.h
"
23
#include "
dolby_e.h
"
24
#include "
get_bits.h
"
25
#include "
put_bits.h
"
26
27
typedef
struct
DBEParseContext
{
28
DBEContext
dectx
;
29
}
DBEParseContext
;
30
31
static
int
dolby_e_parse
(
AVCodecParserContext
*
s2
,
AVCodecContext
*avctx,
32
const
uint8_t **poutbuf,
int
*poutbuf_size,
33
const
uint8_t *buf,
int
buf_size)
34
{
35
DBEParseContext
*
s1
=
s2
->priv_data;
36
DBEContext
*
s
= &
s1
->dectx;
37
int
ret
;
38
39
if
((
ret
=
ff_dolby_e_parse_header
(
s
, buf, buf_size)) < 0)
40
goto
end;
41
42
s2
->duration =
FRAME_SAMPLES
;
43
switch
(
s
->metadata.nb_channels) {
44
case
4:
45
avctx->
channel_layout
=
AV_CH_LAYOUT_4POINT0
;
46
break
;
47
case
6:
48
avctx->
channel_layout
=
AV_CH_LAYOUT_5POINT1
;
49
break
;
50
case
8:
51
avctx->
channel_layout
=
AV_CH_LAYOUT_7POINT1
;
52
break
;
53
}
54
55
avctx->
channels
=
s
->metadata.nb_channels;
56
avctx->
sample_rate
=
s
->metadata.sample_rate;
57
avctx->
sample_fmt
=
AV_SAMPLE_FMT_FLTP
;
58
59
end:
60
/* always return the full packet. this parser isn't doing any splitting or
61
combining, only packet analysis */
62
*poutbuf = buf;
63
*poutbuf_size = buf_size;
64
return
buf_size;
65
}
66
67
const
AVCodecParser
ff_dolby_e_parser
= {
68
.
codec_ids
= {
AV_CODEC_ID_DOLBY_E
},
69
.priv_data_size =
sizeof
(
DBEParseContext
),
70
.parser_parse =
dolby_e_parse
,
71
};
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition:
samplefmt.h:69
AVCodecContext::channel_layout
uint64_t channel_layout
Audio channel layout.
Definition:
avcodec.h:1043
ff_dolby_e_parser
const AVCodecParser ff_dolby_e_parser
Definition:
dolby_e_parser.c:67
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition:
avcodec.h:992
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
FRAME_SAMPLES
#define FRAME_SAMPLES
Definition:
dolby_e.h:27
DBEContext
Definition:
dolby_e.h:70
s
#define s(width, name)
Definition:
cbs_vp9.c:257
s1
#define s1
Definition:
regdef.h:38
get_bits.h
AV_CODEC_ID_DOLBY_E
@ AV_CODEC_ID_DOLBY_E
Definition:
codec_id.h:507
AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_5POINT1
Definition:
channel_layout.h:101
s2
#define s2
Definition:
regdef.h:39
AVCodecParser::codec_ids
int codec_ids[7]
Definition:
avcodec.h:2935
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition:
avcodec.h:1000
AVCodecContext::channels
int channels
number of audio channels
Definition:
avcodec.h:993
AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_7POINT1
Definition:
channel_layout.h:112
avcodec.h
AVCodecParserContext
Definition:
avcodec.h:2775
ret
ret
Definition:
filter_design.txt:187
AVCodecContext
main external API structure.
Definition:
avcodec.h:383
channel_layout.h
dolby_e_parse
static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition:
dolby_e_parser.c:31
AVCodecParser
Definition:
avcodec.h:2934
AV_CH_LAYOUT_4POINT0
#define AV_CH_LAYOUT_4POINT0
Definition:
channel_layout.h:96
dolby_e.h
DBEParseContext::dectx
DBEContext dectx
Definition:
dolby_e_parser.c:28
put_bits.h
DBEParseContext
Definition:
dolby_e_parser.c:27
Generated on Wed Aug 24 2022 21:37:32 for FFmpeg by
1.8.17