r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / libmpeg3 / libmpeg3.h
blobdbf9029f80d3d89abf73e5ed11cb2cf1c6743583
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 /* This is meaningless except for TOC files. */
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 /* Total bytes. Used for absolute byte seeking. */
115 int64_t mpeg3_get_bytes(mpeg3_t *file);
117 /* Seek all the tracks to the absolute byte in the */
118 /* file. This eliminates the need for tocs but doesn't */
119 /* give frame accuracy. */
120 int mpeg3_seek_byte(mpeg3_t *file, int64_t byte);
121 int64_t mpeg3_tell_byte(mpeg3_t *file);
124 /* To synchronize audio and video in percentage seeking mode, these must */
125 /* be called after percentage seeking the video file and before */
126 /* percentage seeking the audio file. Then when the audio file is percentage */
127 /* seeked it will search for the nearest pts to file->percentage_pts. */
129 * double mpeg3_get_percentage_pts(mpeg3_t *file);
130 * void mpeg3_set_percentage_pts(mpeg3_t *file, double pts);
133 int mpeg3_previous_frame(mpeg3_t *file, int stream);
134 int mpeg3_end_of_audio(mpeg3_t *file, int stream);
135 int mpeg3_end_of_video(mpeg3_t *file, int stream);
137 /* Give the seconds time in the last packet read */
138 double mpeg3_get_time(mpeg3_t *file);
140 /* Read a frame. The dimensions of the input area and output frame must be supplied. */
141 /* The frame is taken from the input area and scaled to fit the output frame in 1 step. */
142 /* Stream defines the number of the multiplexed stream to read. */
143 /* The last row of **output_rows must contain 4 extra bytes for scratch work. */
144 int mpeg3_read_frame(mpeg3_t *file,
145 unsigned char **output_rows, /* Array of pointers to the start of each output row */
146 int in_x, /* Location in input frame to take picture */
147 int in_y,
148 int in_w,
149 int in_h,
150 int out_w, /* Dimensions of output_rows */
151 int out_h,
152 int color_model, /* One of the color model #defines */
153 int stream);
155 /* Get the colormodel being used natively by the stream */
156 int mpeg3_colormodel(mpeg3_t *file, int stream);
157 /* Set the row stride to be used in mpeg3_read_yuvframe */
158 int mpeg3_set_rowspan(mpeg3_t *file, int bytes, int stream);
160 /* Read a frame in the native color model used by the stream. */
161 /* The Y, U, and V planes are copied into the y, u, and v */
162 /* buffers provided. */
163 /* The input is cropped to the dimensions given but not scaled. */
164 int mpeg3_read_yuvframe(mpeg3_t *file,
165 char *y_output,
166 char *u_output,
167 char *v_output,
168 int in_x,
169 int in_y,
170 int in_w,
171 int in_h,
172 int stream);
174 /* Read a frame in the native color model used by the stream. */
175 /* The Y, U, and V planes are not copied but the _output pointers */
176 /* are redirected to the frame buffer. */
177 int mpeg3_read_yuvframe_ptr(mpeg3_t *file,
178 char **y_output,
179 char **u_output,
180 char **v_output,
181 int stream);
183 /* Drop frames number of frames */
184 int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream);
186 /* Read the next compressed frame including headers. */
187 /* Store the size in size and return a 1 if error. */
188 /* Stream defines the number of the multiplexed stream to read. */
189 int mpeg3_read_video_chunk(mpeg3_t *file,
190 unsigned char *output,
191 long *size,
192 long max_size,
193 int stream);
195 /* Master control */
196 int mpeg3_total_programs();
197 int mpeg3_set_program(int program);
199 #ifdef __cplusplus
201 #endif
203 #endif