r1051: Resources window: Keep the divider inside the window.
[cinelerra_cv.git] / libmpeg3 / libmpeg3.h
blob22a3890792504acb976e1036851692a87614fc68
1 #ifndef LIBMPEG3_H
2 #define LIBMPEG3_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 // FIXME: don't include private definitions in external header
9 #include "mpeg3private.h"
12 /* Supported color models for mpeg3_read_frame */
13 #define MPEG3_RGB565 2
14 #define MPEG3_BGR888 0
15 #define MPEG3_BGRA8888 1
16 #define MPEG3_RGB888 3
17 #define MPEG3_RGBA8888 4
18 #define MPEG3_RGBA16161616 5
20 /* Color models for the 601 to RGB conversion */
21 /* 601 not implemented for scalar code */
22 #define MPEG3_601_RGB565 11
23 #define MPEG3_601_BGR888 7
24 #define MPEG3_601_BGRA8888 8
25 #define MPEG3_601_RGB888 9
26 #define MPEG3_601_RGBA8888 10
28 /* Supported color models for mpeg3_read_yuvframe */
29 #define MPEG3_YUV420P 12
30 #define MPEG3_YUV422P 13
33 /* Error codes for the error_return variable */
34 #define MPEG3_UNDEFINED_ERROR 1
35 #define MPEG3_INVALID_TOC_VERSION 2
36 #define MPEG3_TOC_DATE_MISMATCH 3
38 /* Get version information */
39 int mpeg3_major();
40 int mpeg3_minor();
41 int mpeg3_release();
44 /* Check for file compatibility. Return 1 if compatible. */
45 int mpeg3_check_sig(char *path);
47 /* Open the MPEG stream. */
48 /* An error code is put into *error_return if it fails and error_return is nonzero. */
49 mpeg3_t* mpeg3_open(char *path, int *error_return);
51 /* Open the MPEG stream and copy the tables from an already open stream. */
52 /* Eliminates some initial scanning and is used for opening audio streams. */
53 /* An error code is put into *error_return if it fails and error_return is nonzero. */
54 mpeg3_t* mpeg3_open_copy(char *path, mpeg3_t *old_file, int *error_return);
55 int mpeg3_close(mpeg3_t *file);
60 /* Performance */
61 int mpeg3_set_cpus(mpeg3_t *file, int cpus);
63 /* Query the MPEG3 stream about audio. */
64 int mpeg3_has_audio(mpeg3_t *file);
65 int mpeg3_total_astreams(mpeg3_t *file); /* Number of multiplexed audio streams */
66 int mpeg3_audio_channels(mpeg3_t *file, int stream);
67 int mpeg3_sample_rate(mpeg3_t *file, int stream);
68 char* mpeg3_audio_format(mpeg3_t *file, int stream);
70 /* Total length obtained from the timecode. */
71 /* For DVD files, this is unreliable. */
72 long mpeg3_audio_samples(mpeg3_t *file, int stream);
73 int mpeg3_set_sample(mpeg3_t *file, long sample, int stream); /* Seek to a sample */
74 long mpeg3_get_sample(mpeg3_t *file, int stream); /* Tell current position */
76 /* Read a PCM buffer of audio from 1 channel and advance the position. */
77 /* Return a 1 if error. */
78 /* Stream defines the number of the multiplexed stream to read. */
79 /* If both output arguments are null the audio is not rendered. */
80 int mpeg3_read_audio(mpeg3_t *file,
81 float *output_f, /* Pointer to pre-allocated buffer of floats */
82 short *output_i, /* Pointer to pre-allocated buffer of int16's */
83 int channel, /* Channel to decode */
84 long samples, /* Number of samples to decode */
85 int stream); /* Stream containing the channel */
87 /* Reread the last PCM buffer from a different channel and advance the position */
88 int mpeg3_reread_audio(mpeg3_t *file,
89 float *output_f, /* Pointer to pre-allocated buffer of floats */
90 short *output_i, /* Pointer to pre-allocated buffer of int16's */
91 int channel, /* Channel to decode */
92 long samples, /* Number of samples to decode */
93 int stream); /* Stream containing the channel */
95 /* Read the next compressed audio chunk. Store the size in size and return a */
96 /* 1 if error. */
97 /* Stream defines the number of the multiplexed stream to read. */
98 int mpeg3_read_audio_chunk(mpeg3_t *file,
99 unsigned char *output,
100 long *size,
101 long max_size,
102 int stream);
104 /* Query the stream about video. */
105 int mpeg3_has_video(mpeg3_t *file);
106 int mpeg3_total_vstreams(mpeg3_t *file); /* Number of multiplexed video streams */
107 int mpeg3_video_width(mpeg3_t *file, int stream);
108 int mpeg3_video_height(mpeg3_t *file, int stream);
109 float mpeg3_aspect_ratio(mpeg3_t *file, int stream); /* aspect ratio. 0 if none */
110 double mpeg3_frame_rate(mpeg3_t *file, int stream); /* Frames/sec */
113 /* Total length. */
114 /* This is meaningless except for TOC files. */
115 long mpeg3_video_frames(mpeg3_t *file, int stream);
116 int mpeg3_set_frame(mpeg3_t *file, long frame, int stream); /* Seek to a frame */
117 int mpeg3_skip_frames();
118 long mpeg3_get_frame(mpeg3_t *file, int stream); /* Tell current position */
120 /* Total bytes. Used for absolute byte seeking. */
121 int64_t mpeg3_get_bytes(mpeg3_t *file);
123 /* Seek all the tracks to the absolute byte in the */
124 /* file. This eliminates the need for tocs but doesn't */
125 /* give frame accuracy. */
126 int mpeg3_seek_byte(mpeg3_t *file, int64_t byte);
127 int64_t mpeg3_tell_byte(mpeg3_t *file);
130 /* To synchronize audio and video in percentage seeking mode, these must */
131 /* be called after percentage seeking the video file and before */
132 /* percentage seeking the audio file. Then when the audio file is percentage */
133 /* seeked it will search for the nearest pts to file->percentage_pts. */
135 * double mpeg3_get_percentage_pts(mpeg3_t *file);
136 * void mpeg3_set_percentage_pts(mpeg3_t *file, double pts);
139 int mpeg3_previous_frame(mpeg3_t *file, int stream);
140 int mpeg3_end_of_audio(mpeg3_t *file, int stream);
141 int mpeg3_end_of_video(mpeg3_t *file, int stream);
143 /* Give the seconds time in the last packet read */
144 double mpeg3_get_time(mpeg3_t *file);
146 /* Read a frame. The dimensions of the input area and output frame must be supplied. */
147 /* The frame is taken from the input area and scaled to fit the output frame in 1 step. */
148 /* Stream defines the number of the multiplexed stream to read. */
149 /* The last row of **output_rows must contain 4 extra bytes for scratch work. */
150 int mpeg3_read_frame(mpeg3_t *file,
151 unsigned char **output_rows, /* Array of pointers to the start of each output row */
152 int in_x, /* Location in input frame to take picture */
153 int in_y,
154 int in_w,
155 int in_h,
156 int out_w, /* Dimensions of output_rows */
157 int out_h,
158 int color_model, /* One of the color model #defines */
159 int stream);
161 /* Get the colormodel being used natively by the stream */
162 int mpeg3_colormodel(mpeg3_t *file, int stream);
163 /* Set the row stride to be used in mpeg3_read_yuvframe */
164 int mpeg3_set_rowspan(mpeg3_t *file, int bytes, int stream);
166 /* Read a frame in the native color model used by the stream. */
167 /* The Y, U, and V planes are copied into the y, u, and v */
168 /* buffers provided. */
169 /* The input is cropped to the dimensions given but not scaled. */
170 int mpeg3_read_yuvframe(mpeg3_t *file,
171 char *y_output,
172 char *u_output,
173 char *v_output,
174 int in_x,
175 int in_y,
176 int in_w,
177 int in_h,
178 int stream);
180 /* Read a frame in the native color model used by the stream. */
181 /* The Y, U, and V planes are not copied but the _output pointers */
182 /* are redirected to the frame buffer. */
183 int mpeg3_read_yuvframe_ptr(mpeg3_t *file,
184 char **y_output,
185 char **u_output,
186 char **v_output,
187 int stream);
189 /* Drop frames number of frames */
190 int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream);
192 /* Read the next compressed frame including headers. */
193 /* Store the size in size and return a 1 if error. */
194 /* Stream defines the number of the multiplexed stream to read. */
195 int mpeg3_read_video_chunk(mpeg3_t *file,
196 unsigned char *output,
197 long *size,
198 long max_size,
199 int stream);
201 /* Master control */
202 int mpeg3_total_programs();
203 int mpeg3_set_program(int program);
205 /* Memory used by video caches. */
206 int64_t mpeg3_memory_usage(mpeg3_t *file);
214 /* subtitle functions */
215 /* get number of subtitle tracks */
216 int mpeg3_subtitle_tracks(mpeg3_t *file);
217 /* Enable overlay of a subtitle track. */
218 /* track - the number of the subtitle track starting from 0 */
219 /* The same subtitle track is overlayed for all video tracks. */
220 /* Pass -1 to disable subtitles. */
221 void mpeg3_show_subtitle(mpeg3_t *file, int track);
230 /* Table of contents generation */
231 /* Begin constructing table of contents */
232 mpeg3_t* mpeg3_start_toc(char *path, char *toc_path, int64_t *total_bytes);
233 /* Set the maximum number of bytes per index track */
234 void mpeg3_set_index_bytes(mpeg3_t *file, int64_t bytes);
235 /* Process one packet */
236 int mpeg3_do_toc(mpeg3_t *file, int64_t *bytes_processed);
237 /* Write table of contents */
238 void mpeg3_stop_toc(mpeg3_t *file);
240 /* Get modification date of source file from table of contents. */
241 /* Used to compare DVD source file to table of contents source. */
242 int64_t mpeg3_get_source_date(mpeg3_t *file);
243 /* Get modification date of source file from source file. */
244 int64_t mpeg3_calculate_source_date(char *path);
251 /* Table of contents queries */
252 /* Return number of tracks in the table of contents */
253 int mpeg3_index_tracks(mpeg3_t *file);
254 /* Return number of channels in track */
255 int mpeg3_index_channels(mpeg3_t *file, int track);
256 /* Return zoom factor of index */
257 int mpeg3_index_zoom(mpeg3_t *file);
258 /* Number of high/low pairs in a channel of the track */
259 int mpeg3_index_size(mpeg3_t *file, int track);
260 /* Get data for one index channel */
261 float* mpeg3_index_data(mpeg3_t *file, int track, int channel);
262 /* Returns 1 if the file has a table of contents */
263 int mpeg3_has_toc(mpeg3_t *file);
264 /* Return the path of the title number or 0 if no more titles. */
265 char* mpeg3_title_path(mpeg3_t *file, int number);
268 #ifdef __cplusplus
270 #endif
272 #endif