⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 theora.h

📁 mediastreamer2是开源的网络传输媒体流的库
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************** *                                                                  * * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       * *                                                                  * * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                * * by the Xiph.Org Foundation http://www.xiph.org/                  * *                                                                  * ********************************************************************  function:  last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $ ********************************************************************/#ifndef _O_THEORA_H_#define _O_THEORA_H_#ifdef __cplusplusextern "C"{#endif /* __cplusplus */#ifndef LIBOGG2#include <ogg/ogg.h>#else#include <ogg2/ogg.h>/* This is temporary until libogg2 is more complete */ogg_buffer_state *ogg_buffer_create(void);#endif/** \mainpage *  * \section intro Introduction * * This is the documentation for the libtheora C API. * libtheora is the reference implementation for * <a href="http://www.theora.org/">Theora</a>, a free video codec. * Theora is derived from On2's VP3 codec with improved integration for * Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>. *//** \file * The libtheora C API. *//** * A YUV buffer for passing uncompressed frames to and from the codec. * This holds a Y'CbCr frame in planar format. The CbCr planes can be * subsampled and have their own separate dimensions and row stride * offsets. Note that the strides may be negative in some  * configurations. For theora the width and height of the largest plane * must be a multiple of 16. The actual meaningful picture size and  * offset are stored in the theora_info structure; frames returned by * the decoder may need to be cropped for display. * * All samples are 8 bits. Within each plane samples are ordered by * row from the top of the frame to the bottom. Within each row samples * are ordered from left to right. */typedef struct {    int   y_width;      /**< Width of the Y' luminance plane */    int   y_height;     /**< Height of the luminance plane */    int   y_stride;     /**< Offset in bytes between successive rows */    int   uv_width;     /**< Height of the Cb and Cr chroma planes */    int   uv_height;    /**< Width of the chroma planes */    int   uv_stride;    /**< Offset between successive chroma rows */    unsigned char *y;   /**< Pointer to start of luminance data */    unsigned char *u;   /**< Pointer to start of Cb data */    unsigned char *v;   /**< Pointer to start of Cr data */} yuv_buffer;/** * A Colorspace. */typedef enum {  OC_CS_UNSPECIFIED,    /**< The colorspace is unknown or unspecified */  OC_CS_ITU_REC_470M,   /**< This is the best option for 'NTSC' content */  OC_CS_ITU_REC_470BG,  /**< This is the best option for 'PAL' content */  OC_CS_NSPACES         /**< This marks the end of the defined colorspaces */} theora_colorspace;/** * A Chroma subsampling * * These enumerate the available chroma subsampling options supported * by the theora format. See Section 4.4 of the specification for * exact definitions. */typedef enum {  OC_PF_420,    /**< Chroma subsampling by 2 in each direction (4:2:0) */  OC_PF_RSVD,   /**< Reserved value */  OC_PF_422,    /**< Horizonatal chroma subsampling by 2 (4:2:2) */  OC_PF_444,    /**< No chroma subsampling at all (4:4:4) */} theora_pixelformat;/** * Theora bitstream info. * Contains the basic playback parameters for a stream, * corresponds to the initial 'info' header packet. *  * Encoded theora frames must be a multiple of 16 is size; * this is what the width and height members represent. To * handle other sizes, a crop rectangle is specified in  * frame_height and frame_width, offset_x and offset_y. The * offset and size should still be a multiple of 2 to avoid * chroma sampling shifts. Offset values in this structure * are measured from the  upper left of the image. * * Frame rate, in frames per second, is stored as a rational * fraction. So is the aspect ratio. Note that this refers * to the aspect ratio of the frame pixels, not of the * overall frame itself. *  * see the example code for use of the other parameters and * good default settings for the encoder parameters. */typedef struct {  ogg_uint32_t  width;		/**< encoded frame width  */  ogg_uint32_t  height;		/**< encoded frame height */  ogg_uint32_t  frame_width;	/**< display frame width  */  ogg_uint32_t  frame_height;	/**< display frame height */  ogg_uint32_t  offset_x;	/**< horizontal offset of the displayed frame */  ogg_uint32_t  offset_y;	/**< vertical offset of the displayed frame */  ogg_uint32_t  fps_numerator;	    /**< frame rate numerator **/  ogg_uint32_t  fps_denominator;    /**< frame rate denominator **/  ogg_uint32_t  aspect_numerator;   /**< pixel aspect ratio numerator */  ogg_uint32_t  aspect_denominator; /**< pixel aspect ratio denominator */  theora_colorspace colorspace;	    /**< colorspace */  int           target_bitrate;	    /**< nominal bitrate in bits per second */  int           quality;  /**< Nominal quality setting, 0-63 */  int           quick_p;  /**< Quick encode/decode */  /* decode only */  unsigned char version_major;  unsigned char version_minor;  unsigned char version_subminor;  void *codec_setup;  /* encode only */  int           dropframes_p;  int           keyframe_auto_p;  ogg_uint32_t  keyframe_frequency;  ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to                                              get granpos shift correct */  ogg_uint32_t  keyframe_data_target_bitrate;  ogg_int32_t   keyframe_auto_threshold;  ogg_uint32_t  keyframe_mindistance;  ogg_int32_t   noise_sensitivity;  ogg_int32_t   sharpness;  theora_pixelformat pixelformat;	/**< chroma subsampling mode to expect */} theora_info;/** Codec internal state and context. */typedef struct{  theora_info *i;  ogg_int64_t granulepos;  void *internal_encode;  void *internal_decode;} theora_state;/**  * Comment header metadata. * * This structure holds the in-stream metadata corresponding to * the 'comment' header packet. * * Meta data is stored as a series of (tag, value) pairs, in * length-encoded string vectors. The first occurence of the  * '=' character delimits the tag and value. A particular tag * may occur more than once. The character set encoding for * the strings is always utf-8, but the tag names are limited * to case-insensitive ascii. See the spec for details. * * In filling in this structure, theora_decode_header() will * null-terminate the user_comment strings for safety. However, * the bitstream format itself treats them as 8-bit clean, * and so the length array should be treated as authoritative * for their length. */typedef struct theora_comment{  char **user_comments;         /**< An array of comment string vectors */  int   *comment_lengths;       /**< An array of corresponding string vector lengths in bytes */  int    comments;              /**< The total number of comment string vectors */  char  *vendor;                /**< The vendor string identifying the encoder, null terminated */} theora_comment;#define OC_FAULT       -1       /**< General failure */#define OC_EINVAL      -10      /**< Library encountered invalid internal data */#define OC_DISABLED    -11      /**< Requested action is disabled */#define OC_BADHEADER   -20      /**< Header packet was corrupt/invalid */#define OC_NOTFORMAT   -21      /**< Packet is not a theora packet */#define OC_VERSION     -22      /**< Bitstream version is not handled */#define OC_IMPL        -23      /**< Feature or action not implemented */#define OC_BADPACKET   -24      /**< Packet is corrupt */#define OC_NEWPACKET   -25      /**< Packet is an (ignorable) unhandled extension */#define OC_DUPFRAME    1        /**< Packet is a dropped frame *//**  * Retrieve a human-readable string to identify the encoder vendor and version. * \returns A version string. */extern const char *theora_version_string(void);/** * Retrieve a 32-bit version number. * This number is composed of a 16-bit major version, 8-bit minor version * and 8 bit sub-version, composed as follows:<pre>   (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)</pre>* \returns The version number.*/extern ogg_uint32_t theora_version_number(void);/** * Initialize the theora encoder. * \param th The theora_state handle to initialize for encoding. * \param ti A theora_info struct filled with the desired encoding parameters. * \retval 0 Success */extern int theora_encode_init(theora_state *th, theora_info *ti);/** * Submit a YUV buffer to the theora encoder. * \param t A theora_state handle previously initialized for encoding. * \param yuv A buffer of YUV data to encode. * \retval OC_EINVAL Encoder is not ready, or is finished. * \retval -1 The size of the given frame differs from those previously input * \retval 0 Success */extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);/** * Request the next packet of encoded video.  * The encoded data is placed in a user-provided ogg_packet structure. * \param t A theora_state handle previously initialized for encoding. * \param last_p whether this is the last packet the encoder should produce. * \param op An ogg_packet structure to fill. libtheora will set all *           elements of this structure, including a pointer to encoded *           data. The memory for the encoded data is owned by libtheora. * \retval 0 No internal storage exists OR no packet is ready * \retval -1 The encoding process has completed * \retval 1 Success */extern int theora_encode_packetout( theora_state *t, int last_p,                                    ogg_packet *op);/** * Request a packet containing the initial header. * A pointer to the header data is placed in a user-provided ogg_packet * structure. * \param t A theora_state handle previously initialized for encoding. * \param op An ogg_packet structure to fill. libtheora will set all *           elements of this structure, including a pointer to the header *           data. The memory for the header data is owned by libtheora. * \retval 0 Success */extern int theora_encode_header(theora_state *t, ogg_packet *op);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -