[FFmpeg-devel] support for audio with sample resolution better than 16bit

Michael Niedermayer michaelni
Mon Apr 21 19:37:46 CEST 2008


On Mon, Apr 21, 2008 at 06:59:30PM +0200, Lars T?uber wrote:
> Hallo!
> 
> Here is what I understood so far could be meant by all of you.
> 
> The patch might not compile, it's just for discussion.
> 
> Regards
> Lars

> diff -pur ffmpeg/libavcodec/utils.c ffmpeg.2/libavcodec/utils.c
> --- ffmpeg/libavcodec/utils.c	2008-04-11 18:11:42.000000000 +0200
> +++ ffmpeg.2/libavcodec/utils.c	2008-04-21 18:52:08.000000000 +0200
> @@ -955,11 +955,11 @@ int attribute_align_arg avcodec_decode_v
>      return ret;
>  }
>  
> -int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
> -                         int *frame_size_ptr,
> +int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx,
> +                        void *samples, int *frame_size_ptr,

You misunderstood (me at least)

I meant:

-int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
+int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, void *samples,
                          int *frame_size_ptr,


[...]
> +    if (avctx->sample_fmt == SAMPLE_FMT_U8) {
> +        for (i=0; i<*frame_size_ptr; i++)
> +            ((int16_t *)samples)[i] = (int16_t)((((uint8_t *)samples)[i] - 0x80) << 8);
> +        *frame_size_ptr *= 2;
> +    }
> +
> +    if (avctx->sample_fmt == SAMPLE_FMT_S32) {
> +        data_size/=4;
> +        for (i=0; i<*frame_size_ptr; i++)
> +            ((int16_t *)samples)[i] = (int16_t)(((int32_t *)samples)[i] >> 16);
> +        *frame_size_ptr *= 2;
> +    }

We do not convert formats behind the users back for video, so why should we
for audio?
Yes, most applications will need to add 2 lines of code to execute some
convertion function or to pass the sample_fmt. But they need to do this
anyway eventually, such convertion code in avcodec_decode_audio2() would
only exist until the next major ver bump and would do more harm (slow,
maintaince) than good.

Also we do not need a major ver bump for the use of sample_fmt it was there
since ages, applications which ignored it are broken even if that means all
applications are.


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- 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/20080421/084facf0/attachment.pgp>



More information about the ffmpeg-devel mailing list