示例#1
0
static void motion_estimation(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000007); // motion estimation
	RVCE_CS(0x00000001); // encIMEDecimationSearch
	RVCE_CS(0x00000001); // motionEstHalfPixel
	RVCE_CS(0x00000000); // motionEstQuarterPixel
	RVCE_CS(0x00000000); // disableFavorPMVPoint
	RVCE_CS(0x00000000); // forceZeroPointCenter
	RVCE_CS(0x00000000); // LSMVert
	RVCE_CS(0x00000010); // encSearchRangeX
	RVCE_CS(0x00000010); // encSearchRangeY
	RVCE_CS(0x00000010); // encSearch1RangeX
	RVCE_CS(0x00000010); // encSearch1RangeY
	RVCE_CS(0x00000000); // disable16x16Frame1
	RVCE_CS(0x00000000); // disableSATD
	RVCE_CS(0x00000000); // enableAMD
	RVCE_CS(0x000000fe); // encDisableSubMode
	RVCE_CS(0x00000000); // encIMESkipX
	RVCE_CS(0x00000000); // encIMESkipY
	RVCE_CS(0x00000000); // encEnImeOverwDisSubm
	RVCE_CS(0x00000000); // encImeOverwDisSubmNo
	RVCE_CS(0x00000001); // encIME2SearchRangeX
	RVCE_CS(0x00000001); // encIME2SearchRangeY
	RVCE_CS(0x00000000); // parallelModeSpeedupEnable
	RVCE_CS(0x00000000); // fme0_encDisableSubMode
	RVCE_CS(0x00000000); // fme1_encDisableSubMode
	RVCE_CS(0x00000000); // imeSWSpeedupEnable
	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(enc->enc_pic.fb.feedback_ring_size);
	RVCE_END();
}
static void create(struct rvce_encoder *enc)
{
	struct r600_common_screen *rscreen = (struct r600_common_screen *)enc->screen;
	enc->task_info(enc, 0x00000000, 0, 0, 0);

	RVCE_BEGIN(0x01000001); // create cmd
	RVCE_CS(enc->enc_pic.ec.enc_use_circular_buffer);
	RVCE_CS(profiles[enc->base.profile -
		PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE]); // encProfile
	RVCE_CS(enc->base.level); // encLevel
	RVCE_CS(enc->enc_pic.ec.enc_pic_struct_restriction);
	RVCE_CS(enc->base.width); // encImageWidth
	RVCE_CS(enc->base.height); // encImageHeight

	if (rscreen->chip_class < GFX9) {
		RVCE_CS(enc->luma->u.legacy.level[0].nblk_x * enc->luma->bpe); // encRefPicLumaPitch
		RVCE_CS(enc->chroma->u.legacy.level[0].nblk_x * enc->chroma->bpe); // encRefPicChromaPitch
		RVCE_CS(align(enc->luma->u.legacy.level[0].nblk_y, 16) / 8); // encRefYHeightInQw
	} else {
		RVCE_CS(enc->luma->u.gfx9.surf_pitch * enc->luma->bpe); // encRefPicLumaPitch
		RVCE_CS(enc->chroma->u.gfx9.surf_pitch * enc->chroma->bpe); // encRefPicChromaPitch
		RVCE_CS(align(enc->luma->u.gfx9.surf_height, 16) / 8); // encRefYHeightInQw
	}

	RVCE_CS(enc->enc_pic.addrmode_arraymode_disrdo_distwoinstants);

	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_context_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_input_luma_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_input_chroma_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_mode_chromaflag_vbaqmode_scenechangesensitivity);
	RVCE_END();
}
示例#4
0
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 pic_control(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000002); // pic control
	RVCE_CS(enc->enc_pic.pc.enc_use_constrained_intra_pred);
	RVCE_CS(enc->enc_pic.pc.enc_cabac_enable);
	RVCE_CS(enc->enc_pic.pc.enc_cabac_idc);
	RVCE_CS(enc->enc_pic.pc.enc_loop_filter_disable);
	RVCE_CS(enc->enc_pic.pc.enc_lf_beta_offset);
	RVCE_CS(enc->enc_pic.pc.enc_lf_alpha_c0_offset);
	RVCE_CS(enc->enc_pic.pc.enc_crop_left_offset);
	RVCE_CS(enc->enc_pic.pc.enc_crop_right_offset);
	RVCE_CS(enc->enc_pic.pc.enc_crop_top_offset);
	RVCE_CS(enc->enc_pic.pc.enc_crop_bottom_offset);
	RVCE_CS(enc->enc_pic.pc.enc_num_mbs_per_slice);
	RVCE_CS(enc->enc_pic.pc.enc_intra_refresh_num_mbs_per_slot);
	RVCE_CS(enc->enc_pic.pc.enc_force_intra_refresh);
	RVCE_CS(enc->enc_pic.pc.enc_force_imb_period);
	RVCE_CS(enc->enc_pic.pc.enc_pic_order_cnt_type);
	RVCE_CS(enc->enc_pic.pc.log2_max_pic_order_cnt_lsb_minus4);
	RVCE_CS(enc->enc_pic.pc.enc_sps_id);
	RVCE_CS(enc->enc_pic.pc.enc_pps_id);
	RVCE_CS(enc->enc_pic.pc.enc_constraint_set_flags);
	RVCE_CS(enc->enc_pic.pc.enc_b_pic_pattern);
	RVCE_CS(enc->enc_pic.pc.weight_pred_mode_b_picture);
	RVCE_CS(enc->enc_pic.pc.enc_number_of_reference_frames);
	RVCE_CS(enc->enc_pic.pc.enc_max_num_ref_frames);
	RVCE_CS(enc->enc_pic.pc.enc_num_default_active_ref_l0);
	RVCE_CS(enc->enc_pic.pc.enc_num_default_active_ref_l1);
	RVCE_CS(enc->enc_pic.pc.enc_slice_mode);
	RVCE_CS(enc->enc_pic.pc.enc_max_slice_size);
	RVCE_END();
}
static void motion_estimation(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000007); // motion estimation
	RVCE_CS(enc->enc_pic.me.enc_ime_decimation_search);
	RVCE_CS(enc->enc_pic.me.motion_est_half_pixel);
	RVCE_CS(enc->enc_pic.me.motion_est_quarter_pixel);
	RVCE_CS(enc->enc_pic.me.disable_favor_pmv_point);
	RVCE_CS(enc->enc_pic.me.force_zero_point_center);
	RVCE_CS(enc->enc_pic.me.lsmvert);
	RVCE_CS(enc->enc_pic.me.enc_search_range_x);
	RVCE_CS(enc->enc_pic.me.enc_search_range_y);
	RVCE_CS(enc->enc_pic.me.enc_search1_range_x);
	RVCE_CS(enc->enc_pic.me.enc_search1_range_y);
	RVCE_CS(enc->enc_pic.me.disable_16x16_frame1);
	RVCE_CS(enc->enc_pic.me.disable_satd);
	RVCE_CS(enc->enc_pic.me.enable_amd);
	RVCE_CS(enc->enc_pic.me.enc_disable_sub_mode);
	RVCE_CS(enc->enc_pic.me.enc_ime_skip_x);
	RVCE_CS(enc->enc_pic.me.enc_ime_skip_y);
	RVCE_CS(enc->enc_pic.me.enc_en_ime_overw_dis_subm);
	RVCE_CS(enc->enc_pic.me.enc_ime_overw_dis_subm_no);
	RVCE_CS(enc->enc_pic.me.enc_ime2_search_range_x);
	RVCE_CS(enc->enc_pic.me.enc_ime2_search_range_y);
	RVCE_CS(enc->enc_pic.me.parallel_mode_speedup_enable);
	RVCE_CS(enc->enc_pic.me.fme0_enc_disable_sub_mode);
	RVCE_CS(enc->enc_pic.me.fme1_enc_disable_sub_mode);
	RVCE_CS(enc->enc_pic.me.ime_sw_speedup_enable);
	RVCE_END();
}
示例#7
0
static void destroy(struct rvce_encoder *enc)
{
	enc->task_info(enc, 0x00000001, 0, 0, 0);

	RVCE_BEGIN(0x02000001); // destroy
	RVCE_END();
}
示例#8
0
static void rate_control(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000005); // rate control
	RVCE_CS(enc->pic.rate_ctrl.rate_ctrl_method); // encRateControlMethod
	RVCE_CS(enc->pic.rate_ctrl.target_bitrate); // encRateControlTargetBitRate
	RVCE_CS(enc->pic.rate_ctrl.peak_bitrate); // encRateControlPeakBitRate
	RVCE_CS(enc->pic.rate_ctrl.frame_rate_num); // encRateControlFrameRateNum
	RVCE_CS(0x00000000); // encGOPSize
	RVCE_CS(enc->pic.quant_i_frames); // encQP_I
	RVCE_CS(enc->pic.quant_p_frames); // encQP_P
	RVCE_CS(enc->pic.quant_b_frames); // encQP_B
	RVCE_CS(enc->pic.rate_ctrl.vbv_buffer_size); // encVBVBufferSize
	RVCE_CS(enc->pic.rate_ctrl.frame_rate_den); // encRateControlFrameRateDen
	RVCE_CS(0x00000000); // encVBVBufferLevel
	RVCE_CS(0x00000000); // encMaxAUSize
	RVCE_CS(0x00000000); // encQPInitialMode
	RVCE_CS(enc->pic.rate_ctrl.target_bits_picture); // encTargetBitsPerPicture
	RVCE_CS(enc->pic.rate_ctrl.peak_bits_picture_integer); // encPeakBitsPerPictureInteger
	RVCE_CS(enc->pic.rate_ctrl.peak_bits_picture_fraction); // encPeakBitsPerPictureFractional
	RVCE_CS(0x00000000); // encMinQP
	RVCE_CS(0x00000033); // encMaxQP
	RVCE_CS(0x00000000); // encSkipFrameEnable
	RVCE_CS(0x00000000); // encFillerDataEnable
	RVCE_CS(0x00000000); // encEnforceHRD
	RVCE_CS(0x00000000); // encBPicsDeltaQP
	RVCE_CS(0x00000000); // encReferenceBPicsDeltaQP
	RVCE_CS(0x00000000); // encRateControlReInitDisable
	RVCE_CS(0x00000000); // encLCVBRInitQPFlag
	RVCE_CS(0x00000000); // encLCVBRSATDBasedNonlinearBitBudgetFlag
	RVCE_END();
}
static void rate_control(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000005); // rate control
	RVCE_CS(enc->enc_pic.rc.rc_method);
	RVCE_CS(enc->enc_pic.rc.target_bitrate);
	RVCE_CS(enc->enc_pic.rc.peak_bitrate);
	RVCE_CS(enc->enc_pic.rc.frame_rate_num);
	RVCE_CS(enc->enc_pic.rc.gop_size);
	RVCE_CS(enc->enc_pic.rc.quant_i_frames);
	RVCE_CS(enc->enc_pic.rc.quant_p_frames);
	RVCE_CS(enc->enc_pic.rc.quant_b_frames);
	RVCE_CS(enc->enc_pic.rc.vbv_buffer_size);
	RVCE_CS(enc->enc_pic.rc.frame_rate_den);
	RVCE_CS(enc->enc_pic.rc.vbv_buf_lv);
	RVCE_CS(enc->enc_pic.rc.max_au_size);
	RVCE_CS(enc->enc_pic.rc.qp_initial_mode);
	RVCE_CS(enc->enc_pic.rc.target_bits_picture);
	RVCE_CS(enc->enc_pic.rc.peak_bits_picture_integer);
	RVCE_CS(enc->enc_pic.rc.peak_bits_picture_fraction);
	RVCE_CS(enc->enc_pic.rc.min_qp);
	RVCE_CS(enc->enc_pic.rc.max_qp);
	RVCE_CS(enc->enc_pic.rc.skip_frame_enable);
	RVCE_CS(enc->enc_pic.rc.fill_data_enable);
	RVCE_CS(enc->enc_pic.rc.enforce_hrd);
	RVCE_CS(enc->enc_pic.rc.b_pics_delta_qp);
	RVCE_CS(enc->enc_pic.rc.ref_b_pics_delta_qp);
	RVCE_CS(enc->enc_pic.rc.rc_reinit_disable);
	RVCE_CS(enc->enc_pic.rc.enc_lcvbr_init_qp_flag);
	RVCE_CS(enc->enc_pic.rc.lcvbrsatd_based_nonlinear_bit_budget_flag);
	RVCE_END();
}
示例#10
0
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();
}
示例#11
0
static void task_info(struct rvce_encoder *enc, uint32_t taskOperation)
{
	RVCE_BEGIN(0x00000002); // task info
	RVCE_CS(0xffffffff); // offsetOfNextTaskInfo
	RVCE_CS(taskOperation); // taskOperation
	RVCE_CS(0x00000000); // referencePictureDependency
	RVCE_CS(0x00000000); // collocateFlagDependency
	RVCE_CS(0x00000000); // feedbackIndex
	RVCE_CS(0x00000000); // videoBitstreamRingIndex
	RVCE_END();
}
示例#12
0
static void vui(struct rvce_encoder *enc)
{
	int i;

	if (!enc->pic.rate_ctrl.frame_rate_num)
		return;

	RVCE_BEGIN(0x04000009); // vui
	RVCE_CS(0x00000000); //aspectRatioInfoPresentFlag
	RVCE_CS(0x00000000); //aspectRatioInfo.aspectRatioIdc
	RVCE_CS(0x00000000); //aspectRatioInfo.sarWidth
	RVCE_CS(0x00000000); //aspectRatioInfo.sarHeight
	RVCE_CS(0x00000000); //overscanInfoPresentFlag
	RVCE_CS(0x00000000); //overScanInfo.overscanAppropFlag
	RVCE_CS(0x00000000); //videoSignalTypePresentFlag
	RVCE_CS(0x00000005); //videoSignalTypeInfo.videoFormat
	RVCE_CS(0x00000000); //videoSignalTypeInfo.videoFullRangeFlag
	RVCE_CS(0x00000000); //videoSignalTypeInfo.colorDescriptionPresentFlag
	RVCE_CS(0x00000002); //videoSignalTypeInfo.colorPrim
	RVCE_CS(0x00000002); //videoSignalTypeInfo.transferChar
	RVCE_CS(0x00000002); //videoSignalTypeInfo.matrixCoef
	RVCE_CS(0x00000000); //chromaLocInfoPresentFlag
	RVCE_CS(0x00000000); //chromaLocInfo.chromaLocTop
	RVCE_CS(0x00000000); //chromaLocInfo.chromaLocBottom
	RVCE_CS(0x00000001); //timingInfoPresentFlag
	RVCE_CS(enc->pic.rate_ctrl.frame_rate_den); //timingInfo.numUnitsInTick
	RVCE_CS(enc->pic.rate_ctrl.frame_rate_num * 2); //timingInfo.timeScale;
	RVCE_CS(0x00000001); //timingInfo.fixedFrameRateFlag
	RVCE_CS(0x00000000); //nalHRDParametersPresentFlag
	RVCE_CS(0x00000000); //hrdParam.cpbCntMinus1
	RVCE_CS(0x00000004); //hrdParam.bitRateScale
	RVCE_CS(0x00000006); //hrdParam.cpbSizeScale
	for (i = 0; i < 32; i++) {
		RVCE_CS(0x00000000); //hrdParam.bitRateValueMinus
		RVCE_CS(0x00000000); //hrdParam.cpbSizeValueMinus
		RVCE_CS(0x00000000); //hrdParam.cbrFlag
	}
	RVCE_CS(0x00000017); //hrdParam.initialCpbRemovalDelayLengthMinus1
	RVCE_CS(0x00000017); //hrdParam.cpbRemovalDelayLengthMinus1
	RVCE_CS(0x00000017); //hrdParam.dpbOutputDelayLengthMinus1
	RVCE_CS(0x00000018); //hrdParam.timeOffsetLength
	RVCE_CS(0x00000000); //lowDelayHRDFlag
	RVCE_CS(0x00000000); //picStructPresentFlag
	RVCE_CS(0x00000000); //bitstreamRestrictionPresentFlag
	RVCE_CS(0x00000001); //bitstreamRestrictions.motionVectorsOverPicBoundariesFlag
	RVCE_CS(0x00000002); //bitstreamRestrictions.maxBytesPerPicDenom
	RVCE_CS(0x00000001); //bitstreamRestrictions.maxBitsPerMbDenom
	RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthHori
	RVCE_CS(0x00000010); //bitstreamRestrictions.log2MaxMvLengthVert
	RVCE_CS(0x00000003); //bitstreamRestrictions.numReorderFrames
	RVCE_CS(0x00000003); //bitstreamRestrictions.maxDecFrameBuffering
	RVCE_END();
}
static void vui(struct rvce_encoder *enc)
{
	int i;

	if (!enc->enc_pic.enable_vui)
		return;

	RVCE_BEGIN(0x04000009); // vui
	RVCE_CS(enc->enc_pic.vui.aspect_ratio_info_present_flag);
	RVCE_CS(enc->enc_pic.vui.aspect_ratio_idc);
	RVCE_CS(enc->enc_pic.vui.sar_width);
	RVCE_CS(enc->enc_pic.vui.sar_height);
	RVCE_CS(enc->enc_pic.vui.overscan_info_present_flag);
	RVCE_CS(enc->enc_pic.vui.overscan_Approp_flag);
	RVCE_CS(enc->enc_pic.vui.video_signal_type_present_flag);
	RVCE_CS(enc->enc_pic.vui.video_format);
	RVCE_CS(enc->enc_pic.vui.video_full_range_flag);
	RVCE_CS(enc->enc_pic.vui.color_description_present_flag);
	RVCE_CS(enc->enc_pic.vui.color_prim);
	RVCE_CS(enc->enc_pic.vui.transfer_char);
	RVCE_CS(enc->enc_pic.vui.matrix_coef);
	RVCE_CS(enc->enc_pic.vui.chroma_loc_info_present_flag);
	RVCE_CS(enc->enc_pic.vui.chroma_loc_top);
	RVCE_CS(enc->enc_pic.vui.chroma_loc_bottom);
	RVCE_CS(enc->enc_pic.vui.timing_info_present_flag);
	RVCE_CS(enc->enc_pic.vui.num_units_in_tick);
	RVCE_CS(enc->enc_pic.vui.time_scale);
	RVCE_CS(enc->enc_pic.vui.fixed_frame_rate_flag);
	RVCE_CS(enc->enc_pic.vui.nal_hrd_parameters_present_flag);
	RVCE_CS(enc->enc_pic.vui.cpb_cnt_minus1);
	RVCE_CS(enc->enc_pic.vui.bit_rate_scale);
	RVCE_CS(enc->enc_pic.vui.cpb_size_scale);
	for (i = 0; i < 32; i++) {
		RVCE_CS(enc->enc_pic.vui.bit_rate_value_minus);
		RVCE_CS(enc->enc_pic.vui.cpb_size_value_minus);
		RVCE_CS(enc->enc_pic.vui.cbr_flag);
	}
	RVCE_CS(enc->enc_pic.vui.initial_cpb_removal_delay_length_minus1);
	RVCE_CS(enc->enc_pic.vui.cpb_removal_delay_length_minus1);
	RVCE_CS(enc->enc_pic.vui.dpb_output_delay_length_minus1);
	RVCE_CS(enc->enc_pic.vui.time_offset_length);
	RVCE_CS(enc->enc_pic.vui.low_delay_hrd_flag);
	RVCE_CS(enc->enc_pic.vui.pic_struct_present_flag);
	RVCE_CS(enc->enc_pic.vui.bitstream_restriction_present_flag);
	RVCE_CS(enc->enc_pic.vui.motion_vectors_over_pic_boundaries_flag);
	RVCE_CS(enc->enc_pic.vui.max_bytes_per_pic_denom);
	RVCE_CS(enc->enc_pic.vui.max_bits_per_mb_denom);
	RVCE_CS(enc->enc_pic.vui.log2_max_mv_length_hori);
	RVCE_CS(enc->enc_pic.vui.log2_max_mv_length_vert);
	RVCE_CS(enc->enc_pic.vui.num_reorder_frames);
	RVCE_CS(enc->enc_pic.vui.max_dec_frame_buffering);
	RVCE_END();
}
示例#14
0
static void create(struct rvce_encoder *enc)
{
	task_info(enc, 0x00000000);

	RVCE_BEGIN(0x01000001); // create cmd
	RVCE_CS(0x00000000); // encUseCircularBuffer
	RVCE_CS(0x00000041); // encProfile
	RVCE_CS(0x0000000a); // encLevel
	RVCE_CS(0x00000000); // encPicStructRestriction
	RVCE_CS(enc->base.width); // encImageWidth
	RVCE_CS(enc->base.height); // encImageHeight
	RVCE_CS(enc->luma->level[0].pitch_bytes); // encRefPicLumaPitch
	RVCE_CS(enc->chroma->level[0].pitch_bytes); // encRefPicChromaPitch
	RVCE_CS(align(enc->luma->npix_y, 16) / 8); // encRefYHeightInQw
	RVCE_CS(0x00000000); // encRefPic(Addr|Array)Mode, encPicStructRestriction, disableRDO
	RVCE_END();
}
示例#15
0
static void task_info(struct rvce_encoder *enc, uint32_t op,
		      uint32_t dep, uint32_t fb_idx, uint32_t ring_idx)
{
	RVCE_BEGIN(0x00000002); // task info
	if (op == 0x3) {
		if (enc->task_info_idx) {
			uint32_t offs = enc->cs->current.cdw - enc->task_info_idx + 3;
			// Update offsetOfNextTaskInfo
			enc->cs->current.buf[enc->task_info_idx] = offs;
		}
		enc->task_info_idx = enc->cs->current.cdw;
	}
	RVCE_CS(0xffffffff); // offsetOfNextTaskInfo
	RVCE_CS(op); // taskOperation
	RVCE_CS(dep); // referencePictureDependency
	RVCE_CS(0x00000000); // collocateFlagDependency
	RVCE_CS(fb_idx); // feedbackIndex
	RVCE_CS(ring_idx); // videoBitstreamRingIndex
	RVCE_END();
}
示例#16
0
static void rdo(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000008); // rdo
	RVCE_CS(0x00000000); // encDisableTbePredIFrame
	RVCE_CS(0x00000000); // encDisableTbePredPFrame
	RVCE_CS(0x00000000); // useFmeInterpolY
	RVCE_CS(0x00000000); // useFmeInterpolUV
	RVCE_CS(0x00000000); // useFmeIntrapolY
	RVCE_CS(0x00000000); // useFmeIntrapolUV
	RVCE_CS(0x00000000); // useFmeInterpolY_1
	RVCE_CS(0x00000000); // useFmeInterpolUV_1
	RVCE_CS(0x00000000); // useFmeIntrapolY_1
	RVCE_CS(0x00000000); // useFmeIntrapolUV_1
	RVCE_CS(0x00000000); // enc16x16CostAdj
	RVCE_CS(0x00000000); // encSkipCostAdj
	RVCE_CS(0x00000000); // encForce16x16skip
	RVCE_CS(0x00000000); // encDisableThresholdCalcA
	RVCE_CS(0x00000000); // encLumaCoeffCost
	RVCE_CS(0x00000000); // encLumaMBCoeffCost
	RVCE_CS(0x00000000); // encChromaCoeffCost
	RVCE_END();
}
static void rdo(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000008); // rdo
	RVCE_CS(enc->enc_pic.rdo.enc_disable_tbe_pred_i_frame);
	RVCE_CS(enc->enc_pic.rdo.enc_disable_tbe_pred_p_frame);
	RVCE_CS(enc->enc_pic.rdo.use_fme_interpol_y);
	RVCE_CS(enc->enc_pic.rdo.use_fme_interpol_uv);
	RVCE_CS(enc->enc_pic.rdo.use_fme_intrapol_y);
	RVCE_CS(enc->enc_pic.rdo.use_fme_intrapol_uv);
	RVCE_CS(enc->enc_pic.rdo.use_fme_interpol_y_1);
	RVCE_CS(enc->enc_pic.rdo.use_fme_interpol_uv_1);
	RVCE_CS(enc->enc_pic.rdo.use_fme_intrapol_y_1);
	RVCE_CS(enc->enc_pic.rdo.use_fme_intrapol_uv_1);
	RVCE_CS(enc->enc_pic.rdo.enc_16x16_cost_adj);
	RVCE_CS(enc->enc_pic.rdo.enc_skip_cost_adj);
	RVCE_CS(enc->enc_pic.rdo.enc_force_16x16_skip);
	RVCE_CS(enc->enc_pic.rdo.enc_disable_threshold_calc_a);
	RVCE_CS(enc->enc_pic.rdo.enc_luma_coeff_cost);
	RVCE_CS(enc->enc_pic.rdo.enc_luma_mb_coeff_cost);
	RVCE_CS(enc->enc_pic.rdo.enc_chroma_coeff_cost);
	RVCE_END();
}
示例#18
0
static void create(struct rvce_encoder *enc)
{
	enc->task_info(enc, 0x00000000, 0, 0, 0);

	RVCE_BEGIN(0x01000001); // create cmd
	RVCE_CS(0x00000000); // encUseCircularBuffer
	RVCE_CS(profiles[enc->base.profile -
		PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE]); // encProfile
	RVCE_CS(enc->base.level); // encLevel
	RVCE_CS(0x00000000); // encPicStructRestriction
	RVCE_CS(enc->base.width); // encImageWidth
	RVCE_CS(enc->base.height); // encImageHeight
	RVCE_CS(enc->luma->level[0].pitch_bytes); // encRefPicLumaPitch
	RVCE_CS(enc->chroma->level[0].pitch_bytes); // encRefPicChromaPitch
	RVCE_CS(align(enc->luma->npix_y, 16) / 8); // encRefYHeightInQw
	RVCE_CS(0x00000000); // encRefPic(Addr|Array)Mode, encPicStructRestriction, disableRDO

	RVCE_CS(0x00000000); // encPreEncodeContextBufferOffset
	RVCE_CS(0x00000000); // encPreEncodeInputLumaBufferOffset
	RVCE_CS(0x00000000); // encPreEncodeInputChromaBufferOffs
	RVCE_CS(0x00000000); // encPreEncodeMode|ChromaFlag|VBAQMode|SceneChangeSensitivity
	RVCE_END();
}
示例#19
0
static void pic_control(struct rvce_encoder *enc)
{
	unsigned encNumMBsPerSlice;

	encNumMBsPerSlice = align(enc->base.width, 16) / 16;
	encNumMBsPerSlice *= align(enc->base.height, 16) / 16;

	RVCE_BEGIN(0x04000002); // pic control
	RVCE_CS(0x00000000); // encUseConstrainedIntraPred
	RVCE_CS(0x00000000); // encCABACEnable
	RVCE_CS(0x00000000); // encCABACIDC
	RVCE_CS(0x00000000); // encLoopFilterDisable
	RVCE_CS(0x00000000); // encLFBetaOffset
	RVCE_CS(0x00000000); // encLFAlphaC0Offset
	RVCE_CS(0x00000000); // encCropLeftOffset
	RVCE_CS((align(enc->base.width, 16) - enc->base.width) >> 1); // encCropRightOffset
	RVCE_CS(0x00000000); // encCropTopOffset
	RVCE_CS((align(enc->base.height, 16) - enc->base.height) >> 1); // encCropBottomOffset
	RVCE_CS(encNumMBsPerSlice); // encNumMBsPerSlice
	RVCE_CS(0x00000000); // encIntraRefreshNumMBsPerSlot
	RVCE_CS(0x00000000); // encForceIntraRefresh
	RVCE_CS(0x00000000); // encForceIMBPeriod
	RVCE_CS(0x00000000); // encPicOrderCntType
	RVCE_CS(0x00000000); // log2_max_pic_order_cnt_lsb_minus4
	RVCE_CS(0x00000000); // encSPSID
	RVCE_CS(0x00000000); // encPPSID
	RVCE_CS(0x00000040); // encConstraintSetFlags
	RVCE_CS(MAX2(enc->base.max_references, 1) - 1); // encBPicPattern
	RVCE_CS(0x00000000); // weightPredModeBPicture
	RVCE_CS(MIN2(enc->base.max_references, 2)); // encNumberOfReferenceFrames
	RVCE_CS(enc->base.max_references + 1); // encMaxNumRefFrames
	RVCE_CS(0x00000001); // encNumDefaultActiveRefL0
	RVCE_CS(0x00000001); // encNumDefaultActiveRefL1
	RVCE_CS(0x00000000); // encSliceMode
	RVCE_CS(0x00000000); // encMaxSliceSize
	RVCE_END();
}
示例#20
0
static void create(struct rvce_encoder *enc)
{
	enc->enc_pic.addrmode_arraymode_disrdo_distwoinstants = 0x00000201;
	enc->task_info(enc, 0x00000000, 0, 0, 0);

	RVCE_BEGIN(0x01000001); // create cmd
	RVCE_CS(enc->enc_pic.ec.enc_use_circular_buffer);
	RVCE_CS(profiles[enc->base.profile -
		PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE]); // encProfile
	RVCE_CS(enc->base.level); // encLevel
	RVCE_CS(enc->enc_pic.ec.enc_pic_struct_restriction);
	RVCE_CS(enc->base.width); // encImageWidth
	RVCE_CS(enc->base.height); // encImageHeight
	RVCE_CS(enc->luma->level[0].pitch_bytes); // encRefPicLumaPitch
	RVCE_CS(enc->chroma->level[0].pitch_bytes); // encRefPicChromaPitch
	RVCE_CS(align(enc->luma->npix_y, 16) / 8); // encRefYHeightInQw
	RVCE_CS(enc->enc_pic.addrmode_arraymode_disrdo_distwoinstants);

	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_context_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_input_luma_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_input_chroma_buffer_offset);
	RVCE_CS(enc->enc_pic.ec.enc_pre_encode_mode_chromaflag_vbaqmode_scenechangesensitivity);
	RVCE_END();
}
static void task_info(struct rvce_encoder *enc, uint32_t op,
					  uint32_t dep, uint32_t fb_idx, uint32_t ring_idx)
{
	RVCE_BEGIN(0x00000002); // task info
	if (op == 0x3) {
		if (enc->task_info_idx) {
			uint32_t offs = enc->cs->current.cdw - enc->task_info_idx + 3;
			// Update offsetOfNextTaskInfo
			enc->cs->current.buf[enc->task_info_idx] = offs;
		}
		enc->task_info_idx = enc->cs->current.cdw;
	}
	enc->enc_pic.ti.task_operation = op;
	enc->enc_pic.ti.reference_picture_dependency = dep;
	enc->enc_pic.ti.feedback_index = fb_idx;
	enc->enc_pic.ti.video_bitstream_ring_index = ring_idx;
	RVCE_CS(enc->enc_pic.ti.offset_of_next_task_info);
	RVCE_CS(enc->enc_pic.ti.task_operation);
	RVCE_CS(enc->enc_pic.ti.reference_picture_dependency);
	RVCE_CS(enc->enc_pic.ti.collocate_flag_dependency);
	RVCE_CS(enc->enc_pic.ti.feedback_index);
	RVCE_CS(enc->enc_pic.ti.video_bitstream_ring_index);
	RVCE_END();
}
示例#22
0
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();
}
示例#23
0
static void config_extension(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000001); // config extension
	RVCE_CS(0x00000003); // encEnablePerfLogging
	RVCE_END();
}
static void session(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x00000001); // session cmd
	RVCE_CS(enc->stream_handle);
	RVCE_END();
}
示例#25
0
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();
}
示例#26
0
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();
}
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 config_extension(struct rvce_encoder *enc)
{
	RVCE_BEGIN(0x04000001); // config extension
	RVCE_CS(enc->enc_pic.ce.enc_enable_perf_logging);
	RVCE_END();
}