r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / quicktime / plugin.c
blobfb589d8312ab80125110ce6a2c33375b4f0ce02f
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 "qtvorbis.h"
40 #include "qtmp3.h"
41 #include "rawaudio.h"
42 #include "twos.h"
43 #include "ulaw.h"
44 #include "wma.h"
45 #include "wmx2.h"
47 static void register_acodecs()
49 register_acodec(quicktime_init_codec_twos);
50 register_acodec(quicktime_init_codec_rawaudio);
51 register_acodec(quicktime_init_codec_ima4);
52 register_acodec(quicktime_init_codec_ulaw);
54 register_acodec(quicktime_init_codec_vorbis);
55 register_acodec(quicktime_init_codec_mp3);
56 register_acodec(quicktime_init_codec_wmx2);
57 register_acodec(quicktime_init_codec_wmav1);
58 register_acodec(quicktime_init_codec_wmav2);
65 #include "raw.h"
66 #include "dv.h"
67 #include "jpeg.h"
68 #include "mpeg4.h"
69 #include "qtpng.h"
70 #include "v308.h"
71 #include "v408.h"
72 #include "v410.h"
73 #include "yuv2.h"
74 #include "yuv4.h"
75 #include "yv12.h"
77 static void register_vcodecs()
80 register_vcodec(quicktime_init_codec_raw);
82 register_vcodec(quicktime_init_codec_divx);
83 register_vcodec(quicktime_init_codec_hv60);
84 register_vcodec(quicktime_init_codec_div3);
85 register_vcodec(quicktime_init_codec_div3lower);
86 register_vcodec(quicktime_init_codec_svq1);
87 register_vcodec(quicktime_init_codec_dv);
88 register_vcodec(quicktime_init_codec_dvsd);
91 register_vcodec(quicktime_init_codec_jpeg);
92 register_vcodec(quicktime_init_codec_mjpa);
93 register_vcodec(quicktime_init_codec_png);
95 register_vcodec(quicktime_init_codec_yuv2);
96 register_vcodec(quicktime_init_codec_yuv4);
97 register_vcodec(quicktime_init_codec_yv12);
98 register_vcodec(quicktime_init_codec_v410);
99 register_vcodec(quicktime_init_codec_v308);
100 register_vcodec(quicktime_init_codec_v408);
106 int quicktime_find_vcodec(quicktime_video_map_t *vtrack)
108 int i;
109 char *compressor = vtrack->track->mdia.minf.stbl.stsd.table[0].format;
110 quicktime_codec_t *codec_base = (quicktime_codec_t*)vtrack->codec;
111 if(!total_vcodecs) register_vcodecs();
113 for(i = 0; i < total_vcodecs; i++)
115 quicktime_codectable_t *table = &vcodecs[i];
116 table->init_vcodec(vtrack);
117 if(quicktime_match_32(compressor, codec_base->fourcc))
119 return 0;
121 else
123 codec_base->delete_vcodec(vtrack);
124 codec_base->priv = 0;
128 return -1;
132 int quicktime_find_acodec(quicktime_audio_map_t *atrack)
134 int i;
135 char *compressor = atrack->track->mdia.minf.stbl.stsd.table[0].format;
136 int compression_id = atrack->track->mdia.minf.stbl.stsd.table[0].compression_id;
137 quicktime_codec_t *codec_base = (quicktime_codec_t*)atrack->codec;
138 if(!total_acodecs) register_acodecs();
140 for(i = 0; i < total_acodecs; i++)
142 quicktime_codectable_t *table = &acodecs[i];
143 table->init_acodec(atrack);
145 // For writing and reading Quicktime
146 if(quicktime_match_32(compressor, codec_base->fourcc))
147 return 0;
148 else
149 // For reading AVI, the fourcc may be 0 and the compression_id used instead
150 if(compressor[0] == 0 && codec_base->wav_id == compression_id)
151 return 0;
152 else
154 codec_base->delete_acodec(atrack);
155 codec_base->priv = 0;
159 return -1;