Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: celt/rate.c

Issue 882843002: Update to opus-HEAD-66611f1. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/opus.git@master
Patch Set: Add the contents of Makefile.mips back. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « celt/pitch.c ('k') | celt/stack_alloc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2007-2008 CSIRO 1 /* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2009 Xiph.Org Foundation 2 Copyright (c) 2007-2009 Xiph.Org Foundation
3 Written by Jean-Marc Valin */ 3 Written by Jean-Marc Valin */
4 /* 4 /*
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions 6 modification, are permitted provided that the following conditions
7 are met: 7 are met:
8 8
9 - Redistributions of source code must retain the above copyright 9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer. 10 notice, this list of conditions and the following disclaimer.
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 we just signaled should be cocentrated in this band. */ 326 we just signaled should be cocentrated in this band. */
327 if (j<=skip_start) 327 if (j<=skip_start)
328 { 328 {
329 /* Give the bit we reserved to end skipping back. */ 329 /* Give the bit we reserved to end skipping back. */
330 total += skip_rsv; 330 total += skip_rsv;
331 break; 331 break;
332 } 332 }
333 /*Figure out how many left-over bits we would be adding to this band. 333 /*Figure out how many left-over bits we would be adding to this band.
334 This can include bits we've stolen back from higher, skipped bands.*/ 334 This can include bits we've stolen back from higher, skipped bands.*/
335 left = total-psum; 335 left = total-psum;
336 percoeff = left/(m->eBands[codedBands]-m->eBands[start]); 336 percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]);
337 left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; 337 left -= (m->eBands[codedBands]-m->eBands[start])*percoeff;
338 rem = IMAX(left-(m->eBands[j]-m->eBands[start]),0); 338 rem = IMAX(left-(m->eBands[j]-m->eBands[start]),0);
339 band_width = m->eBands[codedBands]-m->eBands[j]; 339 band_width = m->eBands[codedBands]-m->eBands[j];
340 band_bits = (int)(bits[j] + percoeff*band_width + rem); 340 band_bits = (int)(bits[j] + percoeff*band_width + rem);
341 /*Only code a skip decision if we're above the threshold for this band. 341 /*Only code a skip decision if we're above the threshold for this band.
342 Otherwise it is force-skipped. 342 Otherwise it is force-skipped.
343 This ensures that we have enough bits to code the skip flag.*/ 343 This ensures that we have enough bits to code the skip flag.*/
344 if (band_bits >= IMAX(thresh[j], alloc_floor+(1<<BITRES))) 344 if (band_bits >= IMAX(thresh[j], alloc_floor+(1<<BITRES)))
345 { 345 {
346 if (encode) 346 if (encode)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (encode) 407 if (encode)
408 ec_enc_bit_logp(ec, *dual_stereo, 1); 408 ec_enc_bit_logp(ec, *dual_stereo, 1);
409 else 409 else
410 *dual_stereo = ec_dec_bit_logp(ec, 1); 410 *dual_stereo = ec_dec_bit_logp(ec, 1);
411 } 411 }
412 else 412 else
413 *dual_stereo = 0; 413 *dual_stereo = 0;
414 414
415 /* Allocate the remaining bits */ 415 /* Allocate the remaining bits */
416 left = total-psum; 416 left = total-psum;
417 percoeff = left/(m->eBands[codedBands]-m->eBands[start]); 417 percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]);
418 left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; 418 left -= (m->eBands[codedBands]-m->eBands[start])*percoeff;
419 for (j=start;j<codedBands;j++) 419 for (j=start;j<codedBands;j++)
420 bits[j] += ((int)percoeff*(m->eBands[j+1]-m->eBands[j])); 420 bits[j] += ((int)percoeff*(m->eBands[j+1]-m->eBands[j]));
421 for (j=start;j<codedBands;j++) 421 for (j=start;j<codedBands;j++)
422 { 422 {
423 int tmp = (int)IMIN(left, m->eBands[j+1]-m->eBands[j]); 423 int tmp = (int)IMIN(left, m->eBands[j+1]-m->eBands[j]);
424 bits[j] += tmp; 424 bits[j] += tmp;
425 left -= tmp; 425 left -= tmp;
426 } 426 }
427 /*for (j=0;j<end;j++)printf("%d ", bits[j]);printf("\n");*/ 427 /*for (j=0;j<end;j++)printf("%d ", bits[j]);printf("\n");*/
(...skipping 30 matching lines...) Expand all
458 offset += den<<BITRES>>2; 458 offset += den<<BITRES>>2;
459 459
460 /* Changing the offset for allocating the second and third 460 /* Changing the offset for allocating the second and third
461 fine energy bit */ 461 fine energy bit */
462 if (bits[j] + offset < den*2<<BITRES) 462 if (bits[j] + offset < den*2<<BITRES)
463 offset += NClogN>>2; 463 offset += NClogN>>2;
464 else if (bits[j] + offset < den*3<<BITRES) 464 else if (bits[j] + offset < den*3<<BITRES)
465 offset += NClogN>>3; 465 offset += NClogN>>3;
466 466
467 /* Divide with rounding */ 467 /* Divide with rounding */
468 ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))) / (den<<BITRE S)); 468 ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))));
469 ebits[j] = celt_udiv(ebits[j], den)>>BITRES;
469 470
470 /* Make sure not to bust */ 471 /* Make sure not to bust */
471 if (C*ebits[j] > (bits[j]>>BITRES)) 472 if (C*ebits[j] > (bits[j]>>BITRES))
472 ebits[j] = bits[j] >> stereo >> BITRES; 473 ebits[j] = bits[j] >> stereo >> BITRES;
473 474
474 /* More than that is useless because that's about as far as PVQ can go */ 475 /* More than that is useless because that's about as far as PVQ can go */
475 ebits[j] = IMIN(ebits[j], MAX_FINE_BITS); 476 ebits[j] = IMIN(ebits[j], MAX_FINE_BITS);
476 477
477 /* If we rounded down or capped this band, make it a candidate for the 478 /* If we rounded down or capped this band, make it a candidate for the
478 final fine energy pass */ 479 final fine energy pass */
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 bits1[j] = bits1j; 630 bits1[j] = bits1j;
630 bits2[j] = bits2j; 631 bits2[j] = bits2j;
631 } 632 }
632 codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thre sh, cap, 633 codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thre sh, cap,
633 total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_s tereo_rsv, 634 total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_s tereo_rsv,
634 pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth) ; 635 pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth) ;
635 RESTORE_STACK; 636 RESTORE_STACK;
636 return codedBands; 637 return codedBands;
637 } 638 }
638 639
OLDNEW
« no previous file with comments | « celt/pitch.c ('k') | celt/stack_alloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698