| 1 | # Ogg Declarations |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2006,2007,2008 PySoy Group |
|---|
| 4 | # |
|---|
| 5 | # This program is free software; you can redistribute it and/or modify |
|---|
| 6 | # it under the terms of the GNU Affero General Public License as published |
|---|
| 7 | # by the Free Software Foundation, either version 3 of the License, or |
|---|
| 8 | # (at your option) any later version. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU Affero General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU Affero General Public License |
|---|
| 16 | # along with this program; if not, see http://www.gnu.org/licenses |
|---|
| 17 | # |
|---|
| 18 | # $Id$ |
|---|
| 19 | |
|---|
| 20 | cdef extern from "ogg/ogg.h" nogil : |
|---|
| 21 | ctypedef short ogg_int16_t |
|---|
| 22 | ctypedef unsigned short ogg_uint16_t |
|---|
| 23 | ctypedef int ogg_int32_t |
|---|
| 24 | ctypedef unsigned int ogg_uint32_t |
|---|
| 25 | ctypedef long ogg_int64_t |
|---|
| 26 | |
|---|
| 27 | ctypedef struct oggpack_buffer : |
|---|
| 28 | long endbyte |
|---|
| 29 | int endbit |
|---|
| 30 | unsigned char *buffer |
|---|
| 31 | unsigned char *ptr |
|---|
| 32 | long storage |
|---|
| 33 | |
|---|
| 34 | ctypedef struct ogg_page : |
|---|
| 35 | unsigned char *header |
|---|
| 36 | long header_len |
|---|
| 37 | unsigned char *body |
|---|
| 38 | long body_len |
|---|
| 39 | |
|---|
| 40 | ctypedef struct ogg_stream_state : |
|---|
| 41 | unsigned char *body_data |
|---|
| 42 | long body_storage |
|---|
| 43 | long body_fill |
|---|
| 44 | long body_returned |
|---|
| 45 | int *lacing_vals |
|---|
| 46 | ogg_int64_t *granule_vals |
|---|
| 47 | long lacing_storage |
|---|
| 48 | long lacing_fill |
|---|
| 49 | long lacing_packet |
|---|
| 50 | long lacing_returned |
|---|
| 51 | unsigned char header[282] |
|---|
| 52 | int header_fill |
|---|
| 53 | int e_o_s |
|---|
| 54 | int b_o_s |
|---|
| 55 | long serialno |
|---|
| 56 | long pageno |
|---|
| 57 | ogg_int64_t packetno |
|---|
| 58 | ogg_int64_t granulepos |
|---|
| 59 | |
|---|
| 60 | ctypedef struct ogg_packet : |
|---|
| 61 | unsigned char *packet |
|---|
| 62 | long bytes |
|---|
| 63 | long b_o_s |
|---|
| 64 | long e_o_s |
|---|
| 65 | ogg_int64_t granulepos |
|---|
| 66 | ogg_int64_t packetno |
|---|
| 67 | |
|---|
| 68 | ctypedef struct ogg_sync_state : |
|---|
| 69 | unsigned char *data |
|---|
| 70 | int storage |
|---|
| 71 | int fill |
|---|
| 72 | int returned |
|---|
| 73 | int unsynced |
|---|
| 74 | int header |
|---|
| 75 | int body |
|---|
| 76 | |
|---|
| 77 | cdef void oggpack_writeinit ( oggpack_buffer* ) |
|---|
| 78 | cdef void oggpack_writetrunc ( oggpack_buffer*, long ) |
|---|
| 79 | cdef void oggpack_writealign ( oggpack_buffer* ) |
|---|
| 80 | cdef void oggpack_writecopy ( oggpack_buffer*, void*, long ) |
|---|
| 81 | cdef void oggpack_reset ( oggpack_buffer* ) |
|---|
| 82 | cdef void oggpack_writeclear ( oggpack_buffer* ) |
|---|
| 83 | cdef void oggpack_readinit ( oggpack_buffer*, unsigned char*, int ) |
|---|
| 84 | cdef void oggpack_write ( oggpack_buffer*, unsigned long, int ) |
|---|
| 85 | cdef long oggpack_look ( oggpack_buffer*, int ) |
|---|
| 86 | cdef long oggpack_look1 ( oggpack_buffer* ) |
|---|
| 87 | cdef void oggpack_adv ( oggpack_buffer*, int ) |
|---|
| 88 | cdef void oggpack_adv1 ( oggpack_buffer* ) |
|---|
| 89 | cdef long oggpack_read ( oggpack_buffer*, int ) |
|---|
| 90 | cdef long oggpack_read1 ( oggpack_buffer* ) |
|---|
| 91 | cdef long oggpack_bytes ( oggpack_buffer* ) |
|---|
| 92 | cdef long oggpack_bits ( oggpack_buffer* ) |
|---|
| 93 | cdef unsigned char *oggpack_get_buffer ( oggpack_buffer* ) |
|---|
| 94 | |
|---|
| 95 | cdef void oggpackB_writeinit ( oggpack_buffer* ) |
|---|
| 96 | cdef void oggpackB_writetrunc ( oggpack_buffer*, long ) |
|---|
| 97 | cdef void oggpackB_writealign ( oggpack_buffer* ) |
|---|
| 98 | cdef void oggpackB_writecopy ( oggpack_buffer*, void*, long ) |
|---|
| 99 | cdef void oggpackB_reset ( oggpack_buffer* ) |
|---|
| 100 | cdef void oggpackB_writeclear ( oggpack_buffer* ) |
|---|
| 101 | cdef void oggpackB_readinit ( oggpack_buffer*, unsigned char*, int ) |
|---|
| 102 | cdef void oggpackB_write ( oggpack_buffer*, unsigned long, int ) |
|---|
| 103 | cdef long oggpackB_look ( oggpack_buffer*, int ) |
|---|
| 104 | cdef long oggpackB_look1 ( oggpack_buffer* ) |
|---|
| 105 | cdef void oggpackB_adv ( oggpack_buffer*, int ) |
|---|
| 106 | cdef void oggpackB_adv1 ( oggpack_buffer* ) |
|---|
| 107 | cdef long oggpackB_read ( oggpack_buffer*, int ) |
|---|
| 108 | cdef long oggpackB_read1 ( oggpack_buffer* ) |
|---|
| 109 | cdef long oggpackB_bytes ( oggpack_buffer* ) |
|---|
| 110 | cdef long oggpackB_bits ( oggpack_buffer* ) |
|---|
| 111 | cdef unsigned char *oggpackB_get_buffer ( oggpack_buffer* ) |
|---|
| 112 | |
|---|
| 113 | cdef int ogg_stream_packetin ( ogg_stream_state*, ogg_packet* ) |
|---|
| 114 | cdef int ogg_stream_pageout ( ogg_stream_state*, ogg_page* ) |
|---|
| 115 | cdef int ogg_stream_flush ( ogg_stream_state*, ogg_page* ) |
|---|
| 116 | |
|---|
| 117 | cdef int ogg_sync_init ( ogg_sync_state* ) |
|---|
| 118 | cdef int ogg_sync_clear ( ogg_sync_state* ) |
|---|
| 119 | cdef int ogg_sync_reset ( ogg_sync_state* ) |
|---|
| 120 | cdef int ogg_sync_destroy ( ogg_sync_state* ) |
|---|
| 121 | |
|---|
| 122 | cdef char *ogg_sync_buffer ( ogg_sync_state*, long ) |
|---|
| 123 | cdef int ogg_sync_wrote ( ogg_sync_state*, long ) |
|---|
| 124 | cdef long ogg_sync_pageseek ( ogg_sync_state*, ogg_page* ) |
|---|
| 125 | cdef int ogg_sync_pageout ( ogg_sync_state*, ogg_page* ) |
|---|
| 126 | cdef int ogg_stream_pagein ( ogg_stream_state*, ogg_page* ) |
|---|
| 127 | cdef int ogg_stream_packetout ( ogg_stream_state*, ogg_packet* ) |
|---|
| 128 | cdef int ogg_stream_packetpeek ( ogg_stream_state*, ogg_packet* ) |
|---|
| 129 | |
|---|
| 130 | cdef int ogg_stream_init ( ogg_stream_state*, int ) |
|---|
| 131 | cdef int ogg_stream_clear ( ogg_stream_state* ) |
|---|
| 132 | cdef int ogg_stream_reset ( ogg_stream_state* ) |
|---|
| 133 | cdef int ogg_stream_reset_serialno ( ogg_stream_state*, int ) |
|---|
| 134 | cdef int ogg_stream_destroy ( ogg_stream_state* ) |
|---|
| 135 | cdef int ogg_stream_eos ( ogg_stream_state* ) |
|---|
| 136 | |
|---|
| 137 | cdef void ogg_page_checksum_set ( ogg_page* ) |
|---|
| 138 | cdef int ogg_page_version ( ogg_page* ) |
|---|
| 139 | cdef int ogg_page_continued ( ogg_page* ) |
|---|
| 140 | cdef int ogg_page_bos ( ogg_page* ) |
|---|
| 141 | cdef int ogg_page_eos ( ogg_page* ) |
|---|
| 142 | cdef int ogg_page_serialno ( ogg_page* ) |
|---|
| 143 | cdef long ogg_page_pageno ( ogg_page* ) |
|---|
| 144 | cdef int ogg_page_packets ( ogg_page* ) |
|---|
| 145 | cdef ogg_int64_t ogg_page_granulepos ( ogg_page* ) |
|---|
| 146 | cdef void ogg_packet_clear ( ogg_packet* ) |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | cdef extern from "vorbis/codec.h" nogil : |
|---|
| 150 | ctypedef enum : |
|---|
| 151 | OV_FALSE |
|---|
| 152 | OV_EOF |
|---|
| 153 | OV_HOLE |
|---|
| 154 | OV_EREAD |
|---|
| 155 | OV_EFAULT |
|---|
| 156 | OV_EIMPL |
|---|
| 157 | OV_EINVAL |
|---|
| 158 | OV_ENOTVORBIS |
|---|
| 159 | OV_EBADHEADER |
|---|
| 160 | OV_EVERSION |
|---|
| 161 | OV_ENOTAUDIO |
|---|
| 162 | OV_EBADPACKET |
|---|
| 163 | OV_EBADLINK |
|---|
| 164 | OV_ENOSEEK |
|---|
| 165 | |
|---|
| 166 | cdef struct vorbis_info : |
|---|
| 167 | int version |
|---|
| 168 | int channels |
|---|
| 169 | long rate |
|---|
| 170 | long bitrate_upper |
|---|
| 171 | long bitrate_nominal |
|---|
| 172 | long bitrate_lower |
|---|
| 173 | long bitrate_window |
|---|
| 174 | void *codec_setup |
|---|
| 175 | |
|---|
| 176 | cdef struct vorbis_dsp_state : |
|---|
| 177 | int analysisp |
|---|
| 178 | vorbis_info *vi |
|---|
| 179 | float **pcm |
|---|
| 180 | float **pcmret |
|---|
| 181 | int pcm_storage |
|---|
| 182 | int pcm_current |
|---|
| 183 | int pcm_returned |
|---|
| 184 | int preextrapolate |
|---|
| 185 | int eofflag |
|---|
| 186 | long lW |
|---|
| 187 | long W |
|---|
| 188 | long nW |
|---|
| 189 | long centerW |
|---|
| 190 | ogg_int64_t granulepos |
|---|
| 191 | ogg_int64_t sequence |
|---|
| 192 | ogg_int64_t glue_bits |
|---|
| 193 | ogg_int64_t time_bits |
|---|
| 194 | ogg_int64_t floor_bits |
|---|
| 195 | ogg_int64_t res_bits |
|---|
| 196 | void *backend_state |
|---|
| 197 | |
|---|
| 198 | cdef struct alloc_chain : |
|---|
| 199 | void *ptr |
|---|
| 200 | alloc_chain *next |
|---|
| 201 | |
|---|
| 202 | cdef struct vorbis_block : |
|---|
| 203 | float **pcm |
|---|
| 204 | oggpack_buffer opb |
|---|
| 205 | long lW |
|---|
| 206 | long W |
|---|
| 207 | long nW |
|---|
| 208 | int pcmend |
|---|
| 209 | int mode |
|---|
| 210 | int eofflag |
|---|
| 211 | ogg_int64_t granulepos |
|---|
| 212 | ogg_int64_t sequence |
|---|
| 213 | vorbis_dsp_state *vd |
|---|
| 214 | void *localstore |
|---|
| 215 | long localtop |
|---|
| 216 | long localalloc |
|---|
| 217 | long totaluse |
|---|
| 218 | alloc_chain *reap |
|---|
| 219 | long glue_bits |
|---|
| 220 | long time_bits |
|---|
| 221 | long floor_bits |
|---|
| 222 | long res_bits |
|---|
| 223 | void *internal |
|---|
| 224 | |
|---|
| 225 | cdef struct vorbis_comment : |
|---|
| 226 | char **user_comments |
|---|
| 227 | int *comment_lengths |
|---|
| 228 | int comments |
|---|
| 229 | char *vendor |
|---|
| 230 | |
|---|
| 231 | cdef void vorbis_info_init ( vorbis_info* ) |
|---|
| 232 | cdef void vorbis_info_clear ( vorbis_info* ) |
|---|
| 233 | cdef int vorbis_info_blocksize ( vorbis_info*, int ) |
|---|
| 234 | cdef void vorbis_comment_init ( vorbis_comment* ) |
|---|
| 235 | cdef void vorbis_comment_add ( vorbis_comment*, char* ) |
|---|
| 236 | cdef void vorbis_comment_add_tag ( vorbis_comment*, char*, char* ) |
|---|
| 237 | cdef char *vorbis_comment_query ( vorbis_comment*, char*, int ) |
|---|
| 238 | cdef int vorbis_comment_query_count ( vorbis_comment*, char* ) |
|---|
| 239 | cdef void vorbis_comment_clear ( vorbis_comment* ) |
|---|
| 240 | cdef int vorbis_block_init ( vorbis_dsp_state*, vorbis_block* ) |
|---|
| 241 | cdef int vorbis_block_clear ( vorbis_block* ) |
|---|
| 242 | cdef void vorbis_dsp_clear ( vorbis_dsp_state* ) |
|---|
| 243 | cdef double vorbis_granule_time ( vorbis_dsp_state*, ogg_int64_t ) |
|---|
| 244 | cdef int vorbis_analysis_init ( vorbis_dsp_state*, vorbis_info* ) |
|---|
| 245 | cdef int vorbis_commentheader_out ( vorbis_comment*, ogg_packet* ) |
|---|
| 246 | cdef int vorbis_analysis_headerout ( vorbis_dsp_state*, |
|---|
| 247 | vorbis_comment*, ogg_packet*, |
|---|
| 248 | ogg_packet*, ogg_packet* ) |
|---|
| 249 | cdef float **vorbis_analysis_buffer ( vorbis_dsp_state*, int ) |
|---|
| 250 | cdef int vorbis_analysis_wrote ( vorbis_dsp_state*, int ) |
|---|
| 251 | cdef int vorbis_analysis_blockout ( vorbis_dsp_state*, vorbis_block* ) |
|---|
| 252 | cdef int vorbis_analysis ( vorbis_block*, ogg_packet* ) |
|---|
| 253 | cdef int vorbis_bitrate_addblock ( vorbis_block* ) |
|---|
| 254 | cdef int vorbis_bitrate_flushpacket ( vorbis_dsp_state*, ogg_packet* ) |
|---|
| 255 | cdef int vorbis_synthesis_headerin ( vorbis_info*, vorbis_comment*, |
|---|
| 256 | ogg_packet* ) |
|---|
| 257 | cdef int vorbis_synthesis_init ( vorbis_dsp_state*, vorbis_info* ) |
|---|
| 258 | cdef int vorbis_synthesis_restart ( vorbis_dsp_state* ) |
|---|
| 259 | cdef int vorbis_synthesis ( vorbis_block*, ogg_packet* ) |
|---|
| 260 | cdef int vorbis_synthesis_trackonly ( vorbis_block*, ogg_packet* ) |
|---|
| 261 | cdef int vorbis_synthesis_blockin ( vorbis_dsp_state*, vorbis_block* ) |
|---|
| 262 | cdef int vorbis_synthesis_pcmout ( vorbis_dsp_state*, float*** ) |
|---|
| 263 | cdef int vorbis_synthesis_lapout ( vorbis_dsp_state*, float*** ) |
|---|
| 264 | cdef int vorbis_synthesis_read ( vorbis_dsp_state*, int ) |
|---|
| 265 | cdef long vorbis_packet_blocksize ( vorbis_info*, ogg_packet* ) |
|---|
| 266 | cdef int vorbis_synthesis_halfrate ( vorbis_info*, int ) |
|---|
| 267 | cdef int vorbis_synthesis_halfrate_p( vorbis_info *v ) |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | cdef extern from "theora/theora.h" nogil : |
|---|
| 271 | ctypedef enum : |
|---|
| 272 | OC_FAULT |
|---|
| 273 | OC_EINVAL |
|---|
| 274 | OC_DISABLED |
|---|
| 275 | OC_BADHEADER |
|---|
| 276 | OC_NOTFORMAT |
|---|
| 277 | OC_VERSION |
|---|
| 278 | OC_IMPL |
|---|
| 279 | OC_BADPACKET |
|---|
| 280 | OC_NEWPACKET |
|---|
| 281 | OC_DUPFRAME |
|---|
| 282 | |
|---|
| 283 | ctypedef enum theora_colorspace : |
|---|
| 284 | OC_CS_UNSPECIFIED, |
|---|
| 285 | OC_CS_ITU_REC_470M, |
|---|
| 286 | OC_CS_ITU_REC_470BG, |
|---|
| 287 | OC_CS_NSPACES |
|---|
| 288 | |
|---|
| 289 | ctypedef enum theora_pixelformat : |
|---|
| 290 | OC_PF_420, |
|---|
| 291 | OC_PF_RSVD, |
|---|
| 292 | OC_PF_422, |
|---|
| 293 | OC_PF_444, |
|---|
| 294 | |
|---|
| 295 | ctypedef struct yuv_buffer : |
|---|
| 296 | int y_width |
|---|
| 297 | int y_height |
|---|
| 298 | int y_stride |
|---|
| 299 | int uv_width |
|---|
| 300 | int uv_height |
|---|
| 301 | int uv_stride |
|---|
| 302 | unsigned char *y |
|---|
| 303 | unsigned char *u |
|---|
| 304 | unsigned char *v |
|---|
| 305 | |
|---|
| 306 | ctypedef struct theora_info : |
|---|
| 307 | ogg_uint32_t width |
|---|
| 308 | ogg_uint32_t height |
|---|
| 309 | ogg_uint32_t frame_width |
|---|
| 310 | ogg_uint32_t frame_height |
|---|
| 311 | ogg_uint32_t offset_x |
|---|
| 312 | ogg_uint32_t offset_y |
|---|
| 313 | ogg_uint32_t fps_numerator |
|---|
| 314 | ogg_uint32_t fps_denominator |
|---|
| 315 | ogg_uint32_t aspect_numerator |
|---|
| 316 | ogg_uint32_t aspect_denominator |
|---|
| 317 | theora_colorspace colorspace |
|---|
| 318 | int target_bitrate |
|---|
| 319 | int quality |
|---|
| 320 | int quick_p |
|---|
| 321 | unsigned char version_major |
|---|
| 322 | unsigned char version_minor |
|---|
| 323 | unsigned char version_subminor |
|---|
| 324 | void *codec_setup |
|---|
| 325 | int dropframes_p |
|---|
| 326 | int keyframe_auto_p |
|---|
| 327 | ogg_uint32_t keyframe_frequency |
|---|
| 328 | ogg_uint32_t keyframe_frequency_force |
|---|
| 329 | ogg_uint32_t keyframe_data_target_bitrate |
|---|
| 330 | ogg_int32_t keyframe_auto_threshold |
|---|
| 331 | ogg_uint32_t keyframe_mindistance |
|---|
| 332 | ogg_int32_t noise_sensitivity |
|---|
| 333 | ogg_int32_t sharpness |
|---|
| 334 | theora_pixelformat pixelformat |
|---|
| 335 | |
|---|
| 336 | ctypedef struct theora_state : |
|---|
| 337 | theora_info *i |
|---|
| 338 | ogg_int64_t granulepos |
|---|
| 339 | void *internal_encode |
|---|
| 340 | void *internal_decode |
|---|
| 341 | |
|---|
| 342 | cdef struct theora_comment : |
|---|
| 343 | char **user_comments |
|---|
| 344 | int *_lengths |
|---|
| 345 | int comments |
|---|
| 346 | char *vendor |
|---|
| 347 | |
|---|
| 348 | cdef char *theora_version_string ( ) |
|---|
| 349 | cdef ogg_uint32_t theora_version_number( ) |
|---|
| 350 | cdef int theora_encode_init ( theora_state*, theora_info* ) |
|---|
| 351 | cdef int theora_encode_YUVin ( theora_state*, yuv_buffer* ) |
|---|
| 352 | cdef int theora_encode_packetout ( theora_state*, int, ogg_packet* ) |
|---|
| 353 | cdef int theora_encode_header ( theora_state*, ogg_packet* ) |
|---|
| 354 | cdef int theora_encode_comment ( theora_comment*, ogg_packet* ) |
|---|
| 355 | cdef int theora_encode_tables ( theora_state*, ogg_packet* ) |
|---|
| 356 | cdef int theora_decode_header ( theora_info*, theora_comment*, |
|---|
| 357 | ogg_packet* ) |
|---|
| 358 | cdef int theora_decode_init ( theora_state*, theora_info* ) |
|---|
| 359 | cdef int theora_decode_packetin ( theora_state*, ogg_packet* ) |
|---|
| 360 | cdef int theora_decode_YUVout ( theora_state*, yuv_buffer* ) |
|---|
| 361 | cdef int theora_packet_isheader ( ogg_packet* ) |
|---|
| 362 | cdef int theora_packet_iskeyframe ( ogg_packet* ) |
|---|
| 363 | cdef int theora_granule_shift ( theora_info* ) |
|---|
| 364 | cdef ogg_int64_t theora_granule_frame ( theora_state*, ogg_int64_t ) |
|---|
| 365 | cdef double theora_granule_time ( theora_state*, ogg_int64_t ) |
|---|
| 366 | cdef void theora_info_init ( theora_info* ) |
|---|
| 367 | cdef void theora_info_clear ( theora_info* ) |
|---|
| 368 | cdef void theora_clear ( theora_state* ) |
|---|
| 369 | cdef void theora_comment_init ( theora_comment* ) |
|---|
| 370 | cdef void theora_comment_add ( theora_comment*, char* ) |
|---|
| 371 | cdef void theora_comment_add_tag ( theora_comment*, char*, char* ) |
|---|
| 372 | cdef char *theora_comment_query ( theora_comment*, char*, int ) |
|---|
| 373 | cdef int theora_comment_query_count ( theora_comment*, char* ) |
|---|
| 374 | cdef void theora_comment_clear ( theora_comment* ) |
|---|