[FFmpeg-devel] Experimental MSVC port
Ronald S. Bultje
rsbultje
Wed Mar 26 16:46:22 CET 2008
Hi,
On Wed, Mar 26, 2008 at 11:16 AM, Ole Andre Vadla Ravn?s <
ole.andre.ravnas at tandberg.com> wrote:
You want to split this stuff up in many, many small patches for the obvious
stuff. It'll make applying a lot easier. For example:
+#include <assert.h>
> #include <inttypes.h>
or
> @@ -39,6 +44,11 @@
> # include <limits.h>
> # include <errno.h>
> # include <math.h>
> +
> +# ifdef _MSC_VER
> +# define WIN32_LEAN_AND_MEAN
> +# include <windows.h>
> +# endif
> #endif /* HAVE_AV_CONFIG_H */
>
> #ifndef av_always_inline
(actually, why do you need windows.h? What's wrong with standard libc
headers on win32? If specific functions need windows.h (as below in
read_time()), then just include them in those particular functions, not
everywhere)
or
> @@ -298,11 +308,17 @@ static inline uint64_t read_time(void)
> #elif defined(ARCH_X86_32)
> static inline long long read_time(void)
> {
> +#ifndef _MSC_VER
> long long l;
> asm volatile( "rdtsc\n\t"
> : "=A" (l)
> );
> return l;
> +#else
> + LARGE_INTEGER i;
> + QueryPerformanceCounter(&i);
> + return i.QuadPart;
> +#endif
> }
> #elif ARCH_BFIN
> static inline uint64_t read_time(void)
Each of those (and others) can be done in separate patches and I don't think
many people would mind.
+#ifdef _MSC_VER
> +#define inline __inline
> +#endif
-> liboss (same in random.h)
> Index: ffmpeg/libavutil/intfloat_readwrite.c
> ===================================================================
> --- ffmpeg.orig/libavutil/intfloat_readwrite.c
> +++ ffmpeg/libavutil/intfloat_readwrite.c
> @@ -28,15 +28,22 @@
> #include "common.h"
> #include "intfloat_readwrite.h"
>
> +#ifndef _MSC_VER
> +#define NaN (0.0/0.0)
> +#else
> +static unsigned long nan[2] = { 0xffffffff, 0x7fffffff };
> +#define NaN (*((double *) nan))
> +#endif
> +
> double av_int2dbl(int64_t v){
> if(v+v > 0xFFEULL<<52)
> - return 0.0/0.0;
> + return NaN;
> return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1),
> (v>>52&0x7FF)-1075);
> }
>
> float av_int2flt(int32_t v){
> if(v+v > 0xFF000000U)
> - return 0.0/0.0;
> + return NaN;
> return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
> }
>
> @@ -48,7 +55,7 @@ double av_ext2dbl(const AVExtFloat ext){
> m = (m<<8) + ext.mantissa[i];
> e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];
> if (e == 0x7fff && m)
> - return 0.0/0.0;
> + return NaN;
> e -= 16383 + 63; /* In IEEE 80 bits, the whole (i.e. 1.xxxx)
> * mantissa bit is written as opposed to the
> * single and double precision formats */
> @@ -87,7 +94,7 @@ AVExtFloat av_dbl2ext(double d){
> ext.mantissa[i] = m>>(56-(i<<3));
> } else if (f != 0.0) {
> ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;
> - if (f != 1/0.0)
> + if (f != NaN)
> ext.mantissa[0] = ~0;
> }
> if (d < 0)
Can be done separately also.
> @@ -1747,7 +1755,10 @@ enum CodecID av_codec_get_id(const AVCod
> #define MAX_STD_TIMEBASES (60*12+5)
> static int get_std_framerate(int i){
> if(i<60*12) return i*1001;
> - else return ((int[]){24,30,60,12,15})[i-60*12]*1000*12;
> + else {
> + int values[] = {24,30,60,12,15};
> + return values[i-60*12]*1000*12;
> + }
> }
>
> int av_find_stream_info(AVFormatContext *ic)
Can you do your changes in rationale.c, opt.c and h263.c in this style also
(i.e. don't remove the unnamed struct intialized in favour of value
initializes, but rather in favour of named struct initializers).
Ronald
More information about the ffmpeg-devel
mailing list