[FFmpeg-devel] [PATCH] LPCM in MPEG-TS, next iteration
Michael Niedermayer
michaelni
Mon Aug 17 05:53:29 CEST 2009
On Sat, Aug 15, 2009 at 04:04:36PM +0300, Christian P. Schmidt wrote:
> Carl Eugen Hoyos wrote:
> > Christian P. Schmidt <schmidt <at> digadd.de> writes:
> >
> >> + * LPCM codecs for PCM formats found in MPEG streams
> >> + * Copyright (c) 2009 FFmpeg developers
> >
> > I still think this is not acceptable.
>
> I give up on not putting my name.
you could use a pseudonym if you really dont want your name there
[...]
> + dprintf(avctx, "pcm_bluray_parse_header: %d channels, %d bits per sample, %d kHz, %d kbit\n",
> + avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate,
> + avctx->bit_rate);
should be under if( avctx->debug & FF_DEBUG_PICT_INFO)
> + return 0;
> +}
> +
> +static int pcm_bluray_decode_frame(AVCodecContext *avctx,
> + void *data,
> + int *data_size,
> + AVPacket *avpkt)
> +{
> + const uint8_t *src = avpkt->data;
> + int buf_size = avpkt->size;
> + int num_source_channels, channel, retval;
> + int sample_size, samples;
> +#if HAVE_BIGENDIAN
> + int used_sample_size;
> +#endif
redundant #if
> + int16_t *dst16 = data;
> + int32_t *dst32 = data;
> +
> + if (buf_size < 4) {
> + av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n");
> + return -1;
> + }
> +
> + if (pcm_bluray_parse_header(avctx, src))
> + return -1;
> + src += 4;
> + buf_size -= 4;
> +
> + /* There's always an even number of channels in the source */
> + num_source_channels = FFALIGN(avctx->channels, 2);
> + sample_size = (num_source_channels * avctx->bits_per_coded_sample) >> 3;
> + samples = buf_size / sample_size;
> + *data_size = samples * avctx->channels *
> + (avctx->sample_fmt == SAMPLE_FMT_S32 ? 4 : 2);
should there not be a check on data_size being large enough?
> +
> + dprintf(avctx,
> + "pcm_bluray_decode_frame: c: %d sc: %d s: %d in: %d ds: %d\n",
> + avctx->channels, num_source_channels, num_samples, buf_size,
> + *data_size);
> +
> + if (samples) {
> + switch (avctx->channel_layout) {
> + /* cases with same number of source and coded channels */
> + case CH_LAYOUT_STEREO:
> + case CH_LAYOUT_4POINT0:
> + case CH_LAYOUT_2_2:
> + samples *= num_source_channels;
> + if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
> +#if HAVE_BIGENDIAN
> + memcpy(dst16, src, samples << 1);
> +#else
> + do {
> + *dst16++ = bytestream_get_be16(&src);
> + } while (--samples);
> +#endif
> + } else {
> + do {
> + *dst32++ = bytestream_get_be24(&src) << 8;
> + } while (--samples);
> + }
> + break;
> + /* cases where number of source channels = coded channels +1 */
> + case CH_LAYOUT_MONO:
> + case CH_LAYOUT_SURROUND:
> + case CH_LAYOUT_2_1:
> + case CH_LAYOUT_5POINT0:
> + if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
> +#if HAVE_BIGENDIAN
> + used_sample_size = avctx->channels * 2;
> + do {
> + memcpy(dst16, src, used_sample_size);
> + dst16 += avctx->channels;
> + src += sample_size;
> + } while (--samples);
> +#else
> + do {
> + channel = avctx->channels;
> + do {
> + *dst16++ = bytestream_get_be16(&src);
> + } while (--channel);
> + src += 2;
> + } while (--samples);
> +#endif
ugly, duplicated and factorizeable
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090817/be088a9b/attachment.pgp>
More information about the ffmpeg-devel
mailing list