22 #include <libdcadec/dca_context.h>
34 struct dcadec_context *
ctx;
48 int input_size = avpkt->
size;
71 if ((ret = dcadec_context_parse(s->
ctx, input, input_size)) < 0) {
72 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_parse() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
75 if ((ret = dcadec_context_filter(s->
ctx, &samples, &nsamples, &channel_mask,
76 &sample_rate, &bits_per_sample, &profile)) < 0) {
77 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_filter() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
85 if (bits_per_sample == 16)
87 else if (bits_per_sample > 16 && bits_per_sample <= 24)
98 case DCADEC_PROFILE_DS:
101 case DCADEC_PROFILE_DS_96_24:
104 case DCADEC_PROFILE_DS_ES:
107 case DCADEC_PROFILE_HD_HRA:
110 case DCADEC_PROFILE_HD_MA:
113 case DCADEC_PROFILE_EXPRESS:
116 case DCADEC_PROFILE_UNKNOWN:
123 if (profile == DCADEC_PROFILE_DS || profile == DCADEC_PROFILE_DS_96_24 || profile == DCADEC_PROFILE_DS_ES) {
124 struct dcadec_core_info *info = dcadec_context_get_core_info(s->
ctx);
126 dcadec_context_free_core_info(info);
134 for (i = 0; i < avctx->
channels; i++) {
137 for (k = 0; k < nsamples; k++)
138 plane[k] = samples[i][k];
141 int shift = 32 - bits_per_sample;
142 for (k = 0; k < nsamples; k++)
143 plane[k] = samples[i][k] <<
shift;
155 dcadec_context_clear(s->
ctx);
162 dcadec_context_destroy(s->
ctx);
177 flags |= DCADEC_FLAG_CORE_BIT_EXACT;
179 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 av_cold int init(AVCodecContext *avctx)
static av_cold void dcadec_flush(AVCodecContext *avctx)
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 CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#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. ...
const char * name
Name of the codec implementation.
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_PROFILE_DTS_HD_HRA
int bit_rate
the average bitrate
audio channel layout utility functions
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)
static void flush(AVCodecContext *avctx)
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
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 CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define FF_PROFILE_DTS_HD_MA
int channels
number of audio channels
static enum AVSampleFormat sample_fmts[]
uint8_t ** extended_data
pointers to the data planes/channels.
#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