1159b3361Sopenharmony_ci/*
2159b3361Sopenharmony_ci * Copyright (C) 1999-2010 The L.A.M.E. project
3159b3361Sopenharmony_ci *
4159b3361Sopenharmony_ci * Initially written by Michael Hipp, see also AUTHORS and README.
5159b3361Sopenharmony_ci *
6159b3361Sopenharmony_ci * This library is free software; you can redistribute it and/or
7159b3361Sopenharmony_ci * modify it under the terms of the GNU Library General Public
8159b3361Sopenharmony_ci * License as published by the Free Software Foundation; either
9159b3361Sopenharmony_ci * version 2 of the License, or (at your option) any later version.
10159b3361Sopenharmony_ci *
11159b3361Sopenharmony_ci * This library is distributed in the hope that it will be useful,
12159b3361Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13159b3361Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
14159b3361Sopenharmony_ci * Library General Public License for more details.
15159b3361Sopenharmony_ci *
16159b3361Sopenharmony_ci * You should have received a copy of the GNU Library General Public
17159b3361Sopenharmony_ci * License along with this library; if not, write to the
18159b3361Sopenharmony_ci * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19159b3361Sopenharmony_ci * Boston, MA 02111-1307, USA.
20159b3361Sopenharmony_ci */
21159b3361Sopenharmony_ci#ifndef _MPGLIB_H_
22159b3361Sopenharmony_ci#define _MPGLIB_H_
23159b3361Sopenharmony_ci
24159b3361Sopenharmony_ci#ifdef HAVE_CONFIG_H
25159b3361Sopenharmony_ci# include <config.h>
26159b3361Sopenharmony_ci#endif
27159b3361Sopenharmony_ci
28159b3361Sopenharmony_ci#include "lame.h"
29159b3361Sopenharmony_ci
30159b3361Sopenharmony_ci#ifdef HAVE_MPG123
31159b3361Sopenharmony_ci#include <mpg123.h>
32159b3361Sopenharmony_ci#ifndef MPG123_API_VERSION
33159b3361Sopenharmony_ci#error "Seems like you got the wrong mpg123 header. No MPG123_API_VERSION defined."
34159b3361Sopenharmony_ci#endif
35159b3361Sopenharmony_ci#if (MPG123_API_VERSION < 45)
36159b3361Sopenharmony_ci#error "Need mpg123 API >= 45."
37159b3361Sopenharmony_ci#endif
38159b3361Sopenharmony_ci#endif
39159b3361Sopenharmony_ci
40159b3361Sopenharmony_ci#ifndef plotting_data_defined
41159b3361Sopenharmony_ci#define plotting_data_defined
42159b3361Sopenharmony_cistruct plotting_data;
43159b3361Sopenharmony_citypedef struct plotting_data plotting_data;
44159b3361Sopenharmony_ci#endif
45159b3361Sopenharmony_ci
46159b3361Sopenharmony_ci
47159b3361Sopenharmony_ciextern void lame_report_fnc(lame_report_function f, const char *format, ...);
48159b3361Sopenharmony_ci
49159b3361Sopenharmony_ci#ifdef HAVE_MPGLIB
50159b3361Sopenharmony_cistruct buf {
51159b3361Sopenharmony_ci    unsigned char *pnt;
52159b3361Sopenharmony_ci    long    size;
53159b3361Sopenharmony_ci    long    pos;
54159b3361Sopenharmony_ci    struct buf *next;
55159b3361Sopenharmony_ci    struct buf *prev;
56159b3361Sopenharmony_ci};
57159b3361Sopenharmony_ci
58159b3361Sopenharmony_cistruct framebuf {
59159b3361Sopenharmony_ci    struct buf *buf;
60159b3361Sopenharmony_ci    long    pos;
61159b3361Sopenharmony_ci    struct frame *next;
62159b3361Sopenharmony_ci    struct frame *prev;
63159b3361Sopenharmony_ci};
64159b3361Sopenharmony_ci
65159b3361Sopenharmony_ci#endif
66159b3361Sopenharmony_ci
67159b3361Sopenharmony_citypedef struct mpstr_tag {
68159b3361Sopenharmony_ci#ifdef HAVE_MPG123
69159b3361Sopenharmony_ci    mpg123_handle *mh;
70159b3361Sopenharmony_ci    struct mpg123_moreinfo mi;
71159b3361Sopenharmony_ci#else
72159b3361Sopenharmony_ci    struct buf *head, *tail; /* buffer linked list pointers, tail points to oldest buffer */
73159b3361Sopenharmony_ci    int     vbr_header;      /* 1 if valid Xing vbr header detected */
74159b3361Sopenharmony_ci    int     num_frames;      /* set if vbr header present */
75159b3361Sopenharmony_ci    int     enc_delay;       /* set if vbr header present */
76159b3361Sopenharmony_ci    int     enc_padding;     /* set if vbr header present */
77159b3361Sopenharmony_ci    /* header_parsed, side_parsed and data_parsed must be all set 1
78159b3361Sopenharmony_ci       before the full frame has been parsed */
79159b3361Sopenharmony_ci    int     header_parsed;   /* 1 = header of current frame has been parsed */
80159b3361Sopenharmony_ci    int     side_parsed;     /* 1 = header of sideinfo of current frame has been parsed */
81159b3361Sopenharmony_ci    int     data_parsed;
82159b3361Sopenharmony_ci    int     free_format;     /* 1 = free format frame */
83159b3361Sopenharmony_ci    int     old_free_format; /* 1 = last frame was free format */
84159b3361Sopenharmony_ci    int     bsize;
85159b3361Sopenharmony_ci    int     framesize;
86159b3361Sopenharmony_ci    int     ssize;           /* number of bytes used for side information, including 2 bytes for CRC-16 if present */
87159b3361Sopenharmony_ci    int     dsize;
88159b3361Sopenharmony_ci    int     fsizeold;        /* size of previous frame, -1 for first */
89159b3361Sopenharmony_ci    int     fsizeold_nopadding;
90159b3361Sopenharmony_ci    struct frame fr;         /* holds the parameters decoded from the header */
91159b3361Sopenharmony_ci    struct III_sideinfo sideinfo;
92159b3361Sopenharmony_ci    unsigned char bsspace[2][MAXFRAMESIZE + 1024]; /* bit stream space used ???? */ /* MAXFRAMESIZE */
93159b3361Sopenharmony_ci    real    hybrid_block[2][2][SBLIMIT * SSLIMIT];
94159b3361Sopenharmony_ci    int     hybrid_blc[2];
95159b3361Sopenharmony_ci    unsigned long header;
96159b3361Sopenharmony_ci    int     bsnum;
97159b3361Sopenharmony_ci    real    synth_buffs[2][2][0x110];
98159b3361Sopenharmony_ci    int     synth_bo;
99159b3361Sopenharmony_ci    int     sync_bitstream;  /* 1 = bitstream is yet to be synchronized */
100159b3361Sopenharmony_ci
101159b3361Sopenharmony_ci    int     bitindex;
102159b3361Sopenharmony_ci    unsigned char *wordpointer;
103159b3361Sopenharmony_ci#endif
104159b3361Sopenharmony_ci    plotting_data *pinfo;
105159b3361Sopenharmony_ci
106159b3361Sopenharmony_ci    lame_report_function report_msg;
107159b3361Sopenharmony_ci    lame_report_function report_dbg;
108159b3361Sopenharmony_ci    lame_report_function report_err;
109159b3361Sopenharmony_ci} MPSTR, *PMPSTR;
110159b3361Sopenharmony_ci
111159b3361Sopenharmony_ci#ifdef HAVE_MPGLIB
112159b3361Sopenharmony_ci#define MP3_ERR -1
113159b3361Sopenharmony_ci#define MP3_OK  0
114159b3361Sopenharmony_ci#define MP3_NEED_MORE 1
115159b3361Sopenharmony_ci#endif
116159b3361Sopenharmony_ci
117159b3361Sopenharmony_ci
118159b3361Sopenharmony_ci#endif /* _MPGLIB_H_ */
119