[FFmpeg-devel] [RFC] LPCM 24 bits support

Michael Niedermayer michaelni
Sat Apr 19 17:05:37 CEST 2008


On Sat, Apr 19, 2008 at 10:11:56AM +0200, Lars T?uber wrote:
> On Sat, 19 Apr 2008 02:15:16 +0200 Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Fri, Apr 18, 2008 at 11:24:03PM +0200, Lars T?uber wrote:
> > > On Fri, 18 Apr 2008 22:52:40 +0200 Michael Niedermayer <michaelni at gmx.at> wrote:
> > > > On Fri, Apr 18, 2008 at 09:37:12PM +0200, Lars T?uber wrote:
> > > > > On Fri, 18 Apr 2008 22:08:24 +0200 Michael Niedermayer <michaelni at gmx.at> wrote:
> > > > > > On Fri, Apr 18, 2008 at 09:05:23PM +0200, Lars T?uber wrote:
> > > > > > > On Fri, 18 Apr 2008 15:39:43 +0200 Michael Niedermayer <michaelni at gmx.at> wrote:
> > > > > > > > On Thu, Apr 17, 2008 at 10:13:40PM +0200, Lars T?uber wrote:
> [...]
> > > diff -pur ffmpeg/libavcodec/pcm.c ffmpeg.1/libavcodec/pcm.c
> > > --- ffmpeg/libavcodec/pcm.c	2008-04-18 20:22:18.000000000 +0200
> > > +++ ffmpeg.1/libavcodec/pcm.c	2008-04-18 23:19:20.000000000 +0200
> > > @@ -492,6 +498,41 @@ static int pcm_decode_frame(AVCodecConte
> > >              *samples++ = s->table[*src++];
> > >          }
> > >          break;
> > > +    case CODEC_ID_PCM_DVD: {
> > > +            int audio24[8*2], *ap;
> > > +            const uint8_t *src_LSB;
> > > +
> > > +            if (avctx->channels > 8) {
> > > +                av_log(avctx, AV_LOG_ERROR, "PCM_DVD channels out of bounds\n");
> > > +                return -1;
> > > +            }
> > 
> > > +            n = buf_size / (avctx->channels * 2 * avctx->bits_per_sample / 8);
> > > +            while (n--) {
> > > +                ap = audio24;
> > > +                src_LSB = src + avctx->channels * 2 * 2;
> > > +
> > > +                switch (avctx->bits_per_sample) {
> > > +                    case 20:
> > > +                        for (c=0; c < avctx->channels; c++, src+=4, src_LSB++ ) {
> > > +                            *ap++ = src[0]<<16 | src[1]<<8 | (*src_LSB & 0xf0);
> > > +                            *ap++ = src[2]<<16 | src[3]<<8 | (*src_LSB & 0x0f)<<4;
> > > +                        }
> > > +                        break;
> > > +                    case 24:
> > > +                        for (c=0; c < 2*avctx->channels; c++, src+=2, src_LSB++ )
> > > +                            *ap++ = src[0]<<16 | src[1]<<8 | *src_LSB;
> > > +                        break;
> > > +                    default:
> > > +                        av_log(avctx, AV_LOG_ERROR, "PCM_DVD unsupported sample depth\n");
> > > +                        return -1;
> > > +                }
> > > +                src = src_LSB;
> > > +
> > > +                for (c=0; c < avctx->channels*2; c++)
> > > +                    *samples++ = audio24[c] >> 8;
> > 
> > following is simpler and faster:
> > 
> > if(avctx->bits_per_sample != 20 && avctx->bits_per_sample != 24){
> >     av_log(avctx, AV_LOG_ERROR, "PCM_DVD unsupported sample depth\n");
> >     return -1;
> > }
> > n = buf_size / (avctx->channels * 2 * avctx->bits_per_sample / 8);
> > while (n--) {
> >     for (c=0; c < 2*avctx->channels; c++)
> >         *samples++ = bytestream_get_be16(&src);
> >     src+= avctx->channels * (avctx->bits_per_sample-16) / 4;
> > }
> 
> Yes of course, but as I stated earlier:
> > On Thu, 17 Apr 2008 21:10:07 +0100 M?ns Rullg?rd <mans at mansr.com> wrote:
> >> What's the point in saving 24 bits per sample to a temporary buffer,
> >> only to discard the low 8 bits later?
> > 
> > I'd like to work on a patch that makes ffmpeg support more than 16 bit for audio after this has been accepted.
> > For instance to convert 24bit pcm_dvd to 24bit flac. But I don't know how to do this right now.
> > Is this overhead acceptable till then?
> 
> Otherwise I will change it to your version.

please change it, it can always be changed again when 24bits are supported


> OR:
> Is it allowed to sent commented out code or ifdefed-out-code for a wide-sample-version in addition to the working 16bit version?

You can send anything, but IMHO its better to send a functional patch
which could be applied after 24bit support has been added.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20080419/1b9542dd/attachment.pgp>



More information about the ffmpeg-devel mailing list