Commit 1ddc6ec7 authored by jbr's avatar jbr

share some constants between the FLAC encoder and FLAC decoder


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18041 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent e7aa6eb0
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include "avcodec.h" #include "avcodec.h"
#define FLAC_STREAMINFO_SIZE 34 #define FLAC_STREAMINFO_SIZE 34
#define FLAC_MAX_CHANNELS 8
#define FLAC_MIN_BLOCKSIZE 16
#define FLAC_MAX_BLOCKSIZE 65535
enum { enum {
FLAC_METADATA_TYPE_STREAMINFO = 0, FLAC_METADATA_TYPE_STREAMINFO = 0,
......
...@@ -46,9 +46,6 @@ ...@@ -46,9 +46,6 @@
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
#define MAX_CHANNELS 8
#define MAX_BLOCKSIZE 65535
enum decorrelation_type { enum decorrelation_type {
INDEPENDENT, INDEPENDENT,
LEFT_SIDE, LEFT_SIDE,
...@@ -69,7 +66,7 @@ typedef struct FLACContext { ...@@ -69,7 +66,7 @@ typedef struct FLACContext {
enum decorrelation_type decorrelation; ///< channel decorrelation type in the current frame enum decorrelation_type decorrelation; ///< channel decorrelation type in the current frame
int got_streaminfo; ///< indicates if the STREAMINFO has been read int got_streaminfo; ///< indicates if the STREAMINFO has been read
int32_t *decoded[MAX_CHANNELS]; ///< decoded samples int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
uint8_t *bitstream; uint8_t *bitstream;
unsigned int bitstream_size; unsigned int bitstream_size;
unsigned int bitstream_index; unsigned int bitstream_index;
...@@ -190,7 +187,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, ...@@ -190,7 +187,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
skip_bits(&gb, 16); /* skip min blocksize */ skip_bits(&gb, 16); /* skip min blocksize */
s->max_blocksize = get_bits(&gb, 16); s->max_blocksize = get_bits(&gb, 16);
if (s->max_blocksize < 16) { if (s->max_blocksize < FLAC_MIN_BLOCKSIZE) {
av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n", av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
s->max_blocksize); s->max_blocksize);
s->max_blocksize = 16; s->max_blocksize = 16;
...@@ -510,9 +507,9 @@ static int decode_frame(FLACContext *s, int alloc_data_size) ...@@ -510,9 +507,9 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
sample_rate_code = get_bits(&s->gb, 4); sample_rate_code = get_bits(&s->gb, 4);
assignment = get_bits(&s->gb, 4); /* channel assignment */ assignment = get_bits(&s->gb, 4); /* channel assignment */
if (assignment < 8 && s->channels == assignment+1) if (assignment < FLAC_MAX_CHANNELS && s->channels == assignment+1)
decorrelation = INDEPENDENT; decorrelation = INDEPENDENT;
else if (assignment >=8 && assignment < 11 && s->channels == 2) else if (assignment >= FLAC_MAX_CHANNELS && assignment < 11 && s->channels == 2)
decorrelation = LEFT_SIDE + assignment - 8; decorrelation = LEFT_SIDE + assignment - 8;
else { else {
av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
......
...@@ -27,10 +27,7 @@ ...@@ -27,10 +27,7 @@
#include "dsputil.h" #include "dsputil.h"
#include "golomb.h" #include "golomb.h"
#include "lpc.h" #include "lpc.h"
#include "flac.h"
#define FLAC_MAX_CH 8
#define FLAC_MIN_BLOCKSIZE 16
#define FLAC_MAX_BLOCKSIZE 65535
#define FLAC_SUBFRAME_CONSTANT 0 #define FLAC_SUBFRAME_CONSTANT 0
#define FLAC_SUBFRAME_VERBATIM 1 #define FLAC_SUBFRAME_VERBATIM 1
...@@ -43,8 +40,6 @@ ...@@ -43,8 +40,6 @@
#define FLAC_CHMODE_RIGHT_SIDE 9 #define FLAC_CHMODE_RIGHT_SIDE 9
#define FLAC_CHMODE_MID_SIDE 10 #define FLAC_CHMODE_MID_SIDE 10
#define FLAC_STREAMINFO_SIZE 34
#define MAX_FIXED_ORDER 4 #define MAX_FIXED_ORDER 4
#define MAX_PARTITION_ORDER 8 #define MAX_PARTITION_ORDER 8
#define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER) #define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER)
...@@ -82,7 +77,7 @@ typedef struct FlacSubframe { ...@@ -82,7 +77,7 @@ typedef struct FlacSubframe {
} FlacSubframe; } FlacSubframe;
typedef struct FlacFrame { typedef struct FlacFrame {
FlacSubframe subframes[FLAC_MAX_CH]; FlacSubframe subframes[FLAC_MAX_CHANNELS];
int blocksize; int blocksize;
int bs_code[2]; int bs_code[2];
uint8_t crc8; uint8_t crc8;
...@@ -185,7 +180,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) ...@@ -185,7 +180,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
return -1; return -1;
} }
if(channels < 1 || channels > FLAC_MAX_CH) { if(channels < 1 || channels > FLAC_MAX_CHANNELS) {
return -1; return -1;
} }
s->channels = channels; s->channels = channels;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment