X264 DSP porting

Source: Internet
Author: User

Although I still have one year to graduate, I have finished my graduation project and it takes about three months. I am an acute student and have a strong desire to learn the knowledge I am interested in. I also want to write more information, such
I am very interested in arm, Linux, and networks. At the beginning of this semester, I chose video encoding, which is based on the H.264 Video Encoder OF THE dm64.
During the reply, the Director said that the focus should be on implementation and application. In general, optimization is done by many people in the company. I added the network part when I was doing this and I was interested in the network, so it basically became a Network Camera.
The prototype of the header.
The basic process is to capture the camera video (yuv4: 2), convert it to yuv4: 2: 0, use H
. 264 encoding, the PC telnet to the DSP, send commands, you can receive the code stream sent from the DSP, and finally decode and display. The video size is qcif, UDP, and DHCP are dynamically obtained.
The IP address is obtained and the PC-side master program is decoded. The other two threads are established to accept the bitstream and display the image respectively. The DSP uses the DSP/BIOS system framework. After the network and camera driver are initialized, the system waits for the PC to launch.
.

Programming on the DMPS is a little complicated. At the beginning, I started to look at the routines. Although it is a C language, a bunch of drivers and CSL and BSL need to be familiar with them. The camera driver fvid can be used.
Therefore, fvid_alloc () and fvid_exchange () can basically meet the requirements, and a while can constitute the subject loop. The yuv422 obtained by the camera is converted
Yuv420, I didn't use the standard conversion here. I understood it as retaining the line, so I used dat_copy () to copy the brightness and dat_copy2d () to reduce the latency.
The color is copied to the pre-encoding data area by the row division. T264_encode () is the encoding program, and its main function is from t264 to dependent Project
I added about 50 C subprograms to the main project and used linear assembly or inner concatenation functions to rewrite them. The encoding speed can reach 17 frames, and the video after the subjective feeling is not stuck. I cannot
Let's not talk about the optimization of the encoding program. Let's start with another section.

My main focus is on optimization, but I feel like a bottomless pit, I don't want to spend too much time on it, the encoding speed is always unable to make a qualitative leap. At the beginning, it was upgraded from four frames to 17 frames.
(For video sequence simulation like highway. qcif, I can even reach 21 frames.) I am so happy that the utilization and optimization of edma and cache are always separated by a layer of yarn.
I can't understand the essence of my limited ability. I always want to find a master who can give me some advice. I have never been able to do so. Ah, it's really a matter of confidence in my life, a like-minded person can only rely on fate.
Ah! The rewriting of the 50 sub-functions is also exhausting me. I really miss writing assembly functions from AM to AM, it is my greatest pleasure to see a 1.1 improvement in speed
Comfort. After writing all 50 functions, I found that the encoded image had serious distortion. It must have been because of the incorrect assembly command or the error in the root program, I have to re-check every function (
All functions use a set of data to test whether the original C function and the compiled assembler program can achieve the same result, some programs get the same results for most data, but some are "extremely
"Data cannot achieve the same result, which was realized later. The use of Assembly commands should be carefully considered for situations such as shift and overflow. Otherwise, wait for a dumb, like LDB and ldbu, rotl and
SHL, SHR, and shru are the most common mistakes. Even if the image is still distorted after this time, I checked some function exclusion functions and finally achieved good results, I am very pleased.
For more information about the network, see the ndk development documentation. If you have experience in network programming in Windows, you can easily get started. I just checked socket programming in windows and compiled several TCP UDP programs, then you can easily program the program. The difficulty is initialization and familiarity.

The decoding and display program of the PC is t264. After reading the program framework, the program is added to the network thread, and the code stream is received from the DSP and then decoded and displayed. The original program is to read the file decoding and display from the local disk. Elimination
Information-driven receiving bitstream, shared bitstream variables among threads, and some synchronization variables. Here, we further understand volatile, extern, and Win32 programming.
The premise of all this is to carefully read the H.264 coding standard documents, hundreds of pages, and understand the t264 encoding program. I have added comments to my coding program, so that I can get started quickly after review. This is actually very time-and effort-consuming, but I enjoy it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.