22 #include <libdcadec/dca_context.h> 34 struct dcadec_context *
ctx;
45 int **samples, nsamples, channel_mask, sample_rate, bits_per_sample,
profile;
48 int input_size = avpkt->
size;
68 if ((ret = dcadec_context_parse(s->
ctx, input, input_size)) < 0) {
69 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_parse() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
72 if ((ret = dcadec_context_filter(s->
ctx, &samples, &nsamples, &channel_mask,
73 &sample_rate, &bits_per_sample, &profile)) < 0) {
74 av_log(avctx,
AV_LOG_ERROR,
"dcadec_context_filter() failed: %d (%s)\n", -ret, dcadec_strerror(ret));
82 if (bits_per_sample == 16)
84 else if (bits_per_sample <= 24)
95 case DCADEC_PROFILE_DS:
98 case DCADEC_PROFILE_DS_96_24:
101 case DCADEC_PROFILE_DS_ES:
104 case DCADEC_PROFILE_HD_HRA:
107 case DCADEC_PROFILE_HD_MA:
110 case DCADEC_PROFILE_EXPRESS:
113 case DCADEC_PROFILE_UNKNOWN:
120 if (profile == DCADEC_PROFILE_DS || profile == DCADEC_PROFILE_DS_96_24 || profile == DCADEC_PROFILE_DS_ES) {
121 struct dcadec_core_info *info = dcadec_context_get_core_info(s->
ctx);
123 dcadec_context_free_core_info(info);
131 for (i = 0; i < avctx->
channels; i++) {
134 for (k = 0; k < nsamples; k++)
135 plane[k] = samples[i][k];
138 int shift = 32 - bits_per_sample;
139 for (k = 0; k < nsamples; k++)
140 plane[k] = samples[i][k] << shift;
152 dcadec_context_clear(s->
ctx);
159 dcadec_context_destroy(s->
ctx);
171 s->
ctx = dcadec_context_create(0);
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
struct dcadec_context * ctx
This structure describes decoded (raw) audio or video data.
#define FF_PROFILE_DTS_HD_HRA
static av_cold void dcadec_flush(AVCodecContext *avctx)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int ff_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 FF_PROFILE_DTS_EXPRESS
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
enum AVSampleFormat sample_fmt
audio sample format
#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 av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define FF_PROFILE_DTS_ES
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
int bit_rate
the average bitrate
audio channel layout utility functions
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
#define FF_PROFILE_UNKNOWN
static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
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)
Libavcodec external API header.
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)
common internal api header.
common internal and external API header
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_cold int init(AVCodecParserContext *s)
#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[]
#define FF_PROFILE_DTS_HD_MA
uint8_t ** extended_data
pointers to the data planes/channels.
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.