[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23189] trunk/blender/source/blender/imbuf /intern/anim.c: == FFMPEG ==

Peter Schlaile peter at schlaile.de
Sun Sep 13 19:52:36 CEST 2009


Revision: 23189
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23189
Author:   schlaile
Date:     2009-09-13 19:52:36 +0200 (Sun, 13 Sep 2009)

Log Message:
-----------
== FFMPEG ==

This fixes the underlying problem of the DV crashings - within blender
code. 

Problem was, that we tried to seek on decode errors. (Unintentionally,
curposition wasn't advanced in that case). That triggered a bug within
ffmpeg, that made blender crash. My workaround fix for 2.49 actually only
prevented the crash, but didn't stop ffmpeg from only decoding black frames
after that point...

(The patch also cleans up the color conversion a little bit, by using
PIX_FMT_RGBA (still need to find a way to make it work with video files
that actually *have* an alpha channel. At least, latest FFMPEG-SVN swscaler
has the ability to use alpha.)

Looks like we can remove extern/ffmpeg now...

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/anim.c

Modified: trunk/blender/source/blender/imbuf/intern/anim.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/anim.c	2009-09-13 17:38:43 UTC (rev 23188)
+++ trunk/blender/source/blender/imbuf/intern/anim.c	2009-09-13 17:52:36 UTC (rev 23189)
@@ -608,7 +608,7 @@
 	anim->pFrameDeinterlaced = avcodec_alloc_frame();
 	anim->pFrameRGB = avcodec_alloc_frame();
 
-	if (avpicture_get_size(PIX_FMT_BGR32, anim->x, anim->y)
+	if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y)
 	    != anim->x * anim->y * 4) {
 		fprintf (stderr,
 			 "ffmpeg has changed alloc scheme ... ARGHHH!\n");
@@ -642,7 +642,7 @@
 		anim->pCodecCtx->pix_fmt,
 		anim->pCodecCtx->width,
 		anim->pCodecCtx->height,
-		PIX_FMT_BGR32,
+		PIX_FMT_RGBA,
 		SWS_FAST_BILINEAR | SWS_PRINT_INFO,
 		NULL, NULL, NULL);
 		
@@ -671,11 +671,11 @@
 
 	if (anim == 0) return (0);
 
-	ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect, 0);
+	ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect, 0);
 
 	avpicture_fill((AVPicture*) anim->pFrameRGB, 
 		       (unsigned char*) ibuf->rect, 
-		       PIX_FMT_BGR32, anim->x, anim->y);
+		       PIX_FMT_RGBA, anim->x, anim->y);
 
 	if (position != anim->curposition + 1) { 
 		if (position > anim->curposition + 1 
@@ -748,6 +748,7 @@
 			if (frameFinished && !pos_found) {
 				if (packet.dts >= pts_to_search) {
 					pos_found = 1;
+					anim->curposition = position;
 				}
 			} 
 
@@ -811,21 +812,21 @@
 
 					for (y = 0; y < h; y++) {
 						unsigned char tmp[4];
-						unsigned long * tmp_l =
-							(unsigned long*) tmp;
+						unsigned int * tmp_l =
+							(unsigned int*) tmp;
 						tmp[3] = 0xff;
 
 						for (x = 0; x < w; x++) {
-							tmp[0] = bottom[3];
-							tmp[1] = bottom[2];
-							tmp[2] = bottom[1];
+							tmp[0] = bottom[0];
+							tmp[1] = bottom[1];
+							tmp[2] = bottom[2];
 
-							bottom[0] = top[3];
-							bottom[1] = top[2];
-							bottom[2] = top[1];
+							bottom[0] = top[0];
+							bottom[1] = top[1];
+							bottom[2] = top[2];
 							bottom[3] = 0xff;
 								
-							*(unsigned long*) top
+							*(unsigned int*) top
 								= *tmp_l;
 
 							bottom +=4;
@@ -848,8 +849,7 @@
 						0, 0, 0 };
 					int i;
 					unsigned char* r;
-					
-						
+	
 					sws_scale(anim->img_convert_ctx,
 						  input->data,
 						  input->linesize,
@@ -857,8 +857,8 @@
 						  anim->pCodecCtx->height,
 						  dst2,
 						  dstStride2);
-					
-					/* workaround: sws_scale 
+
+					/* workaround: sws_scale
 					   sets alpha = 0... */
 					
 					r = (unsigned char*) ibuf->rect;
@@ -867,7 +867,7 @@
 						r[3] = 0xff;
 						r+=4;
 					}
-					
+
 					av_free_packet(&packet);
 					break;
 				}





More information about the Bf-blender-cvs mailing list