Cleanup: remove redundant doxygen \file argument
[blender.git] / source / blender / avi / intern / avi_codecs.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19
20 /** \file \ingroup avi
21  *
22  * This is external code. Identify and convert different avi-files.
23  */
24
25
26 #include "AVI_avi.h"
27 #include "avi_intern.h"
28
29 #include "avi_rgb.h"
30 #include "avi_mjpeg.h"
31 #include "avi_rgb32.h"
32
33 void *avi_format_convert(AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, size_t *size)
34 {
35         if (from == to)
36                 return buffer;
37
38         if (from != AVI_FORMAT_RGB24 &&
39             to != AVI_FORMAT_RGB24)
40         {
41                 return avi_format_convert(movie, stream,
42                                           avi_format_convert(movie, stream, buffer, from, AVI_FORMAT_RGB24, size),
43                                           AVI_FORMAT_RGB24, to, size);
44         }
45
46         switch (to) {
47                 case AVI_FORMAT_RGB24:
48                         switch (from) {
49                                 case AVI_FORMAT_AVI_RGB:
50                                         buffer = avi_converter_from_avi_rgb(movie, stream, buffer, size);
51                                         break;
52                                 case AVI_FORMAT_MJPEG:
53                                         buffer = avi_converter_from_mjpeg(movie, stream, buffer, size);
54                                         break;
55                                 case AVI_FORMAT_RGB32:
56                                         buffer = avi_converter_from_rgb32(movie, stream, buffer, size);
57                                         break;
58                                 default:
59                                         break;
60                         }
61                         break;
62                 case AVI_FORMAT_AVI_RGB:
63                         buffer = avi_converter_to_avi_rgb(movie, stream, buffer, size);
64                         break;
65                 case AVI_FORMAT_MJPEG:
66                         buffer = avi_converter_to_mjpeg(movie, stream, buffer, size);
67                         break;
68                 case AVI_FORMAT_RGB32:
69                         buffer = avi_converter_to_rgb32(movie, stream, buffer, size);
70                         break;
71                 default:
72                         break;
73         }
74
75         return buffer;
76 }
77
78 int avi_get_data_id(AviFormat format, int stream)
79 {
80         char fcc[5];
81
82         if (avi_get_format_type(format) == FCC("vids"))
83                 sprintf(fcc, "%2.2ddc", stream);
84         else if (avi_get_format_type(format) == FCC("auds"))
85                 sprintf(fcc, "%2.2ddc", stream);
86         else
87                 return 0;
88
89         return FCC(fcc);
90 }
91
92 int avi_get_format_type(AviFormat format)
93 {
94         switch (format) {
95                 case AVI_FORMAT_RGB24:
96                 case AVI_FORMAT_RGB32:
97                 case AVI_FORMAT_AVI_RGB:
98                 case AVI_FORMAT_MJPEG:
99                         return FCC("vids");
100                 default:
101                         return 0;
102         }
103 }
104
105 int avi_get_format_fcc(AviFormat format)
106 {
107         switch (format) {
108                 case AVI_FORMAT_RGB24:
109                 case AVI_FORMAT_RGB32:
110                 case AVI_FORMAT_AVI_RGB:
111                         return FCC("DIB ");
112                 case AVI_FORMAT_MJPEG:
113                         return FCC("MJPG");
114                 default:
115                         return 0;
116         }
117 }
118
119 int avi_get_format_compression(AviFormat format)
120 {
121         switch (format) {
122                 case AVI_FORMAT_RGB24:
123                 case AVI_FORMAT_RGB32:
124                 case AVI_FORMAT_AVI_RGB:
125                         return 0;
126                 case AVI_FORMAT_MJPEG:
127                         return FCC("MJPG");
128                 default:
129                         return 0;
130         }
131 }