September 10-Xvid and sultry Chengdu

Source: Internet
Author: User

The last computer architecture of this week was completed yesterday. I moved back to my house because I couldn't stand the sultry nature of my school dormitory. Near the third ring in the night, the sky is overcast, but it is a good sign of rain. When the sky was raining, a water drop hit me through the window. Long-time rain, In the sultry nature of Chengdu in September, I felt a little excited.

In fact, Chengdu in September is also a rainy season, but it may not be worth mentioning compared with Nanjing. Just like me in Chengdu and her in Nanjing.

I woke up this morning and grandma was back. So I began to explore the Xvid application.

I am not quite clear about the differences between Xvid and h264 in terms of codec. But today, I prefer to look at how Xvid code is implemented. I launched a Linux xvid1.2.2 version on the Internet, which contains an encraw example. Today, most of the time is spent on understanding its code structure.

Xvid is complicated for people who do not know how to encode audio and video data. However, I think this is also an opportunity because YUV-format camera data collection and transmission has been realized before, so I got into the habit: no matter how complicated the code content is, I only care about several aspects, 1 is the data type and size before encode, 2 is the data type and size after encoded, 3 is the parameter. After a rough look, there are many parameters that Xvid requires the init operation. Some can be guessed by name, and some can be ignored if I am puzzled. Maybe I was just trying to get started, so I 'd rather spend more time studying how to port the code than focusing on program optimization.

The Xvid encoding process obtained today is roughly as follows:

/*------------------------------------------------------------------------
* Xvid core Initialization
*----------------------------------------------------------------------*/
Xvid_gbl_init_t xvid_gbl_init;
Memset (& xvid_gbl_init, 0, sizeof (xvid_gbl_init ));
Xvid_gbl_init.version = xvid_version;
Xvid_gbl_init.cpu_flags = xvid_cpu_force;
/* Initialize Xvid core -- shocould be done once per _ process __*/
Xvid_global (null, xvid_gbl_init, & xvid_gbl_init, null );

/*------------------------------------------------------------------------
* Xvid encoder Initialization
*----------------------------------------------------------------------*/
Memset (& xvid_enc_create, 0, sizeof (xvid_enc_create ));
Xvid_enc_create.version = xvid_version;
/* Width and height of input frames */
Xvid_enc_create.width = 320; (the video output size in the implemented QT Program)

Xvid_enc_create.height = 240; (the video output size in the implemented QT Program)

Xvid_enc_create.profile = xvid_profile_as_l4; // What does it mean?

..........

..........

Then encode. Pay special attention to the memory size of malloc

 

Unlike the previous conversion from YUV to RGB, Xvid supports conversion from many formats to MPEG4 or AVI. Therefore, you can encapsulate a simple video encoding class for future calls.

PS: Today, I saw 9th sets in a fraction of seconds. It's a little depressing...

 

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.