Mercurial > libavcodec.hg
comparison flacenc.c @ 6548:28e34d24b3f7 libavcodec
remove redundant context variable
author | jbr |
---|---|
date | Mon, 31 Mar 2008 00:29:52 +0000 |
parents | 85acd5166cf8 |
children | a4104482ceef |
comparison
equal
deleted
inserted
replaced
6547:ed204467a154 | 6548:28e34d24b3f7 |
---|---|
100 PutBitContext pb; | 100 PutBitContext pb; |
101 int channels; | 101 int channels; |
102 int ch_code; | 102 int ch_code; |
103 int samplerate; | 103 int samplerate; |
104 int sr_code[2]; | 104 int sr_code[2]; |
105 int blocksize; | |
106 int max_framesize; | 105 int max_framesize; |
107 uint32_t frame_count; | 106 uint32_t frame_count; |
108 FlacFrame frame; | 107 FlacFrame frame; |
109 CompressionOptions options; | 108 CompressionOptions options; |
110 AVCodecContext *avctx; | 109 AVCodecContext *avctx; |
134 | 133 |
135 memset(header, 0, FLAC_STREAMINFO_SIZE); | 134 memset(header, 0, FLAC_STREAMINFO_SIZE); |
136 init_put_bits(&pb, header, FLAC_STREAMINFO_SIZE); | 135 init_put_bits(&pb, header, FLAC_STREAMINFO_SIZE); |
137 | 136 |
138 /* streaminfo metadata block */ | 137 /* streaminfo metadata block */ |
139 put_bits(&pb, 16, s->blocksize); | 138 put_bits(&pb, 16, s->avctx->frame_size); |
140 put_bits(&pb, 16, s->blocksize); | 139 put_bits(&pb, 16, s->avctx->frame_size); |
141 put_bits(&pb, 24, 0); | 140 put_bits(&pb, 24, 0); |
142 put_bits(&pb, 24, s->max_framesize); | 141 put_bits(&pb, 24, s->max_framesize); |
143 put_bits(&pb, 20, s->samplerate); | 142 put_bits(&pb, 20, s->samplerate); |
144 put_bits(&pb, 3, s->channels-1); | 143 put_bits(&pb, 3, s->channels-1); |
145 put_bits(&pb, 5, 15); /* bits per sample - 1 */ | 144 put_bits(&pb, 5, 15); /* bits per sample - 1 */ |
349 avctx->frame_size > FLAC_MAX_BLOCKSIZE) { | 348 avctx->frame_size > FLAC_MAX_BLOCKSIZE) { |
350 av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n", | 349 av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n", |
351 avctx->frame_size); | 350 avctx->frame_size); |
352 return -1; | 351 return -1; |
353 } | 352 } |
354 s->blocksize = avctx->frame_size; | |
355 } else { | 353 } else { |
356 s->blocksize = select_blocksize(s->samplerate, s->options.block_time_ms); | 354 s->avctx->frame_size = select_blocksize(s->samplerate, s->options.block_time_ms); |
357 avctx->frame_size = s->blocksize; | 355 } |
358 } | 356 av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", s->avctx->frame_size); |
359 av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", s->blocksize); | |
360 | 357 |
361 /* set LPC precision */ | 358 /* set LPC precision */ |
362 if(avctx->lpc_coeff_precision > 0) { | 359 if(avctx->lpc_coeff_precision > 0) { |
363 if(avctx->lpc_coeff_precision > MAX_LPC_PRECISION) { | 360 if(avctx->lpc_coeff_precision > MAX_LPC_PRECISION) { |
364 av_log(avctx, AV_LOG_ERROR, "invalid lpc coeff precision: %d\n", | 361 av_log(avctx, AV_LOG_ERROR, "invalid lpc coeff precision: %d\n", |
373 av_log(avctx, AV_LOG_DEBUG, " lpc precision: %d\n", | 370 av_log(avctx, AV_LOG_DEBUG, " lpc precision: %d\n", |
374 s->options.lpc_coeff_precision); | 371 s->options.lpc_coeff_precision); |
375 | 372 |
376 /* set maximum encoded frame size in verbatim mode */ | 373 /* set maximum encoded frame size in verbatim mode */ |
377 if(s->channels == 2) { | 374 if(s->channels == 2) { |
378 s->max_framesize = 14 + ((s->blocksize * 33 + 7) >> 3); | 375 s->max_framesize = 14 + ((s->avctx->frame_size * 33 + 7) >> 3); |
379 } else { | 376 } else { |
380 s->max_framesize = 14 + (s->blocksize * s->channels * 2); | 377 s->max_framesize = 14 + (s->avctx->frame_size * s->channels * 2); |
381 } | 378 } |
382 | 379 |
383 streaminfo = av_malloc(FLAC_STREAMINFO_SIZE); | 380 streaminfo = av_malloc(FLAC_STREAMINFO_SIZE); |
384 write_streaminfo(s, streaminfo); | 381 write_streaminfo(s, streaminfo); |
385 avctx->extradata = streaminfo; | 382 avctx->extradata = streaminfo; |
399 FlacFrame *frame; | 396 FlacFrame *frame; |
400 | 397 |
401 frame = &s->frame; | 398 frame = &s->frame; |
402 | 399 |
403 for(i=0; i<16; i++) { | 400 for(i=0; i<16; i++) { |
404 if(s->blocksize == flac_blocksizes[i]) { | 401 if(s->avctx->frame_size == flac_blocksizes[i]) { |
405 frame->blocksize = flac_blocksizes[i]; | 402 frame->blocksize = flac_blocksizes[i]; |
406 frame->bs_code[0] = i; | 403 frame->bs_code[0] = i; |
407 frame->bs_code[1] = 0; | 404 frame->bs_code[1] = 0; |
408 break; | 405 break; |
409 } | 406 } |
410 } | 407 } |
411 if(i == 16) { | 408 if(i == 16) { |
412 frame->blocksize = s->blocksize; | 409 frame->blocksize = s->avctx->frame_size; |
413 if(frame->blocksize <= 256) { | 410 if(frame->blocksize <= 256) { |
414 frame->bs_code[0] = 6; | 411 frame->bs_code[0] = 6; |
415 frame->bs_code[1] = frame->blocksize-1; | 412 frame->bs_code[1] = frame->blocksize-1; |
416 } else { | 413 } else { |
417 frame->bs_code[0] = 7; | 414 frame->bs_code[0] = 7; |
1438 int16_t *samples = data; | 1435 int16_t *samples = data; |
1439 int out_bytes; | 1436 int out_bytes; |
1440 | 1437 |
1441 s = avctx->priv_data; | 1438 s = avctx->priv_data; |
1442 | 1439 |
1443 s->blocksize = avctx->frame_size; | |
1444 init_frame(s); | 1440 init_frame(s); |
1445 | 1441 |
1446 copy_samples(s, samples); | 1442 copy_samples(s, samples); |
1447 | 1443 |
1448 channel_decorrelation(s); | 1444 channel_decorrelation(s); |