2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
2011-10-10 09:38:02 +00:00
|
|
|
* Functions for writing avi-format files.
|
|
|
|
* Added interface for generic movie support (ton)
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
#include "BKE_report.h"
|
2019-01-26 20:41:52 +11:00
|
|
|
#ifdef WITH_AVI
|
|
|
|
# include "BLI_blenlib.h"
|
|
|
|
|
|
|
|
# include "BKE_main.h"
|
|
|
|
#endif
|
2011-01-07 19:18:31 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#include "BKE_writeavi.h"
|
2012-10-08 02:51:42 +00:00
|
|
|
|
|
|
|
/* ********************** general blender movie support ***************************** */
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static int start_stub(void *UNUSED(context_v),
|
|
|
|
Scene *UNUSED(scene),
|
|
|
|
RenderData *UNUSED(rd),
|
|
|
|
int UNUSED(rectx),
|
|
|
|
int UNUSED(recty),
|
|
|
|
ReportList *UNUSED(reports),
|
|
|
|
bool UNUSED(preview),
|
|
|
|
const char *UNUSED(suffix))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-01-07 14:51:59 +01:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void end_stub(void *UNUSED(context_v))
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
}
|
2014-01-07 14:51:59 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
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;
|
|
|
|
}
|
2014-01-07 14:51:59 +01:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void *context_create_stub(void)
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
static void context_free_stub(void *UNUSED(context_v))
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2012-10-08 02:51:42 +00:00
|
|
|
#ifdef WITH_AVI
|
|
|
|
# include "AVI_avi.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-01-08 13:52:38 +00:00
|
|
|
/* callbacks */
|
2019-04-17 06:17:24 +02:00
|
|
|
static int start_avi(void *context_v,
|
|
|
|
Scene *scene,
|
|
|
|
RenderData *rd,
|
|
|
|
int rectx,
|
|
|
|
int recty,
|
|
|
|
ReportList *reports,
|
|
|
|
bool preview,
|
|
|
|
const char *suffix);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void end_avi(void *context_v);
|
2019-04-17 06:17:24 +02:00
|
|
|
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);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void filepath_avi(char *string, RenderData *rd, bool preview, const char *suffix);
|
|
|
|
static void *context_create_avi(void);
|
|
|
|
static void context_free_avi(void *context_v);
|
2019-04-17 06:17:24 +02:00
|
|
|
#endif /* WITH_AVI */
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2006-02-05 19:12:25 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
2012-10-08 02:51:42 +00:00
|
|
|
# include "BKE_writeffmpeg.h"
|
2006-02-05 19:12:25 +00:00
|
|
|
#endif
|
|
|
|
|
2012-05-07 09:30:15 +00:00
|
|
|
bMovieHandle *BKE_movie_handle_get(const char imtype)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
static bMovieHandle mh = {NULL};
|
|
|
|
/* stub callbacks in case none of the movie formats is supported */
|
|
|
|
mh.start_movie = start_stub;
|
|
|
|
mh.append_movie = append_stub;
|
|
|
|
mh.end_movie = end_stub;
|
|
|
|
mh.get_movie_path = NULL;
|
|
|
|
mh.context_create = context_create_stub;
|
|
|
|
mh.context_free = context_free_stub;
|
|
|
|
|
|
|
|
/* set the default handle, as builtin */
|
2012-10-08 02:51:42 +00:00
|
|
|
#ifdef WITH_AVI
|
2019-04-17 06:17:24 +02:00
|
|
|
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;
|
2012-10-08 02:51:42 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* do the platform specific handles */
|
2006-02-05 19:12:25 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ELEM(imtype,
|
|
|
|
R_IMF_IMTYPE_FFMPEG,
|
|
|
|
R_IMF_IMTYPE_H264,
|
|
|
|
R_IMF_IMTYPE_XVID,
|
|
|
|
R_IMF_IMTYPE_THEORA)) {
|
|
|
|
mh.start_movie = BKE_ffmpeg_start;
|
|
|
|
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;
|
|
|
|
}
|
2006-02-05 19:12:25 +00:00
|
|
|
#endif
|
2011-07-22 00:34:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* in case all above are disabled */
|
|
|
|
(void)imtype;
|
2015-09-23 02:40:08 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (mh.append_movie != append_stub) ? &mh : NULL;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************************************************************** */
|
2002-11-22 15:59:38 +00:00
|
|
|
|
2012-10-08 02:51:42 +00:00
|
|
|
#ifdef WITH_AVI
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void filepath_avi(char *string, RenderData *rd, bool preview, const char *suffix)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int sfra, efra;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (string == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
if (preview) {
|
|
|
|
sfra = rd->psfra;
|
|
|
|
efra = rd->pefra;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sfra = rd->sfra;
|
|
|
|
efra = rd->efra;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(string, rd->pic);
|
|
|
|
BLI_path_abs(string, BKE_main_blendfile_path_from_global());
|
|
|
|
|
|
|
|
BLI_make_existing_file(string);
|
|
|
|
|
|
|
|
if (rd->scemode & R_EXTENSION) {
|
|
|
|
if (!BLI_path_extension_check(string, ".avi")) {
|
|
|
|
BLI_path_frame_range(string, sfra, efra, 4);
|
|
|
|
strcat(string, ".avi");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (BLI_path_frame_check_chars(string)) {
|
|
|
|
BLI_path_frame_range(string, sfra, efra, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_path_suffix(string, FILE_MAX, suffix, "");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static int start_avi(void *context_v,
|
|
|
|
Scene *UNUSED(scene),
|
|
|
|
RenderData *rd,
|
|
|
|
int rectx,
|
|
|
|
int recty,
|
|
|
|
ReportList *reports,
|
|
|
|
bool preview,
|
|
|
|
const char *suffix)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int x, y;
|
|
|
|
char name[256];
|
|
|
|
AviFormat format;
|
|
|
|
int quality;
|
|
|
|
double framerate;
|
|
|
|
AviMovie *avi = context_v;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
filepath_avi(name, rd, preview, suffix);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
x = rectx;
|
|
|
|
y = recty;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
quality = rd->im_format.quality;
|
|
|
|
framerate = (double)rd->frs_sec / (double)rd->frs_sec_base;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) {
|
2019-04-17 06:17:24 +02:00
|
|
|
format = AVI_FORMAT_AVI_RGB;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
format = AVI_FORMAT_MJPEG;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
|
|
|
|
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
|
|
|
|
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
|
|
|
|
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);
|
2012-05-12 16:11:34 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
avi->interlace = 0;
|
|
|
|
avi->odd_fields = 0;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("Created avi: %s\n", name);
|
|
|
|
return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
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))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
unsigned int *rt1, *rt2, *rectot;
|
|
|
|
int x, y;
|
|
|
|
char *cp, rt;
|
|
|
|
AviMovie *avi = context_v;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (avi == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* note that libavi free's the buffer... stupid interface - zr */
|
|
|
|
rectot = MEM_mallocN(rectx * recty * sizeof(int), "rectot");
|
|
|
|
rt1 = rectot;
|
|
|
|
rt2 = (unsigned int *)pixels + (recty - 1) * rectx;
|
|
|
|
/* flip y and convert to abgr */
|
|
|
|
for (y = 0; y < recty; y++, rt1 += rectx, rt2 -= rectx) {
|
|
|
|
memcpy(rt1, rt2, rectx * sizeof(int));
|
|
|
|
|
|
|
|
cp = (char *)rt1;
|
|
|
|
for (x = rectx; x > 0; x--) {
|
|
|
|
rt = cp[0];
|
|
|
|
cp[0] = cp[3];
|
|
|
|
cp[3] = rt;
|
|
|
|
rt = cp[1];
|
|
|
|
cp[1] = cp[2];
|
|
|
|
cp[2] = rt;
|
|
|
|
cp += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AVI_write_frame(avi, (frame - start_frame), AVI_FORMAT_RGB32, rectot, rectx * recty * 4);
|
|
|
|
// printf("added frame %3d (frame %3d in avi): ", frame, frame-start_frame);
|
|
|
|
|
|
|
|
return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void end_avi(void *context_v)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
AviMovie *avi = context_v;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (avi == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
AVI_close_compress(avi);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
static void *context_create_avi(void)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
AviMovie *avi = MEM_mallocN(sizeof(AviMovie), "avimovie");
|
|
|
|
return avi;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void context_free_avi(void *context_v)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
AviMovie *avi = context_v;
|
|
|
|
if (avi) {
|
|
|
|
MEM_freeN(avi);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
#endif /* WITH_AVI */
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2015-01-24 16:48:23 +11:00
|
|
|
/* similar to BKE_image_path_from_imformat() */
|
2015-04-06 10:40:12 -03:00
|
|
|
void BKE_movie_filepath_get(char *string, RenderData *rd, bool preview, const char *suffix)
|
2010-01-08 13:52:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bMovieHandle *mh = BKE_movie_handle_get(rd->im_format.imtype);
|
|
|
|
if (mh && mh->get_movie_path) {
|
|
|
|
mh->get_movie_path(string, rd, preview, suffix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
string[0] = '\0';
|
|
|
|
}
|
2010-01-08 13:52:38 +00:00
|
|
|
}
|