diff options
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/va/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/va/meson.build | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/va/picture.c | 188 | ||||
-rw-r--r-- | src/gallium/state_trackers/va/picture_h264_enc.c | 202 | ||||
-rw-r--r-- | src/gallium/state_trackers/va/va_private.h | 6 |
5 files changed, 260 insertions, 139 deletions
diff --git a/src/gallium/state_trackers/va/Makefile.sources b/src/gallium/state_trackers/va/Makefile.sources index 2d6546b4b66..8a69828c01c 100644 --- a/src/gallium/state_trackers/va/Makefile.sources +++ b/src/gallium/state_trackers/va/Makefile.sources @@ -8,6 +8,7 @@ C_SOURCES := \ picture_mpeg12.c \ picture_mpeg4.c \ picture_h264.c \ + picture_h264_enc.c \ picture_hevc.c \ picture_vc1.c \ picture_mjpeg.c \ diff --git a/src/gallium/state_trackers/va/meson.build b/src/gallium/state_trackers/va/meson.build index 56e68e9e28d..0dec48c930d 100644 --- a/src/gallium/state_trackers/va/meson.build +++ b/src/gallium/state_trackers/va/meson.build @@ -26,7 +26,7 @@ libva_st = static_library( 'buffer.c', 'config.c', 'context.c', 'display.c', 'image.c', 'picture.c', 'picture_mpeg12.c', 'picture_mpeg4.c', 'picture_h264.c', 'picture_hevc.c', 'picture_vc1.c', 'picture_mjpeg.c', 'postproc.c', 'subpicture.c', - 'surface.c', + 'surface.c', 'picture_h264_enc.c', ), c_args : [ c_vis_args, diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 8cdd2240d53..7c72188c2d0 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -104,46 +104,6 @@ vlVaGetReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, *ref_frame = NULL; } -static void -getEncParamPreset(vlVaContext *context) -{ - //motion estimation preset - context->desc.h264enc.motion_est.motion_est_quarter_pixel = 0x00000001; - context->desc.h264enc.motion_est.lsmvert = 0x00000002; - context->desc.h264enc.motion_est.enc_disable_sub_mode = 0x00000078; - context->desc.h264enc.motion_est.enc_en_ime_overw_dis_subm = 0x00000001; - context->desc.h264enc.motion_est.enc_ime_overw_dis_subm_no = 0x00000001; - context->desc.h264enc.motion_est.enc_ime2_search_range_x = 0x00000004; - context->desc.h264enc.motion_est.enc_ime2_search_range_y = 0x00000004; - - //pic control preset - context->desc.h264enc.pic_ctrl.enc_cabac_enable = 0x00000001; - context->desc.h264enc.pic_ctrl.enc_constraint_set_flags = 0x00000040; - - //rate control - context->desc.h264enc.rate_ctrl.vbv_buffer_size = 20000000; - context->desc.h264enc.rate_ctrl.vbv_buf_lv = 48; - context->desc.h264enc.rate_ctrl.fill_data_enable = 1; - context->desc.h264enc.rate_ctrl.enforce_hrd = 1; - context->desc.h264enc.enable_vui = false; - if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0 || - context->desc.h264enc.rate_ctrl.frame_rate_den == 0) { - context->desc.h264enc.rate_ctrl.frame_rate_num = 30; - context->desc.h264enc.rate_ctrl.frame_rate_den = 1; - } - context->desc.h264enc.rate_ctrl.target_bits_picture = - context->desc.h264enc.rate_ctrl.target_bitrate * - ((float)context->desc.h264enc.rate_ctrl.frame_rate_den / - context->desc.h264enc.rate_ctrl.frame_rate_num); - context->desc.h264enc.rate_ctrl.peak_bits_picture_integer = - context->desc.h264enc.rate_ctrl.peak_bitrate * - ((float)context->desc.h264enc.rate_ctrl.frame_rate_den / - context->desc.h264enc.rate_ctrl.frame_rate_num); - - context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0; - context->desc.h264enc.ref_pic_mode = 0x00000201; -} - static VAStatus handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { @@ -354,55 +314,52 @@ handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf) static VAStatus handleVAEncMiscParameterTypeRateControl(vlVaContext *context, VAEncMiscParameterBuffer *misc) { - VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl *)misc->data; - if (context->desc.h264enc.rate_ctrl.rate_ctrl_method == - PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT) - context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second; - else - context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * (rc->target_percentage / 100.0); - context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second; - if (context->desc.h264enc.rate_ctrl.target_bitrate < 2000000) - context->desc.h264enc.rate_ctrl.vbv_buffer_size = MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 2000000); - else - context->desc.h264enc.rate_ctrl.vbv_buffer_size = context->desc.h264enc.rate_ctrl.target_bitrate; + VAStatus status = VA_STATUS_SUCCESS; - return VA_STATUS_SUCCESS; + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + status = vlVaHandleVAEncMiscParameterTypeRateControlH264(context, misc); + break; + + default: + break; + } + + return status; } static VAStatus handleVAEncMiscParameterTypeFrameRate(vlVaContext *context, VAEncMiscParameterBuffer *misc) { - VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data; - if (fr->framerate & 0xffff0000) { - context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate & 0xffff; - context->desc.h264enc.rate_ctrl.frame_rate_den = fr->framerate >> 16 & 0xffff; - } else { - context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate; - context->desc.h264enc.rate_ctrl.frame_rate_den = 1; + VAStatus status = VA_STATUS_SUCCESS; + + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + status = vlVaHandleVAEncMiscParameterTypeFrameRateH264(context, misc); + break; + + default: + break; } - return VA_STATUS_SUCCESS; + + return status; } static VAStatus handleVAEncSequenceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { - VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 *)buf->data; - if (!context->decoder) { - context->templat.max_references = h264->max_num_ref_frames; - context->templat.level = h264->level_idc; - context->decoder = drv->pipe->create_video_codec(drv->pipe, &context->templat); - if (!context->decoder) - return VA_STATUS_ERROR_ALLOCATION_FAILED; + VAStatus status = VA_STATUS_SUCCESS; + + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + status = vlVaHandleVAEncSequenceParameterBufferTypeH264(drv, context, buf); + break; + + default: + break; } - context->gop_coeff = ((1024 + h264->intra_idr_period - 1) / h264->intra_idr_period + 1) / 2 * 2; - if (context->gop_coeff > VL_VA_ENC_GOP_COEFF) - context->gop_coeff = VL_VA_ENC_GOP_COEFF; - context->desc.h264enc.gop_size = h264->intra_idr_period * context->gop_coeff; - context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2; - context->desc.h264enc.rate_ctrl.frame_rate_den = h264->num_units_in_tick; - context->desc.h264enc.pic_order_cnt_type = h264->seq_fields.bits.pic_order_cnt_type; - return VA_STATUS_SUCCESS; + return status; } static VAStatus @@ -431,80 +388,35 @@ handleVAEncMiscParameterBufferType(vlVaContext *context, vlVaBuffer *buf) static VAStatus handleVAEncPictureParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { - VAEncPictureParameterBufferH264 *h264; - vlVaBuffer *coded_buf; + VAStatus status = VA_STATUS_SUCCESS; - h264 = buf->data; - context->desc.h264enc.frame_num = h264->frame_num; - context->desc.h264enc.not_referenced = false; - context->desc.h264enc.pic_order_cnt = h264->CurrPic.TopFieldOrderCnt; - if (context->desc.h264enc.gop_cnt == 0) - context->desc.h264enc.i_remain = context->gop_coeff; - else if (context->desc.h264enc.frame_num == 1) - context->desc.h264enc.i_remain--; - - context->desc.h264enc.p_remain = context->desc.h264enc.gop_size - context->desc.h264enc.gop_cnt - context->desc.h264enc.i_remain; - - coded_buf = handle_table_get(drv->htab, h264->coded_buf); - if (!coded_buf->derived_surface.resource) - coded_buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - PIPE_USAGE_STREAM, coded_buf->size); - context->coded_buf = coded_buf; - - util_hash_table_set(context->desc.h264enc.frame_idx, - UINT_TO_PTR(h264->CurrPic.picture_id), - UINT_TO_PTR(h264->frame_num)); - - if (h264->pic_fields.bits.idr_pic_flag == 1) - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_IDR; - else - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_P; + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + status = vlVaHandleVAEncPictureParameterBufferTypeH264(drv, context, buf); + break; - context->desc.h264enc.quant_i_frames = h264->pic_init_qp; - context->desc.h264enc.quant_b_frames = h264->pic_init_qp; - context->desc.h264enc.quant_p_frames = h264->pic_init_qp; - context->desc.h264enc.gop_cnt++; - if (context->desc.h264enc.gop_cnt == context->desc.h264enc.gop_size) - context->desc.h264enc.gop_cnt = 0; + default: + break; + } - return VA_STATUS_SUCCESS; + return status; } static VAStatus handleVAEncSliceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { - VAEncSliceParameterBufferH264 *h264; + VAStatus status = VA_STATUS_SUCCESS; - h264 = buf->data; - context->desc.h264enc.ref_idx_l0 = VA_INVALID_ID; - context->desc.h264enc.ref_idx_l1 = VA_INVALID_ID; + switch (u_reduce_video_profile(context->templat.profile)) { + case PIPE_VIDEO_FORMAT_MPEG4_AVC: + status = vlVaHandleVAEncSliceParameterBufferTypeH264(drv, context, buf); + break; - for (int i = 0; i < 32; i++) { - if (h264->RefPicList0[i].picture_id != VA_INVALID_ID) { - if (context->desc.h264enc.ref_idx_l0 == VA_INVALID_ID) - context->desc.h264enc.ref_idx_l0 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx, - UINT_TO_PTR(h264->RefPicList0[i].picture_id))); - } - if (h264->RefPicList1[i].picture_id != VA_INVALID_ID && h264->slice_type == 1) { - if (context->desc.h264enc.ref_idx_l1 == VA_INVALID_ID) - context->desc.h264enc.ref_idx_l1 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx, - UINT_TO_PTR(h264->RefPicList1[i].picture_id))); - } + default: + break; } - if (h264->slice_type == 1) - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_B; - else if (h264->slice_type == 0) - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_P; - else if (h264->slice_type == 2) { - if (context->desc.h264enc.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) - context->desc.h264enc.idr_pic_id++; - else - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_I; - } else - context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_SKIP; - - return VA_STATUS_SUCCESS; + return status; } VAStatus @@ -695,7 +607,7 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) { coded_buf = context->coded_buf; - getEncParamPreset(context); + getEncParamPresetH264(context); context->desc.h264enc.frame_num_cnt++; context->decoder->begin_frame(context->decoder, context->target, &context->desc.base); context->decoder->encode_bitstream(context->decoder, context->target, diff --git a/src/gallium/state_trackers/va/picture_h264_enc.c b/src/gallium/state_trackers/va/picture_h264_enc.c new file mode 100644 index 00000000000..abfd39633de --- /dev/null +++ b/src/gallium/state_trackers/va/picture_h264_enc.c @@ -0,0 +1,202 @@ +/************************************************************************** + * + * Copyright 2018 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "util/u_handle_table.h" +#include "util/u_video.h" +#include "va_private.h" + +VAStatus +vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) +{ + VAEncPictureParameterBufferH264 *h264; + vlVaBuffer *coded_buf; + + h264 = buf->data; + context->desc.h264enc.frame_num = h264->frame_num; + context->desc.h264enc.not_referenced = false; + context->desc.h264enc.pic_order_cnt = h264->CurrPic.TopFieldOrderCnt; + if (context->desc.h264enc.gop_cnt == 0) + context->desc.h264enc.i_remain = context->gop_coeff; + else if (context->desc.h264enc.frame_num == 1) + context->desc.h264enc.i_remain--; + + context->desc.h264enc.p_remain = context->desc.h264enc.gop_size - context->desc.h264enc.gop_cnt - context->desc.h264enc.i_remain; + + coded_buf = handle_table_get(drv->htab, h264->coded_buf); + if (!coded_buf->derived_surface.resource) + coded_buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_STREAM, coded_buf->size); + context->coded_buf = coded_buf; + + util_hash_table_set(context->desc.h264enc.frame_idx, + UINT_TO_PTR(h264->CurrPic.picture_id), + UINT_TO_PTR(h264->frame_num)); + + if (h264->pic_fields.bits.idr_pic_flag == 1) + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_IDR; + else + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_P; + + context->desc.h264enc.quant_i_frames = h264->pic_init_qp; + context->desc.h264enc.quant_b_frames = h264->pic_init_qp; + context->desc.h264enc.quant_p_frames = h264->pic_init_qp; + context->desc.h264enc.gop_cnt++; + if (context->desc.h264enc.gop_cnt == context->desc.h264enc.gop_size) + context->desc.h264enc.gop_cnt = 0; + + return VA_STATUS_SUCCESS; +} + +VAStatus +vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) +{ + VAEncSliceParameterBufferH264 *h264; + + h264 = buf->data; + context->desc.h264enc.ref_idx_l0 = VA_INVALID_ID; + context->desc.h264enc.ref_idx_l1 = VA_INVALID_ID; + + for (int i = 0; i < 32; i++) { + if (h264->RefPicList0[i].picture_id != VA_INVALID_ID) { + if (context->desc.h264enc.ref_idx_l0 == VA_INVALID_ID) + context->desc.h264enc.ref_idx_l0 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx, + UINT_TO_PTR(h264->RefPicList0[i].picture_id))); + } + if (h264->RefPicList1[i].picture_id != VA_INVALID_ID && h264->slice_type == 1) { + if (context->desc.h264enc.ref_idx_l1 == VA_INVALID_ID) + context->desc.h264enc.ref_idx_l1 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx, + UINT_TO_PTR(h264->RefPicList1[i].picture_id))); + } + } + + if (h264->slice_type == 1) + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_B; + else if (h264->slice_type == 0) + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_P; + else if (h264->slice_type == 2) { + if (context->desc.h264enc.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) + context->desc.h264enc.idr_pic_id++; + else + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_I; + } else + context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_SKIP; + + return VA_STATUS_SUCCESS; +} + +VAStatus +vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) +{ + VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 *)buf->data; + if (!context->decoder) { + context->templat.max_references = h264->max_num_ref_frames; + context->templat.level = h264->level_idc; + context->decoder = drv->pipe->create_video_codec(drv->pipe, &context->templat); + if (!context->decoder) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + + context->gop_coeff = ((1024 + h264->intra_idr_period - 1) / h264->intra_idr_period + 1) / 2 * 2; + if (context->gop_coeff > VL_VA_ENC_GOP_COEFF) + context->gop_coeff = VL_VA_ENC_GOP_COEFF; + context->desc.h264enc.gop_size = h264->intra_idr_period * context->gop_coeff; + context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2; + context->desc.h264enc.rate_ctrl.frame_rate_den = h264->num_units_in_tick; + context->desc.h264enc.pic_order_cnt_type = h264->seq_fields.bits.pic_order_cnt_type; + return VA_STATUS_SUCCESS; +} + +VAStatus +vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscParameterBuffer *misc) +{ + VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl *)misc->data; + if (context->desc.h264enc.rate_ctrl.rate_ctrl_method == + PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT) + context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second; + else + context->desc.h264enc.rate_ctrl.target_bitrate = rc->bits_per_second * (rc->target_percentage / 100.0); + context->desc.h264enc.rate_ctrl.peak_bitrate = rc->bits_per_second; + if (context->desc.h264enc.rate_ctrl.target_bitrate < 2000000) + context->desc.h264enc.rate_ctrl.vbv_buffer_size = MIN2((context->desc.h264enc.rate_ctrl.target_bitrate * 2.75), 2000000); + else + context->desc.h264enc.rate_ctrl.vbv_buffer_size = context->desc.h264enc.rate_ctrl.target_bitrate; + + return VA_STATUS_SUCCESS; +} + +VAStatus +vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscParameterBuffer *misc) +{ + VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data; + if (fr->framerate & 0xffff0000) { + context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate & 0xffff; + context->desc.h264enc.rate_ctrl.frame_rate_den = fr->framerate >> 16 & 0xffff; + } else { + context->desc.h264enc.rate_ctrl.frame_rate_num = fr->framerate; + context->desc.h264enc.rate_ctrl.frame_rate_den = 1; + } + return VA_STATUS_SUCCESS; +} + +void getEncParamPresetH264(vlVaContext *context) +{ + //motion estimation preset + context->desc.h264enc.motion_est.motion_est_quarter_pixel = 0x00000001; + context->desc.h264enc.motion_est.lsmvert = 0x00000002; + context->desc.h264enc.motion_est.enc_disable_sub_mode = 0x00000078; + context->desc.h264enc.motion_est.enc_en_ime_overw_dis_subm = 0x00000001; + context->desc.h264enc.motion_est.enc_ime_overw_dis_subm_no = 0x00000001; + context->desc.h264enc.motion_est.enc_ime2_search_range_x = 0x00000004; + context->desc.h264enc.motion_est.enc_ime2_search_range_y = 0x00000004; + + //pic control preset + context->desc.h264enc.pic_ctrl.enc_cabac_enable = 0x00000001; + context->desc.h264enc.pic_ctrl.enc_constraint_set_flags = 0x00000040; + + //rate control + context->desc.h264enc.rate_ctrl.vbv_buffer_size = 20000000; + context->desc.h264enc.rate_ctrl.vbv_buf_lv = 48; + context->desc.h264enc.rate_ctrl.fill_data_enable = 1; + context->desc.h264enc.rate_ctrl.enforce_hrd = 1; + context->desc.h264enc.enable_vui = false; + if (context->desc.h264enc.rate_ctrl.frame_rate_num == 0 || + context->desc.h264enc.rate_ctrl.frame_rate_den == 0) { + context->desc.h264enc.rate_ctrl.frame_rate_num = 30; + context->desc.h264enc.rate_ctrl.frame_rate_den = 1; + } + context->desc.h264enc.rate_ctrl.target_bits_picture = + context->desc.h264enc.rate_ctrl.target_bitrate * + ((float)context->desc.h264enc.rate_ctrl.frame_rate_den / + context->desc.h264enc.rate_ctrl.frame_rate_num); + context->desc.h264enc.rate_ctrl.peak_bits_picture_integer = + context->desc.h264enc.rate_ctrl.peak_bitrate * + ((float)context->desc.h264enc.rate_ctrl.frame_rate_den / + context->desc.h264enc.rate_ctrl.frame_rate_num); + + context->desc.h264enc.rate_ctrl.peak_bits_picture_fraction = 0; + context->desc.h264enc.ref_pic_mode = 0x00000201; +} diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 46f6ba66f2a..eef75c6bdae 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -426,5 +426,11 @@ void vlVaHandlePictureParameterBufferMJPEG(vlVaDriver *drv, vlVaContext *context void vlVaHandleIQMatrixBufferMJPEG(vlVaContext *context, vlVaBuffer *buf); void vlVaHandleHuffmanTableBufferType(vlVaContext *context, vlVaBuffer *buf); void vlVaHandleSliceParameterBufferMJPEG(vlVaContext *context, vlVaBuffer *buf); +void getEncParamPresetH264(vlVaContext *context); +VAStatus vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); +VAStatus vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); +VAStatus vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf); +VAStatus vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscParameterBuffer *buf); +VAStatus vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscParameterBuffer *buf); #endif //VA_PRIVATE_H |