Exemplo n.º 1
0
static VAStatus tng_yuv_processor_CreateContext(
    object_context_p obj_context,
    object_config_p obj_config)
{
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    context_DEC_p dec_ctx = (context_DEC_p) obj_context->format_data;
    context_yuv_processor_p ctx;

    ctx = (context_yuv_processor_p) malloc(sizeof(struct context_yuv_processor_s));
    CHECK_ALLOCATION(ctx);

    /* ctx could be create in/out another dec context */
    ctx->has_dec_ctx = 0;
    ctx->src_surface = NULL;

    if (!dec_ctx) {
        dec_ctx = (context_DEC_p) malloc(sizeof(struct context_DEC_s));
        CHECK_ALLOCATION(dec_ctx);
        obj_context->format_data = (void *)dec_ctx;
        ctx->has_dec_ctx = 1;
        vaStatus = vld_dec_CreateContext(dec_ctx, obj_context);
        DEBUG_FAILURE;
    }

    dec_ctx->yuv_ctx = ctx;
    dec_ctx->process_buffer = tng_yuv_processor_process_buffer;

    return vaStatus;
}
static VAStatus tng_yuv_processor_CreateContext(
    object_context_p obj_context,
    object_config_p __maybe_unused obj_config)
{
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    context_DEC_p dec_ctx = (context_DEC_p) obj_context->format_data;
    context_yuv_processor_p ctx;

    ctx = (context_yuv_processor_p) malloc(sizeof(struct context_yuv_processor_s));
    CHECK_ALLOCATION(ctx);

    /* ctx could be create in/out another dec context */
    ctx->has_dec_ctx = 0;
    ctx->src_surface = NULL;

    if (!dec_ctx) {
        dec_ctx = (context_DEC_p) malloc(sizeof(struct context_DEC_s));
        if(dec_ctx == NULL) {
            free(ctx);
            vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
            drv_debug_msg(VIDEO_DEBUG_ERROR, "%s fails with '%d' at %s:%d\n", __FUNCTION__, vaStatus, __FILE__, __LINE__);
            return vaStatus;
        }
        obj_context->format_data = (void *)dec_ctx;
        ctx->has_dec_ctx = 1;
        vaStatus = vld_dec_CreateContext(dec_ctx, obj_context);
        DEBUG_FAILURE;
    }

    dec_ctx->yuv_ctx = ctx;
    dec_ctx->process_buffer = tng_yuv_processor_process_buffer;

    return vaStatus;
}
Exemplo n.º 3
0
static VAStatus tng_JPEG_CreateContext(
    object_context_p obj_context,
    object_config_p obj_config) {
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    context_JPEG_p ctx;

    /* Validate flag */
    /* Validate picture dimensions */
    vaStatus = tng__JPEG_check_legal_picture(obj_context, obj_config);
    if (VA_STATUS_SUCCESS != vaStatus) {
        DEBUG_FAILURE;
        return vaStatus;
    }

    ctx = (context_JPEG_p) calloc(1, sizeof(struct context_JPEG_s));
    if (NULL == ctx) {
        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
        DEBUG_FAILURE;
        return vaStatus;
    }
    obj_context->format_data = (void*) ctx;
    ctx->obj_context = obj_context;
    ctx->pic_params = NULL;

    ctx->dec_ctx.begin_slice = tng__JPEG_begin_slice;
    ctx->dec_ctx.process_slice = tng__JPEG_process_slice_data;
    ctx->dec_ctx.end_slice = tng__JPEG_end_slice;
    ctx->dec_ctx.process_buffer = tng_JPEG_process_buffer;
    ctx->dec_ctx.preload_buffer = NULL;

    switch (obj_config->profile) {
    case VAProfileJPEGBaseline:
        drv_debug_msg(VIDEO_DEBUG_GENERAL, "JPEG_PROFILE_BASELINE\n");
        ctx->profile = JPEG_PROFILE_BASELINE;
        break;

    default:
        ASSERT(0 == 1);
        vaStatus = VA_STATUS_ERROR_UNKNOWN;
    }

    ctx->vlctable_buffer_size = 1984 * 2;
    if (vaStatus == VA_STATUS_SUCCESS) {
        vaStatus = psb_buffer_create(obj_context->driver_data,
                                     ctx->vlctable_buffer_size,
                                     psb_bt_cpu_vpu,
                                     &ctx->vlc_packed_table);
        DEBUG_FAILURE;
    }

    if (vaStatus == VA_STATUS_SUCCESS) {
        vaStatus = vld_dec_CreateContext(&ctx->dec_ctx, obj_context);
        DEBUG_FAILURE;
    }

    if (vaStatus != VA_STATUS_SUCCESS) {
        tng_JPEG_DestroyContext(obj_context);
    }

    return vaStatus;
}