[FFmpeg-devel] [PATCH] Change round to rint in atrac3.c

Benjamin Larsson banan
Mon Oct 15 10:07:18 CEST 2007


Fred Rothganger wrote:
> I am compiling ffmpeg under cygwin with -mno-cygwin, and then linking 
> the resulting static libs under MSVC 2005 edition.  There are three 
> symbols that remain undefined at link time:
>
> _snprintf
> _gettimeofday
> _round
>
> This patch addresses _round.  Don't know what the efficiency impact is 
> of using rint() and cast rather than round().
>
> -- Fred
>
> ------------------------------------------------------------------------
>
> Index: atrac3.c
> ===================================================================
> --- atrac3.c	(revision 10737)
> +++ atrac3.c	(working copy)
> @@ -895,13 +895,13 @@
>      if (q->channels == 1) {
>          /* mono */
>          for (i = 0; i<1024; i++)
> -            samples[i] = av_clip_int16(round(q->outSamples[i]));
> +            samples[i] = av_clip_int16((int) rint(q->outSamples[i]));
>          *data_size = 1024 * sizeof(int16_t);
>      } else {
>          /* stereo */
>          for (i = 0; i < 1024; i++) {
> -            samples[i*2] = av_clip_int16(round(q->outSamples[i]));
> -            samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i]));
> +            samples[i*2] = av_clip_int16((int) rint(q->outSamples[i]));
> +            samples[i*2+1] = av_clip_int16((int) rint(q->outSamples[1024+i]));
>          }
>          *data_size = 2048 * sizeof(int16_t);
>      }
>   

Here we should use the dsp optimized float to int16 routines. That would 
take care of the round usage by not using it at all. Either send a patch 
yourself or file a request on the roundup issue tracker and I'll do it 
when I get time.

MvH
Benjamin Larsson






More information about the ffmpeg-devel mailing list