2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
2022-02-10 09:56:54 +11:00
|
|
|
* Functions for writing AVI-format files.
|
2022-02-09 18:31:42 +11:00
|
|
|
* Added interface for generic movie support (ton)
|
2019-02-18 08:08:12 +11:00
|
|
|
* \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 ***************************** */
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static int start_stub(void *UNUSED(context_v),
|
2020-03-13 17:27:11 +11:00
|
|
|
const Scene *UNUSED(scene),
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderData *UNUSED(rd),
|
|
|
|
|
int UNUSED(rectx),
|
|
|
|
|
int UNUSED(recty),
|
|
|
|
|
ReportList *UNUSED(reports),
|
|
|
|
|
bool UNUSED(preview),
|
|
|
|
|
const char *UNUSED(suffix))
|
2014-01-07 14:51:59 +01:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void end_stub(void *UNUSED(context_v)) {}
|
2014-01-07 14:51:59 +01:00
|
|
|
|
2015-04-06 10:40:12 -03: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))
|
2014-01-07 14:51:59 +01:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void *context_create_stub(void)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void context_free_stub(void *UNUSED(context_v)) {}
|
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 */
|
2015-04-06 10:40:12 -03:00
|
|
|
static int start_avi(void *context_v,
|
2020-03-13 17:27:11 +11:00
|
|
|
const Scene *scene,
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderData *rd,
|
|
|
|
|
int rectx,
|
|
|
|
|
int recty,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
bool preview,
|
|
|
|
|
const char *suffix);
|
|
|
|
|
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);
|
2023-06-19 12:28:46 +10:00
|
|
|
static void filepath_avi(char filepath[FILE_MAX],
|
|
|
|
|
const RenderData *rd,
|
|
|
|
|
bool preview,
|
|
|
|
|
const char *suffix);
|
2015-04-06 10:40:12 -03:00
|
|
|
static void *context_create_avi(void);
|
|
|
|
|
static void context_free_avi(void *context_v);
|
2012-10-08 02:51:42 +00: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
|
|
|
{
|
2013-03-22 05:34:10 +00:00
|
|
|
static bMovieHandle mh = {NULL};
|
2014-01-07 14:51:59 +01:00
|
|
|
/* 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;
|
2015-04-06 10:40:12 -03:00
|
|
|
mh.context_create = context_create_stub;
|
|
|
|
|
mh.context_free = context_free_stub;
|
2019-04-17 06:17:24 +02: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
|
|
|
/* set the default handle, as builtin */
|
2012-10-08 02:51:42 +00:00
|
|
|
#ifdef WITH_AVI
|
2012-05-12 16:11:34 +00:00
|
|
|
mh.start_movie = start_avi;
|
|
|
|
|
mh.append_movie = append_avi;
|
|
|
|
|
mh.end_movie = end_avi;
|
2010-01-08 13:52:38 +00:00
|
|
|
mh.get_movie_path = filepath_avi;
|
2015-04-06 10:40:12 -03:00
|
|
|
mh.context_create = context_create_avi;
|
|
|
|
|
mh.context_free = context_free_avi;
|
2012-10-08 02:51:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
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
|
|
|
/* do the platform specific handles */
|
2006-02-05 19:12:25 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(imtype,
|
|
|
|
|
R_IMF_IMTYPE_FFMPEG,
|
|
|
|
|
R_IMF_IMTYPE_H264,
|
|
|
|
|
R_IMF_IMTYPE_XVID,
|
Video rendering: FFMpeg AV1 codec encoding support
Previously, the Blender video renderer did not have support for
encoding video to AV1 (not to be confused with the container AVI).
The proposed solution is to leverage the existing FFMpeg renderer
to encode to AV1.
Note that avcodec_find_encoder(AV_CODEC_ID_AV1) usually returns
"libaom-av1" which is the "reference implementation" for AV1 encoding
(the default for FFMpeg, and is slow). "libsvtav1" is faster and
preferred so there is extra handling when fetching the AV1 codec for
encoding such that "libsvtav1" is used when possible.
This commit should only affect the options available for video
rendering, which includes the additional AV1 codec to choose from, and
setting "-crf".
Also note that the current release of FFMpeg for ArchLinux does not
support "-crf" for "libsvtav1", but the equivalent option "-qp" is
supported and used as a fallback when "libsvtav1" is used (as
mentioned here: https://trac.ffmpeg.org/wiki/Encode/AV1#SVT-AV1 ).
(Actually, both "-crf" and "-qp" is specified with the same value in
the code. When a release of FFMpeg obtains support for "-crf" for
"libsvtav1" is released, the code shouldn't be needed to change.)
The usage of the AV1 codec should be very similar to the usage of the
H264 codec, but is limited to the "mp4" and "mkv" containers.
This patch pertains to the "VFX & Video" module, as its main purpose
is to supplement the Video Sequencer tool with the additional AV1
codec for encoded video output.
Differential Revision: https://developer.blender.org/D14920
Reviewed By: sergey , ISS, zeddb
2022-10-21 20:10:17 -06:00
|
|
|
R_IMF_IMTYPE_THEORA,
|
|
|
|
|
R_IMF_IMTYPE_AV1))
|
|
|
|
|
{
|
2012-05-07 09:30:15 +00:00
|
|
|
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;
|
2015-04-06 10:40:12 -03:00
|
|
|
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
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* in case all above are disabled */
|
2015-09-23 02:40:08 +10:00
|
|
|
(void)imtype;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
static void filepath_avi(char filepath[FILE_MAX],
|
|
|
|
|
const RenderData *rd,
|
|
|
|
|
bool preview,
|
|
|
|
|
const char *suffix)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2015-03-26 14:49:59 +01:00
|
|
|
int sfra, efra;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
if (filepath == NULL) {
|
2012-05-12 16:11:34 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-26 14:49:59 +01:00
|
|
|
if (preview) {
|
|
|
|
|
sfra = rd->psfra;
|
|
|
|
|
efra = rd->pefra;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sfra = rd->sfra;
|
|
|
|
|
efra = rd->efra;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
BLI_strncpy(filepath, rd->pic, FILE_MAX);
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_path_abs(filepath, BKE_main_blendfile_path_from_global());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_file_ensure_parent_dir_exists(filepath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-11-25 16:59:10 +11:00
|
|
|
if (rd->scemode & R_EXTENSION) {
|
2023-05-03 14:13:27 +10:00
|
|
|
if (!BLI_path_extension_check(filepath, ".avi")) {
|
2023-05-15 09:09:08 +10:00
|
|
|
BLI_path_frame_range(filepath, FILE_MAX, sfra, efra, 4);
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_strncat(filepath, ".avi", FILE_MAX);
|
2013-11-25 16:59:10 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2023-05-03 14:13:27 +10:00
|
|
|
if (BLI_path_frame_check_chars(filepath)) {
|
2023-05-15 09:09:08 +10:00
|
|
|
BLI_path_frame_range(filepath, FILE_MAX, sfra, efra, 4);
|
2013-11-25 16:59:10 +11:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-03 14:13:27 +10:00
|
|
|
BLI_path_suffix(filepath, FILE_MAX, suffix, "");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static int start_avi(void *context_v,
|
2020-03-13 17:27:11 +11:00
|
|
|
const Scene *UNUSED(scene),
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderData *rd,
|
|
|
|
|
int rectx,
|
|
|
|
|
int recty,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
bool preview,
|
|
|
|
|
const char *suffix)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
int x, y;
|
2023-06-19 12:28:46 +10:00
|
|
|
char filepath[FILE_MAX];
|
2002-10-12 11:37:38 +00:00
|
|
|
AviFormat format;
|
== Core ==
This adds fractional FPS support to blender and should finally
make NTSC work correctly.
NTSC has an FPS of 30.0/1.001 which is approximately 29.97 FPS.
Therefore, it is not enough to simply make frs_sec a float, since
you can't represent this accurately enough.
I added a seperate variable frs_sec_base and FPS is now
frs_sec / frs_sec_base.
I changed all the places, where frs_sec was used to my best knowledge.
For convenience sake, I added several macros, that should make life
easier in the future:
FRA2TIME(a) : convert frame number to a double precision time in seconds
TIME2FRA(a) : the same in the opposite direction
FPS : return current FPS as a double precision number
(last resort)
This closes bug #6715
Standard framerates not supported / breaks sync -- 23.967 29.967 etc.
https://projects.blender.org/tracker/?func=detail&aid=6715&group_id=9&atid=125
Please give this heavy testing with NTSC files, quicktime in/export
and the python interface.
Errors are most probably only spotted on longer timelines, so that is
also important.
The patch was tested by Troy Sobotka and me, so it most probably should
work out of the box, but wider testing is important, since errors are
very subtle.
Enjoy!
2007-10-21 15:42:08 +00:00
|
|
|
int quality;
|
|
|
|
|
double framerate;
|
2015-04-06 10:40:12 -03:00
|
|
|
AviMovie *avi = context_v;
|
|
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
filepath_avi(filepath, rd, preview, suffix);
|
2002-10-12 11:37:38 +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
|
|
|
x = rectx;
|
|
|
|
|
y = recty;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 16:11:34 +00: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) {
|
2012-05-12 16:11:34 +00:00
|
|
|
format = AVI_FORMAT_AVI_RGB;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2002-10-12 11:37:38 +00:00
|
|
|
format = AVI_FORMAT_MJPEG;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
if (AVI_open_compress(filepath, avi, 1, format) != AVI_ERROR_NONE) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file");
|
2009-12-22 12:01:32 +00:00
|
|
|
return 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-12 16:11:34 +00: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);
|
|
|
|
|
|
|
|
|
|
avi->interlace = 0;
|
|
|
|
|
avi->odd_fields = 0;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
printf("Created avi: %s\n", filepath);
|
2009-12-22 12:01:32 +00:00
|
|
|
return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03: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
|
|
|
{
|
2022-09-26 10:56:05 +10:00
|
|
|
uint *rt1, *rt2, *rectot;
|
2006-01-09 15:46:43 +00:00
|
|
|
int x, y;
|
|
|
|
|
char *cp, rt;
|
2015-04-06 10:40:12 -03:00
|
|
|
AviMovie *avi = context_v;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (avi == NULL) {
|
2009-12-22 12:01:32 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
/* note that libavi free's the buffer... stupid interface - zr */
|
2012-05-12 16:11:34 +00:00
|
|
|
rectot = MEM_mallocN(rectx * recty * sizeof(int), "rectot");
|
|
|
|
|
rt1 = rectot;
|
2022-09-26 10:56:05 +10:00
|
|
|
rt2 = (uint *)pixels + (recty - 1) * rectx;
|
2006-01-09 15:46:43 +00:00
|
|
|
/* flip y and convert to abgr */
|
2012-05-12 16:11:34 +00:00
|
|
|
for (y = 0; y < recty; y++, rt1 += rectx, rt2 -= rectx) {
|
|
|
|
|
memcpy(rt1, rt2, rectx * sizeof(int));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
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;
|
2006-01-09 15:46:43 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 16:11:34 +00:00
|
|
|
AVI_write_frame(avi, (frame - start_frame), AVI_FORMAT_RGB32, rectot, rectx * recty * 4);
|
2014-03-25 10:10:00 +11:00
|
|
|
// printf("added frame %3d (frame %3d in avi): ", frame, frame-start_frame);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
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
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
AviMovie *avi = context_v;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (avi == NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 16:11:34 +00: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)
|
|
|
|
|
{
|
|
|
|
|
AviMovie *avi = MEM_mallocN(sizeof(AviMovie), "avimovie");
|
|
|
|
|
return avi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void context_free_avi(void *context_v)
|
|
|
|
|
{
|
|
|
|
|
AviMovie *avi = context_v;
|
|
|
|
|
if (avi) {
|
|
|
|
|
MEM_freeN(avi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-08 02:51:42 +00:00
|
|
|
#endif /* WITH_AVI */
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2023-06-19 12:28:46 +10:00
|
|
|
void BKE_movie_filepath_get(char filepath[/*FILE_MAX*/ 1024],
|
|
|
|
|
const RenderData *rd,
|
|
|
|
|
bool preview,
|
|
|
|
|
const char *suffix)
|
2010-01-08 13:52:38 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
bMovieHandle *mh = BKE_movie_handle_get(rd->im_format.imtype);
|
2015-09-23 02:40:08 +10:00
|
|
|
if (mh && mh->get_movie_path) {
|
2023-05-03 14:13:27 +10:00
|
|
|
mh->get_movie_path(filepath, rd, preview, suffix);
|
2015-09-23 02:40:08 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2023-05-03 14:13:27 +10:00
|
|
|
filepath[0] = '\0';
|
2015-09-23 02:40:08 +10:00
|
|
|
}
|
2010-01-08 13:52:38 +00:00
|
|
|
}
|