libtheora  1.1.1
theora.h
Go to the documentation of this file.
1 /********************************************************************
2  * *
3  * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7  * *
8  * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
9  * by the Xiph.Org Foundation http://www.xiph.org/ *
10  * *
11  ********************************************************************
12 
13  function:
14  last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $
15 
16  ********************************************************************/
17 
18 #ifndef _O_THEORA_H_
19 #define _O_THEORA_H_
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif /* __cplusplus */
25 
26 #include <stddef.h> /* for size_t */
27 
28 #include <ogg/ogg.h>
29 
121 /* @{ */
122 
147 typedef struct {
148  int y_width;
149  int y_height;
150  int y_stride;
152  int uv_width;
153  int uv_height;
154  int uv_stride;
155  unsigned char *y;
156  unsigned char *u;
157  unsigned char *v;
159 } yuv_buffer;
160 
164 typedef enum {
170 
178 typedef enum {
184 
206 typedef struct {
207  ogg_uint32_t width;
208  ogg_uint32_t height;
209  ogg_uint32_t frame_width;
210  ogg_uint32_t frame_height;
211  ogg_uint32_t offset_x;
212  ogg_uint32_t offset_y;
213  ogg_uint32_t fps_numerator;
214  ogg_uint32_t fps_denominator;
215  ogg_uint32_t aspect_numerator;
216  ogg_uint32_t aspect_denominator;
219  int quality;
220  int quick_p;
222  /* decode only */
223  unsigned char version_major;
224  unsigned char version_minor;
225  unsigned char version_subminor;
226 
227  void *codec_setup;
228 
229  /* encode only */
232  ogg_uint32_t keyframe_frequency;
233  ogg_uint32_t keyframe_frequency_force; /* also used for decode init to
234  get granpos shift correct */
237  ogg_uint32_t keyframe_mindistance;
238  ogg_int32_t noise_sensitivity;
239  ogg_int32_t sharpness;
240 
243 } theora_info;
244 
247 typedef struct{
249  ogg_int64_t granulepos;
250 
253 
254 } theora_state;
255 
275 typedef struct theora_comment{
276  char **user_comments;
278  int comments;
279  char *vendor;
282 
283 
285 /* \anchor decctlcodes_old
286  * These are the available request codes for theora_control()
287  * when called with a decoder instance.
288  * By convention decoder control codes are odd, to distinguish
289  * them from \ref encctlcodes_old "encoder control codes" which
290  * are even.
291  *
292  * Note that since the 1.0 release, both the legacy and the final
293  * implementation accept all the same control codes, but only the
294  * final API declares the newer codes.
295  *
296  * Keep any experimental or vendor-specific values above \c 0x8000.*/
297 
306 #define TH_DECCTL_GET_PPLEVEL_MAX (1)
307 
313 #define TH_DECCTL_SET_PPLEVEL (3)
314 
327 #define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
328 
336 #define TH_DECCTL_SET_GRANPOS (5)
337 
353 #define TH_ENCCTL_SET_QUANT_PARAMS (2)
354 
382 #define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
383 
397 #define TH_ENCCTL_GET_SPLEVEL_MAX (12)
398 
412 #define TH_ENCCTL_SET_SPLEVEL (14)
413 
416 #define OC_FAULT -1
417 #define OC_EINVAL -10
418 #define OC_DISABLED -11
419 #define OC_BADHEADER -20
420 #define OC_NOTFORMAT -21
421 #define OC_VERSION -22
422 #define OC_IMPL -23
423 #define OC_BADPACKET -24
424 #define OC_NEWPACKET -25
425 #define OC_DUPFRAME 1
431 extern const char *theora_version_string(void);
432 
442 extern ogg_uint32_t theora_version_number(void);
443 
450 extern int theora_encode_init(theora_state *th, theora_info *ti);
451 
462 extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
463 
476 extern int theora_encode_packetout( theora_state *t, int last_p,
477  ogg_packet *op);
478 
489 extern int theora_encode_header(theora_state *t, ogg_packet *op);
490 
502 extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
503 
514 extern int theora_encode_tables(theora_state *t, ogg_packet *op);
515 
558  ogg_packet *op);
559 
568 extern int theora_decode_init(theora_state *th, theora_info *c);
569 
577 extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
578 
589 extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
590 
603 extern int theora_packet_isheader(ogg_packet *op);
604 
615 extern int theora_packet_iskeyframe(ogg_packet *op);
616 
643 
660 extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
661 
677 extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
678 
685 extern void theora_info_init(theora_info *c);
686 
692 extern void theora_info_clear(theora_info *c);
693 
698 extern void theora_clear(theora_state *t);
699 
704 extern void theora_comment_init(theora_comment *tc);
705 
718 extern void theora_comment_add(theora_comment *tc, char *comment);
719 
732 extern void theora_comment_add_tag(theora_comment *tc,
733  char *tag, char *value);
734 
749 extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
750 
760 extern int theora_comment_query_count(theora_comment *tc, char *tag);
761 
766 extern void theora_comment_clear(theora_comment *tc);
767 
776 extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
777 
778 /* @} */ /* end oldfuncs doxygen group */
779 
780 #ifdef __cplusplus
781 }
782 #endif /* __cplusplus */
783 
784 #endif /* _O_THEORA_H_ */