mask xy scale, mask boundary only overlay, fix 8 char mask nm bug, rework maskgui...
[goodguy/cinelerra.git] / cinelerra-5.1 / libzmpeg3 / mpeg3.C
1 #include "libzmpeg3.h"
2
3 extern "C" int
4 mpeg3_major()
5 {
6   return zmpeg3_t::zmajor();
7 }
8
9 extern "C" int
10 mpeg3_minor()
11 {
12   return zmpeg3_t::zminor();
13 }
14
15 extern "C" int
16 mpeg3_release()
17 {
18   return zmpeg3_t::zrelease();
19 }
20
21 extern "C" int
22 mpeg3_check_sig(char *path)
23 {
24   return zmpeg3_t::check_sig(path);
25 }
26
27 extern "C" zmpeg3_t*
28 mpeg3_open(const char *path, int *error_return)
29 {
30   zmpeg3_t *src = new zmpeg3_t(path, *error_return);
31   if( *error_return ) { delete src;  src = 0; }
32   return src;
33 }
34
35 extern "C" zmpeg3_t*
36 mpeg3_open_title(const char *title_path, const char *path, int *error_return)
37 {
38   zmpeg3_t *src = new zmpeg3_t(path, *error_return, ZIO_UNBUFFERED, title_path);
39   if( *error_return ) { delete src;  src = 0; }
40   return src;
41 }
42
43 extern "C" zmpeg3_t*
44 mpeg3_zopen(const char *title_path, const char *path, int *error_return, int access)
45 {
46   zmpeg3_t *src = new zmpeg3_t(path, *error_return, access, title_path);
47   if( *error_return ) { delete src;  src = 0; }
48   return src;
49 }
50
51 extern "C" int
52 mpeg3_close(zmpeg3_t *zsrc)
53 {
54   delete zsrc;
55   return 0;
56 }
57
58 extern "C" zmpeg3_t*
59 mpeg3_open_copy(const char *path, zmpeg3_t *old_src, int *error_return)
60 {
61   return old_src;
62 }
63
64 extern "C" int
65 mpeg3_set_pts_padding(zmpeg3_t *zsrc, int v)
66 {
67   return zsrc->set_pts_padding(v);
68 }
69
70 extern "C" int
71 mpeg3_set_cpus(zmpeg3_t *zsrc, int cpus)
72 {
73   return zsrc->set_cpus(cpus);
74 }
75
76 extern "C" int
77 mpeg3_has_audio(zmpeg3_t *zsrc)
78 {
79   return zsrc->has_audio();
80 }
81
82
83 extern "C" int
84 mpeg3_total_astreams(zmpeg3_t *zsrc)
85 {
86   return zsrc->total_astreams();
87 }
88
89
90 extern "C" int
91 mpeg3_audio_channels(zmpeg3_t *zsrc, int stream)
92 {
93   return zsrc->audio_channels(stream);
94 }
95
96
97 extern "C" int
98 mpeg3_sample_rate(zmpeg3_t *zsrc, int stream)
99 {
100   return zsrc->sample_rate(stream);
101 }
102
103
104 extern "C" const char *
105 mpeg3_audio_format(zmpeg3_t *zsrc, int stream)
106 {
107   return zsrc->audio_format(stream);
108 }
109
110 extern "C" long
111 mpeg3_get_audio_nudge(zmpeg3_t *zsrc, int stream)
112 {
113   return zsrc->audio_nudge(stream);
114 }
115
116 extern "C" long
117 mpeg3_audio_samples(zmpeg3_t *zsrc, int stream)
118 {
119   return zsrc->audio_samples(stream);
120 }
121
122  
123 extern "C" int
124 mpeg3_set_sample(zmpeg3_t *zsrc, long sample, int stream)
125 {
126   return zsrc->set_sample(sample, stream);
127 }
128
129 extern "C" long
130 mpeg3_get_sample(zmpeg3_t *zsrc, int stream)
131 {
132   return zsrc->get_sample(stream);
133 }
134
135 extern "C" int
136 mpeg3_read_audio_d(zmpeg3_t *zsrc,double *output_d,
137   int channel, long samples, int stream)
138 {
139   return zsrc->read_audio(output_d, channel, samples, stream);
140 }
141
142 extern "C" int
143 mpeg3_read_audio_f(zmpeg3_t *zsrc,float *output_f,
144   int channel, long samples, int stream)
145 {
146   return zsrc->read_audio(output_f, channel, samples, stream);
147 }
148
149 extern "C" int
150 mpeg3_read_audio_i(zmpeg3_t *zsrc,int *output_i,
151   int channel, long samples, int stream)
152 {
153   return zsrc->read_audio(output_i, channel, samples, stream);
154 }
155
156 extern "C" int
157 mpeg3_read_audio_s(zmpeg3_t *zsrc,short *output_s,
158   int channel, long samples, int stream)
159 {
160   return zsrc->read_audio(output_s, channel, samples, stream);
161 }
162
163 extern "C" int
164 mpeg3_read_audio(zmpeg3_t *zsrc,float *output_f, short *output_i,
165   int channel, long samples, int stream)
166 {
167   if( output_f != 0 )
168     return zsrc->read_audio(output_f, channel, samples, stream);
169   if( output_i != 0 )
170     return zsrc->read_audio(output_i, channel, samples, stream);
171   return 1;
172 }
173
174 extern "C" int
175 mpeg3_reread_audio(zmpeg3_t *zsrc,float *output_f, short *output_i,
176   int channel, long samples, int stream)
177 {
178   if( output_f != 0 )
179     return zsrc->reread_audio(output_f, channel, samples, stream);
180   if( output_i != 0 )
181     return zsrc->reread_audio(output_i, channel, samples, stream);
182   return 1;
183 }
184
185 extern "C" int
186 mpeg3_reread_audio_d(zmpeg3_t *zsrc,double *output_d,
187   int channel, long samples, int stream)
188 {
189   return zsrc->reread_audio(output_d, channel, samples, stream);
190 }
191
192 extern "C" int
193 mpeg3_reread_audio_f(zmpeg3_t *zsrc,float *output_f,
194   int channel, long samples, int stream)
195 {
196   return zsrc->reread_audio(output_f, channel, samples, stream);
197 }
198
199 extern "C" int
200 mpeg3_reread_audio_i(zmpeg3_t *zsrc,int *output_i,
201   int channel, long samples, int stream)
202 {
203   return zsrc->reread_audio(output_i, channel, samples, stream);
204 }
205
206 extern "C" int
207 mpeg3_reread_audio_s(zmpeg3_t *zsrc,short *output_s,
208   int channel, long samples, int stream)
209 {
210   return zsrc->reread_audio(output_s, channel, samples, stream);
211 }
212
213 extern "C" int
214 mpeg3_read_audio_chunk(zmpeg3_t *zsrc,unsigned char *output,
215   long *size, long max_size, int stream)
216 {
217   return zsrc->read_audio_chunk(output, size, max_size, stream);
218 }
219
220 extern "C" int
221 mpeg3_has_video(zmpeg3_t *zsrc)
222 {
223   return zsrc->has_video();
224 }
225
226 extern "C" int
227 mpeg3_total_vstreams(zmpeg3_t *zsrc)
228 {
229   return zsrc->total_vstreams();
230 }
231
232 extern "C" int
233 mpeg3_video_width(zmpeg3_t *zsrc, int stream)
234 {
235   return zsrc->video_width(stream);
236 }
237
238 extern "C" int
239 mpeg3_video_height(zmpeg3_t *zsrc, int stream)
240 {
241   return zsrc->video_height(stream);
242 }
243
244 extern "C" int
245 mpeg3_coded_width(zmpeg3_t *zsrc, int stream)
246 {
247   return zsrc->coded_width(stream);
248 }
249
250 extern "C" int
251 mpeg3_coded_height(zmpeg3_t *zsrc, int stream)
252 {
253   return zsrc->coded_height(stream);
254 }
255
256 extern "C" int
257 mpeg3_video_pid(zmpeg3_t *zsrc, int stream)
258 {
259   return zsrc->video_pid(stream);
260 }
261
262 extern "C" float
263 mpeg3_aspect_ratio(zmpeg3_t *zsrc, int stream)
264 {
265   return zsrc->aspect_ratio(stream);
266 }
267
268 extern "C" double
269 mpeg3_frame_rate(zmpeg3_t *zsrc, int stream)
270 {
271   return zsrc->frame_rate(stream);
272 }
273
274 extern "C" long
275 mpeg3_video_frames(zmpeg3_t *zsrc, int stream)
276 {
277   return zsrc->video_frames(stream);
278 }
279
280
281 extern "C" int
282 mpeg3_set_frame(zmpeg3_t *zsrc, long frame, int stream)
283 {
284   return zsrc->set_frame(frame, stream);
285 }
286
287 #if 0
288 extern "C" int
289 mpeg3_skip_frames(zmpeg3_t *zsrc)
290 {
291   return zsrc->skip_frames();
292 }
293 #endif
294
295 extern "C" long
296 mpeg3_get_frame(zmpeg3_t *zsrc, int stream)
297 {
298   return zsrc->get_frame(stream);
299 }
300
301 extern "C" int64_t
302 mpeg3_get_bytes(zmpeg3_t *zsrc)
303 {
304   return zsrc->get_bytes();
305 }
306
307 extern "C" int
308 mpeg3_seek_byte(zmpeg3_t *zsrc, int64_t byte)
309 {
310   return zsrc->seek_byte(byte);
311 }
312
313
314 extern "C" int64_t
315 mpeg3_tell_byte(zmpeg3_t *zsrc)
316 {
317   return zsrc->tell_byte();
318 }
319
320 extern "C" int
321 mpeg3_previous_frame(zmpeg3_t *zsrc, int stream)
322 {
323   return zsrc->previous_frame(stream);
324 }
325
326
327 extern "C" int
328 mpeg3_end_of_audio(zmpeg3_t *zsrc, int stream)
329 {
330   return zsrc->end_of_audio(stream);
331 }
332
333
334 extern "C" int
335 mpeg3_end_of_video(zmpeg3_t *zsrc, int stream)
336 {
337   return zsrc->end_of_video(stream);
338 }
339
340 extern "C" double
341 mpeg3_get_time(zmpeg3_t *zsrc)
342 {
343   return zsrc->get_time();
344 }
345
346 extern "C" double
347 mpeg3_get_audio_time(zmpeg3_t* zsrc, int stream)
348 {
349   return zsrc->get_audio_time(stream);
350 }
351
352 extern "C" double
353 mpeg3_get_cell_time(zmpeg3_t *zsrc, int no, double *time)
354 {
355   return zsrc->get_cell_time(no, *time);
356 }
357
358 extern "C" double
359 mpeg3_get_video_time(zmpeg3_t* zsrc, int stream)
360 {
361   return zsrc->get_video_time(stream);
362 }
363
364 extern "C" int
365 mpeg3_read_frame(zmpeg3_t *zsrc, unsigned char **output_rows,
366     int in_x, int in_y, int in_w, int in_h, 
367     int out_w, int out_h, int color_model, int stream)
368 {
369   return zsrc->read_frame(output_rows, in_x, in_y, in_w, in_h,
370     out_w, out_h, color_model, stream);
371 }
372
373 extern "C" int
374 mpeg3_colormodel(zmpeg3_t *zsrc, int stream)
375 {
376   return zsrc->colormodel(stream);
377 }
378
379 extern "C" int
380 mpeg3_set_rowspan(zmpeg3_t *zsrc, int bytes, int stream)
381 {
382   return zsrc->set_rowspan(bytes, stream);
383 }
384
385 extern "C" int
386 mpeg3_read_yuvframe(zmpeg3_t *zsrc,
387     char *y_output, char *u_output, char *v_output,
388     int in_x, int in_y, int in_w, int in_h, int stream)
389 {
390   return zsrc->read_yuvframe(y_output, u_output, v_output,
391     in_x, in_y, in_w, in_h, stream);
392 }
393
394 extern "C" int
395 mpeg3_read_yuvframe_ptr(zmpeg3_t *zsrc,
396     char **y_output, char **u_output, char **v_output, int stream)
397 {
398   return zsrc->read_yuvframe_ptr(y_output, u_output, v_output, stream);
399 }
400
401 extern "C" int
402 mpeg3_drop_frames(zmpeg3_t *zsrc, long frames, int stream)
403 {
404   return zsrc->drop_frames(frames, stream);
405 }
406
407 extern "C" int
408 mpeg3_read_video_chunk(zmpeg3_t *zsrc, unsigned char *output, 
409     long *size, long max_size, int stream)
410 {
411   return zsrc->read_video_chunk(output, size, max_size, stream);
412 }
413
414 extern "C" int
415 mpeg3_get_total_vts_titles(zmpeg3_t *zsrc)
416 {
417   return zsrc->get_total_vts_titles();
418 }
419
420 extern "C" int
421 mpeg3_set_vts_title(zmpeg3_t *zsrc,int title)
422 {
423   return zsrc->set_vts_title(title);
424 }
425
426 extern "C" int
427 mpeg3_get_total_interleaves(zmpeg3_t *zsrc)
428 {
429   return zsrc->get_total_interleaves();
430 }
431
432 extern "C" int
433 mpeg3_set_interleave(zmpeg3_t *zsrc,int no)
434 {
435   return zsrc->set_interleave(no);
436 }
437
438 extern "C" int
439 mpeg3_set_angle(zmpeg3_t *zsrc,int a)
440 {
441   return zsrc->set_angle(a);
442 }
443
444 extern "C" int
445 mpeg3_set_program(zmpeg3_t *zsrc,int no)
446 {
447   return zsrc->set_program(no);
448 }
449
450 extern "C" int64_t
451 mpeg3_memory_usage(zmpeg3_t *zsrc)
452 {
453   return zsrc->memory_usage();
454 }
455
456 extern "C" int
457 mpeg3_get_thumbnail(zmpeg3_t *zsrc,
458   int trk, int64_t *frn, uint8_t **t, int *w, int *h)
459 {
460   return zsrc->get_thumbnail(trk, *frn, *t, *w, *h);
461 }
462
463 extern "C" int
464 mpeg3_set_thumbnail_callback(zmpeg3_t *zsrc, int trk,
465    int skim, int thumb, zthumbnail_cb fn, void *p)
466 {
467   return zsrc->set_thumbnail_callback(trk, skim, thumb, fn, p);
468 }
469
470 extern "C" int
471 mpeg3_set_cc_text_callback(zmpeg3_t *zsrc, int trk, zcc_text_cb fn)
472 {
473   return zsrc->set_cc_text_callback(trk, fn);
474 }
475
476 extern "C" int
477 mpeg3_subtitle_tracks(zmpeg3_t *zsrc)
478 {
479   return zsrc->subtitle_tracks();
480 }
481
482 extern "C" int
483 mpeg3_show_subtitle(zmpeg3_t *zsrc, int vtrk, int strk)
484 {
485   return zsrc->show_subtitle(vtrk, strk);
486 }
487
488 extern "C" int
489 mpeg3_display_subtitle(zmpeg3_t *zsrc, int stream, int sid, int id,
490    uint8_t *yp, uint8_t *up, uint8_t *vp, uint8_t *ap,
491    int x, int y, int w, int h, double start_msecs, double stop_msecs)
492 {
493   return zsrc->display_subtitle(stream, sid, id, yp, up, vp, ap,
494                                 x, y, w, h, start_msecs, stop_msecs);
495 }
496
497 extern "C" int
498 mpeg3_delete_subtitle(zmpeg3_t *zsrc, int stream, int sid, int id)
499 {
500   return zsrc->delete_subtitle(stream, sid, id);
501 }
502
503 extern "C" zmpeg3_t*
504 mpeg3_start_toc(char *path, char *toc_path, int program, int64_t *total_bytes)
505 {
506   return zmpeg3_t::start_toc(path, toc_path, program, total_bytes);
507 }
508
509 extern "C" void
510 mpeg3_set_index_bytes(zmpeg3_t *zsrc, int64_t bytes)
511 {
512   return zsrc->set_index_bytes(bytes);
513 }
514
515 extern "C" int
516 mpeg3_do_toc(zmpeg3_t *zsrc, int64_t *bytes_processed)
517 {
518   return zsrc->do_toc(bytes_processed);
519 }
520
521 extern "C" void
522 mpeg3_stop_toc(zmpeg3_t *zsrc)
523 {
524   return zsrc->stop_toc();
525 }
526
527 extern "C" int64_t
528 mpeg3_get_source_date(zmpeg3_t *zsrc)
529 {
530   return zsrc->get_source_date();
531 }
532
533 extern "C" int64_t
534 mpeg3_calculate_source_date(char *path)
535 {
536   return zmpeg3_t::calculate_source_date(path);
537 }
538
539 extern "C" int
540 mpeg3_index_tracks(zmpeg3_t *zsrc)
541 {
542   return zsrc->index_tracks();
543 }
544
545 extern "C" int
546 mpeg3_index_channels(zmpeg3_t *zsrc, int track)
547 {
548   return zsrc->index_channels(track);
549 }
550
551 extern "C" int
552 mpeg3_index_zoom(zmpeg3_t *zsrc)
553 {
554   return zsrc->index_zoom();
555 }
556
557 extern "C" int
558 mpeg3_index_size(zmpeg3_t *zsrc, int track)
559 {
560   return zsrc->index_size(track);
561 }
562
563 extern "C" float*
564 mpeg3_index_data(zmpeg3_t *zsrc, int track, int channel)
565 {
566   return zsrc->index_data(track, channel);
567 }
568
569 extern "C" int
570 mpeg3_has_toc(zmpeg3_t *zsrc)
571 {
572   return zsrc->has_toc();
573 }
574
575 extern "C" char *
576 mpeg3_title_path(zmpeg3_t *zsrc, int number)
577 {
578   return zsrc->title_path(number);
579 }
580
581 extern "C" int
582 mpeg3_is_program_stream(zmpeg3_t * zsrc)
583 {
584   return zsrc->is_program_stream() ? 1 : 0;
585 }
586
587 extern "C" int
588 mpeg3_is_transport_stream(zmpeg3_t * zsrc)
589 {
590   return zsrc->is_transport_stream() ? 1 : 0;
591 }
592
593 extern "C" int
594 mpeg3_is_video_stream(zmpeg3_t * zsrc)
595 {
596   return zsrc->is_video_stream() ? 1 : 0;
597 }
598
599 extern "C" int
600 mpeg3_is_audio_stream(zmpeg3_t * zsrc)
601 {
602   return zsrc->is_audio_stream() ? 1 : 0;
603 }
604
605 extern "C" int
606 mpeg3_is_ifo_file(zmpeg3_t * zsrc)
607 {
608   return zsrc->is_ifo_file() ? 1 : 0;
609 }
610
611 extern "C" int
612 mpeg3_create_title(zmpeg3_t * zsrc, int full_scan)
613 {
614   return zsrc->demuxer->create_title(full_scan);
615 }
616
617 extern "C" int
618 mpeg3audio_dolayer3(mpeg3_layer_t *zaudio,
619    char *frame, int frame_size, float **output, int render)
620 {
621   zaudio_decoder_layer_t *audio = (zaudio_decoder_layer_t *)zaudio;
622   return audio->do_layer3((uint8_t*)frame, frame_size, output, render);
623 }
624
625 extern "C" void
626 mpeg3_layer_reset(mpeg3_layer_t *zlayer_data)
627 {
628   zaudio_decoder_layer_t *layer_data = (zaudio_decoder_layer_t *)zlayer_data;
629   layer_data->layer_reset();
630 }
631
632 extern "C" int
633 mpeg3_layer_header(mpeg3_layer_t *zlayer_data, unsigned char *data)
634 {
635   zaudio_decoder_layer_t *layer_data = (zaudio_decoder_layer_t *)zlayer_data;
636   return layer_data->layer3_header(data);
637 }
638
639 extern "C" mpeg3_layer_t*
640 mpeg3_new_layer()
641 {
642   return (mpeg3_layer_t*) new zaudio_decoder_layer_t();
643 }
644
645 extern "C" void
646 mpeg3_delete_layer(mpeg3_layer_t *zaudio)
647 {
648   zaudio_decoder_layer_t *audio = (zaudio_decoder_layer_t *)zaudio;
649   delete audio;
650 }
651
652 extern "C" void
653 mpeg3_skip_video_frame(mpeg3_t *zsrc,int stream)
654 {
655   zsrc->vtrack[stream]->demuxer->skip_video_frame();
656 }
657
658 extern "C" int64_t
659 mpeg3_video_tell_byte(mpeg3_t *zsrc, int stream)
660 {
661   return zsrc->vtrack[stream]->demuxer->absolute_position();
662 }
663
664 extern "C" int64_t
665 mpeg3_audio_tell_byte(mpeg3_t *zsrc, int stream)
666 {
667   return zsrc->atrack[stream]->demuxer->absolute_position();
668 }
669
670 #ifdef ZDVB
671
672 extern "C" int
673 mpeg3_dvb_channel_count(zmpeg3_t *zsrc)
674 {
675   if( !zsrc->dvb.mgt )
676         zsrc->demuxer->create_title();
677   return zsrc->dvb.channel_count();
678 }
679
680 extern "C" int
681 mpeg3_dvb_get_channel(zmpeg3_t *zsrc,int n, int *major, int *minor)
682 {
683   return zsrc->dvb.get_channel(n, *major, *minor);
684 }
685
686 extern "C" int
687 mpeg3_dvb_get_station_id(zmpeg3_t *zsrc,int n, char *name)
688 {
689   return zsrc->dvb.get_station_id(n, name);
690 }
691
692 extern "C" int
693 mpeg3_dvb_total_astreams(zmpeg3_t *zsrc,int n, int *count)
694 {
695   return zsrc->dvb.total_astreams(n, *count);
696 }
697
698 extern "C" int
699 mpeg3_dvb_astream_number(zmpeg3_t *zsrc,int n, int ord, int *stream, char *enc)
700 {
701   return zsrc->dvb.astream_number(n, ord, *stream, enc);
702 }
703
704 extern "C" int
705 mpeg3_dvb_total_vstreams(zmpeg3_t *zsrc,int n, int *count)
706 {
707   return zsrc->dvb.total_vstreams(n, *count);
708 }
709
710 extern "C" int
711 mpeg3_dvb_vstream_number(zmpeg3_t *zsrc,int n, int ord, int *stream)
712 {
713   return zsrc->dvb.vstream_number(n, ord, *stream);
714 }
715
716 extern "C" int
717 mpeg3_dvb_get_chan_info(mpeg3_t *zsrc,int n, int ord, int i, char *cp, int len)
718 {
719   return zsrc->dvb.get_chan_info(n, ord, i, cp, len);
720 }
721
722 int mpeg3_dvb_get_system_time(mpeg3_t *zsrc, int64_t *tm)
723 {
724   return (*tm=zsrc->dvb.get_system_time()) >= 0 ? 0 : 1;
725 }
726
727 #endif
728