FFmpeg
ac3dec_float.c
Go to the documentation of this file.
1 /*
2  * AC-3 Audio Decoder
3  * This code was developed as part of Google Summer of Code 2006.
4  * E-AC-3 support was added as part of Google Summer of Code 2007.
5  *
6  * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com)
7  * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
8  * Copyright (c) 2007 Justin Ruggles <justin.ruggles@gmail.com>
9  *
10  * This file is part of FFmpeg.
11  *
12  * FFmpeg is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * FFmpeg is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with FFmpeg; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 
27 /**
28  * Upmix delay samples from stereo to original channel layout.
29  */
30 
31 #include "config_components.h"
32 #define IMDCT_TYPE AV_TX_FLOAT_MDCT
33 
34 #include "ac3dec.h"
35 #include "codec_internal.h"
36 #include "profiles.h"
37 #include "eac3dec.c"
38 #include "ac3dec.c"
39 
40 static const AVOption options[] = {
41  { "cons_noisegen", "enable consistent noise generation", OFFSET(consistent_noise_generation), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
42  { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
43  { "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
44  { "target_level", "target level in -dBFS (0 not applied)", OFFSET(target_level), AV_OPT_TYPE_INT, {.i64 = 0 }, -31, 0, PAR },
45 
46 {"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2, 0, .unit = "dmix_mode"},
47 {"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
48 {"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
49 {"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
50 {"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
51 
52  { "downmix", "Request a specific channel layout from the decoder", OFFSET(downmix_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, .flags = PAR },
53 
54  { NULL},
55 };
56 
58  .class_name = "(E-)AC3 decoder",
59  .item_name = av_default_item_name,
60  .option = options,
61  .version = LIBAVUTIL_VERSION_INT,
62 };
63 
65  .p.name = "ac3",
66  .p.type = AVMEDIA_TYPE_AUDIO,
67  .p.id = AV_CODEC_ID_AC3,
68  .priv_data_size = sizeof (AC3DecodeContext),
70  .close = ac3_decode_end,
72  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
74  CODEC_LONG_NAME("ATSC A/52A (AC-3)"),
75  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
77  .p.priv_class = &ac3_eac3_decoder_class,
78  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
79 };
80 
81 #if CONFIG_EAC3_DECODER
82 const FFCodec ff_eac3_decoder = {
83  .p.name = "eac3",
84  .p.type = AVMEDIA_TYPE_AUDIO,
85  .p.id = AV_CODEC_ID_EAC3,
86  .priv_data_size = sizeof (AC3DecodeContext),
88  .close = ac3_decode_end,
90  .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
92  CODEC_LONG_NAME("ATSC A/52B (AC-3, E-AC-3)"),
93  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
95  .p.priv_class = &ac3_eac3_decoder_class,
97  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
98 };
99 #endif
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AV_CODEC_ID_AC3
@ AV_CODEC_ID_AC3
Definition: codec_id.h:443
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
AVOption
AVOption.
Definition: opt.h:346
FFCodec
Definition: codec_internal.h:127
ff_ac3_decoder
const FFCodec ff_ac3_decoder
Definition: ac3dec_float.c:64
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
ac3dec.h
ac3_decode_frame
static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode a single AC-3 frame.
Definition: ac3dec.c:1488
ac3dec.c
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ac3_decode_init
static av_cold int ac3_decode_init(AVCodecContext *avctx)
AVCodec initialization.
Definition: ac3dec.c:208
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
ac3_eac3_decoder_class
static const AVClass ac3_eac3_decoder_class
Definition: ac3dec_float.c:57
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
profiles.h
options
static const AVOption options[]
Definition: ac3dec_float.c:40
ff_eac3_decoder
const FFCodec ff_eac3_decoder
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Definition: opt.h:252
eac3dec.c
AV_CODEC_ID_EAC3
@ AV_CODEC_ID_EAC3
Definition: codec_id.h:480
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
codec_internal.h
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
ff_eac3_profiles
const AVProfile ff_eac3_profiles[]
Definition: profiles.c:50
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
ac3_decode_end
static av_cold int ac3_decode_end(AVCodecContext *avctx)
Uninitialize the AC-3 decoder.
Definition: ac3dec.c:1856
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
OFFSET
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your see the OFFSET() macro
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
PAR
@ PAR
Definition: af_afade.c:61