部件号: TDA4VEN
您好、专家:
我们使用的 SDK 版本为 11.0。 我们总共编码了 2 个 H265 视频流。 在操作过程中,我们发现视频偶尔有马赛克效果,同时内核 wave5 将打印如图所示的错误消息。 请帮助确认导致此问题的原因。 谢谢你。

This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
部件号: TDA4VEN
您好、专家:
我们使用的 SDK 版本为 11.0。 我们总共编码了 2 个 H265 视频流。 在操作过程中,我们发现视频偶尔有马赛克效果,同时内核 wave5 将打印如图所示的错误消息。 请帮助确认导致此问题的原因。 谢谢你。

您好:
我们使用的是 Linux + RTOS、SDK 版本为 11.0。 在编码阶段、使用了 gstreamer。 下面是用于构建流水线的流水线和代码。
gst-launch-1.0 \ appsrc name=appsrc_xxx format=time is-live=true ! \ queue name=queue_xxx leaky=0 ! \ capsfilter name=capsfilter_xxx caps="video/x-raw,format=(string)NV12,width=(int)832,height=(int)1120,framerate=(fraction)25/1,colorimetry=bt601" ! \ v4l2h265enc name=h265enc_xxx \ output-io-mode=5 \ extra-controls="video_bitrate=(int)6000000,video_gop_size=(int)25,prepend_sps_and_pps_to_idr=(int)1,video_bitrate_mode=(int)0,hevc_maximum_qp_value=(int)38,hevc_i_frame_qp_value=(int)22,hevc_level=(int)4,frame_level_rate_control_enable=(int)1" ! \ appsink name=appsink_xxx sync=false appsrc name=appsrc_xxx format=time is-live=true ! \ queue name=queue_xxx leaky=0 ! \ capsfilter name=capsfilter_xxx caps="video/x-raw,format=(string)NV12,width=(int)1568,height=(int)1120,framerate=(fraction)25/1,colorimetry=bt601" ! \ v4l2h265enc name=h265enc_xxx \ output-io-mode=5 \ extra-controls="video_bitrate=(int)6000000,video_gop_size=(int)25,prepend_sps_and_pps_to_idr=(int)1,video_bitrate_mode=(int)0,hevc_maximum_qp_value=(int)38,hevc_i_frame_qp_value=(int)22,hevc_level=(int)4,frame_level_rate_control_enable=(int)1" ! \ appsink name=appsink_xxx sync=false
这是用于构建流水线的代码。
void CFrameDataConverter::CreateCompressPipeline(int iWidth, int iHeight, const ColorType& eDstColorType)
{
if(nullptr != m_pCompressPipeline){
CloseCompressPipline();
}
if (nullptr == m_pAllocator)
{
m_pAllocator = gst_dmabuf_allocator_new();
}
//创建一个流水线,该流水线名字是【Compress-pipeline】
std::string strName = (std::string("pipeline_") + m_strChannel);
m_pCompressPipeline = gst_pipeline_new(strName.c_str());
///appsrc用于从应用程序中提取数据,并将其发送到 GStreamer 流水线(Pipeline)中
strName = (std::string("appsrc_") + m_strChannel);
m_pCompressSource = gst_element_factory_make("appsrc", strName.c_str());
// 创建queue元素
strName = (std::string("queue_") + m_strChannel);
GstElement *queue = gst_element_factory_make("queue", strName.c_str());
//encode的过滤和转换器
strName = (std::string("capsfilter_") + m_strChannel);
GstElement *pFilter1 = gst_element_factory_make("capsfilter", strName.c_str());
//编码器
GstElement *pEncoder = nullptr;
switch (eDstColorType)
{
default:
case ColorType::COLOR_TYPE_H264:
strName = (std::string("h264enc_") + m_strChannel);
pEncoder = gst_element_factory_make("v4l2h264enc", strName.c_str());
break;
case ColorType::COLOR_TYPE_H265:
strName = (std::string("h265enc_") + m_strChannel);
pEncoder = gst_element_factory_make("v4l2h265enc", strName.c_str());
break;
}
//输出插件
strName = (std::string("appsink_") + m_strChannel);
GstElement* pSink = gst_element_factory_make("appsink", strName.c_str());
//设置数据源为内存中获取
g_object_set(m_pCompressSource, "format", GST_FORMAT_TIME, "is-live", TRUE, NULL);
// 设置queue元素的leaky属性为2(0不丢帧,1新的丢弃,2旧的丢弃)
g_object_set(queue, "leaky", 0, NULL);
//创建一个视频格式的caps结构
GstCaps *caps1 = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, m_strFromFormat.c_str(),
"width", G_TYPE_INT, iWidth,
"height", G_TYPE_INT, iHeight,
"framerate", GST_TYPE_FRACTION, 25, 1,
"colorimetry", G_TYPE_STRING, "bt601",
NULL);
g_object_set(pFilter1, "caps", caps1, NULL);
gst_caps_unref(caps1);
//设置编码器的额外控制选项
/*Enum "GstV4l2IOMode" Default: 0, "auto"
(0): auto - GST_V4L2_IO_AUTO
(1): rw - GST_V4L2_IO_RW
(2): mmap - GST_V4L2_IO_MMAP //0拷贝,mmap映射非DMA BUFFEER fd
(3): userptr - GST_V4L2_IO_USERPTR //无效
(4): dmabuf - GST_V4L2_IO_DMABUF //有拷贝
(5): dmabuf-import - GST_V4L2_IO_DMABUF_IMPORT //0拷贝,mmap映射DMA BUFFEER fd
*/
g_object_set(G_OBJECT(pEncoder), "output-io-mode", 5, NULL);
GstStructure *extra_controls =
gst_structure_new("extra-controls",
"video_bitrate", G_TYPE_INT, 6000000, //比特率6m/s
// "h264_i_frame_period",G_TYPE_INT, 12, //不设置I帧间隔,IDR帧代替I帧
"video_gop_size", G_TYPE_INT, 25, //IDR帧间隔25
"prepend_sps_and_pps_to_idr",G_TYPE_INT, 1, //在IDR帧前插入SPS和PPS
"video_bitrate_mode", G_TYPE_INT, 0, //1:固定比特率,0:可变比特率
"hevc_maximum_qp_value", G_TYPE_INT, 38, //最大QP值40
"hevc_i_frame_qp_value", G_TYPE_INT, 22, //I帧QP值20
"hevc_level", G_TYPE_INT, 4, //HEVC级别4
"frame_level_rate_control_enable", G_TYPE_INT, 1, // 开启帧级速率控制
NULL
);
// 设置 extra-controls 属性
GValue value = G_VALUE_INIT;
g_value_init(&value, GST_TYPE_STRUCTURE);
g_value_take_boxed(&value, extra_controls); // 注意:这会转移所有权,extra_controls 指针将不再有效
g_object_set_property(G_OBJECT(pEncoder), "extra-controls", &value);
g_value_unset(&value); // 释放 GValue
//如果是"I420"或"NV12",不需要转换格式,直接皆可以使用
// 先把元件加入到容器(流水线)中
gst_bin_add_many(GST_BIN(m_pCompressPipeline), m_pCompressSource, queue, pFilter1, pEncoder, pSink, NULL);
// 再确定连接方式
gst_element_link_many(m_pCompressSource, queue, pFilter1, pEncoder, pSink, NULL);
//设置回调函数
GstAppSinkCallbacks callbacks = { NULL, NULL, new_sample_Compress};
gst_app_sink_set_callbacks(GST_APP_SINK(pSink), &callbacks, this, NULL);
if(gst_element_set_state(m_pCompressPipeline, GST_STATE_READY) != GST_STATE_CHANGE_FAILURE) {
g_object_get(G_OBJECT(pEncoder), "device-fd", &m_DevFd, NULL);
if(m_DevFd > 0) {INVO_APP_LOGI("chn[%s] codec dev fd = %d\n",m_strChannel.c_str(), m_DevFd);}
}
return;
}您好 Sarabesh:
我们已在客户电路板上运行 Linux memtester + 2 路编码器。 故障板 WAVE5 报告没有源缓冲区发生概率没有增加。
看起来增加 LPDDR4 吞吐量无法加速这种问题的发生。
以下是正常工作阶段 TDA4Entry 无内存大小静态。 由于 LPDDR4 大小限制、CMA 自由大小保持在~4.6MB。 不确定此较小的 CMA 大小是否与 H.264 编码器存在关系报告错误。
你有这种经验与我们分享吗?
此致!
Han Tao

尊敬的客户:
已检查源代码 sdk11。 在 wave5_VPU_open_enc 中发现存储器泄漏错误、请应用它并尝试。
在最新的 git 中、 出于某种原因、我还发现 src_buf 删除到 finish_encode。 补丁如下、请逐步尝试。
谢谢。
Linjun
尊敬的 Qinghong:
请告知我们您的进度、如果需要更多支持、我们将在本周关闭此 TT。
[引述 userid=“485706“ url=“~/support/processors-group/processors/f/processors-forum/1638653/tda4ven-the-h265-encoder-reported-an-error-during-operation/6325713已检查源代码 sdk11。 在 wave5_VPU_open_enc 中发现存储器泄漏错误、请应用它并尝试。
在最新的 git 中、 出于某种原因、我还发现 src_buf 删除到 finish_encode。 补丁如下、请逐步尝试。
[/报价]非常感谢!
Yong