22 #include <libdcadec/dca_context.h>
36 struct dcadec_context *
ctx;
44 const char *
message,
void *cbarg)
49 case DCADEC_LOG_ERROR:
52 case DCADEC_LOG_WARNING:
58 case DCADEC_LOG_VERBOSE:
61 case DCADEC_LOG_DEBUG:
67 av_log(cbarg, av_level,
"%s\n", message);
75 struct dcadec_exss_info *exss;
80 int input_size = avpkt->
size;
103 if ((ret = dcadec_context_parse(s->
ctx, input, input_size)) < 0) {
104 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_parse() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
107 if ((ret = dcadec_context_filter(s->
ctx, &samples, &nsamples, &channel_mask,
108 &sample_rate, &bits_per_sample, &profile)) < 0) {
109 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_filter() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
117 if (bits_per_sample == 16)
119 else if (bits_per_sample > 16 && bits_per_sample <= 24)
130 case DCADEC_PROFILE_DS:
133 case DCADEC_PROFILE_DS_96_24:
136 case DCADEC_PROFILE_DS_ES:
139 case DCADEC_PROFILE_HD_HRA:
142 case DCADEC_PROFILE_HD_MA:
145 case DCADEC_PROFILE_EXPRESS:
148 case DCADEC_PROFILE_UNKNOWN:
155 if (profile == DCADEC_PROFILE_DS || profile == DCADEC_PROFILE_DS_96_24 || profile == DCADEC_PROFILE_DS_ES) {
156 struct dcadec_core_info *info = dcadec_context_get_core_info(s->
ctx);
158 dcadec_context_free_core_info(info);
162 if (exss = dcadec_context_get_exss_info(s->
ctx)) {
165 switch(exss->matrix_encoding) {
166 case DCADEC_MATRIX_ENCODING_SURROUND:
169 case DCADEC_MATRIX_ENCODING_HEADPHONE:
173 dcadec_context_free_exss_info(exss);
184 for (i = 0; i < avctx->
channels; i++) {
187 for (k = 0; k < nsamples; k++)
188 plane[k] = samples[i][k];
191 int shift = 32 - bits_per_sample;
192 for (k = 0; k < nsamples; k++)
193 plane[k] = samples[i][k] <<
shift;
205 dcadec_context_clear(s->
ctx);
212 dcadec_context_destroy(s->
ctx);
227 flags |= DCADEC_FLAG_CORE_BIT_EXACT;
230 flags |= DCADEC_FLAG_STRICT;
236 flags |= DCADEC_FLAG_KEEP_DMIX_2CH;
239 flags |= DCADEC_FLAG_KEEP_DMIX_6CH;
242 flags |= DCADEC_FLAG_NATIVE_LAYOUT;
251 flags |= DCADEC_FLAG_CORE_ONLY;
254 #if DCADEC_API_VERSION >= DCADEC_VERSION_CODE(0, 1, 0)
256 flags |= DCADEC_FLAG_CORE_LFE_IIR;
260 flags |= DCADEC_FLAG_CORE_LFE_FIR;
264 s->
ctx = dcadec_context_create(flags);
276 #define OFFSET(x) offsetof(DCADecContext, x)
277 #define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
280 {
"lfe_filter",
"Lossy LFE channel interpolation filter",
OFFSET(lfe_filter),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
PARAM,
"lfe_filter" },
281 {
"default",
"Library default", 0,
AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX,
PARAM,
"lfe_filter" },
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
struct dcadec_context * ctx
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
#define FF_PROFILE_DTS_HD_HRA
static av_cold void dcadec_flush(AVCodecContext *avctx)
static const AVClass dcadec_class
#define FF_PROFILE_DTS_EXPRESS
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define AV_CH_LAYOUT_STEREO
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
enum AVSampleFormat sample_fmt
audio sample format
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define AV_LOG_VERBOSE
Detailed information.
#define DCA_SYNCWORD_CORE_BE
#define AV_CH_LAYOUT_5POINT1
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define FF_PROFILE_DTS_ES
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
audio channel layout utility functions
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define FF_PROFILE_UNKNOWN
int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size)
Convert bitstream to one representation based on sync marker.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define FF_PROFILE_DTS_96_24
static av_cold int dcadec_init(AVCodecContext *avctx)
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
static void my_log_cb(int level, const char *file, int line, const char *message, void *cbarg)
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Describe the class of an AVClass context structure.
static av_cold int dcadec_close(AVCodecContext *avctx)
const AVProfile ff_dca_profiles[]
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
common internal and external API header
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int channels
number of audio channels
#define DCA_SYNCWORD_SUBSTREAM
static enum AVSampleFormat sample_fmts[]
#define FF_PROFILE_DTS_HD_MA
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
#define AVERROR_EXTERNAL
Generic error in an external library.
This structure stores compressed data.
AVCodec ff_libdcadec_decoder
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const AVOption dcadec_options[]