|
Blender
V2.59
|
00001 /* 00002 * $Id: codecs.c 36271 2011-04-21 13:11:51Z campbellbarton $ 00003 * 00004 * This is external code. Identify and convert different avi-files. 00005 * 00006 * ***** BEGIN GPL LICENSE BLOCK ***** 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License 00010 * as published by the Free Software Foundation; either version 2 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software Foundation, 00020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00023 * All rights reserved. 00024 * 00025 * The Original Code is: all of this file. 00026 * 00027 * Contributor(s): none yet. 00028 * 00029 * ***** END GPL LICENSE BLOCK ***** 00030 */ 00031 00037 #include "AVI_avi.h" 00038 #include "avi_intern.h" 00039 00040 #include "avirgb.h" 00041 #include "mjpeg.h" 00042 #include "rgb32.h" 00043 00044 void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) { 00045 if (from == to) 00046 return buffer; 00047 00048 if (from != AVI_FORMAT_RGB24 && 00049 to != AVI_FORMAT_RGB24) 00050 return avi_format_convert(movie, stream, 00051 avi_format_convert (movie, stream, buffer, from, AVI_FORMAT_RGB24, size), 00052 AVI_FORMAT_RGB24, to, size); 00053 00054 switch (to) { 00055 case AVI_FORMAT_RGB24: 00056 switch (from) { 00057 case AVI_FORMAT_AVI_RGB: 00058 buffer = avi_converter_from_avi_rgb (movie, stream, buffer, size); 00059 break; 00060 case AVI_FORMAT_MJPEG: 00061 buffer = avi_converter_from_mjpeg (movie, stream, buffer, size); 00062 break; 00063 case AVI_FORMAT_RGB32: 00064 buffer = avi_converter_from_rgb32 (movie, stream, buffer, size); 00065 break; 00066 default: 00067 break; 00068 } 00069 break; 00070 case AVI_FORMAT_AVI_RGB: 00071 buffer = avi_converter_to_avi_rgb (movie, stream, buffer, size); 00072 break; 00073 case AVI_FORMAT_MJPEG: 00074 buffer = avi_converter_to_mjpeg (movie, stream, buffer, size); 00075 break; 00076 case AVI_FORMAT_RGB32: 00077 buffer = avi_converter_to_rgb32 (movie, stream, buffer, size); 00078 break; 00079 default: 00080 break; 00081 } 00082 00083 return buffer; 00084 } 00085 00086 int avi_get_data_id (AviFormat format, int stream) { 00087 char fcc[5]; 00088 00089 if (avi_get_format_type (format) == FCC("vids")) 00090 sprintf (fcc,"%2.2ddc",stream); 00091 else if (avi_get_format_type (format) == FCC("auds")) 00092 sprintf (fcc,"%2.2ddc",stream); 00093 else 00094 return 0; 00095 00096 return FCC(fcc); 00097 } 00098 00099 int avi_get_format_type (AviFormat format) { 00100 switch (format) { 00101 case AVI_FORMAT_RGB24: 00102 case AVI_FORMAT_RGB32: 00103 case AVI_FORMAT_AVI_RGB: 00104 case AVI_FORMAT_MJPEG: 00105 return FCC("vids"); 00106 break; 00107 default: 00108 return 0; 00109 break; 00110 } 00111 } 00112 00113 int avi_get_format_fcc (AviFormat format) { 00114 switch (format) { 00115 case AVI_FORMAT_RGB24: 00116 case AVI_FORMAT_RGB32: 00117 case AVI_FORMAT_AVI_RGB: 00118 return FCC("DIB "); 00119 break; 00120 case AVI_FORMAT_MJPEG: 00121 return FCC("MJPG"); 00122 break; 00123 default: 00124 return 0; 00125 break; 00126 } 00127 } 00128 00129 int avi_get_format_compression (AviFormat format) { 00130 switch (format) { 00131 case AVI_FORMAT_RGB24: 00132 case AVI_FORMAT_RGB32: 00133 case AVI_FORMAT_AVI_RGB: 00134 return 0; 00135 break; 00136 case AVI_FORMAT_MJPEG: 00137 return FCC("MJPG"); 00138 break; 00139 default: 00140 return 0; 00141 break; 00142 } 00143 }