VisualC/external/include/vorbis/vorbisfile.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 09 Jan 2012 04:20:54 -0500
changeset 556 2686e67b59fd
parent 532 VisualC/vorbis/include/vorbis/vorbisfile.h@b8e8ae4852b2
child 642 dae7bb0a66b1
child 937 3797c39725bf
permissions -rwxr-xr-x
Moved external libraries into the "external" directory and added x64 build configuration.
slouken@495
     1
/********************************************************************
slouken@495
     2
 *                                                                  *
slouken@495
     3
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
slouken@495
     4
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
slouken@495
     5
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
slouken@495
     6
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
slouken@495
     7
 *                                                                  *
slouken@495
     8
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
slouken@495
     9
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
slouken@495
    10
 *                                                                  *
slouken@495
    11
 ********************************************************************
slouken@495
    12
slouken@495
    13
 function: stdio-based convenience library for opening/seeking/decoding
slouken@532
    14
 last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $
slouken@495
    15
slouken@495
    16
 ********************************************************************/
slouken@495
    17
slouken@495
    18
#ifndef _OV_FILE_H_
slouken@495
    19
#define _OV_FILE_H_
slouken@495
    20
slouken@495
    21
#ifdef __cplusplus
slouken@495
    22
extern "C"
slouken@495
    23
{
slouken@495
    24
#endif /* __cplusplus */
slouken@495
    25
slouken@495
    26
#include <stdio.h>
slouken@495
    27
#include "codec.h"
slouken@495
    28
slouken@495
    29
/* The function prototypes for the callbacks are basically the same as for
slouken@495
    30
 * the stdio functions fread, fseek, fclose, ftell.
slouken@495
    31
 * The one difference is that the FILE * arguments have been replaced with
slouken@495
    32
 * a void * - this is to be used as a pointer to whatever internal data these
slouken@495
    33
 * functions might need. In the stdio case, it's just a FILE * cast to a void *
slouken@495
    34
 *
slouken@495
    35
 * If you use other functions, check the docs for these functions and return
slouken@495
    36
 * the right values. For seek_func(), you *MUST* return -1 if the stream is
slouken@495
    37
 * unseekable
slouken@495
    38
 */
slouken@495
    39
typedef struct {
slouken@495
    40
  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
slouken@495
    41
  int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
slouken@495
    42
  int    (*close_func) (void *datasource);
slouken@495
    43
  long   (*tell_func)  (void *datasource);
slouken@495
    44
} ov_callbacks;
slouken@495
    45
slouken@495
    46
#ifndef OV_EXCLUDE_STATIC_CALLBACKS
slouken@495
    47
slouken@495
    48
/* a few sets of convenient callbacks, especially for use under
slouken@495
    49
 * Windows where ov_open_callbacks() should always be used instead of
slouken@532
    50
 * ov_open() to avoid problems with incompatible crt.o version linking
slouken@495
    51
 * issues. */
slouken@495
    52
slouken@495
    53
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
slouken@495
    54
  if(f==NULL)return(-1);
slouken@495
    55
slouken@495
    56
#ifdef __MINGW32__
slouken@495
    57
  return fseeko64(f,off,whence);
slouken@495
    58
#elif defined (_WIN32)
slouken@495
    59
  return _fseeki64(f,off,whence);
slouken@495
    60
#else
slouken@495
    61
  return fseek(f,off,whence);
slouken@495
    62
#endif
slouken@495
    63
}
slouken@495
    64
slouken@495
    65
/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as
slouken@495
    66
 * static data. That means that every file which includes this header
slouken@495
    67
 * will get its own copy of these structs whether it uses them or
slouken@495
    68
 * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS.
slouken@495
    69
 * These static symbols are essential on platforms such as Windows on
slouken@495
    70
 * which several different versions of stdio support may be linked to
slouken@495
    71
 * by different DLLs, and we need to be certain we know which one
slouken@495
    72
 * we're using (the same one as the main application).
slouken@495
    73
 */
slouken@495
    74
slouken@495
    75
static ov_callbacks OV_CALLBACKS_DEFAULT = {
slouken@495
    76
  (size_t (*)(void *, size_t, size_t, void *))  fread,
slouken@495
    77
  (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
slouken@495
    78
  (int (*)(void *))                             fclose,
slouken@495
    79
  (long (*)(void *))                            ftell
slouken@495
    80
};
slouken@495
    81
slouken@495
    82
static ov_callbacks OV_CALLBACKS_NOCLOSE = {
slouken@495
    83
  (size_t (*)(void *, size_t, size_t, void *))  fread,
slouken@495
    84
  (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
slouken@495
    85
  (int (*)(void *))                             NULL,
slouken@495
    86
  (long (*)(void *))                            ftell
slouken@495
    87
};
slouken@495
    88
slouken@495
    89
static ov_callbacks OV_CALLBACKS_STREAMONLY = {
slouken@495
    90
  (size_t (*)(void *, size_t, size_t, void *))  fread,
slouken@495
    91
  (int (*)(void *, ogg_int64_t, int))           NULL,
slouken@495
    92
  (int (*)(void *))                             fclose,
slouken@495
    93
  (long (*)(void *))                            NULL
slouken@495
    94
};
slouken@495
    95
slouken@495
    96
static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {
slouken@495
    97
  (size_t (*)(void *, size_t, size_t, void *))  fread,
slouken@495
    98
  (int (*)(void *, ogg_int64_t, int))           NULL,
slouken@495
    99
  (int (*)(void *))                             NULL,
slouken@495
   100
  (long (*)(void *))                            NULL
slouken@495
   101
};
slouken@495
   102
slouken@495
   103
#endif
slouken@495
   104
slouken@495
   105
#define  NOTOPEN   0
slouken@495
   106
#define  PARTOPEN  1
slouken@495
   107
#define  OPENED    2
slouken@495
   108
#define  STREAMSET 3
slouken@495
   109
#define  INITSET   4
slouken@495
   110
slouken@495
   111
typedef struct OggVorbis_File {
slouken@495
   112
  void            *datasource; /* Pointer to a FILE *, etc. */
slouken@495
   113
  int              seekable;
slouken@495
   114
  ogg_int64_t      offset;
slouken@495
   115
  ogg_int64_t      end;
slouken@495
   116
  ogg_sync_state   oy;
slouken@495
   117
slouken@495
   118
  /* If the FILE handle isn't seekable (eg, a pipe), only the current
slouken@495
   119
     stream appears */
slouken@495
   120
  int              links;
slouken@495
   121
  ogg_int64_t     *offsets;
slouken@495
   122
  ogg_int64_t     *dataoffsets;
slouken@495
   123
  long            *serialnos;
slouken@495
   124
  ogg_int64_t     *pcmlengths; /* overloaded to maintain binary
slouken@532
   125
                                  compatibility; x2 size, stores both
slouken@495
   126
                                  beginning and end values */
slouken@495
   127
  vorbis_info     *vi;
slouken@495
   128
  vorbis_comment  *vc;
slouken@495
   129
slouken@495
   130
  /* Decoding working state local storage */
slouken@495
   131
  ogg_int64_t      pcm_offset;
slouken@495
   132
  int              ready_state;
slouken@495
   133
  long             current_serialno;
slouken@495
   134
  int              current_link;
slouken@495
   135
slouken@495
   136
  double           bittrack;
slouken@495
   137
  double           samptrack;
slouken@495
   138
slouken@495
   139
  ogg_stream_state os; /* take physical pages, weld into a logical
slouken@495
   140
                          stream of packets */
slouken@495
   141
  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
slouken@495
   142
  vorbis_block     vb; /* local working space for packet->PCM decode */
slouken@495
   143
slouken@495
   144
  ov_callbacks callbacks;
slouken@495
   145
slouken@495
   146
} OggVorbis_File;
slouken@495
   147
slouken@495
   148
slouken@495
   149
extern int ov_clear(OggVorbis_File *vf);
slouken@532
   150
extern int ov_fopen(const char *path,OggVorbis_File *vf);
slouken@532
   151
extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
slouken@495
   152
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
slouken@532
   153
                const char *initial, long ibytes, ov_callbacks callbacks);
slouken@495
   154
slouken@532
   155
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
slouken@495
   156
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
slouken@532
   157
                const char *initial, long ibytes, ov_callbacks callbacks);
slouken@495
   158
extern int ov_test_open(OggVorbis_File *vf);
slouken@495
   159
slouken@495
   160
extern long ov_bitrate(OggVorbis_File *vf,int i);
slouken@495
   161
extern long ov_bitrate_instant(OggVorbis_File *vf);
slouken@495
   162
extern long ov_streams(OggVorbis_File *vf);
slouken@495
   163
extern long ov_seekable(OggVorbis_File *vf);
slouken@495
   164
extern long ov_serialnumber(OggVorbis_File *vf,int i);
slouken@495
   165
slouken@495
   166
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
slouken@495
   167
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
slouken@495
   168
extern double ov_time_total(OggVorbis_File *vf,int i);
slouken@495
   169
slouken@495
   170
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   171
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   172
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   173
extern int ov_time_seek(OggVorbis_File *vf,double pos);
slouken@495
   174
extern int ov_time_seek_page(OggVorbis_File *vf,double pos);
slouken@495
   175
slouken@495
   176
extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   177
extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   178
extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);
slouken@495
   179
extern int ov_time_seek_lap(OggVorbis_File *vf,double pos);
slouken@495
   180
extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos);
slouken@495
   181
slouken@495
   182
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
slouken@495
   183
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
slouken@495
   184
extern double ov_time_tell(OggVorbis_File *vf);
slouken@495
   185
slouken@495
   186
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
slouken@495
   187
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
slouken@495
   188
slouken@495
   189
extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,
slouken@495
   190
                          int *bitstream);
slouken@495
   191
extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length,
slouken@495
   192
                          int bigendianp,int word,int sgned,int *bitstream,
slouken@495
   193
                          void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);
slouken@495
   194
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
slouken@495
   195
                    int bigendianp,int word,int sgned,int *bitstream);
slouken@495
   196
extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);
slouken@495
   197
slouken@495
   198
extern int ov_halfrate(OggVorbis_File *vf,int flag);
slouken@495
   199
extern int ov_halfrate_p(OggVorbis_File *vf);
slouken@495
   200
slouken@495
   201
#ifdef __cplusplus
slouken@495
   202
}
slouken@495
   203
#endif /* __cplusplus */
slouken@495
   204
slouken@495
   205
#endif
slouken@495
   206