[MPlayer-dev-eng] [PATCH] Fix demux_mov on 64-bit platforms
Nico Sabbi
nsabbi at tiscali.it
Mon Oct 11 17:26:20 CEST 2004
Timo Teräs wrote:
>Hi,
>
>I recently reported a but on advusers lists [1], but got no responses. Now I
>managed to get a memory debugger working on my AMD64 boxen so I was able to
>analyze the problem. The demux_mov.c crashed in operations to a
>ImageDescription structure. Then I realized that structure defination is
>complitely broken on 64-bit boxes as sizeof(long) == 8.
>
>Please review and commit attached patch (it is mostly a search/replace of long
>to int with few exceptions on loader/qtx/qtxsdk/components.h). It has also
>minor fix for vd_ffmpeg.
>
>After this fix the .MOVs play ok on my AMD64.
>
>Cheers,
> Timo
>
>[1] http://mplayerhq.hu/pipermail/mplayer-advusers/2004-September/001019.html
>
>
>------------------------------------------------------------------------
>
>? .inslog2
>? amd64-sorenson-fix.diff
>? typescript
>Index: libmpcodecs/vd_ffmpeg.c
>===================================================================
>RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
>retrieving revision 1.135
>diff -u -r1.135 vd_ffmpeg.c
>--- libmpcodecs/vd_ffmpeg.c 27 Sep 2004 10:08:57 -0000 1.135
>+++ libmpcodecs/vd_ffmpeg.c 11 Oct 2004 13:32:56 -0000
>@@ -349,7 +349,7 @@
> sh->format == mmioFOURCC('S','V','Q','3')){
> avctx->extradata_size = *(int*)sh->ImageDesc;
> avctx->extradata = malloc(avctx->extradata_size);
>- memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size);
>+ memcpy(avctx->extradata, ((int*)sh->ImageDesc)+1, avctx->extradata_size-sizeof(int));
> }
>
> if(sh->bih)
>Index: loader/qtx/qtxsdk/components.h
>===================================================================
>RCS file: /cvsroot/mplayer/main/loader/qtx/qtxsdk/components.h,v
>retrieving revision 1.9
>diff -u -r1.9 components.h
>--- loader/qtx/qtxsdk/components.h 8 Nov 2003 00:26:51 -0000 1.9
>+++ loader/qtx/qtxsdk/components.h 11 Oct 2004 13:32:56 -0000
>@@ -2,23 +2,23 @@
>
> typedef char * Ptr;
> typedef Ptr * Handle;
>-typedef long Size;
>+typedef int Size;
> typedef unsigned char Boolean;
> typedef unsigned char Str31[32];
>-typedef long Fixed;
>+typedef int Fixed;
>
>-typedef long OSErr;
>+typedef int OSErr;
> typedef int OSType;
>
>-typedef long ComponentResult;
>+typedef int ComponentResult;
> typedef unsigned char UInt8;
> typedef signed char SInt8;
> typedef unsigned short UInt16;
> typedef signed short SInt16;
>-typedef unsigned long UInt32;
>-typedef signed long SInt32;
>+typedef unsigned int UInt32;
>+typedef signed int SInt32;
>
>-#define FOUR_CHAR_CODE(a,b,c,d) ((unsigned long)(a)<<24 | (unsigned long)(b)<<16 | (unsigned long)(c)<<8 | (unsigned long)(d)) /* otherwise compiler will complain about values with high bit set */
>+#define FOUR_CHAR_CODE(a,b,c,d) ((unsigned int)(a)<<24 | (unsigned int)(b)<<16 | (unsigned int)(c)<<8 | (unsigned int)(d)) /* otherwise compiler will complain about values with high bit set */
>
> // codec private shit:
> typedef void *GlobalsPtr;
>@@ -30,7 +30,7 @@
> UInt8 flags; /* call modifiers: sync/async, deferred, immed, etc */
> UInt8 paramSize; /* size in bytes of actual parameters passed to this call */
> short what; /* routine selector, negative for Component management calls */
>- long params[1]; /* actual parameters for the indicated routine */
>+ int params[1]; /* actual parameters for the indicated routine */
> };
> typedef struct ComponentParameters ComponentParameters;
>
>@@ -39,8 +39,8 @@
> OSType componentType; /* A unique 4-byte code indentifying the command set */
> OSType componentSubType; /* Particular flavor of this instance */
> OSType componentManufacturer; /* Vendor indentification */
>- unsigned long componentFlags; /* 8 each for Component,Type,SubType,Manuf/revision */
>- unsigned long componentFlagsMask; /* Mask for specifying which flags to consider in search, zero during registration */
>+ unsigned int componentFlags; /* 8 each for Component,Type,SubType,Manuf/revision */
>+ unsigned int componentFlagsMask; /* Mask for specifying which flags to consider in search, zero during registration */
> };
> typedef struct ComponentDescription ComponentDescription;
>
>@@ -65,14 +65,14 @@
>
>
> struct __attribute__((__packed__)) ComponentRecord {
>- long data[1];
>+ int data[1];
> };
> typedef struct ComponentRecord ComponentRecord;
> typedef ComponentRecord * Component;
>
>
> struct __attribute__((__packed__)) ComponentInstanceRecord {
>- long data[1];
>+ int data[1];
> };
> typedef struct ComponentInstanceRecord ComponentInstanceRecord;
>
>@@ -107,7 +107,7 @@
> typedef ColorSpec CSpecArray[1];
>
> struct __attribute__((__packed__)) ColorTable {
>- long ctSeed; /*unique identifier for table*/
>+ int ctSeed; /*unique identifier for table*/
> short ctFlags; /*high bit: 0 = PixMap; 1 = device*/
> short ctSize; /*number of entries in CTTable*/
> CSpecArray ctTable; /*array [0..0] of ColorSpec*/
>@@ -122,27 +122,27 @@
> typedef struct MatrixRecord MatrixRecord;
> typedef MatrixRecord * MatrixRecordPtr;
>
>-typedef long ImageSequence;
>+typedef int ImageSequence;
> typedef OSType CodecType;
> typedef unsigned short CodecFlags;
>-typedef unsigned long CodecQ;
>+typedef unsigned int CodecQ;
>
> struct __attribute__((__packed__)) ImageDescription {
>- long idSize; /* total size of ImageDescription including extra data ( CLUTs and other per sequence data ) */
>+ int idSize; /* total size of ImageDescription including extra data ( CLUTs and other per sequence data ) */
> CodecType cType; /* what kind of codec compressed this data */
>- long resvd1; /* reserved for Apple use */
>+ int resvd1; /* reserved for Apple use */
> short resvd2; /* reserved for Apple use */
> short dataRefIndex; /* set to zero */
> short version; /* which version is this data */
> short revisionLevel; /* what version of that codec did this */
>- long vendor; /* whose codec compressed this data */
>+ int vendor; /* whose codec compressed this data */
> CodecQ temporalQuality; /* what was the temporal quality factor */
> CodecQ spatialQuality; /* what was the spatial quality factor */
> short width; /* how many pixels wide is this data */
> short height; /* how many pixels high is this data */
> Fixed hRes; /* horizontal resolution */
> Fixed vRes; /* vertical resolution */
>- long dataSize; /* if known, the size of data for this image descriptor */
>+ int dataSize; /* if known, the size of data for this image descriptor */
> short frameCount; /* number of frames this description applies to */
> Str31 name; /* name of codec ( in case not installed ) */
> short depth; /* what depth is this data (1-32) or ( 33-40 grayscale ) */
>@@ -173,15 +173,15 @@
> };
>
> struct __attribute__((__packed__)) PixMapExtension {
>- long extSize; /*size of struct, duh!*/
>- unsigned long pmBits; /*pixmap attributes bitfield*/
>+ int extSize; /*size of struct, duh!*/
>+ unsigned int pmBits; /*pixmap attributes bitfield*/
> void * pmGD; /*this is a GDHandle*/
>- long pmSeed;
>+ int pmSeed;
> Fixed gammaLevel; /*pixmap gammalevel*/
> Fixed requestedGammaLevel;
>- unsigned long reserved2;
>- long longRowBytes; /*used when rowBytes > 16382*/
>- unsigned long signature;
>+ unsigned int reserved2;
>+ int intRowBytes; /*used when rowBytes > 16382*/
>+ unsigned int signature;
> Handle baseAddrHandle;
> };
> typedef struct PixMapExtension PixMapExtension;
>@@ -196,7 +196,7 @@
> Rect bounds; /*encloses bitmap*/
> short pmVersion; /*pixMap version number*/
> short packType; /*defines packing format*/
>- long packSize; /*length of pixel data*/
>+ int packSize; /*length of pixel data*/
> Fixed hRes; /*horiz. resolution (ppi)*/
> Fixed vRes; /*vert. resolution (ppi)*/
> short pixelType; /*defines pixel type*/
>@@ -252,8 +252,8 @@
> short txMode;
> short txSize;
> Fixed spExtra;
>- long fgColor;
>- long bkColor;
>+ int fgColor;
>+ int bkColor;
> short colrBit;
> short patStretch;
> Handle picSave;
>@@ -298,7 +298,7 @@
> transparent = 36
> };
>
>-typedef unsigned long GWorldFlags;
>+typedef unsigned int GWorldFlags;
>
>
>
>@@ -405,15 +405,15 @@
>
>
> struct __attribute__((__packed__)) CodecCapabilities {
>- long flags;
>+ int flags;
> short wantedPixelSize;
> short extendWidth;
> short extendHeight;
> short bandMin;
> short bandInc;
> short pad;
>- unsigned long time;
>- long flags2; /* field new in QuickTime 4.0 */
>+ unsigned int time;
>+ int flags2; /* field new in QuickTime 4.0 */
> };
> typedef struct CodecCapabilities CodecCapabilities;
>
>@@ -421,12 +421,12 @@
> ImageSequence sequenceID; /* predecompress,banddecompress */
> ImageDescriptionHandle imageDescription; /* predecompress,banddecompress */
> Ptr data;
>- long bufferSize;
>+ int bufferSize;
>
>- long frameNumber;
>- long startLine;
>- long stopLine;
>- long conditionFlags;
>+ int frameNumber;
>+ int startLine;
>+ int stopLine;
>+ int conditionFlags;
>
> CodecFlags callerFlags; // short
> CodecCapabilities * capabilities; /* predecompress,banddecompress */
>@@ -443,7 +443,7 @@
> CodecQ accuracy; /* predecompress,banddecompress */
> short transferMode; /* predecompress,banddecompress */
> ICMFrameTimePtr frameTime; /* banddecompress */
>- long reserved[1];
>+ int reserved[1];
>
> /* The following fields only exist for QuickTime 2.0 and greater */
> SInt8 matrixFlags; /* high bit set if 2x resize */
>@@ -460,8 +460,8 @@
> /* The following fields only exist for QuickTime 2.5 and greater */
> OSType ** wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
>
>- long screenFloodMethod;
>- long screenFloodValue;
>+ int screenFloodMethod;
>+ int screenFloodValue;
> short preferredOffscreenPixelSize;
>
> /* The following fields only exist for QuickTime 3.0 and greater */
>@@ -471,12 +471,12 @@
> Boolean needUpdateOnSourceChange; /* band decompress */
> Boolean pad;
>
>- long unused;
>+ int unused;
>
> CGrafPtr finalDestinationPort;
>
>- long requestedBufferWidth; /* must set codecWantsSpecialScaling to indicate this field is valid*/
>- long requestedBufferHeight; /* must set codecWantsSpecialScaling to indicate this field is valid*/
>+ int requestedBufferWidth; /* must set codecWantsSpecialScaling to indicate this field is valid*/
>+ int requestedBufferHeight; /* must set codecWantsSpecialScaling to indicate this field is valid*/
>
> /* The following fields only exist for QuickTime 4.0 and greater */
> Rect displayableAreaOfRequestedBuffer; /* set in predecompress*/
>@@ -494,8 +494,8 @@
>
>
> struct __attribute__((__packed__)) ImageSubCodecDecompressCapabilities {
>- long recordSize; /* sizeof(ImageSubCodecDecompressCapabilities)*/
>- long decompressRecordSize; /* size of your codec's decompress record*/
>+ int recordSize; /* sizeof(ImageSubCodecDecompressCapabilities)*/
>+ int decompressRecordSize; /* size of your codec's decompress record*/
> Boolean canAsync; /* default true*/
> UInt8 pad0;
>
>@@ -517,7 +517,7 @@
>
> struct __attribute__((__packed__)) ImageSubCodecDecompressRecord {
> Ptr baseAddr;
>- long rowBytes;
>+ int rowBytes;
> Ptr codecData;
> ICMProgressProcRecord progressProcRecord;
> ICMDataProcRecord dataProcRecord;
>@@ -525,7 +525,7 @@
> UInt8 frameType;
> Boolean inhibitMP; /* set this in BeginBand to tell the base decompressor not to call DrawBand from an MP task for this frame. (Only has any effect for MP-capable subcodecs. New in QuickTime 5.0.)*/
> UInt8 pad[2];
>- long priv[2];
>+ int priv[2];
>
> /* The following fields only exist for QuickTime 5.0 and greater */
> ImageCodecDrawBandCompleteUPP drawBandCompleteUPP; /* only used if subcodec set subCodecCallsDrawBandComplete; if drawBandCompleteUPP is non-nil, codec must call it when a frame is finished, but may return from DrawBand before the frame is finished. */
>@@ -584,10 +584,10 @@
> Str31 typeName; /* name of the codec type i.e.: 'Apple Image Compression' */
> short version; /* version of the codec data that this codec knows about */
> short revisionLevel; /* revision level of this codec i.e: 0x00010001 (1.0.1) */
>- long vendor; /* Maker of this codec i.e: 'appl' */
>- long decompressFlags; /* codecInfo flags for decompression capabilities */
>- long compressFlags; /* codecInfo flags for compression capabilities */
>- long formatFlags; /* codecInfo flags for compression format details */
>+ int vendor; /* Maker of this codec i.e: 'appl' */
>+ int decompressFlags; /* codecInfo flags for decompression capabilities */
>+ int compressFlags; /* codecInfo flags for compression capabilities */
>+ int formatFlags; /* codecInfo flags for compression format details */
> UInt8 compressionAccuracy; /* measure (1-255) of accuracy of this codec for compress (0 if unknown) */
> UInt8 decompressionAccuracy; /* measure (1-255) of accuracy of this codec for decompress (0 if unknown) */
> unsigned short compressionSpeed; /* ( millisecs for compressing 320x240 on base mac II) (0 if unknown) */
>@@ -598,7 +598,7 @@
> short minimumWidth; /* minimum width of image (block size) */
> short decompressPipelineLatency; /* in milliseconds ( for asynchronous codecs ) */
> short compressPipelineLatency; /* in milliseconds ( for asynchronous codecs ) */
>- long privateData;
>+ int privateData;
> };
> typedef struct CodecInfo CodecInfo;
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>MPlayer-dev-eng mailing list
>MPlayer-dev-eng at mplayerhq.hu
>http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>
>
why don't you use [u]int32 and [u]int64 instead?
More information about the MPlayer-dev-eng
mailing list