Logo Search packages:      
Sourcecode: blender version File versions

int avcodec_open ( AVCodecContext avctx,
AVCodec codec 
)

opens / inits the AVCodecContext. not thread save!

Definition at line 843 of file utils.c.

References av_freep(), avcodec_open(), AVCodecContext::codec, AVCodecContext::codec_id, AVCodecContext::coded_height, AVCodecContext::coded_width, AVCodecContext::frame_number, AVCodecContext::height, AVCodec::id, AVCodec::init, AVCodecContext::priv_data, AVCodec::priv_data_size, and AVCodecContext::width.

Referenced by avcodec_open().

{
    int ret= -1;

    entangled_thread_counter++;
    if(entangled_thread_counter != 1){
        av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
        goto end;
    }

    if(avctx->codec)
        goto end;

    if (codec->priv_data_size > 0) {
        avctx->priv_data = av_mallocz(codec->priv_data_size);
        if (!avctx->priv_data)
            goto end;
    } else {
        avctx->priv_data = NULL;
    }

    if(avctx->coded_width && avctx->coded_height)
        avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
    else if(avctx->width && avctx->height)
        avcodec_set_dimensions(avctx, avctx->width, avctx->height);

    if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)){
        av_freep(&avctx->priv_data);
        goto end;
    }

    avctx->codec = codec;
    avctx->codec_id = codec->id;
    avctx->frame_number = 0;
    ret = avctx->codec->init(avctx);
    if (ret < 0) {
        av_freep(&avctx->priv_data);
        avctx->codec= NULL;
        goto end;
    }
    ret=0;
end:
    entangled_thread_counter--;
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index