2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* options.h
|
|
|
|
|
*
|
|
|
|
|
* This is external code. Sets some compression related options
|
|
|
|
|
* (width, height quality, framerate).
|
|
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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-04-16 22:40:48 +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.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
#include "AVI_avi.h"
|
|
|
|
|
#include "avi_intern.h"
|
|
|
|
|
#include "endian.h"
|
|
|
|
|
|
|
|
|
|
/* avi_set_compress_options gets its own file... now don't WE feel important? */
|
|
|
|
|
|
|
|
|
|
AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (movie->header->TotalFrames != 0) /* Can't change params after we have already started writing frames */
|
|
|
|
|
return AVI_ERROR_OPTION;
|
|
|
|
|
|
|
|
|
|
switch (option_type) {
|
|
|
|
|
case AVI_OPTION_TYPE_MAIN:
|
|
|
|
|
switch (option) {
|
|
|
|
|
case AVI_OPTION_WIDTH:
|
|
|
|
|
movie->header->Width = *((int *) opt_data);
|
|
|
|
|
movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3;
|
|
|
|
|
|
|
|
|
|
for (i=0; i < movie->header->Streams; i++) {
|
|
|
|
|
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
|
|
|
|
|
((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data);
|
|
|
|
|
movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize;
|
|
|
|
|
movie->streams[i].sh.right = *((int *) opt_data);
|
|
|
|
|
((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize;
|
|
|
|
|
fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET);
|
|
|
|
|
awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AVI_OPTION_HEIGHT:
|
|
|
|
|
movie->header->Height = *((int *) opt_data);
|
|
|
|
|
movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3;
|
|
|
|
|
|
|
|
|
|
for (i=0; i < movie->header->Streams; i++) {
|
|
|
|
|
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
|
|
|
|
|
((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data);
|
|
|
|
|
movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize;
|
|
|
|
|
movie->streams[i].sh.bottom = *((int *) opt_data);
|
|
|
|
|
((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize;
|
|
|
|
|
fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET);
|
|
|
|
|
awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AVI_OPTION_QUALITY:
|
|
|
|
|
for (i=0; i < movie->header->Streams; i++) {
|
|
|
|
|
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
|
|
|
|
|
movie->streams[i].sh.Quality = (*((int *) opt_data))*100;
|
|
|
|
|
fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET);
|
|
|
|
|
awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AVI_OPTION_FRAMERATE:
|
== 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
|
|
|
if (1000000/(*((double *) opt_data)))
|
|
|
|
|
movie->header->MicroSecPerFrame = 1000000/(*((double *) opt_data));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
for (i=0; i < movie->header->Streams; i++) {
|
|
|
|
|
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
|
|
|
|
|
movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame;
|
|
|
|
|
fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET);
|
|
|
|
|
awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
fseek (movie->fp, movie->offset_table[0], SEEK_SET);
|
|
|
|
|
awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case AVI_OPTION_TYPE_STRH:
|
2010-03-22 09:30:00 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case AVI_OPTION_TYPE_STRF:
|
2010-03-22 09:30:00 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
default:
|
2010-03-22 09:30:00 +00:00
|
|
|
return AVI_ERROR_OPTION;
|
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AVI_ERROR_NONE;
|
|
|
|
|
}
|
|
|
|
|
|