22 #include <libdcadec/dca_context.h>
34 struct dcadec_context *
ctx;
50 int input_size = avpkt->
size;
73 if ((ret = dcadec_context_parse(s->
ctx, input, input_size)) < 0) {
74 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_parse() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
77 if ((ret = dcadec_context_filter(s->
ctx, &samples, &nsamples, &channel_mask,
78 &sample_rate, &bits_per_sample, &profile)) < 0) {
79 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_filter() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
87 if (bits_per_sample == 16)
89 else if (bits_per_sample > 16 && bits_per_sample <= 24)
100 case DCADEC_PROFILE_DS:
103 case DCADEC_PROFILE_DS_96_24:
106 case DCADEC_PROFILE_DS_ES:
109 case DCADEC_PROFILE_HD_HRA:
112 case DCADEC_PROFILE_HD_MA:
115 case DCADEC_PROFILE_EXPRESS:
118 case DCADEC_PROFILE_UNKNOWN:
125 if (profile == DCADEC_PROFILE_DS || profile == DCADEC_PROFILE_DS_96_24 || profile == DCADEC_PROFILE_DS_ES) {
126 struct dcadec_core_info *info = dcadec_context_get_core_info(s->
ctx);
128 dcadec_context_free_core_info(info);
132 #if HAVE_STRUCT_DCADEC_EXSS_INFO_MATRIX_ENCODING
133 if (exss = dcadec_context_get_exss_info(s->
ctx)) {
141 av_log(avctx,
AV_LOG_WARNING,
"%s downmix was requested but no custom coefficients are available, "
142 "this may result in clipping\n",
147 switch(exss->matrix_encoding) {
148 case DCADEC_MATRIX_ENCODING_SURROUND:
151 case DCADEC_MATRIX_ENCODING_HEADPHONE:
155 dcadec_context_free_exss_info(exss);
167 for (i = 0; i < avctx->
channels; i++) {
170 for (k = 0; k < nsamples; k++)
171 plane[k] = samples[i][k];
174 int shift = 32 - bits_per_sample;
175 for (k = 0; k < nsamples; k++)
176 plane[k] = samples[i][k] <<
shift;
188 dcadec_context_clear(s->
ctx);
195 dcadec_context_destroy(s->
ctx);
210 flags |= DCADEC_FLAG_CORE_BIT_EXACT;
222 flags |= DCADEC_FLAG_KEEP_DMIX_2CH | DCADEC_FLAG_KEEP_DMIX_6CH;
225 flags |= DCADEC_FLAG_KEEP_DMIX_6CH;
233 s->
ctx = dcadec_context_create(flags);
#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.
static av_cold int init(AVCodecContext *avctx)
static av_cold void dcadec_flush(AVCodecContext *avctx)
#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.
#define FF_PROFILE_DTS_EXPRESS
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define FF_PROFILE_DTS_ES
enum AVSampleFormat sample_fmt
audio sample format
#define FF_PROFILE_UNKNOWN
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 FF_PROFILE_DTS_96_24
#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. ...
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
#define FF_PROFILE_DTS_HD_HRA
int bit_rate
the average bitrate
audio channel layout utility functions
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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.
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...
static av_cold int dcadec_init(AVCodecContext *avctx)
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
#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.
static const AVProfile profiles[]
static av_cold int dcadec_close(AVCodecContext *avctx)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
common internal and external API header
#define FF_PROFILE_DTS_HD_MA
#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
static enum AVSampleFormat sample_fmts[]
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.