[MPlayer-dev-eng] [PATCH] depend on libavutil and use proper machine-independant float reading
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Apr 16 16:31:03 CEST 2006
Hi,
I found the attached patch lying around, not sure if it applies, but
before I take any more effort I'd like to get some comments on it.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: bswap.h
===================================================================
RCS file: /cvsroot/mplayer/main/bswap.h,v
retrieving revision 1.6
diff -u -r1.6 bswap.h
--- bswap.h 13 Jul 2005 17:24:41 -0000 1.6
+++ bswap.h 12 Oct 2005 12:29:50 -0000
@@ -117,37 +117,6 @@
#endif /* !HAVE_BYTESWAP_H */
-static float inline bswap_flt(float x) {
- union {uint32_t i; float f;} u;
- u.f = x;
- u.i = bswap_32(u.i);
- return u.f;
-}
-
-static double inline bswap_dbl(double x) {
- union {uint64_t i; double d;} u;
- u.d = x;
- u.i = bswap_64(u.i);
- return u.d;
-}
-
-static long double inline bswap_ldbl(long double x) {
- union {char d[10]; long double ld;} uin;
- union {char d[10]; long double ld;} uout;
- uin.ld = x;
- uout.d[0] = uin.d[9];
- uout.d[1] = uin.d[8];
- uout.d[2] = uin.d[7];
- uout.d[3] = uin.d[6];
- uout.d[4] = uin.d[5];
- uout.d[5] = uin.d[4];
- uout.d[6] = uin.d[3];
- uout.d[7] = uin.d[2];
- uout.d[8] = uin.d[1];
- uout.d[9] = uin.d[0];
- return uout.ld;
-}
-
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian
@@ -158,12 +127,6 @@
#define le2me_16(x) bswap_16(x)
#define le2me_32(x) bswap_32(x)
#define le2me_64(x) bswap_64(x)
-#define be2me_flt(x) (x)
-#define be2me_dbl(x) (x)
-#define be2me_ldbl(x) (x)
-#define le2me_flt(x) bswap_flt(x)
-#define le2me_dbl(x) bswap_dbl(x)
-#define le2me_ldbl(x) bswap_ldbl(x)
#else
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
@@ -171,12 +134,6 @@
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#define le2me_64(x) (x)
-#define be2me_flt(x) bswap_flt(x)
-#define be2me_dbl(x) bswap_dbl(x)
-#define be2me_ldbl(x) bswap_ldbl(x)
-#define le2me_flt(x) (x)
-#define le2me_dbl(x) (x)
-#define le2me_ldbl(x) (x)
#endif
#endif /* __BSWAP_H__ */
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.1078
diff -u -r1.1078 configure
--- configure 11 Oct 2005 23:44:08 -0000 1.1078
+++ configure 12 Oct 2005 12:30:16 -0000
@@ -5792,6 +5792,7 @@
_libavutil=yes
else
_libavutil=no
+ die "libavutil is required by MPlayer!"
fi
echores "$_libavutil"
Index: libmpdemux/demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.48
diff -u -r1.48 demux_mkv.c
--- libmpdemux/demux_mkv.c 2 Sep 2005 08:32:32 -0000 1.48
+++ libmpdemux/demux_mkv.c 12 Oct 2005 12:32:01 -0000
@@ -643,7 +643,7 @@
case MATROSKA_ID_DURATION:
{
- long double num = ebml_read_float (s, &l);
+ double num = ebml_read_float (s, &l);
if (num == EBML_FLOAT_INVALID)
return 1;
mkv_d->duration = num * mkv_d->tc_scale / 1000000000.0;
@@ -836,7 +836,7 @@
{
case MATROSKA_ID_AUDIOSAMPLINGFREQ:
{
- long double num = ebml_read_float (s, &l);
+ double num = ebml_read_float (s, &l);
if (num == EBML_FLOAT_INVALID)
return 0;
track->a_sfreq = num;
@@ -891,7 +891,7 @@
{
case MATROSKA_ID_VIDEOFRAMERATE:
{
- long double num = ebml_read_float (s, &l);
+ double num = ebml_read_float (s, &l);
if (num == EBML_FLOAT_INVALID)
return 0;
track->v_frate = num;
Index: libmpdemux/demux_nuv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_nuv.c,v
retrieving revision 1.15
diff -u -r1.15 demux_nuv.c
--- libmpdemux/demux_nuv.c 5 Aug 2005 19:57:46 -0000 1.15
+++ libmpdemux/demux_nuv.c 12 Oct 2005 12:32:03 -0000
@@ -16,6 +16,7 @@
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
+#include "libavutil/intfloat_readwrite.h"
#include "nuppelvideo.h"
Index: libmpdemux/ebml.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ebml.c,v
retrieving revision 1.6
diff -u -r1.6 ebml.c
--- libmpdemux/ebml.c 13 Jul 2005 17:24:42 -0000 1.6
+++ libmpdemux/ebml.c 12 Oct 2005 12:32:04 -0000
@@ -13,6 +13,7 @@
#include "stream.h"
#include "ebml.h"
#include "bswap.h"
+#include "libavutil/intfloat_readwrite.h"
/*
@@ -164,10 +165,10 @@
/*
* Read the next element as a float.
*/
-long double
+double
ebml_read_float (stream_t *s, uint64_t *length)
{
- long double value;
+ double value;
uint64_t len;
int l;
@@ -176,26 +177,15 @@
{
case 4:
{
- union {uint32_t i; float f;} u;
- u.i = stream_read_dword (s);
- value = u.f;
+ int32_t v = stream_read_dword(s);
+ value = av_int2flt(v);
break;
}
case 8:
{
- union {uint64_t i; double d;} u;
- u.i = stream_read_qword (s);
- value = u.d;
- break;
- }
-
- case 10:
- {
- union {uint8_t data[10]; long double ld;} u;
- if (stream_read (s, u.data, 10) != 10)
- return EBML_FLOAT_INVALID;
- value = be2me_ldbl(u.ld);
+ int32_t v = stream_read_qword(s);
+ value = av_int2dbl(v);
break;
}
Index: libmpdemux/ebml.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ebml.h,v
retrieving revision 1.3
diff -u -r1.3 ebml.h
--- libmpdemux/ebml.h 25 Jan 2004 16:17:38 -0000 1.3
+++ libmpdemux/ebml.h 12 Oct 2005 12:32:05 -0000
@@ -172,7 +172,7 @@
uint64_t ebml_read_length (stream_t *s, int *length);
uint64_t ebml_read_uint (stream_t *s, uint64_t *length);
int64_t ebml_read_int (stream_t *s, uint64_t *length);
-long double ebml_read_float (stream_t *s, uint64_t *length);
+double ebml_read_float (stream_t *s, uint64_t *length);
char *ebml_read_ascii (stream_t *s, uint64_t *length);
char *ebml_read_utf8 (stream_t *s, uint64_t *length);
int ebml_read_skip (stream_t *s, uint64_t *length);
Index: libmpdemux/nuppelvideo.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/nuppelvideo.h,v
retrieving revision 1.5
diff -u -r1.5 nuppelvideo.h
--- libmpdemux/nuppelvideo.h 1 Aug 2005 18:52:20 -0000 1.5
+++ libmpdemux/nuppelvideo.h 12 Oct 2005 12:32:05 -0000
@@ -12,9 +12,15 @@
char pimode; // P .. progressive
// I .. interlaced (2 half pics) [NI]
char pad2[3];
+ union {
+ int64_t aspect_int;
double aspect; // 1.0 .. square pixel (1.5 .. e.g. width=480: width*1.5=720
// for capturing for svcd material
+ };
+ union {
+ int64_t fps_int;
double fps;
+ };
int videoblocks; // count of video-blocks -1 .. unknown 0 .. no video
int audioblocks; // count of audio-blocks -1 .. unknown 0 .. no audio
int textsblocks; // count of text-blocks -1 .. unknown 0 .. no text
@@ -120,13 +126,16 @@
unsigned char *buffer_offset;
} audbuffertyp;
+// since this struct contains double values, this function
+// really does only le->me conversion, it can not be used for
+// me->le conversion!!
#define le2me_rtfileheader(h) { \
(h)->width = le2me_32((h)->width); \
(h)->height = le2me_32((h)->height); \
(h)->desiredwidth = le2me_32((h)->desiredwidth); \
(h)->desiredheight = le2me_32((h)->desiredheight); \
- (h)->aspect = le2me_dbl((h)->aspect); \
- (h)->fps = le2me_dbl((h)->fps); \
+ (h)->aspect = av_int2dbl(le2me_64((h)->aspect_int)); \
+ (h)->fps = av_int2dbl(le2me_64((h)->fps_int)); \
(h)->videoblocks = le2me_32((h)->videoblocks); \
(h)->audioblocks = le2me_32((h)->audioblocks); \
(h)->textsblocks = le2me_32((h)->textsblocks); \
More information about the MPlayer-dev-eng
mailing list