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

Ramiro Polla ramiro
Thu Mar 15 21:44:08 CET 2007


Hello,

Michael Niedermayer escreveu:
> 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
>
>   
Ok.
> [...]
>   
>> @@ -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
>
>
>   
Ok.

pcm_av_rwbl.diff changes the functions to use AV_xx16.
pcm_bytestream.diff makes 16 and 24 bit reads/writes use bytestream.
pcm_byte.diff changes dst[0]; dst++; blocks to *dst++;

Ramiro Polla
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pcm_av_rwbl.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070315/39333373/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pcm_bytestream.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070315/39333373/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pcm_byte.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070315/39333373/attachment-0001.txt>



More information about the ffmpeg-devel mailing list