static void feedback(struct rvce_encoder *enc) { RVCE_BEGIN(0x05000005); // feedback buffer RVCE_WRITE(enc->fb->res->buf, enc->fb->res->domains, 0x0); // feedbackRingAddressHi/Lo RVCE_CS(enc->enc_pic.fb.feedback_ring_size); RVCE_END(); }
static void feedback(struct rvce_encoder *enc) { RVCE_BEGIN(0x05000005); // feedback buffer RVCE_WRITE(enc->fb->res->buf, enc->fb->res->domains, 0x0); // feedbackRingAddressHi/Lo RVCE_CS(0x00000001); // feedbackRingSize RVCE_END(); }
static void feedback(struct rvce_encoder *enc) { RVCE_BEGIN(0x05000005); // feedback buffer RVCE_WRITE(enc->fb->cs_handle, enc->fb->domain); // feedbackRingAddressHi RVCE_CS(0x00000000); // feedbackRingAddressLo RVCE_CS(0x00000001); // feedbackRingSize RVCE_END(); }
static void encode(struct rvce_encoder *enc) { signed luma_offset, chroma_offset, bs_offset; unsigned dep, bs_idx = enc->bs_idx++; int i; if (enc->dual_inst) { if (bs_idx == 0) dep = 1; else if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) dep = 0; else dep = 2; } else dep = 0; enc->task_info(enc, 0x00000003, dep, 0, bs_idx); RVCE_BEGIN(0x05000001); // context buffer RVCE_READWRITE(enc->cpb.res->buf, enc->cpb.res->domains, 0); // encodeContextAddressHi/Lo RVCE_END(); bs_offset = -(signed)(bs_idx * enc->bs_size); RVCE_BEGIN(0x05000004); // video bitstream buffer RVCE_WRITE(enc->bs_handle, RADEON_DOMAIN_GTT, bs_offset); // videoBitstreamRingAddressHi/Lo RVCE_CS(enc->bs_size); // videoBitstreamRingSize RVCE_END(); if (enc->dual_pipe) { unsigned aux_offset = enc->cpb.res->buf->size - RVCE_MAX_AUX_BUFFER_NUM * RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE * 2; RVCE_BEGIN(0x05000002); // auxiliary buffer for (i = 0; i < 8; ++i) { RVCE_CS(aux_offset); aux_offset += RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE; } for (i = 0; i < 8; ++i) RVCE_CS(RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE); RVCE_END(); } RVCE_BEGIN(0x03000001); // encode RVCE_CS(enc->pic.frame_num ? 0x0 : 0x11); // insertHeaders RVCE_CS(0x00000000); // pictureStructure RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize RVCE_CS(0x00000000); // forceRefreshMap RVCE_CS(0x00000000); // insertAUD RVCE_CS(0x00000000); // endOfSequence RVCE_CS(0x00000000); // endOfStream RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->luma->level[0].offset); // inputPictureLumaAddressHi/Lo RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma->level[0].offset); // inputPictureChromaAddressHi/Lo RVCE_CS(align(enc->luma->npix_y, 16)); // encInputFrameYPitch RVCE_CS(enc->luma->level[0].pitch_bytes); // encInputPicLumaPitch RVCE_CS(enc->chroma->level[0].pitch_bytes); // encInputPicChromaPitch if (enc->dual_pipe) RVCE_CS(0x00000000); // encInputPic(Addr|Array)Mode,encDisable(TwoPipeMode|MBOffloading) else RVCE_CS(0x00010000); // encInputPic(Addr|Array)Mode,encDisable(TwoPipeMode|MBOffloading) RVCE_CS(0x00000000); // encInputPicTileConfig RVCE_CS(enc->pic.picture_type); // encPicType RVCE_CS(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR); // encIdrFlag RVCE_CS(0x00000000); // encIdrPicId RVCE_CS(0x00000000); // encMGSKeyPic RVCE_CS(!enc->pic.not_referenced); // encReferenceFlag RVCE_CS(0x00000000); // encTemporalLayerIndex RVCE_CS(0x00000000); // num_ref_idx_active_override_flag RVCE_CS(0x00000000); // num_ref_idx_l0_active_minus1 RVCE_CS(0x00000000); // num_ref_idx_l1_active_minus1 i = enc->pic.frame_num - enc->pic.ref_idx_l0; if (i > 1 && enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) { RVCE_CS(0x00000001); // encRefListModificationOp RVCE_CS(i - 1); // encRefListModificationNum } else { RVCE_CS(0x00000000); // encRefListModificationOp RVCE_CS(0x00000000); // encRefListModificationNum } for (i = 0; i < 3; ++i) { RVCE_CS(0x00000000); // encRefListModificationOp RVCE_CS(0x00000000); // encRefListModificationNum } for (i = 0; i < 4; ++i) { RVCE_CS(0x00000000); // encDecodedPictureMarkingOp RVCE_CS(0x00000000); // encDecodedPictureMarkingNum RVCE_CS(0x00000000); // encDecodedPictureMarkingIdx RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingOp RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingNum } // encReferencePictureL0[0] RVCE_CS(0x00000000); // pictureStructure if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P || enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) { struct rvce_cpb_slot *l0 = l0_slot(enc); rvce_frame_offset(enc, l0, &luma_offset, &chroma_offset); RVCE_CS(l0->picture_type); // encPicType RVCE_CS(l0->frame_num); // frameNumber RVCE_CS(l0->pic_order_cnt); // pictureOrderCount RVCE_CS(luma_offset); // lumaOffset RVCE_CS(chroma_offset); // chromaOffset } else { RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } // encReferencePictureL0[1] RVCE_CS(0x00000000); // pictureStructure RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset // encReferencePictureL1[0] RVCE_CS(0x00000000); // pictureStructure if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) { struct rvce_cpb_slot *l1 = l1_slot(enc); rvce_frame_offset(enc, l1, &luma_offset, &chroma_offset); RVCE_CS(l1->picture_type); // encPicType RVCE_CS(l1->frame_num); // frameNumber RVCE_CS(l1->pic_order_cnt); // pictureOrderCount RVCE_CS(luma_offset); // lumaOffset RVCE_CS(chroma_offset); // chromaOffset } else { RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } rvce_frame_offset(enc, current_slot(enc), &luma_offset, &chroma_offset); RVCE_CS(luma_offset); // encReconstructedLumaOffset RVCE_CS(chroma_offset); // encReconstructedChromaOffset RVCE_CS(0x00000000); // encColocBufferOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureChromaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureChromaOffset RVCE_CS(0x00000000); // pictureCount RVCE_CS(enc->pic.frame_num); // frameNumber RVCE_CS(enc->pic.pic_order_cnt); // pictureOrderCount RVCE_CS(0x00000000); // numIPicRemainInRCGOP RVCE_CS(0x00000000); // numPPicRemainInRCGOP RVCE_CS(0x00000000); // numBPicRemainInRCGOP RVCE_CS(0x00000000); // numIRPicRemainInRCGOP RVCE_CS(0x00000000); // enableIntraRefresh RVCE_END(); }
static void encode(struct rvce_encoder *enc) { struct r600_common_screen *rscreen = (struct r600_common_screen *)enc->screen; signed luma_offset, chroma_offset, bs_offset; unsigned dep, bs_idx = enc->bs_idx++; int i; if (enc->dual_inst) { if (bs_idx == 0) dep = 1; else if (enc->enc_pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) dep = 0; else dep = 2; } else dep = 0; enc->task_info(enc, 0x00000003, dep, 0, bs_idx); RVCE_BEGIN(0x05000001); // context buffer RVCE_READWRITE(enc->cpb.res->buf, enc->cpb.res->domains, 0); // encodeContextAddressHi/Lo RVCE_END(); bs_offset = -(signed)(bs_idx * enc->bs_size); RVCE_BEGIN(0x05000004); // video bitstream buffer RVCE_WRITE(enc->bs_handle, RADEON_DOMAIN_GTT, bs_offset); // videoBitstreamRingAddressHi/Lo RVCE_CS(enc->bs_size); // videoBitstreamRingSize RVCE_END(); if (enc->dual_pipe) { unsigned aux_offset = enc->cpb.res->buf->size - RVCE_MAX_AUX_BUFFER_NUM * RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE * 2; RVCE_BEGIN(0x05000002); // auxiliary buffer for (i = 0; i < 8; ++i) { RVCE_CS(aux_offset); aux_offset += RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE; } for (i = 0; i < 8; ++i) RVCE_CS(RVCE_MAX_BITSTREAM_OUTPUT_ROW_SIZE); RVCE_END(); } RVCE_BEGIN(0x03000001); // encode RVCE_CS(enc->enc_pic.frame_num ? 0x0 : 0x11); // insertHeaders RVCE_CS(enc->enc_pic.eo.picture_structure); RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize RVCE_CS(enc->enc_pic.eo.force_refresh_map); RVCE_CS(enc->enc_pic.eo.insert_aud); RVCE_CS(enc->enc_pic.eo.end_of_sequence); RVCE_CS(enc->enc_pic.eo.end_of_stream); if (rscreen->chip_class < GFX9) { RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->luma->u.legacy.level[0].offset); // inputPictureLumaAddressHi/Lo RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma->u.legacy.level[0].offset); // inputPictureChromaAddressHi/Lo RVCE_CS(align(enc->luma->u.legacy.level[0].nblk_y, 16)); // encInputFrameYPitch RVCE_CS(enc->luma->u.legacy.level[0].nblk_x * enc->luma->bpe); // encInputPicLumaPitch RVCE_CS(enc->chroma->u.legacy.level[0].nblk_x * enc->chroma->bpe); // encInputPicChromaPitch } else { RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->luma->u.gfx9.surf_offset); // inputPictureLumaAddressHi/Lo RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma->u.gfx9.surf_offset); // inputPictureChromaAddressHi/Lo RVCE_CS(align(enc->luma->u.gfx9.surf_height, 16)); // encInputFrameYPitch RVCE_CS(enc->luma->u.gfx9.surf_pitch * enc->luma->bpe); // encInputPicLumaPitch RVCE_CS(enc->chroma->u.gfx9.surf_pitch * enc->chroma->bpe); // encInputPicChromaPitch } if (enc->dual_pipe) enc->enc_pic.eo.enc_input_pic_addr_array_disable2pipe_disablemboffload = 0x00000000; else enc->enc_pic.eo.enc_input_pic_addr_array_disable2pipe_disablemboffload = 0x00010000; RVCE_CS(enc->enc_pic.eo.enc_input_pic_addr_array_disable2pipe_disablemboffload); 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_H264_ENC_PICTURE_TYPE_IDR); // encIdrFlag if ((enc->enc_pic.picture_type == PIPE_H264_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); RVCE_CS(enc->enc_pic.eo.enc_temporal_layer_index); RVCE_CS(enc->enc_pic.eo.num_ref_idx_active_override_flag); 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_H264_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 < 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); } // encReferencePictureL0[0] RVCE_CS(0x00000000); // pictureStructure if(enc->enc_pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P || enc->enc_pic.picture_type == PIPE_H264_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); } 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); } // encReferencePictureL0[1] enc->enc_pic.eo.l0_picture_structure = 0x00000000; 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_picture_structure); 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); // encReferencePictureL1[0] RVCE_CS(0x00000000); // pictureStructure if(enc->enc_pic.picture_type == PIPE_H264_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); } si_vce_frame_offset(enc, si_current_slot(enc), &luma_offset, &chroma_offset); RVCE_CS(luma_offset); RVCE_CS(chroma_offset); RVCE_CS(enc->enc_pic.eo.enc_coloc_buffer_offset); RVCE_CS(enc->enc_pic.eo.enc_reconstructed_ref_base_picture_luma_offset); 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); RVCE_CS(enc->enc_pic.pic_order_cnt); RVCE_CS(enc->enc_pic.i_remain); RVCE_CS(enc->enc_pic.p_remain); RVCE_CS(enc->enc_pic.eo.num_b_pic_remain_in_rcgop); RVCE_CS(enc->enc_pic.eo.num_ir_pic_remain_in_rcgop); RVCE_CS(enc->enc_pic.eo.enable_intra_refresh); RVCE_CS(enc->enc_pic.eo.aq_variance_en); RVCE_CS(enc->enc_pic.eo.aq_block_size); RVCE_CS(enc->enc_pic.eo.aq_mb_variance_sel); RVCE_CS(enc->enc_pic.eo.aq_frame_variance_sel); RVCE_CS(enc->enc_pic.eo.aq_param_a); RVCE_CS(enc->enc_pic.eo.aq_param_b); RVCE_CS(enc->enc_pic.eo.aq_param_c); RVCE_CS(enc->enc_pic.eo.aq_param_d); RVCE_CS(enc->enc_pic.eo.aq_param_e); RVCE_CS(enc->enc_pic.eo.context_in_sfb); RVCE_END(); }
static void encode(struct rvce_encoder *enc) { signed luma_offset, chroma_offset; int i; enc->task_info(enc, 0x00000003, 0, 0, 0); RVCE_BEGIN(0x05000001); // context buffer RVCE_READWRITE(enc->cpb.res->buf, enc->cpb.res->domains, 0x0); // encodeContextAddressHi/Lo RVCE_END(); RVCE_BEGIN(0x05000004); // video bitstream buffer RVCE_WRITE(enc->bs_handle, RADEON_DOMAIN_GTT, 0x0); // videoBitstreamRingAddressHi/Lo RVCE_CS(enc->bs_size); // videoBitstreamRingSize RVCE_END(); RVCE_BEGIN(0x03000001); // encode RVCE_CS(0x00000000); // insertHeaders RVCE_CS(0x00000000); // pictureStructure RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize RVCE_CS(0x00000000); // forceRefreshMap RVCE_CS(0x00000000); // insertAUD RVCE_CS(0x00000000); // endOfSequence RVCE_CS(0x00000000); // endOfStream RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->luma->level[0].offset); // inputPictureLumaAddressHi/Lo RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma->level[0].offset); // inputPictureChromaAddressHi/Lo RVCE_CS(align(enc->luma->npix_y, 16)); // encInputFrameYPitch RVCE_CS(enc->luma->level[0].pitch_bytes); // encInputPicLumaPitch RVCE_CS(enc->chroma->level[0].pitch_bytes); // encInputPicChromaPitch RVCE_CS(0x00000000); // encInputPic(Addr|Array)Mode RVCE_CS(0x00000000); // encInputPicTileConfig RVCE_CS(enc->pic.picture_type); // encPicType RVCE_CS(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR); // encIdrFlag RVCE_CS(0x00000000); // encIdrPicId RVCE_CS(0x00000000); // encMGSKeyPic RVCE_CS(!enc->pic.not_referenced); // encReferenceFlag RVCE_CS(0x00000000); // encTemporalLayerIndex RVCE_CS(0x00000000); // num_ref_idx_active_override_flag RVCE_CS(0x00000000); // num_ref_idx_l0_active_minus1 RVCE_CS(0x00000000); // num_ref_idx_l1_active_minus1 i = enc->pic.frame_num - enc->pic.ref_idx_l0; if (i > 1 && enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) { RVCE_CS(0x00000001); // encRefListModificationOp RVCE_CS(i - 1); // encRefListModificationNum } else { RVCE_CS(0x00000000); // encRefListModificationOp RVCE_CS(0x00000000); // encRefListModificationNum } for (i = 0; i < 3; ++i) { RVCE_CS(0x00000000); // encRefListModificationOp RVCE_CS(0x00000000); // encRefListModificationNum } for (i = 0; i < 4; ++i) { RVCE_CS(0x00000000); // encDecodedPictureMarkingOp RVCE_CS(0x00000000); // encDecodedPictureMarkingNum RVCE_CS(0x00000000); // encDecodedPictureMarkingIdx RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingOp RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingNum } // encReferencePictureL0[0] RVCE_CS(0x00000000); // pictureStructure if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P || enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) { struct rvce_cpb_slot *l0 = l0_slot(enc); rvce_frame_offset(enc, l0, &luma_offset, &chroma_offset); RVCE_CS(l0->picture_type); // encPicType RVCE_CS(l0->frame_num); // frameNumber RVCE_CS(l0->pic_order_cnt); // pictureOrderCount RVCE_CS(luma_offset); // lumaOffset RVCE_CS(chroma_offset); // chromaOffset } else { RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } // encReferencePictureL0[1] RVCE_CS(0x00000000); // pictureStructure RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset // encReferencePictureL1[0] RVCE_CS(0x00000000); // pictureStructure if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) { struct rvce_cpb_slot *l1 = l1_slot(enc); rvce_frame_offset(enc, l1, &luma_offset, &chroma_offset); RVCE_CS(l1->picture_type); // encPicType RVCE_CS(l1->frame_num); // frameNumber RVCE_CS(l1->pic_order_cnt); // pictureOrderCount RVCE_CS(luma_offset); // lumaOffset RVCE_CS(chroma_offset); // chromaOffset } else { RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } rvce_frame_offset(enc, current_slot(enc), &luma_offset, &chroma_offset); RVCE_CS(luma_offset); // encReconstructedLumaOffset RVCE_CS(chroma_offset); // encReconstructedChromaOffset RVCE_CS(0x00000000); // encColocBufferOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureChromaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureChromaOffset RVCE_CS(0x00000000); // pictureCount RVCE_CS(enc->pic.frame_num); // frameNumber RVCE_CS(enc->pic.pic_order_cnt); // pictureOrderCount RVCE_CS(0x00000000); // numIPicRemainInRCGOP RVCE_CS(0x00000000); // numPPicRemainInRCGOP RVCE_CS(0x00000000); // numBPicRemainInRCGOP RVCE_CS(0x00000000); // numIRPicRemainInRCGOP RVCE_CS(0x00000000); // enableIntraRefresh RVCE_END(); }
static void encode(struct rvce_encoder *enc) { int i; unsigned pitch = align(enc->luma->level[0].pitch_bytes, 128); unsigned vpitch = align(enc->luma->npix_y, 16); unsigned fsize = pitch * (vpitch + vpitch / 2); unsigned chroma_offset = pitch * vpitch; unsigned luma_offset; task_info(enc, 0x00000003); RVCE_BEGIN(0x05000001); // context buffer RVCE_READWRITE(enc->cpb.cs_handle, enc->cpb.domain); // encodeContextAddressHi RVCE_CS(0x00000000); // encodeContextAddressLo RVCE_END(); RVCE_BEGIN(0x05000004); // video bitstream buffer RVCE_WRITE(enc->bs_handle, RADEON_DOMAIN_GTT); // videoBitstreamRingAddressHi RVCE_CS(0x00000000); // videoBitstreamRingAddressLo RVCE_CS(enc->bs_size); // videoBitstreamRingSize RVCE_END(); RVCE_BEGIN(0x03000001); // encode RVCE_CS(0x00000000); // insertHeaders RVCE_CS(0x00000000); // pictureStructure RVCE_CS(enc->bs_size); // allowedMaxBitstreamSize RVCE_CS(0x00000000); // forceRefreshMap RVCE_CS(0x00000000); // insertAUD RVCE_CS(0x00000000); // endOfSequence RVCE_CS(0x00000000); // endOfStream RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM); // inputPictureLumaAddressHi RVCE_CS(enc->luma->level[0].offset); // inputPictureLumaAddressLo RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM); // inputPictureChromaAddressHi RVCE_CS(enc->chroma->level[0].offset); // inputPictureChromaAddressLo RVCE_CS(align(enc->luma->npix_y, 16)); // encInputFrameYPitch RVCE_CS(enc->luma->level[0].pitch_bytes); // encInputPicLumaPitch RVCE_CS(enc->chroma->level[0].pitch_bytes); // encInputPicChromaPitch RVCE_CS(0x00000000); // encInputPic(Addr|Array)Mode RVCE_CS(0x00000000); // encInputPicTileConfig RVCE_CS(enc->pic.picture_type); // encPicType RVCE_CS(enc->pic.picture_type == 3); // encIdrFlag RVCE_CS(0x00000000); // encIdrPicId RVCE_CS(0x00000000); // encMGSKeyPic RVCE_CS(0x00000001); // encReferenceFlag RVCE_CS(0x00000000); // encTemporalLayerIndex RVCE_CS(0x00000000); // num_ref_idx_active_override_flag RVCE_CS(0x00000000); // num_ref_idx_l0_active_minus1 RVCE_CS(0x00000000); // num_ref_idx_l1_active_minus1 for (i = 0; i < 4; ++i) { RVCE_CS(0x00000000); // encRefListModificationOp RVCE_CS(0x00000000); // encRefListModificationNum } for (i = 0; i < 4; ++i) { RVCE_CS(0x00000000); // encDecodedPictureMarkingOp RVCE_CS(0x00000000); // encDecodedPictureMarkingNum RVCE_CS(0x00000000); // encDecodedPictureMarkingIdx } for (i = 0; i < 4; ++i) { RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingOp RVCE_CS(0x00000000); // encDecodedRefBasePictureMarkingNum } RVCE_CS(0x00000000); // pictureStructure luma_offset = (2 * ((enc->pic.frame_num - 1) % 2) * fsize + 2 * fsize); if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR) { RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } else if(enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P) { RVCE_CS(0x00000000); // encPicType RVCE_CS(enc->pic.frame_num - 1); // frameNumber RVCE_CS(enc->pic.frame_num - 1); // pictureOrderCount RVCE_CS(luma_offset); // lumaOffset RVCE_CS(chroma_offset + luma_offset); // chromaOffset } for (i = 0; i < 2; ++i) { RVCE_CS(0x00000000); // pictureStructure RVCE_CS(0x00000000); // encPicType RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0xffffffff); // lumaOffset RVCE_CS(0xffffffff); // chromaOffset } luma_offset = (2 * (enc->pic.frame_num % 2) * fsize + 2 * fsize); RVCE_CS(luma_offset); // encReconstructedLumaOffset RVCE_CS(chroma_offset + luma_offset); // encReconstructedChromaOffset RVCE_CS(0x00000000); // encColocBufferOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReconstructedRefBasePictureChromaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureLumaOffset RVCE_CS(0x00000000); // encReferenceRefBasePictureChromaOffset RVCE_CS(0x00000000); // pictureCount RVCE_CS(0x00000000); // frameNumber RVCE_CS(0x00000000); // pictureOrderCount RVCE_CS(0x00000000); // numIPicRemainInRCGOP RVCE_CS(0x00000000); // numPPicRemainInRCGOP RVCE_CS(0x00000000); // numBPicRemainInRCGOP RVCE_CS(0x00000000); // numIRPicRemainInRCGOP RVCE_CS(0x00000000); // enableIntraRefresh RVCE_END(); }