static av_cold int vdadec_init(AVCodecContext *avctx)
{
    VDADecoderContext *ctx = avctx->priv_data;
    struct vda_context *vda_ctx = &ctx->vda_ctx;
    OSStatus status;
    int ret;
    ctx->h264_initialized = 0;
    /* init pix_fmts of codec */
    if (!ff_h264_vda_decoder.pix_fmts) {
        if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
        else
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
    /* init vda */
    memset(vda_ctx, 0, sizeof(struct vda_context));
    vda_ctx->width = avctx->width;
    vda_ctx->height = avctx->height;
    vda_ctx->format = 'avc1';
    vda_ctx->use_sync_decoding = 1;
    vda_ctx->use_ref_buffer = 1;
    ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
    switch (ctx->pix_fmt) {
    case AV_PIX_FMT_UYVY422:
        vda_ctx->cv_pix_fmt_type = '2vuy';
        break;
    case AV_PIX_FMT_YUYV422:
        vda_ctx->cv_pix_fmt_type = 'yuvs';
        break;
    case AV_PIX_FMT_NV12:
        vda_ctx->cv_pix_fmt_type = '420v';
        break;
    case AV_PIX_FMT_YUV420P:
        vda_ctx->cv_pix_fmt_type = 'y420';
        break;
    default:
        av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
    status = ff_vda_create_decoder(vda_ctx,
                                   avctx->extradata, avctx->extradata_size);
    if (status != kVDADecoderNoErr) {
        av_log(avctx, AV_LOG_ERROR,
                "Failed to init VDA decoder: %d.\n", status);
    /* init H.264 decoder */
    set_context(avctx);
    ret = ff_h264_decoder.init(avctx);
    restore_context(avctx);
    if (ret < 0) {
        av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n");
    ctx->h264_initialized = 1;
    return 0;
failed:
    vdadec_close(avctx);
    return -1;
static av_cold int vdadec_init(AVCodecContext *avctx)
{
    VDADecoderContext *ctx = avctx->priv_data;
    struct vda_context *vda_ctx = &ctx->vda_ctx;
    OSStatus status;
    int ret;
    ctx->h264_initialized = 0;
    
    if (!ff_h264_vda_decoder.pix_fmts) {
        if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
        else
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
    
    memset(vda_ctx, 0, sizeof(struct vda_context));
    vda_ctx->width = avctx->width;
    vda_ctx->height = avctx->height;
    vda_ctx->format = 'avc1';
    vda_ctx->use_sync_decoding = 1;
    vda_ctx->use_ref_buffer = 1;
    ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
    switch (ctx->pix_fmt) {
    case AV_PIX_FMT_UYVY422:
        vda_ctx->cv_pix_fmt_type = '2vuy';
        break;
    case AV_PIX_FMT_YUYV422:
        vda_ctx->cv_pix_fmt_type = 'yuvs';
        break;
    case AV_PIX_FMT_NV12:
        vda_ctx->cv_pix_fmt_type = '420v';
        break;
    case AV_PIX_FMT_YUV420P:
        vda_ctx->cv_pix_fmt_type = 'y420';
        break;
    default:
        av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
    status = ff_vda_create_decoder(vda_ctx,
                                   avctx->extradata, avctx->extradata_size);
    if (status != kVDADecoderNoErr) {
        av_log(avctx, AV_LOG_ERROR,
                "Failed to init VDA decoder: %d.\n", status);
    
    set_context(avctx);
    ret = ff_h264_decoder.init(avctx);
    restore_context(avctx);
    if (ret < 0) {
        av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n");
    ctx->h264_initialized = 1;
    return 0;
failed:
    vdadec_close(avctx);
    return -1;
static av_cold int FUNC_0(AVCodecContext *avctx)
{
    VDADecoderContext *ctx = avctx->priv_data;
    struct vda_context *VAR_0 = &ctx->VAR_0;
    OSStatus status;
    int VAR_1;
    ctx->h264_initialized = 0;
    
    if (!ff_h264_vda_decoder.pix_fmts) {
        if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
        else
            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
    
    memset(VAR_0, 0, sizeof(struct vda_context));
    VAR_0->width = avctx->width;
    VAR_0->height = avctx->height;
    VAR_0->format = 'avc1';
    VAR_0->use_sync_decoding = 1;
    VAR_0->use_ref_buffer = 1;
    ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
    switch (ctx->pix_fmt) {
    case AV_PIX_FMT_UYVY422:
        VAR_0->cv_pix_fmt_type = '2vuy';
        break;
    case AV_PIX_FMT_YUYV422:
        VAR_0->cv_pix_fmt_type = 'yuvs';
        break;
    case AV_PIX_FMT_NV12:
        VAR_0->cv_pix_fmt_type = '420v';
        break;
    case AV_PIX_FMT_YUV420P:
        VAR_0->cv_pix_fmt_type = 'y420';
        break;
    default:
        av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
    status = ff_vda_create_decoder(VAR_0,
                                   avctx->extradata, avctx->extradata_size);
    if (status != kVDADecoderNoErr) {
        av_log(avctx, AV_LOG_ERROR,
                "Failed to init VDA decoder: %d.\n", status);
    
    set_context(avctx);
    VAR_1 = ff_h264_decoder.init(avctx);
    restore_context(avctx);
    if (VAR_1 < 0) {
        av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n");
    ctx->h264_initialized = 1;
    return 0;
failed:
    vdadec_close(avctx);
    return -1;
static av_cold int FUNC_0(AVCodecContext *avctx)
{ VDADecoderContext *ctx = avctx->priv_data; struct vda_context *VAR_0 = &ctx->VAR_0; OSStatus status; int VAR_1; ctx->h264_initialized = 0; if (!ff_h264_vda_decoder.pix_fmts) { if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7; else
ff_h264_vda_decoder.pix_fmts = vda_pixfmts; memset(VAR_0, 0, sizeof(struct vda_context)); VAR_0->width = avctx->width; VAR_0->height = avctx->height; VAR_0->format = 'avc1'; VAR_0->use_sync_decoding = 1; VAR_0->use_ref_buffer = 1; ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); switch (ctx->pix_fmt) { case AV_PIX_FMT_UYVY422:
VAR_0->cv_pix_fmt_type = '2vuy'; break; case AV_PIX_FMT_YUYV422:
VAR_0->cv_pix_fmt_type = 'yuvs'; break; case AV_PIX_FMT_NV12:
VAR_0->cv_pix_fmt_type = '420v'; break; case AV_PIX_FMT_YUV420P:
VAR_0->cv_pix_fmt_type = 'y420'; break; default:
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt); status = ff_vda_create_decoder(VAR_0,
avctx->extradata, avctx->extradata_size); if (status != kVDADecoderNoErr) { av_log(avctx, AV_LOG_ERROR,
"Failed to init VDA decoder: %d.\n", status); set_context(avctx); VAR_1 = ff_h264_decoder.init(avctx); restore_context(avctx); if (VAR_1 < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n"); ctx->h264_initialized = 1; return 0; failed:
vdadec_close(avctx); return -1;