|
Blender
V2.59
|
00001 /* 00002 * $Id: options.c 38142 2011-07-06 10:19:04Z blendix $ 00003 * 00004 * This is external code. Sets some compression related options 00005 * (width, height quality, framerate). 00006 * 00007 * ***** BEGIN GPL LICENSE BLOCK ***** 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * as published by the Free Software Foundation; either version 2 00012 * of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software Foundation, 00021 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00022 * 00023 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00024 * All rights reserved. 00025 * 00026 * The Original Code is: all of this file. 00027 * 00028 * Contributor(s): none yet. 00029 * 00030 * ***** END GPL LICENSE BLOCK ***** 00031 * 00032 */ 00033 00039 #include "AVI_avi.h" 00040 #include "avi_intern.h" 00041 #include "endian.h" 00042 00043 #include "BLI_winstuff.h" 00044 00045 /* avi_set_compress_options gets its own file... now don't WE feel important? */ 00046 00047 AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) { 00048 int i; 00049 00050 (void)stream; /* unused */ 00051 00052 if (movie->header->TotalFrames != 0) /* Can't change params after we have already started writing frames */ 00053 return AVI_ERROR_OPTION; 00054 00055 switch (option_type) { 00056 case AVI_OPTION_TYPE_MAIN: 00057 switch (option) { 00058 case AVI_OPTION_WIDTH: 00059 movie->header->Width = *((int *) opt_data); 00060 movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; 00061 00062 for (i=0; i < movie->header->Streams; i++) { 00063 if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { 00064 ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); 00065 movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; 00066 movie->streams[i].sh.right = *((int *) opt_data); 00067 ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; 00068 fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); 00069 awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); 00070 } 00071 } 00072 00073 break; 00074 00075 case AVI_OPTION_HEIGHT: 00076 movie->header->Height = *((int *) opt_data); 00077 movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; 00078 00079 for (i=0; i < movie->header->Streams; i++) { 00080 if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { 00081 ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); 00082 movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; 00083 movie->streams[i].sh.bottom = *((int *) opt_data); 00084 ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; 00085 fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); 00086 awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); 00087 } 00088 } 00089 00090 break; 00091 00092 case AVI_OPTION_QUALITY: 00093 for (i=0; i < movie->header->Streams; i++) { 00094 if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { 00095 movie->streams[i].sh.Quality = (*((int *) opt_data))*100; 00096 fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); 00097 awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); 00098 } 00099 } 00100 break; 00101 00102 case AVI_OPTION_FRAMERATE: 00103 if (1000000/(*((double *) opt_data))) 00104 movie->header->MicroSecPerFrame = 1000000/(*((double *) opt_data)); 00105 00106 for (i=0; i < movie->header->Streams; i++) { 00107 if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { 00108 movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; 00109 fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); 00110 awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); 00111 } 00112 } 00113 00114 } 00115 00116 fseek (movie->fp, movie->offset_table[0], SEEK_SET); 00117 awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); 00118 00119 break; 00120 case AVI_OPTION_TYPE_STRH: 00121 break; 00122 case AVI_OPTION_TYPE_STRF: 00123 break; 00124 default: 00125 return AVI_ERROR_OPTION; 00126 break; 00127 } 00128 00129 return AVI_ERROR_NONE; 00130 } 00131