55 static const uint32_t frequencies[4] = { 48000, 96000, 44100, 32000 };
60 if (
s->last_header == header_int)
74 s->extra_sample_count = 0;
80 "PCM DVD unsupported sample depth %i\n",
102 s->samples_per_block = 1;
111 s->samples_per_block = 4 / avctx->
channels;
112 s->groups_per_block = 1;
117 s->samples_per_block = 1;
118 s->groups_per_block = 2;
124 s->samples_per_block = 4;
132 "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64
" bit/s\n",
136 s->last_header = header_int;
142 void *dst,
int blocks)
145 int16_t *dst16 = dst;
156 dst16 += blocks *
s->block_size / 2;
158 int samples = blocks * avctx->
channels;
160 *dst16++ = bytestream2_get_be16u(&gb);
168 for (
i = 2;
i;
i--) {
169 dst32[0] = bytestream2_get_be16u(&gb) << 16;
170 dst32[1] = bytestream2_get_be16u(&gb) << 16;
171 t = bytestream2_get_byteu(&gb);
172 *dst32++ += (t & 0xf0) << 8;
173 *dst32++ += (t & 0x0f) << 12;
178 for (
i =
s->groups_per_block;
i;
i--) {
179 dst32[0] = bytestream2_get_be16u(&gb) << 16;
180 dst32[1] = bytestream2_get_be16u(&gb) << 16;
181 dst32[2] = bytestream2_get_be16u(&gb) << 16;
182 dst32[3] = bytestream2_get_be16u(&gb) << 16;
183 t = bytestream2_get_byteu(&gb);
184 *dst32++ += (t & 0xf0) << 8;
185 *dst32++ += (t & 0x0f) << 12;
186 t = bytestream2_get_byteu(&gb);
187 *dst32++ += (t & 0xf0) << 8;
188 *dst32++ += (t & 0x0f) << 12;
196 for (
i = 2;
i;
i--) {
197 dst32[0] = bytestream2_get_be16u(&gb) << 16;
198 dst32[1] = bytestream2_get_be16u(&gb) << 16;
199 *dst32++ += bytestream2_get_byteu(&gb) << 8;
200 *dst32++ += bytestream2_get_byteu(&gb) << 8;
205 for (
i =
s->groups_per_block;
i;
i--) {
206 dst32[0] = bytestream2_get_be16u(&gb) << 16;
207 dst32[1] = bytestream2_get_be16u(&gb) << 16;
208 dst32[2] = bytestream2_get_be16u(&gb) << 16;
209 dst32[3] = bytestream2_get_be16u(&gb) << 16;
210 *dst32++ += bytestream2_get_byteu(&gb) << 8;
211 *dst32++ += bytestream2_get_byteu(&gb) << 8;
212 *dst32++ += bytestream2_get_byteu(&gb) << 8;
213 *dst32++ += bytestream2_get_byteu(&gb) << 8;
224 int *got_frame_ptr,
AVPacket *avpkt)
228 int buf_size = avpkt->
size;
241 if (
s->last_block_size &&
s->last_block_size !=
s->block_size) {
243 s->extra_sample_count = 0;
245 s->last_block_size =
s->block_size;
249 blocks = (buf_size +
s->extra_sample_count) /
s->block_size;
258 if (
s->extra_sample_count) {
259 int missing_samples =
s->block_size -
s->extra_sample_count;
260 if (buf_size >= missing_samples) {
261 memcpy(
s->extra_samples +
s->extra_sample_count,
src,
264 src += missing_samples;
265 buf_size -= missing_samples;
266 s->extra_sample_count = 0;
270 memcpy(
s->extra_samples +
s->extra_sample_count,
src, buf_size);
271 s->extra_sample_count += buf_size;
279 buf_size -= blocks *
s->block_size;
284 src += blocks *
s->block_size;
285 memcpy(
s->extra_samples,
src, buf_size);
286 s->extra_sample_count = buf_size;
static enum AVSampleFormat sample_fmts[]
Libavcodec external API header.
#define FF_DEBUG_PICT_INFO
static av_cold int init(AVCodecContext *avctx)
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVCodec ff_pcm_dvd_decoder
static void * pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src, void *dst, int blocks)
static int pcm_dvd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx)
static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header)
static const uint8_t header[24]
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
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
int channels
number of audio channels
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This structure stores compressed data.
uint8_t extra_samples[8 *3 *4]