Guest User

Untitled

a guest
Jun 18th, 2013
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -b -u -r -N '--exclude=.git' xbmc_orig/configure.in xbmc_huceke/configure.in
  2. --- xbmc_orig/configure.in  2013-06-17 16:17:09.000000000 +0200
  3. +++ xbmc_huceke/configure.in    2013-06-17 16:16:23.000000000 +0200
  4. @@ -130,6 +130,8 @@
  5.  vtbdecoder_disabled="== VTBDecoder support manually disabled. =="
  6.  openmax_disabled="== OpenMax support manually disabled. =="
  7.  openmax_not_found="== Could not find libnvomx. OpenMax support disabled. =="
  8. +cedar_disabled="== Cedar HW support enabled. =="
  9. +cedar_enabled="== Cedar HW support enabled. =="
  10.  ssh_not_found="== Could not find libssh. =="
  11.  ssh_disabled="== SSH SFTP disabled. =="
  12.  librtmp_not_found="== Could not find libRTMP. RTMP support disabled. =="
  13. @@ -272,6 +274,12 @@
  14.    [use_tegra=$enableval],
  15.    [use_tegra=no])
  16.  
  17. +AC_ARG_ENABLE([cedar],
  18. +  [AS_HELP_STRING([--enable-cedar],
  19. +  [enable Cedar HW decoding (default is no)])],
  20. +  [use_cedar=$enableval],
  21. +  [use_cedar=no])
  22. +
  23.  AC_ARG_ENABLE([profiling],
  24.    [AS_HELP_STRING([--enable-profiling],
  25.    [enable gprof profiling (default is no)])],
  26. @@ -1815,6 +1823,18 @@
  27.    fi
  28.  fi
  29.  
  30. +# Cedar HW decoder
  31. +if test "x$use_cedar" != "xno"; then
  32. +  AC_DEFINE([HAVE_LIBCEDAR], [1], [Define to 1 if you have the 'cedar' librarie)])
  33. +  AC_MSG_NOTICE($cedar_enabled)
  34. +  use_cedar="yes"
  35. +  USE_CEDAR=1
  36. +else
  37. +  AC_MSG_NOTICE($cedar_disabled)
  38. +  use_cedar="no"
  39. +  USE_CEDAR=0
  40. +fi
  41. +
  42.  # yajl version check (yajl_version.h was added in yajl 2.0)
  43.  AC_CHECK_HEADERS([yajl/yajl_version.h], [], [
  44.  AC_DEFINE(YAJL_MAJOR, 1, [yajl version 1])
  45. @@ -1981,6 +2001,12 @@
  46.    final_message="$final_message\n  OpenMax:\tNo"
  47.  fi
  48.  
  49. +if test "$use_cedar" != "no"; then
  50. +  final_message="$final_message\n  CedarHW:\tYes"
  51. +else
  52. +  final_message="$final_message\n  CedarHW:\tNo"
  53. +fi
  54. +
  55.  if test "$use_joystick" = "yes"; then
  56.    final_message="$final_message\n  Joystick:\tYes"
  57.    SDL_DEFINES="$SDL_DEFINES -DHAS_SDL_JOYSTICK"
  58. @@ -2442,6 +2468,7 @@
  59.  AC_SUBST(USE_AIRPLAY)
  60.  AC_SUBST(USE_VDA)
  61.  AC_SUBST(USE_OPENMAX)
  62. +AC_SUBST(USE_CEDAR)
  63.  AC_SUBST(USE_PULSE)
  64.  AC_SUBST(USE_XRANDR)
  65.  AC_SUBST(USE_ALSA)
  66. diff -b -u -r -N '--exclude=.git' xbmc_orig/docs/README.allwinner xbmc_huceke/docs/README.allwinner
  67. --- xbmc_orig/docs/README.allwinner 1970-01-01 01:00:00.000000000 +0100
  68. +++ xbmc_huceke/docs/README.allwinner   2013-06-17 16:16:23.000000000 +0200
  69. @@ -0,0 +1,21 @@
  70. +Required changes to your fex board file :
  71. +
  72. + disp_init_enable = 1
  73. + disp_mode  = 0
  74. + screen0_output_type  = 3
  75. +-screen0_output_mode  = 5
  76. ++screen0_output_mode  = 4
  77. + screen1_output_type  = 2
  78. + screen1_output_mode  = 11
  79. + fb0_framebuffer_num  = 2
  80. + fb0_format = 10
  81. +-fb0_pixel_sequence = 0
  82. +-fb0_scaler_mode_enable = 1
  83. ++fb0_pixel_sequence = 1
  84. ++fb0_scaler_mode_enable = 0
  85. + fb1_framebuffer_num  = 2
  86. + fb1_format = 10
  87. +-fb1_pixel_sequence = 0
  88. +-fb1_scaler_mode_enable = 1
  89. ++fb1_pixel_sequence = 1
  90. ++fb1_scaler_mode_enable = 0
  91. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/allwinner/depends/depends.mk xbmc_huceke/tools/allwinner/depends/depends.mk
  92. --- xbmc_orig/tools/allwinner/depends/depends.mk    1970-01-01 01:00:00.000000000 +0100
  93. +++ xbmc_huceke/tools/allwinner/depends/depends.mk  2013-06-17 16:16:23.000000000 +0200
  94. @@ -0,0 +1,54 @@
  95. +export CFLAGS=-pipe -O3 -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -mabi=aapcs-linux -Wno-psabi -Wa,-mno-warn-deprecated -Wno-deprecated-declarations -ftree-vectorize
  96. +ifeq ($(USE_BUILDROOT),1)
  97. +   export HOST=arm-linux-gnueabihf
  98. +   export BUILD=i686-linux
  99. +   export PREFIX=$(XBMCPREFIX)
  100. +   export SYSROOT=$(BUILDROOT)/output/host/usr/arm-unknown-linux-gnueabi/sysroot
  101. +   export CFLAGS+=-isystem$(SYSROOT)/usr/include -isystem$(PREFIX)/include -isystem$(PREFIX)/usr/include/mysql --sysroot=$(SYSROOT)
  102. +   export CXXFLAGS=$(CFLAGS) --sysroot=$(SYSROOT)
  103. +   export CPPFLAGS=$(CFLAGS) --sysroot=$(SYSROOT)
  104. +   export LDFLAGS=-L$(XBMCPREFIX)/lib
  105. +   export LD=$(TOOLCHAIN)/bin/$(HOST)-ld
  106. +   export CC=$(TOOLCHAIN)/bin/$(HOST)-gcc
  107. +   export CXX=$(TOOLCHAIN)/bin/$(HOST)-g++
  108. +   export OBJDUMP=$(TOOLCHAIN)/bin/$(HOST)-objdump
  109. +   export RANLIB=$(TOOLCHAIN)/bin/$(HOST)-ranlib
  110. +   export STRIP=$(TOOLCHAIN)/bin/$(HOST)-strip
  111. +   export AR=$(TOOLCHAIN)/bin/$(HOST)-ar
  112. +   export CXXCPP=$(CXX) -E
  113. +   export PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig
  114. +   export PYTHON_VERSION=2.7
  115. +   export PATH:=$(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(PATH)
  116. +   export TEXTUREPACKER_NATIVE_ROOT=/usr
  117. +   export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION) -lpthread -ldl -lutil -lm
  118. +else
  119. +   export HOST=arm-bcm2708-linux-gnueabi
  120. +   export BUILD=i686-linux
  121. +   export PREFIX=${XBMCPREFIX}
  122. +   export TARGETFS
  123. +   export SYSROOT=/usr/local/bcm-gcc/arm-bcm2708-linux-gnueabi/sys-root
  124. +   export RLINK_PATH=-Wl,-rpath-link,${SYSROOT}/lib -Wl,-rpath-link,${TARGETFS}/lib -Wl,-rpath-link,${TARGETFS}/usr/lib
  125. +   export CFLAGS+=-isystem${XBMCPREFIX}/include -isystem${SDKSTAGE}/usr/include
  126. +   export CFLAGS+=-L${XBMCPREFIX}/lib -L${SYSROOT}/lib -L${TARGETFS}/lib -L${TARGETFS}/usr/lib ${RLINK_PATH}
  127. +   export CXXFLAGS=${CFLAGS}
  128. +   export CPPFLAGS=${CFLAGS}
  129. +   export LDFLAGS=${RLINK_PATH} -L${TARGETFS}/lib -L${TARGETFS}/usr/lib -L${XBMCPREFIX}/lib
  130. +   export LD=${TOOLCHAIN}/bin/${HOST}-ld
  131. +   export AR=${TOOLCHAIN}/bin/${HOST}-ar
  132. +   export CC=${TOOLCHAIN}/bin/${HOST}-gcc
  133. +   export CXX=${TOOLCHAIN}/bin/${HOST}-g++
  134. +   export CXXCPP=${CXX} -E
  135. +   export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
  136. +   export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
  137. +   export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
  138. +   #export ACLOCAL=aclocal -I ${SDKSTAGE}/usr/share/aclocal -I ${TARGETFS}/usr/share/aclocal-1.11
  139. +   export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig:${SDKSTAGE}/lib/pkgconfig:${SDKSTAGE}/usr/lib/pkgconfig
  140. +   export PKG_CONFIG_PATH=$(PREFIX)/bin/pkg-config
  141. +   export PYTHON_VERSION=2.6
  142. +   export PATH:=${PREFIX}/bin:$(PATH):${TOOLCHAIN}/bin
  143. +   export TEXTUREPACKER_NATIVE_ROOT=/usr
  144. +   export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION)
  145. +endif
  146. +export PYTHON_CPPFLAGS=-I$(SDKSTAGE)/usr/include/python$(PYTHON_VERSION)
  147. +export PYTHON_SITE_PKG=$(SDKSTAGE)/usr/lib/python$(PYTHON_VERSION)/site-packages
  148. +export PYTHON_NOVERSIONCHECK=no-check
  149. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/allwinner/depends/xbmc/Makefile xbmc_huceke/tools/allwinner/depends/xbmc/Makefile
  150. --- xbmc_orig/tools/allwinner/depends/xbmc/Makefile 1970-01-01 01:00:00.000000000 +0100
  151. +++ xbmc_huceke/tools/allwinner/depends/xbmc/Makefile   2013-06-17 16:16:23.000000000 +0200
  152. @@ -0,0 +1,27 @@
  153. +include ../../Makefile.include
  154. +include ../depends.mk
  155. +
  156. +SOURCE=../../../../
  157. +
  158. +ifeq ($(USE_BUILDROOT),1)
  159. +   export PATH:=$(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(SYSROOT)/usr/bin:$(PATH)
  160. +endif
  161. +
  162. +CONFIGURE=./configure --prefix=$(PREFIX) --build=$(BUILD) --host=$(HOST) \
  163. +   --enable-gles --disable-sdl --disable-x11 --disable-xrandr --disable-openmax \
  164. +   --disable-optical-drive --disable-dvdcss --disable-joystick --disable-debug \
  165. +   --disable-crystalhd --disable-vtbdecoder --disable-vaapi --disable-vdpau \
  166. +   --disable-pulse --disable-projectm --disable-optimizations --enable-cedar \
  167. +   --enable-neon --disable-libcec
  168. +
  169. +all: configure
  170. +
  171. +clean:
  172. +distclean:
  173. +   cd $(SOURCE);
  174. +
  175. +configure:
  176. +   cd $(SOURCE); ./bootstrap
  177. +   cd $(SOURCE); $(CONFIGURE)
  178. +   #cd $(SOURCE); make -j $(JOBS)
  179. +   #cd $(SOURCE); make install
  180. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/allwinner/setup-sdk.sh xbmc_huceke/tools/allwinner/setup-sdk.sh
  181. --- xbmc_orig/tools/allwinner/setup-sdk.sh  1970-01-01 01:00:00.000000000 +0100
  182. +++ xbmc_huceke/tools/allwinner/setup-sdk.sh    2013-06-17 16:16:23.000000000 +0200
  183. @@ -0,0 +1,41 @@
  184. +#!/bin/bash
  185. +
  186. +SCRIPT_PATH=$(cd `dirname $0` && pwd)
  187. +
  188. +USE_BUILDROOT=1
  189. +
  190. +if [ "$USE_BUILDROOT" = "1" ]; then
  191. +  BUILDROOT=/media/usbdisk/xbmc/xbmc-alwinner/buildroot-allwinner
  192. +  TARBALLS=/opt/xbmc-tarballs
  193. +  XBMCPREFIX=/media/usbdisk/xbmc/xbmc-alwinner/xbmc-bin
  194. +
  195. +  SDKSTAGE=$BUILDROOT/output/staging
  196. +  TARGETFS=$BUILDROOT/output/target
  197. +  TOOLCHAIN=$BUILDROOT/output/host/usr/
  198. +else
  199. +  TARBALLS=/opt/xbmc-tarballs
  200. +  SDKSTAGE=/opt/bcm-rootfs
  201. +  XBMCPREFIX=/opt/xbmc-bcm/xbmc-bin
  202. +  TARGETFS=/opt/bcm-rootfs
  203. +  TOOLCHAIN=/usr/local/bcm-gcc
  204. +  BUILDROOT=/opt/bcm-rootfs
  205. +fi
  206. +
  207. +sudo mkdir -p $XBMCPREFIX
  208. +sudo chmod 777 $XBMCPREFIX
  209. +mkdir -p $XBMCPREFIX/lib
  210. +mkdir -p $XBMCPREFIX/include
  211. +
  212. +echo "SDKSTAGE=$SDKSTAGE"                                              >  $SCRIPT_PATH/Makefile.include
  213. +echo "XBMCPREFIX=$XBMCPREFIX"                                          >> $SCRIPT_PATH/Makefile.include
  214. +echo "TARGETFS=$TARGETFS"                                              >> $SCRIPT_PATH/Makefile.include
  215. +echo "TOOLCHAIN=$TOOLCHAIN"                                            >> $SCRIPT_PATH/Makefile.include
  216. +echo "BUILDROOT=$BUILDROOT"                                            >> $SCRIPT_PATH/Makefile.include
  217. +echo "USE_BUILDROOT=$USE_BUILDROOT"                                    >> $SCRIPT_PATH/Makefile.include
  218. +echo "BASE_URL=http://mirrors.xbmc.org/build-deps/darwin-libs"         >> $SCRIPT_PATH/Makefile.include
  219. +echo "TARBALLS_LOCATION=$TARBALLS"                                     >> $SCRIPT_PATH/Makefile.include
  220. +echo "RETRIEVE_TOOL=/usr/bin/curl"                                     >> $SCRIPT_PATH/Makefile.include
  221. +echo "RETRIEVE_TOOL_FLAGS=-Ls --create-dirs --output \$(TARBALLS_LOCATION)/\$(ARCHIVE)" >> $SCRIPT_PATH/Makefile.include
  222. +echo "ARCHIVE_TOOL=/bin/tar"                                           >> $SCRIPT_PATH/Makefile.include
  223. +echo "ARCHIVE_TOOL_FLAGS=xf"                                           >> $SCRIPT_PATH/Makefile.include
  224. +echo "JOBS=$((`grep -c processor /proc/cpuinfo` -1))"                  >> $SCRIPT_PATH/Makefile.include
  225. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp xbmc_huceke/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
  226. --- xbmc_orig/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp   2013-06-17 16:17:17.000000000 +0200
  227. +++ xbmc_huceke/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2013-06-17 16:16:23.000000000 +0200
  228. @@ -756,6 +756,15 @@
  229.        {
  230.          EnumerateDevice(list, name, desc ? desc : name, config);
  231.        }
  232. +      else
  233. +      {
  234. +        /* sun4i whilelist */
  235. +        std::string strDevice = std::string(name);
  236. +        size_t found = strDevice.find("sun4i");
  237. +
  238. +        if(found != std::string::npos)
  239. +          EnumerateDevice(list, name, desc ? desc : name, config);
  240. +      }
  241.      }
  242.      free(io);
  243.      free(name);
  244. @@ -857,6 +866,10 @@
  245.    else if (name.substr(0, 6) == "iec958" || name.substr(0, 5) == "spdif")
  246.      return AE_DEVTYPE_IEC958;
  247.  
  248. +  /* sun4i hdmi device */
  249. +  if(name.find("sun4isndhdmi") != std::string::npos)
  250. +    return AE_DEVTYPE_HDMI;
  251. +
  252.    return AE_DEVTYPE_PCM;
  253.  }
  254.  
  255. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
  256. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp    2013-06-17 16:17:17.000000000 +0200
  257. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp  2013-06-17 16:16:23.000000000 +0200
  258. @@ -48,7 +48,9 @@
  259.  #include "Overlay/DVDOverlayCodecText.h"
  260.  #include "Overlay/DVDOverlayCodecTX3G.h"
  261.  #include "Overlay/DVDOverlayCodecFFmpeg.h"
  262. -
  263. +#if defined(HAVE_LIBCEDAR)
  264. +#include "Video/DVDVideoCodecCedar.h"
  265. +#endif
  266.  
  267.  #include "DVDStreamInfo.h"
  268.  #include "settings/GUISettings.h"
  269. @@ -169,9 +171,19 @@
  270.  #elif defined(_LINUX) && !defined(TARGET_DARWIN)
  271.    hwSupport += "VAAPI:no ";
  272.  #endif
  273. +#if defined(HAVE_LIBCEDAR)
  274. +  hwSupport += "CEDAR:yes ";
  275. +#else
  276. +  hwSupport += "CEDAR:no ";
  277. +#endif
  278.  
  279.    CLog::Log(LOGDEBUG, "CDVDFactoryCodec: compiled in hardware support: %s", hwSupport.c_str());
  280.  
  281. +#if defined(HAVE_LIBCEDAR)
  282. +  CLog::Log(LOGINFO, "Trying Cedar Video Decoder...");
  283. +  if ( (pCodec = OpenCodec(new CDVDVideoCodecCedar(), hint, options)) ) return pCodec;
  284. +#endif
  285. +
  286.    // dvd's have weird still-frames in it, which is not fully supported in ffmpeg
  287.    if(hint.stills && (hint.codec == CODEC_ID_MPEG2VIDEO || hint.codec == CODEC_ID_MPEG1VIDEO))
  288.    {
  289. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.cpp xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.cpp
  290. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.cpp  1970-01-01 01:00:00.000000000 +0100
  291. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.cpp    2013-06-17 16:16:23.000000000 +0200
  292. @@ -0,0 +1,580 @@
  293. +/*
  294. + *      Copyright (C) 2010 Team XBMC
  295. + *      http://www.xbmc.org
  296. + *
  297. + *  This Program is free software; you can redistribute it and/or modify
  298. + *  it under the terms of the GNU General Public License as published by
  299. + *  the Free Software Foundation; either version 2, or (at your option)
  300. + *  any later version.
  301. + *
  302. + *  This Program is distributed in the hope that it will be useful,
  303. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  304. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  305. + *  GNU General Public License for more details.
  306. + *
  307. + *  You should have received a copy of the GNU General Public License
  308. + *  along with XBMC; see the file COPYING.  If not, write to
  309. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  310. + *  http://www.gnu.org/copyleft/gpl.html
  311. + *
  312. + */
  313. +
  314. +#include "CedarOverlayManager.h"
  315. +
  316. +#if defined(HAVE_LIBCEDAR)
  317. +
  318. +#define CLASSNAME "CCedarOverlayManager"
  319. +
  320. +#include "utils/log.h"
  321. +#include <stdio.h>
  322. +#include <stdlib.h>
  323. +#include <sys/stat.h>
  324. +#include <sys/ioctl.h>
  325. +#include <fcntl.h>
  326. +#include <stropts.h>
  327. +#include <unistd.h>
  328. +#include <string.h>
  329. +
  330. +#define FBIO_WAITFORVSYNC       _IOW('F', 0x20, __u32)
  331. +
  332. +CCedarOverlayManager::CCedarOverlayManager()
  333. +{
  334. +  m_DisplayHandle = 0;
  335. +  m_open = false;
  336. +  m_videoLayer = 0;
  337. +  m_videoLayerInit = false;
  338. +  m_FrameBufferHandle = 0;
  339. +  m_FrameBufferLayerHandle = 0;
  340. +  m_screenId = 0;
  341. +  memset(&ColorKey, 0x0, sizeof(__disp_colorkey_t));
  342. +  m_format = RENDER_FMT_NONE;
  343. +}
  344. +
  345. +CCedarOverlayManager::~CCedarOverlayManager()
  346. +{
  347. +  Close();
  348. +}
  349. +
  350. +void CCedarOverlayManager::Close()
  351. +{
  352. +
  353. +  if(m_videoLayer)
  354. +  {
  355. +    /* stop video layer */
  356. +    m_cedarArguments[0] = m_screenId;
  357. +    m_cedarArguments[1] = m_videoLayer;
  358. +    m_cedarArguments[2] = 0;
  359. +    m_cedarArguments[3] = 0;
  360. +    ioctl(m_DisplayHandle, DISP_CMD_VIDEO_STOP, m_cedarArguments);
  361. +
  362. +    /* relase video layer */
  363. +    m_cedarArguments[0] = m_screenId;
  364. +    m_cedarArguments[1] = m_videoLayer;
  365. +    m_cedarArguments[2] = 0;
  366. +    m_cedarArguments[3] = 0;
  367. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_RELEASE, m_cedarArguments);
  368. +
  369. +    m_videoLayer = 0;
  370. +  }
  371. +
  372. +  if(m_DisplayHandle)
  373. +  {
  374. +    /*
  375. +    m_cedarArguments[0] = m_screenId;
  376. +    m_cedarArguments[1] = 0;
  377. +    m_cedarArguments[2] = 0;
  378. +    m_cedarArguments[3] = 0;
  379. +    ioctl(m_DisplayHandle, DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE, m_cedarArguments);
  380. +    */
  381. +    close(m_DisplayHandle);
  382. +  }
  383. +
  384. +  /* set alpha on */
  385. +  if(m_FrameBufferLayerHandle)
  386. +  {
  387. +    m_cedarArguments[0] = m_screenId;
  388. +    m_cedarArguments[1] = m_FrameBufferLayerHandle;
  389. +    m_cedarArguments[2] = 0;
  390. +    m_cedarArguments[3] = 0;
  391. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_ALPHA_ON, m_cedarArguments);
  392. +  }
  393. +
  394. +  if(m_FrameBufferHandle);
  395. +    close(m_FrameBufferHandle);
  396. +
  397. +  m_DisplayHandle = 0;
  398. +  m_videoLayer = 0;
  399. +  m_FrameBufferHandle = 0;
  400. +  m_open = false;
  401. +  m_videoLayerInit = false;
  402. +  m_format = RENDER_FMT_NONE;
  403. +
  404. +  m_dllCedar.Unload();
  405. +}
  406. +
  407. +void CCedarOverlayManager::UpdatePos(CRect &destRect, CRect &sourceRect)
  408. +{
  409. +  if(m_videoLayer)
  410. +  {
  411. +    m_destRect = destRect;
  412. +    m_sourceRect = sourceRect;
  413. +
  414. +    /*
  415. +    memset(&m_videoLayerAttr, 0x0, sizeof(__disp_layer_info_t));
  416. +    m_cedarArguments[0] = m_screenId;
  417. +    m_cedarArguments[1] = m_videoLayer;
  418. +    m_cedarArguments[2] = (unsigned long)(&m_videoLayerAttr);
  419. +    m_cedarArguments[3] = 0;
  420. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_GET_PARA, m_cedarArguments);
  421. +
  422. +    m_videoLayerAttr.scn_win.x = m_destRect.x1;
  423. +    m_videoLayerAttr.scn_win.y = m_destRect.y1;
  424. +    m_videoLayerAttr.scn_win.width  = m_destRect.x2 - m_destRect.x1;
  425. +    m_videoLayerAttr.scn_win.height = m_destRect.y2 - m_destRect.y1;
  426. +    m_videoLayerAttr.src_win.x = m_sourceRect.x1;
  427. +    m_videoLayerAttr.src_win.y = m_sourceRect.y1;
  428. +    m_videoLayerAttr.src_win.width = m_sourceRect.x2 - m_sourceRect.x1;
  429. +    m_videoLayerAttr.src_win.height = m_sourceRect.y2 - m_sourceRect.y1;
  430. +
  431. +    m_cedarArguments[0] = m_screenId;
  432. +    m_cedarArguments[1] = m_videoLayer;
  433. +    m_cedarArguments[2] = (unsigned long)(&m_videoLayerAttr);
  434. +    m_cedarArguments[3] = 0;
  435. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_PARA, m_cedarArguments);
  436. +    */
  437. +
  438. +    /* setup video layer parameters */
  439. +    __disp_rect_t scn_win;
  440. +
  441. +    scn_win.x = m_destRect.x1;
  442. +    scn_win.y = m_destRect.y1;
  443. +    scn_win.width  = m_destRect.x2 - m_destRect.x1;
  444. +    scn_win.height = m_destRect.y2 - m_destRect.y1;
  445. +
  446. +    m_cedarArguments[0] = m_screenId;
  447. +    m_cedarArguments[1] = m_videoLayer;
  448. +    m_cedarArguments[2] = (unsigned long)(&scn_win);
  449. +    m_cedarArguments[3] = 0;
  450. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_SCN_WINDOW, m_cedarArguments);
  451. +
  452. +    __disp_rect_t src_win;
  453. +
  454. +    src_win.x = m_sourceRect.x1;
  455. +    src_win.y = m_sourceRect.y1;
  456. +    src_win.width = m_sourceRect.x2 - m_sourceRect.x1;
  457. +    src_win.height = m_sourceRect.y2 - m_sourceRect.y1;
  458. +
  459. +    m_cedarArguments[0] = m_screenId;
  460. +    m_cedarArguments[1] = m_videoLayer;
  461. +    m_cedarArguments[2] = (unsigned long)(&src_win);
  462. +    m_cedarArguments[3] = 0;
  463. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_SRC_WINDOW, m_cedarArguments);
  464. +  }
  465. +}
  466. +
  467. +void CCedarOverlayManager::SetColorKey()
  468. +{
  469. +  if(m_videoLayer)
  470. +  {
  471. +    m_cedarArguments[0] = m_screenId;
  472. +    m_cedarArguments[1] = m_videoLayer;
  473. +    m_cedarArguments[2] = 0;
  474. +    m_cedarArguments[3] = 0;
  475. +    int ret = ioctl(m_DisplayHandle, DISP_CMD_LAYER_TOP, m_cedarArguments);
  476. +    if(ret != 0)
  477. +    {
  478. +      CLog::Log(LOGERROR, "%s:%s Error iset layer top err(%d)\n", CLASSNAME, __func__, ret);
  479. +      return;
  480. +    }
  481. +
  482. +    m_cedarArguments[0] = m_screenId;
  483. +    m_cedarArguments[1] = m_videoLayer;
  484. +    m_cedarArguments[2] = 0;
  485. +    m_cedarArguments[3] = 0;
  486. +    if(m_screenId == 0)
  487. +    {
  488. +      ioctl(m_DisplayHandle, DISP_CMD_LAYER_CK_OFF, m_cedarArguments);
  489. +    }
  490. +    else
  491. +    {
  492. +      ioctl(m_DisplayHandle, DISP_CMD_LAYER_CK_ON, m_cedarArguments);
  493. +    }
  494. +  }
  495. +
  496. +  memset(&ColorKey, 0x0, sizeof(__disp_colorkey_t));
  497. +
  498. +  if(m_screenId == 1)
  499. +  {
  500. +    ColorKey.ck_min.alpha  = 0xFF;
  501. +    ColorKey.ck_min.red    = 0x05;
  502. +    ColorKey.ck_min.green  = 0x01;
  503. +    ColorKey.ck_min.blue   = 0x07;
  504. +    ColorKey.ck_max.alpha  = 0xFF;
  505. +    ColorKey.ck_max.red    = 0x05;
  506. +    ColorKey.ck_max.green  = 0x01;
  507. +    ColorKey.ck_max.blue   = 0x07;
  508. +  }
  509. +  else
  510. +  {
  511. +    ColorKey.ck_min.alpha  = 0xFF;
  512. +    ColorKey.ck_min.red    = 0x00;
  513. +    ColorKey.ck_min.green  = 0x00;
  514. +    ColorKey.ck_min.blue   = 0x00;
  515. +    ColorKey.ck_max.alpha  = 0xFF;
  516. +    ColorKey.ck_max.red    = 0x00;
  517. +    ColorKey.ck_max.green  = 0x00;
  518. +    ColorKey.ck_max.blue   = 0x00;
  519. +  }
  520. +
  521. +  ColorKey.red_match_rule   = 2;
  522. +  ColorKey.green_match_rule = 2;
  523. +  ColorKey.blue_match_rule  = 2;
  524. +
  525. +  m_cedarArguments[0] = 0;
  526. +  m_cedarArguments[1] = (unsigned long) (&ColorKey);
  527. +  m_cedarArguments[2] = 0;
  528. +  m_cedarArguments[3] = 0;
  529. +  ioctl(m_DisplayHandle, DISP_CMD_SET_COLORKEY, m_cedarArguments);
  530. +
  531. +  m_cedarArguments[0] = 0;
  532. +  m_cedarArguments[1] = (unsigned long) (&ColorKey);
  533. +  m_cedarArguments[2] = 0;
  534. +  m_cedarArguments[3] = 0;
  535. +  ioctl(m_DisplayHandle, DISP_CMD_SET_BKCOLOR, m_cedarArguments);
  536. +
  537. +  m_cedarArguments[0] = m_screenId;
  538. +  m_cedarArguments[1] = m_FrameBufferLayerHandle;
  539. +  m_cedarArguments[2] = 0;
  540. +  m_cedarArguments[3] = 0;
  541. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_PIPE, m_cedarArguments);
  542. +
  543. +  m_cedarArguments[0] = m_screenId;
  544. +  m_cedarArguments[1] = m_FrameBufferLayerHandle;
  545. +  m_cedarArguments[2] = 0;
  546. +  m_cedarArguments[3] = 0;
  547. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_TOP, m_cedarArguments);
  548. +
  549. +  m_cedarArguments[0] = m_screenId;
  550. +  m_cedarArguments[1] = m_FrameBufferLayerHandle;
  551. +  m_cedarArguments[2] = 0xFF;
  552. +  m_cedarArguments[3] = 0;
  553. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_ALPHA_VALUE, m_cedarArguments);
  554. +
  555. +  m_cedarArguments[0] = m_screenId;
  556. +  m_cedarArguments[1] = m_FrameBufferLayerHandle;
  557. +  m_cedarArguments[2] = 0;
  558. +  m_cedarArguments[3] = 0;
  559. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_ALPHA_OFF, m_cedarArguments);
  560. +
  561. +  m_cedarArguments[0] = m_screenId;
  562. +  m_cedarArguments[1] = m_FrameBufferLayerHandle;
  563. +  m_cedarArguments[2] = 0;
  564. +  m_cedarArguments[3] = 0;
  565. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_CK_OFF, m_cedarArguments);
  566. +}
  567. +
  568. +bool CCedarOverlayManager::Open(CRect &destRect, CRect &sourceRect, ERenderFormat format)
  569. +{
  570. +  if(m_open)
  571. +    Close();
  572. +
  573. +  if(!m_dllCedar.Load())
  574. +    return false;
  575. +
  576. +  m_destRect = destRect;
  577. +  m_sourceRect = sourceRect;
  578. +  m_format = format;
  579. +
  580. +  m_DisplayHandle = open("/dev/disp", O_RDWR);
  581. +  if(m_DisplayHandle < 0)
  582. +  {
  583. +    CLog::Log(LOGERROR, "%s:%s Error opening display\n", CLASSNAME, __func__);
  584. +    return false;
  585. +  }
  586. +
  587. +  /* get video layer */
  588. +  m_cedarArguments[0] = m_screenId;
  589. +  m_cedarArguments[1] = DISP_LAYER_WORK_MODE_NORMAL;
  590. +  m_cedarArguments[2] = 0;
  591. +  m_cedarArguments[3] = 0;
  592. +
  593. +  m_videoLayer = ioctl(m_DisplayHandle, DISP_CMD_LAYER_REQUEST, m_cedarArguments);
  594. +  if(m_videoLayer == 0)
  595. +  {
  596. +    CLog::Log(LOGERROR, "%s:%s Error getting video layer err(%d)\n", CLASSNAME, __func__, m_videoLayer);
  597. +    return false;
  598. +  }
  599. +
  600. +  /* get display dimensions */
  601. +  m_cedarArguments[0] = m_screenId;
  602. +  m_cedarArguments[1] = m_videoLayer;
  603. +  m_cedarArguments[2] = 0;
  604. +  m_cedarArguments[3] = 0;
  605. +
  606. +  m_displayWidth = ioctl(m_DisplayHandle, DISP_CMD_SCN_GET_WIDTH, m_cedarArguments);
  607. +  m_displayHeight = ioctl(m_DisplayHandle, DISP_CMD_SCN_GET_HEIGHT, m_cedarArguments);
  608. +
  609. +  m_FrameBufferHandle = open("/dev/fb0", O_RDWR);
  610. +  if(m_FrameBufferHandle < 0)
  611. +  {
  612. +    CLog::Log(LOGERROR, "%s:%s Error opening framebuffer\n", CLASSNAME, __func__);
  613. +    return false;
  614. +  }
  615. +  ioctl(m_FrameBufferHandle, FBIOGET_LAYER_HDL_0, &m_FrameBufferLayerHandle);
  616. +
  617. +  CLog::Log(LOGINFO, "%s:%s Display %dx%d\n", CLASSNAME, __func__, m_displayWidth, m_displayHeight);
  618. +
  619. +  /*
  620. +  m_cedarArguments[0] = m_screenId;
  621. +  m_cedarArguments[1] = 0;
  622. +  m_cedarArguments[2] = 0;
  623. +  m_cedarArguments[3] = 0;
  624. +  ioctl(m_DisplayHandle, DISP_CMD_START_CMD_CACHE, m_cedarArguments);
  625. +  */
  626. +
  627. +  m_open = true;
  628. +  return true;
  629. +}
  630. +
  631. +bool CCedarOverlayManager::InitVideoLayer(__disp_pixel_fmt_t fmt)
  632. +{
  633. +  int ret = 0;
  634. +
  635. +  if(!m_open)
  636. +  {
  637. +    CLog::Log(LOGERROR, "%s:%s Error Diplay not opened\n", CLASSNAME, __func__);
  638. +    return false;
  639. +  }
  640. +
  641. +  memset(&m_videoLayerAttr, 0x0, sizeof(__disp_layer_info_t));
  642. +
  643. +  /* setup video layer parameters */
  644. +  m_videoLayerAttr.mode           = DISP_LAYER_WORK_MODE_SCALER;
  645. +  m_videoLayerAttr.pipe           = 1;
  646. +  m_videoLayerAttr.fb.addr[0]     = 0;
  647. +  m_videoLayerAttr.fb.addr[1]     = 0;
  648. +  m_videoLayerAttr.fb.size.width  = m_sourceRect.x2 - m_sourceRect.x1; //m_displayWidth;
  649. +  m_videoLayerAttr.fb.size.height = m_sourceRect.y2 - m_sourceRect.y1; //m_displayHeight;
  650. +  m_videoLayerAttr.alpha_en       = 1;
  651. +  m_videoLayerAttr.alpha_val      = 0xFF;
  652. +  m_videoLayerAttr.scn_win.x      = m_destRect.x1;
  653. +  m_videoLayerAttr.scn_win.y      = m_destRect.y1;
  654. +  m_videoLayerAttr.scn_win.width  = m_destRect.x2 - m_destRect.x1;
  655. +  m_videoLayerAttr.scn_win.height = m_destRect.y2 - m_destRect.y1;
  656. +  m_videoLayerAttr.prio           = 0xff;
  657. +  m_videoLayerAttr.src_win.x      = m_sourceRect.x1;
  658. +  m_videoLayerAttr.src_win.y      = m_sourceRect.y1;
  659. +  m_videoLayerAttr.src_win.width  = m_sourceRect.x2 - m_sourceRect.x1;
  660. +  m_videoLayerAttr.src_win.height = m_sourceRect.y2 - m_sourceRect.y1;
  661. +  m_videoLayerAttr.fb.b_trd_src   = false;
  662. +  m_videoLayerAttr.b_trd_out      = false;
  663. +  m_videoLayerAttr.fb.trd_mode    = DISP_3D_SRC_MODE_SSH;
  664. +  m_videoLayerAttr.out_trd_mode   = DISP_3D_OUT_MODE_FP;
  665. +  m_videoLayerAttr.b_from_screen  = false;
  666. +
  667. +  if((m_destRect.x2 - m_destRect.x1) < 720)
  668. +    m_videoLayerAttr.fb.cs_mode   = DISP_BT601;
  669. +  else
  670. +    m_videoLayerAttr.fb.cs_mode   = DISP_BT709;
  671. +
  672. +  if(fmt == DISP_FORMAT_ARGB8888)
  673. +  {
  674. +    m_videoLayerAttr.fb.mode      = DISP_MOD_NON_MB_PLANAR;
  675. +    m_videoLayerAttr.fb.format    = fmt;
  676. +    m_videoLayerAttr.fb.br_swap   = 0;
  677. +    m_videoLayerAttr.fb.cs_mode   = DISP_YCC;
  678. +    m_videoLayerAttr.fb.seq       = DISP_SEQ_P3210;
  679. +  }
  680. +  else if(m_format == RENDER_FMT_YUV420P)
  681. +  {
  682. +    m_videoLayerAttr.fb.mode      = DISP_MOD_NON_MB_PLANAR;
  683. +    m_videoLayerAttr.fb.format    = DISP_FORMAT_YUV420;
  684. +    m_videoLayerAttr.fb.br_swap   = 0;
  685. +    m_videoLayerAttr.fb.seq       = DISP_SEQ_YUYV;
  686. +  }
  687. +  else if(fmt == DISP_FORMAT_YUV420)
  688. +  {
  689. +    m_videoLayerAttr.fb.mode      = DISP_MOD_MB_UV_COMBINED;
  690. +    m_videoLayerAttr.fb.format    = fmt;
  691. +    m_videoLayerAttr.fb.br_swap   = 0;
  692. +    m_videoLayerAttr.fb.seq       = DISP_SEQ_UVUV;
  693. +  }
  694. +  else
  695. +  {
  696. +    return false;
  697. +  }
  698. +
  699. +  m_cedarArguments[0] = m_screenId;
  700. +  m_cedarArguments[1] = m_videoLayer;
  701. +  m_cedarArguments[2] = (unsigned long) (&m_videoLayerAttr);
  702. +  m_cedarArguments[3] = 0;
  703. +  ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_PARA, m_cedarArguments);
  704. +
  705. +  m_cedarArguments[0] = m_screenId;
  706. +  m_cedarArguments[1] = m_videoLayer;
  707. +  m_cedarArguments[2] = 0;
  708. +  m_cedarArguments[3] = 0;
  709. +
  710. +  ret = ioctl(m_DisplayHandle, DISP_CMD_LAYER_BOTTOM, m_cedarArguments);
  711. +  if(ret != 0)
  712. +  {
  713. +    CLog::Log(LOGERROR, "%s:%s Error configure video layer err(%d)\n", CLASSNAME, __func__, ret);
  714. +    return false;
  715. +  }
  716. +
  717. +  SetColorKey();
  718. +
  719. +  m_cedarArguments[0] = m_screenId;
  720. +  m_cedarArguments[1] = m_videoLayer;
  721. +  m_cedarArguments[2] = 0;
  722. +  m_cedarArguments[3] = 0;
  723. +
  724. +  ret = ioctl(m_DisplayHandle, DISP_CMD_LAYER_OPEN, m_cedarArguments);
  725. +  if (ret != 0)
  726. +  {
  727. +    CLog::Log(LOGERROR, "%s:%s Error open display layer err(%d)\n", CLASSNAME, __func__, ret);
  728. +    return false;
  729. +  }
  730. +
  731. +  /* start video layer */
  732. +  m_cedarArguments[0] = m_screenId;
  733. +  m_cedarArguments[1] = m_videoLayer;
  734. +  m_cedarArguments[2] = 0;
  735. +  m_cedarArguments[3] = 0;
  736. +
  737. +  ret = ioctl(m_DisplayHandle, DISP_CMD_VIDEO_START, m_cedarArguments);
  738. +  if(ret != 0)
  739. +  {
  740. +    CLog::Log(LOGERROR, "%s:%s Error starting video err(%d)\n", CLASSNAME, __func__, ret);
  741. +    return false;
  742. +  }
  743. +
  744. +  m_videoLayerInit = true;
  745. +  return true;
  746. +}
  747. +
  748. +bool CCedarOverlayManager::RenderFrame(unsigned int yAddr, unsigned int uAddr, unsigned int vAddr,
  749. +    unsigned int ySize, unsigned int uSize, unsigned int vSize,
  750. +    __disp_pixel_fmt_t fmt, int frame_rate, int frame)
  751. +{
  752. +  __disp_video_fb_t   frameBuffer;
  753. +  __disp_layer_info_t layerInfo;
  754. +  int ret = 0;
  755. +
  756. +  memset(&frameBuffer, 0x0, sizeof(__disp_video_fb_t));
  757. +
  758. +  //frameBuffer.top_field_first   = display_info->top_field_first;
  759. +  frameBuffer.interlace = 0;
  760. +  frameBuffer.frame_rate    = 60;
  761. +
  762. +  m_dllCedar.MemFlushCache((u8 *)(yAddr), ySize);
  763. +  m_dllCedar.MemFlushCache((u8 *)(uAddr), uSize);
  764. +
  765. +  if(yAddr)
  766. +    yAddr = m_dllCedar.MemGetPhyAddr(yAddr);
  767. +  if(uAddr)
  768. +    uAddr = m_dllCedar.MemGetPhyAddr(uAddr);
  769. +  if(vAddr)
  770. +    vAddr = m_dllCedar.MemGetPhyAddr(vAddr);
  771. +
  772. +  frameBuffer.addr[0] = yAddr;
  773. +  frameBuffer.addr[1] = uAddr;
  774. +  frameBuffer.addr[2] = vAddr;
  775. +
  776. +  frameBuffer.addr_right[0] = 0;
  777. +  frameBuffer.addr_right[1] = 0;
  778. +  frameBuffer.addr_right[2] = 0;
  779. +
  780. +  frameBuffer.id = frame;
  781. +
  782. +  if(!m_videoLayerInit)
  783. +  {
  784. +    /* setu pvideo layer */
  785. +    if(!InitVideoLayer(fmt))
  786. +      return false;
  787. +        
  788. +    memset(&layerInfo, 0x0, sizeof(__disp_layer_info_t));
  789. +
  790. +    /* setup framebuffer address */
  791. +    m_cedarArguments[0] = m_screenId;
  792. +    m_cedarArguments[1] = m_videoLayer;
  793. +    m_cedarArguments[2] = (unsigned long) (&layerInfo);
  794. +    m_cedarArguments[3] = 0;
  795. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_GET_PARA, m_cedarArguments);
  796. +
  797. +    layerInfo.fb.addr[0] = frameBuffer.addr[0];
  798. +    layerInfo.fb.addr[1] = frameBuffer.addr[1];
  799. +    layerInfo.fb.addr[2] = frameBuffer.addr[2];
  800. +
  801. +    layerInfo.fb.trd_right_addr[0] = frameBuffer.addr_right[0];
  802. +    layerInfo.fb.trd_right_addr[1] = frameBuffer.addr_right[1];
  803. +    layerInfo.fb.trd_right_addr[2] = frameBuffer.addr_right[2];
  804. +
  805. +    m_cedarArguments[0] = m_screenId;
  806. +    m_cedarArguments[1] = m_videoLayer;
  807. +    m_cedarArguments[2] = (unsigned long) (&layerInfo);
  808. +    m_cedarArguments[3] = 0;
  809. +    ioctl(m_DisplayHandle, DISP_CMD_LAYER_SET_PARA, m_cedarArguments);
  810. +
  811. +    /* open video layer */
  812. +#if 0
  813. +    m_cedarArguments[0] = m_screenId;
  814. +    m_cedarArguments[1] = m_videoLayer;
  815. +    m_cedarArguments[2] = 0;
  816. +    m_cedarArguments[3] = 0;
  817. +
  818. +    ret = ioctl(m_DisplayHandle, DISP_CMD_LAYER_OPEN, m_cedarArguments);
  819. +    if (ret != 0)
  820. +    {
  821. +      CLog::Log(LOGERROR, "%s:%s Error open display layer err(%d)\n", CLASSNAME, __func__, ret);
  822. +      return false;
  823. +    }
  824. +
  825. +    /* start video layer */
  826. +    m_cedarArguments[0] = m_screenId;
  827. +    m_cedarArguments[1] = m_videoLayer;
  828. +    m_cedarArguments[2] = 0;
  829. +    m_cedarArguments[3] = 0;
  830. +
  831. +    ret = ioctl(m_DisplayHandle, DISP_CMD_VIDEO_START, m_cedarArguments);
  832. +    if(ret != 0)
  833. +    {
  834. +      CLog::Log(LOGERROR, "%s:%s Error starting video err(%d)\n", CLASSNAME, __func__, ret);
  835. +      return false;
  836. +    }
  837. +#endif
  838. +  }
  839. +  else
  840. +  {
  841. +    m_cedarArguments[0] = m_screenId;
  842. +    m_cedarArguments[1] = m_videoLayer;
  843. +    m_cedarArguments[2] = (unsigned long) (&frameBuffer);
  844. +    m_cedarArguments[3] = 0;
  845. +    ioctl(m_DisplayHandle, DISP_CMD_VIDEO_SET_FB, m_cedarArguments);
  846. +  }
  847. +
  848. +  return true;
  849. +}
  850. +
  851. +int CCedarOverlayManager::GetFrameID()
  852. +{
  853. +  if(!m_open)
  854. +    return -1;
  855. +
  856. +  m_cedarArguments[0] = m_screenId;
  857. +  m_cedarArguments[1] = m_videoLayer;
  858. +  m_cedarArguments[2] = 0;
  859. +  m_cedarArguments[3] = 0;
  860. +
  861. +  return ioctl(m_DisplayHandle, DISP_CMD_VIDEO_GET_FRAME_ID, m_cedarArguments);
  862. +}
  863. +
  864. +bool CCedarOverlayManager::WaitVSYNC()
  865. +{
  866. +  if(m_FrameBufferHandle)
  867. +    ioctl(m_FrameBufferHandle, FBIO_WAITFORVSYNC, NULL);
  868. +
  869. +  return true;
  870. +}
  871. +
  872. +#endif
  873. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.h xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.h
  874. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.h    1970-01-01 01:00:00.000000000 +0100
  875. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.h  2013-06-17 16:16:23.000000000 +0200
  876. @@ -0,0 +1,76 @@
  877. +/*
  878. + *      Copyright (C) 2010 Team XBMC
  879. + *      http://www.xbmc.org
  880. + *
  881. + *  This Program is free software; you can redistribute it and/or modify
  882. + *  it under the terms of the GNU General Public License as published by
  883. + *  the Free Software Foundation; either version 2, or (at your option)
  884. + *  any later version.
  885. + *
  886. + *  This Program is distributed in the hope that it will be useful,
  887. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  888. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  889. + *  GNU General Public License for more details.
  890. + *
  891. + *  You should have received a copy of the GNU General Public License
  892. + *  along with XBMC; see the file COPYING.  If not, write to
  893. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  894. + *  http://www.gnu.org/copyleft/gpl.html
  895. + *
  896. + */
  897. +
  898. +#ifndef _OVERLAYRENDERCEDAR_H_
  899. +#define _OVERLAYRENDERCEDAR_H_
  900. +
  901. +#include "system.h"
  902. +
  903. +#if defined(HAVE_LIBCEDAR)
  904. +
  905. +#include <asm/types.h>
  906. +#include <drv_display_sun4i.h>
  907. +#include "guilib/Geometry.h"
  908. +#include "cores/VideoRenderers/RenderFlags.h"
  909. +#include "cores/VideoRenderers/RenderFormats.h"
  910. +#include "DllLibCedar.h"
  911. +
  912. +class CCedarOverlayManager
  913. +{
  914. +public:
  915. +  CCedarOverlayManager();
  916. +  ~CCedarOverlayManager();
  917. +  void Close();
  918. +  void UpdatePos(CRect &destRect, CRect &sourceRect);
  919. +  void SetColorKey();
  920. +  bool Open(CRect &destRect, CRect &sourceRect, ERenderFormat format);
  921. +  bool InitVideoLayer(__disp_pixel_fmt_t fmt);
  922. +  bool RenderFrame(unsigned int yAddr, unsigned int uAddr, unsigned int vAddr,
  923. +      unsigned int ySize, unsigned int uSize, unsigned int vSize,
  924. +      __disp_pixel_fmt_t fmt, int frame_rate, int frame);
  925. +  int  GetFrameID();
  926. +  bool WaitVSYNC();
  927. +  __disp_colorkey_t ColorKey;
  928. +private:
  929. +protected:
  930. +  unsigned long m_cedarArguments[4];
  931. +  unsigned int  m_width;
  932. +  unsigned int  m_height;
  933. +  int           m_screenId;
  934. +  int           m_DisplayHandle;
  935. +  int           m_videoLayer;
  936. +  int           m_FrameBufferHandle;
  937. +  int           m_FrameBufferLayerHandle;
  938. +  int           m_displayLayer;
  939. +  bool          m_open;
  940. +  bool          m_videoLayerInit;
  941. +  unsigned int  m_displayWidth;
  942. +  unsigned int  m_displayHeight;
  943. +  CRect         m_destRect;
  944. +  CRect         m_sourceRect;
  945. +  __disp_layer_info_t m_videoLayerAttr;
  946. +  ERenderFormat m_format;
  947. +  DllLibCedar   m_dllCedar;
  948. +};
  949. +
  950. +#endif
  951. +
  952. +#endif
  953. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibCedar.h xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibCedar.h
  954. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibCedar.h    1970-01-01 01:00:00.000000000 +0100
  955. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibCedar.h  2013-06-17 16:16:23.000000000 +0200
  956. @@ -0,0 +1,65 @@
  957. +#pragma once
  958. +
  959. +/*
  960. + *      Copyright (C) 2005-2008 Team XBMC
  961. + *      http://www.xbmc.org
  962. + *
  963. + *  This Program is free software; you can redistribute it and/or modify
  964. + *  it under the terms of the GNU General Public License as published by
  965. + *  the Free Software Foundation; either version 2, or (at your option)
  966. + *  any later version.
  967. + *
  968. + *  This Program is distributed in the hope that it will be useful,
  969. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  970. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  971. + *  GNU General Public License for more details.
  972. + *
  973. + *  You should have received a copy of the GNU General Public License
  974. + *  along with XBMC; see the file COPYING.  If not, write to
  975. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  976. + *  http://www.gnu.org/copyleft/gpl.html
  977. + *
  978. + */
  979. +
  980. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  981. +  #include "config.h"
  982. +#endif
  983. +extern "C" {
  984. +#include <libcedar/CedarDecoder.h>
  985. +}
  986. +#include "DynamicDll.h"
  987. +#include "utils/log.h"
  988. +
  989. +#define DLL_PATH_LIBCEDAR "/usr/lib/libcedar.so"
  990. +
  991. +class DllLibCedarInterface
  992. +{
  993. +public:
  994. +  virtual ~DllLibCedarInterface() {}
  995. +  virtual CCedarDecoder *AllocCedarDecoder() = 0;
  996. +  virtual CCedarDecoder *FreeCedarDecoder(CCedarDecoder *decoder) = 0;
  997. +  virtual unsigned int MemGetPhyAddr(unsigned int mem) = 0;
  998. +  virtual void *MemPalloc(u32 size, u32 align) = 0;
  999. +  virtual void MemPfree(void* p) = 0;
  1000. +  virtual void MemFlushCache(u8* mem, u32 size) = 0;
  1001. +};
  1002. +
  1003. +class DllLibCedar : public DllDynamic, DllLibCedarInterface
  1004. +{
  1005. +  DECLARE_DLL_WRAPPER(DllLibCedar, DLL_PATH_LIBCEDAR)
  1006. +  LOAD_SYMBOLS()
  1007. +  DEFINE_METHOD0(CCedarDecoder *, AllocCedarDecoder)
  1008. +  DEFINE_METHOD1(CCedarDecoder *, FreeCedarDecoder, (CCedarDecoder *p1))
  1009. +  DEFINE_METHOD1(unsigned int, MemGetPhyAddr, (unsigned int p1))
  1010. +  DEFINE_METHOD2(void *, MemPalloc, (u32 p1, u32 p2))
  1011. +  DEFINE_METHOD1(void , MemPfree, (void *p1))
  1012. +  DEFINE_METHOD2(void , MemFlushCache, (u8 *p1, u32 p2))
  1013. +  BEGIN_METHOD_RESOLVE()
  1014. +    RESOLVE_METHOD(AllocCedarDecoder)
  1015. +    RESOLVE_METHOD(FreeCedarDecoder)
  1016. +    RESOLVE_METHOD(MemGetPhyAddr)
  1017. +    RESOLVE_METHOD(MemPalloc)
  1018. +    RESOLVE_METHOD(MemPfree)
  1019. +    RESOLVE_METHOD(MemFlushCache)
  1020. +  END_METHOD_RESOLVE()
  1021. +};
  1022. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.cpp xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.cpp
  1023. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.cpp   1970-01-01 01:00:00.000000000 +0100
  1024. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.cpp 2013-06-17 16:16:23.000000000 +0200
  1025. @@ -0,0 +1,508 @@
  1026. +/*
  1027. + *      Copyright (C) 2012 Team XBMC
  1028. + *      http://www.xbmc.org
  1029. + *
  1030. + *  This Program is free software; you can redistribute it and/or modify
  1031. + *  it under the terms of the GNU General Public License as published by
  1032. + *  the Free Software Foundation; either version 2, or (at your option)
  1033. + *  any later version.
  1034. + *
  1035. + *  This Program is distributed in the hope that it will be useful,
  1036. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1037. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1038. + *  GNU General Public License for more details.
  1039. + *
  1040. + *  You should have received a copy of the GNU General Public License
  1041. + *  along with XBMC; see the file COPYING.  If not, write to
  1042. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1043. + *  http://www.gnu.org/copyleft/gpl.html
  1044. + *
  1045. + */
  1046. +
  1047. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  1048. +  #include "config.h"
  1049. +#elif defined(_WIN32)
  1050. +#include "system.h"
  1051. +#endif
  1052. +
  1053. +#if defined(HAVE_LIBCEDAR)
  1054. +
  1055. +#include "DVDStreamInfo.h"
  1056. +#include "DVDCodecs/DVDCodecUtils.h"
  1057. +#include "DVDVideoCodecCedar.h"
  1058. +#include "DynamicDll.h"
  1059. +#include "cores/VideoRenderers/RenderFormats.h"
  1060. +#include "utils/BitstreamConverter.h"
  1061. +
  1062. +#include "guilib/GraphicContext.h"
  1063. +
  1064. +#include "utils/log.h"
  1065. +#include "linux/XMemUtils.h"
  1066. +#include "DVDClock.h"
  1067. +#include "threads/Atomics.h"
  1068. +
  1069. +#include <sys/time.h>
  1070. +#include <inttypes.h>
  1071. +
  1072. +#ifdef CLASSNAME
  1073. +#undef CLASSNAME
  1074. +#endif
  1075. +#define CLASSNAME "CDVDVideoCodecCedar"
  1076. +
  1077. +#define ALIGN(x, n) (((x) + (n) - 1) & (~((n) - 1)))
  1078. +#define CODEC_4CC(c1,c2,c3,c4) (((u32)(c4)<<24)|((u32)(c3)<<16)|((u32)(c2)<<8)|(u32)(c1))
  1079. +
  1080. +static long g_cedaropen = 0;
  1081. +
  1082. +CDVDVideoCodecCedar::CDVDVideoCodecCedar()
  1083. +{
  1084. +  m_video_codec_name  = "";
  1085. +  m_cedarDecoder      = NULL;
  1086. +  m_valid_pts         = false;
  1087. +  m_packet_count      = 0;
  1088. +  m_converter         = NULL;
  1089. +  m_convert           = false;
  1090. +  m_is_open           = false;
  1091. +
  1092. +  memset(&m_videobuffer, 0, sizeof(DVDVideoPicture));
  1093. +}
  1094. +
  1095. +CDVDVideoCodecCedar::~CDVDVideoCodecCedar()
  1096. +{
  1097. +  Dispose();
  1098. +}
  1099. +
  1100. +bool CDVDVideoCodecCedar::NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize)
  1101. +{
  1102. +  switch(codec)
  1103. +  {
  1104. +    case CODEC_ID_H264:
  1105. +      if (in_extrasize < 7 || in_extradata == NULL)
  1106. +        return true;
  1107. +      // valid avcC atom data always starts with the value 1 (version), otherwise annexb
  1108. +      else if ( *in_extradata != 1 )
  1109. +        return true;
  1110. +    default: break;
  1111. +  }
  1112. +  return false;
  1113. +}
  1114. +
  1115. +bool CDVDVideoCodecCedar::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
  1116. +{
  1117. +  if (cas(&g_cedaropen, 0, 1) != 0)
  1118. +  {
  1119. +    CLog::Log(LOGERROR, "%s::%s decoder already in use\n", CLASSNAME, __func__);
  1120. +    return false;
  1121. +  }
  1122. +
  1123. +  if(!m_dllCedar.Load())
  1124. +    return false;
  1125. +
  1126. +  Dispose();
  1127. +
  1128. +  m_decoded_width   = hints.width;
  1129. +  m_decoded_height  = hints.height;
  1130. +
  1131. +  if(!m_decoded_width || !m_decoded_height)
  1132. +  {
  1133. +    CLog::Log(LOGERROR, "%s::%s unknown decoded size %dx%d\n", CLASSNAME, __func__, m_decoded_width, m_decoded_height);
  1134. +    return false;
  1135. +  }
  1136. +
  1137. +  m_converter = new CBitstreamConverter();
  1138. +  if(!m_converter)
  1139. +  {
  1140. +    CLog::Log(LOGERROR, "%s::%s allocationg bistream converter\n", CLASSNAME, __func__);
  1141. +    return false;
  1142. +  }
  1143. +
  1144. +  int extrasize = hints.extrasize;
  1145. +  uint8_t *extradata = (uint8_t *)hints.extradata;
  1146. +
  1147. +  m_convert = m_converter->Open(hints.codec, (uint8_t *)hints.extradata, hints.extrasize, false);
  1148. +  if(m_convert)
  1149. +  {
  1150. +    extrasize = m_converter->GetExtraSize();
  1151. +    extradata = m_converter->GetExtraData();
  1152. +  }
  1153. +
  1154. +  vstream_info_t    stream_info;
  1155. +  memset(&stream_info, 0x0, sizeof(vstream_info_t));
  1156. +
  1157. +  stream_info.container_format  = CONTAINER_FORMAT_UNKNOW;
  1158. +
  1159. +  /*
  1160. +  printf("extradata : ");
  1161. +  for(int i = 0; i < extrasize; i++)
  1162. +  {
  1163. +    uint8_t *p = (uint8_t *)extradata;
  1164. +    printf("%02x ", p[i]);
  1165. +  }
  1166. +  printf("\n");
  1167. +  */
  1168. +
  1169. +  switch(hints.codec)
  1170. +  {
  1171. +    case CODEC_ID_H264:
  1172. +      stream_info.format              = STREAM_FORMAT_H264;
  1173. +      stream_info.sub_format          = STREAM_SUB_FORMAT_UNKNOW;
  1174. +      /*
  1175. +      if(hints.codec_tag == 27 || NaluFormatStartCodes(hints.codec, extradata, extrasize)) //M2TS and TS
  1176. +      {
  1177. +        printf("ts\n");
  1178. +        stream_info.container_format  = CONTAINER_FORMAT_TS;
  1179. +      }
  1180. +      */
  1181. +      m_video_codec_name              = "cedar-h264";
  1182. +      break;
  1183. +    case CODEC_ID_MPEG1VIDEO:
  1184. +      stream_info.format              = STREAM_FORMAT_MPEG2;
  1185. +      stream_info.sub_format          = MPEG2_SUB_FORMAT_MPEG1;
  1186. +      m_video_codec_name              = "cedar-mpeg1";
  1187. +      break;
  1188. +    case CODEC_ID_MPEG2VIDEO:
  1189. +      stream_info.format              = STREAM_FORMAT_MPEG2;
  1190. +      stream_info.sub_format          = MPEG2_SUB_FORMAT_MPEG2;
  1191. +      extradata = NULL;
  1192. +      extrasize = 0;
  1193. +      m_video_codec_name              = "cedar-mpeg2";
  1194. +      break;
  1195. +    case CODEC_ID_MSMPEG4V1:
  1196. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1197. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_DIVX1;
  1198. +      m_video_codec_name              = "cedar-divx1";
  1199. +      break;
  1200. +    break;
  1201. +    case CODEC_ID_MSMPEG4V2:
  1202. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1203. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_DIVX2;
  1204. +      m_video_codec_name              = "cedar-divx2";
  1205. +      break;
  1206. +    case CODEC_ID_MSMPEG4V3:
  1207. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1208. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_DIVX3;
  1209. +      m_video_codec_name              = "cedar-divx3";
  1210. +      break;
  1211. +    case CODEC_ID_MPEG4:
  1212. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1213. +      switch(hints.codec_tag)
  1214. +      {
  1215. +        case CODEC_4CC('D','X','5','0'):
  1216. +        case CODEC_4CC('D','I','V','5'):
  1217. +          stream_info.sub_format      = MPEG4_SUB_FORMAT_DIVX5;
  1218. +          m_video_codec_name          = "cedar-divx5";
  1219. +          break;
  1220. +        case CODEC_4CC('X','V','I','D'):
  1221. +        case CODEC_4CC('M','P','4','V'):
  1222. +        case CODEC_4CC('P','M','P','4'):
  1223. +        case CODEC_4CC('F','M','P','4'):
  1224. +          stream_info.sub_format      = MPEG4_SUB_FORMAT_XVID;
  1225. +          m_video_codec_name          = "cedar-xvid";
  1226. +          break;
  1227. +        default:
  1228. +          return false;
  1229. +      }
  1230. +      break;
  1231. +    case CODEC_ID_VP6F:
  1232. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1233. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_VP6;
  1234. +      m_video_codec_name              = "cedar-vp6";
  1235. +      break;
  1236. +    case CODEC_ID_H263:
  1237. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1238. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_H263;
  1239. +      m_video_codec_name              = "cedar-h263";
  1240. +      break;
  1241. +    case CODEC_ID_VP8:
  1242. +      stream_info.format              = STREAM_FORMAT_VP8;
  1243. +      stream_info.sub_format          = STREAM_SUB_FORMAT_UNKNOW;
  1244. +      m_video_codec_name              = "cedar-vp8";
  1245. +      break;
  1246. +    case CODEC_ID_VC1:
  1247. +      stream_info.format              = STREAM_FORMAT_VC1;
  1248. +      stream_info.sub_format          = STREAM_SUB_FORMAT_UNKNOW;
  1249. +      m_video_codec_name              = "cedar-vc1";
  1250. +      break;
  1251. +    case CODEC_ID_WMV3:
  1252. +      stream_info.format              = STREAM_FORMAT_VC1;
  1253. +      stream_info.sub_format          = STREAM_SUB_FORMAT_UNKNOW;
  1254. +      m_video_codec_name              = "cedar-wmv3";
  1255. +      break;
  1256. +    case CODEC_ID_WMV1:
  1257. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1258. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_WMV1;
  1259. +      m_video_codec_name              = "cedar-wmv1";
  1260. +      break;
  1261. +    case CODEC_ID_WMV2:
  1262. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1263. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_WMV2;
  1264. +      m_video_codec_name              = "cedar-wmv2";
  1265. +      break;
  1266. +    case CODEC_ID_FLV1:
  1267. +      stream_info.format              = STREAM_FORMAT_MPEG4;
  1268. +      stream_info.sub_format          = MPEG4_SUB_FORMAT_SORENSSON_H263;
  1269. +      m_video_codec_name              = "cedar-sorensson";
  1270. +      break;
  1271. +    case CODEC_ID_MJPEG:
  1272. +      stream_info.format              = STREAM_FORMAT_MJPEG;
  1273. +      stream_info.sub_format          = STREAM_SUB_FORMAT_UNKNOW;
  1274. +      m_video_codec_name              = "cedar-mjpeg";
  1275. +      break;
  1276. +    default:
  1277. +      CLog::Log(LOGERROR, "%s::%s CodecID 0x%08x not supported by Cedar decoder\n", CLASSNAME, __func__, hints.codec);
  1278. +      return false;
  1279. +  }
  1280. +
  1281. +  stream_info.container_format    = CONTAINER_FORMAT_UNKNOW;
  1282. +  stream_info.video_width         = m_decoded_width;
  1283. +  stream_info.video_height        = m_decoded_height;
  1284. +  if (hints.fpsrate && hints.fpsscale)
  1285. +    stream_info.frame_rate = DVD_TIME_BASE /
  1286. +      CDVDCodecUtils::NormalizeFrameduration((double)DVD_TIME_BASE *
  1287. +      hints.fpsscale / hints.fpsrate) * 1000;
  1288. +  else
  1289. +    stream_info.frame_rate = 25.0f * 1000;
  1290. +  stream_info.frame_duration      = (double)DVD_TIME_BASE / stream_info.frame_rate * 1000.0f;
  1291. +  stream_info.is_pts_correct      = 1;
  1292. +  stream_info.aspec_ratio         = m_decoded_width / m_decoded_height * 1000;
  1293. +
  1294. +  m_cedarDecoder = m_dllCedar.AllocCedarDecoder();
  1295. +
  1296. +  if(!m_cedarDecoder)
  1297. +  {
  1298. +    CLog::Log(LOGERROR, "%s::%s Cedar create\n", CLASSNAME, __func__);
  1299. +    return false;
  1300. +  }
  1301. +
  1302. +  if(!m_cedarDecoder->Open(&stream_info, extradata, extrasize))
  1303. +  {
  1304. +    CLog::Log(LOGERROR, "%s::%s Cedar decoder open\n", CLASSNAME, __func__);
  1305. +    m_cedarDecoder->Close();
  1306. +    return false;
  1307. +  }
  1308. +
  1309. +  m_is_open = true;
  1310. +
  1311. +  CLog::Log(LOGINFO, "%s::%s - Cedar Decoder opened with codec : %s [%dx%d]", CLASSNAME, __func__,
  1312. +            m_video_codec_name.c_str(), m_decoded_width, m_decoded_height);
  1313. +
  1314. +  return true;
  1315. +}
  1316. +
  1317. +void CDVDVideoCodecCedar::Dispose()
  1318. +{
  1319. +  if(m_is_open)
  1320. +    m_cedarDecoder->Close();
  1321. +
  1322. +  if(m_cedarDecoder)
  1323. +  {
  1324. +    cas(&g_cedaropen, 1, 0);
  1325. +    m_dllCedar.FreeCedarDecoder(m_cedarDecoder);
  1326. +    m_cedarDecoder = NULL;
  1327. +  }
  1328. +  
  1329. +  m_video_codec_name  = "";
  1330. +
  1331. +  memset(&m_videobuffer, 0, sizeof(DVDVideoPicture));
  1332. +
  1333. +  while (!m_dts_queue.empty())
  1334. +    m_dts_queue.pop();
  1335. +
  1336. +  m_valid_pts = false;
  1337. +
  1338. +  m_packet_count = 0;
  1339. +
  1340. +  delete m_converter;
  1341. +  m_converter = NULL;
  1342. +  m_convert = false;
  1343. +
  1344. +  m_dllCedar.Unload();
  1345. +
  1346. +  m_is_open = false;
  1347. +}
  1348. +
  1349. +void CDVDVideoCodecCedar::SetDropState(bool bDrop)
  1350. +{
  1351. +  m_drop_state = bDrop;
  1352. +
  1353. +  /*
  1354. +  if(m_drop_state)
  1355. +  {
  1356. +    while(m_cedarDecoder->ReadyFrames())
  1357. +    {
  1358. +      vpicture_t *picture = m_cedarDecoder->GetDisplayFrame();
  1359. +      if(picture)
  1360. +      {
  1361. +        m_cedarDecoder->ReturnDisplayFrame(picture);
  1362. +        if(!m_dts_queue.empty())
  1363. +          m_dts_queue.pop();
  1364. +      }
  1365. +      else
  1366. +        break;
  1367. +    }
  1368. +  }
  1369. +  */
  1370. +}
  1371. +
  1372. +int CDVDVideoCodecCedar::Decode(uint8_t *pData, int iSize, double dts, double pts)
  1373. +{
  1374. +  if (!pData)
  1375. +  {
  1376. +    int ret = 0;
  1377. +    if(m_cedarDecoder->ReadyFrames() == 1)
  1378. +      ret = VC_PICTURE | VC_BUFFER;
  1379. +    else if(m_cedarDecoder->ReadyFrames() > 1)
  1380. +      ret = VC_PICTURE;
  1381. +    else
  1382. +      ret = VC_BUFFER;
  1383. +    return ret;
  1384. +  }
  1385. +
  1386. +  int demuxer_bytes = 0;
  1387. +  uint8_t *demuxer_content = NULL;
  1388. +
  1389. +  if(m_convert)
  1390. +  {
  1391. +    m_converter->Convert(pData, iSize);
  1392. +    demuxer_bytes = m_converter->GetConvertSize();
  1393. +    demuxer_content = m_converter->GetConvertBuffer();
  1394. +  }
  1395. +  else
  1396. +  {
  1397. +    demuxer_bytes = iSize;
  1398. +    demuxer_content = pData;
  1399. +  }
  1400. +
  1401. +  if(demuxer_bytes && demuxer_content)
  1402. +  {
  1403. +    double pts_cedar = (pts == DVD_NOPTS_VALUE) ? 0 : pts / 1000;
  1404. +
  1405. +    m_valid_pts = (pts != DVD_NOPTS_VALUE);
  1406. +
  1407. +    vstream_data_t *streamData = m_cedarDecoder->AllocateBuffer(demuxer_bytes, pts_cedar);
  1408. +
  1409. +    if(streamData)
  1410. +    {
  1411. +      m_cedarDecoder->AddBufferData(streamData, demuxer_content, demuxer_bytes);
  1412. +      m_cedarDecoder->AddBuffer(streamData);
  1413. +  
  1414. +      m_dts_queue.push(dts);
  1415. +
  1416. +      m_packet_count++;
  1417. +    }
  1418. +    else
  1419. +    {
  1420. +      CLog::Log(LOGERROR, "%s::%s decoder buffer full. frame dropped\n" , CLASSNAME, __func__);
  1421. +    }
  1422. +  }
  1423. +
  1424. +  int ret = 0;
  1425. +
  1426. +  if(m_cedarDecoder->FreeFrames() > 1 && m_cedarDecoder->ReadyBuffers() && m_packet_count > 1)
  1427. +  {
  1428. +    //unsigned int start = XbmcThreads::SystemClockMillis();
  1429. +    s32 decoderRet = m_cedarDecoder->Decode(false, pts);
  1430. +    //int lastDecodeTime = XbmcThreads::SystemClockMillis() - start;
  1431. +    if(decoderRet == VRESULT_ERR_NO_MEMORY || decoderRet == VRESULT_ERR_UNSUPPORTED)
  1432. +    {
  1433. +      CLog::Log(LOGERROR, "%s::%s bitstream unsupported\n", CLASSNAME, __func__);
  1434. +      return VC_ERROR;
  1435. +    }
  1436. +    //if(lastDecodeTime > 40)
  1437. +    //  printf("decode tooked %3d ms\n", lastDecodeTime);
  1438. +    
  1439. +    switch(decoderRet)
  1440. +    {
  1441. +      case VRESULT_OK:
  1442. +      case VRESULT_FRAME_DECODED:
  1443. +      case VRESULT_KEYFRAME_DECODED:
  1444. +      case VRESULT_NO_BITSTREAM:
  1445. +        ret |= VC_BUFFER;
  1446. +        break;
  1447. +      default:
  1448. +        break;
  1449. +    }
  1450. +  }
  1451. +
  1452. +  if(m_cedarDecoder->ReadyFrames())
  1453. +    ret |= VC_PICTURE;
  1454. +
  1455. +  return ret;
  1456. +}
  1457. +
  1458. +bool CDVDVideoCodecCedar::GetPicture(DVDVideoPicture *pDvdVideoPicture)
  1459. +{
  1460. +  // clone the video picture buffer settings.
  1461. +  bool bRet = false;
  1462. +
  1463. +  vpicture_t *picture = m_cedarDecoder->GetDisplayFrame();
  1464. +  if(picture)
  1465. +  {
  1466. +    m_cedarPicture.Picture  = picture;
  1467. +    m_videobuffer.cedarPicture = &m_cedarPicture;
  1468. +  
  1469. +    /* set ref on the frame */
  1470. +
  1471. +    m_videobuffer.format          = RENDER_FMT_BYPASS_CEDAR;
  1472. +    m_videobuffer.pts             = DVD_NOPTS_VALUE;
  1473. +    m_videobuffer.dts             = DVD_NOPTS_VALUE;
  1474. +
  1475. +    if(m_valid_pts)
  1476. +      m_videobuffer.pts           = m_cedarPicture.Picture->pts * 1000;
  1477. +
  1478. +    if (!m_dts_queue.empty())
  1479. +    {
  1480. +      m_videobuffer.dts = m_dts_queue.front();
  1481. +      m_dts_queue.pop();
  1482. +    }
  1483. +
  1484. +    //printf("pts %f dts %f\n", m_videobuffer.pts, m_videobuffer.dts);
  1485. +
  1486. +    m_videobuffer.iDisplayWidth   = m_decoded_width;
  1487. +    m_videobuffer.iDisplayHeight  = m_decoded_height;
  1488. +    m_videobuffer.iWidth          = m_cedarPicture.Picture->width;
  1489. +    m_videobuffer.iHeight         = m_cedarPicture.Picture->height;
  1490. +
  1491. +    m_videobuffer.data[0]         = m_cedarPicture.Picture->y;
  1492. +    m_videobuffer.data[1]         = m_cedarPicture.Picture->u;
  1493. +    m_videobuffer.data[2]         = m_cedarPicture.Picture->u;
  1494. +    m_videobuffer.iLineSize[0]    = m_cedarPicture.Picture->width;
  1495. +    m_videobuffer.iLineSize[1]    = m_cedarPicture.Picture->height / 2;
  1496. +    m_videobuffer.iLineSize[2]    = m_cedarPicture.Picture->height / 2;
  1497. +
  1498. +    m_videobuffer.iFlags          = DVP_FLAG_ALLOCATED;
  1499. +    /*
  1500. +    m_videobuffer.iFlags          |= m_drop_state ? DVP_FLAG_DROPPED : 0;
  1501. +    */
  1502. +
  1503. +    bRet = true;
  1504. +  }
  1505. +  else
  1506. +  {
  1507. +    m_videobuffer.cedarPicture    = NULL;
  1508. +    m_videobuffer.iFlags          = DVP_FLAG_DROPPED;
  1509. +  }
  1510. +
  1511. +  *pDvdVideoPicture = m_videobuffer;
  1512. +
  1513. +  return bRet;
  1514. +}
  1515. +
  1516. +bool CDVDVideoCodecCedar::ClearPicture(DVDVideoPicture* pDvdVideoPicture)
  1517. +{
  1518. +  if(pDvdVideoPicture->cedarPicture != NULL)
  1519. +  {
  1520. +    m_cedarDecoder->ReturnDisplayFrame(pDvdVideoPicture->cedarPicture->Picture);
  1521. +  }
  1522. +  pDvdVideoPicture->cedarPicture = NULL;
  1523. +
  1524. +  return CDVDVideoCodec::ClearPicture(pDvdVideoPicture);
  1525. +}
  1526. +
  1527. +void CDVDVideoCodecCedar::Reset(void)
  1528. +{
  1529. +  if(m_cedarDecoder)
  1530. +    m_cedarDecoder->Flush();
  1531. +}
  1532. +
  1533. +#endif
  1534. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.h xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.h
  1535. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.h 1970-01-01 01:00:00.000000000 +0100
  1536. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.h   2013-06-17 16:16:23.000000000 +0200
  1537. @@ -0,0 +1,92 @@
  1538. +/*
  1539. + *      Copyright (C) 2012 Team XBMC
  1540. + *      http://www.xbmc.org
  1541. + *
  1542. + *  This Program is free software; you can redistribute it and/or modify
  1543. + *  it under the terms of the GNU General Public License as published by
  1544. + *  the Free Software Foundation; either version 2, or (at your option)
  1545. + *  any later version.
  1546. + *
  1547. + *  This Program is distributed in the hope that it will be useful,
  1548. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1549. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1550. + *  GNU General Public License for more details.
  1551. + *
  1552. + *  You should have received a copy of the GNU General Public License
  1553. + *  along with XBMC; see the file COPYING.  If not, write to
  1554. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1555. + *  http://www.gnu.org/copyleft/gpl.html
  1556. + *
  1557. + */
  1558. +
  1559. +#pragma once
  1560. +
  1561. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  1562. +  #include "config.h"
  1563. +#elif defined(_WIN32)
  1564. +#include "system.h"
  1565. +#endif
  1566. +
  1567. +#if defined(HAVE_LIBCEDAR)
  1568. +
  1569. +#include "DVDVideoCodec.h"
  1570. +#include <libcedar/CedarDecoder.h>
  1571. +#include "DllLibCedar.h"
  1572. +#include "threads/Thread.h"
  1573. +#include "threads/SingleLock.h"
  1574. +#include "DllAvFormat.h"
  1575. +
  1576. +#include <list>
  1577. +#include <vector>
  1578. +#include <queue>
  1579. +#include <deque>
  1580. +
  1581. +class CDVDVideoCodecCedar;
  1582. +class CBitstreamConverter;
  1583. +
  1584. +typedef struct CedarPicture
  1585. +{
  1586. +  vpicture_t *Picture;
  1587. +} CedarPicture;
  1588. +
  1589. +class CDVDVideoCodecCedar : public CDVDVideoCodec
  1590. +{
  1591. +public:
  1592. +  CDVDVideoCodecCedar();
  1593. +  ~CDVDVideoCodecCedar();
  1594. +
  1595. +  // Required overrides
  1596. +  bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
  1597. +  void Dispose(void);
  1598. +  int  Decode(uint8_t *pData, int iSize, double dts, double pts);
  1599. +  void Reset(void);
  1600. +  void SetDropState(bool bDrop);
  1601. +  bool GetPicture(DVDVideoPicture *pDvdVideoPicture);
  1602. +  bool ClearPicture(DVDVideoPicture* pDvdVideoPicture);
  1603. +  const char* GetName() { return m_video_codec_name.c_str(); };
  1604. +  void Process();
  1605. +protected:
  1606. +  // Video format
  1607. +  bool                            m_drop_state;
  1608. +  unsigned int                    m_decoded_width;
  1609. +  unsigned int                    m_decoded_height;
  1610. +  CStdString                      m_video_codec_name;
  1611. +  bool                            m_valid_pts;
  1612. +  uint64_t                        m_packet_count;
  1613. +  bool                            m_is_open;
  1614. +
  1615. +  unsigned int m_input_size;
  1616. +
  1617. +  std::queue<double> m_dts_queue;
  1618. +
  1619. +  CCedarDecoder                   *m_cedarDecoder;
  1620. +  CBitstreamConverter             *m_converter;
  1621. +  bool                            m_convert;
  1622. +  DllLibCedar                     m_dllCedar;
  1623. +  DVDVideoPicture                 m_videobuffer;
  1624. +  CedarPicture                    m_cedarPicture;
  1625. +
  1626. +  bool NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize);
  1627. +};
  1628. +
  1629. +#endif
  1630. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
  1631. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h  2013-06-17 16:17:17.000000000 +0200
  1632. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h    2013-06-17 16:16:23.000000000 +0200
  1633. @@ -37,6 +37,7 @@
  1634.  class CVDPAU;
  1635.  class COpenMax;
  1636.  class COpenMaxVideo;
  1637. +struct CedarPicture;
  1638.  struct OpenMaxVideoBuffer;
  1639.  
  1640.  // should be entirely filled by all codecs
  1641. @@ -71,6 +72,8 @@
  1642.      };
  1643.    };
  1644.  
  1645. +  CedarPicture *cedarPicture;
  1646. +
  1647.    unsigned int iFlags;
  1648.  
  1649.    double       iRepeatPicture;
  1650. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
  1651. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in  2013-06-17 16:17:17.000000000 +0200
  1652. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in    2013-06-17 16:16:23.000000000 +0200
  1653. @@ -22,6 +22,12 @@
  1654.  SRCS += OpenMaxVideo.cpp
  1655.  SRCS += DVDVideoCodecOpenMax.cpp
  1656.  endif
  1657. +ifeq (@USE_CEDAR@,1)
  1658. +SRCS += DVDVideoCodecCedar.cpp \
  1659. +        CedarOverlayManager.cpp \
  1660. +
  1661. +endif
  1662. +
  1663.  
  1664.  LIB=Video.a
  1665.  
  1666. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDFileInfo.cpp xbmc_huceke/xbmc/cores/dvdplayer/DVDFileInfo.cpp
  1667. --- xbmc_orig/xbmc/cores/dvdplayer/DVDFileInfo.cpp  2013-06-17 16:17:17.000000000 +0200
  1668. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDFileInfo.cpp    2013-06-17 16:16:23.000000000 +0200
  1669. @@ -162,6 +162,11 @@
  1670.      CDVDStreamInfo hint(*pDemuxer->GetStream(nVideoStream), true);
  1671.      hint.software = true;
  1672.  
  1673. +#if defined(HAVE_LIBCEDAR)
  1674. +    // libmpeg2 is not thread safe so use ffmepg for mpeg2/mpeg1 thumb extraction
  1675. +    CDVDCodecOptions dvdOptions;
  1676. +    pVideoCodec = CDVDFactoryCodec::OpenCodec(new CDVDVideoCodecFFmpeg(), hint, dvdOptions);
  1677. +#else
  1678.      if (hint.codec == CODEC_ID_MPEG2VIDEO || hint.codec == CODEC_ID_MPEG1VIDEO)
  1679.      {
  1680.        // libmpeg2 is not thread safe so use ffmepg for mpeg2/mpeg1 thumb extraction
  1681. @@ -172,7 +177,7 @@
  1682.      {
  1683.        pVideoCodec = CDVDFactoryCodec::CreateVideoCodec( hint );
  1684.      }
  1685. -
  1686. +#endif
  1687.      if (pVideoCodec)
  1688.      {
  1689.        int nTotalLen = pDemuxer->GetStreamLength();
  1690. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc_huceke/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
  1691. --- xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp   2013-06-17 16:17:17.000000000 +0200
  1692. +++ xbmc_huceke/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2013-06-17 16:16:23.000000000 +0200
  1693. @@ -280,6 +280,10 @@
  1694.    CLog::Log(LOGNOTICE, "deleting video codec");
  1695.    if (m_pVideoCodec)
  1696.    {
  1697. +#if defined(HAS_VIDEO_PLAYBACK) && defined(HAVE_LIBCEDAR)
  1698. +    /* cose renderer before decoder, the renderer could hold data from the decoder */
  1699. +    g_renderManager.UnInit();
  1700. +#endif
  1701.      m_pVideoCodec->Dispose();
  1702.      delete m_pVideoCodec;
  1703.      m_pVideoCodec = NULL;
  1704. @@ -1127,6 +1131,9 @@
  1705.        case RENDER_FMT_BYPASS:
  1706.          formatstr = "BYPASS";
  1707.          break;
  1708. +      case RENDER_FMT_BYPASS_CEDAR:
  1709. +        formatstr = "BYPASS_CEDAR";
  1710. +        break;
  1711.        case RENDER_FMT_NONE:
  1712.          formatstr = "NONE";
  1713.          break;
  1714. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/Makefile.in xbmc_huceke/xbmc/cores/VideoRenderers/Makefile.in
  1715. --- xbmc_orig/xbmc/cores/VideoRenderers/Makefile.in 2013-06-12 16:21:05.000000000 +0200
  1716. +++ xbmc_huceke/xbmc/cores/VideoRenderers/Makefile.in   2013-06-17 16:16:23.000000000 +0200
  1717. @@ -14,8 +14,11 @@
  1718.  endif
  1719.  
  1720.  ifeq (@USE_OPENGLES@,1)
  1721. +SRCS += OverlayRendererGL.cpp \
  1722. +ifeq (@USE_CEDAR@,1)
  1723. +SRCS += OverlayRendererCedar.cpp \
  1724. +else
  1725.  SRCS += LinuxRendererGLES.cpp
  1726. -SRCS += OverlayRendererGL.cpp
  1727.  endif
  1728.  
  1729.  LIB = VideoRenderer.a
  1730. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererCedar.cpp xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererCedar.cpp
  1731. --- xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererCedar.cpp    1970-01-01 01:00:00.000000000 +0100
  1732. +++ xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererCedar.cpp  2013-06-17 16:16:23.000000000 +0200
  1733. @@ -0,0 +1,529 @@
  1734. +/*
  1735. + *      Copyright (C) 2012 Team XBMC
  1736. + *      http://www.solid-run.com
  1737. + *
  1738. + *  This Program is free software; you can redistribute it and/or modify
  1739. + *  it under the terms of the GNU General Public License as published by
  1740. + *  the Free Software Foundation; either version 2, or (at your option)
  1741. + *  any later version.
  1742. + *
  1743. + *  This Program is distributed in the hope that it will be useful,
  1744. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1745. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1746. + *  GNU General Public License for more details.
  1747. + *
  1748. + *  You should have received a copy of the GNU General Public License
  1749. + *  along with XBMC; see the file COPYING.  If not, write to
  1750. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1751. + *  http://www.gnu.org/copyleft/gpl.html
  1752. + *
  1753. + * Original Dove Overlay Rendere written by Rabeeh Khoury from Solid-Run <support@solid-run.com>
  1754. + *
  1755. + */
  1756. +
  1757. +#include "system.h"
  1758. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  1759. +#include "config.h"
  1760. +#endif
  1761. +
  1762. +#if defined(HAVE_LIBCEDAR)
  1763. +
  1764. +#include "system_gl.h"
  1765. +#include "OverlayRendererCedar.h"
  1766. +#include "drv_display_sun4i.h"
  1767. +#include "utils/log.h"
  1768. +#include <stdlib.h>
  1769. +#include <malloc.h>
  1770. +#include "utils/fastmemcpy.h"
  1771. +#include "guilib/GraphicContext.h"
  1772. +#include "utils/GLUtils.h"
  1773. +#include "threads/Thread.h"
  1774. +
  1775. +#if defined(CLASSNAME)
  1776. +#undef CLASSNAME
  1777. +#endif
  1778. +
  1779. +#define CLASSNAME "COverlayRendererCedar"
  1780. +
  1781. +COverlayRendererCedar::YUVBUFFER::YUVBUFFER()
  1782. +{
  1783. +  memset(&image , 0, sizeof(image));
  1784. +  flipindex = 0;
  1785. +}
  1786. +
  1787. +COverlayRendererCedar::YUVBUFFER::~YUVBUFFER()
  1788. +{
  1789. +}
  1790. +
  1791. +COverlayRendererCedar::COverlayRendererCedar()
  1792. +{
  1793. +  for(int i = 0; i < NUM_BUFFERS; i++)
  1794. +  {
  1795. +    YV12Image &img = m_buffers[i].image;
  1796. +    img.plane[0]  = NULL;
  1797. +    img.plane[1]  = NULL;
  1798. +    img.plane[2]  = NULL;
  1799. +    m_buffers[i].cedarPicture  = NULL;
  1800. +  }
  1801. +  m_cedarDecoder = NULL;
  1802. +
  1803. +  UnInit();
  1804. +}
  1805. +
  1806. +COverlayRendererCedar::~COverlayRendererCedar()
  1807. +{
  1808. +  UnInit();
  1809. +}
  1810. +
  1811. +void COverlayRendererCedar::WaitFrame(int64_t frameId)
  1812. +{
  1813. +  if (!m_bConfigured) return;
  1814. +
  1815. +  unsigned int start = XbmcThreads::SystemClockMillis();
  1816. +  unsigned int end = 0;
  1817. +
  1818. +  while(m_overlayCedar.GetFrameID() != frameId)
  1819. +  {
  1820. +    Sleep(10);
  1821. +    end = XbmcThreads::SystemClockMillis() - start;
  1822. +    if(end > 30)
  1823. +      break;
  1824. +  }
  1825. +}
  1826. +
  1827. +void COverlayRendererCedar::ManageDisplay()
  1828. +{
  1829. +  CRect view;
  1830. +
  1831. +  view.x1 = (float)g_settings.m_ResInfo[m_resolution].Overscan.left;
  1832. +  view.y1 = (float)g_settings.m_ResInfo[m_resolution].Overscan.top;
  1833. +  view.x2 = (float)g_settings.m_ResInfo[m_resolution].Overscan.right;
  1834. +  view.y2 = (float)g_settings.m_ResInfo[m_resolution].Overscan.bottom;
  1835. +
  1836. +  m_sourceRect.x1 = (float)g_settings.m_currentVideoSettings.m_CropLeft;
  1837. +  m_sourceRect.y1 = (float)g_settings.m_currentVideoSettings.m_CropTop;
  1838. +  m_sourceRect.x2 = (float)m_sourceWidth - g_settings.m_currentVideoSettings.m_CropRight;
  1839. +  m_sourceRect.y2 = (float)m_sourceHeight - g_settings.m_currentVideoSettings.m_CropBottom;
  1840. +
  1841. +  CalcNormalDisplayRect(view.x1, view.y1, view.Width(), view.Height(), GetAspectRatio() * g_settings.m_fPixelRatio, g_settings.m_fZoomAmount, g_settings.m_fVerticalShift);
  1842. +
  1843. +  m_glRect.x1 = 0.0f;
  1844. +  m_glRect.y1 = 0.0f;
  1845. +  m_glRect.x2 = (float)g_settings.m_ResInfo[m_resolution].iWidth;
  1846. +  m_glRect.y2 = (float)g_settings.m_ResInfo[m_resolution].iHeight;
  1847. +
  1848. +  if(m_destRectOld != m_destRect || m_sourceRectOld != m_sourceRect)
  1849. +  {
  1850. +    m_destRectOld = m_destRect;
  1851. +    m_sourceRectOld = m_sourceRect;
  1852. +    m_overlayCedar.UpdatePos(m_destRect, m_sourceRect);
  1853. +  }
  1854. +}
  1855. +
  1856. +bool COverlayRendererCedar::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation)
  1857. +{
  1858. +  m_format = format;
  1859. +  m_renderOrientation = orientation;
  1860. +
  1861. +  if(!m_dllCedar.Load())
  1862. +    return false;
  1863. +
  1864. +  if (m_format != RENDER_FMT_YUV420P && m_format != RENDER_FMT_BYPASS_CEDAR)
  1865. +  {
  1866. +    CLog::Log(LOGERROR, "%s::%s - Bad format\n", CLASSNAME, __func__);
  1867. +    return false;
  1868. +  }
  1869. +
  1870. +  m_sourceWidth   = width;
  1871. +  m_sourceHeight  = height;
  1872. +  m_iFlags        = flags;
  1873. +
  1874. +  // Calculate the input frame aspect ratio.
  1875. +  CalculateFrameAspectRatio(d_width, d_height);
  1876. +  ChooseBestResolution(fps);
  1877. +  SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode);
  1878. +  ManageDisplay();
  1879. +
  1880. +  if(!m_overlayCedar.Open(m_destRect, m_sourceRect, m_format))
  1881. +  {
  1882. +    CLog::Log(LOGERROR, "%s::%s Cedar overlay open\n", CLASSNAME, __func__);
  1883. +    return false;
  1884. +  }
  1885. +
  1886. +  CLog::Log(LOGDEBUG, "m_sourceRect.x1 %f m_sourceRect.x2 %f m_sourceRect.y1 %f m_sourceRect.y2 %f m_sourceFrameRatio %f\n",
  1887. +      m_sourceRect.x1, m_sourceRect.x2, m_sourceRect.y1, m_sourceRect.y2, m_sourceFrameRatio);
  1888. +  CLog::Log(LOGDEBUG, "m_destRect.x1 %f m_destRect.x2 %f m_destRect.y1 %f m_destRect.y2 %f\n",
  1889. +      m_destRect.x1, m_destRect.x2, m_destRect.y1, m_destRect.y2);
  1890. +
  1891. +  m_enabled = 0;
  1892. +
  1893. +  for (unsigned int i = 0; i < NUM_BUFFERS; i++)
  1894. +  {
  1895. +    FreeYV12Image(i);
  1896. +    CreateYV12Image(i, m_sourceWidth, m_sourceHeight);
  1897. +  }
  1898. +
  1899. +  m_currentBuffer = 0;
  1900. +  m_bConfigured   = true;
  1901. +
  1902. +  CLog::Log(LOGDEBUG, "%s::%s - Proper format, continuing\n", CLASSNAME, __func__);
  1903. +
  1904. +  return m_bConfigured;
  1905. +}
  1906. +
  1907. +unsigned int COverlayRendererCedar::PreInit()
  1908. +{
  1909. +  UnInit();
  1910. +
  1911. +  m_currentBuffer = 0;
  1912. +
  1913. +  m_resolution = g_guiSettings.m_LookAndFeelResolution;
  1914. +  if ( m_resolution == RES_WINDOW )
  1915. +    m_resolution = RES_DESKTOP;
  1916. +
  1917. +  return true;
  1918. +}
  1919. +
  1920. +int COverlayRendererCedar::GetImage(YV12Image *image, int source, bool readonly)
  1921. +{
  1922. +  if(!image)
  1923. +    return -1;
  1924. +
  1925. +  /* take next available buffer */
  1926. +  if( source == AUTOSOURCE)
  1927. +    source = NextYV12Image();
  1928. +
  1929. +  YV12Image &im = m_buffers[source].image;
  1930. +
  1931. +  for(int p = 0; p < MAX_PLANES; p++)
  1932. +  {
  1933. +    image->plane[p]  = im.plane[p];
  1934. +    image->stride[p] = im.stride[p];
  1935. +  }
  1936. +
  1937. +  image->width    = im.width;
  1938. +  image->height   = im.height;
  1939. +  image->flags    = im.flags;
  1940. +  image->cshift_x = im.cshift_x;
  1941. +  image->cshift_y = im.cshift_y;
  1942. +
  1943. +  return source;
  1944. +}
  1945. +
  1946. +void COverlayRendererCedar::ReleaseImage(int source, bool preserve)
  1947. +{
  1948. +  /*
  1949. +  CedarPicture *cedarPicture = m_buffers[source].cedarPicture;
  1950. +  if(cedarPicture)
  1951. +  {
  1952. +    m_buffers[source].cedarPicture = NULL;
  1953. +  }
  1954. +  */
  1955. +}
  1956. +
  1957. +void COverlayRendererCedar::FlipPage(int source)
  1958. +{
  1959. +  if (!m_bConfigured)
  1960. +    return;
  1961. +
  1962. +  /*
  1963. +  CedarPicture *cedarPicture = NULL;
  1964. +  cedarPicture = m_buffers[m_currentBuffer].cedarPicture;
  1965. +  */
  1966. +
  1967. +  /* switch source */
  1968. +  if( source >= 0 && source < NUM_BUFFERS )
  1969. +    m_currentBuffer = source;
  1970. +  else
  1971. +    m_currentBuffer = NextYV12Image();
  1972. +
  1973. +  /*
  1974. +  if(cedarPicture && cedarPicture->Picture)
  1975. +  {
  1976. +    vpicture_t *picture = cedarPicture->Picture;
  1977. +
  1978. +    __disp_pixel_fmt_t pixel_format = picture->pixel_format == PIXEL_FORMAT_AW_YUV422 ? DISP_FORMAT_YUV422 : DISP_FORMAT_YUV420;
  1979. +
  1980. +    m_overlayCedar.RenderFrame((unsigned int)picture->y, (unsigned int)picture->u, (unsigned int)picture->v,
  1981. +        (unsigned int)picture->size_y, (unsigned int)picture->size_u, (unsigned int)picture->size_v,
  1982. +        pixel_format, picture->frame_rate, m_pictureCount);
  1983. +    m_overlayCedar.WaitVSYNC();
  1984. +    WaitFrame(m_pictureCount);
  1985. +    m_pictureCount++;
  1986. +  }
  1987. +  */
  1988. +}
  1989. +
  1990. +void COverlayRendererCedar::Reset()
  1991. +{
  1992. +}
  1993. +
  1994. +void COverlayRendererCedar::Update(bool bPauseDrawing)
  1995. +{
  1996. +  if (!m_bConfigured) return;
  1997. +  ManageDisplay();
  1998. +}
  1999. +
  2000. +void COverlayRendererCedar::AddProcessor(DVDVideoPicture &pic)
  2001. +{
  2002. +  if (!m_bConfigured) return;
  2003. +
  2004. +  //printf("COverlayRendererCedar::AddProcessor %d\n", NextYV12Image());
  2005. +  YUVBUFFER &buf = m_buffers[NextYV12Image()];
  2006. +
  2007. +  if(m_format == RENDER_FMT_YUV420P)
  2008. +  {
  2009. +    if(!m_cedarDecoder)
  2010. +      m_cedarDecoder = m_dllCedar.AllocCedarDecoder();
  2011. +
  2012. +    /* allocate softpicture */
  2013. +    if(!buf.cedarPicture)
  2014. +    {
  2015. +      buf.cedarPicture = (CedarPicture*)malloc(sizeof(CedarPicture));
  2016. +      memset(buf.cedarPicture, 0, sizeof(CedarPicture));
  2017. +
  2018. +      vpicture_t *softPicture = (vpicture_t*)malloc(sizeof(vpicture_t));
  2019. +      memset(softPicture, 0, sizeof(vpicture_t));
  2020. +
  2021. +      buf.cedarPicture->Picture  = softPicture;
  2022. +
  2023. +      /* setup framebuffer picture */
  2024. +      softPicture->size_y = (pic.iWidth * pic.iHeight);
  2025. +      softPicture->size_u = pic.iWidth * pic.iHeight / 4;
  2026. +      softPicture->size_v = pic.iWidth * pic.iHeight / 4;
  2027. +
  2028. +      softPicture->y = (u8*)m_cedarDecoder->MemPalloc(softPicture->size_y, 1024);
  2029. +      softPicture->u = (u8*)m_cedarDecoder->MemPalloc(softPicture->size_u, 1024);
  2030. +      softPicture->v = (u8*)m_cedarDecoder->MemPalloc(softPicture->size_v, 1024);
  2031. +
  2032. +      softPicture->pixel_format     = PIXEL_FORMAT_AW_YUV420;
  2033. +      softPicture->store_width      = pic.iWidth;
  2034. +      softPicture->store_height     = pic.iHeight;
  2035. +      softPicture->display_width    = pic.iWidth;
  2036. +      softPicture->display_height   = pic.iHeight;
  2037. +      softPicture->width            = pic.iWidth;
  2038. +      softPicture->height           = pic.iHeight;
  2039. +      softPicture->aspect_ratio     = 1000;
  2040. +
  2041. +      softPicture->id = m_pictureCount++;
  2042. +    }
  2043. +
  2044. +    /* copy to virtual adress */
  2045. +
  2046. +    int i = 0;
  2047. +    unsigned char *src = pic.data[0];
  2048. +    unsigned char *dst = buf.cedarPicture->Picture->y;
  2049. +    int w = pic.iWidth;
  2050. +    int h = pic.iHeight;
  2051. +    for(i = 0; i < h; i++)
  2052. +    {
  2053. +      fast_memcpy(dst, src, w);
  2054. +      src += pic.iLineSize[0];
  2055. +      dst += pic.iWidth;
  2056. +    }
  2057. +
  2058. +    src = pic.data[1];
  2059. +    dst = buf.cedarPicture->Picture->u;
  2060. +
  2061. +    w >>= 1;
  2062. +    h >>= 1;
  2063. +
  2064. +    if(w == pic.iLineSize[1])
  2065. +    {
  2066. +        fast_memcpy(dst, src, w*h);
  2067. +    }
  2068. +    else
  2069. +    {
  2070. +      for(i = 0; i < h; i++)
  2071. +      {
  2072. +        fast_memcpy(dst, src, w);
  2073. +        dst  += w;
  2074. +        src  += pic.iLineSize[1];
  2075. +      }
  2076. +    }
  2077. +
  2078. +    src = pic.data[2];
  2079. +    dst = buf.cedarPicture->Picture->v;
  2080. +
  2081. +    if(w == pic.iLineSize[1])
  2082. +    {
  2083. +        fast_memcpy(dst, src, w*h);
  2084. +    }
  2085. +    else
  2086. +    {
  2087. +      for(i = 0; i < h; i++)
  2088. +      {
  2089. +        fast_memcpy(dst, src, w);
  2090. +        dst  += w;
  2091. +        src  += pic.iLineSize[2];
  2092. +      }
  2093. +    }
  2094. +  }
  2095. +  else
  2096. +  {
  2097. +    if(pic.cedarPicture)
  2098. +      buf.cedarPicture = pic.cedarPicture;
  2099. +  }
  2100. +
  2101. +  CedarPicture *cedarPicture = buf.cedarPicture;
  2102. +  if(cedarPicture && cedarPicture->Picture)
  2103. +  {
  2104. +    vpicture_t *picture = cedarPicture->Picture;
  2105. +
  2106. +    __disp_pixel_fmt_t pixel_format = picture->pixel_format == PIXEL_FORMAT_AW_YUV422 ? DISP_FORMAT_YUV422 : DISP_FORMAT_YUV420;
  2107. +
  2108. +    m_overlayCedar.RenderFrame((unsigned int)picture->y, (unsigned int)picture->u, (unsigned int)picture->v,
  2109. +        (unsigned int)picture->size_y, (unsigned int)picture->size_u, (unsigned int)picture->size_v,
  2110. +        pixel_format, picture->frame_rate, m_pictureCount);
  2111. +    m_overlayCedar.WaitVSYNC();
  2112. +    //WaitFrame(m_pictureCount);
  2113. +    m_pictureCount++;
  2114. +  }
  2115. +}
  2116. +
  2117. +void COverlayRendererCedar::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
  2118. +{
  2119. +  if (!m_bConfigured) return;
  2120. +
  2121. +  g_graphicsContext.BeginPaint();
  2122. +
  2123. +  glEnable(GL_BLEND);
  2124. +  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  2125. +  glClearColor(0, 0, 0, 0);
  2126. +  glClear(GL_COLOR_BUFFER_BIT);
  2127. +
  2128. +  g_graphicsContext.EndPaint();
  2129. +}
  2130. +
  2131. +bool COverlayRendererCedar::RenderCapture(CRenderCapture* capture)
  2132. +{
  2133. +  CLog::Log(LOGERROR, "%s::%s - Not implemented\n", CLASSNAME, __func__);
  2134. +  return true;
  2135. +}
  2136. +
  2137. +void COverlayRendererCedar::UnInit()
  2138. +{
  2139. +  CLog::Log(LOGDEBUG, "%s::%s\n", CLASSNAME, __func__);
  2140. +
  2141. +  WaitFrame(m_pictureCount);
  2142. +
  2143. +  for(int i = 0; i < NUM_BUFFERS; i++)
  2144. +    FreeYV12Image(i);
  2145. +
  2146. +  m_overlayCedar.Close();
  2147. +
  2148. +  m_currentBuffer           = 0;
  2149. +  m_iFlags                  = 0;
  2150. +  m_bConfigured             = false;
  2151. +  m_sourceWidth             = 0;
  2152. +  m_sourceHeight            = 0;
  2153. +  m_pictureCount            = 0;
  2154. +  m_timeOut                 = 0;
  2155. +  m_format                  = RENDER_FMT_NONE;
  2156. +
  2157. +  if(m_cedarDecoder)
  2158. +    m_cedarDecoder = m_dllCedar.FreeCedarDecoder(m_cedarDecoder);
  2159. +
  2160. +  m_dllCedar.Unload();
  2161. +}
  2162. +
  2163. +void COverlayRendererCedar::CreateThumbnail(CBaseTexture* texture, unsigned int width, unsigned int height)
  2164. +{
  2165. +  CLog::Log(LOGDEBUG, "%s::%s Was asked to create thumbnail (width = %d, height = %d\n",
  2166. +      CLASSNAME, __func__, width, height);
  2167. +}
  2168. +
  2169. +bool COverlayRendererCedar::Supports(EDEINTERLACEMODE mode)
  2170. +{
  2171. +  return false;
  2172. +}
  2173. +
  2174. +bool COverlayRendererCedar::Supports(ERENDERFEATURE feature)
  2175. +{
  2176. +  return false;
  2177. +}
  2178. +
  2179. +bool COverlayRendererCedar::SupportsMultiPassRendering()
  2180. +{
  2181. +  return false;
  2182. +}
  2183. +
  2184. +bool COverlayRendererCedar::Supports(EINTERLACEMETHOD method)
  2185. +{
  2186. +  return false;
  2187. +}
  2188. +
  2189. +bool COverlayRendererCedar::Supports(ESCALINGMETHOD method)
  2190. +{
  2191. +  if(method == VS_SCALINGMETHOD_NEAREST || method == VS_SCALINGMETHOD_LINEAR)
  2192. +    return true;
  2193. +
  2194. +  return false;
  2195. +}
  2196. +
  2197. +EINTERLACEMETHOD COverlayRendererCedar::AutoInterlaceMethod()
  2198. +{
  2199. +  return VS_INTERLACEMETHOD_NONE;
  2200. +}
  2201. +
  2202. +unsigned int COverlayRendererCedar::NextYV12Image()
  2203. +{
  2204. +  return (m_currentBuffer + 1) % NUM_BUFFERS;
  2205. +}
  2206. +
  2207. +bool COverlayRendererCedar::CreateYV12Image(unsigned int index, unsigned int width, unsigned int height)
  2208. +{
  2209. +  YV12Image &im = m_buffers[index].image;
  2210. +
  2211. +  im.width  = width;
  2212. +  im.height = height;
  2213. +  im.cshift_x = 1;
  2214. +  im.cshift_y = 1;
  2215. +
  2216. +  unsigned paddedWidth = (im.width + 15) & ~15;
  2217. +
  2218. +  im.stride[0] = paddedWidth;
  2219. +  im.stride[1] = paddedWidth >> im.cshift_x;
  2220. +  im.stride[2] = paddedWidth >> im.cshift_x;
  2221. +
  2222. +  im.planesize[0] = im.stride[0] * im.height;
  2223. +  im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
  2224. +  im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
  2225. +
  2226. +  return true;
  2227. +}
  2228. +
  2229. +bool COverlayRendererCedar::FreeYV12Image(unsigned int index)
  2230. +{
  2231. +  YV12Image &im = m_buffers[index].image;
  2232. +
  2233. +  for (int i = 0; i < MAX_PLANES; i++)
  2234. +  {
  2235. +    im.plane[i] = NULL;
  2236. +  }
  2237. +
  2238. +  if(m_buffers[index].cedarPicture)
  2239. +  {
  2240. +    if(m_format == RENDER_FMT_YUV420P)
  2241. +    {
  2242. +      vpicture_t *picture = m_buffers[index].cedarPicture->Picture;
  2243. +
  2244. +      if(picture->y)
  2245. +        m_cedarDecoder->MemPfree(picture->u);
  2246. +      if(picture->u)
  2247. +        m_cedarDecoder->MemPfree(picture->v);
  2248. +      if(picture->v)
  2249. +        m_cedarDecoder->MemPfree(picture->v);
  2250. +
  2251. +      free(m_buffers[index].cedarPicture->Picture);
  2252. +      free(m_buffers[index].cedarPicture);
  2253. +    }
  2254. +  }
  2255. +  m_buffers[index].cedarPicture = NULL;
  2256. +
  2257. +  memset(&im , 0, sizeof(YV12Image));
  2258. +
  2259. +  return true;
  2260. +}
  2261. +
  2262. +#endif
  2263. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererCedar.h xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererCedar.h
  2264. --- xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererCedar.h  1970-01-01 01:00:00.000000000 +0100
  2265. +++ xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererCedar.h    2013-06-17 16:16:23.000000000 +0200
  2266. @@ -0,0 +1,181 @@
  2267. +/*
  2268. + *      Copyright (C) 2012 Team XBMC
  2269. + *      http://xbmc.org
  2270. + *
  2271. + *  This Program is free software; you can redistribute it and/or modify
  2272. + *  it under the terms of the GNU General Public License as published by
  2273. + *  the Free Software Foundation; either version 2, or (at your option)
  2274. + *  any later version.
  2275. + *
  2276. + *  This Program is distributed in the hope that it will be useful,
  2277. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2278. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2279. + *  GNU General Public License for more details.
  2280. + *
  2281. + *  You should have received a copy of the GNU General Public License
  2282. + *  along with XBMC; see the file COPYING.  If not, write to
  2283. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  2284. + *  http://www.gnu.org/copyleft/gpl.html
  2285. + *
  2286. + */
  2287. +
  2288. +#pragma once
  2289. +
  2290. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  2291. +  #include "config.h"
  2292. +#elif defined(_WIN32)
  2293. +#include "system.h"
  2294. +#endif
  2295. +
  2296. +#if defined(HAVE_LIBCEDAR)
  2297. +
  2298. +#undef __u8
  2299. +#undef byte
  2300. +
  2301. +#include "../../settings/VideoSettings.h"
  2302. +#include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
  2303. +#include "RenderFlags.h"
  2304. +#include "BaseRenderer.h"
  2305. +#include "settings/GUISettings.h"
  2306. +#include "settings/Settings.h"
  2307. +
  2308. +#include "cores/dvdplayer/DVDCodecs/Video/CedarOverlayManager.h"
  2309. +#include "cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCedar.h"
  2310. +
  2311. +class CRenderCapture;
  2312. +class CBaseTexture;
  2313. +
  2314. +extern "C"
  2315. +{
  2316. +#include <sys/ioctl.h>
  2317. +#include <linux/fb.h>
  2318. +#include "drv_display_sun4i.h"
  2319. +}
  2320. +
  2321. +struct DRAWRECT
  2322. +{
  2323. +  float left;
  2324. +  float top;
  2325. +  float right;
  2326. +  float bottom;
  2327. +};
  2328. +
  2329. +struct YUVRANGE
  2330. +{
  2331. +  int y_min, y_max;
  2332. +  int u_min, u_max;
  2333. +  int v_min, v_max;
  2334. +};
  2335. +
  2336. +struct YUVCOEF
  2337. +{
  2338. +  float r_up, r_vp;
  2339. +  float g_up, g_vp;
  2340. +  float b_up, b_vp;
  2341. +};
  2342. +
  2343. +#define AUTOSOURCE -1
  2344. +
  2345. +#define PLANE_Y 0
  2346. +#define PLANE_U 1
  2347. +#define PLANE_V 2
  2348. +
  2349. +#define FIELD_FULL 0
  2350. +#define FIELD_ODD 1
  2351. +#define FIELD_EVEN 2
  2352. +
  2353. +#define NUM_BUFFERS 2
  2354. +
  2355. +extern YUVRANGE yuv_range_lim;
  2356. +extern YUVRANGE yuv_range_full;
  2357. +extern YUVCOEF yuv_coef_bt601;
  2358. +extern YUVCOEF yuv_coef_bt709;
  2359. +extern YUVCOEF yuv_coef_ebu;
  2360. +extern YUVCOEF yuv_coef_smtp240m;
  2361. +
  2362. +class COverlayRendererCedar : public CBaseRenderer
  2363. +{
  2364. +  public:
  2365. +    COverlayRendererCedar();
  2366. +    virtual ~COverlayRendererCedar();
  2367. +
  2368. +    virtual void Update(bool bPauseDrawing);
  2369. +    virtual void SetupScreenshot() {};
  2370. +
  2371. +    bool RenderCapture(CRenderCapture* capture);
  2372. +
  2373. +    void CreateThumbnail(CBaseTexture *texture, unsigned int width, unsigned int height);
  2374. +
  2375. +    // Player functions
  2376. +    virtual void ManageDisplay();
  2377. +    bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height,
  2378. +        float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation);
  2379. +    virtual bool IsConfigured() { return m_bConfigured; }
  2380. +    virtual int          GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
  2381. +    virtual void         ReleaseImage(int source, bool preserve = false);
  2382. +    virtual void         FlipPage(int source);
  2383. +    virtual unsigned int PreInit();
  2384. +    virtual void         UnInit();
  2385. +    virtual void         Reset(); /* resets renderer after seek for example */
  2386. +
  2387. +    virtual void         AddProcessor(DVDVideoPicture &pic);
  2388. +
  2389. +    virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
  2390. +
  2391. +    // Feature support
  2392. +    virtual bool SupportsMultiPassRendering();
  2393. +    virtual bool Supports(ERENDERFEATURE feature);
  2394. +    virtual bool Supports(EDEINTERLACEMODE mode);
  2395. +    virtual bool Supports(EINTERLACEMETHOD method);
  2396. +    virtual bool Supports(ESCALINGMETHOD method);
  2397. +
  2398. +    virtual EINTERLACEMETHOD AutoInterlaceMethod();
  2399. +
  2400. +  private:
  2401. +    void WaitFrame(int64_t frameId);
  2402. +
  2403. +    unsigned int NextYV12Image();
  2404. +    bool CreateYV12Image(unsigned int index, unsigned int width, unsigned int height);
  2405. +    bool FreeYV12Image(unsigned int index);
  2406. +
  2407. +    bool          m_bConfigured;
  2408. +    unsigned int  m_iFlags;
  2409. +
  2410. +    struct YUVBUFFER
  2411. +    {
  2412. +      YUVBUFFER();
  2413. +     ~YUVBUFFER();
  2414. +
  2415. +      YV12Image image;
  2416. +      unsigned  flipindex;
  2417. +
  2418. +      CedarPicture *cedarPicture;
  2419. +    };
  2420. +
  2421. +    YUVBUFFER     m_buffers[NUM_BUFFERS];
  2422. +    unsigned int  m_currentBuffer;
  2423. +
  2424. +    int                       m_enabled;
  2425. +
  2426. +    CCedarOverlayManager      m_overlayCedar;
  2427. +    CRect                     m_glRect;
  2428. +    CRect                     m_destRectOld;
  2429. +    CRect                     m_sourceRectOld;
  2430. +    int64_t                   m_pictureCount;
  2431. +    int                       m_timeOut;
  2432. +    ERenderFormat             m_format;
  2433. +    DllLibCedar               m_dllCedar;
  2434. +    CCedarDecoder             *m_cedarDecoder;
  2435. +};
  2436. +
  2437. +inline int NP2( unsigned x )
  2438. +{
  2439. +  --x;
  2440. +  x |= x >> 1;
  2441. +  x |= x >> 2;
  2442. +  x |= x >> 4;
  2443. +  x |= x >> 8;
  2444. +  x |= x >> 16;
  2445. +  return ++x;
  2446. +}
  2447. +#endif
  2448. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp
  2449. --- xbmc_orig/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp   2013-06-17 16:17:17.000000000 +0200
  2450. +++ xbmc_huceke/xbmc/cores/VideoRenderers/OverlayRendererGL.cpp 2013-06-17 16:16:23.000000000 +0200
  2451. @@ -26,7 +26,9 @@
  2452.  #ifdef HAS_GL
  2453.    #include "LinuxRendererGL.h"
  2454.  #elif HAS_GLES == 2
  2455. +#if !defined(HAVE_LIBCEDAR)
  2456.    #include "LinuxRendererGLES.h"
  2457. +#endif
  2458.    #include "guilib/MatrixGLES.h"
  2459.  #endif
  2460.  #include "RenderManager.h"
  2461. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h xbmc_huceke/xbmc/cores/VideoRenderers/RenderFormats.h
  2462. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h 2013-06-17 16:17:17.000000000 +0200
  2463. +++ xbmc_huceke/xbmc/cores/VideoRenderers/RenderFormats.h   2013-06-17 16:16:23.000000000 +0200
  2464. @@ -34,6 +34,7 @@
  2465.    RENDER_FMT_OMXEGL,
  2466.    RENDER_FMT_CVBREF,
  2467.    RENDER_FMT_BYPASS,
  2468. +  RENDER_FMT_BYPASS_CEDAR,
  2469.  };
  2470.  
  2471.  #endif
  2472. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc_huceke/xbmc/cores/VideoRenderers/RenderManager.cpp
  2473. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp   2013-06-17 16:17:17.000000000 +0200
  2474. +++ xbmc_huceke/xbmc/cores/VideoRenderers/RenderManager.cpp 2013-06-17 16:16:23.000000000 +0200
  2475. @@ -35,7 +35,9 @@
  2476.  #include "settings/GUISettings.h"
  2477.  #include "settings/AdvancedSettings.h"
  2478.  
  2479. -#if defined(HAS_GL)
  2480. +#if defined(HAVE_LIBCEDAR)
  2481. +  #include "OverlayRendererCedar.h"
  2482. +#elif defined(HAS_GL)
  2483.    #include "LinuxRendererGL.h"
  2484.  #elif HAS_GLES == 2
  2485.    #include "LinuxRendererGLES.h"
  2486. @@ -325,7 +327,9 @@
  2487.    m_bPauseDrawing = false;
  2488.    if (!m_pRenderer)
  2489.    {
  2490. -#if defined(HAS_GL)
  2491. +#if defined(HAVE_LIBCEDAR)
  2492. +    m_pRenderer = new COverlayRendererCedar();
  2493. +#elif defined(HAS_GL)
  2494.      m_pRenderer = new CLinuxRendererGL();
  2495.  #elif HAS_GLES == 2
  2496.      m_pRenderer = new CLinuxRendererGLES();
  2497. @@ -813,8 +817,18 @@
  2498.    || pic.format == RENDER_FMT_YUV420P10
  2499.    || pic.format == RENDER_FMT_YUV420P16)
  2500.    {
  2501. +#ifdef HAVE_LIBCEDAR
  2502. +    m_pRenderer->AddProcessor(pic);
  2503. +#else
  2504.      CDVDCodecUtils::CopyPicture(&image, &pic);
  2505. +#endif
  2506. +  }
  2507. +#ifdef HAVE_LIBCEDAR
  2508. +  else if(pic.format == RENDER_FMT_BYPASS_CEDAR)
  2509. +  {
  2510. +    m_pRenderer->AddProcessor(pic);
  2511.    }
  2512. +#endif
  2513.    else if(pic.format == RENDER_FMT_NV12)
  2514.    {
  2515.      CDVDCodecUtils::CopyNV12Picture(&image, &pic);
  2516. @@ -822,7 +836,11 @@
  2517.    else if(pic.format == RENDER_FMT_YUYV422
  2518.         || pic.format == RENDER_FMT_UYVY422)
  2519.    {
  2520. +#ifdef HAVE_LIBCEDAR
  2521. +    m_pRenderer->AddProcessor(pic);
  2522. +#else
  2523.      CDVDCodecUtils::CopyYUV422PackedPicture(&image, &pic);
  2524. +#endif
  2525.    }
  2526.    else if(pic.format == RENDER_FMT_DXVA)
  2527.    {
  2528. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h xbmc_huceke/xbmc/cores/VideoRenderers/RenderManager.h
  2529. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h 2013-06-17 16:17:17.000000000 +0200
  2530. +++ xbmc_huceke/xbmc/cores/VideoRenderers/RenderManager.h   2013-06-17 16:16:23.000000000 +0200
  2531. @@ -22,6 +22,12 @@
  2532.  
  2533.  #include <list>
  2534.  
  2535. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  2536. +  #include "config.h"
  2537. +#elif defined(_WIN32)
  2538. +#include "system.h"
  2539. +#endif
  2540. +
  2541.  #include "cores/VideoRenderers/BaseRenderer.h"
  2542.  #include "guilib/Geometry.h"
  2543.  #include "guilib/Resolution.h"
  2544. @@ -29,6 +35,9 @@
  2545.  #include "threads/Thread.h"
  2546.  #include "settings/VideoSettings.h"
  2547.  #include "OverlayRenderer.h"
  2548. +#if defined(HAVE_LIBCEDAR)
  2549. +  #include "OverlayRendererCedar.h"
  2550. +#endif
  2551.  
  2552.  class CRenderCapture;
  2553.  
  2554. @@ -43,6 +52,9 @@
  2555.  class CLinuxRenderer;
  2556.  class CLinuxRendererGL;
  2557.  class CLinuxRendererGLES;
  2558. +#if defined(HAVE_LIBCEDAR)
  2559. +class COverlayRenderCedar;
  2560. +#endif
  2561.  
  2562.  class CXBMCRenderManager
  2563.  {
  2564. @@ -110,7 +122,9 @@
  2565.  
  2566.    void UpdateResolution();
  2567.  
  2568. -#ifdef HAS_GL
  2569. +#if defined(HAVE_LIBCEDAR)
  2570. +  COverlayRendererCedar *m_pRenderer;
  2571. +#elif HAS_GL
  2572.    CLinuxRendererGL    *m_pRenderer;
  2573.  #elif HAS_GLES == 2
  2574.    CLinuxRendererGLES  *m_pRenderer;
  2575. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/utils/BitstreamConverter.cpp xbmc_huceke/xbmc/utils/BitstreamConverter.cpp
  2576. --- xbmc_orig/xbmc/utils/BitstreamConverter.cpp 2013-06-17 16:17:18.000000000 +0200
  2577. +++ xbmc_huceke/xbmc/utils/BitstreamConverter.cpp   2013-06-17 16:16:23.000000000 +0200
  2578. @@ -460,7 +460,8 @@
  2579.          // valid avcC atom data always starts with the value 1 (version)
  2580.          if ( *in_extradata != 1 )
  2581.          {
  2582. -          if (in_extradata[0] == 0 && in_extradata[1] == 0 && in_extradata[2] == 0 && in_extradata[3] == 1)
  2583. +          if ( (in_extradata[0] == 0 && in_extradata[1] == 0 && in_extradata[2] == 0 && in_extradata[3] == 1) ||
  2584. +               (in_extradata[0] == 0 && in_extradata[1] == 0 && in_extradata[2] == 1) )
  2585.            {
  2586.              CLog::Log(LOGINFO, "CBitstreamConverter::Open annexb to bitstream init\n");
  2587.              // video content is from x264 or from bytestream h264 (AnnexB format)
  2588. @@ -701,10 +702,16 @@
  2589.  
  2590.  uint8_t *CBitstreamConverter::GetExtraData()
  2591.  {
  2592. +  if(m_convert_bitstream)
  2593. +    return m_sps_pps_context.sps_pps_data;
  2594. +  else
  2595.    return m_extradata;
  2596.  }
  2597.  int CBitstreamConverter::GetExtraSize()
  2598.  {
  2599. +  if(m_convert_bitstream)
  2600. +    return m_sps_pps_context.size;
  2601. +  else
  2602.    return m_extrasize;
  2603.  }
  2604.  
  2605. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeCedar.cpp xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeCedar.cpp
  2606. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeCedar.cpp 1970-01-01 01:00:00.000000000 +0100
  2607. +++ xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeCedar.cpp   2013-06-17 16:16:23.000000000 +0200
  2608. @@ -0,0 +1,237 @@
  2609. +/*
  2610. + *      Copyright (C) 2011-2012 Team XBMC
  2611. + *      http://www.xbmc.org
  2612. + *
  2613. + *  This Program is free software; you can redistribute it and/or modify
  2614. + *  it under the terms of the GNU General Public License as published by
  2615. + *  the Free Software Foundation; either version 2, or (at your option)
  2616. + *  any later version.
  2617. + *
  2618. + *  This Program is distributed in the hope that it will be useful,
  2619. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2620. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2621. + *  GNU General Public License for more details.
  2622. + *
  2623. + *  You should have received a copy of the GNU General Public License
  2624. + *  along with XBMC; see the file COPYING.  If not, see
  2625. + *  <http://www.gnu.org/licenses/>.
  2626. + *
  2627. + */
  2628. +#include <EGL/egl.h>
  2629. +#include "EGLNativeTypeCedar.h"
  2630. +#include <stdlib.h>
  2631. +#include <linux/fb.h>
  2632. +#include <sys/ioctl.h>
  2633. +#include "utils/StringUtils.h"
  2634. +#include "guilib/gui3d.h"
  2635. +
  2636. +CEGLNativeTypeCedar::CEGLNativeTypeCedar()
  2637. +{
  2638. +}
  2639. +
  2640. +CEGLNativeTypeCedar::~CEGLNativeTypeCedar()
  2641. +{
  2642. +}
  2643. +
  2644. +bool CEGLNativeTypeCedar::CheckCompatibility()
  2645. +{
  2646. +  int tmpfd = open("/dev/cedar_dev", O_RDONLY);
  2647. +
  2648. +  if(tmpfd >= 0)
  2649. +  {
  2650. +    close(tmpfd);
  2651. +    return true;
  2652. +  }
  2653. +
  2654. +  return false;
  2655. +}
  2656. +
  2657. +void CEGLNativeTypeCedar::Initialize()
  2658. +{
  2659. +  SetCpuMinLimit(true);
  2660. +  return;
  2661. +}
  2662. +void CEGLNativeTypeCedar::Destroy()
  2663. +{
  2664. +  SetCpuMinLimit(false);
  2665. +  return;
  2666. +}
  2667. +
  2668. +bool CEGLNativeTypeCedar::CreateNativeDisplay()
  2669. +{
  2670. +  m_nativeDisplay = EGL_DEFAULT_DISPLAY;
  2671. +  return true;
  2672. +}
  2673. +
  2674. +bool CEGLNativeTypeCedar::CreateNativeWindow()
  2675. +{
  2676. +#if defined(_FBDEV_WINDOW_H_)
  2677. +  fbdev_window *nativeWindow = new fbdev_window;
  2678. +  if (!nativeWindow)
  2679. +    return false;
  2680. +
  2681. +  nativeWindow->width = 1280;
  2682. +  nativeWindow->height = 720;
  2683. +  m_nativeWindow = nativeWindow;
  2684. +  return true;
  2685. +#else
  2686. +  return false;
  2687. +#endif
  2688. +}
  2689. +
  2690. +bool CEGLNativeTypeCedar::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
  2691. +{
  2692. +  if (!nativeDisplay)
  2693. +    return false;
  2694. +  *nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
  2695. +  return true;
  2696. +}
  2697. +
  2698. +bool CEGLNativeTypeCedar::GetNativeWindow(XBNativeWindowType **nativeWindow) const
  2699. +{
  2700. +  if (!nativeWindow)
  2701. +    return false;
  2702. +  *nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
  2703. +  return true;
  2704. +}
  2705. +
  2706. +bool CEGLNativeTypeCedar::DestroyNativeDisplay()
  2707. +{
  2708. +  return true;
  2709. +}
  2710. +
  2711. +bool CEGLNativeTypeCedar::DestroyNativeWindow()
  2712. +{
  2713. +  free(m_nativeWindow);
  2714. +  return true;
  2715. +}
  2716. +
  2717. +bool CEGLNativeTypeCedar::GetNativeResolution(RESOLUTION_INFO *res) const
  2718. +{
  2719. +  res->iWidth  = 1280;
  2720. +  res->iHeight = 720;
  2721. +  res->fRefreshRate = 60;
  2722. +  res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
  2723. +  res->iScreen       = 0;
  2724. +  res->bFullScreen   = true;
  2725. +  res->iSubtitles    = (int)(0.965 * res->iHeight);
  2726. +  res->fPixelRatio   = 1.0f;
  2727. +  res->iScreenWidth  = res->iWidth;
  2728. +  res->iScreenHeight = res->iHeight;
  2729. +  res->strMode.Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate,
  2730. +     res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
  2731. +  return true;
  2732. +}
  2733. +
  2734. +bool CEGLNativeTypeCedar::SetNativeResolution(const RESOLUTION_INFO &res)
  2735. +{
  2736. +  return false;
  2737. +}
  2738. +
  2739. +bool CEGLNativeTypeCedar::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
  2740. +{
  2741. +  RESOLUTION_INFO res;
  2742. +
  2743. +  res.iWidth  = 1280;
  2744. +  res.iHeight = 720;
  2745. +  res.fRefreshRate = 60;
  2746. +  res.dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
  2747. +  res.iScreen       = 0;
  2748. +  res.bFullScreen   = true;
  2749. +  res.iSubtitles    = (int)(0.965 * res.iHeight);
  2750. +  res.fPixelRatio   = 1.0f;
  2751. +  res.iScreenWidth  = res.iWidth;
  2752. +  res.iScreenHeight = res.iHeight;
  2753. +  res.strMode.Format("%dx%d @ %.2f%s - Full Screen", res.iScreenWidth, res.iScreenHeight, res.fRefreshRate,
  2754. +     res.dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
  2755. +
  2756. +  resolutions.push_back(res);
  2757. +
  2758. +  return resolutions.size() > 0;
  2759. +}
  2760. +
  2761. +bool CEGLNativeTypeCedar::GetPreferredResolution(RESOLUTION_INFO *res) const
  2762. +{
  2763. +  return false;
  2764. +}
  2765. +
  2766. +bool CEGLNativeTypeCedar::ShowWindow(bool show)
  2767. +{
  2768. +  return false;
  2769. +}
  2770. +
  2771. +int CEGLNativeTypeCedar::get_sysfs_str(const char *path, char *valstr, const int size) const
  2772. +{
  2773. +  int fd = open(path, O_RDONLY);
  2774. +  if (fd >= 0)
  2775. +  {
  2776. +    int len = read(fd, valstr, size - 1);
  2777. +    if (len != -1 )
  2778. +      valstr[len] = '\0';
  2779. +    close(fd);
  2780. +  }
  2781. +  else
  2782. +  {
  2783. +    sprintf(valstr, "%s", "fail");
  2784. +    return -1;
  2785. +  }
  2786. +  return 0;
  2787. +}
  2788. +
  2789. +int CEGLNativeTypeCedar::set_sysfs_str(const char *path, const char *val) const
  2790. +{
  2791. +  int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
  2792. +  if (fd >= 0)
  2793. +  {
  2794. +    write(fd, val, strlen(val));
  2795. +    close(fd);
  2796. +    return 0;
  2797. +  }
  2798. +  return -1;
  2799. +}
  2800. +
  2801. +int CEGLNativeTypeCedar::set_sysfs_int(const char *path, const int val) const
  2802. +{
  2803. +  char bcmd[16];
  2804. +  int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
  2805. +  if (fd >= 0)
  2806. +  {
  2807. +    sprintf(bcmd, "%d", val);
  2808. +    write(fd, bcmd, strlen(bcmd));
  2809. +    close(fd);
  2810. +    return 0;
  2811. +  }
  2812. +  return -1;
  2813. +}
  2814. +
  2815. +int CEGLNativeTypeCedar::get_sysfs_int(const char *path) const
  2816. +{
  2817. +  int val = 0;
  2818. +  char bcmd[16];
  2819. +  int fd = open(path, O_RDONLY);
  2820. +  if (fd >= 0)
  2821. +  {
  2822. +    memset(bcmd, 0, 16);
  2823. +    read(fd, bcmd, sizeof(bcmd));
  2824. +    val = strtol(bcmd, NULL, 0);
  2825. +    close(fd);
  2826. +  }
  2827. +  return val;
  2828. +}
  2829. +
  2830. +void CEGLNativeTypeCedar::SetCpuMinLimit(bool limit)
  2831. +{
  2832. +  // set performance governor, ondemand is optimized for powersave, not our needs
  2833. +  char scaling_governor[256] = {0};
  2834. +
  2835. +  if(limit)
  2836. +  {
  2837. +    get_sysfs_str("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", scaling_governor, 255);
  2838. +    set_sysfs_str("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "performance");
  2839. +    m_scaling_governor = scaling_governor;
  2840. +  }
  2841. +  else
  2842. +  {
  2843. +    set_sysfs_str("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", m_scaling_governor.c_str());
  2844. +  }
  2845. +}
  2846. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeCedar.h xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeCedar.h
  2847. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeCedar.h   1970-01-01 01:00:00.000000000 +0100
  2848. +++ xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeCedar.h 2013-06-17 16:16:23.000000000 +0200
  2849. @@ -0,0 +1,59 @@
  2850. +#pragma once
  2851. +
  2852. +/*
  2853. + *      Copyright (C) 2011-2012 Team XBMC
  2854. + *      http://www.xbmc.org
  2855. + *
  2856. + *  This Program is free software; you can redistribute it and/or modify
  2857. + *  it under the terms of the GNU General Public License as published by
  2858. + *  the Free Software Foundation; either version 2, or (at your option)
  2859. + *  any later version.
  2860. + *
  2861. + *  This Program is distributed in the hope that it will be useful,
  2862. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2863. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2864. + *  GNU General Public License for more details.
  2865. + *
  2866. + *  You should have received a copy of the GNU General Public License
  2867. + *  along with XBMC; see the file COPYING.  If not, see
  2868. + *  <http://www.gnu.org/licenses/>.
  2869. + *
  2870. + */
  2871. +
  2872. +#include "EGLNativeType.h"
  2873. +class CEGLNativeTypeCedar : public CEGLNativeType
  2874. +{
  2875. +public:
  2876. +  CEGLNativeTypeCedar();
  2877. +  virtual ~CEGLNativeTypeCedar();
  2878. +  virtual std::string GetNativeName() const { return "cedar"; };
  2879. +  virtual bool  CheckCompatibility();
  2880. +  virtual void  Initialize();
  2881. +  virtual void  Destroy();
  2882. +  virtual int   GetQuirks() { return EGL_QUIRK_NONE; };
  2883. +
  2884. +  virtual bool  CreateNativeDisplay();
  2885. +  virtual bool  CreateNativeWindow();
  2886. +  virtual bool  GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
  2887. +  virtual bool  GetNativeWindow(XBNativeWindowType **nativeWindow) const;
  2888. +
  2889. +  virtual bool  DestroyNativeWindow();
  2890. +  virtual bool  DestroyNativeDisplay();
  2891. +
  2892. +  virtual bool  GetNativeResolution(RESOLUTION_INFO *res) const;
  2893. +  virtual bool  SetNativeResolution(const RESOLUTION_INFO &res);
  2894. +  virtual bool  ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions);
  2895. +  virtual bool  GetPreferredResolution(RESOLUTION_INFO *res) const;
  2896. +
  2897. +  virtual bool  ShowWindow(bool show);
  2898. +
  2899. +protected:
  2900. +  int get_sysfs_str(const char *path, char *valstr, const int size) const;
  2901. +  int set_sysfs_str(const char *path, const char *val) const;
  2902. +  int set_sysfs_int(const char *path, const int val) const;
  2903. +  int get_sysfs_int(const char *path) const;
  2904. +
  2905. +  void SetCpuMinLimit(bool limit);
  2906. +
  2907. +  std::string m_scaling_governor;
  2908. +};
  2909. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeGeneric.cpp xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeGeneric.cpp
  2910. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeGeneric.cpp   1970-01-01 01:00:00.000000000 +0100
  2911. +++ xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeGeneric.cpp 2013-06-17 16:16:23.000000000 +0200
  2912. @@ -0,0 +1,151 @@
  2913. +/*
  2914. + *      Copyright (C) 2011-2012 Team XBMC
  2915. + *      http://www.xbmc.org
  2916. + *
  2917. + *  This Program is free software; you can redistribute it and/or modify
  2918. + *  it under the terms of the GNU General Public License as published by
  2919. + *  the Free Software Foundation; either version 2, or (at your option)
  2920. + *  any later version.
  2921. + *
  2922. + *  This Program is distributed in the hope that it will be useful,
  2923. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2924. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2925. + *  GNU General Public License for more details.
  2926. + *
  2927. + *  You should have received a copy of the GNU General Public License
  2928. + *  along with XBMC; see the file COPYING.  If not, see
  2929. + *  <http://www.gnu.org/licenses/>.
  2930. + *
  2931. + */
  2932. +#include <EGL/egl.h>
  2933. +#include "EGLNativeTypeGeneric.h"
  2934. +#include <stdlib.h>
  2935. +#include <linux/fb.h>
  2936. +#include <sys/ioctl.h>
  2937. +#include "utils/StringUtils.h"
  2938. +#include "guilib/gui3d.h"
  2939. +
  2940. +CEGLNativeTypeGeneric::CEGLNativeTypeGeneric()
  2941. +{
  2942. +}
  2943. +
  2944. +CEGLNativeTypeGeneric::~CEGLNativeTypeGeneric()
  2945. +{
  2946. +}
  2947. +
  2948. +bool CEGLNativeTypeGeneric::CheckCompatibility()
  2949. +{
  2950. +  return true;
  2951. +}
  2952. +
  2953. +void CEGLNativeTypeGeneric::Initialize()
  2954. +{
  2955. +  return;
  2956. +}
  2957. +void CEGLNativeTypeGeneric::Destroy()
  2958. +{
  2959. +  return;
  2960. +}
  2961. +
  2962. +bool CEGLNativeTypeGeneric::CreateNativeDisplay()
  2963. +{
  2964. +  m_nativeDisplay = EGL_DEFAULT_DISPLAY;
  2965. +  return true;
  2966. +}
  2967. +
  2968. +bool CEGLNativeTypeGeneric::CreateNativeWindow()
  2969. +{
  2970. +#if defined(_FBDEV_WINDOW_H_)
  2971. +  fbdev_window *nativeWindow = new fbdev_window;
  2972. +  if (!nativeWindow)
  2973. +    return false;
  2974. +
  2975. +  nativeWindow->width = 1280;
  2976. +  nativeWindow->height = 720;
  2977. +  m_nativeWindow = nativeWindow;
  2978. +  return true;
  2979. +#else
  2980. +  return false;
  2981. +#endif
  2982. +}
  2983. +
  2984. +bool CEGLNativeTypeGeneric::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
  2985. +{
  2986. +  if (!nativeDisplay)
  2987. +    return false;
  2988. +  *nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
  2989. +  return true;
  2990. +}
  2991. +
  2992. +bool CEGLNativeTypeGeneric::GetNativeWindow(XBNativeWindowType **nativeWindow) const
  2993. +{
  2994. +  if (!nativeWindow)
  2995. +    return false;
  2996. +  *nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
  2997. +  return true;
  2998. +}
  2999. +
  3000. +bool CEGLNativeTypeGeneric::DestroyNativeDisplay()
  3001. +{
  3002. +  return true;
  3003. +}
  3004. +
  3005. +bool CEGLNativeTypeGeneric::DestroyNativeWindow()
  3006. +{
  3007. +  free(m_nativeWindow);
  3008. +  return true;
  3009. +}
  3010. +
  3011. +bool CEGLNativeTypeGeneric::GetNativeResolution(RESOLUTION_INFO *res) const
  3012. +{
  3013. +  res->iWidth  = 1280;
  3014. +  res->iHeight = 720;
  3015. +  res->fRefreshRate = 60;
  3016. +  res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
  3017. +  res->iScreen       = 0;
  3018. +  res->bFullScreen   = true;
  3019. +  res->iSubtitles    = (int)(0.965 * res->iHeight);
  3020. +  res->fPixelRatio   = 1.0f;
  3021. +  res->iScreenWidth  = res->iWidth;
  3022. +  res->iScreenHeight = res->iHeight;
  3023. +  res->strMode.Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate,
  3024. +     res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
  3025. +  return true;
  3026. +}
  3027. +
  3028. +bool CEGLNativeTypeGeneric::SetNativeResolution(const RESOLUTION_INFO &res)
  3029. +{
  3030. +  return false;
  3031. +}
  3032. +
  3033. +bool CEGLNativeTypeGeneric::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
  3034. +{
  3035. +  RESOLUTION_INFO res;
  3036. +
  3037. +  res.iWidth  = 1280;
  3038. +  res.iHeight = 720;
  3039. +  res.fRefreshRate = 60;
  3040. +  res.dwFlags= D3DPRESENTFLAG_PROGRESSIVE;
  3041. +  res.iScreen       = 0;
  3042. +  res.bFullScreen   = true;
  3043. +  res.iSubtitles    = (int)(0.965 * res.iHeight);
  3044. +  res.fPixelRatio   = 1.0f;
  3045. +  res.iScreenWidth  = res.iWidth;
  3046. +  res.iScreenHeight = res.iHeight;
  3047. +  res.strMode.Format("%dx%d @ %.2f%s - Full Screen", res.iScreenWidth, res.iScreenHeight, res.fRefreshRate,
  3048. +     res.dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
  3049. +
  3050. +  resolutions.push_back(res);
  3051. +
  3052. +  return resolutions.size() > 0;
  3053. +}
  3054. +
  3055. +bool CEGLNativeTypeGeneric::GetPreferredResolution(RESOLUTION_INFO *res) const
  3056. +{
  3057. +  return false;
  3058. +}
  3059. +
  3060. +bool CEGLNativeTypeGeneric::ShowWindow(bool show)
  3061. +{
  3062. +  return false;
  3063. +}
  3064. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeGeneric.h xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeGeneric.h
  3065. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeGeneric.h 1970-01-01 01:00:00.000000000 +0100
  3066. +++ xbmc_huceke/xbmc/windowing/egl/EGLNativeTypeGeneric.h   2013-06-17 16:16:23.000000000 +0200
  3067. @@ -0,0 +1,51 @@
  3068. +#pragma once
  3069. +
  3070. +/*
  3071. + *      Copyright (C) 2011-2012 Team XBMC
  3072. + *      http://www.xbmc.org
  3073. + *
  3074. + *  This Program is free software; you can redistribute it and/or modify
  3075. + *  it under the terms of the GNU General Public License as published by
  3076. + *  the Free Software Foundation; either version 2, or (at your option)
  3077. + *  any later version.
  3078. + *
  3079. + *  This Program is distributed in the hope that it will be useful,
  3080. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  3081. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3082. + *  GNU General Public License for more details.
  3083. + *
  3084. + *  You should have received a copy of the GNU General Public License
  3085. + *  along with XBMC; see the file COPYING.  If not, see
  3086. + *  <http://www.gnu.org/licenses/>.
  3087. + *
  3088. + */
  3089. +
  3090. +#include "EGLNativeType.h"
  3091. +class CEGLNativeTypeGeneric : public CEGLNativeType
  3092. +{
  3093. +public:
  3094. +  CEGLNativeTypeGeneric();
  3095. +  virtual ~CEGLNativeTypeGeneric();
  3096. +  virtual std::string GetNativeName() const { return "generic"; };
  3097. +  virtual bool  CheckCompatibility();
  3098. +  virtual void  Initialize();
  3099. +  virtual void  Destroy();
  3100. +  virtual int   GetQuirks() { return EGL_QUIRK_NONE; };
  3101. +
  3102. +  virtual bool  CreateNativeDisplay();
  3103. +  virtual bool  CreateNativeWindow();
  3104. +  virtual bool  GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
  3105. +  virtual bool  GetNativeWindow(XBNativeWindowType **nativeWindow) const;
  3106. +
  3107. +  virtual bool  DestroyNativeWindow();
  3108. +  virtual bool  DestroyNativeDisplay();
  3109. +
  3110. +  virtual bool  GetNativeResolution(RESOLUTION_INFO *res) const;
  3111. +  virtual bool  SetNativeResolution(const RESOLUTION_INFO &res);
  3112. +  virtual bool  ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions);
  3113. +  virtual bool  GetPreferredResolution(RESOLUTION_INFO *res) const;
  3114. +
  3115. +  virtual bool  ShowWindow(bool show);
  3116. +
  3117. +protected:
  3118. +};
  3119. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLWrapper.cpp xbmc_huceke/xbmc/windowing/egl/EGLWrapper.cpp
  3120. --- xbmc_orig/xbmc/windowing/egl/EGLWrapper.cpp 2013-06-17 16:17:18.000000000 +0200
  3121. +++ xbmc_huceke/xbmc/windowing/egl/EGLWrapper.cpp   2013-06-17 16:16:23.000000000 +0200
  3122. @@ -25,6 +25,7 @@
  3123.  #include "utils/log.h"
  3124.  #include "EGLNativeTypeAndroid.h"
  3125.  #include "EGLNativeTypeAmlogic.h"
  3126. +#include "EGLNativeTypeCedar.h"
  3127.  #include "EGLNativeTypeRaspberryPI.h"
  3128.  #include "EGLWrapper.h"
  3129.  
  3130. @@ -77,6 +78,20 @@
  3131.      if (nativeGuess->CheckCompatibility())
  3132.      {
  3133.        if(implementation == nativeGuess->GetNativeName() || implementation == "auto")
  3134. +      {
  3135. +        m_nativeTypes = nativeGuess;
  3136. +        ret = true;
  3137. +      }
  3138. +    }
  3139. +  }
  3140. +
  3141. +  if (!ret)
  3142. +  {
  3143. +    delete nativeGuess;
  3144. +    nativeGuess = new CEGLNativeTypeCedar;
  3145. +    if (nativeGuess->CheckCompatibility())
  3146. +    {
  3147. +      if(implementation == nativeGuess->GetNativeName() || implementation == "auto")
  3148.        {
  3149.          m_nativeTypes = nativeGuess;
  3150.          ret = true;
  3151. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/Makefile xbmc_huceke/xbmc/windowing/egl/Makefile
  3152. --- xbmc_orig/xbmc/windowing/egl/Makefile   2013-06-12 16:21:09.000000000 +0200
  3153. +++ xbmc_huceke/xbmc/windowing/egl/Makefile 2013-06-17 16:16:23.000000000 +0200
  3154. @@ -3,6 +3,7 @@
  3155.  SRCS = WinSystemEGL.cpp
  3156.  SRCS+= EGLNativeTypeAmlogic.cpp
  3157.  SRCS+= EGLNativeTypeAndroid.cpp
  3158. +SRCS+= EGLNativeTypeCedar.cpp
  3159.  SRCS+= EGLNativeTypeRaspberryPI.cpp
  3160.  SRCS+= EGLWrapper.cpp
RAW Paste Data