78static_assert(
sizeof(
PCMDVDAHeader) == 11,
"unexpected header padding");
89#define CH_C AV_CH_FRONT_CENTER
90#define CH_L AV_CH_FRONT_LEFT
91#define CH_R AV_CH_FRONT_RIGHT
92#define CH_LFE AV_CH_LOW_FREQUENCY
93#define CH_S AV_CH_BACK_CENTER
94#define CH_LS AV_CH_BACK_LEFT
95#define CH_RS AV_CH_BACK_RIGHT
111 [ 0] = { 1, 0, {
CH_C } },
148 uint32_t header_int =
header->quantization |
149 header->sampling_frequency << 8 |
150 header->channel_assignment << 16;
151 int assignment =
header->channel_assignment & 0x1f;
152 int bits[2], rate[2];
156 if (
s->last_header == header_int)
163 header->channel_assignment);
165 if (assignment > 20) {
174 for (
int i = 0;
i < 2;
i++) {
176 int freq =
i ?
header->sampling_frequency & 0xf :
header->sampling_frequency >> 4;
179 if (
i && (
quant == 0xf || freq == 0xf))
180 s->group_channels[1] = 0;
181 if (!
s->group_channels[
i]) {
186 if (
quant > 2 || (freq & 7) > 2) {
188 "invalid group %d quantization %#x or sample rate %#x\n",
193 rate[
i] = (freq & 8 ? 44100 : 48000) << (freq & 7);
201 if (
s->group_channels[1] && rate[1] != rate[0]) {
207 s->group_bits[0] =
bits[0];
208 s->group_bits[1] =
bits[1];
209 s->channels =
s->group_channels[0] +
s->group_channels[1];
210 s->block_size = 2 * (
s->group_channels[0] *
bits[0] +
211 s->group_channels[1] *
bits[1]) / 8;
214 for (
int i = 0;
i <
s->channels;
i++)
216 for (
int i = 0;
i <
s->channels;
i++) {
220 s->group_map[0][
i] =
pos;
222 s->group_map[1][
i -
s->group_channels[0]] =
pos;
235 "pcm_dvda_parse_header: %d channels, %d+%d bits per sample, "
236 "%d Hz, %"PRId64
" bit/s\n",
240 s->last_header = header_int;
253 void *
dst,
int blocks)
256 int16_t *dst16 =
dst;
262 for (
int g = 1;
g >= 0;
g--) {
263 const int ch =
s->group_channels[
g];
264 const int bits =
s->group_bits[
g];
265 const uint8_t *
map =
s->group_map[
g];
270 for (
int n = 0; n < 2; n++) {
271 for (
int j = 0; j < ch; j++) {
272 unsigned v = bytestream2_get_be16u(gb);
274 dst16[n *
s->channels +
map[j]] = v;
276 dst32[n *
s->channels +
map[j]] = v << 16;
280 for (
int n = 0; n < 2; n++)
281 for (
int j = 0; j < ch; j++)
282 dst32[n *
s->channels +
map[j]] |=
283 bytestream2_get_byteu(gb) << 8;
286 dst16 += 2 *
s->channels;
287 dst32 += 2 *
s->channels;
292 int *got_frame_ptr,
AVPacket *avpkt)
296 int buf_size = avpkt->
size;
302 if (buf_size <
sizeof(*
header)) {
309 header_size = offsetof(
PCMDVDAHeader, first_access_unit_pointer) +
310 header->private_header_length;
311 if (header_size <
sizeof(*
header) || header_size > buf_size) {
320 buf_size -= header_size;
321 blocks = buf_size /
s->block_size;
322 if (buf_size %
s->block_size)
324 buf_size %
s->block_size);
331 frame->nb_samples = blocks * 2;
344 .p.name =
"pcm_dvda",
345 CODEC_LONG_NAME(
"PCM signed 16|20|24-bit big-endian for DVD-Audio media"),
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_pcm_dvda_decoder
Libavcodec external API header.
#define FF_DEBUG_PICT_INFO
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
const VDPAUPixFmtMap * map
static const uint16_t mask[17]
static int pcm_dvda_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static int pcm_dvda_parse_header(AVCodecContext *avctx, const PCMDVDAHeader *header)
static const struct @332126027324302347145266027355074342206106360164 channel_assignments[21]
static av_cold int pcm_dvda_decode_init(AVCodecContext *avctx)
static void pcm_dvda_decode_samples(AVCodecContext *avctx, GetByteContext *gb, void *dst, int blocks)
static const uint8_t header[24]
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int64_t bit_rate
the average bitrate
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
#define avpriv_request_sample(...)
static const uint8_t quant[64]