[Bf-blender-cvs] [55d7595] multiview: Movie Writing: changes to encapsulate the elements (as oppose to have everything static)

Dalai Felinto noreply at git.blender.org
Fri Jan 16 22:29:28 CET 2015


Commit: 55d75953ce05bb13e5669b9d5096a97917ddee03
Author: Dalai Felinto
Date:   Fri Jan 16 15:40:22 2015 -0200
Branches: multiview
https://developer.blender.org/rB55d75953ce05bb13e5669b9d5096a97917ddee03

Movie Writing: changes to encapsulate the elements (as oppose to have
everything static)

You can now export individual streams of videos (e.g., Movie_L.mov,
Movie_R.mov) safely! =)

Before that not only were the names clashing (as I initially thought)
but in fact the whole video streaming was mixed up (when you had to
export more than one video simultaneously).

The way to solve this is to *stop* using static elements and to create a
context to store the current movie data.

This commits involves a lot of changes, but I believe things are working
well. In fact the way I was handling MovieHandler was wrong (creating
arrays and all that), so I'm really glad I got to this.

Note: I couldn't test Frameserver, in fact test with the general codecs
(using multiview or not) are appreciated.

Thanks for Sergey Sharybin for the suggestions that lead to this
solution.

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

M	source/blender/blenkernel/BKE_writeavi.h
M	source/blender/blenkernel/BKE_writeffmpeg.h
M	source/blender/blenkernel/BKE_writeframeserver.h
M	source/blender/blenkernel/intern/writeavi.c
M	source/blender/blenkernel/intern/writeffmpeg.c
M	source/blender/blenkernel/intern/writeframeserver.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/screen/screendump.c
M	source/blender/quicktime/apple/qtkit_export.m
M	source/blender/quicktime/quicktime_export.h
M	source/blender/render/extern/include/RE_pipeline.h
M	source/blender/render/intern/include/render_types.h
M	source/blender/render/intern/source/pipeline.c

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

diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h
index 4a1de0f..680506a 100644
--- a/source/blender/blenkernel/BKE_writeavi.h
+++ b/source/blender/blenkernel/BKE_writeavi.h
@@ -43,16 +43,19 @@ struct ReportList;
 struct Scene;
 
 typedef struct bMovieHandle {
-	int (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty, const char *suffix, struct ReportList *reports);
-	int (*append_movie)(struct RenderData *rd, int start_frame, int frame, int *pixels,
+	int (*start_movie)(void *context_v, struct Scene *scene, struct RenderData *rd, int rectx, int recty, const char *suffix, struct ReportList *reports);
+	int (*append_movie)(void *context_v, struct RenderData *rd, int start_frame, int frame, int *pixels,
 	                    int rectx, int recty, const char *suffix, struct ReportList *reports);
-	void (*end_movie)(void);
-	int (*get_next_frame)(struct RenderData *rd, struct ReportList *reports); /* optional */
+	void (*end_movie)(void *context_v);
+	int (*get_next_frame)(void *context_v, struct RenderData *rd, struct ReportList *reports); /* optional */
 	void (*get_movie_path)(char *string, struct RenderData *rd, const char *suffix); /* optional */
+	void *(*context_create)(void);
+	void (*context_free)(void *context_v);
 } bMovieHandle;
 
 bMovieHandle *BKE_movie_handle_get(const char imtype);
 void BKE_movie_filepath_get(char *string, struct RenderData *rd, const char *suffix);
+void BKE_context_create(bMovieHandle *mh);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h
index 2052c87..4f4d5de 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -69,9 +69,9 @@ struct RenderData;
 struct ReportList;
 struct Scene;
 
-int BKE_ffmpeg_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, const char *suffix, struct ReportList *reports);
-void BKE_ffmpeg_end(void);
-int BKE_ffmpeg_append(struct RenderData *rd, int start_frame, int frame, int *pixels,
+int BKE_ffmpeg_start(void *context_v, struct Scene *scene, struct RenderData *rd, int rectx, int recty, const char *suffix, struct ReportList *reports);
+void BKE_ffmpeg_end(void *context_v);
+int BKE_ffmpeg_append(void *context_v, struct RenderData *rd, int start_frame, int frame, int *pixels,
                       int rectx, int recty, const char *suffix, struct ReportList *reports);
 void BKE_ffmpeg_filepath_get(char *string, struct RenderData *rd, const char *suffix);
 
@@ -83,6 +83,9 @@ bool BKE_ffmpeg_alpha_channel_is_supported(struct RenderData *rd);
 int BKE_ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str);
 void BKE_ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_);
 
+void *BKE_ffmpeg_context_create(void);
+void BKE_ffmpeg_context_free(void *context_v);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h
index bdce9ab..ecca697 100644
--- a/source/blender/blenkernel/BKE_writeframeserver.h
+++ b/source/blender/blenkernel/BKE_writeframeserver.h
@@ -40,11 +40,13 @@ struct RenderData;
 struct ReportList;
 struct Scene;
 
-int BKE_frameserver_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports);
-void BKE_frameserver_end(void);
-int BKE_frameserver_append(struct RenderData *rd, int start_frame, int frame, int *pixels,
-                           int rectx, int recty, struct ReportList *reports);
-int BKE_frameserver_loop(struct RenderData *rd, struct ReportList *reports);
+int BKE_frameserver_start(void *context_v, struct Scene *scene, struct RenderData *rd, int rectx, int recty, const char *suffix, struct ReportList *reports);
+void BKE_frameserver_end(void *context_v);
+int BKE_frameserver_append(void *context_v, struct RenderData *rd, int start_frame, int frame, int *pixels,
+                           int rectx, int recty, const char*suffix, struct ReportList *reports);
+int BKE_frameserver_loop(void *context_v, struct RenderData *rd, struct ReportList *reports);
+void *BKE_frameserver_context_create(void);
+void BKE_frameserver_context_free(void *context_v);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index bf65b79..eef0faf 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -50,26 +50,34 @@
 
 /* ********************** general blender movie support ***************************** */
 
-static int start_stub(Scene *UNUSED(scene), RenderData *UNUSED(rd), int UNUSED(rectx), int UNUSED(recty),
-                      ReportList *UNUSED(reports))
+static int start_stub(void *UNUSED(context_v), Scene *UNUSED(scene), RenderData *UNUSED(rd), int UNUSED(rectx), int UNUSED(recty),
+                      const char *UNUSED(suffix), ReportList *UNUSED(reports))
 { return 0; }
 
-static void end_stub(void)
+static void end_stub(void *UNUSED(context_v))
 {}
 
-static int append_stub(RenderData *UNUSED(rd), int UNUSED(start_frame), int UNUSED(frame), int *UNUSED(pixels),
-                       int UNUSED(rectx), int UNUSED(recty), ReportList *UNUSED(reports))
+static int append_stub(void *UNUSED(context_v), RenderData *UNUSED(rd), int UNUSED(start_frame), int UNUSED(frame), int *UNUSED(pixels),
+                       int UNUSED(rectx), int UNUSED(recty), const char *UNUSED(suffix), ReportList *UNUSED(reports))
 { return 0; }
 
+static void *context_create_stub(void)
+{ return NULL; }
+
+static void context_free_stub(void *UNUSED(context_v))
+{}
+
 #ifdef WITH_AVI
 #  include "AVI_avi.h"
 
 /* callbacks */
-static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, const char *suffix, ReportList *reports);
-static void end_avi(void);
-static int append_avi(RenderData *rd, int start_frame, int frame, int *pixels,
+static int start_avi(void *context_v, Scene *scene, RenderData *rd, int rectx, int recty, const char *suffix, ReportList *reports);
+static void end_avi(void *context_v);
+static int append_avi(void *context_v, RenderData *rd, int start_frame, int frame, int *pixels,
                       int rectx, int recty, const char *suffix, ReportList *reports);
 static void filepath_avi(char *string, RenderData *rd, const char *suffix);
+static void *context_create_avi(void);
+static void context_free_avi(void *context_v);
 #endif  /* WITH_AVI */
 
 #ifdef WITH_QUICKTIME
@@ -93,13 +101,17 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
 	mh.end_movie = end_stub;
 	mh.get_next_frame = NULL;
 	mh.get_movie_path = NULL;
-	
+	mh.context_create = context_create_stub;
+	mh.context_free = context_free_stub;
+
 	/* set the default handle, as builtin */
 #ifdef WITH_AVI
 	mh.start_movie = start_avi;
 	mh.append_movie = append_avi;
 	mh.end_movie = end_avi;
 	mh.get_movie_path = filepath_avi;
+	mh.context_create = context_create_avi;
+	mh.context_free = context_free_avi;
 #endif
 
 	/* do the platform specific handles */
@@ -109,6 +121,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
 		mh.append_movie = append_qt;
 		mh.end_movie = end_qt;
 		mh.get_movie_path = filepath_qt;
+		mh.context_create = context_create_qt;
+		mh.context_free = context_free_qt;
 	}
 #endif
 #ifdef WITH_FFMPEG
@@ -117,6 +131,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
 		mh.append_movie = BKE_ffmpeg_append;
 		mh.end_movie = BKE_ffmpeg_end;
 		mh.get_movie_path = BKE_ffmpeg_filepath_get;
+		mh.context_create = BKE_ffmpeg_context_create;
+		mh.context_free = BKE_ffmpeg_context_free;
 	}
 #endif
 #ifdef WITH_FRAMESERVER
@@ -125,6 +141,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
 		mh.append_movie = BKE_frameserver_append;
 		mh.end_movie = BKE_frameserver_end;
 		mh.get_next_frame = BKE_frameserver_loop;
+		mh.context_create = BKE_frameserver_context_create;
+		mh.context_free = BKE_frameserver_context_free;
 	}
 #endif
 
@@ -139,8 +157,6 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
 
 #ifdef WITH_AVI
 
-static AviMovie *avi = NULL;
-
 static void filepath_avi(char *string, RenderData *rd, const char *suffix)
 {
 	if (string == NULL) return;
@@ -165,7 +181,7 @@ static void filepath_avi(char *string, RenderData *rd, const char *suffix)
 	BLI_path_view(string, suffix);
 }
 
-static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, const char *suffix, ReportList *reports)
+static int start_avi(void *context_v, Scene *scene, RenderData *rd, int rectx, int recty, const char *suffix, ReportList *reports)
 {
 	int x, y;
 	char name[256];
@@ -174,6 +190,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, const c
 	double framerate;
 	
 	(void)scene; /* unused */
+	AviMovie *avi = context_v;
 	
 	filepath_avi(name, rd, suffix);
 
@@ -182,8 +199,6 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, const c
 
 	quality = rd->im_format.quality;
 	framerate = (double) rd->frs_sec / (double) rd->frs_sec_base;
-	
-	avi = MEM_mallocN(sizeof(AviMovie), "avimovie");
 
 	if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) format = AVI_FORMAT_AVI_RGB;
 	else format = AVI_FORMAT_MJPEG;
@@ -209,12 +224,13 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, const c
 	return 1;
 }
 
-static int append_avi(RenderData *UNUSED(rd), int start_frame, int frame, int *pixels,
+static int append_avi(void *context_v, RenderData *UNUSED(rd), int start_frame, int frame, int *pixels,
                       int rectx, int recty, const char *UNUSED(suffix), ReportList *UNUSED(reports))
 {
 	unsigned int *rt1, *rt2, *rectot;
 	int x, y;
 	char *cp, rt;
+	AviMovie *avi = context_v;
 	
 	if (avi == NULL)
 		return 0;
@@ -245,14 +261,29 @@ static int append_avi(RenderData *UNUSED(rd), int start_frame, int frame, int *p
 	return 1;
 }
 
-static void end_avi(void)
+static void end_avi(void *context_v)
 {
+	AviMovie *avi = context_v;
+
 	if (avi == NULL) return;
 
 	AVI_close_compress(avi);
-	MEM_freeN(avi);
-	avi = NULL;
 }
+
+static void *context_create_avi()
+{
+	AviMovie 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list