Revision dd8871a6 libavcodec/aacsbr.c

View differences:

libavcodec/aacsbr.c
293 293
    bands[num_bands-1] = stop - previous;
294 294
}
295 295

  
296
static int check_n_master(AVCodecContext *avccontext, int n_master, int bs_xover_band)
296
static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
297 297
{
298 298
    // Requirements (14496-3 sp04 p205)
299 299
    if (n_master <= 0) {
300
        av_log(avccontext, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
300
        av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
301 301
        return -1;
302 302
    }
303 303
    if (bs_xover_band >= n_master) {
304
        av_log(avccontext, AV_LOG_ERROR,
304
        av_log(avctx, AV_LOG_ERROR,
305 305
               "Invalid bitstream, crossover band index beyond array bounds: %d\n",
306 306
               bs_xover_band);
307 307
        return -1;
......
349 349
        sbr_offset_ptr = sbr_offset[5];
350 350
        break;
351 351
    default:
352
        av_log(ac->avccontext, AV_LOG_ERROR,
352
        av_log(ac->avctx, AV_LOG_ERROR,
353 353
               "Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
354 354
        return -1;
355 355
    }
......
367 367
    } else if (spectrum->bs_stop_freq == 15) {
368 368
        sbr->k[2] = 3*sbr->k[0];
369 369
    } else {
370
        av_log(ac->avccontext, AV_LOG_ERROR,
370
        av_log(ac->avctx, AV_LOG_ERROR,
371 371
               "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
372 372
        return -1;
373 373
    }
......
382 382
        max_qmf_subbands = 32;
383 383

  
384 384
    if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
385
        av_log(ac->avccontext, AV_LOG_ERROR,
385
        av_log(ac->avctx, AV_LOG_ERROR,
386 386
               "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
387 387
        return -1;
388 388
    }
......
393 393

  
394 394
        dk = spectrum->bs_alter_scale + 1;
395 395
        sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
396
        if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
396
        if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
397 397
            return -1;
398 398

  
399 399
        for (k = 1; k <= sbr->n_master; k++)
......
428 428
        num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2;
429 429

  
430 430
        if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205)
431
            av_log(ac->avccontext, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
431
            av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
432 432
            return -1;
433 433
        }
434 434

  
......
442 442
        vk0[0] = sbr->k[0];
443 443
        for (k = 1; k <= num_bands_0; k++) {
444 444
            if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205)
445
                av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
445
                av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
446 446
                return -1;
447 447
            }
448 448
            vk0[k] += vk0[k-1];
......
472 472
            vk1[0] = sbr->k[1];
473 473
            for (k = 1; k <= num_bands_1; k++) {
474 474
                if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205)
475
                    av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
475
                    av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
476 476
                    return -1;
477 477
                }
478 478
                vk1[k] += vk1[k-1];
479 479
            }
480 480

  
481 481
            sbr->n_master = num_bands_0 + num_bands_1;
482
            if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
482
            if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
483 483
                return -1;
484 484
            memcpy(&sbr->f_master[0],               vk0,
485 485
                   (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
......
488 488

  
489 489
        } else {
490 490
            sbr->n_master = num_bands_0;
491
            if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
491
            if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
492 492
                return -1;
493 493
            memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
494 494
        }
......
524 524
        // illegal however the Coding Technologies decoder check stream has a final
525 525
        // count of 6 patches
526 526
        if (sbr->num_patches > 5) {
527
            av_log(ac->avccontext, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
527
            av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
528 528
            return -1;
529 529
        }
530 530

  
......
563 563

  
564 564
    // Requirements (14496-3 sp04 p205)
565 565
    if (sbr->kx[1] + sbr->m[1] > 64) {
566
        av_log(ac->avccontext, AV_LOG_ERROR,
566
        av_log(ac->avctx, AV_LOG_ERROR,
567 567
               "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]);
568 568
        return -1;
569 569
    }
570 570
    if (sbr->kx[1] > 32) {
571
        av_log(ac->avccontext, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
571
        av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
572 572
        return -1;
573 573
    }
574 574

  
......
580 580
    sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands *
581 581
                               log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3
582 582
    if (sbr->n_q > 5) {
583
        av_log(ac->avccontext, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
583
        av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
584 584
        return -1;
585 585
    }
586 586

  
......
638 638
            ch_data->bs_amp_res = 0;
639 639

  
640 640
        if (ch_data->bs_num_env > 4) {
641
            av_log(ac->avccontext, AV_LOG_ERROR,
641
            av_log(ac->avctx, AV_LOG_ERROR,
642 642
                   "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
643 643
                   ch_data->bs_num_env);
644 644
            return -1;
......
693 693
        ch_data->bs_num_env                 = num_rel_lead + num_rel_trail + 1;
694 694

  
695 695
        if (ch_data->bs_num_env > 5) {
696
            av_log(ac->avccontext, AV_LOG_ERROR,
696
            av_log(ac->avctx, AV_LOG_ERROR,
697 697
                   "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
698 698
                   ch_data->bs_num_env);
699 699
            return -1;
......
714 714
    }
715 715

  
716 716
    if (bs_pointer > ch_data->bs_num_env + 1) {
717
        av_log(ac->avccontext, AV_LOG_ERROR,
717
        av_log(ac->avctx, AV_LOG_ERROR,
718 718
               "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
719 719
               bs_pointer);
720 720
        return -1;
......
722 722

  
723 723
    for (i = 1; i <= ch_data->bs_num_env; i++) {
724 724
        if (ch_data->t_env[i-1] > ch_data->t_env[i]) {
725
            av_log(ac->avccontext, AV_LOG_ERROR, "Non monotone time borders\n");
725
            av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n");
726 726
            return -1;
727 727
        }
728 728
    }
......
907 907
    switch (bs_extension_id) {
908 908
    case EXTENSION_ID_PS:
909 909
        if (!ac->m4ac.ps) {
910
            av_log(ac->avccontext, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
910
            av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
911 911
            skip_bits_long(gb, *num_bits_left); // bs_fill_bits
912 912
            *num_bits_left = 0;
913 913
        } else {
914 914
#if 0
915 915
            *num_bits_left -= ff_ps_data(gb, ps);
916 916
#else
917
            av_log_missing_feature(ac->avccontext, "Parametric Stereo is", 0);
917
            av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0);
918 918
            skip_bits_long(gb, *num_bits_left); // bs_fill_bits
919 919
            *num_bits_left = 0;
920 920
#endif
921 921
        }
922 922
        break;
923 923
    default:
924
        av_log_missing_feature(ac->avccontext, "Reserved SBR extensions are", 1);
924
        av_log_missing_feature(ac->avctx, "Reserved SBR extensions are", 1);
925 925
        skip_bits_long(gb, *num_bits_left); // bs_fill_bits
926 926
        *num_bits_left = 0;
927 927
        break;
......
1006 1006
            return get_bits_count(gb) - cnt;
1007 1007
        }
1008 1008
    } else {
1009
        av_log(ac->avccontext, AV_LOG_ERROR,
1009
        av_log(ac->avctx, AV_LOG_ERROR,
1010 1010
            "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
1011 1011
        sbr->start = 0;
1012 1012
        return get_bits_count(gb) - cnt;
......
1033 1033
    if (err >= 0)
1034 1034
        err = sbr_make_f_derived(ac, sbr);
1035 1035
    if (err < 0) {
1036
        av_log(ac->avccontext, AV_LOG_ERROR,
1036
        av_log(ac->avctx, AV_LOG_ERROR,
1037 1037
               "SBR reset failed. Switching SBR to pure upsampling mode.\n");
1038 1038
        sbr->start = 0;
1039 1039
    }
......
1085 1085
    bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
1086 1086

  
1087 1087
    if (bytes_read > cnt) {
1088
        av_log(ac->avccontext, AV_LOG_ERROR,
1088
        av_log(ac->avctx, AV_LOG_ERROR,
1089 1089
               "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read);
1090 1090
    }
1091 1091
    return cnt;
......
1380 1380
            g--;
1381 1381

  
1382 1382
            if (g < 0) {
1383
                av_log(ac->avccontext, AV_LOG_ERROR,
1383
                av_log(ac->avctx, AV_LOG_ERROR,
1384 1384
                       "ERROR : no subband found for frequency %d\n", k);
1385 1385
                return -1;
1386 1386
            }

Also available in: Unified diff