r1005: Increase the number of displayed digits for resample audio dialog box
[cinelerra_cv/mob.git] / libmpeg3 / libmpeg3.c
blob697e590cd051ea13b7f68242d27a3e8208286491
1 #include "libmpeg3.h"
2 #include "mpeg3private.h"
3 #include "mpeg3protos.h"
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
8 #include <string.h>
11 int mpeg3_major()
13 return MPEG3_MAJOR;
16 int mpeg3_minor()
18 return MPEG3_MINOR;
21 int mpeg3_release()
23 return MPEG3_RELEASE;
28 mpeg3_t* mpeg3_new(char *path)
30 int i;
31 mpeg3_t *file = calloc(1, sizeof(mpeg3_t));
32 file->cpus = 1;
33 file->fs = mpeg3_new_fs(path);
34 // Late compilers don't produce usable code.
35 file->demuxer = mpeg3_new_demuxer(file, 0, 0, -1);
36 file->seekable = 1;
37 file->index_bytes = 0x300000;
38 file->subtitle_track = -1;
39 return file;
42 mpeg3_index_t* mpeg3_new_index()
44 mpeg3_index_t *index = calloc(1, sizeof(mpeg3_index_t));
45 index->index_zoom = 1;
46 return index;
49 void mpeg3_delete_index(mpeg3_index_t *index)
51 int i;
52 for(i = 0;i < index->index_channels; i++)
53 free(index->index_data[i]);
54 free(index->index_data);
55 free(index);
58 int mpeg3_delete(mpeg3_t *file)
60 int i;
61 const int debug = 0;
63 if(debug) printf("mpeg3_delete 1\n");
64 for(i = 0; i < file->total_vstreams; i++)
65 mpeg3_delete_vtrack(file, file->vtrack[i]);
66 if(debug) printf("mpeg3_delete 2\n");
68 for(i = 0; i < file->total_astreams; i++)
69 mpeg3_delete_atrack(file, file->atrack[i]);
71 for(i = 0; i < file->total_sstreams; i++)
72 mpeg3_delete_strack(file->strack[i]);
75 if(debug) printf("mpeg3_delete 3\n");
76 mpeg3_delete_fs(file->fs);
77 mpeg3_delete_demuxer(file->demuxer);
79 if(debug) printf("mpeg3_delete 4\n");
80 if(file->frame_offsets)
82 for(i = 0; i < file->total_vstreams; i++)
84 free(file->frame_offsets[i]);
85 free(file->keyframe_numbers[i]);
88 if(debug) printf("mpeg3_delete 5\n");
89 free(file->frame_offsets);
90 free(file->keyframe_numbers);
91 free(file->total_frame_offsets);
92 free(file->total_keyframe_numbers);
95 if(debug) printf("mpeg3_delete 6\n");
96 if(file->sample_offsets)
98 for(i = 0; i < file->total_astreams; i++)
99 free(file->sample_offsets[i]);
101 free(file->sample_offsets);
102 free(file->total_sample_offsets);
105 if(debug) printf("mpeg3_delete 7\n");
107 if(file->channel_counts)
108 free(file->channel_counts);
110 if(file->audio_eof)
111 free(file->audio_eof);
113 if(debug) printf("mpeg3_delete 8\n");
114 if(file->indexes)
116 for(i = 0; i < file->total_indexes; i++)
117 mpeg3_delete_index(file->indexes[i]);
118 if(debug) printf("mpeg3_delete 9\n");
120 free(file->indexes);
123 if(debug) printf("mpeg3_delete 10\n");
124 free(file);
125 if(debug) printf("mpeg3_delete 11\n");
126 return 0;
129 int mpeg3_check_sig(char *path)
131 mpeg3_fs_t *fs;
132 u_int32_t bits, bits2;
133 char *ext;
134 int result = 0;
136 fs = mpeg3_new_fs(path);
137 if(mpeg3io_open_file(fs))
139 /* File not found */
140 return 0;
143 bits = mpeg3io_read_int32(fs);
144 bits2 = mpeg3io_read_int32(fs);
145 ext = strrchr(path, '.');
146 /* Test header */
147 if(bits == MPEG3_TOC_PREFIX)
149 result = 1;
151 else
152 if(((bits2 >> 24) & 0xff) == MPEG3_SYNC_BYTE &&
153 ext &&
154 !strncasecmp(ext, ".m2ts", 5))
156 result = 1;
158 else
159 if((((bits >> 24) & 0xff) == MPEG3_SYNC_BYTE) ||
160 (bits == MPEG3_PACK_START_CODE) ||
161 ((bits & 0xfff00000) == 0xfff00000) ||
162 ((bits & 0xffff0000) == 0xffe30000) ||
163 (bits == MPEG3_SEQUENCE_START_CODE) ||
164 (bits == MPEG3_PICTURE_START_CODE) ||
165 (((bits & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE) ||
166 ((bits >> 8) == MPEG3_ID3_PREFIX) ||
167 (bits == MPEG3_RIFF_CODE) ||
168 (bits == MPEG3_IFO_PREFIX))
170 result = 1;
172 if(ext)
174 /* Test file extension. */
175 if(strncasecmp(ext, ".ifo", 4) &&
176 strncasecmp(ext, ".mp2", 4) &&
177 strncasecmp(ext, ".mp3", 4) &&
178 strncasecmp(ext, ".m1v", 4) &&
179 strncasecmp(ext, ".m2v", 4) &&
180 strncasecmp(ext, ".m2s", 4) &&
181 strncasecmp(ext, ".mpg", 4) &&
182 strncasecmp(ext, ".vob", 4) &&
183 strncasecmp(ext, ".mpeg", 4) &&
184 strncasecmp(ext, ".m2t", 4) &&
185 strncasecmp(ext, ".ac3", 4))
186 result = 0;
190 mpeg3io_close_file(fs);
191 mpeg3_delete_fs(fs);
192 return result;
204 static int is_toc(uint32_t bits)
206 return (bits == MPEG3_TOC_PREFIX);
210 static int is_ifo(uint32_t bits)
212 return (bits == MPEG3_IFO_PREFIX);
215 static int is_transport(uint32_t bits)
217 return (((bits >> 24) & 0xff) == MPEG3_SYNC_BYTE);
220 static int is_bd(uint32_t bits1, uint32_t bits2)
222 return (((bits2 >> 24) & 0xff) == MPEG3_SYNC_BYTE);
225 static int is_program(uint32_t bits)
227 return (bits == MPEG3_PACK_START_CODE);
230 static int is_mpeg_audio(uint32_t bits)
232 return (bits & 0xfff00000) == 0xfff00000 ||
233 (bits & 0xffff0000) == 0xffe30000 ||
234 ((bits >> 8) == MPEG3_ID3_PREFIX) ||
235 (bits == MPEG3_RIFF_CODE);
238 static int is_mpeg_video(uint32_t bits)
240 return (bits == MPEG3_SEQUENCE_START_CODE ||
241 bits == MPEG3_PICTURE_START_CODE);
244 static int is_ac3(uint32_t bits)
246 return (((bits & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE);
249 static int calculate_packet_size(int is_transport,
250 int is_program,
251 int is_audio,
252 int is_video,
253 int is_bd)
255 if(is_transport)
257 if(is_bd)
258 return MPEG3_BD_PACKET_SIZE;
259 else
260 return MPEG3_TS_PACKET_SIZE;
262 else
263 if(is_program)
264 return 0;
265 else
266 if(is_audio)
267 return MPEG3_DVD_PACKET_SIZE;
268 else
269 if(is_video)
270 return MPEG3_DVD_PACKET_SIZE;
275 int mpeg3_get_file_type(mpeg3_t *file,
276 mpeg3_t *old_file,
277 int *toc_atracks,
278 int *toc_vtracks)
280 uint32_t bits = mpeg3io_read_int32(file->fs);
281 uint32_t bits2 = mpeg3io_read_int32(file->fs);
282 int result = 0;
284 if(old_file) file->is_bd = old_file->is_bd;
286 /* TOC */
287 if(is_toc(bits))
289 /* Table of contents for another title set */
290 if(!old_file)
292 if(toc_atracks && toc_vtracks)
294 if((result = mpeg3_read_toc(file, toc_atracks, toc_vtracks)))
296 mpeg3io_close_file(file->fs);
297 return result;
300 else
302 mpeg3io_close_file(file->fs);
303 return 1;
306 mpeg3io_close_file(file->fs);
308 else
309 /* IFO file */
310 if(is_ifo(bits))
312 if(!old_file)
314 file->is_program_stream = 1;
315 if(mpeg3_read_ifo(file, 0))
317 mpeg3io_close_file(file->fs);
318 return 1;
321 file->is_ifo_file = 1;
322 mpeg3io_close_file(file->fs);
324 else
325 if(is_bd(bits, bits2))
327 file->is_bd = 1;
328 file->is_transport_stream = 1;
330 else
331 if(is_transport(bits))
333 /* Transport stream */
334 file->is_transport_stream = 1;
336 else
337 if(is_program(bits))
339 /* Program stream */
340 /* Determine packet size empirically */
341 file->is_program_stream = 1;
343 else
344 if(is_mpeg_audio(bits))
346 /* MPEG Audio only */
347 file->is_audio_stream = 1;
349 else
350 if(is_mpeg_video(bits))
352 /* Video only */
353 file->is_video_stream = 1;
355 else
356 if(is_ac3(bits))
358 /* AC3 Audio only */
359 file->is_audio_stream = 1;
361 else
363 fprintf(stderr, "mpeg3_get_file_type: not a readable stream.\n");
364 return 1;
368 * printf("mpeg3_get_file_type 2 %p %d %d %d %d\n",
369 * old_file,
370 * file->is_transport_stream,
371 * file->is_program_stream,
372 * file->is_video_stream,
373 * file->is_audio_stream);
377 file->packet_size = calculate_packet_size(file->is_transport_stream,
378 file->is_program_stream,
379 file->is_audio_stream,
380 file->is_video_stream,
381 file->is_bd);
383 return 0;
387 static void copy_subtitles(mpeg3_t *file, mpeg3_t *old_file)
389 int i, j;
390 file->total_sstreams = old_file->total_sstreams;
391 for(i = 0; i < file->total_sstreams; i++)
393 file->strack[i] = mpeg3_new_strack(old_file->strack[i]->id);
394 mpeg3_copy_strack(file->strack[i], old_file->strack[i]);
397 memcpy(file->palette, old_file->palette, 16 * 4);
398 file->have_palette = old_file->have_palette;
402 mpeg3_t* mpeg3_open_copy(char *path, mpeg3_t *old_file, int *error_return)
404 mpeg3_t *file = 0;
405 int i, done;
406 int result = 0;
407 /* The table of contents may have fewer tracks than are in the demuxer */
408 /* This limits the track count */
409 int toc_atracks = 0x7fffffff;
410 int toc_vtracks = 0x7fffffff;
413 /* Initialize the file structure */
414 file = mpeg3_new(path);
417 /* Need to perform authentication before reading a single byte. */
418 if(mpeg3io_open_file(file->fs))
420 mpeg3_delete(file);
421 return 0;
428 /* =============================== Create the title objects ========================= */
429 if((*error_return = mpeg3_get_file_type(file,
430 old_file,
431 &toc_atracks,
432 &toc_vtracks)))
434 mpeg3_delete(file);
435 return 0;
448 /* Create titles */
449 /* Copy data from an old file */
450 if(old_file && mpeg3_get_demuxer(old_file))
452 mpeg3demux_copy_titles(file->demuxer, mpeg3_get_demuxer(old_file));
453 copy_subtitles(file, old_file);
455 file->is_transport_stream = old_file->is_transport_stream;
456 file->is_program_stream = old_file->is_program_stream;
457 file->is_bd = old_file->is_bd;
458 file->source_date = old_file->source_date;
460 else
461 /* Start from scratch */
462 if(!file->demuxer->total_titles)
464 mpeg3_create_title(file->demuxer, 0);
479 /* Generate tracks */
480 if(file->is_transport_stream || file->is_program_stream)
482 /* Create video tracks */
483 for(i = 0;
484 i < MPEG3_MAX_STREAMS && file->total_vstreams < toc_vtracks;
485 i++)
487 if(file->demuxer->vstream_table[i])
489 file->vtrack[file->total_vstreams] =
490 mpeg3_new_vtrack(file,
492 file->demuxer,
493 file->total_vstreams);
494 if(file->vtrack[file->total_vstreams])
495 file->total_vstreams++;
500 /* Create audio tracks */
501 for(i = 0; i < MPEG3_MAX_STREAMS && file->total_astreams < toc_atracks; i++)
503 if(file->demuxer->astream_table[i])
505 file->atrack[file->total_astreams] = mpeg3_new_atrack(file,
507 file->demuxer->astream_table[i],
508 file->demuxer,
509 file->total_astreams);
510 if(file->atrack[file->total_astreams]) file->total_astreams++;
514 else
515 if(file->is_video_stream)
517 /* Create video tracks */
518 file->vtrack[0] = mpeg3_new_vtrack(file,
519 -1,
520 file->demuxer,
522 if(file->vtrack[0]) file->total_vstreams++;
524 else
525 if(file->is_audio_stream)
527 /* Create audio tracks */
529 file->atrack[0] = mpeg3_new_atrack(file,
530 -1,
531 AUDIO_UNKNOWN,
532 file->demuxer,
534 if(file->atrack[0]) file->total_astreams++;
541 mpeg3io_close_file(file->fs);
543 return file;
546 mpeg3_t* mpeg3_open(char *path, int *error_return)
548 return mpeg3_open_copy(path, 0, error_return);
551 int mpeg3_close(mpeg3_t *file)
553 /* File is closed in the same procedure it is opened in. */
554 mpeg3_delete(file);
555 return 0;
558 int mpeg3_set_cpus(mpeg3_t *file, int cpus)
560 int i;
561 file->cpus = cpus;
562 for(i = 0; i < file->total_vstreams; i++)
563 mpeg3video_set_cpus(file->vtrack[i]->video, cpus);
564 return 0;
567 int mpeg3_has_audio(mpeg3_t *file)
569 return file->total_astreams > 0;
572 int mpeg3_total_astreams(mpeg3_t *file)
574 return file->total_astreams;
577 int mpeg3_audio_channels(mpeg3_t *file,
578 int stream)
580 if(file->total_astreams)
581 return file->atrack[stream]->channels;
582 return -1;
585 int mpeg3_sample_rate(mpeg3_t *file,
586 int stream)
588 if(file->total_astreams)
589 return file->atrack[stream]->sample_rate;
590 return -1;
593 long mpeg3_get_sample(mpeg3_t *file,
594 int stream)
596 if(file->total_astreams)
597 return file->atrack[stream]->current_position;
598 return -1;
601 int mpeg3_set_sample(mpeg3_t *file,
602 long sample,
603 int stream)
605 if(file->total_astreams)
607 //printf(__FUNCTION__ " 1 %d %d\n", file->atrack[stream]->current_position, sample);
608 file->atrack[stream]->current_position = sample;
609 mpeg3audio_seek_sample(file->atrack[stream]->audio, sample);
610 return 0;
612 return -1;
615 long mpeg3_audio_samples(mpeg3_t *file,
616 int stream)
618 if(file->total_astreams)
619 return file->atrack[stream]->total_samples;
620 return -1;
623 char* mpeg3_audio_format(mpeg3_t *file, int stream)
625 if(stream < file->total_astreams)
627 switch(file->atrack[stream]->format)
629 case AUDIO_UNKNOWN: return "Unknown"; break;
630 case AUDIO_MPEG: return "MPEG"; break;
631 case AUDIO_AC3: return "AC3"; break;
632 case AUDIO_PCM: return "PCM"; break;
633 case AUDIO_AAC: return "AAC"; break;
634 case AUDIO_JESUS: return "Vorbis"; break;
637 return "";
640 int mpeg3_has_video(mpeg3_t *file)
642 return file->total_vstreams > 0;
645 int mpeg3_total_vstreams(mpeg3_t *file)
647 return file->total_vstreams;
650 int mpeg3_video_width(mpeg3_t *file,
651 int stream)
653 if(file->total_vstreams)
654 return file->vtrack[stream]->width;
655 return -1;
658 int mpeg3_video_height(mpeg3_t *file,
659 int stream)
661 if(file->total_vstreams)
662 return file->vtrack[stream]->height;
663 return -1;
666 float mpeg3_aspect_ratio(mpeg3_t *file, int stream)
668 if(file->total_vstreams)
669 return file->vtrack[stream]->aspect_ratio;
670 return 0;
673 double mpeg3_frame_rate(mpeg3_t *file,
674 int stream)
676 if(file->total_vstreams)
677 return file->vtrack[stream]->frame_rate;
678 return -1;
681 long mpeg3_video_frames(mpeg3_t *file,
682 int stream)
684 if(file->total_vstreams)
685 return file->vtrack[stream]->total_frames;
686 return -1;
689 long mpeg3_get_frame(mpeg3_t *file,
690 int stream)
692 if(file->total_vstreams)
693 return file->vtrack[stream]->current_position;
694 return -1;
697 int mpeg3_set_frame(mpeg3_t *file,
698 long frame,
699 int stream)
701 if(file->total_vstreams)
703 file->vtrack[stream]->current_position = frame;
704 mpeg3video_seek_frame(file->vtrack[stream]->video, frame);
705 return 0;
707 return -1;
710 int mpeg3_seek_byte(mpeg3_t *file, int64_t byte)
712 int i;
714 // file->percentage_pts = -1;
715 for(i = 0; i < file->total_vstreams; i++)
717 file->vtrack[i]->current_position = 0;
718 mpeg3video_seek_byte(file->vtrack[i]->video, byte);
721 for(i = 0; i < file->total_astreams; i++)
723 file->atrack[i]->current_position = 0;
724 mpeg3audio_seek_byte(file->atrack[i]->audio, byte);
727 return 0;
731 * double mpeg3_get_percentage_pts(mpeg3_t *file)
733 * return file->percentage_pts;
736 * void mpeg3_set_percentage_pts(mpeg3_t *file, double pts)
742 int mpeg3_previous_frame(mpeg3_t *file, int stream)
744 file->last_type_read = 2;
745 file->last_stream_read = stream;
747 if(file->total_vstreams)
748 return mpeg3video_previous_frame(file->vtrack[stream]->video);
750 return 0;
753 int64_t mpeg3_tell_byte(mpeg3_t *file)
755 int64_t result = 0;
756 if(file->last_type_read == 1)
758 result = mpeg3demux_tell_byte(file->atrack[file->last_stream_read]->demuxer);
761 if(file->last_type_read == 2)
763 result = mpeg3demux_tell_byte(file->vtrack[file->last_stream_read]->demuxer);
765 return result;
768 int64_t mpeg3_get_bytes(mpeg3_t *file)
770 return mpeg3demux_movie_size(file->demuxer);
773 double mpeg3_get_time(mpeg3_t *file)
775 double atime = 0, vtime = 0;
777 if(file->is_transport_stream || file->is_program_stream)
779 /* Timecode only available in transport stream */
780 if(file->last_type_read == 1)
782 atime = mpeg3demux_get_time(file->atrack[file->last_stream_read]->demuxer);
784 else
785 if(file->last_type_read == 2)
787 vtime = mpeg3demux_get_time(file->vtrack[file->last_stream_read]->demuxer);
790 else
792 /* Use percentage and total time */
793 if(file->total_astreams)
795 atime = mpeg3demux_tell_byte(file->atrack[0]->demuxer) *
796 mpeg3_audio_samples(file, 0) /
797 mpeg3_sample_rate(file, 0) /
798 mpeg3_get_bytes(file);
801 if(file->total_vstreams)
803 vtime = mpeg3demux_tell_byte(file->vtrack[0]->demuxer) *
804 mpeg3_video_frames(file, 0) /
805 mpeg3_frame_rate(file, 0) /
806 mpeg3_get_bytes(file);
810 return MAX(atime, vtime);
813 int mpeg3_end_of_audio(mpeg3_t *file, int stream)
815 int result = 0;
816 if(!file->atrack[stream]->channels) return 1;
817 result = mpeg3demux_eof(file->atrack[stream]->demuxer);
818 return result;
821 int mpeg3_end_of_video(mpeg3_t *file, int stream)
823 int result = 0;
824 result = mpeg3demux_eof(file->vtrack[stream]->demuxer);
825 return result;
829 int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream)
831 int result = -1;
833 if(file->total_vstreams)
835 result = mpeg3video_drop_frames(file->vtrack[stream]->video,
836 frames,
838 if(frames > 0) file->vtrack[stream]->current_position += frames;
839 file->last_type_read = 2;
840 file->last_stream_read = stream;
842 return result;
845 int mpeg3_colormodel(mpeg3_t *file, int stream)
847 if(file->total_vstreams)
849 return mpeg3video_colormodel(file->vtrack[stream]->video);
851 return 0;
854 int mpeg3_set_rowspan(mpeg3_t *file, int bytes, int stream)
856 if(file->total_vstreams)
858 file->vtrack[stream]->video->row_span = bytes;
860 return 0;
864 int mpeg3_read_frame(mpeg3_t *file,
865 unsigned char **output_rows,
866 int in_x,
867 int in_y,
868 int in_w,
869 int in_h,
870 int out_w,
871 int out_h,
872 int color_model,
873 int stream)
875 int result = -1;
876 //printf("mpeg3_read_frame 1 %d\n", file->vtrack[stream]->current_position);
878 if(file->total_vstreams)
880 result = mpeg3video_read_frame(file->vtrack[stream]->video,
881 output_rows,
882 in_x,
883 in_y,
884 in_w,
885 in_h,
886 out_w,
887 out_h,
888 color_model);
889 //printf(__FUNCTION__ " 2\n");
890 file->last_type_read = 2;
891 file->last_stream_read = stream;
892 file->vtrack[stream]->current_position++;
895 //printf("mpeg3_read_frame 2 %d\n", file->vtrack[stream]->current_position);
896 return result;
899 int mpeg3_read_yuvframe(mpeg3_t *file,
900 char *y_output,
901 char *u_output,
902 char *v_output,
903 int in_x,
904 int in_y,
905 int in_w,
906 int in_h,
907 int stream)
909 int result = -1;
911 //printf("mpeg3_read_yuvframe 1\n");
912 if(file->total_vstreams)
914 result = mpeg3video_read_yuvframe(file->vtrack[stream]->video,
915 y_output,
916 u_output,
917 v_output,
918 in_x,
919 in_y,
920 in_w,
921 in_h);
922 file->last_type_read = 2;
923 file->last_stream_read = stream;
924 file->vtrack[stream]->current_position++;
926 //printf("mpeg3_read_yuvframe 100\n");
927 return result;
930 int mpeg3_read_yuvframe_ptr(mpeg3_t *file,
931 char **y_output,
932 char **u_output,
933 char **v_output,
934 int stream)
936 int result = -1;
938 if(file->total_vstreams)
940 result = mpeg3video_read_yuvframe_ptr(file->vtrack[stream]->video,
941 y_output,
942 u_output,
943 v_output);
944 file->last_type_read = 2;
945 file->last_stream_read = stream;
946 file->vtrack[stream]->current_position++;
948 return result;
951 int mpeg3_read_audio(mpeg3_t *file,
952 float *output_f,
953 short *output_i,
954 int channel,
955 long samples,
956 int stream)
958 int result = -1;
960 if(file->total_astreams)
962 result = mpeg3audio_decode_audio(file->atrack[stream]->audio,
963 output_f,
964 output_i,
965 channel,
966 samples);
967 file->last_type_read = 1;
968 file->last_stream_read = stream;
969 file->atrack[stream]->current_position += samples;
972 return result;
975 int mpeg3_reread_audio(mpeg3_t *file,
976 float *output_f,
977 short *output_i,
978 int channel,
979 long samples,
980 int stream)
982 if(file->total_astreams)
984 mpeg3_set_sample(file,
985 file->atrack[stream]->current_position - samples,
986 stream);
987 file->last_type_read = 1;
988 file->last_stream_read = stream;
989 return mpeg3_read_audio(file,
990 output_f,
991 output_i,
992 channel,
993 samples,
994 stream);
996 return -1;
999 int mpeg3_read_audio_chunk(mpeg3_t *file,
1000 unsigned char *output,
1001 long *size,
1002 long max_size,
1003 int stream)
1005 int result = 0;
1006 if(file->total_astreams)
1008 result = mpeg3audio_read_raw(file->atrack[stream]->audio,
1009 output,
1010 size,
1011 max_size);
1012 file->last_type_read = 1;
1013 file->last_stream_read = stream;
1015 return result;
1018 int mpeg3_read_video_chunk(mpeg3_t *file,
1019 unsigned char *output,
1020 long *size,
1021 long max_size,
1022 int stream)
1024 int result = 0;
1025 if(file->total_vstreams)
1027 result = mpeg3video_read_raw(file->vtrack[stream]->video,
1028 output,
1029 size,
1030 max_size);
1031 file->last_type_read = 2;
1032 file->last_stream_read = stream;
1034 return result;
1039 int64_t mpeg3_memory_usage(mpeg3_t *file)
1041 int i;
1042 int64_t result = 0;
1043 for(i = 0; i < file->total_vstreams; i++)
1045 result += mpeg3_cache_usage(file->vtrack[i]->frame_cache);
1047 return result;