mpp-nyanmisaka/mpp/base/mpp_sys_cfg_st.cpp
Hongjin Li 70b572a2c0 fix[mpp_sys_cfg]: Fix abnormal stride calculation.
Platform: General

Error case:
If the specification specifies a stride, it should be
configured according to the specification's stride rather
than calculated based on width and height, especially
in scenarios involving H.264 field-based sources.
For the case of FBC, hor_stride needs to be processed
based on pixels and is unrelated to bit depth.

Reported-by: Johnson Ding <johnson.ding@rock-chips.com>

Source: rk_32.h264

Signed-off-by: Hongjin Li <vic.hong@rock-chips.com>
Change-Id: I02058432f2baeeea4c5a87c6845b24de8a78b276
2025-02-13 00:20:12 +00:00

162 lines
5.1 KiB
C++

/* SPDX-License-Identifier: Apache-2.0 OR MIT */
/*
* Copyright (c) 2024 Rockchip Electronics Co., Ltd.
*/
#define MODULE_TAG "mpp_sys_cfg_st"
#include "mpp_log.h"
#include "mpp_mem.h"
#include "mpp_time.h"
#include "mpp_common.h"
#include "rk_mpp_cfg.h"
#include "mpp_sys_cfg.h"
#include "mpp_sys_cfg_st.h"
MPP_RET mpp_sys_cfg_st_get_h_stride(MppSysCfgStHStrd *h_stride_cfg)
{
MPP_RET ret = MPP_OK;
MppSysCfg cfg;
ret = mpp_sys_cfg_get(&cfg);
if (ret) {
mpp_err("mpp_sys_cfg_get failed\n");
goto DONE;
}
/* set correct parameter */
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", h_stride_cfg->type);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", h_stride_cfg->fmt_fbc);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", h_stride_cfg->width);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", h_stride_cfg->h_stride_by_byte);
/* get result */
mpp_sys_cfg_ioctl(cfg);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_pixel",
&h_stride_cfg->h_stride_by_pixel);
ret = mpp_sys_cfg_put(cfg);
if (ret) {
mpp_err("mpp_sys_cfg_put failed\n");
goto DONE;
}
DONE:
mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
return ret;
}
MPP_RET mpp_sys_cfg_st_get_byte_stride(MppSysCfgStHByteStrd *byte_stride_cfg)
{
MPP_RET ret = MPP_OK;
MppSysCfg cfg;
ret = mpp_sys_cfg_get(&cfg);
if (ret) {
mpp_err("mpp_sys_cfg_get failed\n");
goto DONE;
}
/* set correct parameter */
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", byte_stride_cfg->type);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_codec", byte_stride_cfg->fmt_codec);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", byte_stride_cfg->fmt_fbc);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", byte_stride_cfg->width);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", byte_stride_cfg->h_stride_by_byte);
/* get result */
mpp_sys_cfg_ioctl(cfg);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_byte",
&byte_stride_cfg->h_stride_by_byte);
ret = mpp_sys_cfg_put(cfg);
if (ret) {
mpp_err("mpp_sys_cfg_put failed\n");
goto DONE;
}
DONE:
mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
return ret;
}
MPP_RET mpp_sys_cfg_st_get_v_stride(MppSysCfgStVStrd *v_stride_cfg)
{
MPP_RET ret = MPP_OK;
MppSysCfg cfg;
ret = mpp_sys_cfg_get(&cfg);
if (ret) {
mpp_err("mpp_sys_cfg_get failed\n");
goto DONE;
}
/* set correct parameter */
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", v_stride_cfg->type);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", v_stride_cfg->fmt_fbc);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:height", v_stride_cfg->height);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:v_stride", v_stride_cfg->v_stride);
/* get result */
mpp_sys_cfg_ioctl(cfg);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:v_stride", &v_stride_cfg->v_stride);
ret = mpp_sys_cfg_put(cfg);
if (ret) {
mpp_err("mpp_sys_cfg_put failed\n");
goto DONE;
}
DONE:
mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
return ret;
}
MPP_RET mpp_sys_cfg_st_get_size(MppSysCfgStSize *size_cfg)
{
MPP_RET ret = MPP_OK;
MppSysCfg cfg;
ret = mpp_sys_cfg_get(&cfg);
if (ret) {
mpp_err("mpp_sys_cfg_get failed\n");
goto DONE;
}
/* set correct parameter */
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", size_cfg->type);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_codec", size_cfg->fmt_codec);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", size_cfg->fmt_fbc);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", size_cfg->width);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:height", size_cfg->height);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", size_cfg->h_stride_by_byte);
ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:v_stride", size_cfg->v_stride);
/* get result */
mpp_sys_cfg_ioctl(cfg);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_byte", &size_cfg->h_stride_by_byte);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_pixel", &size_cfg->h_stride_by_pixel);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:v_stride", &size_cfg->v_stride);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_total", &size_cfg->size_total);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_fbc_hdr", &size_cfg->size_fbc_hdr);
ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_fbc_bdy", &size_cfg->size_fbc_bdy);
ret = mpp_sys_cfg_put(cfg);
if (ret) {
mpp_err("mpp_sys_cfg_put failed\n");
goto DONE;
}
DONE:
mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
return ret;
}