~ubuntu-branches/ubuntu/oneiric/faac/oneiric

« back to all changes in this revision

Viewing changes to plugins/cooledit/Cfaad.h

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-01-06 22:47:35 UTC
  • mfrom: (0.1.3 hoary) (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080106224735-jhb3ptzjfm2j7n89
Tags: 1.26-0.1ubuntu1
* Sync from debian-multimedia
* Ubuntu Changes:
 - Maintainer Spec
 - Versioned mp4v2 dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
FAAC - codec plugin for Cooledit
3
 
Copyright (C) 2004 Antonio Foranna
4
 
 
5
 
This program is free software; you can redistribute it and/or modify
6
 
it under the terms of the GNU General Public License as published by
7
 
the Free Software Foundation.
8
 
        
9
 
This program is distributed in the hope that it will be useful,
10
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
GNU General Public License for more details.
13
 
                
14
 
You should have received a copy of the GNU General Public License
15
 
along with this program; if not, write to the Free Software
16
 
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
 
                        
18
 
The author can be contacted at:
19
 
ntnfrn_email-temp@yahoo.it
20
 
*/
21
 
 
22
 
#ifndef _Cfaad_H
23
 
#define _Cfaad_H
24
 
 
25
 
#include <mp4.h>
26
 
#include "faac.h"
27
 
 
28
 
#ifdef MAIN
29
 
        #undef MAIN
30
 
#endif
31
 
#ifdef SSR
32
 
        #undef SSR
33
 
#endif
34
 
#ifdef LTP
35
 
        #undef LTP
36
 
#endif
37
 
 
38
 
#include "faad.h"
39
 
#include "Defines.h"
40
 
#include "CRegistry.h"
41
 
 
42
 
#if RAW!=0
43
 
        #undef RAW
44
 
        #define RAW 0
45
 
#endif
46
 
#if ADTS!=1
47
 
        #undef ADTS
48
 
        #define ADTS 1
49
 
#endif
50
 
#if ADIF!=2
51
 
        #undef ADIF
52
 
        #define ADIF 2
53
 
#endif
54
 
 
55
 
 
56
 
// make this higher to support files with more channels
57
 
#define MAX_CHANNELS 6
58
 
#if FAAD_MIN_STREAMSIZE<2048
59
 
#undef FAAD_MIN_STREAMSIZE
60
 
// 960 for LD or else 1024 (expanded to 2048 for HE-AAC)
61
 
#define FAAD_MIN_STREAMSIZE 2048
62
 
#endif
63
 
 
64
 
#define FAAD_STREAMSIZE (FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
65
 
 
66
 
 
67
 
 
68
 
// -----------------------------------------------------------------------------------------------
69
 
 
70
 
 
71
 
 
72
 
/* FAAD file buffering routines */
73
 
typedef struct {
74
 
    long bytes_into_buffer;
75
 
    long bytes_consumed;
76
 
    long file_offset;
77
 
    unsigned char *buffer;
78
 
    int at_eof;
79
 
    FILE *infile;
80
 
} aac_buffer;
81
 
// -----------------------------------------------------------------------------------------------
82
 
 
83
 
typedef struct {
84
 
    int version;
85
 
    int channels;
86
 
    int sampling_rate;
87
 
    int bitrate;
88
 
    int length;
89
 
    int object_type;
90
 
    int headertype;
91
 
} faadAACInfo;
92
 
// -----------------------------------------------------------------------------------------------
93
 
 
94
 
typedef struct mdc
95
 
{
96
 
bool                                    DefaultCfg;
97
 
BYTE                                    Channels;
98
 
DWORD                                   BitRate;
99
 
faacDecConfiguration    DecCfg;
100
 
} MY_DEC_CFG;
101
 
// -----------------------------------------------------------------------------------------------
102
 
 
103
 
typedef struct input_tag // any special vars associated with input file
104
 
{
105
 
//MP4
106
 
MP4FileHandle   mp4File;
107
 
MP4SampleId             sampleId,
108
 
                                numSamples;
109
 
int                             track;
110
 
BYTE                    type;
111
 
 
112
 
//AAC
113
 
FILE                    *aacFile;
114
 
DWORD                   src_size;               // size of compressed file
115
 
long                    tagsize;
116
 
DWORD                   bytes_read;             // from file
117
 
long                    bytes_consumed; // from buffer by faadDecDecode
118
 
long                    bytes_into_buffer;
119
 
unsigned char   *buffer;
120
 
 
121
 
// Raw AAC
122
 
DWORD                   bytesconsumed;  // to decode current frame by faadDecDecode
123
 
BOOL                    FindBitrate;
124
 
 
125
 
// GLOBAL
126
 
faacDecHandle   hDecoder;
127
 
faadAACInfo             file_info;
128
 
faacDecFrameInfo        frameInfo;
129
 
DWORD                   len_ms;                 // length of file in milliseconds
130
 
BYTE                    Channels;
131
 
DWORD                   Samprate;
132
 
WORD                    BitsPerSample;
133
 
DWORD                   dst_size;               // size of decoded file. Cooledit needs it to update its progress bar
134
 
//char                  *src_name;              // name of compressed file
135
 
int                             IsMP4;
136
 
} MYINPUT;
137
 
// -----------------------------------------------------------------------------------------------
138
 
 
139
 
class Cfaad
140
 
{
141
 
private:
142
 
        virtual int GetAACTrack(MP4FileHandle infile);
143
 
        long id3v2_TagSize(aac_buffer *b);
144
 
        int fill_buffer(aac_buffer *b);
145
 
        void advance_buffer(aac_buffer *b, int bytes);
146
 
        int adts_parse(aac_buffer *b, int *bitrate, float *length);
147
 
        void GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize);
148
 
        int IsMP4(LPSTR lpstrFilename);
149
 
 
150
 
        virtual void DisplayError(char *ProcName, char *str);
151
 
        virtual HANDLE ERROR_getInfos(char *str) { DisplayError("getInfos", str); return NULL; }
152
 
        virtual int ERROR_processData(char *str) { DisplayError("processData", str); return 0; }
153
 
        virtual void showInfo(MYINPUT *mi) {}
154
 
        virtual void showProgress(MYINPUT *mi) {}
155
 
        virtual void setFaadCfg(faacDecHandle hDecoder);
156
 
 
157
 
public:
158
 
    Cfaad(HANDLE hInput=NULL);
159
 
    virtual ~Cfaad();
160
 
 
161
 
        static void ReadCfgDec(MY_DEC_CFG *cfg);
162
 
        static void WriteCfgDec(MY_DEC_CFG *cfg);
163
 
    virtual HANDLE getInfos(LPSTR lpstrFilename);
164
 
    virtual int processData(HANDLE hInput, unsigned char far *bufout, long lBytes);
165
 
 
166
 
// AAC
167
 
//      bool            BlockSeeking;
168
 
 
169
 
// GLOBAL
170
 
//      long            newpos_ms;
171
 
//      BOOL            IsSeekable;
172
 
        HANDLE                  hInput;
173
 
};
174
 
#endif