Revision 1c3c129b

View differences:

libavcodec/sipr.c
130 130
    AVCodecContext *avctx;
131 131
    DSPContext dsp;
132 132

  
133
    SiprModeParam m;
134 133
    SiprMode mode;
135 134

  
136 135
    float past_pitch_gain;
......
410 409
                         float *out_data)
411 410
{
412 411
    int i, j;
413
    int frame_size = ctx->m.subframe_count * SUBFR_SIZE;
412
    int subframe_count = modes[ctx->mode].subframe_count;
413
    int frame_size = subframe_count * SUBFR_SIZE;
414 414
    float Az[LP_FILTER_ORDER * MAX_SUBFRAME_COUNT];
415 415
    float *excitation;
416 416
    float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];
......
424 424
    memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float));
425 425
    lsf_decode_fp(lsf_new, ctx->lsf_history, params);
426 426

  
427
    sipr_decode_lp(lsf_new, ctx->lsp_history, Az, ctx->m.subframe_count);
427
    sipr_decode_lp(lsf_new, ctx->lsp_history, Az, subframe_count);
428 428

  
429 429
    memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float));
430 430

  
431 431
    excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL;
432 432

  
433
    for (i = 0; i < ctx->m.subframe_count; i++) {
433
    for (i = 0; i < subframe_count; i++) {
434 434
        float *pAz = Az + i*LP_FILTER_ORDER;
435 435
        float fixed_vector[SUBFR_SIZE];
436 436
        int T0,T0_frac;
......
450 450
        decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode,
451 451
                            ctx->past_pitch_gain < 0.8);
452 452

  
453
        eval_ir(pAz, T0, impulse_response, ctx->m.pitch_sharp_factor);
453
        eval_ir(pAz, T0, impulse_response, modes[ctx->mode].pitch_sharp_factor);
454 454

  
455 455
        convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
456 456
                              SUBFR_SIZE);
......
497 497
           LP_FILTER_ORDER * sizeof(float));
498 498

  
499 499
    if (ctx->mode == MODE_5k0) {
500
        for (i = 0; i < ctx->m.subframe_count; i++) {
500
        for (i = 0; i < subframe_count; i++) {
501 501
            float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
502 502
                                           ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
503 503
                                           SUBFR_SIZE);
......
532 532
    else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
533 533
    else                              ctx->mode = MODE_5k0;
534 534

  
535
    ctx->m = modes[ctx->mode];
536
    av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", ctx->m.mode_name);
535
    av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
537 536

  
538 537
    for (i = 0; i < LP_FILTER_ORDER; i++)
539 538
        ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1));
......
560 559
    SiprContext *ctx = avctx->priv_data;
561 560
    const uint8_t *buf=avpkt->data;
562 561
    SiprParameters parm;
562
    const SiprModeParam *mode_par = &modes[ctx->mode];
563 563
    GetBitContext gb;
564 564
    float *data = datap;
565 565
    int i;
566 566

  
567 567
    ctx->avctx = avctx;
568
    if (avpkt->size < (ctx->m.bits_per_frame >> 3)) {
568
    if (avpkt->size < (mode_par->bits_per_frame >> 3)) {
569 569
        av_log(avctx, AV_LOG_ERROR,
570 570
               "Error processing packet: packet size (%d) too small\n",
571 571
               avpkt->size);
......
573 573
        *data_size = 0;
574 574
        return -1;
575 575
    }
576
    if (*data_size < SUBFR_SIZE * ctx->m.subframe_count * sizeof(float)) {
576
    if (*data_size < SUBFR_SIZE * mode_par->subframe_count * sizeof(float)) {
577 577
        av_log(avctx, AV_LOG_ERROR,
578 578
               "Error processing packet: output buffer (%d) too small\n",
579 579
               *data_size);
......
582 582
        return -1;
583 583
    }
584 584

  
585
    init_get_bits(&gb, buf, ctx->m.bits_per_frame);
585
    init_get_bits(&gb, buf, mode_par->bits_per_frame);
586 586

  
587
    for (i = 0; i < ctx->m.frames_per_packet; i++) {
588
        decode_parameters(&parm, &gb, &ctx->m);
587
    for (i = 0; i < mode_par->frames_per_packet; i++) {
588
        decode_parameters(&parm, &gb, mode_par);
589 589
        decode_frame(ctx, &parm, data);
590 590

  
591
        data += SUBFR_SIZE * ctx->m.subframe_count;
591
        data += SUBFR_SIZE * mode_par->subframe_count;
592 592
    }
593 593

  
594
    *data_size = ctx->m.frames_per_packet * SUBFR_SIZE *
595
        ctx->m.subframe_count * sizeof(float);
594
    *data_size = mode_par->frames_per_packet * SUBFR_SIZE *
595
        mode_par->subframe_count * sizeof(float);
596 596

  
597
    return ctx->m.bits_per_frame >> 3;
597
    return mode_par->bits_per_frame >> 3;
598 598
};
599 599

  
600 600
AVCodec sipr_decoder = {

Also available in: Unified diff