Revision 313b52fb libavcodec/alac.c

View differences:

libavcodec/alac.c
65 65

  
66 66
    AVCodecContext *avctx;
67 67
    GetBitContext gb;
68
    /* init to 0; first frame decode should initialize from extradata and
69
     * set this to 1 */
70
    int context_initialized;
71 68

  
72 69
    int numchannels;
73 70
    int bytespersample;
......
471 468

  
472 469
    /* short-circuit null buffers */
473 470
    if (!inbuffer || !input_buffer_size)
474
        return input_buffer_size;
475

  
476
    /* initialize from the extradata */
477
    if (!alac->context_initialized) {
478
        if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
479
            av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
480
                ALAC_EXTRADATA_SIZE);
481
            return input_buffer_size;
482
        }
483
        if (alac_set_info(alac)) {
484
            av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
485
            return input_buffer_size;
486
        }
487
        alac->context_initialized = 1;
488
    }
471
        return -1;
489 472

  
490 473
    init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
491 474

  
......
493 476
    if (channels > MAX_CHANNELS) {
494 477
        av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
495 478
               MAX_CHANNELS);
496
        return input_buffer_size;
479
        return -1;
497 480
    }
498 481

  
499 482
    /* 2^result = something to do with output waiting.
......
678 661
{
679 662
    ALACContext *alac = avctx->priv_data;
680 663
    alac->avctx = avctx;
681
    alac->context_initialized = 0;
682

  
683 664
    alac->numchannels = alac->avctx->channels;
684 665

  
666
    /* initialize from the extradata */
667
    if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
668
        av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
669
            ALAC_EXTRADATA_SIZE);
670
        return -1;
671
    }
672
    if (alac_set_info(alac)) {
673
        av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
674
        return -1;
675
    }
676

  
685 677
    return 0;
686 678
}
687 679

  

Also available in: Unified diff