Android multimedia support library opencore Video hardware acceleration

Source: Internet
Author: User

The default support library for playing video and audio in earlier versions of android2.2 is opencore. Opencore is very powerful and supports multiple media formats and extensions. Of course, this article will briefly introduce how to accelerate the Video hardware of opencore to improve its video operation efficiency.

The function of opencore is to decode the media (audio and video) data and output it to the terminal device. Audio Data decoding and output are relatively simple. This article focuses on video data decoding and output. To enable video playback of opencore to support the Android system, Google defines two sets of video output solutions, one of which is hardware-accelerated video output by hardware manufacturers, the hardware overlay module can be called in the hardware video output to perform hardware mixing on the output video data, which results in high output efficiency. The other is Google-defined soft video output, the soft video output is defined as the androidsurfaceoutput class. In this solution, the system calls surfacefilnger to mix the output video data. This is a software alias, And the execution efficiency is relatively low. See the handlesetvideosurface method code in the playerdriver. cpp file:

    // attempt to load device-specific video MIO    if (mLibHandle != NULL) {        VideoMioFactory f = (VideoMioFactory) ::dlsym(mLibHandle, VIDEO_MIO_FACTORY_NAME);        if (f != NULL) {            mio = f();        }    }    // if no device-specific MIO was created, use the generic one    if (mio == NULL) {        LOGW("Using generic video MIO");        mio = new AndroidSurfaceOutput();    }

We can see that if mlibhandle is not empty, the Mio (Multimedia Io) Factory method in the hardware library is called to generate the Mio (Multimedia Io ). If mlibhandle is empty, use the generic video Mio (androidsurfaceoutput class ). If you carefully study the androidsurfaceoutput class, you will find that the surfaceflinger called at the underlying layer is used for video data mixing and output. Interested friends can view the code.

What about mlibhandle initialization? The playerdriver class constructor in the playerdriver. cpp file contains the following code:

    // running in emulation?    mLibHandle = NULL;    char value[PROPERTY_VALUE_MAX];    if (property_get("ro.kernel.qemu", value, 0)) {        mEmulation = true;        LOGV("Emulation mode - using software codecs");    } else {        // attempt to open h/w specific library        mLibHandle = ::dlopen(MIO_LIBRARY_NAME, RTLD_NOW);        if (mLibHandle != NULL) {            LOGV("OpenCore hardware module loaded");        } else {            LOGV("OpenCore hardware module not found");        }    }

We can see that mlibhandle is the handle of the mio_library_name library. See the following code:

// library and function name to retrieve device-specific MIOsstatic const char* MIO_LIBRARY_NAME = "";static const char* VIDEO_MIO_FACTORY_NAME = "createVideoMio";

Now we can clearly see that if there is a libopencorehw. So library in the system, opencore will call the createvideomio function in the library to create mio. From this we can know that the hardware acceleration for the video output of opencore is actually defining the libopencorehw. So library.

So what is the definition of libopencorehw. So? Because the libopencorehw. So library is related to hardware, different hardware will have different implementations, so this library can be understood as part of the hardware adaptation layer (HAL. See how to implement Hal for Android (hardware adaptation layer). Due to the ever-changing hardware, we will not provide an example here. There are many such examples. Most of them are based on ARM chips. You can customize them to their own platform libraries.

This article briefly introduces the principle of hardware acceleration for opencore video output. Figuring out the principle of video output hardware acceleration will help some friends who have transplanted android to the new hardware platform. If any, please correct me.

Related Article

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: 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.