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

📄 pogg_dec.h

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 H
字号:
#ifndef _POGG_DEC_H_
#define _POGG_DEC_H_

#include "../buffer/buffer.h"


//--------------------------------------------
typedef short ogg_int16_t;
typedef unsigned short ogg_uint16_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef long long ogg_int64_t;

//#include "os_types.h"

typedef struct ogg_buffer_state
{
    struct ogg_buffer    *unused_buffers;
    struct ogg_reference *unused_references;
    int                   outstanding;
    int                   shutdown;
} ogg_buffer_state;

typedef struct ogg_buffer
{
    unsigned char      *data;
    long                size;
    int                 refcount;

    union
    {
        ogg_buffer_state  *owner;
        struct ogg_buffer *next;
    } ptr;
} ogg_buffer;

typedef struct ogg_reference
{
    ogg_buffer    *buffer;
    long           begin;
    long           length;

    struct ogg_reference *next;
} ogg_reference;

typedef struct oggpack_buffer
{
    int            headbit;
    unsigned char *headptr;
    long           headend;

    /* memory management */
    ogg_reference *head;
    ogg_reference *tail;

    /* render the byte/bit counter API constant time */
    long              count; /* doesn't count the tail */
} oggpack_buffer;

typedef struct oggbyte_buffer
{
    ogg_reference *baseref;

    ogg_reference *ref;
    unsigned char *ptr;
    long           pos;
    long           end;
} oggbyte_buffer;

typedef struct ogg_sync_state
{
    /* decode memory management pool */
    ogg_buffer_state *bufferpool;

    /* stream buffers */
    ogg_reference    *fifo_head;
    ogg_reference    *fifo_tail;
    long              fifo_fill;

    /* stream sync management */
    int               unsynced;
    int               headerbytes;
    int               bodybytes;

} ogg_sync_state;

typedef struct ogg_stream_state
{
    ogg_reference *header_head;
    ogg_reference *header_tail;
    ogg_reference *body_head;
    ogg_reference *body_tail;

    int            e_o_s;    /* set when we have buffered the last
                              packet in the logical bitstream */
    int            b_o_s;    /* set after we've written the initial page
                              of a logical bitstream */
    long           serialno;
    long           pageno;
    ogg_int64_t    packetno; /* sequence number for decode; the framing
                              knows where there's a hole in the data,
                              but we need coupling so that the codec
                              (which is in a seperate abstraction
                              layer) also knows about the gap */
    ogg_int64_t    granulepos;

    int            lacing_fill;
    ogg_uint32_t   body_fill;

    /* decode-side state data */
    int            holeflag;
    int            spanflag;
    int            clearflag;
    int            laceptr;
    ogg_uint32_t   body_fill_next;

} ogg_stream_state;

typedef struct
{
    ogg_reference *packet;
    long           bytes;
    long           b_o_s;
    long           e_o_s;
    ogg_int64_t    granulepos;
    ogg_int64_t    packetno;     /* sequence number for decode; the framing
                                  knows where there's a hole in the data,
                                  but we need coupling so that the codec
                                  (which is in a seperate abstraction
                                  layer) also knows about the gap */
} ogg_packet;

typedef struct
{
    ogg_reference *header;
    int            header_len;
    ogg_reference *body;
    long           body_len;
} ogg_page;

/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/

extern void  oggpack_readinit(oggpack_buffer *b, ogg_reference *r);
extern long  oggpack_look(oggpack_buffer *b, int bits);
extern void  oggpack_adv(oggpack_buffer *b, int bits);
extern long  oggpack_read(oggpack_buffer *b, int bits);
extern long  oggpack_bytes(oggpack_buffer *b);
extern long  oggpack_bits(oggpack_buffer *b);
extern int   oggpack_eop(oggpack_buffer *b);

/* Ogg BITSTREAM PRIMITIVES: decoding **************************/

extern ogg_sync_state *ogg_sync_create(void);
extern int      ogg_sync_destroy(ogg_sync_state *oy);
extern int      ogg_sync_reset(ogg_sync_state *oy);

extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
extern long     ogg_sync_pageseek(ogg_sync_state *oy, ogg_page *og);
extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
extern int      ogg_stream_packetout(ogg_stream_state *os, ogg_packet *op);
extern int      ogg_stream_packetpeek(ogg_stream_state *os, ogg_packet *op);

/* Ogg BITSTREAM PRIMITIVES: general ***************************/

extern ogg_stream_state *ogg_stream_create(int serialno);
extern int      ogg_stream_destroy(ogg_stream_state *os);
extern int      ogg_stream_reset(ogg_stream_state *os);
extern int      ogg_stream_reset_serialno(ogg_stream_state *os, int serialno);
extern int      ogg_stream_eos(ogg_stream_state *os);

extern int      ogg_page_checksum_set(ogg_page *og);

extern int      ogg_page_version(ogg_page *og);
extern int      ogg_page_continued(ogg_page *og);
extern int      ogg_page_bos(ogg_page *og);
extern int      ogg_page_eos(ogg_page *og);
extern ogg_int64_t  ogg_page_granulepos(ogg_page *og);
extern ogg_uint32_t ogg_page_serialno(ogg_page *og);
extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
extern int      ogg_page_packets(ogg_page *og);
extern int      ogg_page_getbuffer(ogg_page *og, unsigned char **buffer);

extern int      ogg_packet_release(ogg_packet *op);
extern int      ogg_page_release(ogg_page *og);

extern void     ogg_page_dup(ogg_page *d, ogg_page *s);

/* Ogg BITSTREAM PRIMITIVES: return codes ***************************/

#define  OGG_SUCCESS   0

#define  OGG_HOLE     -10
#define  OGG_SPAN     -11
#define  OGG_EVERSION -12
#define  OGG_ESERIAL  -13
#define  OGG_EINVAL   -14
#define  OGG_EEOS     -15
//--------------------------------------------------
struct vorbis_dsp_state;
typedef struct vorbis_dsp_state vorbis_dsp_state;

typedef struct vorbis_info
{
    int version;
    int channels;
    long rate;

    /* The below bitrate declarations are *hints*.
       Combinations of the three values carry the following implications:

       all three set to the same value:
         implies a fixed rate bitstream
       only nominal set:
         implies a VBR stream that averages the nominal bitrate.  No hard
         upper/lower limit
       upper and or lower set:
         implies a VBR bitstream that obeys the bitrate limits. nominal
         may also be set to give a nominal rate.
       none set:
         the coder does not care to speculate.
    */

    long bitrate_upper;
    long bitrate_nominal;
    long bitrate_lower;
    long bitrate_window;

    void *codec_setup;
} vorbis_info;

typedef struct vorbis_comment
{
    char **user_comments;
    int   *comment_lengths;
    int    comments;
    char  *vendor;

} vorbis_comment;


/* Vorbis PRIMITIVES: general ***************************************/

extern void     vorbis_info_init(vorbis_info *vi);
extern void     vorbis_info_clear(vorbis_info *vi);
extern int      vorbis_info_blocksize(vorbis_info *vi, int zo);
extern void     vorbis_comment_init(vorbis_comment *vc);
extern void     vorbis_comment_add(vorbis_comment *vc, char *comment);
extern void     vorbis_comment_add_tag(vorbis_comment *vc,
                                           char *tag, char *contents);
extern char    *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
extern int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
extern void     vorbis_comment_clear(vorbis_comment *vc);

/* Vorbis ERRORS and return codes ***********************************/

#define OV_FALSE      -1
#define OV_EOF        -2
#define OV_HOLE       -3

#define OV_EREAD      -128
#define OV_EFAULT     -129
#define OV_EIMPL      -130
#define OV_EINVAL     -131
#define OV_ENOTVORBIS -132
#define OV_EBADHEADER -133
#define OV_EVERSION   -134
#define OV_ENOTAUDIO  -135
#define OV_EBADPACKET -136
#define OV_EBADLINK   -137
#define OV_ENOSEEK    -138
//--------------------------------------------------
typedef struct
{
    size_t (*read_func)(void *ptr, void *datasource, size_t nmemb);
    int (*seek_func)(void *datasource, ogg_int64_t offset, int whence);
    int (*close_func)(void *datasource);
    long(*tell_func)(void *datasource);
} ov_callbacks;

typedef struct OggVorbis_File
{
    void            *datasource; /* Pointer to a FILE *, etc. */
    int              seekable;
    ogg_int64_t      offset;
    ogg_int64_t      end;
    ogg_sync_state   *oy;

    /* If the FILE handle isn't seekable (eg, a pipe), only the current
       stream appears */
    int              links;
    ogg_int64_t     *offsets;
    ogg_int64_t     *dataoffsets;
    ogg_uint32_t    *serialnos;
    ogg_int64_t     *pcmlengths;
    vorbis_info     vi;
    vorbis_comment  vc;

    /* Decoding working state local storage */
    ogg_int64_t      pcm_offset;
    int              ready_state;
    ogg_uint32_t     current_serialno;
    int              current_link;

    ogg_int64_t      bittrack;
    ogg_int64_t      samptrack;

    ogg_stream_state *os; /* take physical pages, weld into a logical
                          stream of packets */
    vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */

    ov_callbacks callbacks;

} OggVorbis_File;

extern int ov_clear(OggVorbis_File *vf);
extern int ov_open(MY_FILE * f, OggVorbis_File *vf, char *initial, long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
                                 char *initial, long ibytes, ov_callbacks callbacks);

extern int ov_test(FILE *f, OggVorbis_File *vf, char *initial, long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
                                 char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf);

extern long ov_bitrate(OggVorbis_File *vf, int i);
extern long ov_bitrate_instant(OggVorbis_File *vf);
extern long ov_streams(OggVorbis_File *vf);
extern long ov_seekable(OggVorbis_File *vf);
extern long ov_serialnumber(OggVorbis_File *vf, int i);

extern ogg_int64_t ov_raw_total(OggVorbis_File *vf, int i);
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf, int i);
extern ogg_int64_t ov_time_total(OggVorbis_File *vf, int i);

extern int ov_raw_seek(OggVorbis_File *vf, ogg_int64_t pos);
extern int ov_pcm_seek(OggVorbis_File *vf, ogg_int64_t pos);
extern int ov_pcm_seek_page(OggVorbis_File *vf, ogg_int64_t pos);
extern int ov_time_seek(OggVorbis_File *vf, ogg_int64_t pos);
extern int ov_time_seek_page(OggVorbis_File *vf, ogg_int64_t pos);

extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);

extern vorbis_info *ov_info(OggVorbis_File *vf, int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf, int link);

extern long ov_read(OggVorbis_File *vf, void *buffer, int length,
                        int *bitstream);
//-------------------------------------------------------------


#define  OGGLENGTH (8192+50)


typedef struct
{
    long           status;


    short     OGGleft[OGGLENGTH];
    short     OGGright[OGGLENGTH];


    //unsigned short usValid;

    unsigned short usSampleRate;

    unsigned char ucChannels;

    //unsigned char ucIsVBR;

    //unsigned long ulFirstFrame;

    unsigned long ulLength;

    // The number of samples in each encoded block of audio.
    //unsigned short usSamplesPerBlock; // block

    // The length of the file in milliseconds.
    unsigned long ulTimeLength;

    unsigned long ulBitRate;

    // The number of samples that have been encoded/decoded.
    unsigned long ulTimePos;



} tOGG;



#endif

⌨️ 快捷键说明

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