X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fflacenc.c;h=c1f862a68458397c795eb4bd35739052100d81c4;hb=67e19a9e4b6b48ecedc6a64210ef6f69edce9119;hp=e8e5674bcec4fe29e9e4f1dcb94486fec514f2ab;hpb=0aed5e9fb895a31c43ff6ab4edfecb5be372f704;p=ffmpeg diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index e8e5674bcec..c1f862a6845 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -83,6 +83,7 @@ typedef struct FlacEncodeContext { int channels; int samplerate; int sr_code[2]; + int max_blocksize; int min_framesize; int max_framesize; int max_encoded_framesize; @@ -107,8 +108,8 @@ static void write_streaminfo(FlacEncodeContext *s, uint8_t *header) init_put_bits(&pb, header, FLAC_STREAMINFO_SIZE); /* streaminfo metadata block */ - put_bits(&pb, 16, s->avctx->frame_size); - put_bits(&pb, 16, s->avctx->frame_size); + put_bits(&pb, 16, s->max_blocksize); + put_bits(&pb, 16, s->max_blocksize); put_bits(&pb, 24, s->min_framesize); put_bits(&pb, 24, s->max_framesize); put_bits(&pb, 20, s->samplerate); @@ -326,6 +327,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) } else { s->avctx->frame_size = select_blocksize(s->samplerate, s->options.block_time_ms); } + s->max_blocksize = s->avctx->frame_size; av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", s->avctx->frame_size); /* set LPC precision */ @@ -550,69 +552,6 @@ static uint32_t calc_rice_params_lpc(RiceContext *rc, int pmin, int pmax, return bits; } -/** - * Apply Welch window function to audio block - */ -static void apply_welch_window(const int32_t *data, int len, double *w_data) -{ - int i, n2; - double w; - double c; - - assert(!(len&1)); //the optimization in r11881 does not support odd len - //if someone wants odd len extend the change in r11881 - - n2 = (len >> 1); - c = 2.0 / (len - 1.0); - - w_data+=n2; - data+=n2; - for(i=0; i 0); @@ -1222,7 +1161,7 @@ static void output_frame_footer(FlacEncodeContext *s) static void update_md5_sum(FlacEncodeContext *s, int16_t *samples) { -#ifdef WORDS_BIGENDIAN +#if HAVE_BIGENDIAN int i; for(i = 0; i < s->frame.blocksize*s->channels; i++) { int16_t smp = le2me_16(samples[i]); @@ -1322,6 +1261,6 @@ AVCodec flac_encoder = { flac_encode_close, NULL, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), };