[FFmpeg-devel] [RFC] LPCM 24 bits support
Giuliano Pochini
pochini
Sun Apr 13 21:57:16 CEST 2008
On Sun, 13 Apr 2008 09:18:16 +0200
Lars T?uber <lars.taeuber at gmx.net> wrote:
> Hallo Giuliano,
>
> I overlooked your work sorry for that.
>
> On Sun, 30 Mar 2008 18:56:17 +0000 Giuliano Pochini <pochini at shiny.it> wrote:
> > diff -dupr ffmpeg__orig/libavcodec/pcm.c ffmpeg/libavcodec/pcm.c
> > --- ffmpeg__orig/libavcodec/pcm.c 2008-02-06 12:37:37.000000000 +0000
> > +++ ffmpeg/libavcodec/pcm.c 2008-03-30 18:41:30.000000000 +0000
> > @@ -492,6 +492,43 @@ static int pcm_decode_frame(AVCodecConte
> > *samples++ = s->table[*src++];
> > }
> > break;
> > + case CODEC_ID_PCM_DVD20:
> > + {
> > + int audio24[8*2], *ap;
> > + const uint8_t *src_LSB;
> > +
> > + for (n=buf_size/(avctx->channels * 5); n>0; n--) {
> > + ap = audio24;
> > + src_LSB = src + avctx->channels * 2 * 2;
> > + for (c=0; c<avctx->channels; c++, src+=4, src_LSB++) {
> > + *ap++ = (((const int8_t *)src)[0]<<16) + (src[1]<<8) + (*src_LSB & 0xf0);
> > + *ap++ = (((const int8_t *)src)[2]<<16) + (src[3]<<8) + ((*src_LSB << 4) & 0xff);
>
> Does this work with an odd number of channels, or are only even number of channels possible?
Yes, it does. I tested it with 1, 2 and 6 -channels files. It works because
each block contains two frames. A 24-bits mono stream is encoded as follows:
0: hi byte channel 0 frame 0
1: mi byte channel 0 frame 0
2: hi byte channel 0 frame 1
3: mi byte channel 0 frame 1
4: lo byte channel 0 frame 0
5: lo byte channel 0 frame 1
A 20-bits mono stream is the same, except byte #4 contains two nibbles.
> > + }
> > + break;
> > + }
>
> I'm not sure, but the break; and the following { should be exchanged.!?
I copied the coding style of adpcm.c, where there are several unconditional
code block inside case's where the break is inside the closing brace.
> > + case CODEC_ID_PCM_DVD24:
> > + { [...]
> > + break;
> > + }
>
> break; <=> } ??
Same as above. Is there a coding style doc ? I could not find any.
--
Giuliano.
More information about the ffmpeg-devel
mailing list