changeset 21810:7a36d3332133

sizeof() is long, thus %d format in error message is wrong. Fix by assigning extradata_size before and printing that, since this also removes a bit of code duplication.
author reimar
date Fri, 05 Jan 2007 15:41:00 +0000
parents 2c473e083c70
children ff1d5576063f
files libmpdemux/muxer_lavf.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/muxer_lavf.c	Fri Jan 05 15:24:38 2007 +0000
+++ b/libmpdemux/muxer_lavf.c	Fri Jan 05 15:41:00 2007 +0000
@@ -251,15 +251,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",
+					ctx->extradata_size);
+				ctx->extradata_size = 0;
 			}
-			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));
 		}
 	}
 }