Commit 1bb830cf authored by Bob Beckett's avatar Bob Beckett
Browse files

mdeia/wave5: refactor CodecInst->codecMode and bitstreamFormat away



store the standard being used in vpu_instance.
remove vpu abstraction translations as they are not needed.
use the final hw std value throughout.
Signed-off-by: Bob Beckett's avatarRobert Beckett <bob.beckett@collabora.com>
parent 5a4bee73
......@@ -83,15 +83,15 @@ static const struct vpu_format vpu_dec_fmt_list[2][6] = {
}
};
static enum CodStd to_vpu_codstd(unsigned int v4l2_pix_fmt)
static enum wave_std to_vpu_codstd(unsigned int v4l2_pix_fmt)
{
switch (v4l2_pix_fmt) {
case V4L2_PIX_FMT_H264:
return STD_AVC;
return W_AVC_DEC;
case V4L2_PIX_FMT_HEVC:
return STD_HEVC;
return W_HEVC_DEC;
default:
return 0;
return STD_UNKNOWN;
}
}
......@@ -907,7 +907,11 @@ static int vpu_dec_queue_setup(struct vb2_queue *q, unsigned int *num_buffers, u
if (vdi_allocate_dma_memory(inst->dev, &inst->bitstream_vbuf, DEC_BS, 0) < 0)
DPRINTK(inst->dev, 1, "Failed to allocate bitstream buffer : %zu\n", inst->bitstream_vbuf.size);
open_param.bitstreamFormat = to_vpu_codstd(inst->src_fmt.pixelformat);
inst->std = to_vpu_codstd(inst->src_fmt.pixelformat);
if (inst->std == STD_UNKNOWN) {
dev_warn(inst->dev->dev, "Unsupported pixelformat: %.4s\n", (char*)&inst->src_fmt.pixelformat);
return -EINVAL;
}
open_param.bitstreamBuffer = inst->bitstream_vbuf.daddr;
open_param.bitstreamBufferSize = inst->bitstream_vbuf.size;
......
......@@ -87,11 +87,11 @@ static enum CodStd to_vpu_codstd(unsigned int v4l2_pix_fmt)
{
switch (v4l2_pix_fmt) {
case V4L2_PIX_FMT_H264:
return STD_AVC;
return W_AVC_ENC;
case V4L2_PIX_FMT_HEVC:
return STD_HEVC;
return W_HEVC_ENC;
default:
return 0;
return STD_UNKNOWN;
}
}
......@@ -1130,7 +1130,11 @@ static int vpu_enc_queue_setup(struct vb2_queue *q, unsigned int *num_buffers, u
memset(&open_param, 0, sizeof(struct EncOpenParam));
set_default_enc_openparam(&open_param);
open_param.bitstreamFormat = to_vpu_codstd(inst->dst_fmt.pixelformat);
inst->std = to_vpu_codstd(inst->dst_fmt.pixelformat);
if (inst->std == STD_UNKNOWN) {
dev_warn(inst->dev->dev, "Unsupported pixelformat: %.4s\n", (char*)&inst->dst_fmt.pixelformat);
return -EINVAL;
}
open_param.picWidth = inst->dst_fmt.width;
open_param.picHeight = inst->dst_fmt.height;
open_param.frameRateInfo = inst->frame_rate;
......
......@@ -25,10 +25,6 @@ uint32_t __VPU_BUSY_TIMEOUT = VPU_BUSY_CHECK_TIMEOUT;
static enum RetCode CheckDecCaps(struct vpu_instance *inst)
{
struct DecInfo* pDecInfo = &inst->handle.CodecInfo->decInfo;
struct VpuAttr* pAttr = &inst->dev->attr;
if ((pAttr->supportDecoders&(1<<pDecInfo->openParam.bitstreamFormat)) == 0)
return RETCODE_NOT_SUPPORTED_FEATURE;
if (pDecInfo->mapType != LINEAR_FRAME_MAP && pDecInfo->mapType != COMPRESSED_FRAME_MAP && pDecInfo->mapType != COMPRESSED_FRAME_MAP_DUAL_CORE_8BIT && pDecInfo->mapType != COMPRESSED_FRAME_MAP_DUAL_CORE_10BIT)
return RETCODE_NOT_SUPPORTED_FEATURE;
......@@ -150,9 +146,6 @@ static int check_dec_open_param(struct vpu_device *dev, struct DecOpenParam *par
if ((pAttr->supportBitstreamMode&(1<<param->bitstreamMode)) == 0)
return -EINVAL;
if ((pAttr->supportDecoders&(1<<param->bitstreamFormat)) == 0)
return -EINVAL;
/* check framebuffer endian */
if ((pAttr->supportEndianMask&(1<<param->frameEndian)) == 0) {
APIDPRINT("%s:%d Invalid frame endian(%d)\n", __FUNCTION__, __LINE__, (int32_t)param->frameEndian);
......@@ -217,64 +210,7 @@ int VPU_DecOpen(struct vpu_device *dev, struct vpu_instance *vpu_inst, struct De
memset(pDecInfo, 0x00, sizeof(struct DecInfo));
memcpy((void*)&pDecInfo->openParam, pop, sizeof(struct DecOpenParam));
if (pop->bitstreamFormat == STD_MPEG4) {
pCodecInst->codecMode = MP4_DEC;
pCodecInst->codecModeAux = MP4_AUX_MPEG4;
}
else if (pop->bitstreamFormat == STD_AVC) {
if (pCodecInst->productId == PRODUCT_ID_521 || pCodecInst->productId == PRODUCT_ID_511 || pCodecInst->productId == PRODUCT_ID_517) {
pCodecInst->codecMode = W_AVC_DEC;
}
else {
pCodecInst->codecMode = AVC_DEC;
pCodecInst->codecModeAux = pop->avcExtension;
}
}
else if (pop->bitstreamFormat == STD_VC1) {
pCodecInst->codecMode = VC1_DEC;
}
else if (pop->bitstreamFormat == STD_MPEG2) {
pCodecInst->codecMode = MP2_DEC;
}
else if (pop->bitstreamFormat == STD_H263) {
pCodecInst->codecMode = MP4_DEC;
pCodecInst->codecModeAux = MP4_AUX_MPEG4;
}
else if (pop->bitstreamFormat == STD_DIV3) {
pCodecInst->codecMode = DV3_DEC;
pCodecInst->codecModeAux = MP4_AUX_DIVX3;
}
else if (pop->bitstreamFormat == STD_RV) {
pCodecInst->codecMode = RV_DEC;
}
else if (pop->bitstreamFormat == STD_AVS) {
pCodecInst->codecMode = AVS_DEC;
}
else if (pop->bitstreamFormat == STD_THO) {
pCodecInst->codecMode = VPX_DEC;
pCodecInst->codecModeAux = VPX_AUX_THO;
}
else if (pop->bitstreamFormat == STD_VP3) {
pCodecInst->codecMode = VPX_DEC;
pCodecInst->codecModeAux = VPX_AUX_THO;
}
else if (pop->bitstreamFormat == STD_VP8) {
pCodecInst->codecMode = VPX_DEC;
pCodecInst->codecModeAux = VPX_AUX_VP8;
}
else if (pop->bitstreamFormat == STD_HEVC) {
pCodecInst->codecMode = W_HEVC_DEC;
}
else if (pop->bitstreamFormat == STD_VP9) {
pCodecInst->codecMode = W_VP9_DEC;
}
else if (pop->bitstreamFormat == STD_AVS2) {
pCodecInst->codecMode = W_AVS2_DEC;
}
else if (pop->bitstreamFormat == STD_AV1) {
pCodecInst->codecMode = W_AV1_DEC;
}
else {
if (vpu_inst->std == STD_UNKNOWN) {
ret = -EINVAL;
goto err_out;
}
......@@ -488,27 +424,27 @@ enum RetCode VPU_DecCompleteSeqInit(struct vpu_instance *inst, struct DecInitial
}
static enum RetCode VpuAllocateFramebuffer(
struct CodecInst* inst, struct FrameBuffer* fbArr, enum TiledMapType mapType, int32_t num,
struct vpu_instance* vpu_inst, struct FrameBuffer* fbArr, enum TiledMapType mapType, int32_t num,
int32_t stride, int32_t height, enum FrameBufferFormat format,
BOOL cbcrInterleave, BOOL nv21, int32_t endian)
{
int32_t i;
struct DecInfo* pDecInfo = &inst->CodecInfo->decInfo;
struct EncInfo* pEncInfo = &inst->CodecInfo->encInfo;
struct DecInfo* pDecInfo = &vpu_inst->handle.CodecInfo->decInfo;
struct EncInfo* pEncInfo = &vpu_inst->handle.CodecInfo->encInfo;
// Variables for TILED_FRAME/FILED_MB_RASTER
uint32_t sizeLuma;
uint32_t sizeChroma;
enum RetCode ret = RETCODE_SUCCESS;
if (inst->codecMode == W_VP9_DEC) {
if (vpu_inst->std == W_VP9_DEC) {
uint32_t framebufHeight;
framebufHeight = VPU_ALIGN64(height);
sizeLuma = CalcLumaSize(inst, inst->productId, stride, framebufHeight, format, cbcrInterleave, mapType);
sizeChroma = CalcChromaSize(inst, inst->productId, stride, framebufHeight, format, cbcrInterleave, mapType);
sizeLuma = CalcLumaSize(vpu_inst, stride, framebufHeight, format, cbcrInterleave, mapType);
sizeChroma = CalcChromaSize(vpu_inst, stride, framebufHeight, format, cbcrInterleave, mapType);
}
else {
sizeLuma = CalcLumaSize(inst, inst->productId, stride, height, format, cbcrInterleave, mapType);
sizeChroma = CalcChromaSize(inst, inst->productId, stride, height, format, cbcrInterleave, mapType);
sizeLuma = CalcLumaSize(vpu_inst, stride, height, format, cbcrInterleave, mapType);
sizeChroma = CalcChromaSize(vpu_inst, stride, height, format, cbcrInterleave, mapType);
}
// Framebuffer common informations
......@@ -529,7 +465,7 @@ static enum RetCode VpuAllocateFramebuffer(
fbArr[i].bufCbSize = (mapType < COMPRESSED_FRAME_MAP && cbcrInterleave == TRUE) ? sizeChroma * 2 : sizeChroma;
fbArr[i].bufCrSize = (cbcrInterleave == TRUE) ? 0 : sizeChroma;
fbArr[i].sourceLBurstEn = FALSE;
if(inst->codecMode == W_HEVC_ENC || inst->codecMode == W_AVC_ENC) {
if(vpu_inst->std == W_HEVC_ENC || vpu_inst->std == W_AVC_ENC) {
fbArr[i].endian = (mapType >= COMPRESSED_FRAME_MAP ? VDI_128BIT_LITTLE_ENDIAN : endian);
fbArr[i].lumaBitDepth = pEncInfo->openParam.EncStdParam.waveParam.internalBitDepth;
fbArr[i].chromaBitDepth = pEncInfo->openParam.EncStdParam.waveParam.internalBitDepth;
......@@ -567,7 +503,7 @@ static enum RetCode VpuRegisterFramebuffer(struct vpu_instance *vpu_inst)
/************************************************************************/
/* for WAVE5 series (511/517/537/521...) */
/************************************************************************/
if (IS_WAVE_DECODER_HANDLE(instance)) {
if (IS_WAVE_DECODER_HANDLE(vpu_inst)) {
if (pDecInfo->mapType < COMPRESSED_FRAME_MAP)
return RETCODE_NOT_SUPPORTED_FEATURE;
......@@ -635,9 +571,7 @@ enum RetCode VPU_DecRegisterFrameBufferEx(struct vpu_instance *inst, int numFbsF
pDecInfo->numFbsForWTL = numFbsForWTL;
pDecInfo->numFrameBuffers = numFbsForDecoding + numFbsForWTL;
pDecInfo->stride = stride;
if (pCodecInst->codecMode == VPX_DEC)
pDecInfo->frameBufferHeight = VPU_ALIGN64(height);
else if (pCodecInst->codecMode == W_VP9_DEC)
if (inst->std == W_VP9_DEC)
pDecInfo->frameBufferHeight = VPU_ALIGN64(height);
else
pDecInfo->frameBufferHeight = height;
......@@ -680,7 +614,7 @@ enum RetCode VPU_DecRegisterFrameBufferEx(struct vpu_instance *inst, int numFbsF
vb = &pDecInfo->vbFrame;
fb = &pDecInfo->frameBufPool[0];
ret = VpuAllocateFramebuffer(
&inst->handle, fb, (enum TiledMapType)mapType, numFbsForDecoding, stride, height, format,
inst, fb, (enum TiledMapType)mapType, numFbsForDecoding, stride, height, format,
pDecInfo->openParam.cbcrInterleave,
pDecInfo->openParam.nv21,
pDecInfo->openParam.frameEndian);
......@@ -700,7 +634,7 @@ enum RetCode VPU_DecRegisterFrameBufferEx(struct vpu_instance *inst, int numFbsF
fb = &pDecInfo->frameBufPool[numFbsForDecoding];
ret = VpuAllocateFramebuffer(
&inst->handle, fb, map, numFbsForWTL, stride, height,
inst, fb, map, numFbsForWTL, stride, height,
pDecInfo->wtlFormat,
pDecInfo->openParam.cbcrInterleave,
pDecInfo->openParam.nv21,
......@@ -744,12 +678,7 @@ enum RetCode VPU_DecGetBitstreamBuffer(struct vpu_instance *inst, PhysicalAddres
}
else {
if (GetPendingInst(inst->dev) == inst) {
if (pCodecInst->codecMode == AVC_DEC && pCodecInst->codecModeAux == AVC_AUX_MVC) {
rdPtr = pDecInfo->streamRdPtr;
}
else {
rdPtr = VpuReadReg(inst->dev, pDecInfo->streamRdPtrRegAddr);
}
rdPtr = VpuReadReg(inst->dev, pDecInfo->streamRdPtrRegAddr);
}
else {
rdPtr = pDecInfo->streamRdPtr;
......@@ -975,13 +904,13 @@ enum RetCode VPU_DecGetOutputInfo(struct vpu_instance *inst, struct DecOutputInf
rectInfo.top = 0;
rectInfo.bottom = info->decPicHeight;
if (pCodecInst->codecMode == W_HEVC_DEC || pCodecInst->codecMode == W_AVC_DEC || pCodecInst->codecMode == AVC_DEC || pCodecInst->codecMode == AVS_DEC)
if (inst->std == W_HEVC_DEC || inst->std == W_AVC_DEC)
rectInfo = pDecInfo->initialInfo.picCropRect;
if (pCodecInst->codecMode == W_HEVC_DEC)
if (inst->std == W_HEVC_DEC)
pDecInfo->decOutInfo[decodedIndex].decodedPOC = info->decodedPOC;
if (pCodecInst->codecMode == W_AVS2_DEC)
if (inst->std == W_AVS2_DEC)
pDecInfo->decOutInfo[decodedIndex].avs2Info.decodedPOI = info->avs2Info.decodedPOI;
info->rcDecoded.left = pDecInfo->decOutInfo[decodedIndex].rcDecoded.left = rectInfo.left;
......@@ -1000,25 +929,6 @@ enum RetCode VPU_DecGetOutputInfo(struct vpu_instance *inst, struct DecOutputInf
displayIndex = info->indexFrameDisplay;
if (info->indexFrameDisplay >= 0 && info->indexFrameDisplay < MAX_GDI_IDX)
{
if (pCodecInst->codecMode == VC1_DEC) // vc1 rotates decoded frame buffer region. the other std rotated whole frame buffer region.
{
if (pDecInfo->rotationEnable && (pDecInfo->rotationAngle==90 || pDecInfo->rotationAngle==270))
{
info->rcDisplay.left = pDecInfo->decOutInfo[displayIndex].rcDecoded.top;
info->rcDisplay.right = pDecInfo->decOutInfo[displayIndex].rcDecoded.bottom;
info->rcDisplay.top = pDecInfo->decOutInfo[displayIndex].rcDecoded.left;
info->rcDisplay.bottom = pDecInfo->decOutInfo[displayIndex].rcDecoded.right;
}
else
{
info->rcDisplay.left = pDecInfo->decOutInfo[displayIndex].rcDecoded.left;
info->rcDisplay.right = pDecInfo->decOutInfo[displayIndex].rcDecoded.right;
info->rcDisplay.top = pDecInfo->decOutInfo[displayIndex].rcDecoded.top;
info->rcDisplay.bottom = pDecInfo->decOutInfo[displayIndex].rcDecoded.bottom;
}
}
else
{
if (pDecInfo->rotationEnable)
{
switch(pDecInfo->rotationAngle)
......@@ -1074,7 +984,7 @@ enum RetCode VPU_DecGetOutputInfo(struct vpu_instance *inst, struct DecOutputInf
}
}
switch (pCodecInst->codecMode) {
switch (inst->std) {
case W_HEVC_DEC:
info->displayPOC = pDecInfo->decOutInfo[displayIndex].decodedPOC;
break;
......@@ -1089,7 +999,6 @@ enum RetCode VPU_DecGetOutputInfo(struct vpu_instance *inst, struct DecOutputInf
default:
break;
}
}
if (info->indexFrameDisplay == info->indexFrameDecoded)
{
......@@ -1125,18 +1034,9 @@ enum RetCode VPU_DecGetOutputInfo(struct vpu_instance *inst, struct DecOutputInf
}
}
if ( (pCodecInst->codecMode == VC1_DEC ) && info->indexFrameDisplay != -3) {
if (pDecInfo->vc1BframeDisplayValid == 0) {
if (info->picType == 2)
info->indexFrameDisplay = -3;
else
pDecInfo->vc1BframeDisplayValid = 1;
}
}
pDecInfo->streamRdPtr = Wave5VpuDecGetRdPtr(inst);
pDecInfo->frameDisplayFlag = VpuReadReg(inst->dev, pDecInfo->frameDisplayFlagRegAddr);
if (pCodecInst->codecMode == W_VP9_DEC) {
if (inst->std == W_VP9_DEC) {
pDecInfo->frameDisplayFlag &= 0xFFFF;
}
pDecInfo->frameEndPos = pDecInfo->streamRdPtr;
......@@ -1271,7 +1171,7 @@ enum RetCode VPU_EncOpen(struct vpu_device *dev, struct vpu_instance *vpu_inst,
struct EncInfo* pEncInfo;
int ret;
if ((ret=Wave5VpuEncCheckOpenParam(dev, pop)) != RETCODE_SUCCESS)
if ((ret=Wave5VpuEncCheckOpenParam(vpu_inst, pop)) != RETCODE_SUCCESS)
return ret;
if (EnterLock(0) != RETCODE_SUCCESS) {
......@@ -1316,11 +1216,6 @@ enum RetCode VPU_EncClose(struct vpu_instance *inst)
struct EncInfo* pEncInfo;
enum RetCode ret;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS) {
return ret;
}
pCodecInst = &inst->handle;
pEncInfo = &pCodecInst->CodecInfo->encInfo;
......@@ -1354,7 +1249,7 @@ enum RetCode VPU_EncClose(struct vpu_instance *inst)
vdi_free_dma_memory(0, &pEncInfo->vbFrame, ENC_ETC, 0);
}
if (pCodecInst->codecMode == W_HEVC_ENC || pCodecInst->codecMode == W_AVC_ENC) {
if (inst->std == W_HEVC_ENC || inst->std == W_AVC_ENC) {
if (pEncInfo->vbSubSamBuf.size)
vdi_free_dma_memory(0, &pEncInfo->vbSubSamBuf, ENC_SUBSAMBUF, 0);
......@@ -1390,12 +1285,12 @@ enum RetCode VPU_EncClose(struct vpu_instance *inst)
return ret;
}
static int32_t CalculateFrameBufSize(struct CodecInst* inst, int32_t productId, int32_t stride, int32_t height, enum TiledMapType mapType, enum FrameBufferFormat format, BOOL interleave)
static int32_t CalculateFrameBufSize(struct vpu_instance* inst, int32_t stride, int32_t height, enum TiledMapType mapType, enum FrameBufferFormat format, BOOL interleave)
{
int32_t size_dpb_lum, size_dpb_chr, size_dpb_all;
size_dpb_lum = CalcLumaSize(inst, productId, stride, height, format, interleave, mapType);
size_dpb_chr = CalcChromaSize(inst, productId, stride, height, format, interleave, mapType);
size_dpb_lum = CalcLumaSize(inst, stride, height, format, interleave, mapType);
size_dpb_chr = CalcChromaSize(inst, stride, height, format, interleave, mapType);
if (mapType < COMPRESSED_FRAME_MAP)
size_dpb_all = size_dpb_lum + size_dpb_chr*2;
......@@ -1414,11 +1309,6 @@ enum RetCode VPU_EncRegisterFrameBuffer(struct vpu_instance *inst, int num, int
struct EncOpenParam* openParam;
struct FrameBuffer* fb;
ret = CheckEncInstanceValidity(&inst->handle);
// FIXME temp
if (ret != RETCODE_SUCCESS)
return ret;
pCodecInst = &inst->handle;
pEncInfo = &pCodecInst->CodecInfo->encInfo;
openParam = &pEncInfo->openParam;
......@@ -1464,7 +1354,7 @@ enum RetCode VPU_EncRegisterFrameBuffer(struct vpu_instance *inst, int num, int
if (inst->frame_buf[0].bufCb == (PhysicalAddress)-1 && inst->frame_buf[0].bufCr == (PhysicalAddress)-1) {
uint32_t size;
pEncInfo->frameAllocExt = TRUE;
size = CalculateFrameBufSize(pCodecInst, pCodecInst->productId, stride, height,
size = CalculateFrameBufSize(inst, stride, height,
(enum TiledMapType)mapType, (enum FrameBufferFormat)openParam->srcFormat,
(BOOL)openParam->cbcrInterleave);
if (mapType == LINEAR_FRAME_MAP) {
......@@ -1474,7 +1364,7 @@ enum RetCode VPU_EncRegisterFrameBuffer(struct vpu_instance *inst, int num, int
}
}
ret = VpuAllocateFramebuffer(
pCodecInst, fb, (enum TiledMapType)mapType, num, stride, height, (enum FrameBufferFormat)openParam->srcFormat,
inst, fb, (enum TiledMapType)mapType, num, stride, height, (enum FrameBufferFormat)openParam->srcFormat,
openParam->cbcrInterleave, FALSE, openParam->frameEndian);
if (ret != RETCODE_SUCCESS) {
SetPendingInst(inst);
......@@ -1503,10 +1393,6 @@ enum RetCode VPU_EncStartOneFrame(
enum RetCode ret;
struct VpuAttr* pAttr = NULL;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS)
return ret;
pCodecInst = &inst->handle;
pEncInfo = &pCodecInst->CodecInfo->encInfo;
......@@ -1514,7 +1400,7 @@ enum RetCode VPU_EncStartOneFrame(
return RETCODE_WRONG_CALL_SEQUENCE;
}
ret = CheckEncParam(&inst->handle, param);
ret = CheckEncParam(inst, param);
if (ret != RETCODE_SUCCESS) {
return ret;
}
......@@ -1555,11 +1441,6 @@ enum RetCode VPU_EncGetOutputInfo(
enum RetCode ret;
struct VpuAttr* pAttr;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS) {
return ret;
}
if (info == 0) {
return RETCODE_INVALID_PARAM;
}
......@@ -1603,12 +1484,6 @@ enum RetCode VPU_EncGiveCommand(
{
struct CodecInst* pCodecInst;
struct EncInfo* pEncInfo;
enum RetCode ret;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS) {
return ret;
}
pCodecInst = &inst->handle;
pEncInfo = &pCodecInst->CodecInfo->encInfo;
......@@ -1675,10 +1550,6 @@ enum RetCode VPU_EncIssueSeqInit(struct vpu_instance *inst)
enum RetCode ret;
struct VpuAttr* pAttr;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS)
return ret;
pCodecInst = &inst->handle;
if (EnterLock(0) != RETCODE_SUCCESS) {
......@@ -1712,11 +1583,6 @@ enum RetCode VPU_EncCompleteSeqInit(struct vpu_instance *inst, struct EncInitial
enum RetCode ret;
struct VpuAttr* pAttr;
ret = CheckEncInstanceValidity(&inst->handle);
if (ret != RETCODE_SUCCESS) {
return ret;
}
if (info == 0) {
return RETCODE_INVALID_PARAM;
}
......
......@@ -23,7 +23,7 @@
#include "vputypes.h"
#include "../vdi/vdi.h"
#define IS_WAVE_DECODER_HANDLE(_inst) (_inst->codecMode == W_HEVC_DEC || _inst->codecMode == W_AVC_DEC || _inst->codecMode == W_VP9_DEC || _inst->codecMode == W_AVS2_DEC || _inst->codecMode == W_AV1_DEC)
#define IS_WAVE_DECODER_HANDLE(_inst) (_inst->handle.isDecoder)
/**
......@@ -120,6 +120,19 @@ enum CodStd {
STD_MAX
};
// new COD_STD since WAVE series
enum wave_std {
W_HEVC_DEC = 0x00,
W_HEVC_ENC = 0x01,
W_AVC_DEC = 0x02,
W_AVC_ENC = 0x03,
W_VP9_DEC = 0x16,
W_AVS2_DEC = 0x18,
W_AV1_DEC = 0x1A,
STD_UNKNOWN = 0xFF
};
/**
* @brief
@verbatim
......@@ -1484,7 +1497,6 @@ struct MP2PicDispExtInfo {
This is used when HOST application calls VPU_Decopen().
*/
struct DecOpenParam {
enum CodStd bitstreamFormat; /**< A standard type of bitstream in decoder operation. It is one of codec standards defined in enum CodStd. */
PhysicalAddress bitstreamBuffer; /**< The start address of bitstream buffer from which the decoder can get the next bitstream. This address must be aligned to AXI bus width. */
int bitstreamBufferSize;/**< The size of the buffer pointed by bitstreamBuffer in byte. This value must be a multiple of 1024. */
/**
......@@ -3022,7 +3034,6 @@ struct HevcSEIDataEnc {
struct EncOpenParam {
PhysicalAddress bitstreamBuffer; /**< The start address of bitstream buffer into which encoder puts bitstream. This address must be aligned to AXI bus width. */
uint32_t bitstreamBufferSize; /**< The size of the buffer in bytes pointed by bitstreamBuffer. This value must be a multiple of 1024. */
enum CodStd bitstreamFormat; /**< The standard type of bitstream in encoder operation. It is one of STD_MPEG4, STD_H263, STD_AVC and STD_HEVC. */
/**
@verbatim
@* 0 : line-buffer mode
......@@ -3912,8 +3923,6 @@ struct EncInfo {
struct CodecInst {
int32_t codecMode;
int32_t codecModeAux;
int32_t productId;
int32_t loggingEnable;
uint32_t isDecoder;
......@@ -3972,6 +3981,7 @@ struct vpu_instance {
enum vpu_instance_type type;
const struct vpu_instance_ops *ops;
enum wave_std std;
int id;
struct CodecInst handle;
struct FrameBuffer frame_buf[MAX_REG_FRAME];
......
......@@ -90,8 +90,6 @@ struct CodecInst *GetCodecInstance(struct vpu_instance *vpu_inst)
if (!pCodecInst->CodecInfo)
return NULL;
pCodecInst->codecMode = -1;
pCodecInst->codecModeAux = -1;
pCodecInst->loggingEnable = 0;
pCodecInst->isDecoder = TRUE;
pCodecInst->productId = vpu_inst->dev->product;
......@@ -221,31 +219,11 @@ enum RetCode SetEncCropInfo(int32_t codecMode, struct EncWaveParam* param, int r
return RETCODE_SUCCESS;
}
enum RetCode CheckEncInstanceValidity(struct CodecInst* handle)
enum RetCode CheckEncParam(struct vpu_instance* inst, struct EncParam * param)
{
struct CodecInst * pCodecInst;
if (handle == NULL)
return RETCODE_INVALID_HANDLE;
pCodecInst = handle;
if (pCodecInst->codecMode != MP4_ENC &&
pCodecInst->codecMode != W_HEVC_ENC &&
pCodecInst->codecMode != W_AVC_ENC &&
pCodecInst->codecMode != AVC_ENC) {
return RETCODE_INVALID_HANDLE;
}
return RETCODE_SUCCESS;
}
enum RetCode CheckEncParam(struct CodecInst* handle, struct EncParam * param)
{
struct CodecInst *pCodecInst;
struct EncInfo *pEncInfo;
pCodecInst = handle;
pEncInfo = &pCodecInst->CodecInfo->encInfo;
pEncInfo = &inst->handle.CodecInfo->encInfo;
if (param == 0) {
return RETCODE_INVALID_PARAM;
......@@ -263,12 +241,7 @@ enum RetCode CheckEncParam(struct CodecInst* handle, struct EncParam * param)
}
}
if (pEncInfo->openParam.bitRate == 0) { // no rate control
if (pCodecInst->codecMode == MP4_ENC) {
if (param->quantParam < 1 || param->quantParam > 31) {
return RETCODE_INVALID_PARAM;
}
}
else if (pCodecInst->codecMode == W_HEVC_ENC) {
if (inst->std == W_HEVC_ENC) {
if (param->forcePicQpEnable == 1) {
if (param->forcePicQpI < 0 || param->forcePicQpI > 63)
return RETCODE_INVALID_PARAM;
......@@ -421,8 +394,7 @@ enum RetCode UpdateFrameBufferAddr(
}
int32_t CalcLumaSize(
struct CodecInst* inst,
int32_t productId,
struct vpu_instance* vpu_inst,
int32_t stride,
int32_t height,
enum FrameBufferFormat format,
......@@ -466,10 +438,10 @@ int32_t CalcLumaSize(
// else if (hevc_encoder) bgs_width = 512.
// else if (hevc_decoder} MAX(comp_size for bgs_width=512, comp_size for bgs_width=1024)
//=====================================================================
if (inst->codecMode == W_AVC_DEC || inst->codecMode == W_AVC_ENC) {
if (vpu_inst->std == W_AVC_DEC || vpu_inst->std == W_AVC_ENC) {
bgs_width = 1024;
}