Blender V2.61 - r43446

codecs.c

Go to the documentation of this file.
00001 /*
00002  *
00003  * This is external code. Identify and convert different avi-files.
00004  *
00005  * ***** BEGIN GPL LICENSE BLOCK *****
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software Foundation,
00019  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00022  * All rights reserved.
00023  *
00024  * The Original Code is: all of this file.
00025  *
00026  * Contributor(s): none yet.
00027  *
00028  * ***** END GPL LICENSE BLOCK *****
00029  */
00030 
00036 #include "AVI_avi.h"
00037 #include "avi_intern.h"
00038 
00039 #include "avirgb.h"
00040 #include "mjpeg.h"
00041 #include "rgb32.h"
00042 
00043 void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size)
00044 {
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 {
00088     char fcc[5];
00089 
00090     if (avi_get_format_type (format) == FCC("vids"))
00091         sprintf (fcc,"%2.2ddc",stream);
00092     else if (avi_get_format_type (format) == FCC("auds"))
00093         sprintf (fcc,"%2.2ddc",stream);
00094     else
00095         return 0;
00096 
00097     return FCC(fcc);
00098 }
00099 
00100 int avi_get_format_type (AviFormat format)
00101 {
00102     switch (format) {
00103     case AVI_FORMAT_RGB24:
00104     case AVI_FORMAT_RGB32:
00105     case AVI_FORMAT_AVI_RGB:
00106     case AVI_FORMAT_MJPEG:
00107         return FCC("vids");
00108         break;
00109     default:
00110         return 0;
00111         break;
00112     }
00113 }
00114 
00115 int avi_get_format_fcc (AviFormat format)
00116 {
00117     switch (format) {
00118     case AVI_FORMAT_RGB24:
00119     case AVI_FORMAT_RGB32:
00120     case AVI_FORMAT_AVI_RGB:
00121         return FCC("DIB ");
00122         break;
00123     case AVI_FORMAT_MJPEG:
00124         return FCC("MJPG");
00125         break;
00126     default:
00127         return 0;
00128         break;
00129     }
00130 }
00131 
00132 int avi_get_format_compression (AviFormat format)
00133 {
00134     switch (format) {
00135     case AVI_FORMAT_RGB24:
00136     case AVI_FORMAT_RGB32:
00137     case AVI_FORMAT_AVI_RGB:
00138         return 0;
00139         break;
00140     case AVI_FORMAT_MJPEG:
00141         return FCC("MJPG");
00142         break;
00143     default:
00144         return 0;
00145         break;
00146     }
00147 }