~ubuntu-branches/ubuntu/hardy/ffmpeg/hardy

« back to all changes in this revision

Viewing changes to libavcodec/ac3enc.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-23 14:35:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060823143552-8fxnur5b9gesr03m
Tags: 3:0.cvs20060823-0ubuntu1
* Sync with Debian:
  + Add the epoch again

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    unsigned int bsid;
39
39
    unsigned int frame_size_min; /* minimum frame size in case rounding is necessary */
40
40
    unsigned int frame_size; /* current frame size in words */
 
41
    unsigned int bits_written;
 
42
    unsigned int samples_written;
41
43
    int halfratecod;
42
44
    unsigned int frmsizecod;
43
45
    unsigned int fscod; /* frequency */
859
861
    s->bit_rate = bitrate;
860
862
    s->frmsizecod = i << 1;
861
863
    s->frame_size_min = (bitrate * 1000 * AC3_FRAME_SIZE) / (freq * 16);
862
 
    /* for now we do not handle fractional sizes */
 
864
    s->bits_written = 0;
 
865
    s->samples_written = 0;
863
866
    s->frame_size = s->frame_size_min;
864
867
 
865
868
    /* bit allocation init */
1374
1377
            v = 14 - log2_tab(input_samples, N);
1375
1378
            if (v < 0)
1376
1379
                v = 0;
1377
 
            exp_samples[i][ch] = v - 8;
 
1380
            exp_samples[i][ch] = v - 9;
1378
1381
            lshift_tab(input_samples, N, v);
1379
1382
 
1380
1383
            /* do the MDCT */
1422
1425
        }
1423
1426
    }
1424
1427
 
 
1428
    /* adjust for fractional frame sizes */
 
1429
    while(s->bits_written >= s->bit_rate*1000 && s->samples_written >= s->sample_rate) {
 
1430
        s->bits_written -= s->bit_rate*1000;
 
1431
        s->samples_written -= s->sample_rate;
 
1432
    }
 
1433
    s->frame_size = s->frame_size_min + (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate*1000);
 
1434
    s->bits_written += s->frame_size * 16;
 
1435
    s->samples_written += AC3_FRAME_SIZE;
 
1436
 
1425
1437
    compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);
1426
1438
    /* everything is known... let's output the frame */
1427
1439
    output_frame_header(s, frame);