Path: blob/master/thirdparty/libvorbis/vorbis/vorbisfile.h
9903 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-2007 *8* by the Xiph.Org Foundation https://xiph.org/ *9* *10********************************************************************1112function: stdio-based convenience library for opening/seeking/decoding1314********************************************************************/1516#ifndef _OV_FILE_H_17#define _OV_FILE_H_1819#ifdef __cplusplus20extern "C"21{22#endif /* __cplusplus */2324#include <stdio.h>25#include "codec.h"2627/* The function prototypes for the callbacks are basically the same as for28* the stdio functions fread, fseek, fclose, ftell.29* The one difference is that the FILE * arguments have been replaced with30* a void * - this is to be used as a pointer to whatever internal data these31* functions might need. In the stdio case, it's just a FILE * cast to a void *32*33* If you use other functions, check the docs for these functions and return34* the right values. For seek_func(), you *MUST* return -1 if the stream is35* unseekable36*/37typedef struct {38size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);39int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);40int (*close_func) (void *datasource);41long (*tell_func) (void *datasource);42} ov_callbacks;4344#ifndef OV_EXCLUDE_STATIC_CALLBACKS4546/* a few sets of convenient callbacks, especially for use under47* Windows where ov_open_callbacks() should always be used instead of48* ov_open() to avoid problems with incompatible crt.o version linking49* issues. */5051static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){52if(f==NULL)return(-1);5354#ifdef __MINGW32__55return fseeko64(f,off,whence);56#elif defined (_WIN32)57return _fseeki64(f,off,whence);58#else59return fseek(f,off,whence);60#endif61}6263/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as64* static data. That means that every file which includes this header65* will get its own copy of these structs whether it uses them or66* not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS.67* These static symbols are essential on platforms such as Windows on68* which several different versions of stdio support may be linked to69* by different DLLs, and we need to be certain we know which one70* we're using (the same one as the main application).71*/7273static ov_callbacks OV_CALLBACKS_DEFAULT = {74(size_t (*)(void *, size_t, size_t, void *)) fread,75(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,76(int (*)(void *)) fclose,77(long (*)(void *)) ftell78};7980static ov_callbacks OV_CALLBACKS_NOCLOSE = {81(size_t (*)(void *, size_t, size_t, void *)) fread,82(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,83(int (*)(void *)) NULL,84(long (*)(void *)) ftell85};8687static ov_callbacks OV_CALLBACKS_STREAMONLY = {88(size_t (*)(void *, size_t, size_t, void *)) fread,89(int (*)(void *, ogg_int64_t, int)) NULL,90(int (*)(void *)) fclose,91(long (*)(void *)) NULL92};9394static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {95(size_t (*)(void *, size_t, size_t, void *)) fread,96(int (*)(void *, ogg_int64_t, int)) NULL,97(int (*)(void *)) NULL,98(long (*)(void *)) NULL99};100101#endif102103#define NOTOPEN 0104#define PARTOPEN 1105#define OPENED 2106#define STREAMSET 3107#define INITSET 4108109typedef struct OggVorbis_File {110void *datasource; /* Pointer to a FILE *, etc. */111int seekable;112ogg_int64_t offset;113ogg_int64_t end;114ogg_sync_state oy;115116/* If the FILE handle isn't seekable (eg, a pipe), only the current117stream appears */118int links;119ogg_int64_t *offsets;120ogg_int64_t *dataoffsets;121long *serialnos;122ogg_int64_t *pcmlengths; /* overloaded to maintain binary123compatibility; x2 size, stores both124beginning and end values */125vorbis_info *vi;126vorbis_comment *vc;127128/* Decoding working state local storage */129ogg_int64_t pcm_offset;130int ready_state;131long current_serialno;132int current_link;133134double bittrack;135double samptrack;136137ogg_stream_state os; /* take physical pages, weld into a logical138stream of packets */139vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */140vorbis_block vb; /* local working space for packet->PCM decode */141142ov_callbacks callbacks;143144} OggVorbis_File;145146147extern int ov_clear(OggVorbis_File *vf);148extern int ov_fopen(const char *path,OggVorbis_File *vf);149extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);150extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,151const char *initial, long ibytes, ov_callbacks callbacks);152153extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);154extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,155const char *initial, long ibytes, ov_callbacks callbacks);156extern int ov_test_open(OggVorbis_File *vf);157158extern long ov_bitrate(OggVorbis_File *vf,int i);159extern long ov_bitrate_instant(OggVorbis_File *vf);160extern long ov_streams(OggVorbis_File *vf);161extern long ov_seekable(OggVorbis_File *vf);162extern long ov_serialnumber(OggVorbis_File *vf,int i);163164extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);165extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);166extern double ov_time_total(OggVorbis_File *vf,int i);167168extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);169extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);170extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);171extern int ov_time_seek(OggVorbis_File *vf,double pos);172extern int ov_time_seek_page(OggVorbis_File *vf,double pos);173174extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);175extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);176extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);177extern int ov_time_seek_lap(OggVorbis_File *vf,double pos);178extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos);179180extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);181extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);182extern double ov_time_tell(OggVorbis_File *vf);183184extern vorbis_info *ov_info(OggVorbis_File *vf,int link);185extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);186187extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,188int *bitstream);189extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length,190int bigendianp,int word,int sgned,int *bitstream,191void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);192extern long ov_read(OggVorbis_File *vf,char *buffer,int length,193int bigendianp,int word,int sgned,int *bitstream);194extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);195196extern int ov_halfrate(OggVorbis_File *vf,int flag);197extern int ov_halfrate_p(OggVorbis_File *vf);198199#ifdef __cplusplus200}201#endif /* __cplusplus */202203#endif204205206207