comparison flacenc.c @ 9188:f534d0cca450 libavcodec

share some constants between the FLAC encoder and FLAC decoder
author jbr
date Thu, 19 Mar 2009 03:04:21 +0000
parents 7a463923ecd1
children 443f056ba7e7
comparison
equal deleted inserted replaced
9187:e10efe27c6b1 9188:f534d0cca450
25 #include "avcodec.h" 25 #include "avcodec.h"
26 #include "bitstream.h" 26 #include "bitstream.h"
27 #include "dsputil.h" 27 #include "dsputil.h"
28 #include "golomb.h" 28 #include "golomb.h"
29 #include "lpc.h" 29 #include "lpc.h"
30 30 #include "flac.h"
31 #define FLAC_MAX_CH 8
32 #define FLAC_MIN_BLOCKSIZE 16
33 #define FLAC_MAX_BLOCKSIZE 65535
34 31
35 #define FLAC_SUBFRAME_CONSTANT 0 32 #define FLAC_SUBFRAME_CONSTANT 0
36 #define FLAC_SUBFRAME_VERBATIM 1 33 #define FLAC_SUBFRAME_VERBATIM 1
37 #define FLAC_SUBFRAME_FIXED 8 34 #define FLAC_SUBFRAME_FIXED 8
38 #define FLAC_SUBFRAME_LPC 32 35 #define FLAC_SUBFRAME_LPC 32
40 #define FLAC_CHMODE_NOT_STEREO 0 37 #define FLAC_CHMODE_NOT_STEREO 0
41 #define FLAC_CHMODE_LEFT_RIGHT 1 38 #define FLAC_CHMODE_LEFT_RIGHT 1
42 #define FLAC_CHMODE_LEFT_SIDE 8 39 #define FLAC_CHMODE_LEFT_SIDE 8
43 #define FLAC_CHMODE_RIGHT_SIDE 9 40 #define FLAC_CHMODE_RIGHT_SIDE 9
44 #define FLAC_CHMODE_MID_SIDE 10 41 #define FLAC_CHMODE_MID_SIDE 10
45
46 #define FLAC_STREAMINFO_SIZE 34
47 42
48 #define MAX_FIXED_ORDER 4 43 #define MAX_FIXED_ORDER 4
49 #define MAX_PARTITION_ORDER 8 44 #define MAX_PARTITION_ORDER 8
50 #define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER) 45 #define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER)
51 #define MAX_LPC_PRECISION 15 46 #define MAX_LPC_PRECISION 15
80 int32_t samples[FLAC_MAX_BLOCKSIZE]; 75 int32_t samples[FLAC_MAX_BLOCKSIZE];
81 int32_t residual[FLAC_MAX_BLOCKSIZE+1]; 76 int32_t residual[FLAC_MAX_BLOCKSIZE+1];
82 } FlacSubframe; 77 } FlacSubframe;
83 78
84 typedef struct FlacFrame { 79 typedef struct FlacFrame {
85 FlacSubframe subframes[FLAC_MAX_CH]; 80 FlacSubframe subframes[FLAC_MAX_CHANNELS];
86 int blocksize; 81 int blocksize;
87 int bs_code[2]; 82 int bs_code[2];
88 uint8_t crc8; 83 uint8_t crc8;
89 int ch_mode; 84 int ch_mode;
90 } FlacFrame; 85 } FlacFrame;
183 178
184 if(avctx->sample_fmt != SAMPLE_FMT_S16) { 179 if(avctx->sample_fmt != SAMPLE_FMT_S16) {
185 return -1; 180 return -1;
186 } 181 }
187 182
188 if(channels < 1 || channels > FLAC_MAX_CH) { 183 if(channels < 1 || channels > FLAC_MAX_CHANNELS) {
189 return -1; 184 return -1;
190 } 185 }
191 s->channels = channels; 186 s->channels = channels;
192 s->ch_code = s->channels-1; 187 s->ch_code = s->channels-1;
193 188