The following steps are required for H.264 encoding and decoding[Copy link]
VPU (Video Processing Unit) is the video processing unit in i.MX27, which is mainly used for hardware encoding and decoding of H.264 BP, MPEG-4 SP, and H.263 P3 formats [6]. In order to enable users to use the hardware codec of VPU, Freescale provides a set of library files based on i.MX27 VPU under Linux. Whether encoding or decoding, the vpu_Init() function must be called first to initialize the VPU hardware. For H.264 encoding, the following steps need to be performed: (1) Call the vpu_EncOpen() function to initialize the VPU encoder; (2) Call the vpu_EncGetInitialInfo() function to obtain the encoding initialization information; (3) Call the vpu_EncRegisterFrameBuffer() function to register the encoding frame buffer; (4) Call the vpu_EncStartOneFrame() function to send each frame of image data in the encoding frame buffer to the VPU encoder for encoding, and store the encoded H.264 code stream in the specified bit stream buffer; (5) When you need to end the encoding operation, just call the vpu_EncClose() function. For H.264 decoding, the following steps need to be performed: (1) Call the vpu_DecOpen() function to initialize the VPU decoder; (2) Call the vpu_DecGetInitialInfo() function to obtain the decoding initialization information; (3) Call the vpu_DecRegisterFrameBuffer() function to register the decoding frame buffer; (4) In order to obtain the H.264 bitstream to be decoded, you can call the vpu_DecGetBitstreamBuffer() function; (5) Call the vpu_DecStartOneFrame() function to send the H.264 bitstream to the VPU decoder for decoding, and store the obtained image data in the decoding frame buffer; (6) When you need to end the decoding operation, just call the vpu_DecClose() function.