mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 11:40:10 +01:00
radeonsi/vce: Remove support for FW 50 and older
Reviewed-by: Leo Liu <leo.liu@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32829>
This commit is contained in:
parent
6510c3d75f
commit
104f9c6654
6 changed files with 3 additions and 716 deletions
|
|
@ -84,8 +84,6 @@ files_libradeonsi = files(
|
|||
'radeon_uvd_enc_1_1.c',
|
||||
'radeon_vce.c',
|
||||
'radeon_vce.h',
|
||||
'radeon_vce_40_2_2.c',
|
||||
'radeon_vce_50.c',
|
||||
'radeon_vce_52.c',
|
||||
'radeon_vcn.h',
|
||||
'radeon_vcn.c',
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FW_40_2_2 ((40 << 24) | (2 << 16) | (2 << 8))
|
||||
#define FW_50_0_1 ((50 << 24) | (0 << 16) | (1 << 8))
|
||||
#define FW_50_1_2 ((50 << 24) | (1 << 16) | (2 << 8))
|
||||
#define FW_50_10_2 ((50 << 24) | (10 << 16) | (2 << 8))
|
||||
#define FW_50_17_3 ((50 << 24) | (17 << 16) | (3 << 8))
|
||||
#define FW_52_0_3 ((52 << 24) | (0 << 16) | (3 << 8))
|
||||
#define FW_52_4_3 ((52 << 24) | (4 << 16) | (3 << 8))
|
||||
#define FW_52_8_3 ((52 << 24) | (8 << 16) | (3 << 8))
|
||||
|
|
@ -460,30 +455,7 @@ struct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context,
|
|||
goto error;
|
||||
}
|
||||
|
||||
switch (sscreen->info.vce_fw_version) {
|
||||
case FW_40_2_2:
|
||||
si_vce_40_2_2_init(enc);
|
||||
break;
|
||||
|
||||
case FW_50_0_1:
|
||||
case FW_50_1_2:
|
||||
case FW_50_10_2:
|
||||
case FW_50_17_3:
|
||||
si_vce_50_init(enc);
|
||||
break;
|
||||
|
||||
case FW_52_0_3:
|
||||
case FW_52_4_3:
|
||||
case FW_52_8_3:
|
||||
si_vce_52_init(enc);
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((sscreen->info.vce_fw_version & (0xff << 24)) >= FW_53) {
|
||||
si_vce_52_init(enc);
|
||||
} else
|
||||
goto error;
|
||||
}
|
||||
|
||||
return &enc->base;
|
||||
|
||||
|
|
@ -500,11 +472,6 @@ error:
|
|||
bool si_vce_is_fw_version_supported(struct si_screen *sscreen)
|
||||
{
|
||||
switch (sscreen->info.vce_fw_version) {
|
||||
case FW_40_2_2:
|
||||
case FW_50_0_1:
|
||||
case FW_50_1_2:
|
||||
case FW_50_10_2:
|
||||
case FW_50_17_3:
|
||||
case FW_52_0_3:
|
||||
case FW_52_4_3:
|
||||
case FW_52_8_3:
|
||||
|
|
|
|||
|
|
@ -415,22 +415,7 @@ bool si_vce_is_fw_version_supported(struct si_screen *sscreen);
|
|||
void si_vce_add_buffer(struct rvce_encoder *enc, struct pb_buffer_lean *buf, unsigned usage,
|
||||
enum radeon_bo_domain domain, signed offset);
|
||||
|
||||
/* init vce fw 40.2.2 specific callbacks */
|
||||
void si_vce_40_2_2_init(struct rvce_encoder *enc);
|
||||
|
||||
/* init vce fw 50 specific callbacks */
|
||||
void si_vce_50_init(struct rvce_encoder *enc);
|
||||
|
||||
/* init vce fw 52 specific callbacks */
|
||||
void si_vce_52_init(struct rvce_encoder *enc);
|
||||
|
||||
/* get parameters for vce 40.2.2 */
|
||||
void si_vce_40_2_2_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic);
|
||||
|
||||
/* get parameters for vce 50 */
|
||||
void si_vce_50_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic);
|
||||
|
||||
/* get parameters for vce 52 */
|
||||
void si_vce_52_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,439 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_vce.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_video.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void session(struct rvce_encoder *enc)
|
||||
{
|
||||
RVCE_BEGIN(0x00000001); // session cmd
|
||||
RVCE_CS(enc->stream_handle);
|
||||
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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
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 create(struct rvce_encoder *enc)
|
||||
{
|
||||
enc->task_info(enc, 0x00000000, 0, 0, 0);
|
||||
|
||||
RVCE_BEGIN(0x01000001); // create cmd
|
||||
RVCE_CS(0x00000000); // encUseCircularBuffer
|
||||
RVCE_CS(u_get_h264_profile_idc(enc->base.profile)); // encProfile
|
||||
RVCE_CS(enc->pic.seq.level_idc); // encLevel
|
||||
RVCE_CS(0x00000000); // encPicStructRestriction
|
||||
RVCE_CS(enc->base.width); // encImageWidth
|
||||
RVCE_CS(enc->base.height); // encImageHeight
|
||||
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
|
||||
RVCE_CS(0x00000000); // encRefPic(Addr|Array)Mode, encPicStructRestriction, disableRDO
|
||||
RVCE_END();
|
||||
}
|
||||
|
||||
static void rate_control(struct rvce_encoder *enc)
|
||||
{
|
||||
uint32_t target_bits_picture =
|
||||
enc->pic.rate_ctrl[0].target_bitrate *
|
||||
((float)enc->pic.rate_ctrl[0].frame_rate_den /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num);
|
||||
uint32_t peak_bits_picture_integer =
|
||||
enc->pic.rate_ctrl[0].peak_bitrate *
|
||||
((float)enc->pic.rate_ctrl[0].frame_rate_den /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num);
|
||||
uint32_t peak_bits_picture_fraction =
|
||||
(((enc->pic.rate_ctrl[0].peak_bitrate *
|
||||
(uint64_t)enc->pic.rate_ctrl[0].frame_rate_den) %
|
||||
enc->pic.rate_ctrl[0].frame_rate_num) << 32) /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num;
|
||||
|
||||
RVCE_BEGIN(0x04000005); // rate control
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].rate_ctrl_method); // encRateControlMethod
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].target_bitrate); // encRateControlTargetBitRate
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].peak_bitrate); // encRateControlPeakBitRate
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].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[0].vbv_buffer_size); // encVBVBufferSize
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].frame_rate_den); // encRateControlFrameRateDen
|
||||
RVCE_CS(0x00000000); // encVBVBufferLevel
|
||||
RVCE_CS(0x00000000); // encMaxAUSize
|
||||
RVCE_CS(0x00000000); // encQPInitialMode
|
||||
RVCE_CS(target_bits_picture); // encTargetBitsPerPicture
|
||||
RVCE_CS(peak_bits_picture_integer); // encPeakBitsPerPictureInteger
|
||||
RVCE_CS(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_END();
|
||||
}
|
||||
|
||||
static void config_extension(struct rvce_encoder *enc)
|
||||
{
|
||||
RVCE_BEGIN(0x04000001); // config extension
|
||||
RVCE_CS(0x00000003); // encEnablePerfLogging
|
||||
RVCE_END();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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 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 vui(struct rvce_encoder *enc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!enc->pic.rate_ctrl[0].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[0].frame_rate_den); // timingInfo.numUnitsInTick
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].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 config(struct rvce_encoder *enc)
|
||||
{
|
||||
enc->task_info(enc, 0x00000002, 0, 0xffffffff, 0);
|
||||
enc->rate_control(enc);
|
||||
enc->config_extension(enc);
|
||||
enc->motion_estimation(enc);
|
||||
enc->rdo(enc);
|
||||
if (enc->use_vui)
|
||||
enc->vui(enc);
|
||||
enc->pic_control(enc);
|
||||
}
|
||||
|
||||
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,
|
||||
(uint64_t)enc->luma->u.legacy.level[0].offset_256B * 256); // inputPictureLumaAddressHi/Lo
|
||||
RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM,
|
||||
(uint64_t)enc->chroma->u.legacy.level[0].offset_256B * 256); // 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
|
||||
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_H2645_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_list[0];
|
||||
if (i > 1 && enc->pic.picture_type == PIPE_H2645_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_H2645_ENC_PICTURE_TYPE_P ||
|
||||
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); // 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_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); // 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
|
||||
}
|
||||
|
||||
si_vce_frame_offset(enc, si_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 destroy(struct rvce_encoder *enc)
|
||||
{
|
||||
enc->task_info(enc, 0x00000001, 0, 0, 0);
|
||||
|
||||
feedback(enc);
|
||||
|
||||
RVCE_BEGIN(0x02000001); // destroy
|
||||
RVCE_END();
|
||||
}
|
||||
|
||||
void si_vce_40_2_2_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
|
||||
{
|
||||
}
|
||||
|
||||
void si_vce_40_2_2_init(struct rvce_encoder *enc)
|
||||
{
|
||||
enc->session = session;
|
||||
enc->task_info = task_info;
|
||||
enc->create = create;
|
||||
enc->feedback = feedback;
|
||||
enc->rate_control = rate_control;
|
||||
enc->config_extension = config_extension;
|
||||
enc->pic_control = pic_control;
|
||||
enc->motion_estimation = motion_estimation;
|
||||
enc->rdo = rdo;
|
||||
enc->vui = vui;
|
||||
enc->config = config;
|
||||
enc->encode = encode;
|
||||
enc->destroy = destroy;
|
||||
enc->si_get_pic_param = si_vce_40_2_2_get_param;
|
||||
}
|
||||
|
|
@ -1,224 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2013 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "pipe/p_video_codec.h"
|
||||
#include "radeon_vce.h"
|
||||
#include "radeon_video.h"
|
||||
#include "si_pipe.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_video.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void rate_control(struct rvce_encoder *enc)
|
||||
{
|
||||
uint32_t target_bits_picture =
|
||||
enc->pic.rate_ctrl[0].target_bitrate *
|
||||
((float)enc->pic.rate_ctrl[0].frame_rate_den /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num);
|
||||
uint32_t peak_bits_picture_integer =
|
||||
enc->pic.rate_ctrl[0].peak_bitrate *
|
||||
((float)enc->pic.rate_ctrl[0].frame_rate_den /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num);
|
||||
uint32_t peak_bits_picture_fraction =
|
||||
(((enc->pic.rate_ctrl[0].peak_bitrate *
|
||||
(uint64_t)enc->pic.rate_ctrl[0].frame_rate_den) %
|
||||
enc->pic.rate_ctrl[0].frame_rate_num) << 32) /
|
||||
enc->pic.rate_ctrl[0].frame_rate_num;
|
||||
|
||||
RVCE_BEGIN(0x04000005); // rate control
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].rate_ctrl_method); // encRateControlMethod
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].target_bitrate); // encRateControlTargetBitRate
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].peak_bitrate); // encRateControlPeakBitRate
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].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[0].vbv_buffer_size); // encVBVBufferSize
|
||||
RVCE_CS(enc->pic.rate_ctrl[0].frame_rate_den); // encRateControlFrameRateDen
|
||||
RVCE_CS(0x00000000); // encVBVBufferLevel
|
||||
RVCE_CS(0x00000000); // encMaxAUSize
|
||||
RVCE_CS(0x00000000); // encQPInitialMode
|
||||
RVCE_CS(target_bits_picture); // encTargetBitsPerPicture
|
||||
RVCE_CS(peak_bits_picture_integer); // encPeakBitsPerPictureInteger
|
||||
RVCE_CS(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 encode(struct rvce_encoder *enc)
|
||||
{
|
||||
signed luma_offset, chroma_offset, bs_offset;
|
||||
unsigned bs_idx = enc->bs_idx++;
|
||||
int i;
|
||||
|
||||
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_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,
|
||||
(uint64_t)enc->luma->u.legacy.level[0].offset_256B * 256); // inputPictureLumaAddressHi/Lo
|
||||
RVCE_READ(enc->handle, RADEON_DOMAIN_VRAM,
|
||||
(uint64_t)enc->chroma->u.legacy.level[0].offset_256B * 256); // 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
|
||||
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_H2645_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_list[0];
|
||||
if (i > 1 && enc->pic.picture_type == PIPE_H2645_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_H2645_ENC_PICTURE_TYPE_P ||
|
||||
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); // 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_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); // 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
|
||||
}
|
||||
|
||||
si_vce_frame_offset(enc, si_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();
|
||||
}
|
||||
|
||||
void si_vce_50_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
|
||||
{
|
||||
}
|
||||
|
||||
void si_vce_50_init(struct rvce_encoder *enc)
|
||||
{
|
||||
si_vce_40_2_2_init(enc);
|
||||
|
||||
/* only the two below are different */
|
||||
enc->rate_control = rate_control;
|
||||
enc->encode = encode;
|
||||
enc->si_get_pic_param = si_vce_50_get_param;
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ static void get_vui_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture
|
|||
enc->enc_pic.vui.max_dec_frame_buffering = 0x00000003;
|
||||
}
|
||||
|
||||
void si_vce_52_get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
|
||||
static void get_param(struct rvce_encoder *enc, struct pipe_h264_enc_picture_desc *pic)
|
||||
{
|
||||
get_rate_control_param(enc, pic);
|
||||
get_motion_estimation_param(enc, pic);
|
||||
|
|
@ -657,5 +657,5 @@ void si_vce_52_init(struct rvce_encoder *enc)
|
|||
enc->config = config;
|
||||
enc->encode = encode;
|
||||
enc->destroy = destroy;
|
||||
enc->si_get_pic_param = si_vce_52_get_param;
|
||||
enc->si_get_pic_param = get_param;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue