CedarX

CedarX is Allwinner's multimedia co-processing technology for hardware accelerated video and image decoding, as used inside their A10 SoC's and others.

=Overview= CedarX is composed of several parts, including:
 * 1) A hardware video decoding unit
 * 2) Proprietary libraries to communicate with the hardware unit
 * 3) Glue code to use those libraries on an actual system with video playback capabilities (e.g. Android)

Note! There seems to be a distinction in the Android code between audio decoding ("CedarA") and video decoding ("CedarX").

Benefits to Allwinner's CedarX technology and libraries:

 * Efficient use of system resources when decoding multimedia, offloading audio and video decoding to CedarX co-processor so that the CPU so that it can be used for other things, (when CedarX is working as it as it should).
 * Allows small and low-powered ARM systems to playback high resolution/bitrate multimedia content, which would not be possible using software-only decoding using only the CPU.

Disadvantages Allwinner's CedarX technology and libraries:

 * Allwinner's own CedarX proprietary libraries have no clear usage license, so even if the source code for some versions is available the terms-of-use is unknown in open source software.
 * The Android glue code is implemented as a "media player" (parallel to Android's Stagefright multimedia framework) instead of as standard OpenMAX (OMX) components and API's.
 * This "media player" has limitations when it comes to playing back content pointed to by Android URIs and some web-based content.
 * There is no glue code for any other multimedia frameworks on GNU/Linux systems. The use of OpenMAX (OMX) instead would have rendered this a non-issue, with existing projects like GstOpenMAX (GStreamer OpenMAX).

= Integration =
 * XBMC
 * VLC
 * OpenMAX
 * Stagefright
 * GStreamer
 * FFmpeg

=CedarX official source code libraries and third-party forks=
 * https://github.com/allwinner-dev-team/android_external_cedarx Allwinner Dev Team Android external CedarX fork
 * https://github.com/linux-sunxi/cedarx-libs linux-sunxi team fork of the official Allwinner CedarX libcedar source code libraries
 * https://github.com/huceke/libcedar libcedar decoder library for libvecore by Edgar Hucek (a.k.a. Gimli) fork for XBMC
 * https://github.com/rellla/cedarx-libs libcedar decoder library for libvecore by empatzero fork for XBMC
 * https://github.com/willswang/libcedarx Wills Wang libcedarx library for libvecore fork for VLC
 * https://github.com/mortaromarcello/android_external_cedarx Android external CedarX fork by mortaromarcello

= Reverse Engineering = On June 15 2012 Iain Bullard started reverse engineering the proprietary libraries.


 * open_cdxalloc as an free reimplementation of Allwinner's libcederxalloc.a.
 * CedarXWrapper as a LD_PRELOADed wrapper to help understanding the proprietary libraries.
 * CedarXPlayerTest as a basic player to use when testing.

Object file observations
The linux libcedarv.a (md5sum b846fdd7135fc35743e7b497a8a5cdd5) static lib contains the following object files:

avs.o         h264.o           mp4_dec_divx311.o    mp4_talbe.o    rv_core.o      vc1decbitpltab.o  vc1gentab.o    vp8Dec.o awprintf.o     h264_register.o  mp4_decfrm_normal.o  mp4_vld_311.o  rv_hal.o       vc1dec_drv.o      vc1hrd.o       vp8Hal.o decfile.o      jpeg_dec_lib.o   mp4_dec_h263.o       mp4_vld.o      rv_huffTab.o   vc1decent.o       vc1.o          vp8.o decoder.o      jpeg_hal.o       mp4_dec_vp6.o        mpeg2Dec.o     rv.o           vc1dec.o          vc1register.o  vp8Quantizer.o fbm.o          libve_adapter.o  mp4_hal.o            mpeg2Hal.o     vbv.o          vc1decpic.o       vc1tools.o get_bits.o     libve.o          mp4_header.o         mpeg2.o        vc1debug.o     vc1decpictab.o    vdecoder.o h264dec_drv.o  mjpeg.o          mp4_register.o       mpeg4.o        vc1decbit.o    vc1decseq.o       vp8Coef.o h264_hal.o     mp4_deccommon.o  mp4_tables_311.o     os_adapter.o   vc1decbitpl.o  vc1decslice.o     vp8DecFrm.o

By looking at the object names and some dissassembly. It can be seen that the CedarX should be able to handle decoding of the following codec bitstreams:

RealVideo 8 and 9. (Fourcc RV30 and RV40). rv.o AVS (though it looks incomplete) avs.o MJPEG mjpeg.o VC1 (should be able to handle WMV3 bitstreams also) vc1.o VP8 vp8.o MPEG2 mpeg2.o MPEG4-AVS mpeg4.o DIVX 3.11 mpeg4.o H.263 mpeg4.o VP6 mpeg4.o WMV1 mpeg4.o (there are references to it, might not be correct) WMV2 mpeg4.o (there are references to it, might not be correct) MPEG4-AVC (h264) h264dec_drv.o

The following objects seem to implement the libve api interface:

awprintf.o (source might be available for this object) fbm.o (source might be available for this object) libve_adapter.o (source might be available for this object) libve.o (code is trivial to RE) os_adapter.o (source might be available for this object) vbv.o (source might be available for this object) vdecoder.o (source might be available for this object)

The file libcedarv_osal.a (md5sum 4b3502c947de4ae4d8c489c20e0c2ae8) contains only one object file:

cedarv_osal_linux.o (code is trivial to RE)

It seems to contain the abstract layer for for the Linux CedarX hardware kernel interface.

= Possibly irrelevant observations =
 * There seems to be a distinction in the Android code between audio decoding ("CedarA") and video decoding ("CedarX").

=References=

= See also =
 * CedarXVideoRenderingChart - Overview chart of working/ non working video files
 * OpenMAX - Open standard API for cross-platform hardware acceleration of audio, image, and video decoding
 * XBMC - XBMC Media Center
 * VLC - VideoLAN Client