[Bf-blender-cvs] [9c3e41b] gooseberry: Ultra hacky fix for sequencer:

Antony Riakiotakis noreply at git.blender.org
Fri Jan 30 12:25:35 CET 2015


Commit: 9c3e41b4f66f663ab8cd27b4d2bf3aa297b478c5
Author: Antony Riakiotakis
Date:   Fri Jan 30 12:25:09 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB9c3e41b4f66f663ab8cd27b4d2bf3aa297b478c5

Ultra hacky fix for sequencer:

Avoid opening the file when doing uncached reading because ffmpeg takes
quite a long time to read the first frame. Instead, avi jpeg is almost
instantaneous here.
This will leave the anim struct without an Imbuf and that can cause
other unexpected issues elsewhere so commiting on gooseberry first
to try.
Speedup is quite impressive though.

Needless to say, code here quickly becomes a mess and the proxy system
should be made saner but for now just commit to keep things working at
the studio.

===================================================================

M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/movieclip.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/imbuf/intern/anim_movie.c
M	source/blender/makesrna/intern/rna_sequencer_api.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 5ee8ae2..d9cb4be 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -90,7 +90,7 @@ char    BKE_imtype_from_arg(const char *arg);
 void    BKE_imformat_defaults(struct ImageFormatData *im_format);
 void    BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf);
 
-struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]);
+struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE], bool openfile);
 
 void    BKE_image_de_interlace(struct Image *ima, int odd);
 
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 4404182..50ecc5a 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2108,7 +2108,7 @@ void BKE_image_path_from_imtype(
 }
 
 /* used by sequencer too */
-struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
+struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE], bool openfile)
 {
 	struct anim *anim;
 	struct ImBuf *ibuf;
@@ -2116,6 +2116,9 @@ struct anim *openanim(const char *name, int flags, int streamindex, char colorsp
 	anim = IMB_open_anim(name, flags, streamindex, colorspace);
 	if (anim == NULL) return NULL;
 
+	if (!openfile)
+		return(anim);
+		
 	ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
 	if (ibuf == NULL) {
 		if (BLI_exists(name))
@@ -2604,7 +2607,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
 		BKE_image_user_file_path(iuser, ima, str);
 
 		/* FIXME: make several stream accessible in image editor, too*/
-		ima->anim = openanim(str, IB_rect, 0, ima->colorspace_settings.name);
+		ima->anim = openanim(str, IB_rect, 0, ima->colorspace_settings.name, true);
 
 		/* let's initialize this user */
 		if (ima->anim && iuser && iuser->frames == 0)
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 491fb46..eefc539 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -248,7 +248,7 @@ static void movieclip_open_anim_file(MovieClip *clip)
 		BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id));
 
 		/* FIXME: make several stream accessible in image editor, too */
-		clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name);
+		clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name, true);
 
 		if (clip->anim) {
 			if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) {
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 70a09c2..bbeb895 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -808,7 +808,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
 			if (seq->anim) IMB_free_anim(seq->anim);
 
 			seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
-			                     seq->streamindex, seq->strip->colorspace_settings.name);
+			                     seq->streamindex, seq->strip->colorspace_settings.name, true);
 
 			if (!seq->anim) {
 				return;
@@ -1357,7 +1357,8 @@ static double seq_rendersize_to_scale_factor(int size)
 	return 0.25;
 }
 
-static void seq_open_anim_file(Sequence *seq)
+/* we may just want to generate the anim struct without getting the frame */
+static void seq_open_anim_file(Sequence *seq, bool openfile)
 {
 	char name[FILE_MAX];
 	StripProxy *proxy;
@@ -1371,7 +1372,7 @@ static void seq_open_anim_file(Sequence *seq)
 	BLI_path_abs(name, G.main->name);
 	
 	seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
-	                     seq->streamindex, seq->strip->colorspace_settings.name);
+	                     seq->streamindex, seq->strip->colorspace_settings.name, openfile);
 
 	if (seq->anim == NULL) {
 		return;
@@ -1479,13 +1480,13 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
 			}
 
 			seq->strip->proxy->anim = openanim(name, IB_rect, 0,
-			        seq->strip->colorspace_settings.name);
+			        seq->strip->colorspace_settings.name, true);
 		}
 		if (seq->strip->proxy->anim == NULL) {
 			return NULL;
 		}
  
-		seq_open_anim_file(seq);
+		seq_open_anim_file(seq, true);
 
 		frameno = IMB_anim_index_get_frame_index(seq->anim, seq->strip->proxy->tc, frameno);
 
@@ -1587,7 +1588,7 @@ SeqIndexBuildContext *BKE_sequencer_proxy_rebuild_context(Main *bmain, Scene *sc
 	context->seq = nseq;
 
 	if (nseq->type == SEQ_TYPE_MOVIE) {
-		seq_open_anim_file(nseq);
+		seq_open_anim_file(nseq, true);
 
 		if (nseq->anim) {
 			context->index_context = IMB_anim_index_rebuild_context(nseq->anim,
@@ -2846,7 +2847,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context, Sequence *s
 
 		case SEQ_TYPE_MOVIE:
 		{
-			seq_open_anim_file(seq);
+			seq_open_anim_file(seq, false);
 
 			if (seq->anim) {
 				IMB_Proxy_Size proxy_size = seq_rendersize_to_proxysize(context->preview_render_size);
@@ -4565,7 +4566,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
 	BLI_strncpy(path, seq_load->path, sizeof(path));
 	BLI_path_abs(path, G.main->name);
 
-	an = openanim(path, IB_rect, 0, colorspace);
+	an = openanim(path, IB_rect, 0, colorspace, true);
 
 	if (an == NULL)
 		return NULL;
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index b8f6e66..96026ed 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1314,25 +1314,27 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position,
 
 	filter_y = (anim->ib_flags & IB_animdeinterlace);
 
-	if (anim->curtype == 0) {
-		ibuf = anim_getnew(anim);
-		if (ibuf == NULL) {
-			return(NULL);
+	if (preview_size == IMB_PROXY_NONE) {
+		if (anim->curtype == 0) {
+			ibuf = anim_getnew(anim);
+			if (ibuf == NULL) {
+				return(NULL);
+			}
+			
+			IMB_freeImBuf(ibuf); /* ???? */
+			ibuf = NULL;
 		}
-
-		IMB_freeImBuf(ibuf); /* ???? */
-		ibuf = NULL;
+		
+		if (position < 0) return(NULL);
+		if (position >= anim->duration) return(NULL);
 	}
-
-	if (position < 0) return(NULL);
-	if (position >= anim->duration) return(NULL);
-
-	if (preview_size != IMB_PROXY_NONE) {
+	else {
 		struct anim *proxy = IMB_anim_open_proxy(anim, preview_size);
 
 		if (proxy) {
 			position = IMB_anim_index_get_frame_index(
 			    anim, tc, position);
+
 			return IMB_anim_absolute(
 			           proxy, position,
 			           IMB_TC_NONE, IMB_PROXY_NONE);
diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c
index 3d358b4..2b7e3d1 100644
--- a/source/blender/makesrna/intern/rna_sequencer_api.c
+++ b/source/blender/makesrna/intern/rna_sequencer_api.c
@@ -199,7 +199,7 @@ static Sequence *rna_Sequences_new_movie(ID *id, Editing *ed, ReportList *report
 	Scene *scene = (Scene *)id;
 	Sequence *seq;
 
-	struct anim *an = openanim(file, IB_rect, 0, NULL);
+	struct anim *an = openanim(file, IB_rect, 0, NULL, true);
 
 	if (an == NULL) {
 		BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file");




More information about the Bf-blender-cvs mailing list