[Ffmpeg-devel] [PATCH] Make pcm.c use bytestream functions

Michael Niedermayer michaelni
Thu Mar 15 00:16:31 CET 2007


Hi

On Wed, Mar 14, 2007 at 04:04:38PM -0300, Ramiro Polla wrote:
> Hello,
> 
> $subj
> 
> Along with [1], it makes:
> ffmpeg -benchmark -i wave.wav -f wav -acodec pcm_s32le -y /dev/null
> 
> take 0,590s instead of 0,750s.
> wave.wav is a 74mb pcm_s16le wav file.
> 
> It's hard to see the difference, but there is one...
> 
> [1] http://article.gmane.org/gmane.comp.video.ffmpeg.devel/46283
> 
> Ramiro Polla

[...]
>      case CODEC_ID_PCM_S8:
>          for(;n>0;n--) {
>              v = *samples++;
> -            dst[0] = v >> 8;
> -            dst++;
> +            v >>= 8;
> +            bytestream_put_byte(&dst, v);

*dst++ = v>>8;


>          }
>          break;
>      case CODEC_ID_PCM_U8:
>          for(;n>0;n--) {
>              v = *samples++;
> -            dst[0] = (v >> 8) + 128;
> -            dst++;
> +            v >>= 8;
> +            v += 128;
> +            bytestream_put_byte(&dst, v);

*dst++ = (v>>8)+128;

similar for the others as IMHO its silly to hide *dst++ behind a function


[...]
> @@ -364,7 +352,11 @@
>      register int n = src_len / bps;
>      if (le) *src += bps - 2;
>      for(;n>0;n--) {
> -        *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) - (us?0x8000:0);
> +        register int v;
> +        if (le) v = AV_RL16(*src);
> +        else    v = AV_RB16(*src);
> +        if (us) v -= 0x80000;
> +        *(*samples)++ = v;

put foobar= us? -0x80000 : 0 before the loop and
v+= foobar; in it


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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070315/b150d70d/attachment.pgp>



More information about the ffmpeg-devel mailing list