r499: This commit was manufactured by cvs2svn to create tag 'r1_2_1-last'.
[cinelerra_cv/mob.git] / hvirtual / quicktime / plugin.c
blob4dbf4ec4086b8b0230e198354e7b028b3db990fb
1 #include <stdio.h>
2 #include <dirent.h>
3 #include <dlfcn.h>
4 #include "funcprotos.h"
5 #include "quicktime.h"
8 static int total_vcodecs = 0;
9 static int total_acodecs = 0;
10 static quicktime_codectable_t *vcodecs = NULL;
11 static quicktime_codectable_t *acodecs = NULL;
16 static int register_vcodec(void (*init_vcodec)(quicktime_video_map_t *))
18 total_vcodecs++;
19 vcodecs = (quicktime_codectable_t *)realloc(vcodecs,
20 total_vcodecs * sizeof(quicktime_codectable_t));
22 vcodecs[total_vcodecs - 1].init_vcodec = init_vcodec;
23 return total_vcodecs - 1;
26 static int register_acodec(void (*init_acodec)(quicktime_audio_map_t *))
28 total_acodecs++;
29 acodecs = (quicktime_codectable_t *)realloc(acodecs,
30 total_acodecs * sizeof(quicktime_codectable_t));
31 acodecs[total_acodecs - 1].init_acodec = init_acodec;
32 return total_acodecs - 1;
38 #include "ima4.h"
39 #include "mp4a.h"
40 #include "qtvorbis.h"
41 #include "qtmp3.h"
42 #include "rawaudio.h"
43 #include "twos.h"
44 #include "ulaw.h"
45 #include "wma.h"
46 #include "wmx2.h"
48 static void register_acodecs()
50 register_acodec(quicktime_init_codec_twos);
51 register_acodec(quicktime_init_codec_rawaudio);
52 register_acodec(quicktime_init_codec_ima4);
53 register_acodec(quicktime_init_codec_mp4a);
54 register_acodec(quicktime_init_codec_ulaw);
56 register_acodec(quicktime_init_codec_vorbis);
57 register_acodec(quicktime_init_codec_mp3);
58 register_acodec(quicktime_init_codec_wmx2);
59 register_acodec(quicktime_init_codec_wmav1);
60 register_acodec(quicktime_init_codec_wmav2);
67 #include "raw.h"
68 #include "dv.h"
69 #include "jpeg.h"
70 #include "mpeg4.h"
71 #include "qtpng.h"
72 #include "rle.h"
73 #include "v308.h"
74 #include "v408.h"
75 #include "v410.h"
76 #include "yuv2.h"
77 #include "yuv4.h"
78 #include "yv12.h"
80 static void register_vcodecs()
83 register_vcodec(quicktime_init_codec_raw);
85 register_vcodec(quicktime_init_codec_divx);
86 register_vcodec(quicktime_init_codec_hv60);
87 register_vcodec(quicktime_init_codec_div3);
88 register_vcodec(quicktime_init_codec_div3lower);
89 register_vcodec(quicktime_init_codec_mp4v);
90 register_vcodec(quicktime_init_codec_svq1);
91 register_vcodec(quicktime_init_codec_svq3);
92 register_vcodec(quicktime_init_codec_h263);
93 register_vcodec(quicktime_init_codec_dv);
94 register_vcodec(quicktime_init_codec_dvsd);
96 register_vcodec(quicktime_init_codec_jpeg);
97 register_vcodec(quicktime_init_codec_mjpa);
98 register_vcodec(quicktime_init_codec_mjpg);
99 register_vcodec(quicktime_init_codec_png);
100 register_vcodec(quicktime_init_codec_rle);
102 register_vcodec(quicktime_init_codec_yuv2);
103 register_vcodec(quicktime_init_codec_yuv4);
104 register_vcodec(quicktime_init_codec_yv12);
105 register_vcodec(quicktime_init_codec_v410);
106 register_vcodec(quicktime_init_codec_v308);
107 register_vcodec(quicktime_init_codec_v408);
113 int quicktime_find_vcodec(quicktime_video_map_t *vtrack)
115 int i;
116 char *compressor = vtrack->track->mdia.minf.stbl.stsd.table[0].format;
117 quicktime_codec_t *codec_base = (quicktime_codec_t*)vtrack->codec;
118 if(!total_vcodecs) register_vcodecs();
120 for(i = 0; i < total_vcodecs; i++)
122 quicktime_codectable_t *table = &vcodecs[i];
123 table->init_vcodec(vtrack);
124 if(quicktime_match_32(compressor, codec_base->fourcc))
126 return 0;
128 else
130 codec_base->delete_vcodec(vtrack);
131 codec_base->priv = 0;
135 return -1;
139 int quicktime_find_acodec(quicktime_audio_map_t *atrack)
141 int i;
142 char *compressor = atrack->track->mdia.minf.stbl.stsd.table[0].format;
143 int compression_id = atrack->track->mdia.minf.stbl.stsd.table[0].compression_id;
144 int32_t compressor_int = *(int32_t*)compressor;
145 quicktime_codec_t *codec_base = (quicktime_codec_t*)atrack->codec;
146 if(!total_acodecs) register_acodecs();
148 for(i = 0; i < total_acodecs; i++)
150 quicktime_codectable_t *table = &acodecs[i];
151 table->init_acodec(atrack);
153 // For writing and reading Quicktime
154 if(quicktime_match_32(compressor, codec_base->fourcc))
155 return 0;
156 else
157 // For reading AVI, the fourcc may be 0 and the compression_id used instead
158 // forucc can also be compression_id (mencoder does that)
159 if((compressor[0] == 0 || compressor_int == codec_base->wav_id) && codec_base->wav_id == compression_id)
160 return 0;
161 else
163 codec_base->delete_acodec(atrack);
164 codec_base->priv = 0;
168 return -1;