radeonsi/vce: Use app DPB management

Same logic as VCN, we use max_num_ref_frames + 1 for initial DPB size
and resize later if needed.

Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32829>
This commit is contained in:
David Rosca 2024-12-20 16:16:16 +01:00 committed by Marge Bot
parent b22913cbd5
commit ffd2cbf2a7
3 changed files with 179 additions and 276 deletions

View file

@ -59,137 +59,9 @@ static void dump_feedback(struct rvce_encoder *enc, struct rvid_buffer *fb)
#endif
/**
* reset the CPB handling
* Calculate the offsets into the DPB
*/
static void reset_cpb(struct rvce_encoder *enc)
{
unsigned i;
list_inithead(&enc->cpb_slots);
for (i = 0; i < enc->cpb_num; ++i) {
struct rvce_cpb_slot *slot = &enc->cpb_array[i];
slot->index = i;
slot->picture_type = PIPE_H2645_ENC_PICTURE_TYPE_SKIP;
slot->frame_num = 0;
slot->pic_order_cnt = 0;
list_addtail(&slot->list, &enc->cpb_slots);
}
}
/**
* sort l0 and l1 to the top of the list
*/
static void sort_cpb(struct rvce_encoder *enc)
{
struct rvce_cpb_slot *i, *l0 = NULL, *l1 = NULL;
LIST_FOR_EACH_ENTRY (i, &enc->cpb_slots, list) {
if (i->frame_num == enc->pic.ref_idx_l0_list[0])
l0 = i;
if (i->frame_num == enc->pic.ref_idx_l1_list[0])
l1 = i;
if (enc->pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_P && l0)
break;
if (enc->pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B && l0 && l1)
break;
}
if (l1) {
list_del(&l1->list);
list_add(&l1->list, &enc->cpb_slots);
}
if (l0) {
list_del(&l0->list);
list_add(&l0->list, &enc->cpb_slots);
}
}
/**
* get number of cpbs based on dpb
*/
static unsigned get_cpb_num(struct rvce_encoder *enc, unsigned level_idc)
{
unsigned w = align(enc->base.width, 16) / 16;
unsigned h = align(enc->base.height, 16) / 16;
unsigned dpb;
switch (level_idc) {
case 10:
dpb = 396;
break;
case 11:
dpb = 900;
break;
case 12:
case 13:
case 20:
dpb = 2376;
break;
case 21:
dpb = 4752;
break;
case 22:
case 30:
dpb = 8100;
break;
case 31:
dpb = 18000;
break;
case 32:
dpb = 20480;
break;
case 40:
case 41:
dpb = 32768;
break;
case 42:
dpb = 34816;
break;
case 50:
dpb = 110400;
break;
default:
case 51:
case 52:
dpb = 184320;
break;
}
return MIN2(dpb / (w * h), 16);
}
/**
* Get the slot for the currently encoded frame
*/
struct rvce_cpb_slot *si_current_slot(struct rvce_encoder *enc)
{
return list_entry(enc->cpb_slots.prev, struct rvce_cpb_slot, list);
}
/**
* Get the slot for L0
*/
struct rvce_cpb_slot *si_l0_slot(struct rvce_encoder *enc)
{
return list_entry(enc->cpb_slots.next, struct rvce_cpb_slot, list);
}
/**
* Get the slot for L1
*/
struct rvce_cpb_slot *si_l1_slot(struct rvce_encoder *enc)
{
return list_entry(enc->cpb_slots.next->next, struct rvce_cpb_slot, list);
}
/**
* Calculate the offsets into the CPB
*/
void si_vce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, signed *luma_offset,
void si_vce_frame_offset(struct rvce_encoder *enc, unsigned slot, signed *luma_offset,
signed *chroma_offset)
{
struct si_screen *sscreen = (struct si_screen *)enc->screen;
@ -207,7 +79,7 @@ void si_vce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, s
}
fsize = pitch * (vpitch + vpitch / 2);
*luma_offset = offset + slot->index * fsize;
*luma_offset = offset + slot * fsize;
*chroma_offset = *luma_offset + pitch * vpitch;
}
@ -226,12 +98,34 @@ static void rvce_destroy(struct pipe_video_codec *encoder)
flush(enc, PIPE_FLUSH_ASYNC, NULL);
si_vid_destroy_buffer(&fb);
}
si_vid_destroy_buffer(&enc->cpb);
si_vid_destroy_buffer(&enc->dpb);
enc->ws->cs_destroy(&enc->cs);
FREE(enc->cpb_array);
FREE(enc);
}
static unsigned get_dpb_size(struct rvce_encoder *enc, unsigned slots)
{
struct si_screen *sscreen = (struct si_screen *)enc->screen;
unsigned dpb_size;
dpb_size = (sscreen->info.gfx_level < GFX9)
? align(enc->luma->u.legacy.level[0].nblk_x * enc->luma->bpe, 128) *
align(enc->luma->u.legacy.level[0].nblk_y, 32)
:
align(enc->luma->u.gfx9.surf_pitch * enc->luma->bpe, 256) *
align(enc->luma->u.gfx9.surf_height, 32);
dpb_size = dpb_size * 3 / 2;
dpb_size = dpb_size * slots;
if (enc->dual_pipe)
dpb_size += RVCE_MAX_AUX_BUFFER_NUM * RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE * 2;
enc->dpb_slots = slots;
return dpb_size;
}
static void rvce_begin_frame(struct pipe_video_codec *encoder, struct pipe_video_buffer *source,
struct pipe_picture_desc *picture)
{
@ -249,48 +143,28 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder, struct pipe_video
enc->pic.rate_ctrl[0].frame_rate_den != pic->rate_ctrl[0].frame_rate_den;
enc->pic = *pic;
enc->base.max_references = pic->seq.max_num_ref_frames;
enc->si_get_pic_param(enc, pic);
enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma);
enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma);
if (!enc->cpb_num) {
struct si_screen *sscreen = (struct si_screen *)encoder->context->screen;
unsigned cpb_size;
unsigned dpb_slots = MAX2(pic->seq.max_num_ref_frames + 1, pic->dpb_size);
enc->cpb_num = get_cpb_num(enc, enc->pic.seq.level_idc);
if (!enc->cpb_num)
return;
if (enc->dpb_slots < dpb_slots) {
unsigned dpb_size;
enc->cpb_array = CALLOC(enc->cpb_num, sizeof(struct rvce_cpb_slot));
if (!enc->cpb_array)
return;
cpb_size = (sscreen->info.gfx_level < GFX9)
? align(enc->luma->u.legacy.level[0].nblk_x * enc->luma->bpe, 128) *
align(enc->luma->u.legacy.level[0].nblk_y, 32)
:
align(enc->luma->u.gfx9.surf_pitch * enc->luma->bpe, 256) *
align(enc->luma->u.gfx9.surf_height, 32);
cpb_size = cpb_size * 3 / 2;
cpb_size = cpb_size * enc->cpb_num;
if (enc->dual_pipe)
cpb_size += RVCE_MAX_AUX_BUFFER_NUM * RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE * 2;
if (!si_vid_create_buffer(enc->screen, &enc->cpb, cpb_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't create CPB buffer.\n");
dpb_size = get_dpb_size(enc, dpb_slots);
if (!enc->dpb.res) {
if (!si_vid_create_buffer(enc->screen, &enc->dpb, dpb_size, PIPE_USAGE_DEFAULT)) {
RVID_ERR("Can't create DPB buffer.\n");
return;
}
} else if (!si_vid_resize_buffer(enc->base.context, &enc->cs, &enc->dpb, dpb_size, NULL)) {
RVID_ERR("Can't resize DPB buffer.\n");
return;
}
}
if (pic->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR)
reset_cpb(enc);
else if (pic->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_P ||
pic->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B)
sort_cpb(enc);
if (!enc->stream_handle) {
struct rvid_buffer fb;
enc->stream_handle = si_vid_alloc_stream_handle();
@ -336,18 +210,9 @@ static int rvce_end_frame(struct pipe_video_codec *encoder, struct pipe_video_bu
struct pipe_picture_desc *picture)
{
struct rvce_encoder *enc = (struct rvce_encoder *)encoder;
struct rvce_cpb_slot *slot = list_entry(enc->cpb_slots.prev, struct rvce_cpb_slot, list);
flush(enc, picture->flush_flags, picture->fence);
/* update the CPB backtrack with the just encoded frame */
slot->picture_type = enc->pic.picture_type;
slot->frame_num = enc->pic.frame_num;
slot->pic_order_cnt = enc->pic.pic_order_cnt;
if (!enc->pic.not_referenced) {
list_del(&slot->list);
list_add(&slot->list, &enc->cpb_slots);
}
return 0;
}

View file

@ -36,16 +36,6 @@ struct si_screen;
typedef void (*rvce_get_buffer)(struct pipe_resource *resource, struct pb_buffer_lean **handle,
struct radeon_surf **surface);
/* Coded picture buffer slot */
struct rvce_cpb_slot {
struct list_head list;
unsigned index;
enum pipe_h2645_enc_picture_type picture_type;
unsigned frame_num;
unsigned pic_order_cnt;
};
struct rvce_rate_control {
uint32_t rc_method;
uint32_t target_bitrate;
@ -239,25 +229,28 @@ struct rvce_enc_operation {
uint32_t num_ref_idx_active_override_flag;
uint32_t num_ref_idx_l0_active_minus1;
uint32_t num_ref_idx_l1_active_minus1;
uint32_t enc_ref_list_modification_op;
uint32_t enc_ref_list_modification_num;
uint32_t enc_decoded_picture_marking_op;
uint32_t enc_decoded_picture_marking_num;
uint32_t enc_decoded_picture_marking_idx;
uint32_t enc_decoded_ref_base_picture_marking_op;
uint32_t enc_decoded_ref_base_picture_marking_num;
uint32_t enc_ref_list_modification_op[4];
uint32_t enc_ref_list_modification_num[4];
uint32_t enc_decoded_picture_marking_op[4];
uint32_t enc_decoded_picture_marking_num[4];
uint32_t enc_decoded_picture_marking_idx[4];
uint32_t enc_decoded_ref_base_picture_marking_op[4];
uint32_t enc_decoded_ref_base_picture_marking_num[4];
uint32_t l0_dpb_idx;
uint32_t l0_picture_structure;
uint32_t l0_enc_pic_type;
uint32_t l0_frame_number;
uint32_t l0_picture_order_count;
uint32_t l0_luma_offset;
uint32_t l0_chroma_offset;
uint32_t l1_dpb_idx;
uint32_t l1_picture_structure;
uint32_t l1_enc_pic_type;
uint32_t l1_frame_number;
uint32_t l1_picture_order_count;
uint32_t l1_luma_offset;
uint32_t l1_chroma_offset;
uint32_t cur_dpb_idx;
uint32_t enc_reconstructed_luma_offset;
uint32_t enc_reconstructed_chroma_offset;
;
@ -332,17 +325,11 @@ struct rvce_h264_enc_pic {
unsigned gop_cnt;
unsigned gop_size;
unsigned pic_order_cnt;
unsigned ref_idx_l0;
unsigned ref_idx_l1;
unsigned addrmode_arraymode_disrdo_distwoinstants;
bool not_referenced;
bool is_idr;
bool has_ref_pic_list;
bool enable_vui;
unsigned int ref_pic_list_0[32];
unsigned int ref_pic_list_1[32];
unsigned int frame_idx[32];
};
/* VCE encoder representation */
@ -381,12 +368,10 @@ struct rvce_encoder {
struct pb_buffer_lean *bs_handle;
unsigned bs_size;
struct rvce_cpb_slot *cpb_array;
struct list_head cpb_slots;
unsigned cpb_num;
unsigned dpb_slots;
struct rvid_buffer *fb;
struct rvid_buffer cpb;
struct rvid_buffer dpb;
struct pipe_h264_enc_picture_desc pic;
struct rvce_h264_enc_pic enc_pic;
@ -398,10 +383,7 @@ struct rvce_encoder {
};
/* CPB handling functions */
struct rvce_cpb_slot *si_current_slot(struct rvce_encoder *enc);
struct rvce_cpb_slot *si_l0_slot(struct rvce_encoder *enc);
struct rvce_cpb_slot *si_l1_slot(struct rvce_encoder *enc);
void si_vce_frame_offset(struct rvce_encoder *enc, struct rvce_cpb_slot *slot, signed *luma_offset,
void si_vce_frame_offset(struct rvce_encoder *enc, unsigned slot, signed *luma_offset,
signed *chroma_offset);
struct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context,

View file

@ -16,6 +16,11 @@
#include <stdio.h>
#define REF_LIST_MODIFICATION_OP_END 0
#define REF_LIST_MODIFICATION_OP_SHORT_TERM_SUBTRACT 1
#define REF_LIST_MODIFICATION_OP_LONG_TERM 2
#define REF_LIST_MODIFICATION_OP_VIEW_ADD 3
static void get_rate_control_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
{
enc->enc_pic.rc.rc_method = pic->rate_ctrl[0].rate_ctrl_method;
@ -166,6 +171,8 @@ static void get_vui_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture
static void get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
{
int i;
get_rate_control_param(enc, pic);
get_motion_estimation_param(enc, pic);
get_pic_control_param(enc, pic);
@ -176,16 +183,104 @@ static void get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_des
enc->enc_pic.picture_type = pic->picture_type;
enc->enc_pic.frame_num = pic->frame_num;
enc->enc_pic.frame_num_cnt = pic->frame_num_cnt;
enc->enc_pic.frame_num_cnt = pic->frame_num_cnt - 1;
enc->enc_pic.p_remain = pic->p_remain;
enc->enc_pic.i_remain = pic->i_remain;
enc->enc_pic.gop_cnt = pic->gop_cnt;
enc->enc_pic.pic_order_cnt = pic->pic_order_cnt;
enc->enc_pic.ref_idx_l0 = pic->ref_idx_l0_list[0];
enc->enc_pic.ref_idx_l1 = pic->ref_idx_l1_list[0];
enc->enc_pic.not_referenced = pic->not_referenced;
enc->enc_pic.addrmode_arraymode_disrdo_distwoinstants = 0x01000201;
enc->enc_pic.is_idr = (pic->picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR);
enc->enc_pic.eo.enc_idr_pic_id = pic->idr_pic_id;
enc->enc_pic.eo.insert_headers = 0;
enc->enc_pic.eo.insert_aud = 0;
util_dynarray_foreach(&pic->raw_headers, struct pipe_enc_raw_header, header) {
switch (header->type) {
case PIPE_H264_NAL_SPS:
enc->enc_pic.eo.insert_headers |= 0x01;
break;
case PIPE_H264_NAL_PPS:
enc->enc_pic.eo.insert_headers |= 0x10;
break;
case PIPE_H264_NAL_AUD:
enc->enc_pic.eo.insert_aud = 1;
break;
default:
break;
}
}
enc->enc_pic.eo.num_ref_idx_active_override_flag = pic->slice.num_ref_idx_active_override_flag;
enc->enc_pic.eo.num_ref_idx_l0_active_minus1 = pic->slice.num_ref_idx_l0_active_minus1;
enc->enc_pic.eo.num_ref_idx_l1_active_minus1 = pic->slice.num_ref_idx_l1_active_minus1;
i = 0;
if (pic->slice.ref_pic_list_modification_flag_l0) {
for (; i < MIN2(4, pic->slice.num_ref_list0_mod_operations); i++) {
struct pipe_h264_ref_list_mod_entry *entry = &pic->slice.ref_list0_mod_operations[i];
switch (entry->modification_of_pic_nums_idc) {
case 0:
enc->enc_pic.eo.enc_ref_list_modification_op[i] = REF_LIST_MODIFICATION_OP_SHORT_TERM_SUBTRACT;
enc->enc_pic.eo.enc_ref_list_modification_num[i] = entry->abs_diff_pic_num_minus1;
break;
case 2:
enc->enc_pic.eo.enc_ref_list_modification_op[i] = REF_LIST_MODIFICATION_OP_LONG_TERM;
enc->enc_pic.eo.enc_ref_list_modification_num[i] = entry->long_term_pic_num;
break;
case 5:
enc->enc_pic.eo.enc_ref_list_modification_op[i] = REF_LIST_MODIFICATION_OP_VIEW_ADD;
enc->enc_pic.eo.enc_ref_list_modification_num[i] = entry->abs_diff_pic_num_minus1;
break;
default:
case 3:
enc->enc_pic.eo.enc_ref_list_modification_op[i] = REF_LIST_MODIFICATION_OP_END;
break;
}
}
}
if (i < 4)
enc->enc_pic.eo.enc_ref_list_modification_op[i] = REF_LIST_MODIFICATION_OP_END;
i = 0;
if (pic->pic_ctrl.nal_unit_type == PIPE_H264_NAL_IDR_SLICE) {
enc->enc_pic.eo.enc_decoded_picture_marking_op[i++] = pic->slice.long_term_reference_flag ? 6 : 0;
} else if (pic->slice.adaptive_ref_pic_marking_mode_flag) {
for (; i < MIN2(4, pic->slice.num_ref_pic_marking_operations); i++) {
struct pipe_h264_ref_pic_marking_entry *entry = &pic->slice.ref_pic_marking_operations[i];
enc->enc_pic.eo.enc_decoded_picture_marking_op[i] = entry->memory_management_control_operation;
switch (entry->memory_management_control_operation) {
case 1:
enc->enc_pic.eo.enc_decoded_picture_marking_num[i] = entry->difference_of_pic_nums_minus1;
break;
case 2:
enc->enc_pic.eo.enc_decoded_picture_marking_num[i] = entry->long_term_pic_num;
break;
case 3:
enc->enc_pic.eo.enc_decoded_picture_marking_num[i] = entry->difference_of_pic_nums_minus1;
enc->enc_pic.eo.enc_decoded_picture_marking_idx[i] = entry->long_term_frame_idx;
break;
case 4:
enc->enc_pic.eo.enc_decoded_picture_marking_idx[i] = entry->max_long_term_frame_idx_plus1;
break;
case 6:
enc->enc_pic.eo.enc_decoded_picture_marking_idx[i] = entry->long_term_frame_idx;
break;
default:
break;
}
}
}
if (i < 4)
enc->enc_pic.eo.enc_decoded_picture_marking_op[i] = 0;
enc->enc_pic.eo.cur_dpb_idx = pic->dpb_curr_pic;
enc->enc_pic.eo.l0_dpb_idx = pic->ref_list0[0];
enc->enc_pic.eo.l1_dpb_idx = PIPE_H2645_LIST_REF_INVALID_ENTRY;
enc->enc_pic.eo.l1_luma_offset = 0xffffffff;
enc->enc_pic.eo.l1_chroma_offset = 0xffffffff;
}
static void create(struct rvce_encoder *enc)
@ -230,7 +325,7 @@ static void encode(struct rvce_encoder *enc)
enc->task_info(enc, 0x00000003, 0, 0, bs_idx);
RVCE_BEGIN(0x05000001); // context buffer
RVCE_READWRITE(enc->cpb.res->buf, enc->cpb.res->domains, 0); // encodeContextAddressHi/Lo
RVCE_READWRITE(enc->dpb.res->buf, enc->dpb.res->domains, 0); // encodeContextAddressHi/Lo
RVCE_END();
bs_offset = -(signed)(bs_idx * enc->bs_size);
@ -253,7 +348,7 @@ static void encode(struct rvce_encoder *enc)
}
RVCE_BEGIN(0x03000001); // encode
RVCE_CS(enc->enc_pic.frame_num ? 0x0 : 0x11); // insertHeaders
RVCE_CS(enc->enc_pic.eo.insert_headers);
RVCE_CS(enc->enc_pic.eo.picture_structure);
RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize
RVCE_CS(enc->enc_pic.eo.force_refresh_map);
@ -287,11 +382,6 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(enc->enc_pic.eo.enc_input_pic_tile_config);
RVCE_CS(enc->enc_pic.picture_type); // encPicType
RVCE_CS(enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR); // encIdrFlag
if ((enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR) &&
(enc->enc_pic.eo.enc_idr_pic_id != 0))
enc->enc_pic.eo.enc_idr_pic_id = enc->enc_pic.idr_pic_id - 1;
else
enc->enc_pic.eo.enc_idr_pic_id = 0x00000000;
RVCE_CS(enc->enc_pic.eo.enc_idr_pic_id);
RVCE_CS(enc->enc_pic.eo.enc_mgs_key_pic);
RVCE_CS(!enc->enc_pic.not_referenced);
@ -300,56 +390,37 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(enc->enc_pic.eo.num_ref_idx_l0_active_minus1);
RVCE_CS(enc->enc_pic.eo.num_ref_idx_l1_active_minus1);
i = enc->enc_pic.frame_num - enc->enc_pic.ref_idx_l0;
if (i > 1 && enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_P) {
enc->enc_pic.eo.enc_ref_list_modification_op = 0x00000001;
enc->enc_pic.eo.enc_ref_list_modification_num = i - 1;
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_op);
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_num);
} else {
enc->enc_pic.eo.enc_ref_list_modification_op = 0x00000000;
enc->enc_pic.eo.enc_ref_list_modification_num = 0x00000000;
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_op);
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_num);
for (i = 0; i < 4; ++i) {
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_op[i]);
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_num[i]);
}
for (i = 0; i < 3; ++i) {
enc->enc_pic.eo.enc_ref_list_modification_op = 0x00000000;
enc->enc_pic.eo.enc_ref_list_modification_num = 0x00000000;
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_op);
RVCE_CS(enc->enc_pic.eo.enc_ref_list_modification_num);
}
for (i = 0; i < 4; ++i) {
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_op);
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_num);
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_idx);
RVCE_CS(enc->enc_pic.eo.enc_decoded_ref_base_picture_marking_op);
RVCE_CS(enc->enc_pic.eo.enc_decoded_ref_base_picture_marking_num);
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_op[i]);
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_num[i]);
RVCE_CS(enc->enc_pic.eo.enc_decoded_picture_marking_idx[i]);
}
for (i = 0; i < 4; ++i) {
RVCE_CS(enc->enc_pic.eo.enc_decoded_ref_base_picture_marking_op[i]);
RVCE_CS(enc->enc_pic.eo.enc_decoded_ref_base_picture_marking_num[i]);
}
// encReferencePictureL0[0]
RVCE_CS(0x00000000); // pictureStructure
if (enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_P ||
enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B) {
struct rvce_cpb_slot *l0 = si_l0_slot(enc);
si_vce_frame_offset(enc, l0, &luma_offset, &chroma_offset);
RVCE_CS(l0->picture_type);
RVCE_CS(l0->frame_num);
RVCE_CS(l0->pic_order_cnt);
RVCE_CS(luma_offset);
RVCE_CS(chroma_offset);
if (enc->enc_pic.eo.l0_dpb_idx != PIPE_H2645_LIST_REF_INVALID_ENTRY) {
si_vce_frame_offset(enc, enc->enc_pic.eo.l0_dpb_idx, &luma_offset, &chroma_offset);
enc->enc_pic.eo.l0_luma_offset = luma_offset;
enc->enc_pic.eo.l0_chroma_offset = chroma_offset;
} else {
enc->enc_pic.eo.l0_enc_pic_type = 0x00000000;
enc->enc_pic.eo.l0_frame_number = 0x00000000;
enc->enc_pic.eo.l0_picture_order_count = 0x00000000;
enc->enc_pic.eo.l0_luma_offset = 0xffffffff;
enc->enc_pic.eo.l0_chroma_offset = 0xffffffff;
RVCE_CS(enc->enc_pic.eo.l0_enc_pic_type);
RVCE_CS(enc->enc_pic.eo.l0_frame_number);
RVCE_CS(enc->enc_pic.eo.l0_picture_order_count);
RVCE_CS(enc->enc_pic.eo.l0_luma_offset);
RVCE_CS(enc->enc_pic.eo.l0_chroma_offset);
}
RVCE_CS(0x00000000); // pictureStructure
RVCE_CS(enc->enc_pic.eo.l0_enc_pic_type);
RVCE_CS(enc->enc_pic.eo.l0_frame_number);
RVCE_CS(enc->enc_pic.eo.l0_picture_order_count);
RVCE_CS(enc->enc_pic.eo.l0_luma_offset);
RVCE_CS(enc->enc_pic.eo.l0_chroma_offset);
// encReferencePictureL0[1]
enc->enc_pic.eo.l0_picture_structure = 0x00000000;
@ -367,28 +438,13 @@ static void encode(struct rvce_encoder *enc)
// encReferencePictureL1[0]
RVCE_CS(0x00000000); // pictureStructure
if (enc->enc_pic.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_B) {
struct rvce_cpb_slot *l1 = si_l1_slot(enc);
si_vce_frame_offset(enc, l1, &luma_offset, &chroma_offset);
RVCE_CS(l1->picture_type);
RVCE_CS(l1->frame_num);
RVCE_CS(l1->pic_order_cnt);
RVCE_CS(luma_offset);
RVCE_CS(chroma_offset);
} else {
enc->enc_pic.eo.l1_enc_pic_type = 0x00000000;
enc->enc_pic.eo.l1_frame_number = 0x00000000;
enc->enc_pic.eo.l1_picture_order_count = 0x00000000;
enc->enc_pic.eo.l1_luma_offset = 0xffffffff;
enc->enc_pic.eo.l1_chroma_offset = 0xffffffff;
RVCE_CS(enc->enc_pic.eo.l1_enc_pic_type);
RVCE_CS(enc->enc_pic.eo.l1_frame_number);
RVCE_CS(enc->enc_pic.eo.l1_picture_order_count);
RVCE_CS(enc->enc_pic.eo.l1_luma_offset);
RVCE_CS(enc->enc_pic.eo.l1_chroma_offset);
}
RVCE_CS(enc->enc_pic.eo.l1_enc_pic_type);
RVCE_CS(enc->enc_pic.eo.l1_frame_number);
RVCE_CS(enc->enc_pic.eo.l1_picture_order_count);
RVCE_CS(enc->enc_pic.eo.l1_luma_offset);
RVCE_CS(enc->enc_pic.eo.l1_chroma_offset);
si_vce_frame_offset(enc, si_current_slot(enc), &luma_offset, &chroma_offset);
si_vce_frame_offset(enc, enc->enc_pic.eo.cur_dpb_idx, &luma_offset, &chroma_offset);
RVCE_CS(luma_offset);
RVCE_CS(chroma_offset);
RVCE_CS(enc->enc_pic.eo.enc_coloc_buffer_offset);
@ -396,7 +452,7 @@ static void encode(struct rvce_encoder *enc)
RVCE_CS(enc->enc_pic.eo.enc_reconstructed_ref_base_picture_chroma_offset);
RVCE_CS(enc->enc_pic.eo.enc_reference_ref_base_picture_luma_offset);
RVCE_CS(enc->enc_pic.eo.enc_reference_ref_base_picture_chroma_offset);
RVCE_CS(enc->enc_pic.frame_num_cnt - 1);
RVCE_CS(enc->enc_pic.frame_num_cnt);
RVCE_CS(enc->enc_pic.frame_num);
RVCE_CS(enc->enc_pic.pic_order_cnt);
RVCE_CS(enc->enc_pic.i_remain);