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: The H265 encoder reported an error during operation.

Part Number: TDA4VEN

Hi, experts:

   The SDK version we are using is 11.0. We have encoded a total of 2 H265 video streams. During the operation, we found that the video occasionally has mosaic effects, and at the same time, the kernel wave5 will print the error message as shown in the figure. Please help confirm what causes this issue. Thank you.

img_v3_0210v_9861da0e-6769-44f1-b786-ea93819e36dg.jpg

  • Hello, 

    Is this on the Vision-Apps SDK (Linux+RTOS) or just Linux. 

    Could you share what pipeline you are using. Is it Gstreamer or a V4L2 application?

    Thanks,
    Sarabesh S.

  • Hello,

    We are using Linux + RTOS, and the SDK version is 11.0. During the coding stage, gstreamer was utilized. Below are the pipeline and the code for building the pipeline.

       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

    This is the code for building the Pipeline.

    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;
    }

  • Hello,

    Bandwidth is limited this week. I’ll take a look next week. 

    Thanks,

    Sarabesh S

  • Hi Sarabesh:

    We has run the Linux memtester + 2 ways encoder at customer board. The failure board WAVE5 report no source buffer happen probability do not increased.

    Looks like increase LPDDR4 throughput can not accelerate this issue happen.

    Below is normal work stage TDA4Entry memory free size statics. Because LPDDR4 size limitation, CMA free size keep at ~4.6MB. Not sure this small CMA size whether have relationship with H.264 encoder report error. 

    Do you has this kind of experience share with us?

    Best Regards!

    Han Tao

  • Hi Han, 

    I'm still reviewing this. Are you using the app_multi_cam demo from the vision-apps sdk?

  • Hi, Sarabesh,

      It's a program developed by ourselves, not a demo from TI.

  • Dear customer,

       Checked the source code sdk11. found a memory leakage bug in the wave5_vpu_open_enc, please apply it and try.

    /cfs-file/__key/communityserver-discussions-components-files/791/memory_5F00_leakagea_5F00_commit_5F00_519e21e32398459ba357e67b541402f7295ee1b.patch

       in the latest git, I also found src_buf removal to finish_encode for some reason. the patch is as below, please try step by step.

        /cfs-file/__key/communityserver-discussions-components-files/791/Commit_5F00_0408e9d60cd1ee9e01c580b67fc68ddb48ecad14.patch

    Thanks.

    Linjun

        

  • update from customer, the issue did not happen w/ two patches in 3.5 hours test last night, keep watching on that.

    thanks a lot!

    yong

  • Dear qinghong.

    Please let us know the progress on your side and if need more support, Or we will close this ticket in this week.

       Checked the source code sdk11. found a memory leakage bug in the wave5_vpu_open_enc, please apply it and try.

    /cfs-file/__key/communityserver-discussions-components-files/791/memory_5F00_leakagea_5F00_commit_5F00_519e21e32398459ba357e67b541402f7295ee1b.patch

       in the latest git, I also found src_buf removal to finish_encode for some reason. the patch is as below, please try step by step.

        /cfs-file/__key/communityserver-discussions-components-files/791/Commit_5F00_0408e9d60cd1ee9e01c580b67fc68ddb48ecad14.patch

    thanks a lot!

    yong

  • Dear Qinghong.

    close this ticket as pending for long time.

    please submit new ticket if need support.

    thanks a lot!

    yong