comparison aacenc.c @ 9938:6c1ac45b3097 libavcodec

cosmetics: Remove unnecessary {} around if/for blocks; move statements after if/for to the next line.
author diego
date Wed, 08 Jul 2009 21:36:33 +0000
parents 3e39dbd2d9eb
children 6c5a58b34997
comparison
equal deleted inserted replaced
9937:3e39dbd2d9eb 9938:6c1ac45b3097
274 if (info->window_sequence[0] != EIGHT_SHORT_SEQUENCE) { 274 if (info->window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
275 put_bits(&s->pb, 6, info->max_sfb); 275 put_bits(&s->pb, 6, info->max_sfb);
276 put_bits(&s->pb, 1, 0); // no prediction 276 put_bits(&s->pb, 1, 0); // no prediction
277 } else { 277 } else {
278 put_bits(&s->pb, 4, info->max_sfb); 278 put_bits(&s->pb, 4, info->max_sfb);
279 for (w = 1; w < 8; w++) { 279 for (w = 1; w < 8; w++)
280 put_bits(&s->pb, 1, !info->group_len[w]); 280 put_bits(&s->pb, 1, !info->group_len[w]);
281 }
282 } 281 }
283 } 282 }
284 283
285 /** 284 /**
286 * Encode MS data. 285 * Encode MS data.
289 static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe) 288 static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe)
290 { 289 {
291 int i, w; 290 int i, w;
292 291
293 put_bits(pb, 2, cpe->ms_mode); 292 put_bits(pb, 2, cpe->ms_mode);
294 if (cpe->ms_mode == 1) { 293 if (cpe->ms_mode == 1)
295 for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]) { 294 for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w])
296 for (i = 0; i < cpe->ch[0].ics.max_sfb; i++) 295 for (i = 0; i < cpe->ch[0].ics.max_sfb; i++)
297 put_bits(pb, 1, cpe->ms_mask[w*16 + i]); 296 put_bits(pb, 1, cpe->ms_mask[w*16 + i]);
298 }
299 }
300 } 297 }
301 298
302 /** 299 /**
303 * Produce integer coefficients from scalefactors provided by the model. 300 * Produce integer coefficients from scalefactors provided by the model.
304 */ 301 */
322 cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i]; 319 cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
323 } 320 }
324 } 321 }
325 start += ics->swb_sizes[g]; 322 start += ics->swb_sizes[g];
326 } 323 }
327 for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--); 324 for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)
325 ;
328 maxsfb = FFMAX(maxsfb, cmaxsfb); 326 maxsfb = FFMAX(maxsfb, cmaxsfb);
329 } 327 }
330 ics->max_sfb = maxsfb; 328 ics->max_sfb = maxsfb;
331 329
332 //adjust zero bands for window groups 330 //adjust zero bands for window groups
350 int msc = 0; 348 int msc = 0;
351 ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); 349 ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);
352 ics1->max_sfb = ics0->max_sfb; 350 ics1->max_sfb = ics0->max_sfb;
353 for (w = 0; w < ics0->num_windows*16; w += 16) 351 for (w = 0; w < ics0->num_windows*16; w += 16)
354 for (i = 0; i < ics0->max_sfb; i++) 352 for (i = 0; i < ics0->max_sfb; i++)
355 if (cpe->ms_mask[w+i]) msc++; 353 if (cpe->ms_mask[w+i])
354 msc++;
356 if (msc == 0 || ics0->max_sfb == 0) 355 if (msc == 0 || ics0->max_sfb == 0)
357 cpe->ms_mode = 0; 356 cpe->ms_mode = 0;
358 else 357 else
359 cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2; 358 cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2;
360 } 359 }
365 */ 364 */
366 static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) 365 static void encode_band_info(AACEncContext *s, SingleChannelElement *sce)
367 { 366 {
368 int w; 367 int w;
369 368
370 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { 369 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
371 s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda); 370 s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda);
372 }
373 } 371 }
374 372
375 /** 373 /**
376 * Encode scalefactors. 374 * Encode scalefactors.
377 */ 375 */
425 for (i = 0; i < sce->ics.max_sfb; i++) { 423 for (i = 0; i < sce->ics.max_sfb; i++) {
426 if (sce->zeroes[w*16 + i]) { 424 if (sce->zeroes[w*16 + i]) {
427 start += sce->ics.swb_sizes[i]; 425 start += sce->ics.swb_sizes[i];
428 continue; 426 continue;
429 } 427 }
430 for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) { 428 for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++)
431 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128, 429 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,
432 sce->ics.swb_sizes[i], 430 sce->ics.swb_sizes[i],
433 sce->sf_idx[w*16 + i], 431 sce->sf_idx[w*16 + i],
434 sce->band_type[w*16 + i], 432 sce->band_type[w*16 + i],
435 s->lambda); 433 s->lambda);
436 }
437 start += sce->ics.swb_sizes[i]; 434 start += sce->ics.swb_sizes[i];
438 } 435 }
439 } 436 }
440 } 437 }
441 438
512 1024 * avctx->channels * sizeof(s->samples[0])); 509 1024 * avctx->channels * sizeof(s->samples[0]));
513 return 0; 510 return 0;
514 } 511 }
515 512
516 init_put_bits(&s->pb, frame, buf_size*8); 513 init_put_bits(&s->pb, frame, buf_size*8);
517 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) { 514 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
518 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); 515 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
519 }
520 start_ch = 0; 516 start_ch = 0;
521 memset(chan_el_counter, 0, sizeof(chan_el_counter)); 517 memset(chan_el_counter, 0, sizeof(chan_el_counter));
522 for (i = 0; i < chan_map[0]; i++) { 518 for (i = 0; i < chan_map[0]; i++) {
523 FFPsyWindowInfo wi[2]; 519 FFPsyWindowInfo wi[2];
524 tag = chan_map[i+1]; 520 tag = chan_map[i+1];
525 chans = tag == TYPE_CPE ? 2 : 1; 521 chans = tag == TYPE_CPE ? 2 : 1;
526 cpe = &s->cpe[i]; 522 cpe = &s->cpe[i];
527 samples2 = samples + start_ch; 523 samples2 = samples + start_ch;
528 la = samples2 + 1024 * avctx->channels + start_ch; 524 la = samples2 + 1024 * avctx->channels + start_ch;
529 if (!data) la = NULL; 525 if (!data)
526 la = NULL;
530 for (j = 0; j < chans; j++) { 527 for (j = 0; j < chans; j++) {
531 IndividualChannelStream *ics = &cpe->ch[j].ics; 528 IndividualChannelStream *ics = &cpe->ch[j].ics;
532 int k; 529 int k;
533 wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]); 530 wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]);
534 ics->window_sequence[1] = ics->window_sequence[0]; 531 ics->window_sequence[1] = ics->window_sequence[0];
586 if (!(avctx->flags & CODEC_FLAG_QSCALE)) { 583 if (!(avctx->flags & CODEC_FLAG_QSCALE)) {
587 float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; 584 float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
588 s->lambda *= ratio; 585 s->lambda *= ratio;
589 } 586 }
590 587
591 if (avctx->frame_bits > 6144*avctx->channels) { 588 if (avctx->frame_bits > 6144*avctx->channels)
592 av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n", 589 av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
593 avctx->frame_bits, 6144*avctx->channels); 590 avctx->frame_bits, 6144*avctx->channels);
594 }
595 591
596 if (!data) 592 if (!data)
597 s->last_frame = 1; 593 s->last_frame = 1;
598 memcpy(s->samples, s->samples + 1024 * avctx->channels, 594 memcpy(s->samples, s->samples + 1024 * avctx->channels,
599 1024 * avctx->channels * sizeof(s->samples[0])); 595 1024 * avctx->channels * sizeof(s->samples[0]));