r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / libmpeg3 / libmpeg3.h
blob1ddb104c2b281d10852cba2f74b1d831bafc1f0a
1 #ifndef LIBMPEG3_H
2 #define LIBMPEG3_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #include "mpeg3private.h"
11 /* Supported color models for mpeg3_read_frame */
12 #define MPEG3_RGB565 2
13 #define MPEG3_BGR888 0
14 #define MPEG3_BGRA8888 1
15 #define MPEG3_RGB888 3
16 #define MPEG3_RGBA8888 4
17 #define MPEG3_RGBA16161616 5
19 /* Color models for the 601 to RGB conversion */
20 /* 601 not implemented for scalar code */
21 #define MPEG3_601_RGB565 11
22 #define MPEG3_601_BGR888 7
23 #define MPEG3_601_BGRA8888 8
24 #define MPEG3_601_RGB888 9
25 #define MPEG3_601_RGBA8888 10
27 /* Supported color models for mpeg3_read_yuvframe */
28 #define MPEG3_YUV420P 12
29 #define MPEG3_YUV422P 13
34 /* Get version information */
35 int mpeg3_major();
36 int mpeg3_minor();
37 int mpeg3_release();
40 /* Check for file compatibility. Return 1 if compatible. */
41 int mpeg3_check_sig(char *path);
43 /* Open the MPEG3 stream. */
44 mpeg3_t* mpeg3_open(char *path);
46 /* Open the MPEG3 stream and copy the tables from an already open stream. */
47 /* Eliminates the initial timecode search. */
48 mpeg3_t* mpeg3_open_copy(char *path, mpeg3_t *old_file);
49 int mpeg3_close(mpeg3_t *file);
54 /* Performance */
55 int mpeg3_set_cpus(mpeg3_t *file, int cpus);
56 int mpeg3_set_mmx(mpeg3_t *file, int use_mmx);
58 /* Query the MPEG3 stream about audio. */
59 int mpeg3_has_audio(mpeg3_t *file);
60 int mpeg3_total_astreams(mpeg3_t *file); /* Number of multiplexed audio streams */
61 int mpeg3_audio_channels(mpeg3_t *file, int stream);
62 int mpeg3_sample_rate(mpeg3_t *file, int stream);
63 char* mpeg3_audio_format(mpeg3_t *file, int stream);
65 /* Total length obtained from the timecode. */
66 /* For DVD files, this is unreliable. */
67 long mpeg3_audio_samples(mpeg3_t *file, int stream);
68 int mpeg3_set_sample(mpeg3_t *file, long sample, int stream); /* Seek to a sample */
69 long mpeg3_get_sample(mpeg3_t *file, int stream); /* Tell current position */
71 /* Read a PCM buffer of audio from 1 channel and advance the position. */
72 /* Return a 1 if error. */
73 /* Stream defines the number of the multiplexed stream to read. */
74 /* If both output arguments are null the audio is not rendered. */
75 int mpeg3_read_audio(mpeg3_t *file,
76 float *output_f, /* Pointer to pre-allocated buffer of floats */
77 short *output_i, /* Pointer to pre-allocated buffer of int16's */
78 int channel, /* Channel to decode */
79 long samples, /* Number of samples to decode */
80 int stream); /* Stream containing the channel */
82 /* Reread the last PCM buffer from a different channel and advance the position */
83 int mpeg3_reread_audio(mpeg3_t *file,
84 float *output_f, /* Pointer to pre-allocated buffer of floats */
85 short *output_i, /* Pointer to pre-allocated buffer of int16's */
86 int channel, /* Channel to decode */
87 long samples, /* Number of samples to decode */
88 int stream); /* Stream containing the channel */
90 /* Read the next compressed audio chunk. Store the size in size and return a */
91 /* 1 if error. */
92 /* Stream defines the number of the multiplexed stream to read. */
93 int mpeg3_read_audio_chunk(mpeg3_t *file,
94 unsigned char *output,
95 long *size,
96 long max_size,
97 int stream);
99 /* Query the stream about video. */
100 int mpeg3_has_video(mpeg3_t *file);
101 int mpeg3_total_vstreams(mpeg3_t *file); /* Number of multiplexed video streams */
102 int mpeg3_video_width(mpeg3_t *file, int stream);
103 int mpeg3_video_height(mpeg3_t *file, int stream);
104 float mpeg3_aspect_ratio(mpeg3_t *file, int stream); /* aspect ratio. 0 if none */
105 double mpeg3_frame_rate(mpeg3_t *file, int stream); /* Frames/sec */
107 /* Total length. */
108 /* For DVD files, this is 1 indicating only percentage seeking is available. */
109 long mpeg3_video_frames(mpeg3_t *file, int stream);
110 int mpeg3_set_frame(mpeg3_t *file, long frame, int stream); /* Seek to a frame */
111 int mpeg3_skip_frames();
112 long mpeg3_get_frame(mpeg3_t *file, int stream); /* Tell current position */
114 /* Seek all the tracks based on a percentage of the total bytes in the */
115 /* file or the total */
116 /* time in a toc if one exists. Percentage is a 0 to 1 double. */
117 /* This eliminates the need for tocs and 64 bit longs but doesn't */
118 /* give frame accuracy. */
119 int mpeg3_seek_percentage(mpeg3_t *file, double percentage);
120 double mpeg3_tell_percentage(mpeg3_t *file);
122 /* To synchronize audio and video in percentage seeking mode, these must */
123 /* be called after percentage seeking the video file and before */
124 /* percentage seeking the audio file. Then when the audio file is percentage */
125 /* seeked it will search for the nearest pts to file->percentage_pts. */
126 double mpeg3_get_percentage_pts(mpeg3_t *file);
127 void mpeg3_set_percentage_pts(mpeg3_t *file, double pts);
129 int mpeg3_previous_frame(mpeg3_t *file, int stream);
130 int mpeg3_end_of_audio(mpeg3_t *file, int stream);
131 int mpeg3_end_of_video(mpeg3_t *file, int stream);
133 /* Give the seconds time in the last packet read */
134 double mpeg3_get_time(mpeg3_t *file);
136 /* Read a frame. The dimensions of the input area and output frame must be supplied. */
137 /* The frame is taken from the input area and scaled to fit the output frame in 1 step. */
138 /* Stream defines the number of the multiplexed stream to read. */
139 /* The last row of **output_rows must contain 4 extra bytes for scratch work. */
140 int mpeg3_read_frame(mpeg3_t *file,
141 unsigned char **output_rows, /* Array of pointers to the start of each output row */
142 int in_x, /* Location in input frame to take picture */
143 int in_y,
144 int in_w,
145 int in_h,
146 int out_w, /* Dimensions of output_rows */
147 int out_h,
148 int color_model, /* One of the color model #defines */
149 int stream);
151 /* Get the colormodel being used natively by the stream */
152 int mpeg3_colormodel(mpeg3_t *file, int stream);
153 /* Set the row stride to be used in mpeg3_read_yuvframe */
154 int mpeg3_set_rowspan(mpeg3_t *file, int bytes, int stream);
156 /* Read a frame in the native color model used by the stream. */
157 /* The Y, U, and V planes are copied into the y, u, and v */
158 /* buffers provided. */
159 /* The input is cropped to the dimensions given but not scaled. */
160 int mpeg3_read_yuvframe(mpeg3_t *file,
161 char *y_output,
162 char *u_output,
163 char *v_output,
164 int in_x,
165 int in_y,
166 int in_w,
167 int in_h,
168 int stream);
170 /* Read a frame in the native color model used by the stream. */
171 /* The Y, U, and V planes are not copied but the _output pointers */
172 /* are redirected to the frame buffer. */
173 int mpeg3_read_yuvframe_ptr(mpeg3_t *file,
174 char **y_output,
175 char **u_output,
176 char **v_output,
177 int stream);
179 /* Drop frames number of frames */
180 int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream);
182 /* Read the next compressed frame including headers. */
183 /* Store the size in size and return a 1 if error. */
184 /* Stream defines the number of the multiplexed stream to read. */
185 int mpeg3_read_video_chunk(mpeg3_t *file,
186 unsigned char *output,
187 long *size,
188 long max_size,
189 int stream);
191 /* Master control */
192 int mpeg3_total_programs();
193 int mpeg3_set_program(int program);
195 #ifdef __cplusplus
197 #endif
199 #endif