r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / libmpeg3 / mpeg3vtrack.c
blobb41867397ebf967498caf8992f869cfbb459a837
1 #include "libmpeg3.h"
2 #include "mpeg3protos.h"
4 #include <stdlib.h>
6 mpeg3_vtrack_t* mpeg3_new_vtrack(mpeg3_t *file,
7 int stream_id,
8 mpeg3_demuxer_t *demuxer,
9 int number)
11 int result = 0;
12 mpeg3_vtrack_t *new_vtrack;
14 //printf("mpeg3_new_vtrack 1\n");
15 new_vtrack = calloc(1, sizeof(mpeg3_vtrack_t));
16 new_vtrack->demuxer = mpeg3_new_demuxer(file, 0, 1, stream_id);
17 if(new_vtrack->demuxer) mpeg3demux_copy_titles(new_vtrack->demuxer, demuxer);
18 new_vtrack->current_position = 0;
20 //printf("mpeg3_new_vtrack 10\n");
21 // Copy pointers
22 if(file->frame_offsets)
24 new_vtrack->frame_offsets = file->frame_offsets[number];
25 new_vtrack->total_frame_offsets = file->total_frame_offsets[number];
26 new_vtrack->keyframe_numbers = file->keyframe_numbers[number];
27 new_vtrack->total_keyframe_numbers = file->total_keyframe_numbers[number];
30 //printf("mpeg3_new_vtrack 20\n");
31 //printf("mpeg3_new_vtrack %llx\n", mpeg3demux_tell(new_vtrack->demuxer));
32 /* Get information about the track here. */
33 new_vtrack->video = mpeg3video_new(file, new_vtrack);
34 if(!new_vtrack->video)
36 /* Failed */
37 mpeg3_delete_vtrack(file, new_vtrack);
38 new_vtrack = 0;
41 //printf("mpeg3_new_vtrack 100\n");
43 return new_vtrack;
46 int mpeg3_delete_vtrack(mpeg3_t *file, mpeg3_vtrack_t *vtrack)
48 if(vtrack->video) mpeg3video_delete(vtrack->video);
49 if(vtrack->demuxer) mpeg3_delete_demuxer(vtrack->demuxer);
50 free(vtrack);
51 return 0;