4 #include "funcprotos.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
*))
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
*))
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;
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
);
81 static void register_vcodecs()
84 register_vcodec(quicktime_init_codec_raw
);
86 register_vcodec(quicktime_init_codec_h264
);
87 register_vcodec(quicktime_init_codec_hv64
);
88 register_vcodec(quicktime_init_codec_divx
);
89 register_vcodec(quicktime_init_codec_hv60
);
90 register_vcodec(quicktime_init_codec_div5
);
91 register_vcodec(quicktime_init_codec_div3
);
92 register_vcodec(quicktime_init_codec_div3v2
);
93 register_vcodec(quicktime_init_codec_div3lower
);
94 register_vcodec(quicktime_init_codec_mp4v
);
95 register_vcodec(quicktime_init_codec_xvid
);
96 register_vcodec(quicktime_init_codec_svq1
);
97 register_vcodec(quicktime_init_codec_svq3
);
98 register_vcodec(quicktime_init_codec_h263
);
99 register_vcodec(quicktime_init_codec_dv
);
100 register_vcodec(quicktime_init_codec_dvsd
);
101 register_vcodec(quicktime_init_codec_dvcp
);
103 register_vcodec(quicktime_init_codec_jpeg
);
104 register_vcodec(quicktime_init_codec_mjpa
);
105 register_vcodec(quicktime_init_codec_mjpg
);
106 register_vcodec(quicktime_init_codec_png
);
107 register_vcodec(quicktime_init_codec_rle
);
109 register_vcodec(quicktime_init_codec_yuv2
);
110 register_vcodec(quicktime_init_codec_2vuy
);
111 register_vcodec(quicktime_init_codec_yuv4
);
112 register_vcodec(quicktime_init_codec_yv12
);
113 register_vcodec(quicktime_init_codec_v410
);
114 register_vcodec(quicktime_init_codec_v308
);
115 register_vcodec(quicktime_init_codec_v408
);
121 int quicktime_find_vcodec(quicktime_video_map_t
*vtrack
)
124 char *compressor
= vtrack
->track
->mdia
.minf
.stbl
.stsd
.table
[0].format
;
125 quicktime_codec_t
*codec_base
= (quicktime_codec_t
*)vtrack
->codec
;
126 if(!total_vcodecs
) register_vcodecs();
128 for(i
= 0; i
< total_vcodecs
; i
++)
130 quicktime_codectable_t
*table
= &vcodecs
[i
];
131 table
->init_vcodec(vtrack
);
132 if(quicktime_match_32(compressor
, codec_base
->fourcc
))
138 codec_base
->delete_vcodec(vtrack
);
139 codec_base
->priv
= 0;
147 int quicktime_find_acodec(quicktime_audio_map_t
*atrack
)
150 char *compressor
= atrack
->track
->mdia
.minf
.stbl
.stsd
.table
[0].format
;
151 int compression_id
= atrack
->track
->mdia
.minf
.stbl
.stsd
.table
[0].compression_id
;
152 quicktime_codec_t
*codec_base
= (quicktime_codec_t
*)atrack
->codec
;
153 int32_t compressor_int
= *(int32_t*)compressor
;
154 if(!total_acodecs
) register_acodecs();
156 for(i
= 0; i
< total_acodecs
; i
++)
158 quicktime_codectable_t
*table
= &acodecs
[i
];
159 table
->init_acodec(atrack
);
161 // For writing and reading Quicktime
162 if(quicktime_match_32(compressor
, codec_base
->fourcc
))
165 // For reading AVI, sometimes the fourcc is 0 and the compression_id is used instead.
166 // Sometimes the compression_id is the fourcc.
167 if((compressor
[0] == 0 || compressor_int
== codec_base
->wav_id
) &&
168 codec_base
->wav_id
== compression_id
)
172 codec_base
->delete_acodec(atrack
);
173 codec_base
->priv
= 0;
181 char* quicktime_acodec_title(char *fourcc
)
185 quicktime_audio_map_t
*atrack
=
186 (quicktime_audio_map_t
*)calloc(1, sizeof(quicktime_audio_map_t
));
187 quicktime_codec_t
*codec_base
=
189 (quicktime_codec_t
*)calloc(1, sizeof(quicktime_codec_t
));
191 if(!total_acodecs
) register_acodecs();
192 for(i
= 0; i
< total_acodecs
&& !done
; i
++)
194 //printf("quicktime_acodec_title 1\n");
195 quicktime_codectable_t
*table
= &acodecs
[i
];
196 //printf("quicktime_acodec_title 2\n");
197 table
->init_acodec(atrack
);
198 //printf("quicktime_acodec_title 3\n");
199 if(quicktime_match_32(fourcc
, codec_base
->fourcc
))
201 result
= codec_base
->title
;
204 //printf("quicktime_acodec_title 4\n");
205 codec_base
->delete_acodec(atrack
);
206 //printf("quicktime_acodec_title 5\n");
217 char* quicktime_vcodec_title(char *fourcc
)
222 quicktime_video_map_t
*vtrack
=
223 (quicktime_video_map_t
*)calloc(1, sizeof(quicktime_video_map_t
));
224 quicktime_codec_t
*codec_base
=
226 (quicktime_codec_t
*)calloc(1, sizeof(quicktime_codec_t
));
230 if(!total_vcodecs
) register_vcodecs();
231 for(i
= 0; i
< total_vcodecs
&& !done
; i
++)
233 quicktime_codectable_t
*table
= &vcodecs
[i
];
234 table
->init_vcodec(vtrack
);
235 if(quicktime_match_32(fourcc
, codec_base
->fourcc
))
237 result
= codec_base
->title
;
240 codec_base
->delete_vcodec(vtrack
);