Go to the documentation of this file.
78 static_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
106 static const struct {
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;
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++) {
219 if (i < s->group_channels[0])
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;
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"),
static int pcm_dvda_parse_header(AVCodecContext *avctx, const PCMDVDAHeader *header)
static void pcm_dvda_decode_samples(AVCodecContext *avctx, GetByteContext *gb, void *dst, int blocks)
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
static av_cold int pcm_dvda_decode_init(AVCodecContext *avctx)
#define FF_DEBUG_PICT_INFO
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
static const uint8_t quant[64]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
const FFCodec ff_pcm_dvda_decoder
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.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const struct @250 channel_assignments[21]
#define CODEC_LONG_NAME(str)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int64_t bit_rate
the average bitrate
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
enum AVSampleFormat sample_fmt
audio sample format
static const uint8_t header[24]
#define xf(width, name, var, range_min, range_max, subs,...)
static int pcm_dvda_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
main external API structure.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define avpriv_request_sample(...)
const VDPAUPixFmtMap * map
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AV_SAMPLE_FMT_S32
signed 32 bits