Hass Multimedia (MPP) Development (3) - video output (VO) and the video decoder (VDEC)

Preface:

    Hass multimedia processing platform (MPP) is divided into: a video input (VI), a video processing (VPSS), a video encoder (VENC), a video decoder (VDEC), video output (VO), Video Detection Analysis (VDA), the audio input (AI), an audio output (AO), the audio encoder (AENC), an audio decoder (ADEC), area management (the rEGION) modules. introduction The video decoder (VDEC) and where the video output module (VO).
    VO is closely related to their display device before using VO, the way you should be aware of the interface display device and timing information.

Description:

Test using the configuration of the development board:

  • House: Hi3521A
  • AD: NVP6134C a
  • Camera: 720P, 1080P
  • Display: HDMI bus, 1080P screen.

Hi3521A VO:

  • A high-definition equipment DHD0, video layer VHD0 supports up to 16 screens.
  • Support PIP (Picture In Picture) screen overlay, PIP screen video layer supports up to 1
  • Maximum output timing: 1920x1080 @ 60 or 1600x1200 @ 60

HDMI:

    Hass HDMI equipment development, refer to "HDMI Development Reference .pdf" official, the basic contents:
    HDMI audio can not be output separately, must rely on the video output, and a clock from the HDMI VO clock, so the interface calling sequence needs to be able to make the VO, then call HDMI interface, and then configure the audio and video output. In addition Hi35xx chip built-in HDMI does not support HDCP, CEC function.
    
    After the driver is loaded correctly, SAMPLE_COMM_VO_HdmiStart direct call function can be activated HDMI interface.
    
    Note that when debugging HDMI because HDMI pins can be multiplexed into ordinary GPIO port, so if the debugger does not make sense when you can first check the HDMI pin configuration.

Video decoding:

    Here Vl video input is not associated, directly using a simulation file to h264 H264 video stream,

(A) a data stream

  • Inside the package general video and audio with video, is now the mainstream video compression format used H264, H265, MGPEG format. We here only H264 format.
  • Hass sample which is a file with h264 h264 1080P to generate a data stream.
  • The main data flow simulation to find the start and end positions of each frame data h264, and then transmits a full data to the decoder to go inside.
  • There are two ways to find a complete data

(2) a read one byte of data

    Read one own data, find the start position of the frame, and then locate the beginning of the next frame, the middle is a complete data

  • Advantage: no data of a preset size
  •  Disadvantages: data is read by time-consuming.

(3) a large packet of data one more    

To set the maximum size of a data space according to the resolution of the video file, the time value read out from the file as a minimum space. From then package the data to find the start position and end position of the frame, when read by the end of next position to read the rest of the packet without processing.

  • Advantages: read files faster
  • Disadvantages: a need to know in advance the maximum data space

Hass sample_vdec method 2 is used, as follows:

else if ( (pstVdecThreadParam->s32StreamMode==VIDEO_MODE_FRAME) && (pstVdecThreadParam->enType == PT_H264) )
        {
            bFindStart = HI_FALSE;  
            bFindEnd   = HI_FALSE;
            /**每次偏移到下一帧开始的位置**/
            fseek(fpStrm, s32UsedBytes, SEEK_SET);
            s32ReadLen = fread(pu8Buf, 1, pstVdecThreadParam->s32MinBufSize, fpStrm);
            if (s32ReadLen == 0)
            {
                if (pstVdecThreadParam->bLoopSend)
                {
                    s32UsedBytes = 0;
                    fseek(fpStrm, 0, SEEK_SET);
                    s32ReadLen = fread(pu8Buf, 1, pstVdecThreadParam->s32MinBufSize, fpStrm);
                }
                else
                {
                    break;
                }
            }

            /**查找开始位置**/
            for (i=0; i<s32ReadLen-5; i++)
            {
                if (  pu8Buf[i] == 0 && pu8Buf[i+1] == 0 && pu8Buf[i+2] == 1 && 
                     ( (pu8Buf[i+3]&0x1F) == 0x5 || (pu8Buf[i+3]&0x1F) == 0x1 ) &&
                     ( (pu8Buf[i+4]&0x80) == 0x80)
                   )                 
                {
                    bFindStart = HI_TRUE;
                    i += 4;
                    break;
                }
            }

            /**查找结束位置,也就是下一个开始帧的标志**/
            for (; i<s32ReadLen-5; i++)
            {
                if (  pu8Buf[i  ] == 0 && pu8Buf[i+1] == 0 && pu8Buf[i+2] == 1 && 
                    ( ((pu8Buf[i+3]&0x1F) == 0x7) || ((pu8Buf[i+3]&0x1F) == 0x8) || ((pu8Buf[i+3]&0x1F) == 0x6)
                      || (((pu8Buf[i+3]&0x1F) == 0x5 || (pu8Buf[i+3]&0x1F) == 0x1) &&((pu8Buf[i+4]&0x80) == 0x80))
                    )
                   )
                {
                    bFindEnd = HI_TRUE;
                    break;
                }
            }

            if(i > 0) s32ReadLen = i;
            if (bFindStart == HI_FALSE)
            {
                printf("SAMPLE_TEST: chn %d can not find start code!s32ReadLen %d, s32UsedBytes %d. \n", 
                                            pstVdecThreadParam->s32ChnId, s32ReadLen, s32UsedBytes);
            }
            else if (bFindEnd == HI_FALSE)
            {
                s32ReadLen = i+5;
            }
            
        }    

Decoding display:

    Decoding module interface description substantially on the reference manual can be achieved.
    Here the analog 4 h264 file into a data stream input to the decoding module, the decoding module and the output module binding, the display screen of the display 4 to 4 split screen effect is as follows:

4-way real-time decoding 1080P @ 30fps does not appear Caton from the picture point of view on the issue Hass Hi3521A equipment, but the CPU occupancy rate is very high.

 

This chapter from the frequency measurement engineering "catalog preface" to get the address provided

 

The first article in this column "catalog preface," lists the complete directory column, read by directory order to help your understanding.

 

 

 

 

发布了175 篇原创文章 · 获赞 262 · 访问量 70万+

Guess you like

Origin blog.csdn.net/li_wen01/article/details/105025072