mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-17 17:10:38 +01:00
frontends/va: Add HEVC Encode support multi slice and extend pipe args
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18328>
This commit is contained in:
parent
52f23f923e
commit
56684b85e9
2 changed files with 50 additions and 1 deletions
|
|
@ -46,6 +46,7 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont
|
|||
|
||||
h265 = buf->data;
|
||||
context->desc.h265enc.decoded_curr_pic = h265->decoded_curr_pic.picture_id;
|
||||
context->desc.h265enc.not_referenced = !h265->pic_fields.bits.reference_pic_flag;
|
||||
|
||||
for (i = 0; i < 15; i++)
|
||||
context->desc.h265enc.reference_frames[i] = h265->reference_frames[i].picture_id;
|
||||
|
|
@ -61,6 +62,8 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont
|
|||
context->desc.h265enc.pic.log2_parallel_merge_level_minus2 = h265->log2_parallel_merge_level_minus2;
|
||||
context->desc.h265enc.pic.nal_unit_type = h265->nal_unit_type;
|
||||
context->desc.h265enc.rc.quant_i_frames = h265->pic_init_qp;
|
||||
context->desc.h265enc.rc.quant_p_frames = h265->pic_init_qp;
|
||||
context->desc.h265enc.rc.quant_b_frames = h265->pic_init_qp;
|
||||
|
||||
switch(h265->pic_fields.bits.coding_type) {
|
||||
case 1:
|
||||
|
|
@ -75,16 +78,22 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont
|
|||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED; //no b frame support
|
||||
context->desc.h265enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_B;
|
||||
break;
|
||||
}
|
||||
|
||||
context->desc.h265enc.pic.constrained_intra_pred_flag = h265->pic_fields.bits.constrained_intra_pred_flag;
|
||||
context->desc.h265enc.pic.pps_loop_filter_across_slices_enabled_flag = h265->pic_fields.bits.pps_loop_filter_across_slices_enabled_flag;
|
||||
context->desc.h265enc.pic.transform_skip_enabled_flag = h265->pic_fields.bits.transform_skip_enabled_flag;
|
||||
|
||||
_mesa_hash_table_insert(context->desc.h265enc.frame_idx,
|
||||
UINT_TO_PTR(h265->decoded_curr_pic.picture_id + 1),
|
||||
UINT_TO_PTR(context->desc.h265enc.frame_num));
|
||||
|
||||
/* Initialize slice descriptors for this picture */
|
||||
context->desc.h265enc.num_slice_descriptors = 0;
|
||||
memset(&context->desc.h265enc.slices_descriptors, 0, sizeof(context->desc.h265enc.slices_descriptors));
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +128,18 @@ vlVaHandleVAEncSliceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *contex
|
|||
context->desc.h265enc.slice.slice_deblocking_filter_disabled_flag = h265->slice_fields.bits.slice_deblocking_filter_disabled_flag;
|
||||
context->desc.h265enc.slice.slice_loop_filter_across_slices_enabled_flag = h265->slice_fields.bits.slice_loop_filter_across_slices_enabled_flag;
|
||||
|
||||
/* Handle the slice control parameters */
|
||||
struct h265_slice_descriptor slice_descriptor = { };
|
||||
slice_descriptor.slice_segment_address = h265->slice_segment_address;
|
||||
slice_descriptor.num_ctu_in_slice = h265->num_ctu_in_slice;
|
||||
slice_descriptor.slice_type = h265->slice_type;
|
||||
assert(slice_descriptor.slice_type <= PIPE_H265_SLICE_TYPE_I);
|
||||
|
||||
if (context->desc.h265enc.num_slice_descriptors < ARRAY_SIZE(context->desc.h265enc.slices_descriptors))
|
||||
context->desc.h265enc.slices_descriptors[context->desc.h265enc.num_slice_descriptors++] = slice_descriptor;
|
||||
else
|
||||
return VA_STATUS_ERROR_NOT_ENOUGH_BUFFER;
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -142,6 +163,7 @@ vlVaHandleVAEncSequenceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *con
|
|||
context->desc.h265enc.seq.general_level_idc = h265->general_level_idc;
|
||||
context->desc.h265enc.seq.general_tier_flag = h265->general_tier_flag;
|
||||
context->desc.h265enc.seq.intra_period = h265->intra_period;
|
||||
context->desc.h265enc.seq.ip_period = h265->ip_period;
|
||||
context->desc.h265enc.seq.pic_width_in_luma_samples = h265->pic_width_in_luma_samples;
|
||||
context->desc.h265enc.seq.pic_height_in_luma_samples = h265->pic_height_in_luma_samples;
|
||||
context->desc.h265enc.seq.chroma_format_idc = h265->seq_fields.bits.chroma_format_idc;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,15 @@ enum pipe_h264_slice_type
|
|||
PIPE_H264_SLICE_TYPE_SI = 0x4
|
||||
};
|
||||
|
||||
enum pipe_h265_slice_type
|
||||
{
|
||||
/* Values match Table 7-7 in HEVC spec
|
||||
for Name association of slice_type */
|
||||
PIPE_H265_SLICE_TYPE_B = 0x0,
|
||||
PIPE_H265_SLICE_TYPE_P = 0x1,
|
||||
PIPE_H265_SLICE_TYPE_I = 0x2,
|
||||
};
|
||||
|
||||
/* Same enum for h264/h265 */
|
||||
enum pipe_h2645_enc_picture_type
|
||||
{
|
||||
|
|
@ -435,6 +444,16 @@ struct h264_slice_descriptor
|
|||
enum pipe_h264_slice_type slice_type;
|
||||
};
|
||||
|
||||
struct h265_slice_descriptor
|
||||
{
|
||||
/** Starting CTU address for this slice. */
|
||||
uint32_t slice_segment_address;
|
||||
/** Number of CTUs in this slice. */
|
||||
uint32_t num_ctu_in_slice;
|
||||
/** slice type. */
|
||||
enum pipe_h265_slice_type slice_type;
|
||||
};
|
||||
|
||||
struct pipe_h264_enc_picture_desc
|
||||
{
|
||||
struct pipe_picture_desc base;
|
||||
|
|
@ -479,6 +498,7 @@ struct pipe_h265_enc_seq_param
|
|||
uint8_t general_level_idc;
|
||||
uint8_t general_tier_flag;
|
||||
uint32_t intra_period;
|
||||
uint32_t ip_period;
|
||||
uint16_t pic_width_in_luma_samples;
|
||||
uint16_t pic_height_in_luma_samples;
|
||||
uint32_t chroma_format_idc;
|
||||
|
|
@ -507,6 +527,8 @@ struct pipe_h265_enc_pic_param
|
|||
uint8_t log2_parallel_merge_level_minus2;
|
||||
uint8_t nal_unit_type;
|
||||
bool constrained_intra_pred_flag;
|
||||
bool pps_loop_filter_across_slices_enabled_flag;
|
||||
bool transform_skip_enabled_flag;
|
||||
};
|
||||
|
||||
struct pipe_h265_enc_slice_param
|
||||
|
|
@ -529,6 +551,8 @@ struct pipe_h265_enc_rate_control
|
|||
unsigned frame_rate_num;
|
||||
unsigned frame_rate_den;
|
||||
unsigned quant_i_frames;
|
||||
unsigned quant_p_frames;
|
||||
unsigned quant_b_frames;
|
||||
unsigned vbv_buffer_size;
|
||||
unsigned vbv_buf_lv;
|
||||
unsigned target_bits_picture;
|
||||
|
|
@ -562,6 +586,9 @@ struct pipe_h265_enc_picture_desc
|
|||
struct pipe_enc_quality_modes quality_modes;
|
||||
bool not_referenced;
|
||||
struct hash_table *frame_idx;
|
||||
|
||||
unsigned num_slice_descriptors;
|
||||
struct h265_slice_descriptor slices_descriptors[128];
|
||||
};
|
||||
|
||||
struct pipe_h265_sps
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue