예제 #1
0
static VAStatus vsp_VP8_CreateContext(
    object_context_p obj_context,
    object_config_p obj_config)
{
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    /* currently vp8 will use vpp's context since they will use the same cmdbuf */
    context_VPP_p ctx;
    int i;

    ctx = (context_VPP_p) calloc(1, sizeof(struct context_VPP_s));
    if (NULL == ctx) {
        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
        DEBUG_FAILURE;
        return vaStatus;
    }

    //set default VP8 sequence params
    vsp_VP8_set_default_params(&ctx->vp8_seq_param);
    ctx->temporal_layer_number = 1;

    for (i = 0; i < obj_config->attrib_count; i++) {
        if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) {
            if (obj_config->attrib_list[i].value == VA_RC_VCM)
               ctx->vp8_seq_param.rc_end_usage = VP8_ENC_SMOOTH_CBR_HRD;
            else
               ctx->vp8_seq_param.rc_end_usage = VP8_ENC_CBR;
        }
    }

    /* set size */
    ctx->param_sz = 0;
    ctx->pic_param_sz = ALIGN_TO_128(sizeof(struct VssVp8encPictureParameterBuffer));
    ctx->param_sz += ctx->pic_param_sz;
    ctx->seq_param_sz = ALIGN_TO_128(sizeof(struct VssVp8encSequenceParameterBuffer));
    ctx->param_sz += ctx->seq_param_sz;
    ctx->ref_param_sz = ALIGN_TO_128(sizeof(ref_frame_surface));
    ctx->param_sz += ctx->ref_param_sz;

    /* set offset */
    ctx->pic_param_offset = 0;
    ctx->seq_param_offset = ctx->pic_param_sz;
    ctx->ref_param_offset = ctx->pic_param_sz + ctx->seq_param_sz;


    ctx->context_buf = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s));
    if (NULL == ctx->context_buf) {
        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
        DEBUG_FAILURE;
        goto out;
    }

    vaStatus = psb_buffer_create(obj_context->driver_data, VSP_VP8ENC_STATE_SIZE, psb_bt_vpu_only, ctx->context_buf);

    if (VA_STATUS_SUCCESS != vaStatus) {
        goto out;
    }

    obj_context->format_data = (void*) ctx;
    ctx->obj_context = obj_context;

    return vaStatus;

out:
    vsp_VP8_DestroyContext(obj_context);

    if (ctx)
        free(ctx);

    return vaStatus;
}
예제 #2
0
파일: vsp_vp8.c 프로젝트: 01org/psb_video
static VAStatus vsp_VP8_CreateContext(
    object_context_p obj_context,
    object_config_p obj_config)
{
    VAStatus vaStatus = VA_STATUS_SUCCESS;
    /* currently vp8 will use vpp's context since they will use the same cmdbuf */
    context_VPP_p ctx;
    int i;

    ctx = (context_VPP_p) calloc(1, sizeof(struct context_VPP_s));
    if (NULL == ctx) {
        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
        DEBUG_FAILURE;
        return vaStatus;
    }

    for (i = 0; i < obj_config->attrib_count; i++) {
	if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) {
            ctx->rc_mode = obj_config->attrib_list[i].value;
	    break;
	}
    }

    /* set size */
    ctx->param_sz = 0;
    ctx->pic_param_sz = ALIGN_TO_128(sizeof(struct VssVp8encPictureParameterBuffer));
    ctx->param_sz += ctx->pic_param_sz;
    ctx->seq_param_sz = ALIGN_TO_128(sizeof(struct VssVp8encSequenceParameterBuffer));
    ctx->param_sz += ctx->seq_param_sz;
    ctx->ref_param_sz = ALIGN_TO_128(sizeof(ref_frame_surface));
    ctx->param_sz += ctx->ref_param_sz;

    /* set offset */
    ctx->pic_param_offset = 0;
    ctx->seq_param_offset = ctx->pic_param_sz;
    ctx->ref_param_offset = ctx->pic_param_sz + ctx->seq_param_sz;

    ctx->min_qp = 4;
    ctx->max_qp = 63;
    ctx->rc_undershoot = 100;
    ctx->buffer_size = 6000;
    ctx->initial_buffer_fullness = 4000;
    ctx->optimal_buffer_fullness = 5000;

    ctx->context_buf = (psb_buffer_p) calloc(1, sizeof(struct psb_buffer_s));
    if (NULL == ctx->context_buf) {
        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
        DEBUG_FAILURE;
        goto out;
    }

    vaStatus = psb_buffer_create(obj_context->driver_data, VSP_VP8ENC_STATE_SIZE, psb_bt_vpu_only, ctx->context_buf);

    if (VA_STATUS_SUCCESS != vaStatus) {
        goto out;
    }

    obj_context->format_data = (void*) ctx;
    ctx->obj_context = obj_context;

    return vaStatus;

out:
    vsp_VP8_DestroyContext(obj_context);

    if (ctx)
        free(ctx);

    return vaStatus;
}