misc/libtremor/tremor/ivorbisfile.h
changeset 7849 a12155461b34
parent 7697 767d3c4153a1
equal deleted inserted replaced
7848:775a72905708 7849:a12155461b34
     4  *                                                                  *
     4  *                                                                  *
     5  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     5  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     6  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
     6  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
     7  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
     7  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
     8  *                                                                  *
     8  *                                                                  *
     9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003    *
     9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
    10  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    10  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
    11  *                                                                  *
    11  *                                                                  *
    12  ********************************************************************
    12  ********************************************************************
    13 
    13 
    14  function: stdio-based convenience library for opening/seeking/decoding
    14  function: stdio-based convenience library for opening/seeking/decoding
    24 #endif /* __cplusplus */
    24 #endif /* __cplusplus */
    25 
    25 
    26 #include <stdio.h>
    26 #include <stdio.h>
    27 #include "ivorbiscodec.h"
    27 #include "ivorbiscodec.h"
    28 
    28 
       
    29 #define CHUNKSIZE 1024
    29 /* The function prototypes for the callbacks are basically the same as for
    30 /* The function prototypes for the callbacks are basically the same as for
    30  * the stdio functions fread, fseek, fclose, ftell. 
    31  * the stdio functions fread, fseek, fclose, ftell. 
    31  * The one difference is that the FILE * arguments have been replaced with
    32  * The one difference is that the FILE * arguments have been replaced with
    32  * a void * - this is to be used as a pointer to whatever internal data these
    33  * a void * - this is to be used as a pointer to whatever internal data these
    33  * functions might need. In the stdio case, it's just a FILE * cast to a void *
    34  * functions might need. In the stdio case, it's just a FILE * cast to a void *
    41   int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
    42   int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
    42   int    (*close_func) (void *datasource);
    43   int    (*close_func) (void *datasource);
    43   long   (*tell_func)  (void *datasource);
    44   long   (*tell_func)  (void *datasource);
    44 } ov_callbacks;
    45 } ov_callbacks;
    45 
    46 
       
    47 #define  NOTOPEN   0
       
    48 #define  PARTOPEN  1
       
    49 #define  OPENED    2
       
    50 #define  STREAMSET 3
       
    51 #define  INITSET   4
       
    52 
    46 typedef struct OggVorbis_File {
    53 typedef struct OggVorbis_File {
    47   void            *datasource; /* Pointer to a FILE *, etc. */
    54   void            *datasource; /* Pointer to a FILE *, etc. */
    48   int              seekable;
    55   int              seekable;
    49   ogg_int64_t      offset;
    56   ogg_int64_t      offset;
    50   ogg_int64_t      end;
    57   ogg_int64_t      end;
    55   int              links;
    62   int              links;
    56   ogg_int64_t     *offsets;
    63   ogg_int64_t     *offsets;
    57   ogg_int64_t     *dataoffsets;
    64   ogg_int64_t     *dataoffsets;
    58   ogg_uint32_t    *serialnos;
    65   ogg_uint32_t    *serialnos;
    59   ogg_int64_t     *pcmlengths;
    66   ogg_int64_t     *pcmlengths;
    60   vorbis_info     vi;
    67   vorbis_info     *vi;
    61   vorbis_comment  vc;
    68   vorbis_comment  *vc;
    62 
    69 
    63   /* Decoding working state local storage */
    70   /* Decoding working state local storage */
    64   ogg_int64_t      pcm_offset;
    71   ogg_int64_t      pcm_offset;
    65   int              ready_state;
    72   int              ready_state;
    66   ogg_uint32_t     current_serialno;
    73   ogg_uint32_t     current_serialno;
    69   ogg_int64_t      bittrack;
    76   ogg_int64_t      bittrack;
    70   ogg_int64_t      samptrack;
    77   ogg_int64_t      samptrack;
    71 
    78 
    72   ogg_stream_state *os; /* take physical pages, weld into a logical
    79   ogg_stream_state *os; /* take physical pages, weld into a logical
    73                           stream of packets */
    80                           stream of packets */
    74   vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */
    81   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
       
    82   vorbis_block     vb; /* local working space for packet->PCM decode */
    75 
    83 
    76   ov_callbacks callbacks;
    84   ov_callbacks callbacks;
    77 
    85 
    78 } OggVorbis_File;
    86 } OggVorbis_File;
    79 
    87 
   108 extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
   116 extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
   109 
   117 
   110 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
   118 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
   111 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
   119 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
   112 
   120 
   113 extern long ov_read(OggVorbis_File *vf,void *buffer,int length,
   121 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
   114 		    int *bitstream);
   122 		    int *bitstream);
   115 
   123 
   116 #ifdef __cplusplus
   124 #ifdef __cplusplus
   117 }
   125 }
   118 #endif /* __cplusplus */
   126 #endif /* __cplusplus */