Path: blob/master/thirdparty/libvorbis/vorbis/codec.h
10278 views
/********************************************************************1* *2* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *3* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *4* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *5* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *6* *7* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *8* by the Xiph.Org Foundation https://xiph.org/ *910********************************************************************1112function: libvorbis codec headers1314********************************************************************/1516#ifndef _vorbis_codec_h_17#define _vorbis_codec_h_1819#ifdef __cplusplus20extern "C"21{22#endif /* __cplusplus */2324#include <ogg/ogg.h>2526typedef struct vorbis_info{27int version;28int channels;29long rate;3031/* The below bitrate declarations are *hints*.32Combinations of the three values carry the following implications:3334all three set to the same value:35implies a fixed rate bitstream36only nominal set:37implies a VBR stream that averages the nominal bitrate. No hard38upper/lower limit39upper and or lower set:40implies a VBR bitstream that obeys the bitrate limits. nominal41may also be set to give a nominal rate.42none set:43the coder does not care to speculate.44*/4546long bitrate_upper;47long bitrate_nominal;48long bitrate_lower;49long bitrate_window;5051void *codec_setup;52} vorbis_info;5354/* vorbis_dsp_state buffers the current vorbis audio55analysis/synthesis state. The DSP state belongs to a specific56logical bitstream ****************************************************/57typedef struct vorbis_dsp_state{58int analysisp;59vorbis_info *vi;6061float **pcm;62float **pcmret;63int pcm_storage;64int pcm_current;65int pcm_returned;6667int preextrapolate;68int eofflag;6970long lW;71long W;72long nW;73long centerW;7475ogg_int64_t granulepos;76ogg_int64_t sequence;7778ogg_int64_t glue_bits;79ogg_int64_t time_bits;80ogg_int64_t floor_bits;81ogg_int64_t res_bits;8283void *backend_state;84} vorbis_dsp_state;8586typedef struct vorbis_block{87/* necessary stream state for linking to the framing abstraction */88float **pcm; /* this is a pointer into local storage */89oggpack_buffer opb;9091long lW;92long W;93long nW;94int pcmend;95int mode;9697int eofflag;98ogg_int64_t granulepos;99ogg_int64_t sequence;100vorbis_dsp_state *vd; /* For read-only access of configuration */101102/* local storage to avoid remallocing; it's up to the mapping to103structure it */104void *localstore;105long localtop;106long localalloc;107long totaluse;108struct alloc_chain *reap;109110/* bitmetrics for the frame */111long glue_bits;112long time_bits;113long floor_bits;114long res_bits;115116void *internal;117118} vorbis_block;119120/* vorbis_block is a single block of data to be processed as part of121the analysis/synthesis stream; it belongs to a specific logical122bitstream, but is independent from other vorbis_blocks belonging to123that logical bitstream. *************************************************/124125struct alloc_chain{126void *ptr;127struct alloc_chain *next;128};129130/* vorbis_info contains all the setup information specific to the131specific compression/decompression mode in progress (eg,132psychoacoustic settings, channel setup, options, codebook133etc). vorbis_info and substructures are in backends.h.134*********************************************************************/135136/* the comments are not part of vorbis_info so that vorbis_info can be137static storage */138typedef struct vorbis_comment{139/* unlimited user comment fields. libvorbis writes 'libvorbis'140whatever vendor is set to in encode */141char **user_comments;142int *comment_lengths;143int comments;144char *vendor;145146} vorbis_comment;147148149/* libvorbis encodes in two abstraction layers; first we perform DSP150and produce a packet (see docs/analysis.txt). The packet is then151coded into a framed OggSquish bitstream by the second layer (see152docs/framing.txt). Decode is the reverse process; we sync/frame153the bitstream and extract individual packets, then decode the154packet back into PCM audio.155156The extra framing/packetizing is used in streaming formats, such as157files. Over the net (such as with UDP), the framing and158packetization aren't necessary as they're provided by the transport159and the streaming layer is not used */160161/* Vorbis PRIMITIVES: general ***************************************/162163extern void vorbis_info_init(vorbis_info *vi);164extern void vorbis_info_clear(vorbis_info *vi);165extern int vorbis_info_blocksize(vorbis_info *vi,int zo);166extern void vorbis_comment_init(vorbis_comment *vc);167extern void vorbis_comment_add(vorbis_comment *vc, const char *comment);168extern void vorbis_comment_add_tag(vorbis_comment *vc,169const char *tag, const char *contents);170extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);171extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag);172extern void vorbis_comment_clear(vorbis_comment *vc);173174extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);175extern int vorbis_block_clear(vorbis_block *vb);176extern void vorbis_dsp_clear(vorbis_dsp_state *v);177extern double vorbis_granule_time(vorbis_dsp_state *v,178ogg_int64_t granulepos);179180extern const char *vorbis_version_string(void);181182/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/183184extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);185extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);186extern int vorbis_analysis_headerout(vorbis_dsp_state *v,187vorbis_comment *vc,188ogg_packet *op,189ogg_packet *op_comm,190ogg_packet *op_code);191extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);192extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);193extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);194extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op);195196extern int vorbis_bitrate_addblock(vorbis_block *vb);197extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,198ogg_packet *op);199200/* Vorbis PRIMITIVES: synthesis layer *******************************/201extern int vorbis_synthesis_idheader(ogg_packet *op);202extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,203ogg_packet *op);204205extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);206extern int vorbis_synthesis_restart(vorbis_dsp_state *v);207extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);208extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);209extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);210extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);211extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);212extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);213extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);214215extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag);216extern int vorbis_synthesis_halfrate_p(vorbis_info *v);217218/* Vorbis ERRORS and return codes ***********************************/219220#define OV_FALSE -1221#define OV_EOF -2222#define OV_HOLE -3223224#define OV_EREAD -128225#define OV_EFAULT -129226#define OV_EIMPL -130227#define OV_EINVAL -131228#define OV_ENOTVORBIS -132229#define OV_EBADHEADER -133230#define OV_EVERSION -134231#define OV_ENOTAUDIO -135232#define OV_EBADPACKET -136233#define OV_EBADLINK -137234#define OV_ENOSEEK -138235236#ifdef __cplusplus237}238#endif /* __cplusplus */239240#endif241242243244