[MPlayer-dev-eng] [PATCH] some muxer_lavf mess cleanup

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jan 5 11:31:33 CET 2007


Hello,
attached patch does:
1) include the proper header (riff.h) instead of adding our own function
prototypes for all those functions
2) add missing prototype for codec_get_id and CodecTag typedef
3) remove useless extern for function prototypes
4) mp_wav_tags is of type CodecTag[] not int[]!!! Lazyness is not an
excuse for that kind of hacks
5) sizeof() is of type long, thus %d is the wrong printf format. Though
I suggest fixing by setting first ctx->extradata_size, thus also
avoiding some code duplication.

Not tested with .so libavformat.
I will apply soon anyway, the fix for issue 5) would be applied separately of
course.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/muxer_lavf.c
===================================================================
--- libmpdemux/muxer_lavf.c	(revision 21822)
+++ libmpdemux/muxer_lavf.c	(working copy)
@@ -19,14 +19,21 @@
 #include "m_option.h"
 #ifdef USE_LIBAVFORMAT_SO
 #include <ffmpeg/avformat.h>
+typedef struct CodecTag {
+    int id;
+    unsigned int tag;
+    unsigned int invalid_asf : 1;
+} CodecTag;
+unsigned int codec_get_wav_tag(int id);
+enum CodecID codec_get_bmp_id(unsigned int tag);
+enum CodecID codec_get_wav_id(unsigned int tag);
+enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag);
 #else
 #include "avformat.h"
+#include "libavformat/riff.h"
 #endif
 
-extern unsigned int codec_get_wav_tag(int id);
-extern enum CodecID codec_get_bmp_id(unsigned int tag);
-extern enum CodecID codec_get_wav_id(unsigned int tag);
-extern const int mp_wav_tags[];
+extern const CodecTag mp_wav_tags[];
 
 extern char *info_name;
 extern char *info_artist;
@@ -251,15 +258,16 @@
 		ctx->time_base.num = stream->h.dwScale;
 		if(stream->bih+1 && (stream->bih->biSize > sizeof(BITMAPINFOHEADER)))
 		{
-			ctx->extradata = av_malloc(stream->bih->biSize - sizeof(BITMAPINFOHEADER));
+			ctx->extradata_size = stream->bih->biSize - sizeof(BITMAPINFOHEADER);
+			ctx->extradata = av_malloc(ctx->extradata_size);
 			if(ctx->extradata != NULL)
-			{
-				ctx->extradata_size = stream->bih->biSize - sizeof(BITMAPINFOHEADER);
 				memcpy(ctx->extradata, stream->bih+1, ctx->extradata_size);
-			}
 			else
+			{
 				mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(video stream) error! couldn't allocate %d bytes for extradata\n",
-					stream->bih->biSize - sizeof(BITMAPINFOHEADER));
+					ctx->extradata_size);
+				ctx->extradata_size = 0;
+			}
 		}
 	}
 }


More information about the MPlayer-dev-eng mailing list