Guest User

Untitled

a guest
Jun 18th, 2013
501
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_rellla/configure.in
  2. --- xbmc_orig/configure.in  2013-06-12 17:20:24.000000000 +0200
  3. +++ xbmc_rellla/configure.in    2013-06-12 17:13:23.000000000 +0200
  4. @@ -2854,6 +2854,8 @@
  5.      CXXFLAGS="$CXXFLAGS"
  6.  ], [$DISABLE_PVR_ADDON_CONFIG])
  7.  
  8. +LIBS="$LIBS $CEDARLIBS"
  9. +
  10.  AC_OUTPUT
  11.  
  12.  final_message="$final_message\n  prefix:\t$prefix\n$dashes"
  13. diff -b -u -r -N '--exclude=.git' xbmc_orig/fix.sh xbmc_rellla/fix.sh
  14. --- xbmc_orig/fix.sh    1970-01-01 01:00:00.000000000 +0100
  15. +++ xbmc_rellla/fix.sh  2013-06-12 17:13:23.000000000 +0200
  16. @@ -0,0 +1,9 @@
  17. +cd /allwinner/xbmc-pvr-bin/lib/xbmc/addons
  18. +cd library.xbmc.addon
  19. +mv libXBMC_addon-arm.so libXBMC_addon-arm-linux.so
  20. +cd ..
  21. +cd library.xbmc.gui
  22. +mv libXBMC_gui-arm.so libXBMC_gui-arm-linux.so
  23. +cd ..
  24. +cd library.xbmc.pvr
  25. +mv libXBMC_pvr-arm.so libXBMC_pvr-arm-linux.so
  26. diff -b -u -r -N '--exclude=.git' xbmc_orig/.gitattributes xbmc_rellla/.gitattributes
  27. --- xbmc_orig/.gitattributes    1970-01-01 01:00:00.000000000 +0100
  28. +++ xbmc_rellla/.gitattributes  2013-06-12 17:13:13.000000000 +0200
  29. @@ -0,0 +1 @@
  30. +*.pbxproj -crlf -diff
  31. diff -b -u -r -N '--exclude=.git' xbmc_orig/.gitmodules xbmc_rellla/.gitmodules
  32. --- xbmc_orig/.gitmodules   2013-06-12 16:20:21.000000000 +0200
  33. +++ xbmc_rellla/.gitmodules 2013-06-12 17:13:13.000000000 +0200
  34. @@ -2,3 +2,8 @@
  35.     path = addons/skin.touched
  36.     url = git://github.com/xbmc/skin.touched.git
  37.     ignore = all
  38. +
  39. +[submodule "pvr-addons"]
  40. +   path = pvr-addons
  41. +   url = git@github.com:rellla/xbmc-pvr-addons.git
  42. +   ignore = all
  43. diff -b -u -r -N '--exclude=.git' xbmc_orig/Makefile.in xbmc_rellla/Makefile.in
  44. --- xbmc_orig/Makefile.in   2013-06-12 17:20:23.000000000 +0200
  45. +++ xbmc_rellla/Makefile.in 2013-06-12 17:13:13.000000000 +0200
  46. @@ -1,4 +1,5 @@
  47.  include bootstrap.mk
  48. +include tools/a10/depends/depends.mk
  49.  
  50.  AUTOGENERATED_MAKEFILES=@OUTPUT_FILES@
  51.  
  52. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/cedarv/.gitignore xbmc_rellla/tools/a10/depends/cedarv/.gitignore
  53. --- xbmc_orig/tools/a10/depends/cedarv/.gitignore   1970-01-01 01:00:00.000000000 +0100
  54. +++ xbmc_rellla/tools/a10/depends/cedarv/.gitignore 2013-06-12 17:13:39.000000000 +0200
  55. @@ -0,0 +1,10 @@
  56. +/adapter
  57. +/libcedarv
  58. +/libvecore
  59. +/vbv
  60. +/fbm
  61. +.installed
  62. +.extracted
  63. +cedardev_api.h
  64. +drv_display_sun4i.h
  65. +
  66. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/cedarv/Makefile xbmc_rellla/tools/a10/depends/cedarv/Makefile
  67. --- xbmc_orig/tools/a10/depends/cedarv/Makefile 1970-01-01 01:00:00.000000000 +0100
  68. +++ xbmc_rellla/tools/a10/depends/cedarv/Makefile   2013-06-12 17:13:39.000000000 +0200
  69. @@ -0,0 +1,63 @@
  70. +include ../depends.mk
  71. +
  72. +TARBALL=cedarx-libs.tar.gz
  73. +URL=https://github.com/linux-sunxi/cedarx-libs/tarball/master
  74. +
  75. +ifeq ($(USEARMHF), 1)
  76. +LIBVERSION=linux-armhf
  77. +else
  78. +LIBVERSION=linux-armel
  79. +endif
  80. +
  81. +SRCS = \
  82. +   libcedarv/vdecoder.c \
  83. +   libcedarv/awprintf.c \
  84. +   fbm/fbm.c \
  85. +   vbv/vbv.c \
  86. +   adapter/libve_adapter.c \
  87. +   adapter/os_adapter.c
  88. +
  89. +ifeq ($(USEARMHF), 1)
  90. +SRCS += adapter/avheap/avheap.c
  91. +endif
  92. +
  93. +OBJS = $(SRCS:%.c=%.o)
  94. +
  95. +TARGET=libcedarv.a
  96. +
  97. +all: .installed
  98. +
  99. +.installed: $(TARGET)
  100. +   install -d $(XBMCPREFIX)/lib
  101. +ifneq ($(USEARMHF), 1)
  102. +   cp adapter/cdxalloc/libcedarxalloc.so $(XBMCPREFIX)/lib
  103. +endif
  104. +   cp libvecore/libvecore.so $(XBMCPREFIX)/lib
  105. +   touch $@
  106. +
  107. +$(TARGET) : .extracted $(OBJS)
  108. +   rm -f $(TARGET)
  109. +   $(AR) cq $(TARGET) $(OBJS)
  110. +  
  111. +.extracted: $(TARBALLS)/$(TARBALL)
  112. +   rm -rf tmp 
  113. +   mkdir tmp
  114. +   ( cd tmp &&\
  115. +     tar xvfz $(TARBALLS)/$(TARBALL) &&\
  116. +     cd linux-sunxi-*/libcedarv/$(LIBVERSION) &&\
  117. +     rm Makefile .gitignore cedardefs.mk &&\
  118. +     rm -rf sample &&\
  119. +     mv * ../../../../ \
  120. +   )
  121. +   rm -rf tmp $(OBJS)
  122. +   touch $@
  123. +  
  124. +$(TARBALLS)/$(TARBALL):
  125. +   install -d $(TARBALLS)
  126. +   wget $(URL) -O $(TARBALLS)/$(TARBALL)
  127. +
  128. +clean:
  129. +   rm -f $(TARGET) $(OBJS)
  130. +   rm -rf adapter fbm libcedarv libvecore vbv
  131. +   rm -f .installed .extracted cedardev_api.h drv_display_sun4i.h
  132. +
  133. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/depends.mk xbmc_rellla/tools/a10/depends/depends.mk
  134. --- xbmc_orig/tools/a10/depends/depends.mk  1970-01-01 01:00:00.000000000 +0100
  135. +++ xbmc_rellla/tools/a10/depends/depends.mk    2013-06-12 17:13:39.000000000 +0200
  136. @@ -0,0 +1,137 @@
  137. +# I used miniand lubuntu (kernel 3.0.36) on mk802.
  138. +#
  139. +# On a10 lubuntu run apt-get build-dep xbmc in it to get all dependencies.
  140. +# SDKSTAGE: rootfs from lubuntu/armel if cross-compiling.
  141. +# On x86 Ubuntu 12.04: I had to make symlinks for
  142. +# /lib/arm-linux-gnueabi, /usr/lib/arm-linux-gnueabi
  143. +# and /usr/include/arm-linux-gnueabi to their path in ${SDKSTAGE}
  144. +#
  145. +
  146. +#your home dir
  147. +#HOME=$(shell echo ~)
  148. +HOME=/opt/a10hacking
  149. +#where your tarballs go
  150. +TARBALLS=$(HOME)/xbmctmp/tarballs
  151. +#whether to compile for armhf
  152. +USEARMHF=1
  153. +
  154. +#wget-command to download files
  155. +WGET=wget --no-check-certificate
  156. +
  157. +#
  158. +# armhf notes:
  159. +#
  160. +# I used linaro alip together with wip/linux-sunxi-3.0/next_mali kernel.
  161. +#
  162. +
  163. +ifeq ($(USEARMHF), 1)
  164. +HF=hf
  165. +else
  166. +HF=
  167. +endif
  168. +
  169. +ifeq ($(shell uname -m),armv7l)
  170. +#
  171. +#native compile
  172. +#
  173. +
  174. +#where is your arm rootfs
  175. +SDKSTAGE=/
  176. +#where is your xbmc install root
  177. +XBMCPREFIX=/allwinner/xbmc-pvr-bin$(HF)
  178. +#where is your toolchain
  179. +TOOLCHAIN=/usr
  180. +
  181. +JOBS=1
  182. +export HOST=arm-linux-gnueabi$(HF)
  183. +export BUILD=arm-linux-gnueabi$(HF)
  184. +export CROSS_COMPILE=
  185. +
  186. +else
  187. +#
  188. +#cross compile
  189. +#
  190. +
  191. +#where is your arm rootfs
  192. +SDKSTAGE=$(HOME)/rootfs/debrootfs
  193. +#where is your xbmc install root
  194. +XBMCPREFIX=/allwinner/xbmc-pvr-bin$(HF)
  195. +#where is your toolchain
  196. +TOOLCHAIN=/usr/arm-linux-gnueabi$(HF)
  197. +
  198. +JOBS=4
  199. +export HOST=arm-linux-gnueabi$(HF)
  200. +export BUILD=i686-linux
  201. +export CROSS_COMPILE=${HOST}-
  202. +
  203. +endif
  204. +
  205. +
  206. +export PREFIX=${XBMCPREFIX}
  207. +
  208. +GLESDIR=$(shell cd ..;pwd)/opengles
  209. +
  210. +export GLESINCLUDES=-I$(GLESDIR)/include
  211. +
  212. +CEDARDIR=$(shell cd ..;pwd)/cedarv
  213. +
  214. +export CEDARINCLUDES=\
  215. +   -I$(CEDARDIR) \
  216. +   -I$(CEDARDIR)/adapter \
  217. +   -I$(CEDARDIR)/adapter/cdxalloc \
  218. +   -I$(CEDARDIR)/adapter/avheap \
  219. +   -I$(CEDARDIR)/fbm \
  220. +   -I$(CEDARDIR)/libcedarv \
  221. +   -I$(CEDARDIR)/libvecore \
  222. +   -I$(CEDARDIR)/vbv
  223. +
  224. +#vecore,cedarxalloc taken from $(XBMCPREFIX)/lib
  225. +ifeq ($(USEARMHF), 1)
  226. +export CEDARLIBS=-L$(CEDARDIR) -lcedarv -lvecore
  227. +else
  228. +export CEDARLIBS=-L$(CEDARDIR) -lcedarv -lvecore -lcedarxalloc
  229. +endif
  230. +
  231. +export RLINK_PATH=-Wl,-rpath,$(XBMCPREFIX)/lib -Wl,-rpath-link,${XBMCPREFIX}/lib:$(SDKSTAGE)/usr/local/lib:${SDKSTAGE}/lib:${SDKSTAGE}/lib/arm-linux-gnueabi$(HF):${SDKSTAGE}/usr/lib:${SDKSTAGE}/usr/lib/arm-linux-gnueabi$(HF)
  232. +export LDFLAGS=\
  233. +${RLINK_PATH} \
  234. +-L${XBMCPREFIX}/lib \
  235. +-L$(SDKSTAGE)/usr/local/lib \
  236. +-L${SDKSTAGE}/lib \
  237. +-L${SDKSTAGE}/lib/arm-linux-gnueabi$(HF) \
  238. +-L${SDKSTAGE}/usr/lib \
  239. +-L${SDKSTAGE}/usr/lib/arm-linux-gnueabi$(HF)
  240. +
  241. +ifeq ($(USEARMHF), 1)
  242. +export CFLAGS=-pipe -O3 -mfloat-abi=hard -mtune=cortex-a8 -mcpu=cortex-a8 -D__ARM_NEON__ -DALLWINNERA10
  243. +else
  244. +export CFLAGS=-pipe -O3 -mfloat-abi=softfp -mtune=cortex-a8 -mcpu=cortex-a8 -D__ARM_NEON__ -DALLWINNERA10
  245. +endif
  246. +export CFLAGS+=$(CEDARINCLUDES) $(GLESINCLUDES)
  247. +export CFLAGS+=\
  248. +-isystem${XBMCPREFIX}/include \
  249. +-isystem$(SDKSTAGE)/usr/local/include \
  250. +-isystem${SDKSTAGE}/usr/include \
  251. +-isystem${SDKSTAGE}/usr/include/arm-linux-gnueabi$(HF)
  252. +export CFLAGS+=${LDFLAGS}
  253. +
  254. +export CXXFLAGS=${CFLAGS}
  255. +export CPPFLAGS=${CFLAGS}
  256. +export LD=${CROSS_COMPILE}ld
  257. +export AR=${CROSS_COMPILE}ar
  258. +export CC=${CROSS_COMPILE}gcc
  259. +export CXX=${CROSS_COMPILE}g++
  260. +export CXXCPP=${CXX} -E
  261. +export RANLIB=${CROSS_COMPILE}ranlib
  262. +export STRIP=${CROSS_COMPILE}strip
  263. +export OBJDUMP=${CROSS_COMPILE}objdump
  264. +export PKG_CONFIG_SYSROOT_DIR=${SDKSTAGE}
  265. +export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig:${SDKSTAGE}/lib/pkgconfig:${SDKSTAGE}/usr/lib/pkgconfig:${SDKSTAGE}/usr/lib/arm-linux-gnueabi$(HF)/pkgconfig:${SDKSTAGE}/usr/share/pkgconfig:${SDKSTAGE}/usr/local/lib/pkgconfig
  266. +export PKG_CONFIG_PATH=${PREFIX}/bin/pkg-config
  267. +export PYTHON_VERSION=2.7
  268. +export PATH:=${PREFIX}/bin:${TOOLCHAIN}/bin:$(PATH)
  269. +export TEXTUREPACKER_NATIVE_ROOT=/usr
  270. +export PYTHON_LDFLAGS=-L${SDKSTAGE}/usr/lib -lpython$(PYTHON_VERSION)
  271. +export PYTHON_CPPFLAGS=-I${SDKSTAGE}/usr/include/python$(PYTHON_VERSION)
  272. +export PYTHON_SITE_PKG=${SDKSTAGE}/usr/lib/python$(PYTHON_VERSION)/site-packages
  273. +export PYTHON_NOVERSIONCHECK=no-check
  274. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/libmad/.gitignore xbmc_rellla/tools/a10/depends/libmad/.gitignore
  275. --- xbmc_orig/tools/a10/depends/libmad/.gitignore   1970-01-01 01:00:00.000000000 +0100
  276. +++ xbmc_rellla/tools/a10/depends/libmad/.gitignore 2013-06-12 17:13:39.000000000 +0200
  277. @@ -0,0 +1,5 @@
  278. +.installed
  279. +.builded
  280. +.configured
  281. +.extracted
  282. +/libmad*
  283. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/libmad/Makefile xbmc_rellla/tools/a10/depends/libmad/Makefile
  284. --- xbmc_orig/tools/a10/depends/libmad/Makefile 1970-01-01 01:00:00.000000000 +0100
  285. +++ xbmc_rellla/tools/a10/depends/libmad/Makefile   2013-06-12 17:13:39.000000000 +0200
  286. @@ -0,0 +1,36 @@
  287. +include ../depends.mk
  288. +
  289. +export CFLAGS+=-marm
  290. +
  291. +LOCATION=ftp://ftp.mars.org/pub/mpeg
  292. +TARBALL=libmad-0.15.1b.tar.gz
  293. +
  294. +all: .installed
  295. +
  296. +.installed: .builded
  297. +   (cd libmad*; sudo make install)
  298. +   touch $@
  299. +
  300. +.builded: .configured
  301. +   (cd libmad*; make)
  302. +   touch $@
  303. +
  304. +.configured: .extracted
  305. +   (  cd libmad* &&\
  306. +      ./configure \
  307. +       --host=$(HOST) \
  308. +       --build=$(BUILD) \
  309. +       --prefix=$(SDKSTAGE)/usr \
  310. +       --libdir=$(SDKSTAGE)/usr/lib/arm-linux-gnueabi$(HF) \
  311. +   )
  312. +   touch $@
  313. +
  314. +.extracted: $(TARBALLS)/$(TARBALL)
  315. +   tar xvfz $(TARBALLS)/$(TARBALL)
  316. +   touch .extracted
  317. +
  318. +$(TARBALLS)/$(TARBALL):
  319. +   $(WGET) $(LOCATION)/$(TARBALL) -O $(TARBALLS)/$(TARBALL)
  320. +  
  321. +clean:
  322. +   rm -rf .installed .builded .configured .extracted libmad*
  323. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/libmad/README xbmc_rellla/tools/a10/depends/libmad/README
  324. --- xbmc_orig/tools/a10/depends/libmad/README   1970-01-01 01:00:00.000000000 +0100
  325. +++ xbmc_rellla/tools/a10/depends/libmad/README 2013-06-12 17:13:39.000000000 +0200
  326. @@ -0,0 +1 @@
  327. +If you encounter crashes playing mp3 please replace libmad with this build.
  328. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/Makefile xbmc_rellla/tools/a10/depends/Makefile
  329. --- xbmc_orig/tools/a10/depends/Makefile    1970-01-01 01:00:00.000000000 +0100
  330. +++ xbmc_rellla/tools/a10/depends/Makefile  2013-06-12 17:13:39.000000000 +0200
  331. @@ -0,0 +1,9 @@
  332. +include depends.mk
  333. +
  334. +all clean:
  335. +   if [ ! -e $(TARBALLS) ]; then mkdir $(TARBALLS); fi
  336. +   (cd opengles; $(MAKE) $@)
  337. +   (cd cedarv; $(MAKE) $@)
  338. +   (cd taglib; $(MAKE) $@)
  339. +   @echo "\nmake $@ for dependencies done.\n"
  340. +
  341. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/opengles/.gitignore xbmc_rellla/tools/a10/depends/opengles/.gitignore
  342. --- xbmc_orig/tools/a10/depends/opengles/.gitignore 1970-01-01 01:00:00.000000000 +0100
  343. +++ xbmc_rellla/tools/a10/depends/opengles/.gitignore   2013-06-12 17:13:39.000000000 +0200
  344. @@ -0,0 +1,4 @@
  345. +/sunxi-mali
  346. +.git
  347. +.installed
  348. +
  349. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/opengles/Makefile xbmc_rellla/tools/a10/depends/opengles/Makefile
  350. --- xbmc_orig/tools/a10/depends/opengles/Makefile   1970-01-01 01:00:00.000000000 +0100
  351. +++ xbmc_rellla/tools/a10/depends/opengles/Makefile 2013-06-12 17:13:39.000000000 +0200
  352. @@ -0,0 +1,31 @@
  353. +include ../depends.mk
  354. +
  355. +MALIGIT=https://github.com/linux-sunxi/sunxi-mali.git
  356. +SUNXI-MALI=sunxi-mali
  357. +VERSION=r3p0
  358. +ABI=armhf
  359. +EGL_TYPE=framebuffer
  360. +
  361. +all: .installed
  362. +
  363. +.installed: .git
  364. +   (   cd $(SUNXI-MALI) &&\
  365. +       make config VERSION=$(VERSION) ABI=$(ABI) EGL_TYPE=$(EGL_TYPE) &&\
  366. +       echo "prefix = $(XBMCPREFIX)/" >> Makefile.setup &&\
  367. +       rm -rf $(XBMCPREFIX) &&\
  368. +       mkdir -p $(XBMCPREFIX)/lib &&\
  369. +       mkdir -p $(XBMCPREFIX)/include &&\
  370. +       make && make install \
  371. +   )
  372. +   touch $@
  373. +
  374. +.git:
  375. +       git clone $(MALIGIT)
  376. +   (   cd $(SUNXI-MALI) &&\
  377. +       git submodule init &&\
  378. +       git submodule update \
  379. +   )
  380. +   touch $@
  381. +
  382. +clean:
  383. +   rm -rf .installed .git $(SUNXI-MALI)
  384. \ Kein Zeilenumbruch am Dateiende.
  385. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/opengles/README xbmc_rellla/tools/a10/depends/opengles/README
  386. --- xbmc_orig/tools/a10/depends/opengles/README 1970-01-01 01:00:00.000000000 +0100
  387. +++ xbmc_rellla/tools/a10/depends/opengles/README   2013-06-12 17:13:39.000000000 +0200
  388. @@ -0,0 +1,3 @@
  389. +I used armel libraries from https://github.com/cnxsoft/a10-bin
  390. +and includes from http://malideveloper.com/files/Mali_OpenGL_ES_2.0_SDK_for_Linux_On_ARM_v1.2.0.9310_Linux.tar.gz
  391. +
  392. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/.gitignore xbmc_rellla/tools/a10/depends/package/.gitignore
  393. --- xbmc_orig/tools/a10/depends/package/.gitignore  1970-01-01 01:00:00.000000000 +0100
  394. +++ xbmc_rellla/tools/a10/depends/package/.gitignore    2013-06-12 17:13:39.000000000 +0200
  395. @@ -0,0 +1,3 @@
  396. +*.deb
  397. +*.tar.gz
  398. +/tmp
  399. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/Makefile xbmc_rellla/tools/a10/depends/package/Makefile
  400. --- xbmc_orig/tools/a10/depends/package/Makefile    1970-01-01 01:00:00.000000000 +0100
  401. +++ xbmc_rellla/tools/a10/depends/package/Makefile  2013-06-12 17:13:39.000000000 +0200
  402. @@ -0,0 +1,42 @@
  403. +include ../depends.mk
  404. +
  405. +LCLPREFIX=$(shell echo $(XBMCPREFIX) | sed 's/^\///g')
  406. +
  407. +DEB=xbmca10.deb
  408. +TARBALL1=xbmca10deb.tar.gz
  409. +TARBALL2=xbmca10.tar.gz
  410. +
  411. +all: $(TARBALL1)
  412. +
  413. +$(TARBALL1): root/DEBIAN/control $(XBMCPREFIX)/lib/xbmc/xbmc.bin README
  414. +   (   rm -rf tmp &&\
  415. +       cp -r root tmp &&\
  416. +       cd tmp &&\
  417. +       tar cf - $(XBMCPREFIX) | tar xf - &&\
  418. +       rm -rf $(LCLPREFIX)/include &&\
  419. +       rm -rf $(LCLPREFIX)/lib/pkgconfig &&\
  420. +       rm -f  $(LCLPREFIX)/lib/*.a &&\
  421. +       $(STRIP) --strip-unneeded `find . -name xbmc.bin -print` &&\
  422. +       $(STRIP) --strip-unneeded `find . -name *.so -print` \
  423. +   )
  424. +   dpkg -b tmp $(DEB)
  425. +   tar cvzf $(TARBALL1) README $(DEB)
  426. +   rm -r tmp $(DEB)
  427. +
  428. +tarball: $(XBMCPREFIX)/lib/xbmc/xbmc.bin
  429. +   (   rm -rf tmp &&\
  430. +       mkdir tmp &&\
  431. +       cd tmp &&\
  432. +       tar cf - $(XBMCPREFIX) | tar xf - &&\
  433. +       rm -rf $(LCLPREFIX)/include &&\
  434. +       rm -rf $(LCLPREFIX)/lib/pkgconfig &&\
  435. +       rm -f  $(LCLPREFIX)/lib/*.a &&\
  436. +       $(STRIP) --strip-unneeded `find . -name xbmc.bin -print` &&\
  437. +       $(STRIP) --strip-unneeded `find . -name *.so -print` \
  438. +   )
  439. +   tar -czvf $(TARBALL2) -C tmp .
  440. +
  441. +clean:
  442. +   rm -rf tmp
  443. +   rm -f $(TARBALL1) $(DEB)
  444. +   rm -f $(TARBALL2)
  445. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/README xbmc_rellla/tools/a10/depends/package/README
  446. --- xbmc_orig/tools/a10/depends/package/README  1970-01-01 01:00:00.000000000 +0100
  447. +++ xbmc_rellla/tools/a10/depends/package/README    2013-06-12 17:13:39.000000000 +0200
  448. @@ -0,0 +1,22 @@
  449. +**WARNING: alpha version - use at your own risk.**
  450. +
  451. +I tested on 1GB mk802 with miniand lubuntu.
  452. +Resolution is fixed to 1280x720.
  453. +
  454. +Installation:
  455. +
  456. +Get miniand lubuntu with 720p resolution for your device from here:
  457. +
  458. +https://www.miniand.com/forums/forums/development/topics/mk802-guides-and-images
  459. +
  460. +After that install xbmca10.deb with the following command:
  461. +
  462. +sudo gdebi xbmca10.deb
  463. +
  464. +Starting:
  465. +
  466. +sudo start xbmc
  467. +
  468. +(Attention: this stops lightdm/x11-session, so it is a good idea to have ssh server running)
  469. +
  470. +First start takes some time since xbmc creates the database and starts downloading plugins.
  471. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/root/DEBIAN/control xbmc_rellla/tools/a10/depends/package/root/DEBIAN/control
  472. --- xbmc_orig/tools/a10/depends/package/root/DEBIAN/control 1970-01-01 01:00:00.000000000 +0100
  473. +++ xbmc_rellla/tools/a10/depends/package/root/DEBIAN/control   2013-06-12 17:13:39.000000000 +0200
  474. @@ -0,0 +1,79 @@
  475. +Section: video
  476. +Priority: optional
  477. +Maintainer: empat zero
  478. +Package: xbmca10
  479. +Architecture: armel
  480. +Version: 0.0.1-alpha
  481. +Depends: mesa-utils,
  482. + x11-utils,
  483. + ttf-liberation,
  484. + ttf-dejavu-core,
  485. + python-imaging,
  486. + python,
  487. + python-support (>= 0.90.0),
  488. + libasound2 (>= 1.0.23),
  489. + libavahi-client3 (>= 0.6.16),
  490. + libavahi-common3 (>= 0.6.16),
  491. + libbluetooth3 (>= 4.91),
  492. + libbz2-1.0,
  493. + libc6 (>= 2.15),
  494. + libcdio13,
  495. + libdbus-1-3 (>= 1.0.2),
  496. + libexpat1 (>= 1.95.8),
  497. + libfreetype6 (>= 2.2.1),
  498. + libfribidi0 (>= 0.19.2),
  499. + libgcc1 (>= 1:4.1.1),
  500. + libgcrypt11 (>= 1.4.5),
  501. + libgl1-mesa-glx | libgl1,
  502. + libglew1.6 (>= 1.6.0),
  503. + libglu1-mesa | libglu1,
  504. + libhal-storage1 (>= 0.5.8.1),
  505. + libhal1 (>= 0.5.8.1),
  506. + libjpeg8 (>= 8c),
  507. + liblzo2-2,
  508. + libmicrohttpd5,
  509. + libmysqlclient18 (>= 5.5.13-1),
  510. + libpcre3 (>= 8.10),
  511. + libpcrecpp0 (>= 7.7),
  512. + libpng12-0 (>= 1.2.13-4),
  513. + libpulse0 (>= 1:1.0),
  514. + libpython2.7 (>= 2.7),
  515. + libsamplerate0 (>= 0.1.7),
  516. + libsdl-mixer1.2,
  517. + libsdl1.2debian (>= 1.2.10-1),
  518. + libsmbclient (>= 2:3.2.0),
  519. + libsqlite3-0 (>= 3.6.11),
  520. + libssl1.0.0 (>= 1.0.0),
  521. + libstdc++6 (>= 4.6),
  522. + libtiff4,
  523. + libudev0 (>= 147),
  524. + libva-glx1,
  525. + libva1 (>> 1.0.15~),
  526. + libvorbis0a (>= 1.1.2),
  527. + libvorbisenc2 (>= 1.1.2),
  528. + libx11-6,
  529. + libxext6,
  530. + libxmu6,
  531. + libxrandr2 (>= 2:1.2.0),
  532. + libyajl1 (>= 1.0.5),
  533. + zlib1g (>= 1:1.1.4),
  534. + libcurl3-gnutls (>= 7.16.2-1),
  535. + libtinyxml2.6.2,
  536. + libssh-4
  537. +Recommends: libass4 (>= 0.9.7),
  538. + libbluray1,
  539. + libcec1,
  540. + libflac8 (>= 1.2.1),
  541. + libmad0 (>= 0.15.1b-3),
  542. + libmodplug1,
  543. + libmp3lame0,
  544. + libmpeg2-4,
  545. + libnfs1,
  546. + libogg0 (>= 1.0rc3),
  547. + libplist1 (>= 0.13),
  548. + librtmp0 (>= 2.3),
  549. + libshairport1,
  550. + libvdpau1 (>= 0.2),
  551. + libvorbisfile3 (>= 1.1.2)
  552. +Description: Allwinner A10 test version of XBMC. Strictly alpha, use at your own risk.
  553. +
  554. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/root/etc/init/xbmc.conf xbmc_rellla/tools/a10/depends/package/root/etc/init/xbmc.conf
  555. --- xbmc_orig/tools/a10/depends/package/root/etc/init/xbmc.conf 1970-01-01 01:00:00.000000000 +0100
  556. +++ xbmc_rellla/tools/a10/depends/package/root/etc/init/xbmc.conf   2013-06-12 17:13:39.000000000 +0200
  557. @@ -0,0 +1,23 @@
  558. +# XBMC Daemon
  559. +#
  560. +
  561. +#thanks, Sam Nazarko
  562. +
  563. +description    "xbmc daemon"
  564. +author     "None"
  565. +
  566. +#you can enable autostart by uncommenting next line
  567. +#start on (started dbus and started mountall and stopped lightdm)
  568. +stop on (xbmc-do-stop or runlevel [!2345])
  569. +
  570. +respawn
  571. +
  572. +pre-start script
  573. +test -x /etc/xbmc-watchdog.sh || { stop; logger -t xbmc "cannot execute /allwinner/xbmc-watchdog.sh, exiting" ; exit 1; }
  574. +end script
  575. +
  576. +pre-stop script
  577. +test "x" == x`pidof xbmc.bin` || kill `pidof xbmc.bin`
  578. +end script
  579. +
  580. +exec /etc/xbmc-watchdog.sh
  581. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/root/etc/xbmc-watchdog.sh xbmc_rellla/tools/a10/depends/package/root/etc/xbmc-watchdog.sh
  582. --- xbmc_orig/tools/a10/depends/package/root/etc/xbmc-watchdog.sh   1970-01-01 01:00:00.000000000 +0100
  583. +++ xbmc_rellla/tools/a10/depends/package/root/etc/xbmc-watchdog.sh 2013-06-12 17:13:39.000000000 +0200
  584. @@ -0,0 +1,49 @@
  585. +#!/bin/sh
  586. +
  587. +#USEHWR="A10HWR=1"
  588. +
  589. +if [ -d /lib/arm-linux-gnueabihf ]
  590. +then
  591. +   #assume linaro rootfs
  592. +   USER=linaro
  593. +   XBMC=/allwinner/xbmc-pvr-binhf/lib/xbmc/xbmc.bin
  594. +else
  595. +   #assume miniand rootfs
  596. +   USER=miniand
  597. +   XBMC=/allwinner/xbmc-pvr-bin/lib/xbmc/xbmc.bin
  598. +fi
  599. +
  600. +#
  601. +#some q&d to avoid editing system config files.
  602. +#
  603. +depmod -a `uname -r`
  604. +modprobe lcd
  605. +modprobe hdmi
  606. +modprobe ump
  607. +modprobe disp
  608. +modprobe mali
  609. +modprobe mali_drm
  610. +chmod 666 /dev/mali /dev/ump /dev/cedar_dev /dev/disp
  611. +chmod -R 666 /dev/input/*
  612. +chmod -R 666 /dev/snd/*
  613. +
  614. +stop lightdm
  615. +
  616. +#thanks, Sam Nazarko
  617. +
  618. +while true
  619. +do
  620. +    su - $USER -c "$USEHWR $XBMC --standalone -fs --lircdev /var/run/lirc/lircd 2>&1 | logger -t xbmc"
  621. +    case "$?" in
  622. +         0) # user quit.
  623. +           sleep 2 ;;
  624. +        64) # shutdown system.
  625. +            poweroff;;
  626. +        65) # warm Restart xbmc
  627. +            sleep 2 ;;
  628. +        66) # Reboot System
  629. +            reboot;;
  630. +         *) # this should not happen
  631. +            sleep 30 ;;
  632. +    esac
  633. +done
  634. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/package/root/.gitignore xbmc_rellla/tools/a10/depends/package/root/.gitignore
  635. --- xbmc_orig/tools/a10/depends/package/root/.gitignore 1970-01-01 01:00:00.000000000 +0100
  636. +++ xbmc_rellla/tools/a10/depends/package/root/.gitignore   2013-06-12 17:13:39.000000000 +0200
  637. @@ -0,0 +1 @@
  638. +/allwinner
  639. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/README xbmc_rellla/tools/a10/depends/README
  640. --- xbmc_orig/tools/a10/depends/README  1970-01-01 01:00:00.000000000 +0100
  641. +++ xbmc_rellla/tools/a10/depends/README    2013-06-12 17:13:39.000000000 +0200
  642. @@ -0,0 +1,25 @@
  643. +Please look at depends.mk.
  644. +After adjusting run make && make -C xbmc.
  645. +If configure is done you can compile from the source root directory.
  646. +
  647. +KNOWN PROBLEMS WITH HARDWARE RENDERING:
  648. +=======================================
  649. +
  650. +- To enable hardware layer rendering you have to set environment A10HWR=1.
  651. +
  652. +- Sometimes the display engine does not initialize correctly and not all
  653. +  colors get rendered or you get pixel noise. After some video startups this
  654. +  disappears.
  655. +
  656. +- Using 1080p and alpha video blending there is a horrible screen tearing,
  657. +  for this reason alpha blending is disabled at 1080p for video at the moment.
  658. +  You can enable it (e.g. for tracking down the problem at kernel level)
  659. +  by setting the environment variable A10AB=1.
  660. +
  661. +KNOWN PROBLEMS WITH PVR:
  662. +========================
  663. +
  664. +- only SD-TV tested (since i do not have DVB-S2 hardware)
  665. +
  666. +PLEASE REMEMBER: This is poc.
  667. +
  668. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/taglib/.gitignore xbmc_rellla/tools/a10/depends/taglib/.gitignore
  669. --- xbmc_orig/tools/a10/depends/taglib/.gitignore   1970-01-01 01:00:00.000000000 +0100
  670. +++ xbmc_rellla/tools/a10/depends/taglib/.gitignore 2013-06-12 17:13:39.000000000 +0200
  671. @@ -0,0 +1,4 @@
  672. +.installed
  673. +.builded
  674. +.extracted
  675. +/taglib*
  676. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/taglib/Makefile xbmc_rellla/tools/a10/depends/taglib/Makefile
  677. --- xbmc_orig/tools/a10/depends/taglib/Makefile 1970-01-01 01:00:00.000000000 +0100
  678. +++ xbmc_rellla/tools/a10/depends/taglib/Makefile   2013-06-12 17:13:39.000000000 +0200
  679. @@ -0,0 +1,34 @@
  680. +include ../depends.mk
  681. +
  682. +LOCATION=https://github.com/downloads/taglib/taglib
  683. +TARBALL=taglib-1.8.tar.gz
  684. +
  685. +all: .installed
  686. +
  687. +.installed: .builded
  688. +   $(MAKE) -C taglib*/build install
  689. +   touch $@
  690. +
  691. +.builded: .extracted
  692. +   (   cd taglib* && rm -rf build && mkdir build && cd build &&\
  693. +       CC=$(CC) CXX=$(CXX) cmake        \
  694. +           -DENABLE_STATIC=1 \
  695. +           -DCMAKE_C_FLAGS:STRING="$(CPPFLAGS) $(CFLAGS)" \
  696. +           -DCMAKE_CXX_FLAGS:STRING="$(CPPFLAGS) $(CXXFLAGS)" \
  697. +           -DCMAKE_INCLUDE_PATH=$(PREFIX)/include \
  698. +           -DCMAKE_LIBRARY_PATH=$(PREFIX)/lib \
  699. +           -DCMAKE_INSTALL_NAME_DIR=$(PREFIX)/lib \
  700. +           -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
  701. +           -DCMAKE_FIND_ROOT_PATH="$(SDKSTAGE):/" .. \
  702. +    )
  703. +   touch $@
  704. +
  705. +.extracted: $(TARBALLS)/$(TARBALL)
  706. +   tar xvfz $(TARBALLS)/$(TARBALL)
  707. +   touch .extracted
  708. +
  709. +$(TARBALLS)/$(TARBALL):
  710. +   $(WGET) $(LOCATION)/$(TARBALL) -O $(TARBALLS)/$(TARBALL)
  711. +  
  712. +clean:
  713. +   rm -rf .installed .builded .configured .extracted taglib*
  714. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/taglib/README xbmc_rellla/tools/a10/depends/taglib/README
  715. --- xbmc_orig/tools/a10/depends/taglib/README   1970-01-01 01:00:00.000000000 +0100
  716. +++ xbmc_rellla/tools/a10/depends/taglib/README 2013-06-12 17:13:39.000000000 +0200
  717. @@ -0,0 +1,3 @@
  718. +TODO:
  719. +
  720. +(Build at your own in lib/taglib. Use native compile and copy to rootfs.)
  721. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/a10/depends/xbmc/Makefile xbmc_rellla/tools/a10/depends/xbmc/Makefile
  722. --- xbmc_orig/tools/a10/depends/xbmc/Makefile   1970-01-01 01:00:00.000000000 +0100
  723. +++ xbmc_rellla/tools/a10/depends/xbmc/Makefile 2013-06-12 17:13:40.000000000 +0200
  724. @@ -0,0 +1,36 @@
  725. +include ../depends.mk
  726. +
  727. +CONFIGURE=./configure \
  728. +   --prefix=$(PREFIX) \
  729. +   --build=$(BUILD) \
  730. +   --host=$(HOST) \
  731. +   --disable-x11 \
  732. +   --disable-sdl \
  733. +   --disable-xrandr \
  734. +   --disable-joystick \
  735. +   --disable-gl \
  736. +   --disable-vdpau \
  737. +   --disable-vaapi \
  738. +   --disable-openmax \
  739. +   --enable-neon \
  740. +   --enable-gles \
  741. +   --disable-mysql \
  742. +
  743. +SRC=../../../../
  744. +
  745. +all: dep
  746. +   (cd $(SRC); make -j$(JOBS))
  747. +
  748. +install-only:
  749. +   (cd $(SRC); make -j$(JOBS) install)
  750. +
  751. +bin-only:
  752. +   (cd $(SRC); make -j$(JOBS))
  753. +
  754. +dep: bootstrap configure
  755. +
  756. +bootstrap:
  757. +   (cd $(SRC); ./bootstrap)
  758. +
  759. +configure:
  760. +   (cd $(SRC); $(CONFIGURE))
  761. \ Kein Zeilenumbruch am Dateiende.
  762. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/android/depends/cedarv/Makefile xbmc_rellla/tools/android/depends/cedarv/Makefile
  763. --- xbmc_orig/tools/android/depends/cedarv/Makefile 1970-01-01 01:00:00.000000000 +0100
  764. +++ xbmc_rellla/tools/android/depends/cedarv/Makefile   2013-06-12 17:13:40.000000000 +0200
  765. @@ -0,0 +1,44 @@
  766. +include ../Makefile.include
  767. +
  768. +TARBALL=cedarx-libs.tar.gz
  769. +URL=https://github.com/linux-sunxi/cedarx-libs/tarball/master
  770. +
  771. +SRCS = \
  772. +   libcedarv/vdecoder.c \
  773. +   libcedarv/awprintf.c \
  774. +   fbm/fbm.c \
  775. +   vbv/vbv.c \
  776. +   adapter/libve_adapter.c \
  777. +   adapter/os_adapter.c
  778. +
  779. +OBJS = $(SRCS:%.c=%.o)
  780. +
  781. +TARGET=libcedarv.a
  782. +
  783. +all: $(TARGET)
  784. +
  785. +$(TARGET) : .extracted $(OBJS)
  786. +   rm -f $(TARGET)
  787. +   $(AR) cq $(TARGET) $(OBJS)
  788. +
  789. +.extracted: $(TARBALLS_LOCATION)/$(TARBALL)
  790. +   rm -rf tmp 
  791. +   mkdir tmp
  792. +   ( cd tmp &&\
  793. +     tar xvfz $(TARBALLS_LOCATION)/$(TARBALL) &&\
  794. +     cd linux-sunxi-*/libcedarv/android &&\
  795. +     rm Makefile .gitignore cedardefs.mk &&\
  796. +     mv * ../../../../ \
  797. +   )
  798. +   rm -rf tmp $(OBJS)
  799. +   touch $@
  800. +  
  801. +$(TARBALLS_LOCATION)/$(TARBALL):
  802. +   install -d $(TARBALLS_LOCATION)
  803. +   wget $(URL) -O $(TARBALLS)/$(TARBALL)
  804. +
  805. +clean:
  806. +   rm -f $(TARGET) $(OBJS)
  807. +   rm -rf tmp adapter fbm libcedarv libvecore vbv
  808. +   rm -f .installed .extracted cedardev_api.h drv_display_sun4i.h
  809. +
  810. diff -b -u -r -N '--exclude=.git' xbmc_orig/tools/Linux/xbmc.sh.in xbmc_rellla/tools/Linux/xbmc.sh.in
  811. --- xbmc_orig/tools/Linux/xbmc.sh.in    2013-06-12 16:20:59.000000000 +0200
  812. +++ xbmc_rellla/tools/Linux/xbmc.sh.in  2013-06-12 17:13:38.000000000 +0200
  813. @@ -107,11 +107,12 @@
  814.    echo "Crash report available at $FILE"
  815.  }
  816.  
  817. -python @datadir@/xbmc/FEH.py $SAVED_ARGS
  818. -RET=$?
  819. -if [ $RET -ne 0 ]; then
  820. -  exit $RET
  821. -fi
  822. +# disable glxinfo check
  823. +# python @datadir@/xbmc/FEH.py $SAVED_ARGS
  824. +# RET=$?
  825. +# if [ $RET -ne 0 ]; then
  826. +#   exit $RET
  827. +# fi
  828.  
  829.  if which gdb >/dev/null 2>&1; then
  830.    # Output warning in case ulimit is unsupported by shell
  831. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/Application.cpp xbmc_rellla/xbmc/Application.cpp
  832. --- xbmc_orig/xbmc/Application.cpp  2013-06-12 17:20:26.000000000 +0200
  833. +++ xbmc_rellla/xbmc/Application.cpp    2013-06-12 17:13:42.000000000 +0200
  834. @@ -2130,6 +2130,15 @@
  835.            singleFrameTime = 200;  // 5 fps, <=200 ms latency to wake up
  836.        }
  837.  
  838. +#ifdef ALLWINNERA10
  839. +      if (IsInScreenSaver())
  840. +      {
  841. +        //so the mk802 does not burn down the house when i'm sleeping :)
  842. +        limitFrames = true;
  843. +        singleFrameTime = 100;
  844. +      }
  845. +#endif
  846. +
  847.        decrement = true;
  848.      }
  849.    }
  850. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp xbmc_rellla/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
  851. --- xbmc_orig/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp   2013-06-12 17:20:26.000000000 +0200
  852. +++ xbmc_rellla/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2013-06-12 17:13:43.000000000 +0200
  853. @@ -775,6 +775,15 @@
  854.        {
  855.          EnumerateDevice(list, name, desc ? desc : name, config);
  856.        }
  857. +      else
  858. +      {
  859. +        /* sun4i whilelist */
  860. +        std::string strDevice = std::string(name);
  861. +        size_t found = strDevice.find("sun4i");
  862. +        
  863. +        if(found != std::string::npos)
  864. +          EnumerateDevice(list, name, desc ? desc : name, config);
  865. +      }
  866.      }
  867.      free(io);
  868.      free(name);
  869. @@ -876,6 +885,10 @@
  870.    else if (name.substr(0, 6) == "iec958" || name.substr(0, 5) == "spdif")
  871.      return AE_DEVTYPE_IEC958;
  872.  
  873. +  /* sun4i hdmi device */
  874. +  if(name.find("sun4isndhdmi") != std::string::npos)
  875. +    return AE_DEVTYPE_HDMI;
  876. +
  877.    return AE_DEVTYPE_PCM;
  878.  }
  879.  
  880. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
  881. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp    2013-06-12 17:20:26.000000000 +0200
  882. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp  2013-06-12 17:13:43.000000000 +0200
  883. @@ -41,6 +41,9 @@
  884.  #if defined(HAS_LIBAMCODEC)
  885.  #include "Video/DVDVideoCodecAmlogic.h"
  886.  #endif
  887. +#ifdef ALLWINNERA10
  888. +#include "Video/DVDVideoCodecA10.h"
  889. +#endif
  890.  #include "Audio/DVDAudioCodecFFmpeg.h"
  891.  #include "Audio/DVDAudioCodecLibMad.h"
  892.  #include "Audio/DVDAudioCodecPcm.h"
  893. @@ -263,6 +266,10 @@
  894.    }
  895.  #endif
  896.  
  897. +#ifdef ALLWINNERA10
  898. +  if ( (pCodec = OpenCodec(new CDVDVideoCodecA10(), hint, options)) ) return pCodec;
  899. +#endif
  900. +
  901.    // try to decide if we want to try halfres decoding
  902.  #if !defined(_LINUX) && !defined(_WIN32)
  903.    float pixelrate = (float)hint.width*hint.height*hint.fpsrate/hint.fpsscale;
  904. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp
  905. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp 1970-01-01 01:00:00.000000000 +0100
  906. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp   2013-06-12 17:13:43.000000000 +0200
  907. @@ -0,0 +1,551 @@
  908. +#include "DVDVideoCodecA10.h"
  909. +#include "DVDClock.h"
  910. +#include "utils/log.h"
  911. +#include "threads/Atomics.h"
  912. +#include "../VideoRenderers/LinuxRendererA10.h"
  913. +//check for eden
  914. +#include "../VideoRenderers/RenderFlags.h"
  915. +#ifdef CONF_FLAGS_FORMAT_A10BUF
  916. +#define RENDER_FMT_YUV420P      DVDVideoPicture::FMT_YUV420P
  917. +#define RENDER_FMT_A10BUF       DVDVideoPicture::FMT_A10BUF
  918. +#endif
  919. +
  920. +#include <sys/ioctl.h>
  921. +#include <math.h>
  922. +
  923. +static long g_cedaropen = 0;
  924. +
  925. +#define PREFRAMES 10 //no. of stream frames to buffer
  926. +
  927. +#define A10DEBUG
  928. +#define MEDIAINFO
  929. +
  930. +#define CODEC_OK        1
  931. +#define CODEC_BAD       0
  932. +
  933. +/*Cedar Decoder*/
  934. +#define A10ENABLE_MPEG1         CODEC_OK
  935. +#define A10ENABLE_MPEG2         CODEC_OK
  936. +#define A10ENABLE_H264          CODEC_OK
  937. +#define A10ENABLE_H263          CODEC_BAD //fails completely
  938. +#define A10ENABLE_VC1_WVC1      CODEC_OK
  939. +#define A10ENABLE_VP6           CODEC_OK
  940. +#define A10ENABLE_VP8           CODEC_OK
  941. +#define A10ENABLE_FLV1          CODEC_OK
  942. +#define A10ENABLE_MJPEG         CODEC_OK
  943. +#define A10ENABLE_WMV1          CODEC_OK
  944. +#define A10ENABLE_WMV2          CODEC_OK
  945. +#define A10ENABLE_WMV3          CODEC_OK
  946. +#define A10ENABLE_MPEG4V1       CODEC_BAD //??
  947. +#define A10ENABLE_MPEG4V2       CODEC_BAD //fails completely
  948. +#define A10ENABLE_MPEG4V3       CODEC_OK
  949. +#define A10ENABLE_DIVX4         CODEC_OK
  950. +#define A10ENABLE_DIVX5         CODEC_OK
  951. +#define A10ENABLE_XVID          CODEC_OK
  952. +
  953. +/*
  954. +TODO:- Finish adding MPEG4 codecs tags
  955. +     - Find out whats causing problems with several codecs, something is wrong or missing in the maping.
  956. +     - Add RealVideo once .rm files can be opened.
  957. +     - AVS and RMG2 codec support.
  958. +
  959. +Note: AllWinner doc says to add FLV container type to VP6 and FLV1, but if i do so they stop working.
  960. +*/
  961. +
  962. +#define _4CC(c1,c2,c3,c4) (((u32)(c4)<<24)|((u32)(c3)<<16)|((u32)(c2)<<8)|(u32)(c1))
  963. +
  964. +static void freecallback(void *callbackpriv, void *pictpriv, cedarv_picture_t &pict)
  965. +{
  966. +  ((CDVDVideoCodecA10*)callbackpriv)->FreePicture(pictpriv, pict);
  967. +}
  968. +
  969. +CDVDVideoCodecA10::CDVDVideoCodecA10()
  970. +{
  971. +  m_hcedarv  = NULL;
  972. +  memset(&m_picture, 0, sizeof(m_picture));
  973. +}
  974. +
  975. +CDVDVideoCodecA10::~CDVDVideoCodecA10()
  976. +{
  977. +  Dispose();
  978. +}
  979. +
  980. +/*
  981. + * Open the decoder, returns true on success
  982. + */
  983. +bool CDVDVideoCodecA10::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
  984. +{
  985. +  if (getenv("NOA10"))
  986. +  {
  987. +    CLog::Log(LOGNOTICE, "A10: disabled.\n");
  988. +    return false;
  989. +  }
  990. +
  991. +  if (hints.software)
  992. +  {
  993. +    CLog::Log(LOGNOTICE, "A10: software decoding requested.\n");
  994. +    return false;
  995. +  }
  996. +
  997. +  CLog::Log(LOGNOTICE, "A10: using hardware rendering.\n");
  998. +
  999. +  m_hints  = hints;
  1000. +  m_aspect = m_hints.aspect;
  1001. +
  1002. +  memset(&m_info, 0, sizeof(m_info));
  1003. +  if (m_hints.fpsscale)
  1004. +  {
  1005. +    m_info.frame_rate = (double)m_hints.fpsrate / m_hints.fpsscale * 1000;
  1006. +  }
  1007. +  if (m_info.frame_rate)
  1008. +  {
  1009. +    m_info.frame_duration = 1000000000.0 / m_info.frame_rate;
  1010. +  }
  1011. +  m_info.video_width = m_hints.width;
  1012. +  m_info.video_height = m_hints.height;
  1013. +  m_info.aspect_ratio = 1000;
  1014. +  m_info.is_pts_correct = !m_hints.ptsinvalid;
  1015. +  m_info.sub_format = CEDARV_SUB_FORMAT_UNKNOW;
  1016. +  m_info.container_format = CEDARV_CONTAINER_FORMAT_UNKNOW;
  1017. +  m_info.init_data_len = 0;
  1018. +  m_info.init_data = NULL;
  1019. +
  1020. +#ifdef MEDIAINFO
  1021. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: fpsrate %d / fpsscale %d\n", m_hints.fpsrate, m_hints.fpsscale);
  1022. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: CodecID %d \n", m_hints.codec);
  1023. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: StreamType %d \n", m_hints.type);
  1024. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Level %d \n", m_hints.level);
  1025. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Profile %d \n", m_hints.profile);
  1026. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: PTS_invalid %d \n", m_hints.ptsinvalid);
  1027. +  CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Tag %d \n", m_hints.codec_tag);
  1028. +  { u8 *pb = (u8*)&m_hints.codec_tag;
  1029. +    if (isalnum(pb[0]) && isalnum(pb[1]) && isalnum(pb[2]) && isalnum(pb[3]))
  1030. +      CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Tag fourcc %c%c%c%c\n", pb[0], pb[1], pb[2], pb[3]);
  1031. +  }
  1032. +  if (m_hints.extrasize)
  1033. +  {
  1034. +    int  i;
  1035. +    char buf[4096];
  1036. +
  1037. +    for (i = 0; i < m_hints.extrasize; i++)
  1038. +      sprintf(buf+i*2, "%02x", ((u8*)m_hints.extradata)[i]);
  1039. +    CLog::Log(LOGDEBUG, "A10: MEDIAINFO: extradata %d %s\n", m_hints.extrasize, buf);
  1040. +  }
  1041. +#endif
  1042. +
  1043. +  m_info.init_data_len = m_hints.extrasize;
  1044. +  m_info.init_data     = (u8*)m_hints.extradata;
  1045. +
  1046. +  switch(m_hints.codec)
  1047. +  {
  1048. +  //MPEG1
  1049. +#if A10ENABLE_MPEG1
  1050. +  case CODEC_ID_MPEG1VIDEO:
  1051. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG2;
  1052. +    m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG1;
  1053. +    break;
  1054. +#endif
  1055. +    //MPEG2
  1056. +#ifdef A10ENABLE_MPEG2
  1057. +  case CODEC_ID_MPEG2VIDEO:
  1058. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG2;
  1059. +    m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG2;
  1060. +    //if passing init_data it fails..
  1061. +    m_info.init_data_len = 0;
  1062. +    m_info.init_data = NULL;
  1063. +    break;
  1064. +#endif
  1065. +    //H263
  1066. +#if A10ENABLE_H263
  1067. +  case CODEC_ID_H263:
  1068. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1069. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_H263;
  1070. +    break;
  1071. +#endif
  1072. +    //H264
  1073. +#if A10ENABLE_H264
  1074. +  case CODEC_ID_H264:
  1075. +    m_info.format = CEDARV_STREAM_FORMAT_H264;
  1076. +    if(m_hints.codec_tag==27) //M2TS and TS
  1077. +      m_info.container_format = CEDARV_CONTAINER_FORMAT_TS;
  1078. +    break;
  1079. +#endif
  1080. +    //VP6
  1081. +#if A10ENABLE_VP6
  1082. +  case CODEC_ID_VP6F:
  1083. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1084. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_VP6;
  1085. +    break;
  1086. +#endif
  1087. +    //WMV1
  1088. +#if A10ENABLE_WMV1
  1089. +  case CODEC_ID_WMV1:
  1090. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1091. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV1;
  1092. +    break;
  1093. +#endif
  1094. +    //WMV2
  1095. +#if A10ENABLE_WMV2
  1096. +  case CODEC_ID_WMV2:
  1097. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1098. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV2;
  1099. +    break;
  1100. +#endif
  1101. +    //WMV3
  1102. +#if A10ENABLE_WMV3
  1103. +  case CODEC_ID_WMV3:
  1104. +    m_info.format = CEDARV_STREAM_FORMAT_VC1;
  1105. +    break;
  1106. +#endif
  1107. +    //VC1 and WVC1
  1108. +#if A10ENABLE_VC1_WVC1
  1109. +  case CODEC_ID_VC1:
  1110. +    m_info.format = CEDARV_STREAM_FORMAT_VC1;
  1111. +    break;
  1112. +#endif
  1113. +    //MJPEG
  1114. +#if A10ENABLE_MJPEG
  1115. +  case CODEC_ID_MJPEG:
  1116. +    m_info.format = CEDARV_STREAM_FORMAT_MJPEG;
  1117. +    break;
  1118. +#endif
  1119. +    //VP8
  1120. +#if A10ENABLE_VP8
  1121. +  case CODEC_ID_VP8:
  1122. +    m_info.format = CEDARV_STREAM_FORMAT_VP8;
  1123. +    break;
  1124. +#endif
  1125. +    //MSMPEG4V1
  1126. +#if A10ENABLE_MPEG4V1
  1127. +  case CODEC_ID_MSMPEG4V1:
  1128. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1129. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX1;
  1130. +    break;
  1131. +#endif
  1132. +    //MSMPEG4V2
  1133. +#if A10ENABLE_MPEG4V2
  1134. +  case CODEC_ID_MSMPEG4V2:
  1135. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1136. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX2;
  1137. +    break;
  1138. +#endif
  1139. +    //MSMPEG4V3
  1140. +#if A10ENABLE_MPEG4V3
  1141. +  case CODEC_ID_MSMPEG4V3:
  1142. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1143. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX3;
  1144. +    break;
  1145. +#endif
  1146. +    //Sorensson Spark (FLV1)
  1147. +#if A10ENABLE_FLV1
  1148. +  case CODEC_ID_FLV1:
  1149. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1150. +    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_SORENSSON_H263;
  1151. +    break;
  1152. +#endif
  1153. +    //Detected as MPEG4 (ID 13)
  1154. +  case CODEC_ID_MPEG4:
  1155. +    m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1156. +    switch(m_hints.codec_tag)
  1157. +    {
  1158. +    //DX40/DIVX4, divx
  1159. +#if A10ENABLE_DIVX4
  1160. +    case _4CC('D','I','V','X'):
  1161. +    case _4CC('d','i','v','x'):
  1162. +      m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX4;
  1163. +      break;
  1164. +#endif
  1165. +    //DX50/DIVX5
  1166. +#if A10ENABLE_DIVX5
  1167. +    case _4CC('D','X','5','0'):
  1168. +    case _4CC('d','x','5','0'):
  1169. +    case _4CC('D','I','V','5'):
  1170. +    case _4CC('d','i','v','5'):
  1171. +      m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX5;
  1172. +      break;
  1173. +#endif
  1174. +   //XVID
  1175. +#if A10ENABLE_XVID
  1176. +    case _4CC('X','V','I','D'):
  1177. +    case _4CC('x','v','i','d'):
  1178. +    case _4CC('X','v','i','D'):
  1179. +    case _4CC('M','P','4','V'):
  1180. +    case _4CC('m','p','4','v'):
  1181. +    case _4CC('M','P','4','S'):
  1182. +    case _4CC('m','p','4','s'):
  1183. +    case _4CC('P','M','P','4'):
  1184. +    case _4CC('p','m','p','4'):
  1185. +    case _4CC('F','M','P','4'):
  1186. +    case _4CC('f','m','p','4'):
  1187. +    case _4CC('X','V','I','X'):
  1188. +    case _4CC('x','v','i','x'):
  1189. +      m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_XVID;
  1190. +      break;
  1191. +#endif
  1192. +    default:
  1193. +      CLog::Log(LOGERROR, "A10: MPEG4 codec tag %d is unknown.\n", m_hints.codec_tag);
  1194. +      return false;
  1195. +    }
  1196. +    break;
  1197. +
  1198. +  default:
  1199. +    CLog::Log(LOGERROR, "A10: codecid %d is unknown.\n", m_hints.codec);
  1200. +    return false;
  1201. +  }
  1202. +
  1203. +  return DoOpen();
  1204. +}
  1205. +
  1206. +bool CDVDVideoCodecA10::DoOpen()
  1207. +{
  1208. +  s32 ret;
  1209. +
  1210. +  if (cas(&g_cedaropen, 0, 1) != 0)
  1211. +  {
  1212. +    CLog::Log(LOGERROR, "A10: cedar already in use");
  1213. +    return false;
  1214. +  }
  1215. +
  1216. +  m_hcedarv = libcedarv_init(&ret);
  1217. +  if (ret < 0)
  1218. +  {
  1219. +    CLog::Log(LOGERROR, "A10: libcedarv_init failed. (%d)\n", ret);
  1220. +    goto Error;
  1221. +  }
  1222. +
  1223. +  ret = m_hcedarv->set_vstream_info(m_hcedarv, &m_info);
  1224. +  if (ret < 0)
  1225. +  {
  1226. +    CLog::Log(LOGERROR, "A10: set_vstream_info failed. (%d)\n", ret);
  1227. +    goto Error;
  1228. +  }
  1229. +
  1230. +  ret = m_hcedarv->open(m_hcedarv);
  1231. +  if (ret < 0)
  1232. +  {
  1233. +    CLog::Log(LOGERROR, "A10: open failed. (%d)\n", ret);
  1234. +    goto Error;
  1235. +  }
  1236. +
  1237. +  m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_RESET, 0);
  1238. +
  1239. +  ret = m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_PLAY, 0);
  1240. +  if (ret < 0)
  1241. +  {
  1242. +    CLog::Log(LOGERROR, "A10: CEDARV_COMMAND_PLAY failed. (%d)\n", ret);
  1243. +    goto Error;
  1244. +  }
  1245. +
  1246. +  m_prebuffer = true;
  1247. +  m_nframes   = 0;
  1248. +
  1249. +  CLog::Log(LOGDEBUG, "A10: cedar open.");
  1250. +  return true;
  1251. +
  1252. +Error:
  1253. +
  1254. +  Dispose();
  1255. +  return false;
  1256. +}
  1257. +
  1258. +/*
  1259. + * Dispose, Free all resources
  1260. + */
  1261. +void CDVDVideoCodecA10::Dispose()
  1262. +{
  1263. +  A10VLFreeQueue();
  1264. +  if (m_hcedarv)
  1265. +  {
  1266. +    m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_STOP, 0);
  1267. +    m_hcedarv->close(m_hcedarv);
  1268. +    libcedarv_exit(m_hcedarv);
  1269. +    m_hcedarv = NULL;
  1270. +    cas(&g_cedaropen, 1, 0);
  1271. +    CLog::Log(LOGDEBUG, "A10: cedar dispose.");
  1272. +  }
  1273. +}
  1274. +
  1275. +/*
  1276. + * returns one or a combination of VC_ messages
  1277. + * pData and iSize can be NULL, this means we should flush the rest of the data.
  1278. + */
  1279. +int CDVDVideoCodecA10::Decode(BYTE* pData, int iSize, double dts, double pts)
  1280. +{
  1281. +  int                        status = 0;
  1282. +  s32                        ret = 0;
  1283. +  u8                        *buf0, *buf1;
  1284. +  u32                        bufsize0, bufsize1;
  1285. +  cedarv_stream_data_info_t  dinf;
  1286. +  cedarv_picture_t           picture;
  1287. +
  1288. +  if (!m_hcedarv)
  1289. +    return VC_ERROR;
  1290. +
  1291. +  if (m_nframes == 0)
  1292. +  {
  1293. +    m_hcedarv->decode(m_hcedarv);
  1294. +    m_hcedarv->decode(m_hcedarv);
  1295. +  }
  1296. +
  1297. +  if (pData && iSize)
  1298. +  {
  1299. +    ret = m_hcedarv->request_write(m_hcedarv, iSize, &buf0, &bufsize0, &buf1, &bufsize1);
  1300. +    if(ret < 0)
  1301. +    {
  1302. +      CLog::Log(LOGERROR, "A10: request_write failed.\n");
  1303. +      return VC_ERROR;
  1304. +    }
  1305. +    if (bufsize1)
  1306. +    {
  1307. +      memcpy(buf0, pData, bufsize0);
  1308. +      memcpy(buf1, pData+bufsize0, bufsize1);
  1309. +    }
  1310. +    else
  1311. +    {
  1312. +      memcpy(buf0, pData, iSize);
  1313. +    }
  1314. +
  1315. +    memset(&dinf, 0, sizeof(dinf));
  1316. +    dinf.lengh = iSize;
  1317. +#ifdef CEDARV_FLAG_DECODE_NO_DELAY
  1318. +    dinf.flags = CEDARV_FLAG_FIRST_PART | CEDARV_FLAG_LAST_PART | CEDARV_FLAG_DECODE_NO_DELAY;
  1319. +#else
  1320. +    dinf.flags = CEDARV_FLAG_FIRST_PART | CEDARV_FLAG_LAST_PART;
  1321. +#endif
  1322. +    if (pts != DVD_NOPTS_VALUE)
  1323. +    {
  1324. +      dinf.flags |= CEDARV_FLAG_PTS_VALID;
  1325. +      dinf.pts = pts;
  1326. +    }
  1327. +    else if (dts != DVD_NOPTS_VALUE)
  1328. +    {
  1329. +      dinf.flags |= CEDARV_FLAG_PTS_VALID;
  1330. +      dinf.pts = dts;
  1331. +    }
  1332. +
  1333. +    ret = m_hcedarv->update_data(m_hcedarv, &dinf);
  1334. +    if (ret)
  1335. +    {
  1336. +      CLog::Log(LOGERROR, "A10: update_data(): %d\n", ret);
  1337. +    }
  1338. +
  1339. +    if (m_prebuffer)
  1340. +    {
  1341. +      m_nframes++;
  1342. +      status |= VC_BUFFER;
  1343. +      if (m_nframes >= PREFRAMES)
  1344. +        m_prebuffer = false;
  1345. +    }
  1346. +  }
  1347. +
  1348. +  if (!m_prebuffer)
  1349. +  {
  1350. +    ret = m_hcedarv->decode(m_hcedarv);
  1351. +    switch(ret)
  1352. +    {
  1353. +    case CEDARV_RESULT_OK:
  1354. +    case CEDARV_RESULT_FRAME_DECODED:
  1355. +    case CEDARV_RESULT_KEYFRAME_DECODED:
  1356. +    case CEDARV_RESULT_NO_BITSTREAM:
  1357. +      status |= VC_BUFFER;
  1358. +      break;
  1359. +    case CEDARV_RESULT_NO_FRAME_BUFFER:
  1360. +      CLog::Log(LOGNOTICE, "A10: no frames. free queue.");
  1361. +      A10VLFreeQueue();
  1362. +      //ret = m_hcedarv->decode(m_hcedarv);
  1363. +      break;
  1364. +
  1365. +    default:
  1366. +      CLog::Log(LOGERROR, "A10: decode(%d): %d\n", iSize, ret);
  1367. +      break;
  1368. +    }
  1369. +
  1370. +    ret = m_hcedarv->display_request(m_hcedarv, &picture);
  1371. +    if (ret > 3 || ret < -1)
  1372. +    {
  1373. +      CLog::Log(LOGERROR, "A10: display_request(): %d\n", ret);
  1374. +    }
  1375. +    else if (ret == 0)
  1376. +    {
  1377. +      float aspect_ratio = m_aspect;
  1378. +
  1379. +      m_picture.dts     = DVD_NOPTS_VALUE;
  1380. +      m_picture.pts     = picture.pts > 0 ? (double)picture.pts : DVD_NOPTS_VALUE;
  1381. +      m_picture.iWidth  = picture.display_width;
  1382. +      m_picture.iHeight = picture.display_height;
  1383. +
  1384. +      if (picture.is_progressive) m_picture.iFlags &= ~DVP_FLAG_INTERLACED;
  1385. +      else                        m_picture.iFlags |= DVP_FLAG_INTERLACED;
  1386. +
  1387. +      /* XXX: we suppose the screen has a 1.0 pixel ratio */ // CDVDVideo will compensate it.
  1388. +      if (aspect_ratio <= 0.0)
  1389. +        aspect_ratio = (float)m_picture.iWidth / (float)m_picture.iHeight;
  1390. +
  1391. +      m_picture.iDisplayHeight = m_picture.iHeight;
  1392. +      m_picture.iDisplayWidth  = ((int)lrint(m_picture.iHeight * aspect_ratio)) & -3;
  1393. +      if (m_picture.iDisplayWidth > m_picture.iWidth)
  1394. +      {
  1395. +        m_picture.iDisplayWidth  = m_picture.iWidth;
  1396. +        m_picture.iDisplayHeight = ((int)lrint(m_picture.iWidth / aspect_ratio)) & -3;
  1397. +      }
  1398. +
  1399. +      m_picture.format     = RENDER_FMT_A10BUF;
  1400. +      m_picture.a10buffer  = A10VLPutQueue(freecallback, (void*)this, NULL, picture);
  1401. +      m_picture.iFlags    |= DVP_FLAG_ALLOCATED;
  1402. +
  1403. +      //CLog::Log(LOGDEBUG, "A10: decode %d\n", buffer->picture.id);
  1404. +
  1405. +      status |= VC_PICTURE;
  1406. +    }
  1407. +  }
  1408. +
  1409. +  return status;
  1410. +}
  1411. +
  1412. +/*
  1413. + * Reset the decoder.
  1414. + * Should be the same as calling Dispose and Open after each other
  1415. + */
  1416. +void CDVDVideoCodecA10::Reset()
  1417. +{
  1418. +  cedarv_picture_t pict;
  1419. +
  1420. +  CLog::Log(LOGDEBUG, "A10: reset requested");
  1421. +  m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_FLUSH, 0);
  1422. +  while(m_hcedarv->display_request(m_hcedarv, &pict) == 0)
  1423. +    m_hcedarv->display_release(m_hcedarv, pict.id);
  1424. +  A10VLFreeQueue();
  1425. +}
  1426. +
  1427. +/*
  1428. + * returns true if successfull
  1429. + * the data is valid until the next Decode call
  1430. + */
  1431. +bool CDVDVideoCodecA10::GetPicture(DVDVideoPicture* pDvdVideoPicture)
  1432. +{
  1433. +  if (m_picture.iFlags & DVP_FLAG_ALLOCATED)
  1434. +  {
  1435. +    *pDvdVideoPicture = m_picture;
  1436. +    return true;
  1437. +  }
  1438. +  return false;
  1439. +}
  1440. +
  1441. +bool CDVDVideoCodecA10::ClearPicture(DVDVideoPicture* pDvdVideoPicture)
  1442. +{
  1443. +  return CDVDVideoCodec::ClearPicture(pDvdVideoPicture);
  1444. +}
  1445. +
  1446. +void CDVDVideoCodecA10::SetDropState(bool bDrop)
  1447. +{
  1448. +}
  1449. +
  1450. +const char* CDVDVideoCodecA10::GetName()
  1451. +{
  1452. +  return "A10";
  1453. +}
  1454. +
  1455. +void CDVDVideoCodecA10::FreePicture(void *pictpriv, cedarv_picture_t &pict)
  1456. +{
  1457. +  m_hcedarv->display_release(m_hcedarv, pict.id);
  1458. +}
  1459. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h
  1460. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h   1970-01-01 01:00:00.000000000 +0100
  1461. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h 2013-06-12 17:13:43.000000000 +0200
  1462. @@ -0,0 +1,140 @@
  1463. +#pragma once
  1464. +
  1465. +/*
  1466. + *      Copyright (C) 2005-2008 Team XBMC
  1467. + *      http://www.xbmc.org
  1468. + *
  1469. + *  This Program is free software; you can redistribute it and/or modify
  1470. + *  it under the terms of the GNU General Public License as published by
  1471. + *  the Free Software Foundation; either version 2, or (at your option)
  1472. + *  any later version.
  1473. + *
  1474. + *  This Program is distributed in the hope that it will be useful,
  1475. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1476. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1477. + *  GNU General Public License for more details.
  1478. + *
  1479. + *  You should have received a copy of the GNU General Public License
  1480. + *  along with XBMC; see the file COPYING.  If not, write to
  1481. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1482. + *  http://www.gnu.org/copyleft/gpl.html
  1483. + *
  1484. + */
  1485. +
  1486. +#include "guilib/Geometry.h"
  1487. +#include "DVDVideoCodec.h"
  1488. +#include "DVDStreamInfo.h"
  1489. +
  1490. +extern "C" {
  1491. +#include <libcedarv.h>
  1492. +};
  1493. +
  1494. +class CDVDVideoCodecA10 : public CDVDVideoCodec
  1495. +{
  1496. +public:
  1497. +
  1498. +  CDVDVideoCodecA10();
  1499. +  virtual ~CDVDVideoCodecA10();
  1500. +
  1501. +  /*
  1502. +   * Open the decoder, returns true on success
  1503. +   */
  1504. +  bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
  1505. +
  1506. +  /*
  1507. +   * Dispose, Free all resources
  1508. +   */
  1509. +  void Dispose();
  1510. +
  1511. +  /*
  1512. +   * returns one or a combination of VC_ messages
  1513. +   * pData and iSize can be NULL, this means we should flush the rest of the data.
  1514. +   */
  1515. +  int Decode(BYTE* pData, int iSize, double dts, double pts);
  1516. +
  1517. + /*
  1518. +   * Reset the decoder.
  1519. +   * Should be the same as calling Dispose and Open after each other
  1520. +   */
  1521. +  void Reset();
  1522. +
  1523. +  /*
  1524. +   * returns true if successfull
  1525. +   * the data is valid until the next Decode call
  1526. +   */
  1527. +  bool GetPicture(DVDVideoPicture* pDvdVideoPicture);
  1528. +
  1529. +
  1530. +  /*
  1531. +   * returns true if successfull
  1532. +   * the data is cleared to zero
  1533. +   */
  1534. +  bool ClearPicture(DVDVideoPicture* pDvdVideoPicture);
  1535. +
  1536. +  /*
  1537. +   * returns true if successfull
  1538. +   * the data is valid until the next Decode call
  1539. +   * userdata can be anything, for now we use it for closed captioning
  1540. +   */
  1541. +  /*-->super
  1542. +  bool GetUserData(DVDVideoUserData* pDvdVideoUserData);
  1543. +  */
  1544. +
  1545. +  /*
  1546. +   * will be called by video player indicating if a frame will eventually be dropped
  1547. +   * codec can then skip actually decoding the data, just consume the data set picture headers
  1548. +   */
  1549. +  void SetDropState(bool bDrop);
  1550. +
  1551. +  /*
  1552. +   * returns the number of demuxer bytes in any internal buffers
  1553. +   */
  1554. +  /*-->super
  1555. +  int GetDataSize(void);
  1556. +  */
  1557. +
  1558. +  /*
  1559. +   * returns the time in seconds for demuxer bytes in any internal buffers
  1560. +   */
  1561. +  /*-->super
  1562. +  virtual double GetTimeSize(void);
  1563. +  */
  1564. +
  1565. +  /*
  1566. +   * set the type of filters that should be applied at decoding stage if possible
  1567. +   */
  1568. +  /*-->super
  1569. +  unsigned int SetFilters(unsigned int filters);
  1570. +  */
  1571. +
  1572. +  /*
  1573. +   *
  1574. +   * should return codecs name
  1575. +   */
  1576. +  const char* GetName();
  1577. +
  1578. +  /*
  1579. +   *
  1580. +   * How many packets should player remember, so codec
  1581. +   * can recover should something cause it to flush
  1582. +   * outside of players control
  1583. +   */
  1584. +  /*-->super
  1585. +  virtual unsigned GetConvergeCount();
  1586. +  */
  1587. +
  1588. +  void FreePicture(void *pictpriv, cedarv_picture_t &pict);
  1589. +
  1590. +private:
  1591. +
  1592. +  bool DoOpen();
  1593. +
  1594. +  //decoding
  1595. +  cedarv_stream_info_t  m_info;
  1596. +  float                 m_aspect;
  1597. +  CDVDStreamInfo        m_hints;
  1598. +  cedarv_decoder_t     *m_hcedarv;
  1599. +  DVDVideoPicture       m_picture;
  1600. +  bool                  m_prebuffer;
  1601. +  int                   m_nframes;
  1602. +};
  1603. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
  1604. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h  2013-06-12 16:46:43.000000000 +0200
  1605. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h    2013-06-12 17:13:43.000000000 +0200
  1606. @@ -38,6 +38,7 @@
  1607.  class COpenMax;
  1608.  class COpenMaxVideo;
  1609.  struct OpenMaxVideoBuffer;
  1610. +struct A10VLQueueItem;
  1611.  
  1612.  // should be entirely filled by all codecs
  1613.  struct DVDVideoPicture
  1614. @@ -69,6 +70,10 @@
  1615.      struct {
  1616.        struct __CVBuffer *cvBufferRef;
  1617.      };
  1618. +
  1619. +    struct {
  1620. +      A10VLQueueItem *a10buffer;
  1621. +    };
  1622.    };
  1623.  
  1624.    unsigned int iFlags;
  1625. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
  1626. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in  2013-06-12 17:20:26.000000000 +0200
  1627. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in    2013-06-12 17:13:43.000000000 +0200
  1628. @@ -28,6 +28,7 @@
  1629.  SRCS += DVDVideoCodecAmlogic.cpp
  1630.  INCLUDES += -I$(prefix)/include/amlplayer
  1631.  endif
  1632. +SRCS += DVDVideoCodecA10.cpp
  1633.  
  1634.  LIB=Video.a
  1635.  
  1636. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc_rellla/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
  1637. --- xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp   2013-06-12 17:20:26.000000000 +0200
  1638. +++ xbmc_rellla/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2013-06-12 17:13:43.000000000 +0200
  1639. @@ -196,6 +196,11 @@
  1640.  #endif
  1641.  
  1642.  
  1643. +#ifdef ALLWINNERA10
  1644. +  if (m_pVideoCodec && (strcmp(m_pVideoCodec->GetName(), "A10") == 0))
  1645. +    m_pVideoCodec->Dispose();
  1646. +#endif
  1647. +
  1648.    CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec);
  1649.    CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, surfaces, formats);
  1650.    if(!codec)
  1651. @@ -1138,6 +1143,11 @@
  1652.        case RENDER_FMT_CVBREF:
  1653.          formatstr = "BGRA";
  1654.          break;
  1655. +#ifdef ALLWINNERA10
  1656. +      case RENDER_FMT_A10BUF:
  1657. +        formatstr = "A10BUF";
  1658. +        break;
  1659. +#endif
  1660.        case RENDER_FMT_BYPASS:
  1661.          formatstr = "BYPASS";
  1662.          break;
  1663. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/omxplayer/OMXPlayer.cpp xbmc_rellla/xbmc/cores/omxplayer/OMXPlayer.cpp
  1664. --- xbmc_orig/xbmc/cores/omxplayer/OMXPlayer.cpp    2013-06-12 17:20:26.000000000 +0200
  1665. +++ xbmc_rellla/xbmc/cores/omxplayer/OMXPlayer.cpp  2013-06-12 17:13:43.000000000 +0200
  1666. @@ -4288,6 +4288,12 @@
  1667.    m_change_volume = true;
  1668.  }
  1669.  
  1670. +void COMXPlayer::SetMute(bool bOnOff)
  1671. +{
  1672. +  m_current_mute = bOnOff;
  1673. +  m_change_volume = true;
  1674. +}
  1675. +
  1676.  void COMXPlayer::SetVolume(float fVolume)
  1677.  {
  1678.    m_current_volume = fVolume;
  1679. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp xbmc_rellla/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp
  1680. --- xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp    1970-01-01 01:00:00.000000000 +0100
  1681. +++ xbmc_rellla/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp  2013-06-12 17:13:43.000000000 +0200
  1682. @@ -0,0 +1,1998 @@
  1683. +/*
  1684. + *      Copyright (C) 2010-2012 Team XBMC
  1685. + *      http://www.xbmc.org
  1686. + *
  1687. + *  This Program is free software; you can redistribute it and/or modify
  1688. + *  it under the terms of the GNU General Public License as published by
  1689. + *  the Free Software Foundation; either version 2, or (at your option)
  1690. + *  any later version.
  1691. + *
  1692. + *  This Program is distributed in the hope that it will be useful,
  1693. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1694. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1695. + *  GNU General Public License for more details.
  1696. + *
  1697. + *  You should have received a copy of the GNU General Public License
  1698. + *  along with XBMC; see the file COPYING.  If not, see
  1699. + *  <http://www.gnu.org/licenses/>.
  1700. + *
  1701. + */
  1702. +
  1703. +#include "system.h"
  1704. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  1705. +  #include "config.h"
  1706. +#endif
  1707. +
  1708. +#if HAS_GLES == 2
  1709. +#include "system_gl.h"
  1710. +
  1711. +#include <locale.h>
  1712. +#include <sys/ioctl.h>
  1713. +#include "guilib/MatrixGLES.h"
  1714. +#include "LinuxRendererA10.h"
  1715. +#include "utils/log.h"
  1716. +#include "utils/fastmemcpy.h"
  1717. +#include "utils/MathUtils.h"
  1718. +#include "utils/GLUtils.h"
  1719. +#include "settings/Settings.h"
  1720. +#include "settings/AdvancedSettings.h"
  1721. +#include "settings/DisplaySettings.h"
  1722. +#include "settings/MediaSettings.h"
  1723. +#include "guilib/FrameBufferObject.h"
  1724. +#include "VideoShaders/YUV2RGBShader.h"
  1725. +#include "VideoShaders/VideoFilterShader.h"
  1726. +#include "windowing/WindowingFactory.h"
  1727. +#include "dialogs/GUIDialogKaiToast.h"
  1728. +#include "guilib/Texture.h"
  1729. +#include "threads/SingleLock.h"
  1730. +#include "RenderCapture.h"
  1731. +#include "RenderFormats.h"
  1732. +#include "xbmc/Application.h"
  1733. +#include "cores/IPlayer.h"
  1734. +
  1735. +using namespace Shaders;
  1736. +
  1737. +CLinuxRendererA10::CLinuxRendererA10()
  1738. +{
  1739. +  m_textureTarget = GL_TEXTURE_2D;
  1740. +
  1741. +  for (int i = 0; i < NUM_BUFFERS; i++)
  1742. +  {
  1743. +    m_eventTexturesDone[i] = new CEvent(false,true);
  1744. +    memset(&m_buffers, 0, sizeof(m_buffers));
  1745. +  }
  1746. +
  1747. +  m_renderMethod = RENDER_GLSL;
  1748. +  m_oldRenderMethod = m_renderMethod;
  1749. +  m_renderQuality = RQ_SINGLEPASS;
  1750. +  m_iFlags = 0;
  1751. +  m_format = RENDER_FMT_NONE;
  1752. +
  1753. +  m_iYV12RenderBuffer = 0;
  1754. +  m_flipindex = 0;
  1755. +  m_currentField = FIELD_FULL;
  1756. +  m_reloadShaders = 0;
  1757. +  m_pYUVShader = NULL;
  1758. +  m_pVideoFilterShader = NULL;
  1759. +  m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
  1760. +  m_scalingMethodGui = (ESCALINGMETHOD)-1;
  1761. +
  1762. +  // default texture handlers to YUV
  1763. +  m_textureUpload = &CLinuxRendererA10::UploadYV12Texture;
  1764. +  m_textureCreate = &CLinuxRendererA10::CreateYV12Texture;
  1765. +  m_textureDelete = &CLinuxRendererA10::DeleteYV12Texture;
  1766. +
  1767. +/* check if needed (import from LinuxRendererGLES.cpp) - rellla
  1768. +  m_NumYV12Buffers = 0;
  1769. +  m_StrictBinding = false;
  1770. +*/
  1771. +  m_iLastRenderBuffer = 0;
  1772. +  m_bConfigured = false;
  1773. +  m_bValidated = false;
  1774. +  m_bImageReady = false;
  1775. +  m_clearColour = 0.0f;
  1776. +/*
  1777. +  m_fbo.width = 0.0;
  1778. +  m_fbo.height = 0.0;
  1779. +  m_pboSupported = false;
  1780. +  m_pboUsed = false;
  1781. +  m_nonLinStretch = false;
  1782. +  m_nonLinStretchGui = false;
  1783. +  m_pixelRatio = 0.0f;
  1784. +*/
  1785. +
  1786. +
  1787. +}
  1788. +
  1789. +CLinuxRendererA10::~CLinuxRendererA10()
  1790. +{
  1791. +  UnInit();
  1792. +  for (int i = 0; i < NUM_BUFFERS; i++)
  1793. +    delete m_eventTexturesDone[i];
  1794. +
  1795. +  if (m_pYUVShader)
  1796. +  {
  1797. +    m_pYUVShader->Free();
  1798. +    delete m_pYUVShader;
  1799. +    m_pYUVShader = NULL;
  1800. +  }
  1801. +}
  1802. +
  1803. +void CLinuxRendererA10::ManageTextures()
  1804. +{
  1805. +  //m_iYV12RenderBuffer = 0;
  1806. +  return;
  1807. +}
  1808. +
  1809. +bool CLinuxRendererA10::ValidateRenderTarget()
  1810. +{
  1811. +  if (!m_bValidated)
  1812. +  {
  1813. +    CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
  1814. +
  1815. +     // create the yuv textures
  1816. +    LoadShaders();
  1817. +
  1818. +    for (int i = 0 ; i < NUM_BUFFERS ; i++)
  1819. +      (this->*m_textureCreate)(i);
  1820. +
  1821. +    m_bValidated = true;
  1822. +    return true;
  1823. +  }
  1824. +  return false;
  1825. +}
  1826. +
  1827. +bool CLinuxRendererA10::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)
  1828. +{
  1829. +  m_sourceWidth = width;
  1830. +  m_sourceHeight = height;
  1831. +  m_renderOrientation = orientation;
  1832. +
  1833. +  // Save the flags.
  1834. +  m_iFlags = flags;
  1835. +  m_format = format;
  1836. +
  1837. +  // Calculate the input frame aspect ratio.
  1838. +  CalculateFrameAspectRatio(d_width, d_height);
  1839. +  ChooseBestResolution(fps);
  1840. +  SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode);
  1841. +  ManageDisplay();
  1842. +
  1843. +  m_bConfigured = true;
  1844. +  m_bImageReady = false;
  1845. +  m_scalingMethodGui = (ESCALINGMETHOD)-1;
  1846. +
  1847. +  // Ensure that textures are recreated and rendering starts only after the 1st
  1848. +  // frame is loaded after every call to Configure().
  1849. +  m_bValidated = false;
  1850. +
  1851. +  for (int i = 0 ; i< NUM_BUFFERS; i++)
  1852. +    m_buffers[i].image.flags = 0;
  1853. +
  1854. +  m_iLastRenderBuffer = -1;
  1855. +
  1856. +  m_RenderUpdateCallBackFn = NULL;
  1857. +  m_RenderUpdateCallBackCtx = NULL;
  1858. +  if ((m_format == RENDER_FMT_BYPASS) && g_application.GetCurrentPlayer())
  1859. +  {
  1860. +    m_renderFeatures.clear();
  1861. +    m_scalingMethods.clear();
  1862. +    m_deinterlaceModes.clear();
  1863. +    m_deinterlaceMethods.clear();
  1864. +
  1865. +    if (m_RenderFeaturesCallBackFn)
  1866. +    {
  1867. +      (*m_RenderFeaturesCallBackFn)(m_RenderFeaturesCallBackCtx, m_renderFeatures);
  1868. +      // after setting up m_RenderFeatures, we are done with the callback
  1869. +      m_RenderFeaturesCallBackFn = NULL;
  1870. +      m_RenderFeaturesCallBackCtx = NULL;
  1871. +    }
  1872. +    g_application.m_pPlayer->GetRenderFeatures(m_renderFeatures);
  1873. +    g_application.m_pPlayer->GetDeinterlaceMethods(m_deinterlaceMethods);
  1874. +    g_application.m_pPlayer->GetDeinterlaceModes(m_deinterlaceModes);
  1875. +    g_application.m_pPlayer->GetScalingMethods(m_scalingMethods);
  1876. +  }
  1877. +
  1878. +  return true;
  1879. +}
  1880. +
  1881. +int CLinuxRendererA10::NextYV12Texture()
  1882. +{
  1883. +  return (m_iYV12RenderBuffer + 1) % NUM_BUFFERS;
  1884. +}
  1885. +
  1886. +int CLinuxRendererA10::GetImage(YV12Image *image, int source, bool readonly)
  1887. +{
  1888. +  if (!image) return -1;
  1889. +  if (!m_bValidated) return -1;
  1890. +
  1891. +  /* take next available buffer */
  1892. +  if( source == AUTOSOURCE )
  1893. +   source = NextYV12Texture();
  1894. +
  1895. +  if (m_renderMethod & RENDER_A10BUF )
  1896. +  {
  1897. +    return source;
  1898. +  }
  1899. +
  1900. +  YV12Image &im = m_buffers[source].image;
  1901. +
  1902. +  if ((im.flags&(~IMAGE_FLAG_READY)) != 0)
  1903. +  {
  1904. +     CLog::Log(LOGDEBUG, "CLinuxRenderer::GetImage - request image but none to give");
  1905. +     return -1;
  1906. +  }
  1907. +
  1908. +  if( readonly )
  1909. +    im.flags |= IMAGE_FLAG_READING;
  1910. +  else
  1911. +  {
  1912. +    if( !m_eventTexturesDone[source]->WaitMSec(500) )
  1913. +      CLog::Log(LOGWARNING, "%s - Timeout waiting for texture %d", __FUNCTION__, source);
  1914. +
  1915. +    im.flags |= IMAGE_FLAG_WRITING;
  1916. +  }
  1917. +
  1918. +  // copy the image - should be operator of YV12Image
  1919. +  for (int p=0;p<MAX_PLANES;p++)
  1920. +  {
  1921. +    image->plane[p]  = im.plane[p];
  1922. +    image->stride[p] = im.stride[p];
  1923. +  }
  1924. +  image->width    = im.width;
  1925. +  image->height   = im.height;
  1926. +  image->flags    = im.flags;
  1927. +  image->cshift_x = im.cshift_x;
  1928. +  image->cshift_y = im.cshift_y;
  1929. +  image->bpp      = 1;
  1930. +
  1931. +  return source;
  1932. +
  1933. +  return -1;
  1934. +}
  1935. +
  1936. +void CLinuxRendererA10::ReleaseImage(int source, bool preserve)
  1937. +{
  1938. +  YV12Image &im = m_buffers[source].image;
  1939. +
  1940. +  if( im.flags & IMAGE_FLAG_WRITING )
  1941. +    m_eventTexturesDone[source]->Set();
  1942. +
  1943. +  im.flags &= ~IMAGE_FLAG_INUSE;
  1944. +  im.flags |= IMAGE_FLAG_READY;
  1945. +  /* if image should be preserved reserve it so it's not auto seleceted */
  1946. +
  1947. +  if( preserve )
  1948. +    im.flags |= IMAGE_FLAG_RESERVED;
  1949. +
  1950. +  m_bImageReady = true;
  1951. +}
  1952. +
  1953. +void CLinuxRendererA10::CalculateTextureSourceRects(int source, int num_planes)
  1954. +{
  1955. +  YUVBUFFER& buf    =  m_buffers[source];
  1956. +  YV12Image* im     = &buf.image;
  1957. +  YUVFIELDS& fields =  buf.fields;
  1958. +
  1959. +  // calculate the source rectangle
  1960. +  for(int field = 0; field < 3; field++)
  1961. +  {
  1962. +    for(int plane = 0; plane < num_planes; plane++)
  1963. +    {
  1964. +      YUVPLANE& p = fields[field][plane];
  1965. +
  1966. +      p.rect = m_sourceRect;
  1967. +      p.width  = im->width;
  1968. +      p.height = im->height;
  1969. +
  1970. +      if(field != FIELD_FULL)
  1971. +      {
  1972. +        /* correct for field offsets and chroma offsets */
  1973. +        float offset_y = 0.5;
  1974. +        if(plane != 0)
  1975. +          offset_y += 0.5;
  1976. +        if(field == FIELD_BOT)
  1977. +          offset_y *= -1;
  1978. +
  1979. +        p.rect.y1 += offset_y;
  1980. +        p.rect.y2 += offset_y;
  1981. +
  1982. +        /* half the height if this is a field */
  1983. +        p.height  *= 0.5f;
  1984. +        p.rect.y1 *= 0.5f;
  1985. +        p.rect.y2 *= 0.5f;
  1986. +      }
  1987. +
  1988. +      if(plane != 0)
  1989. +      {
  1990. +        p.width   /= 1 << im->cshift_x;
  1991. +        p.height  /= 1 << im->cshift_y;
  1992. +
  1993. +        p.rect.x1 /= 1 << im->cshift_x;
  1994. +        p.rect.x2 /= 1 << im->cshift_x;
  1995. +        p.rect.y1 /= 1 << im->cshift_y;
  1996. +        p.rect.y2 /= 1 << im->cshift_y;
  1997. +      }
  1998. +
  1999. +      if (m_textureTarget == GL_TEXTURE_2D)
  2000. +      {
  2001. +        p.height  /= p.texheight;
  2002. +        p.rect.y1 /= p.texheight;
  2003. +        p.rect.y2 /= p.texheight;
  2004. +        p.width   /= p.texwidth;
  2005. +        p.rect.x1 /= p.texwidth;
  2006. +        p.rect.x2 /= p.texwidth;
  2007. +      }
  2008. +    }
  2009. +  }
  2010. +}
  2011. +
  2012. +void CLinuxRendererA10::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
  2013. +                                , unsigned width, unsigned height
  2014. +                                , int stride, void* data )
  2015. +{
  2016. +  if(plane.flipindex == flipindex)
  2017. +    return;
  2018. +
  2019. +  const GLvoid *pixelData = data;
  2020. +
  2021. +  int bps = glFormatElementByteCount(type);
  2022. +
  2023. +  glBindTexture(m_textureTarget, plane.id);
  2024. +
  2025. +  // OpenGL ES does not support strided texture input.
  2026. +  if(stride != width * bps)
  2027. +  {
  2028. +    unsigned char* src = (unsigned char*)data;
  2029. +    for (int y = 0; y < height;++y, src += stride)
  2030. +      glTexSubImage2D(m_textureTarget, 0, 0, y, width, 1, type, GL_UNSIGNED_BYTE, src);
  2031. +  } else {
  2032. +    glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, pixelData);
  2033. +  }
  2034. +
  2035. +  /* check if we need to load any border pixels */
  2036. +  if(height < plane.texheight)
  2037. +    glTexSubImage2D( m_textureTarget, 0
  2038. +                   , 0, height, width, 1
  2039. +                   , type, GL_UNSIGNED_BYTE
  2040. +                   , (unsigned char*)pixelData + stride * (height-1));
  2041. +
  2042. +  if(width  < plane.texwidth)
  2043. +    glTexSubImage2D( m_textureTarget, 0
  2044. +                   , width, 0, 1, height
  2045. +                   , type, GL_UNSIGNED_BYTE
  2046. +                   , (unsigned char*)pixelData + bps * (width-1));
  2047. +
  2048. +  glBindTexture(m_textureTarget, 0);
  2049. +
  2050. +  plane.flipindex = flipindex;
  2051. +}
  2052. +
  2053. +void CLinuxRendererA10::Reset()
  2054. +{
  2055. +  for(int i=0; i<NUM_BUFFERS; i++)
  2056. +  {
  2057. +    /* reset all image flags, this will cleanup textures later */
  2058. +    m_buffers[i].image.flags = 0;
  2059. +    /* reset texture locks, a bit ugly, could result in tearing */
  2060. +    m_eventTexturesDone[i]->Set();
  2061. +  }
  2062. +}
  2063. +
  2064. +void CLinuxRendererA10::Update(bool bPauseDrawing)
  2065. +{
  2066. +  if (!m_bConfigured) return;
  2067. +  ManageDisplay();
  2068. +  ManageTextures();
  2069. +  m_scalingMethodGui = (ESCALINGMETHOD)-1;
  2070. +}
  2071. +
  2072. +void CLinuxRendererA10::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
  2073. +{
  2074. +  if (!m_bConfigured) return;
  2075. +
  2076. +  // if its first pass, just init textures and return
  2077. +  if (ValidateRenderTarget())
  2078. +    return;
  2079. +
  2080. +  if (m_renderMethod & RENDER_BYPASS)
  2081. +  {
  2082. +    ManageDisplay();
  2083. +    ManageTextures();
  2084. +    // if running bypass, then the player might need the src/dst rects
  2085. +    // for sizing video playback on a layer other than the gles layer.
  2086. +    if (m_RenderUpdateCallBackFn)
  2087. +      (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect);
  2088. +
  2089. +    RESOLUTION res = GetResolution();
  2090. +    int iWidth = CDisplaySettings::Get().GetResolutionInfo(res).iWidth;
  2091. +    int iHeight = CDisplaySettings::Get().GetResolutionInfo(res).iHeight;
  2092. +
  2093. +    g_graphicsContext.BeginPaint();
  2094. +
  2095. +    glScissor(m_destRect.x1,
  2096. +              iHeight - m_destRect.y2,
  2097. +              m_destRect.x2 - m_destRect.x1,
  2098. +              m_destRect.y2 - m_destRect.y1);
  2099. +    glEnable(GL_BLEND);
  2100. +    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  2101. +    glClearColor(0, 0, 0, 0);
  2102. +    glClear(GL_COLOR_BUFFER_BIT);
  2103. +    glScissor(0, 0, iWidth, iHeight);
  2104. +
  2105. +    g_graphicsContext.EndPaint();
  2106. +    return;
  2107. +  }
  2108. +  else if (m_renderMethod & RENDER_A10BUF)
  2109. +  {
  2110. +    ManageDisplay();
  2111. +    ManageTextures();
  2112. +
  2113. +    if (m_RenderUpdateCallBackFn)
  2114. +      (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect);
  2115. +
  2116. +    A10VLWaitVSYNC();
  2117. +
  2118. +    g_graphicsContext.BeginPaint();
  2119. +
  2120. +    glEnable(GL_BLEND);
  2121. +    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  2122. +    glClearColor(1.0/255, 2.0/255, 3.0/255, 0);
  2123. +    glClear(GL_COLOR_BUFFER_BIT);
  2124. +    glClearColor(0, 0, 0, 0);
  2125. +
  2126. +    g_graphicsContext.EndPaint();
  2127. +  }
  2128. +
  2129. +  // this needs to be checked after texture validation
  2130. +  if (!m_bImageReady) return;
  2131. +
  2132. +  int index = m_iYV12RenderBuffer;
  2133. +  YUVBUFFER& buf =  m_buffers[index];
  2134. +
  2135. +  if (m_renderMethod & RENDER_A10BUF)
  2136. +  {
  2137. +    A10VLDisplayQueueItem(buf.a10buffer, m_sourceRect, m_destRect);
  2138. +    m_iLastRenderBuffer = index;
  2139. +    VerifyGLState();
  2140. +    return;
  2141. +  }
  2142. +
  2143. +  if (!buf.fields[FIELD_FULL][0].id || !buf.image.flags) return;
  2144. +
  2145. +  ManageDisplay();
  2146. +  ManageTextures();
  2147. +
  2148. +  g_graphicsContext.BeginPaint();
  2149. +
  2150. +  if( !m_eventTexturesDone[index]->WaitMSec(500))
  2151. +  {
  2152. +    CLog::Log(LOGWARNING, "%s - Timeout waiting for texture %d", __FUNCTION__, index);
  2153. +
  2154. +    // render the previous frame if this one isn't ready yet
  2155. +    if (m_iLastRenderBuffer > -1)
  2156. +    {
  2157. +      m_iYV12RenderBuffer = m_iLastRenderBuffer;
  2158. +      index = m_iYV12RenderBuffer;
  2159. +    }
  2160. +  }
  2161. +  else
  2162. +    m_iLastRenderBuffer = index;
  2163. +
  2164. +  if (clear)
  2165. +  {
  2166. +    glClearColor(m_clearColour, m_clearColour, m_clearColour, 0);
  2167. +    glClear(GL_COLOR_BUFFER_BIT);
  2168. +    glClearColor(0,0,0,0);
  2169. +  }
  2170. +
  2171. +  if (alpha<255)
  2172. +  {
  2173. +    glEnable(GL_BLEND);
  2174. +    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  2175. +    if (m_pYUVShader)
  2176. +      m_pYUVShader->SetAlpha(alpha / 255.0f);
  2177. +  }
  2178. +  else
  2179. +  {
  2180. +    glDisable(GL_BLEND);
  2181. +    if (m_pYUVShader)
  2182. +      m_pYUVShader->SetAlpha(1.0f);
  2183. +  }
  2184. +
  2185. +  if ((flags & RENDER_FLAG_TOP) && (flags & RENDER_FLAG_BOT))
  2186. +    CLog::Log(LOGERROR, "GLES: Cannot render stipple!");
  2187. +  else
  2188. +    Render(flags, index);
  2189. +
  2190. +  VerifyGLState();
  2191. +  glEnable(GL_BLEND);
  2192. +
  2193. +  g_graphicsContext.EndPaint();
  2194. +}
  2195. +
  2196. +void CLinuxRendererA10::FlipPage(int source)
  2197. +{
  2198. +  if( source >= 0 && source < NUM_BUFFERS )
  2199. +    m_iYV12RenderBuffer = source;
  2200. +  else
  2201. +    m_iYV12RenderBuffer = NextYV12Texture();
  2202. +
  2203. +  m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
  2204. +
  2205. +  return;
  2206. +}
  2207. +
  2208. +unsigned int CLinuxRendererA10::PreInit()
  2209. +{
  2210. +  CSingleLock lock(g_graphicsContext);
  2211. +  m_bConfigured = false;
  2212. +  m_bValidated = false;
  2213. +  UnInit();
  2214. +  m_resolution = CDisplaySettings::Get().GetCurrentResolution();
  2215. +  if ( m_resolution == RES_WINDOW )
  2216. +    m_resolution = RES_DESKTOP;
  2217. +
  2218. +  m_iYV12RenderBuffer = 0;
  2219. +
  2220. +  m_formats.push_back(RENDER_FMT_YUV420P);
  2221. +  m_formats.push_back(RENDER_FMT_BYPASS);
  2222. +  m_formats.push_back(RENDER_FMT_A10BUF);
  2223. +
  2224. +  // setup the background colour
  2225. +  m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
  2226. +
  2227. +  return true;
  2228. +}
  2229. +
  2230. +void CLinuxRendererA10::UpdateVideoFilter()
  2231. +{
  2232. +  if (m_scalingMethodGui == CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod)
  2233. +    return;
  2234. +  m_scalingMethodGui = CMediaSettings::Get().GetCurrentVideoSettings().m_ScalingMethod;
  2235. +  m_scalingMethod    = m_scalingMethodGui;
  2236. +
  2237. +  if(!Supports(m_scalingMethod))
  2238. +  {
  2239. +    CLog::Log(LOGWARNING, "CLinuxRendererA10::UpdateVideoFilter - choosen scaling method %d, is not supported by renderer", (int)m_scalingMethod);
  2240. +    m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
  2241. +  }
  2242. +
  2243. +  if (m_pVideoFilterShader)
  2244. +  {
  2245. +    m_pVideoFilterShader->Free();
  2246. +    delete m_pVideoFilterShader;
  2247. +    m_pVideoFilterShader = NULL;
  2248. +  }
  2249. +  m_fbo.Cleanup();
  2250. +
  2251. +  VerifyGLState();
  2252. +
  2253. +  switch (m_scalingMethod)
  2254. +  {
  2255. +  case VS_SCALINGMETHOD_NEAREST:
  2256. +    SetTextureFilter(GL_NEAREST);
  2257. +    m_renderQuality = RQ_SINGLEPASS;
  2258. +    return;
  2259. +
  2260. +  case VS_SCALINGMETHOD_LINEAR:
  2261. +    SetTextureFilter(GL_LINEAR);
  2262. +    m_renderQuality = RQ_SINGLEPASS;
  2263. +    return;
  2264. +
  2265. +  case VS_SCALINGMETHOD_CUBIC:
  2266. +    CLog::Log(LOGERROR, "GLES: CUBIC not supported!");
  2267. +    break;
  2268. +
  2269. +  case VS_SCALINGMETHOD_LANCZOS2:
  2270. +  case VS_SCALINGMETHOD_LANCZOS3:
  2271. +  case VS_SCALINGMETHOD_SINC8:
  2272. +  case VS_SCALINGMETHOD_NEDI:
  2273. +    CLog::Log(LOGERROR, "GL: TODO: This scaler has not yet been implemented");
  2274. +    break;
  2275. +
  2276. +  default:
  2277. +    break;
  2278. +  }
  2279. +
  2280. +  CGUIDialogKaiToast::QueueNotification("Video Renderering", "Failed to init video filters/scalers, falling back to bilinear scaling");
  2281. +  CLog::Log(LOGERROR, "GL: Falling back to bilinear due to failure to init scaler");
  2282. +  if (m_pVideoFilterShader)
  2283. +  {
  2284. +    m_pVideoFilterShader->Free();
  2285. +    delete m_pVideoFilterShader;
  2286. +    m_pVideoFilterShader = NULL;
  2287. +  }
  2288. +  m_fbo.Cleanup();
  2289. +
  2290. +  SetTextureFilter(GL_LINEAR);
  2291. +  m_renderQuality = RQ_SINGLEPASS;
  2292. +}
  2293. +
  2294. +void CLinuxRendererA10::LoadShaders(int field)
  2295. +{
  2296. +  int requestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod");
  2297. +  CLog::Log(LOGDEBUG, "GL: Requested render method: %d", requestedMethod);
  2298. +
  2299. +  if (m_pYUVShader)
  2300. +  {
  2301. +    m_pYUVShader->Free();
  2302. +    delete m_pYUVShader;
  2303. +    m_pYUVShader = NULL;
  2304. +  }
  2305. +
  2306. +  switch(requestedMethod)
  2307. +  {
  2308. +    case RENDER_METHOD_AUTO:
  2309. +    case RENDER_METHOD_GLSL:
  2310. +      if (m_format == RENDER_FMT_A10BUF)
  2311. +      {
  2312. +        CLog::Log(LOGNOTICE, "using A10 render method");
  2313. +        m_renderMethod = RENDER_A10BUF;
  2314. +        break;
  2315. +      }
  2316. +      // Try GLSL shaders if supported and user requested auto or GLSL.
  2317. +      // create regular progressive scan shader
  2318. +      m_pYUVShader = new YUV2RGBProgressiveShader(false, m_iFlags, m_format);
  2319. +      CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader");
  2320. +
  2321. +      if (m_pYUVShader && m_pYUVShader->CompileAndLink())
  2322. +      {
  2323. +        m_renderMethod = RENDER_GLSL;
  2324. +        UpdateVideoFilter();
  2325. +        break;
  2326. +      }
  2327. +      else if (m_pYUVShader)
  2328. +      {
  2329. +        m_pYUVShader->Free();
  2330. +        delete m_pYUVShader;
  2331. +        m_pYUVShader = NULL;
  2332. +        CLog::Log(LOGERROR, "GL: Error enabling YUV2RGB GLSL shader");
  2333. +      }
  2334. +      break;
  2335. +    default:
  2336. +      // Use software YUV 2 RGB conversion if user requested it or GLSL failed
  2337. +      CLog::Log(LOGERROR, "no software rendering.");
  2338. +      break;
  2339. +  }
  2340. +
  2341. +  // Now that we now the render method, setup texture function handlers
  2342. +  if (m_format == RENDER_FMT_BYPASS || m_format == RENDER_FMT_A10BUF)
  2343. +  {
  2344. +    m_textureUpload = &CLinuxRendererA10::UploadBYPASSTexture;
  2345. +    m_textureCreate = &CLinuxRendererA10::CreateBYPASSTexture;
  2346. +    m_textureDelete = &CLinuxRendererA10::DeleteBYPASSTexture;
  2347. +  }
  2348. +  else
  2349. +  {
  2350. +    // default to YV12 texture handlers
  2351. +    m_textureUpload = &CLinuxRendererA10::UploadYV12Texture;
  2352. +    m_textureCreate = &CLinuxRendererA10::CreateYV12Texture;
  2353. +    m_textureDelete = &CLinuxRendererA10::DeleteYV12Texture;
  2354. +  }
  2355. +
  2356. +  if (m_oldRenderMethod != m_renderMethod)
  2357. +  {
  2358. +    CLog::Log(LOGDEBUG, "CLinuxRendererA10: Reorder drawpoints due to method change from %i to %i", m_oldRenderMethod, m_renderMethod);
  2359. +    ReorderDrawPoints();
  2360. +    m_oldRenderMethod = m_renderMethod;
  2361. +  }
  2362. +}
  2363. +
  2364. +void CLinuxRendererA10::UnInit()
  2365. +{
  2366. +  CLog::Log(LOGDEBUG, "LinuxRendererGL: Cleaning up GL resources");
  2367. +  CSingleLock lock(g_graphicsContext);
  2368. +
  2369. +  A10VLHide();
  2370. +
  2371. +  // YV12 textures
  2372. +  for (int i = 0; i < NUM_BUFFERS; ++i)
  2373. +    (this->*m_textureDelete)(i);
  2374. +
  2375. +  // cleanup framebuffer object if it was in use
  2376. +  m_fbo.Cleanup();
  2377. +  m_bValidated = false;
  2378. +  m_bImageReady = false;
  2379. +  m_bConfigured = false;
  2380. +  m_RenderUpdateCallBackFn = NULL;
  2381. +  m_RenderUpdateCallBackCtx = NULL;
  2382. +  m_RenderFeaturesCallBackFn = NULL;
  2383. +  m_RenderFeaturesCallBackCtx = NULL;
  2384. +}
  2385. +
  2386. +inline void CLinuxRendererA10::ReorderDrawPoints()
  2387. +{
  2388. +
  2389. +  CBaseRenderer::ReorderDrawPoints();//call base impl. for rotating the points
  2390. +}
  2391. +
  2392. +void CLinuxRendererA10::Render(DWORD flags, int index)
  2393. +{
  2394. +  // If rendered directly by the hardware
  2395. +  if (m_renderMethod & RENDER_BYPASS)
  2396. +    return;
  2397. +
  2398. +  // obtain current field, if interlaced
  2399. +  if( flags & RENDER_FLAG_TOP)
  2400. +    m_currentField = FIELD_TOP;
  2401. +
  2402. +  else if (flags & RENDER_FLAG_BOT)
  2403. +    m_currentField = FIELD_BOT;
  2404. +
  2405. +  else
  2406. +    m_currentField = FIELD_FULL;
  2407. +
  2408. +  (this->*m_textureUpload)(index);
  2409. +
  2410. +  if (m_renderMethod & RENDER_GLSL)
  2411. +  {
  2412. +    UpdateVideoFilter();
  2413. +    switch(m_renderQuality)
  2414. +    {
  2415. +    case RQ_LOW:
  2416. +    case RQ_SINGLEPASS:
  2417. +      RenderSinglePass(index, m_currentField);
  2418. +      VerifyGLState();
  2419. +      break;
  2420. +
  2421. +    case RQ_MULTIPASS:
  2422. +      RenderMultiPass(index, m_currentField);
  2423. +      VerifyGLState();
  2424. +      break;
  2425. +    }
  2426. +  }
  2427. +}
  2428. +
  2429. +void CLinuxRendererA10::RenderSinglePass(int index, int field)
  2430. +{
  2431. +  YV12Image &im     = m_buffers[index].image;
  2432. +  YUVFIELDS &fields = m_buffers[index].fields;
  2433. +  YUVPLANES &planes = fields[field];
  2434. +
  2435. +  if (m_reloadShaders)
  2436. +  {
  2437. +    m_reloadShaders = 0;
  2438. +    LoadShaders(field);
  2439. +  }
  2440. +
  2441. +  glDisable(GL_DEPTH_TEST);
  2442. +
  2443. +  // Y
  2444. +  glActiveTexture(GL_TEXTURE0);
  2445. +  glEnable(m_textureTarget);
  2446. +  glBindTexture(m_textureTarget, planes[0].id);
  2447. +
  2448. +  // U
  2449. +  glActiveTexture(GL_TEXTURE1);
  2450. +  glEnable(m_textureTarget);
  2451. +  glBindTexture(m_textureTarget, planes[1].id);
  2452. +
  2453. +  // V
  2454. +  glActiveTexture(GL_TEXTURE2);
  2455. +  glEnable(m_textureTarget);
  2456. +  glBindTexture(m_textureTarget, planes[2].id);
  2457. +
  2458. +  glActiveTexture(GL_TEXTURE0);
  2459. +  VerifyGLState();
  2460. +
  2461. +  m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f);
  2462. +  m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f);
  2463. +  m_pYUVShader->SetWidth(im.width);
  2464. +  m_pYUVShader->SetHeight(im.height);
  2465. +  if     (field == FIELD_TOP)
  2466. +    m_pYUVShader->SetField(1);
  2467. +  else if(field == FIELD_BOT)
  2468. +    m_pYUVShader->SetField(0);
  2469. +
  2470. +  m_pYUVShader->SetMatrices(g_matrices.GetMatrix(MM_PROJECTION), g_matrices.GetMatrix(MM_MODELVIEW));
  2471. +  m_pYUVShader->Enable();
  2472. +
  2473. +  GLubyte idx[4] = {0, 1, 3, 2};        //determines order of triangle strip
  2474. +  GLfloat m_vert[4][3];
  2475. +  GLfloat m_tex[3][4][2];
  2476. +
  2477. +  GLint vertLoc = m_pYUVShader->GetVertexLoc();
  2478. +  GLint Yloc    = m_pYUVShader->GetYcoordLoc();
  2479. +  GLint Uloc    = m_pYUVShader->GetUcoordLoc();
  2480. +  GLint Vloc    = m_pYUVShader->GetVcoordLoc();
  2481. +
  2482. +  glVertexAttribPointer(vertLoc, 3, GL_FLOAT, 0, 0, m_vert);
  2483. +  glVertexAttribPointer(Yloc, 2, GL_FLOAT, 0, 0, m_tex[0]);
  2484. +  glVertexAttribPointer(Uloc, 2, GL_FLOAT, 0, 0, m_tex[1]);
  2485. +  glVertexAttribPointer(Vloc, 2, GL_FLOAT, 0, 0, m_tex[2]);
  2486. +
  2487. +  glEnableVertexAttribArray(vertLoc);
  2488. +  glEnableVertexAttribArray(Yloc);
  2489. +  glEnableVertexAttribArray(Uloc);
  2490. +  glEnableVertexAttribArray(Vloc);
  2491. +
  2492. +  // Setup vertex position values
  2493. +  for(int i = 0; i < 4; i++)
  2494. +  {
  2495. +    m_vert[i][0] = m_rotatedDestCoords[i].x;
  2496. +    m_vert[i][1] = m_rotatedDestCoords[i].y;
  2497. +    m_vert[i][2] = 0.0f;// set z to 0
  2498. +  }
  2499. +
  2500. +  // Setup texture coordinates
  2501. +  for (int i=0; i<3; i++)
  2502. +  {
  2503. +    m_tex[i][0][0] = m_tex[i][3][0] = planes[i].rect.x1;
  2504. +    m_tex[i][0][1] = m_tex[i][1][1] = planes[i].rect.y1;
  2505. +    m_tex[i][1][0] = m_tex[i][2][0] = planes[i].rect.x2;
  2506. +    m_tex[i][2][1] = m_tex[i][3][1] = planes[i].rect.y2;
  2507. +  }
  2508. +
  2509. +  glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
  2510. +
  2511. +  VerifyGLState();
  2512. +
  2513. +  m_pYUVShader->Disable();
  2514. +  VerifyGLState();
  2515. +
  2516. +  glDisableVertexAttribArray(vertLoc);
  2517. +  glDisableVertexAttribArray(Yloc);
  2518. +  glDisableVertexAttribArray(Uloc);
  2519. +  glDisableVertexAttribArray(Vloc);
  2520. +
  2521. +  glActiveTexture(GL_TEXTURE1);
  2522. +  glDisable(m_textureTarget);
  2523. +
  2524. +  glActiveTexture(GL_TEXTURE2);
  2525. +  glDisable(m_textureTarget);
  2526. +
  2527. +  glActiveTexture(GL_TEXTURE0);
  2528. +  glDisable(m_textureTarget);
  2529. +
  2530. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2531. +
  2532. +  VerifyGLState();
  2533. +}
  2534. +
  2535. +void CLinuxRendererA10::RenderMultiPass(int index, int field)
  2536. +{
  2537. +  // TODO: Multipass rendering does not currently work! FIX!
  2538. +  CLog::Log(LOGERROR, "GLES: MULTIPASS rendering was called! But it doesnt work!!!");
  2539. +  return;
  2540. +
  2541. +  YV12Image &im     = m_buffers[index].image;
  2542. +  YUVPLANES &planes = m_buffers[index].fields[field];
  2543. +
  2544. +  if (m_reloadShaders)
  2545. +  {
  2546. +    m_reloadShaders = 0;
  2547. +    LoadShaders(m_currentField);
  2548. +  }
  2549. +
  2550. +  glDisable(GL_DEPTH_TEST);
  2551. +
  2552. +  // Y
  2553. +  glEnable(m_textureTarget);
  2554. +  glActiveTexture(GL_TEXTURE0);
  2555. +  glBindTexture(m_textureTarget, planes[0].id);
  2556. +  VerifyGLState();
  2557. +
  2558. +  // U
  2559. +  glActiveTexture(GL_TEXTURE1);
  2560. +  glEnable(m_textureTarget);
  2561. +  glBindTexture(m_textureTarget, planes[1].id);
  2562. +  VerifyGLState();
  2563. +
  2564. +  // V
  2565. +  glActiveTexture(GL_TEXTURE2);
  2566. +  glEnable(m_textureTarget);
  2567. +  glBindTexture(m_textureTarget, planes[2].id);
  2568. +  VerifyGLState();
  2569. +
  2570. +  glActiveTexture(GL_TEXTURE0);
  2571. +  VerifyGLState();
  2572. +
  2573. +  // make sure the yuv shader is loaded and ready to go
  2574. +  if (!m_pYUVShader || (!m_pYUVShader->OK()))
  2575. +  {
  2576. +    CLog::Log(LOGERROR, "GL: YUV shader not active, cannot do multipass render");
  2577. +    return;
  2578. +  }
  2579. +
  2580. +  m_fbo.BeginRender();
  2581. +  VerifyGLState();
  2582. +
  2583. +  m_pYUVShader->SetBlack(CMediaSettings::Get().GetCurrentVideoSettings().m_Brightness * 0.01f - 0.5f);
  2584. +  m_pYUVShader->SetContrast(CMediaSettings::Get().GetCurrentVideoSettings().m_Contrast * 0.02f);
  2585. +  m_pYUVShader->SetWidth(im.width);
  2586. +  m_pYUVShader->SetHeight(im.height);
  2587. +  if     (field == FIELD_TOP)
  2588. +    m_pYUVShader->SetField(1);
  2589. +  else if(field == FIELD_BOT)
  2590. +    m_pYUVShader->SetField(0);
  2591. +
  2592. +  VerifyGLState();
  2593. +//TODO
  2594. +//  glPushAttrib(GL_VIEWPORT_BIT);
  2595. +//  glPushAttrib(GL_SCISSOR_BIT);
  2596. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2597. +  g_matrices.PushMatrix();
  2598. +  g_matrices.LoadIdentity();
  2599. +  VerifyGLState();
  2600. +
  2601. +  g_matrices.MatrixMode(MM_PROJECTION);
  2602. +  g_matrices.PushMatrix();
  2603. +  g_matrices.LoadIdentity();
  2604. +  VerifyGLState();
  2605. +  g_matrices.Ortho2D(0, m_sourceWidth, 0, m_sourceHeight);
  2606. +  glViewport(0, 0, m_sourceWidth, m_sourceHeight);
  2607. +  glScissor(0, 0, m_sourceWidth, m_sourceHeight);
  2608. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2609. +  VerifyGLState();
  2610. +
  2611. +
  2612. +  if (!m_pYUVShader->Enable())
  2613. +  {
  2614. +    CLog::Log(LOGERROR, "GL: Error enabling YUV shader");
  2615. +  }
  2616. +
  2617. +// 1st Pass to video frame size
  2618. +//TODO
  2619. +//  float imgwidth  = planes[0].rect.x2 - planes[0].rect.x1;
  2620. +//  float imgheight = planes[0].rect.y2 - planes[0].rect.y1;
  2621. +//  if (m_textureTarget == GL_TEXTURE_2D)
  2622. +//  {
  2623. +//    imgwidth  *= planes[0].texwidth;
  2624. +//    imgheight *= planes[0].texheight;
  2625. +//  }
  2626. +
  2627. +
  2628. +//  glBegin(GL_QUADS);
  2629. +//
  2630. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y1);
  2631. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y1);
  2632. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y1);
  2633. +//  glVertex2f(0.0f    , 0.0f);
  2634. +//
  2635. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y1);
  2636. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y1);
  2637. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y1);
  2638. +//  glVertex2f(imgwidth, 0.0f);
  2639. +//
  2640. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y2);
  2641. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y2);
  2642. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y2);
  2643. +//  glVertex2f(imgwidth, imgheight);
  2644. +//
  2645. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y2);
  2646. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y2);
  2647. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y2);
  2648. +//  glVertex2f(0.0f    , imgheight);
  2649. +//
  2650. +//  glEnd();
  2651. +//  VerifyGLState();
  2652. +
  2653. +  m_pYUVShader->Disable();
  2654. +
  2655. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2656. +  g_matrices.PopMatrix(); // pop modelview
  2657. +  g_matrices.MatrixMode(MM_PROJECTION);
  2658. +  g_matrices.PopMatrix(); // pop projection
  2659. +//TODO
  2660. +//  glPopAttrib(); // pop scissor
  2661. +//  glPopAttrib(); // pop viewport
  2662. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2663. +  VerifyGLState();
  2664. +
  2665. +  m_fbo.EndRender();
  2666. +
  2667. +  glActiveTexture(GL_TEXTURE1);
  2668. +  glDisable(m_textureTarget);
  2669. +  glActiveTexture(GL_TEXTURE2);
  2670. +  glDisable(m_textureTarget);
  2671. +  glActiveTexture(GL_TEXTURE0);
  2672. +  glDisable(m_textureTarget);
  2673. +
  2674. +  glEnable(GL_TEXTURE_2D);
  2675. +  glBindTexture(GL_TEXTURE_2D, m_fbo.Texture());
  2676. +  VerifyGLState();
  2677. +
  2678. +  // Use regular normalized texture coordinates
  2679. +
  2680. +  // 2nd Pass to screen size with optional video filter
  2681. +
  2682. +  if (m_pVideoFilterShader)
  2683. +  {
  2684. +    m_fbo.SetFiltering(GL_TEXTURE_2D, GL_NEAREST);
  2685. +    m_pVideoFilterShader->SetSourceTexture(0);
  2686. +    m_pVideoFilterShader->SetWidth(m_sourceWidth);
  2687. +    m_pVideoFilterShader->SetHeight(m_sourceHeight);
  2688. +    m_pVideoFilterShader->Enable();
  2689. +  }
  2690. +  else
  2691. +    m_fbo.SetFiltering(GL_TEXTURE_2D, GL_LINEAR);
  2692. +
  2693. +  VerifyGLState();
  2694. +
  2695. +//TODO
  2696. +//   imgwidth /= m_sourceWidth;
  2697. +//   imgheight /= m_sourceHeight;
  2698. +//
  2699. +//  glBegin(GL_QUADS);
  2700. +//
  2701. +//  glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f    , 0.0f);
  2702. +//  glVertex4f(m_destRect.x1, m_destRect.y1, 0, 1.0f );
  2703. +//
  2704. +//  glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, 0.0f);
  2705. +//  glVertex4f(m_destRect.x2, m_destRect.y1, 0, 1.0f);
  2706. +//
  2707. +//  glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, imgheight);
  2708. +//  glVertex4f(m_destRect.x2, m_destRect.y2, 0, 1.0f);
  2709. +//
  2710. +//  glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f    , imgheight);
  2711. +//  glVertex4f(m_destRect.x1, m_destRect.y2, 0, 1.0f);
  2712. +//
  2713. +//  glEnd();
  2714. +
  2715. +  VerifyGLState();
  2716. +
  2717. +  if (m_pVideoFilterShader)
  2718. +    m_pVideoFilterShader->Disable();
  2719. +
  2720. +  VerifyGLState();
  2721. +
  2722. +  glDisable(m_textureTarget);
  2723. +  VerifyGLState();
  2724. +}
  2725. +
  2726. +bool CLinuxRendererA10::RenderCapture(CRenderCapture* capture)
  2727. +{
  2728. +  if (!m_bValidated)
  2729. +    return false;
  2730. +
  2731. +  // save current video rect
  2732. +  CRect saveSize = m_destRect;
  2733. +  saveRotatedCoords();//backup current m_rotatedDestCoords
  2734. +
  2735. +  // new video rect is thumbnail size
  2736. +  m_destRect.SetRect(0, 0, (float)capture->GetWidth(), (float)capture->GetHeight());
  2737. +  MarkDirty();
  2738. +  syncDestRectToRotatedPoints();//syncs the changed destRect to m_rotatedDestCoords
  2739. +  // clear framebuffer and invert Y axis to get non-inverted image
  2740. +  glDisable(GL_BLEND);
  2741. +
  2742. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2743. +  g_matrices.PushMatrix();
  2744. +  g_matrices.Translatef(0.0f, capture->GetHeight(), 0.0f);
  2745. +  g_matrices.Scalef(1.0f, -1.0f, 1.0f);
  2746. +
  2747. +  capture->BeginRender();
  2748. +
  2749. +  Render(RENDER_FLAG_NOOSD, m_iYV12RenderBuffer);
  2750. +  // read pixels
  2751. +  glReadPixels(0, g_graphicsContext.GetHeight() - capture->GetHeight(), capture->GetWidth(), capture->GetHeight(),
  2752. +               GL_RGBA, GL_UNSIGNED_BYTE, capture->GetRenderBuffer());
  2753. +
  2754. +  // OpenGLES returns in RGBA order but CRenderCapture needs BGRA order
  2755. +  // XOR Swap RGBA -> BGRA
  2756. +  unsigned char* pixels = (unsigned char*)capture->GetRenderBuffer();
  2757. +  for (unsigned int i = 0; i < capture->GetWidth() * capture->GetHeight(); i++, pixels+=4)
  2758. +  {
  2759. +    std::swap(pixels[0], pixels[2]);
  2760. +  }
  2761. +
  2762. +  capture->EndRender();
  2763. +
  2764. +  // revert model view matrix
  2765. +  g_matrices.MatrixMode(MM_MODELVIEW);
  2766. +  g_matrices.PopMatrix();
  2767. +
  2768. +  // restore original video rect
  2769. +  m_destRect = saveSize;
  2770. +  restoreRotatedCoords();//restores the previous state of the rotated dest coords
  2771. +
  2772. +  return true;
  2773. +}
  2774. +
  2775. +//********************************************************************************************************
  2776. +// YV12 Texture creation, deletion, copying + clearing
  2777. +//********************************************************************************************************
  2778. +void CLinuxRendererA10::UploadYV12Texture(int source)
  2779. +{
  2780. +  YUVBUFFER& buf    =  m_buffers[source];
  2781. +  YV12Image* im     = &buf.image;
  2782. +  YUVFIELDS& fields =  buf.fields;
  2783. +
  2784. +
  2785. +  if (!(im->flags&IMAGE_FLAG_READY))
  2786. +  {
  2787. +    m_eventTexturesDone[source]->Set();
  2788. +    return;
  2789. +  }
  2790. +
  2791. +  bool deinterlacing;
  2792. +  if (m_currentField == FIELD_FULL)
  2793. +    deinterlacing = false;
  2794. +  else
  2795. +    deinterlacing = true;
  2796. +
  2797. +  glEnable(m_textureTarget);
  2798. +  VerifyGLState();
  2799. +
  2800. +  glPixelStorei(GL_UNPACK_ALIGNMENT,1);
  2801. +
  2802. +  if (deinterlacing)
  2803. +  {
  2804. +    // Load Y fields
  2805. +    LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
  2806. +        , im->width, im->height >> 1
  2807. +        , im->stride[0]*2, im->plane[0] );
  2808. +
  2809. +    LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
  2810. +        , im->width, im->height >> 1
  2811. +        , im->stride[0]*2, im->plane[0] + im->stride[0]) ;
  2812. +  }
  2813. +  else
  2814. +  {
  2815. +    // Load Y plane
  2816. +    LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
  2817. +        , im->width, im->height
  2818. +        , im->stride[0], im->plane[0] );
  2819. +  }
  2820. +
  2821. +  VerifyGLState();
  2822. +
  2823. +  glPixelStorei(GL_UNPACK_ALIGNMENT,1);
  2824. +
  2825. +  if (deinterlacing)
  2826. +  {
  2827. +    // Load Even U & V Fields
  2828. +    LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
  2829. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  2830. +        , im->stride[1]*2, im->plane[1] );
  2831. +
  2832. +    LoadPlane( fields[FIELD_TOP][2], GL_LUMINANCE, buf.flipindex
  2833. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  2834. +        , im->stride[2]*2, im->plane[2] );
  2835. +
  2836. +    // Load Odd U & V Fields
  2837. +    LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
  2838. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  2839. +        , im->stride[1]*2, im->plane[1] + im->stride[1] );
  2840. +
  2841. +    LoadPlane( fields[FIELD_BOT][2], GL_LUMINANCE, buf.flipindex
  2842. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  2843. +        , im->stride[2]*2, im->plane[2] + im->stride[2] );
  2844. +
  2845. +  }
  2846. +  else
  2847. +  {
  2848. +    LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
  2849. +        , im->width >> im->cshift_x, im->height >> im->cshift_y
  2850. +        , im->stride[1], im->plane[1] );
  2851. +
  2852. +    LoadPlane( fields[FIELD_FULL][2], GL_LUMINANCE, buf.flipindex
  2853. +        , im->width >> im->cshift_x, im->height >> im->cshift_y
  2854. +        , im->stride[2], im->plane[2] );
  2855. +  }
  2856. +
  2857. +  m_eventTexturesDone[source]->Set();
  2858. +
  2859. +  CalculateTextureSourceRects(source, 3);
  2860. +
  2861. +  glDisable(m_textureTarget);
  2862. +}
  2863. +
  2864. +void CLinuxRendererA10::DeleteYV12Texture(int index)
  2865. +{
  2866. +  YV12Image &im     = m_buffers[index].image;
  2867. +  YUVFIELDS &fields = m_buffers[index].fields;
  2868. +
  2869. +  if( fields[FIELD_FULL][0].id == 0 ) return;
  2870. +
  2871. +  /* finish up all textures, and delete them */
  2872. +  g_graphicsContext.BeginPaint();  //FIXME
  2873. +  for(int f = 0;f<MAX_FIELDS;f++)
  2874. +  {
  2875. +    for(int p = 0;p<MAX_PLANES;p++)
  2876. +    {
  2877. +      if( fields[f][p].id )
  2878. +      {
  2879. +        if (glIsTexture(fields[f][p].id))
  2880. +          glDeleteTextures(1, &fields[f][p].id);
  2881. +        fields[f][p].id = 0;
  2882. +      }
  2883. +    }
  2884. +  }
  2885. +  g_graphicsContext.EndPaint();
  2886. +
  2887. +  for(int p = 0;p<MAX_PLANES;p++)
  2888. +  {
  2889. +    if (im.plane[p])
  2890. +    {
  2891. +      delete [] im.plane[p];
  2892. +      im.plane[p] = NULL;
  2893. +    }
  2894. +  }
  2895. +}
  2896. +
  2897. +bool CLinuxRendererA10::CreateYV12Texture(int index)
  2898. +{
  2899. +  /* since we also want the field textures, pitch must be texture aligned */
  2900. +  YV12Image &im     = m_buffers[index].image;
  2901. +  YUVFIELDS &fields = m_buffers[index].fields;
  2902. +
  2903. +  DeleteYV12Texture(index);
  2904. +
  2905. +  im.height = m_sourceHeight;
  2906. +  im.width  = m_sourceWidth;
  2907. +  im.cshift_x = 1;
  2908. +  im.cshift_y = 1;
  2909. +
  2910. +  im.stride[0] = im.width;
  2911. +  im.stride[1] = im.width >> im.cshift_x;
  2912. +  im.stride[2] = im.width >> im.cshift_x;
  2913. +
  2914. +  im.planesize[0] = im.stride[0] * im.height;
  2915. +  im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
  2916. +  im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
  2917. +
  2918. +  for (int i = 0; i < MAX_PLANES; i++)
  2919. +    im.plane[i] = new BYTE[im.planesize[i]];
  2920. +
  2921. +  glEnable(m_textureTarget);
  2922. +  for(int f = 0;f<MAX_FIELDS;f++)
  2923. +  {
  2924. +    for(int p = 0;p<MAX_PLANES;p++)
  2925. +    {
  2926. +      if (!glIsTexture(fields[f][p].id))
  2927. +      {
  2928. +        glGenTextures(1, &fields[f][p].id);
  2929. +        VerifyGLState();
  2930. +      }
  2931. +    }
  2932. +  }
  2933. +
  2934. +  // YUV
  2935. +  for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
  2936. +  {
  2937. +    int fieldshift = (f==FIELD_FULL) ? 0 : 1;
  2938. +    YUVPLANES &planes = fields[f];
  2939. +
  2940. +    planes[0].texwidth  = im.width;
  2941. +    planes[0].texheight = im.height >> fieldshift;
  2942. +
  2943. +    planes[1].texwidth  = planes[0].texwidth  >> im.cshift_x;
  2944. +    planes[1].texheight = planes[0].texheight >> im.cshift_y;
  2945. +    planes[2].texwidth  = planes[0].texwidth  >> im.cshift_x;
  2946. +    planes[2].texheight = planes[0].texheight >> im.cshift_y;
  2947. +
  2948. +    for(int p = 0; p < 3; p++)
  2949. +    {
  2950. +      YUVPLANE &plane = planes[p];
  2951. +      if (plane.texwidth * plane.texheight == 0)
  2952. +        continue;
  2953. +
  2954. +      glBindTexture(m_textureTarget, plane.id);
  2955. +      CLog::Log(LOGDEBUG,  "GL: Creating YUV NPOT texture of size %d x %d", plane.texwidth, plane.texheight);
  2956. +
  2957. +      glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, plane.texwidth, plane.texheight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
  2958. +
  2959. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  2960. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  2961. +      glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  2962. +      glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  2963. +      VerifyGLState();
  2964. +    }
  2965. +  }
  2966. +  glDisable(m_textureTarget);
  2967. +  m_eventTexturesDone[index]->Set();
  2968. +  return true;
  2969. +}
  2970. +
  2971. +//********************************************************************************************************
  2972. +// BYPASS creation, deletion, copying + clearing
  2973. +//********************************************************************************************************
  2974. +void CLinuxRendererA10::UploadBYPASSTexture(int index)
  2975. +{
  2976. +  m_eventTexturesDone[index]->Set();
  2977. +}
  2978. +
  2979. +void CLinuxRendererA10::DeleteBYPASSTexture(int index)
  2980. +{
  2981. +}
  2982. +
  2983. +bool CLinuxRendererA10::CreateBYPASSTexture(int index)
  2984. +{
  2985. +  m_eventTexturesDone[index]->Set();
  2986. +  return true;
  2987. +}
  2988. +
  2989. +void CLinuxRendererA10::SetTextureFilter(GLenum method)
  2990. +{
  2991. +  for (int i = 0 ; i<NUM_BUFFERS ; i++)
  2992. +  {
  2993. +    YUVFIELDS &fields = m_buffers[i].fields;
  2994. +
  2995. +    for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
  2996. +    {
  2997. +      glBindTexture(m_textureTarget, fields[f][0].id);
  2998. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  2999. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  3000. +      VerifyGLState();
  3001. +
  3002. +      glBindTexture(m_textureTarget, fields[f][1].id);
  3003. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  3004. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  3005. +      VerifyGLState();
  3006. +
  3007. +      glBindTexture(m_textureTarget, fields[f][2].id);
  3008. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  3009. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  3010. +      VerifyGLState();
  3011. +    }
  3012. +  }
  3013. +}
  3014. +
  3015. +bool CLinuxRendererA10::Supports(ERENDERFEATURE feature)
  3016. +{
  3017. +  // Player controls render, let it dictate available render features
  3018. +  if((m_renderMethod & RENDER_BYPASS))
  3019. +  {
  3020. +    Features::iterator itr = std::find(m_renderFeatures.begin(),m_renderFeatures.end(), feature);
  3021. +    return itr != m_renderFeatures.end();
  3022. +  }
  3023. +
  3024. +  if(feature == RENDERFEATURE_BRIGHTNESS)
  3025. +    return false;
  3026. +
  3027. +  if(feature == RENDERFEATURE_CONTRAST)
  3028. +    return false;
  3029. +
  3030. +  if(feature == RENDERFEATURE_GAMMA)
  3031. +    return false;
  3032. +
  3033. +  if(feature == RENDERFEATURE_NOISE)
  3034. +    return false;
  3035. +
  3036. +  if(feature == RENDERFEATURE_SHARPNESS)
  3037. +    return false;
  3038. +
  3039. +  if (feature == RENDERFEATURE_NONLINSTRETCH)
  3040. +    return false;
  3041. +
  3042. +  if (feature == RENDERFEATURE_STRETCH         ||
  3043. +      feature == RENDERFEATURE_CROP            ||
  3044. +      feature == RENDERFEATURE_ZOOM            ||
  3045. +      feature == RENDERFEATURE_VERTICAL_SHIFT  ||
  3046. +      feature == RENDERFEATURE_PIXEL_RATIO     ||
  3047. +      feature == RENDERFEATURE_POSTPROCESS     ||
  3048. +      feature == RENDERFEATURE_ROTATION)
  3049. +    return true;
  3050. +
  3051. +
  3052. +  return false;
  3053. +}
  3054. +
  3055. +bool CLinuxRendererA10::SupportsMultiPassRendering()
  3056. +{
  3057. +  return false;
  3058. +}
  3059. +
  3060. +bool CLinuxRendererA10::Supports(EDEINTERLACEMODE mode)
  3061. +{
  3062. +  // Player controls render, let it dictate available deinterlace modes
  3063. +  if((m_renderMethod & RENDER_BYPASS))
  3064. +  {
  3065. +    Features::iterator itr = std::find(m_deinterlaceModes.begin(),m_deinterlaceModes.end(), mode);
  3066. +    return itr != m_deinterlaceModes.end();
  3067. +  }
  3068. +
  3069. +  if (mode == VS_DEINTERLACEMODE_OFF)
  3070. +    return true;
  3071. +
  3072. +  if(mode == VS_DEINTERLACEMODE_AUTO || mode == VS_DEINTERLACEMODE_FORCE)
  3073. +    return true;
  3074. +
  3075. +  return false;
  3076. +}
  3077. +
  3078. +bool CLinuxRendererA10::Supports(EINTERLACEMETHOD method)
  3079. +{
  3080. +  // Player controls render, let it dictate available deinterlace methods
  3081. +  if((m_renderMethod & RENDER_BYPASS))
  3082. +  {
  3083. +    Features::iterator itr = std::find(m_deinterlaceMethods.begin(),m_deinterlaceMethods.end(), method);
  3084. +    return itr != m_deinterlaceMethods.end();
  3085. +  }
  3086. +
  3087. +  if(method == VS_INTERLACEMETHOD_AUTO)
  3088. +    return true;
  3089. +
  3090. +#if defined(__i386__) || defined(__x86_64__)
  3091. +  if(method == VS_INTERLACEMETHOD_DEINTERLACE
  3092. +  || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
  3093. +  || method == VS_INTERLACEMETHOD_SW_BLEND)
  3094. +#else
  3095. +  if(method == VS_INTERLACEMETHOD_SW_BLEND)
  3096. +#endif
  3097. +    return true;
  3098. +
  3099. +  return false;
  3100. +}
  3101. +
  3102. +bool CLinuxRendererA10::Supports(ESCALINGMETHOD method)
  3103. +{
  3104. +  // Player controls render, let it dictate available scaling methods
  3105. +  if((m_renderMethod & RENDER_BYPASS))
  3106. +  {
  3107. +    Features::iterator itr = std::find(m_scalingMethods.begin(),m_scalingMethods.end(), method);
  3108. +    return itr != m_scalingMethods.end();
  3109. +  }
  3110. +
  3111. +  if(method == VS_SCALINGMETHOD_NEAREST
  3112. +  || method == VS_SCALINGMETHOD_LINEAR)
  3113. +    return true;
  3114. +
  3115. +  return false;
  3116. +}
  3117. +
  3118. +EINTERLACEMETHOD CLinuxRendererA10::AutoInterlaceMethod()
  3119. +{
  3120. +  // Player controls render, let it pick the auto-deinterlace method
  3121. +  if((m_renderMethod & RENDER_BYPASS))
  3122. +  {
  3123. +    if (m_deinterlaceMethods.empty())
  3124. +      return ((EINTERLACEMETHOD)m_deinterlaceMethods[0]);
  3125. +    else
  3126. +      return VS_INTERLACEMETHOD_NONE;
  3127. +  }
  3128. +
  3129. +#if defined(__i386__) || defined(__x86_64__)
  3130. +  return VS_INTERLACEMETHOD_DEINTERLACE_HALF;
  3131. +#else
  3132. +  return VS_INTERLACEMETHOD_SW_BLEND;
  3133. +#endif
  3134. +}
  3135. +
  3136. +void CLinuxRendererA10::AddProcessor(struct A10VLQueueItem *buffer)
  3137. +{
  3138. +  YUVBUFFER &buf = m_buffers[NextYV12Texture()];
  3139. +
  3140. +  buf.a10buffer = buffer;
  3141. +}
  3142. +
  3143. +/*
  3144. + * Video layer functions
  3145. + */
  3146. +
  3147. +static int             g_hfb = -1;
  3148. +static int             g_hdisp = -1;
  3149. +static int             g_screenid = 0;
  3150. +static int             g_syslayer = 0x64;
  3151. +static int             g_hlayer = 0;
  3152. +static int             g_width;
  3153. +static int             g_height;
  3154. +static CRect           g_srcRect;
  3155. +static CRect           g_dstRect;
  3156. +static int             g_lastnr;
  3157. +static int             g_decnr;
  3158. +static int             g_wridx;
  3159. +static int             g_rdidx;
  3160. +static A10VLQueueItem  g_dispq[DISPQS];
  3161. +static pthread_mutex_t g_dispq_mutex;
  3162. +
  3163. +bool A10VLInit(int &width, int &height, double &refreshRate)
  3164. +{
  3165. +  unsigned long       args[4];
  3166. +  __disp_layer_info_t layera;
  3167. +  unsigned int        i;
  3168. +
  3169. +  pthread_mutex_init(&g_dispq_mutex, NULL);
  3170. +
  3171. +  g_hfb = open("/dev/fb0", O_RDWR);
  3172. +
  3173. +  g_hdisp = open("/dev/disp", O_RDWR);
  3174. +  if (g_hdisp == -1)
  3175. +  {
  3176. +    CLog::Log(LOGERROR, "A10: open /dev/disp failed. (%d)", errno);
  3177. +    return false;
  3178. +  }
  3179. +
  3180. +  args[0] = g_screenid;
  3181. +  args[1] = 0;
  3182. +  args[2] = 0;
  3183. +  args[3] = 0;
  3184. +  width  = g_width  = ioctl(g_hdisp, DISP_CMD_SCN_GET_WIDTH , args);
  3185. +  height = g_height = ioctl(g_hdisp, DISP_CMD_SCN_GET_HEIGHT, args);
  3186. +
  3187. +  i = ioctl(g_hdisp, DISP_CMD_HDMI_GET_MODE, args);
  3188. +
  3189. +  switch(i)
  3190. +  {
  3191. +  case DISP_TV_MOD_720P_50HZ:
  3192. +  case DISP_TV_MOD_1080I_50HZ:
  3193. +  case DISP_TV_MOD_1080P_50HZ:
  3194. +    refreshRate = 50.0;
  3195. +    break;
  3196. +  case DISP_TV_MOD_720P_60HZ:
  3197. +  case DISP_TV_MOD_1080I_60HZ:
  3198. +  case DISP_TV_MOD_1080P_60HZ:
  3199. +    refreshRate = 60.0;
  3200. +    break;
  3201. +  case DISP_TV_MOD_1080P_24HZ:
  3202. +    refreshRate = 24.0;
  3203. +    break;
  3204. +  default:
  3205. +    CLog::Log(LOGERROR, "A10: display mode %d is unknown. Assume refreh rate 60Hz\n", i);
  3206. +    refreshRate = 60.0;
  3207. +    break;
  3208. +  }
  3209. +
  3210. +  if ((g_height > 720) && (getenv("A10AB") == NULL))
  3211. +  {
  3212. +    //set workmode scaler (system layer)
  3213. +    args[0] = g_screenid;
  3214. +    args[1] = g_syslayer;
  3215. +    args[2] = (unsigned long) (&layera);
  3216. +    args[3] = 0;
  3217. +    ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  3218. +    layera.mode = DISP_LAYER_WORK_MODE_SCALER;
  3219. +    args[0] = g_screenid;
  3220. +    args[1] = g_syslayer;
  3221. +    args[2] = (unsigned long) (&layera);
  3222. +    args[3] = 0;
  3223. +    ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args);
  3224. +  }
  3225. +  else
  3226. +  {
  3227. +    //set workmode normal (system layer)
  3228. +    args[0] = g_screenid;
  3229. +    args[1] = g_syslayer;
  3230. +    args[2] = (unsigned long) (&layera);
  3231. +    args[3] = 0;
  3232. +    ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  3233. +    //source window information
  3234. +    layera.src_win.x      = 0;
  3235. +    layera.src_win.y      = 0;
  3236. +    layera.src_win.width  = g_width;
  3237. +    layera.src_win.height = g_height;
  3238. +    //screen window information
  3239. +    layera.scn_win.x      = 0;
  3240. +    layera.scn_win.y      = 0;
  3241. +    layera.scn_win.width  = g_width;
  3242. +    layera.scn_win.height = g_height;
  3243. +    layera.mode = DISP_LAYER_WORK_MODE_NORMAL;
  3244. +    args[0] = g_screenid;
  3245. +    args[1] = g_syslayer;
  3246. +    args[2] = (unsigned long) (&layera);
  3247. +    args[3] = 0;
  3248. +    ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args);
  3249. +
  3250. +  }
  3251. +
  3252. +  for (i = 0x65; i <= 0x67; i++)
  3253. +  {
  3254. +    //release possibly lost allocated layers
  3255. +    args[0] = g_screenid;
  3256. +    args[1] = i;
  3257. +    args[2] = 0;
  3258. +    args[3] = 0;
  3259. +    ioctl(g_hdisp, DISP_CMD_LAYER_RELEASE, args);
  3260. +  }
  3261. +
  3262. +  args[0] = g_screenid;
  3263. +  args[1] = DISP_LAYER_WORK_MODE_SCALER;
  3264. +  args[2] = 0;
  3265. +  args[3] = 0;
  3266. +  g_hlayer = ioctl(g_hdisp, DISP_CMD_LAYER_REQUEST, args);
  3267. +  if (g_hlayer <= 0)
  3268. +  {
  3269. +    g_hlayer = 0;
  3270. +    CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_REQUEST failed.\n");
  3271. +    return false;
  3272. +  }
  3273. +
  3274. +  memset(&g_srcRect, 0, sizeof(g_srcRect));
  3275. +  memset(&g_dstRect, 0, sizeof(g_dstRect));
  3276. +
  3277. +  g_lastnr = -1;
  3278. +  g_decnr  = 0;
  3279. +  g_rdidx  = 0;
  3280. +  g_wridx  = 0;
  3281. +
  3282. +  for (i = 0; i < DISPQS; i++)
  3283. +    g_dispq[i].pict.id = -1;
  3284. +
  3285. +  return true;
  3286. +}
  3287. +
  3288. +void A10VLExit()
  3289. +{
  3290. +  unsigned long args[4];
  3291. +
  3292. +  if (g_hlayer)
  3293. +  {
  3294. +    //stop video
  3295. +    args[0] = g_screenid;
  3296. +    args[1] = g_hlayer;
  3297. +    args[2] = 0;
  3298. +    args[3] = 0;
  3299. +    ioctl(g_hdisp, DISP_CMD_VIDEO_STOP, args);
  3300. +
  3301. +    //close layer
  3302. +    args[0] = g_screenid;
  3303. +    args[1] = g_hlayer;
  3304. +    args[2] = 0;
  3305. +    args[3] = 0;
  3306. +    ioctl(g_hdisp, DISP_CMD_LAYER_CLOSE, args);
  3307. +
  3308. +    //release layer
  3309. +    args[0] = g_screenid;
  3310. +    args[1] = g_hlayer;
  3311. +    args[2] = 0;
  3312. +    args[3] = 0;
  3313. +    ioctl(g_hdisp, DISP_CMD_LAYER_RELEASE, args);
  3314. +    g_hlayer = 0;
  3315. +  }
  3316. +  if (g_hdisp != -1)
  3317. +  {
  3318. +    close(g_hdisp);
  3319. +    g_hdisp = -1;
  3320. +  }
  3321. +  if (g_hfb != -1)
  3322. +  {
  3323. +    close(g_hfb);
  3324. +    g_hfb = -1;
  3325. +  }
  3326. +}
  3327. +
  3328. +void A10VLHide()
  3329. +{
  3330. +  unsigned long args[4];
  3331. +
  3332. +  if (g_hlayer)
  3333. +  {
  3334. +    //stop video
  3335. +    args[0] = g_screenid;
  3336. +    args[1] = g_hlayer;
  3337. +    args[2] = 0;
  3338. +    args[3] = 0;
  3339. +    ioctl(g_hdisp, DISP_CMD_VIDEO_STOP, args);
  3340. +
  3341. +    //close layer
  3342. +    args[0] = g_screenid;
  3343. +    args[1] = g_hlayer;
  3344. +    args[2] = 0;
  3345. +    args[3] = 0;
  3346. +    ioctl(g_hdisp, DISP_CMD_LAYER_CLOSE, args);
  3347. +  }
  3348. +
  3349. +  memset(&g_srcRect, 0, sizeof(g_srcRect));
  3350. +  memset(&g_dstRect, 0, sizeof(g_dstRect));
  3351. +}
  3352. +
  3353. +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u32)
  3354. +
  3355. +void A10VLWaitVSYNC()
  3356. +{
  3357. +  //ioctl(g_hfb, FBIO_WAITFORVSYNC, NULL);
  3358. +}
  3359. +
  3360. +A10VLQueueItem *A10VLPutQueue(A10VLCALLBACK     callback,
  3361. +                              void             *callbackpriv,
  3362. +                              void             *pictpriv,
  3363. +                              cedarv_picture_t &pict)
  3364. +{
  3365. +  A10VLQueueItem *pRet;
  3366. +
  3367. +  pthread_mutex_lock(&g_dispq_mutex);
  3368. +
  3369. +  pRet = &g_dispq[g_wridx];
  3370. +
  3371. +  pRet->decnr        = g_decnr++;
  3372. +  pRet->callback     = callback;
  3373. +  pRet->callbackpriv = callbackpriv;
  3374. +  pRet->pictpriv     = pictpriv;
  3375. +  pRet->pict         = pict;
  3376. +
  3377. +  g_wridx++;
  3378. +  if (g_wridx >= DISPQS)
  3379. +    g_wridx = 0;
  3380. +
  3381. +  pthread_mutex_unlock(&g_dispq_mutex);
  3382. +
  3383. +  return pRet;
  3384. +}
  3385. +
  3386. +static void A10VLFreeQueueItem(A10VLQueueItem *pItem)
  3387. +{
  3388. +  if ((int)pItem->pict.id != -1)
  3389. +  {
  3390. +    if (pItem->callback)
  3391. +      pItem->callback(pItem->callbackpriv, pItem->pictpriv, pItem->pict);
  3392. +    pItem->pict.id = -1;
  3393. +  }
  3394. +}
  3395. +
  3396. +void A10VLFreeQueue()
  3397. +{
  3398. +  int i;
  3399. +
  3400. +  pthread_mutex_lock(&g_dispq_mutex);
  3401. +
  3402. +  for (i = 0; i < DISPQS; i++)
  3403. +    A10VLFreeQueueItem(&g_dispq[i]);
  3404. +
  3405. +  pthread_mutex_unlock(&g_dispq_mutex);
  3406. +}
  3407. +
  3408. +void A10VLDisplayQueueItem(A10VLQueueItem *pItem, CRect &srcRect, CRect &dstRect)
  3409. +{
  3410. +  int i;
  3411. +  int curnr;
  3412. +
  3413. +  pthread_mutex_lock(&g_dispq_mutex);
  3414. +
  3415. +  if (!pItem || (pItem->pict.id == -1) || (g_lastnr == pItem->decnr))
  3416. +  {
  3417. +    pthread_mutex_unlock(&g_dispq_mutex);
  3418. +    return;
  3419. +  }
  3420. +
  3421. +  curnr = A10VLDisplayPicture(pItem->pict, pItem->decnr, srcRect, dstRect);
  3422. +
  3423. +  if (curnr != g_lastnr)
  3424. +  {
  3425. +    //free older frames, displayed or not
  3426. +    for (i = 0; i < DISPQS; i++)
  3427. +    {
  3428. +      if(g_dispq[g_rdidx].decnr < curnr)
  3429. +      {
  3430. +        A10VLFreeQueueItem(&g_dispq[g_rdidx]);
  3431. +
  3432. +        g_rdidx++;
  3433. +        if (g_rdidx >= DISPQS)
  3434. +          g_rdidx = 0;
  3435. +
  3436. +      } else break;
  3437. +    }
  3438. +
  3439. +  }
  3440. +
  3441. +  g_lastnr = curnr;
  3442. +
  3443. +  pthread_mutex_unlock(&g_dispq_mutex);
  3444. +}
  3445. +
  3446. +int A10VLDisplayPicture(cedarv_picture_t &picture,
  3447. +                        int               refnr,
  3448. +                        CRect            &srcRect,
  3449. +                        CRect            &dstRect)
  3450. +{
  3451. +  unsigned long       args[4];
  3452. +  __disp_layer_info_t layera;
  3453. +  __disp_video_fb_t   frmbuf;
  3454. +  __disp_colorkey_t   colorkey;
  3455. +
  3456. +  memset(&frmbuf, 0, sizeof(__disp_video_fb_t));
  3457. +  frmbuf.id              = refnr;
  3458. +  frmbuf.interlace       = picture.is_progressive? 0 : 1;
  3459. +  frmbuf.top_field_first = picture.top_field_first;
  3460. +  //frmbuf.frame_rate      = picture.frame_rate;
  3461. +#ifdef CEDARV_FRAME_HAS_PHY_ADDR
  3462. +  frmbuf.addr[0]         = (u32)picture.y;
  3463. +  frmbuf.addr[1]         = (u32)picture.u;
  3464. +#else
  3465. +  frmbuf.addr[0]         = mem_get_phy_addr((u32)picture.y);
  3466. +  frmbuf.addr[1]         = mem_get_phy_addr((u32)picture.u);
  3467. +#endif
  3468. +
  3469. +  if ((g_srcRect != srcRect) || (g_dstRect != dstRect))
  3470. +  {
  3471. +    args[0] = g_screenid;
  3472. +    args[1] = g_hlayer;
  3473. +    args[2] = (unsigned long) (&layera);
  3474. +    args[3] = 0;
  3475. +    ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  3476. +    //set video layer attribute
  3477. +    layera.mode          = DISP_LAYER_WORK_MODE_SCALER;
  3478. +    layera.b_from_screen = 0; //what is this? if enabled all is black
  3479. +    layera.pipe          = 1;
  3480. +    //use alpha blend
  3481. +    layera.alpha_en      = 0;
  3482. +    layera.alpha_val     = 0xff;
  3483. +    layera.ck_enable     = 0;
  3484. +    layera.b_trd_out     = 0;
  3485. +    layera.out_trd_mode  = (__disp_3d_out_mode_t)0;
  3486. +    //frame buffer pst and size information
  3487. +    if (picture.display_height < 720)
  3488. +    {
  3489. +      layera.fb.cs_mode = DISP_BT601;
  3490. +    }
  3491. +    else
  3492. +    {
  3493. +      layera.fb.cs_mode = DISP_BT709;
  3494. +    }
  3495. +    layera.fb.mode        = DISP_MOD_MB_UV_COMBINED;
  3496. +    layera.fb.format      = picture.pixel_format == CEDARV_PIXEL_FORMAT_AW_YUV422 ? DISP_FORMAT_YUV422 : DISP_FORMAT_YUV420;
  3497. +    layera.fb.br_swap     = 0;
  3498. +    layera.fb.seq         = DISP_SEQ_UVUV;
  3499. +    layera.fb.addr[0]     = frmbuf.addr[0];
  3500. +    layera.fb.addr[1]     = frmbuf.addr[1];
  3501. +    layera.fb.b_trd_src   = 0;
  3502. +    layera.fb.trd_mode    = (__disp_3d_src_mode_t)0;
  3503. +    layera.fb.size.width  = picture.display_width;
  3504. +    layera.fb.size.height = picture.display_height;
  3505. +    //source window information
  3506. +    layera.src_win.x      = lrint(srcRect.x1);
  3507. +    layera.src_win.y      = lrint(srcRect.y1);
  3508. +    layera.src_win.width  = lrint(srcRect.x2-srcRect.x1);
  3509. +    layera.src_win.height = lrint(srcRect.y2-srcRect.y1);
  3510. +    //screen window information
  3511. +    layera.scn_win.x      = lrint(dstRect.x1);
  3512. +    layera.scn_win.y      = lrint(dstRect.y1);
  3513. +    layera.scn_win.width  = lrint(dstRect.x2-dstRect.x1);
  3514. +    layera.scn_win.height = lrint(dstRect.y2-dstRect.y1);
  3515. +
  3516. +    CLog::Log(LOGDEBUG, "A10: srcRect=(%lf,%lf)-(%lf,%lf)\n", srcRect.x1, srcRect.y1, srcRect.x2, srcRect.y2);
  3517. +    CLog::Log(LOGDEBUG, "A10: dstRect=(%lf,%lf)-(%lf,%lf)\n", dstRect.x1, dstRect.y1, dstRect.x2, dstRect.y2);
  3518. +
  3519. +    if (    (layera.scn_win.x < 0)
  3520. +         || (layera.scn_win.y < 0)
  3521. +         || (layera.scn_win.width  > g_width)
  3522. +         || (layera.scn_win.height > g_height)    )
  3523. +    {
  3524. +      double xzoom, yzoom;
  3525. +
  3526. +      //TODO: this calculation is against the display fullscreen dimensions,
  3527. +      //but should be against the fullscreen area of xbmc
  3528. +
  3529. +      xzoom = (dstRect.x2 - dstRect.x1) / (srcRect.x2 - srcRect.x1);
  3530. +      yzoom = (dstRect.y2 - dstRect.y1) / (srcRect.y2 - srcRect.x1);
  3531. +
  3532. +      if (layera.scn_win.x < 0)
  3533. +      {
  3534. +        layera.src_win.x -= layera.scn_win.x / xzoom;
  3535. +        layera.scn_win.x = 0;
  3536. +      }
  3537. +      if (layera.scn_win.width > g_width)
  3538. +      {
  3539. +        layera.src_win.width -= (layera.scn_win.width - g_width) / xzoom;
  3540. +        layera.scn_win.width = g_width;
  3541. +      }
  3542. +
  3543. +      if (layera.scn_win.y < 0)
  3544. +      {
  3545. +        layera.src_win.y -= layera.scn_win.y / yzoom;
  3546. +        layera.scn_win.y = 0;
  3547. +      }
  3548. +      if (layera.scn_win.height > g_height)
  3549. +      {
  3550. +        layera.src_win.height -= (layera.scn_win.height - g_height) / yzoom;
  3551. +        layera.scn_win.height = g_height;
  3552. +      }
  3553. +    }
  3554. +
  3555. +    args[0] = g_screenid;
  3556. +    args[1] = g_hlayer;
  3557. +    args[2] = (unsigned long)&layera;
  3558. +    args[3] = 0;
  3559. +    if(ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args))
  3560. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_SET_PARA failed.\n");
  3561. +
  3562. +    //open layer
  3563. +    args[0] = g_screenid;
  3564. +    args[1] = g_hlayer;
  3565. +    args[2] = 0;
  3566. +    args[3] = 0;
  3567. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_OPEN, args))
  3568. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_OPEN failed.\n");
  3569. +
  3570. +    //put behind system layer
  3571. +    args[0] = g_screenid;
  3572. +    args[1] = g_hlayer;
  3573. +    args[2] = 0;
  3574. +    args[3] = 0;
  3575. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_BOTTOM, args))
  3576. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_BOTTOM failed.\n");
  3577. +
  3578. +    //turn off colorkey (system layer)
  3579. +    args[0] = g_screenid;
  3580. +    args[1] = g_syslayer;
  3581. +    args[2] = 0;
  3582. +    args[3] = 0;
  3583. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_CK_OFF, args))
  3584. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_OFF failed.\n");
  3585. +
  3586. +    if ((g_height > 720) && (getenv("A10AB") == NULL))
  3587. +    {
  3588. +      //no tearing at the cost off alpha blending...
  3589. +
  3590. +      //set colorkey
  3591. +      colorkey.ck_min.alpha = 0;
  3592. +      colorkey.ck_min.red   = 1;
  3593. +      colorkey.ck_min.green = 2;
  3594. +      colorkey.ck_min.blue  = 3;
  3595. +      colorkey.ck_max = colorkey.ck_min;
  3596. +      colorkey.ck_max.alpha = 255;
  3597. +      colorkey.red_match_rule   = 2;
  3598. +      colorkey.green_match_rule = 2;
  3599. +      colorkey.blue_match_rule  = 2;
  3600. +
  3601. +      args[0] = g_screenid;
  3602. +      args[1] = (unsigned long)&colorkey;
  3603. +      args[2] = 0;
  3604. +      args[3] = 0;
  3605. +      if (ioctl(g_hdisp, DISP_CMD_SET_COLORKEY, args))
  3606. +        CLog::Log(LOGERROR, "A10: DISP_CMD_SET_COLORKEY failed.\n");
  3607. +
  3608. +      //turn on colorkey
  3609. +      args[0] = g_screenid;
  3610. +      args[1] = g_hlayer;
  3611. +      args[2] = 0;
  3612. +      args[3] = 0;
  3613. +      if (ioctl(g_hdisp, DISP_CMD_LAYER_CK_ON, args))
  3614. +        CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  3615. +
  3616. +      //turn on global alpha (system layer)
  3617. +      args[0] = g_screenid;
  3618. +      args[1] = g_syslayer;
  3619. +      args[2] = 0;
  3620. +      args[3] = 0;
  3621. +      if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  3622. +        CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_ALPHA_ON failed.\n");
  3623. +    }
  3624. +    else
  3625. +    {
  3626. +      //turn off global alpha (system layer)
  3627. +      args[0] = g_screenid;
  3628. +      args[1] = g_syslayer;
  3629. +      args[2] = 0;
  3630. +      args[3] = 0;
  3631. +      if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  3632. +        CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_ALPHA_OFF failed.\n");
  3633. +    }
  3634. +
  3635. +    //enable vpp
  3636. +    args[0] = g_screenid;
  3637. +    args[1] = g_hlayer;
  3638. +    args[2] = 0;
  3639. +    args[3] = 0;
  3640. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_VPP_ON, args))
  3641. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_VPP_ON failed.\n");
  3642. +
  3643. +    //enable enhance
  3644. +    args[0] = g_screenid;
  3645. +    args[1] = g_hlayer;
  3646. +    args[2] = 0;
  3647. +    args[3] = 0;
  3648. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ENHANCE_ON, args))
  3649. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_ENHANCE_ON failed.\n");
  3650. +
  3651. +    //start video
  3652. +    args[0] = g_screenid;
  3653. +    args[1] = g_hlayer;
  3654. +    args[2] = 0;
  3655. +    args[3] = 0;
  3656. +    if (ioctl(g_hdisp, DISP_CMD_VIDEO_START, args))
  3657. +      CLog::Log(LOGERROR, "A10: DISP_CMD_VIDEO_START failed.\n");
  3658. +
  3659. +    g_srcRect = srcRect;
  3660. +    g_dstRect = dstRect;
  3661. +  }
  3662. +
  3663. +  args[0] = g_screenid;
  3664. +  args[1] = g_hlayer;
  3665. +  args[2] = (unsigned long)&frmbuf;
  3666. +  args[3] = 0;
  3667. +  if (ioctl(g_hdisp, DISP_CMD_VIDEO_SET_FB, args))
  3668. +    CLog::Log(LOGERROR, "A10: DISP_CMD_VIDEO_SET_FB failed.\n");
  3669. +
  3670. +  //CLog::Log(LOGDEBUG, "A10: render %d\n", buffer->picture.id);
  3671. +
  3672. +  args[0] = g_screenid;
  3673. +  args[1] = g_hlayer;
  3674. +  args[2] = 0;
  3675. +  args[3] = 0;
  3676. +  return ioctl(g_hdisp, DISP_CMD_VIDEO_GET_FRAME_ID, args);
  3677. +}
  3678. +
  3679. +#endif
  3680. +
  3681. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.h xbmc_rellla/xbmc/cores/VideoRenderers/LinuxRendererA10.h
  3682. --- xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.h  1970-01-01 01:00:00.000000000 +0100
  3683. +++ xbmc_rellla/xbmc/cores/VideoRenderers/LinuxRendererA10.h    2013-06-12 17:13:43.000000000 +0200
  3684. @@ -0,0 +1,306 @@
  3685. +#ifndef LinuxRendererA10_RENDERER
  3686. +#define LinuxRendererA10_RENDERER
  3687. +
  3688. +/*
  3689. + *      Copyright (C) 2010-2012 Team XBMC and others
  3690. + *      http://www.xbmc.org
  3691. + *
  3692. + *  This Program is free software; you can redistribute it and/or modify
  3693. + *  it under the terms of the GNU General Public License as published by
  3694. + *  the Free Software Foundation; either version 2, or (at your option)
  3695. + *  any later version.
  3696. + *
  3697. + *  This Program is distributed in the hope that it will be useful,
  3698. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  3699. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3700. + *  GNU General Public License for more details.
  3701. + *
  3702. + *  You should have received a copy of the GNU General Public License
  3703. + *  along with XBMC; see the file COPYING.  If not, see
  3704. + *  <http://www.gnu.org/licenses/>.
  3705. + *
  3706. + */
  3707. +
  3708. +#if HAS_GLES == 2
  3709. +
  3710. +#include "system_gl.h"
  3711. +
  3712. +#include "xbmc/guilib/FrameBufferObject.h"
  3713. +#include "xbmc/guilib/Shader.h"
  3714. +#include "settings/VideoSettings.h"
  3715. +#include "RenderFlags.h"
  3716. +#include "RenderFormats.h"
  3717. +#include "guilib/GraphicContext.h"
  3718. +#include "BaseRenderer.h"
  3719. +#include "xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
  3720. +#include "xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h"
  3721. +
  3722. +extern "C" {
  3723. +#include <libcedarv.h>
  3724. +#include <drv_display_sun4i.h>
  3725. +#ifndef CEDARV_FRAME_HAS_PHY_ADDR
  3726. +#include <os_adapter.h>
  3727. +#endif
  3728. +}
  3729. +
  3730. +class CRenderCapture;
  3731. +
  3732. +class CBaseTexture;
  3733. +namespace Shaders { class BaseYUV2RGBShader; }
  3734. +namespace Shaders { class BaseVideoFilterShader; }
  3735. +
  3736. +typedef std::vector<int>     Features;
  3737. +
  3738. +#define NUM_BUFFERS 2
  3739. +
  3740. +
  3741. +#undef ALIGN
  3742. +#define ALIGN(value, alignment) (((value)+((alignment)-1))&~((alignment)-1))
  3743. +#define CLAMP(a, min, max) ((a) > (max) ? (max) : ( (a) < (min) ? (min) : a ))
  3744. +
  3745. +#define AUTOSOURCE -1
  3746. +
  3747. +#define IMAGE_FLAG_WRITING   0x01 /* image is in use after a call to GetImage, caller may be reading or writing */
  3748. +#define IMAGE_FLAG_READING   0x02 /* image is in use after a call to GetImage, caller is only reading */
  3749. +#define IMAGE_FLAG_DYNAMIC   0x04 /* image was allocated due to a call to GetImage */
  3750. +#define IMAGE_FLAG_RESERVED  0x08 /* image is reserved, must be asked for specifically used to preserve images */
  3751. +#define IMAGE_FLAG_READY     0x16 /* image is ready to be uploaded to texture memory */
  3752. +#define IMAGE_FLAG_INUSE (IMAGE_FLAG_WRITING | IMAGE_FLAG_READING | IMAGE_FLAG_RESERVED)
  3753. +
  3754. +struct DRAWRECT
  3755. +{
  3756. +  float left;
  3757. +  float top;
  3758. +  float right;
  3759. +  float bottom;
  3760. +};
  3761. +
  3762. +struct YUVRANGE
  3763. +{
  3764. +  int y_min, y_max;
  3765. +  int u_min, u_max;
  3766. +  int v_min, v_max;
  3767. +};
  3768. +
  3769. +struct YUVCOEF
  3770. +{
  3771. +  float r_up, r_vp;
  3772. +  float g_up, g_vp;
  3773. +  float b_up, b_vp;
  3774. +};
  3775. +
  3776. +enum RenderMethod
  3777. +{
  3778. +  RENDER_GLSL   = 0x001,
  3779. +  RENDER_A10BUF = 0x100,
  3780. +  RENDER_BYPASS = 0x400
  3781. +};
  3782. +
  3783. +enum RenderQuality
  3784. +{
  3785. +  RQ_LOW=1,
  3786. +  RQ_SINGLEPASS,
  3787. +  RQ_MULTIPASS,
  3788. +};
  3789. +
  3790. +#define PLANE_Y 0
  3791. +#define PLANE_U 1
  3792. +#define PLANE_V 2
  3793. +
  3794. +#define FIELD_FULL 0
  3795. +#define FIELD_TOP 1
  3796. +#define FIELD_BOT 2
  3797. +
  3798. +class CEvent;
  3799. +
  3800. +struct A10VLQueueItem;
  3801. +
  3802. +class CLinuxRendererA10 : public CBaseRenderer
  3803. +{
  3804. +public:
  3805. +  CLinuxRendererA10();
  3806. +  virtual ~CLinuxRendererA10();
  3807. +
  3808. +  virtual void Update(bool bPauseDrawing);
  3809. +  virtual void SetupScreenshot() {};
  3810. +
  3811. +  bool RenderCapture(CRenderCapture* capture);
  3812. +
  3813. +  // Player functions
  3814. +  virtual bool         Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_formatunsigned, unsigned int orientation);
  3815. +  virtual bool         IsConfigured() { return m_bConfigured; }
  3816. +  virtual int          GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
  3817. +  virtual void         ReleaseImage(int source, bool preserve = false);
  3818. +  virtual void         FlipPage(int source);
  3819. +  virtual unsigned int PreInit();
  3820. +  virtual void         UnInit();
  3821. +  virtual void         Reset(); /* resets renderer after seek for example */
  3822. +  virtual void         ReorderDrawPoints();
  3823. +
  3824. +  virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
  3825. +
  3826. +  // Feature support
  3827. +  virtual bool SupportsMultiPassRendering();
  3828. +  virtual bool Supports(ERENDERFEATURE feature);
  3829. +  virtual bool Supports(EDEINTERLACEMODE mode);
  3830. +  virtual bool Supports(EINTERLACEMETHOD method);
  3831. +  virtual bool Supports(ESCALINGMETHOD method);
  3832. +
  3833. +  virtual EINTERLACEMETHOD AutoInterlaceMethod();
  3834. +
  3835. +  virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
  3836. +
  3837. +  virtual void AddProcessor(struct A10VLQueueItem *pVidBuff);
  3838. +
  3839. +protected:
  3840. +  virtual void Render(DWORD flags, int index);
  3841. +
  3842. +  virtual void ManageTextures();
  3843. +  int  NextYV12Texture();
  3844. +  virtual bool ValidateRenderTarget();
  3845. +  virtual void LoadShaders(int field=FIELD_FULL);
  3846. +  void SetTextureFilter(GLenum method);
  3847. +  void UpdateVideoFilter();
  3848. +
  3849. +  // textures
  3850. +  void (CLinuxRendererA10::*m_textureUpload)(int index);
  3851. +  void (CLinuxRendererA10::*m_textureDelete)(int index);
  3852. +  bool (CLinuxRendererA10::*m_textureCreate)(int index);
  3853. +
  3854. +  void UploadYV12Texture(int index);
  3855. +  void DeleteYV12Texture(int index);
  3856. +  bool CreateYV12Texture(int index);
  3857. +
  3858. +  void UploadBYPASSTexture(int index);
  3859. +  void DeleteBYPASSTexture(int index);
  3860. +  bool CreateBYPASSTexture(int index);
  3861. +
  3862. +  void CalculateTextureSourceRects(int source, int num_planes);
  3863. +
  3864. +  // renderers
  3865. +  void RenderMultiPass(int index, int field);     // multi pass glsl renderer
  3866. +  void RenderSinglePass(int index, int field);    // single pass glsl renderer
  3867. +
  3868. +  CFrameBufferObject m_fbo;
  3869. +
  3870. +  int m_iYV12RenderBuffer;
  3871. +  int m_iLastRenderBuffer;
  3872. +
  3873. +  bool m_bConfigured;
  3874. +  bool m_bValidated;
  3875. +  std::vector<ERenderFormat> m_formats;
  3876. +  bool m_bImageReady;
  3877. +  ERenderFormat m_format;
  3878. +  GLenum m_textureTarget;
  3879. +  unsigned short m_renderMethod;
  3880. +  unsigned short m_oldRenderMethod;
  3881. +  RenderQuality m_renderQuality;
  3882. +  unsigned int m_flipindex; // just a counter to keep track of if a image has been uploaded
  3883. +  bool m_StrictBinding;
  3884. +
  3885. +  // Raw data used by renderer
  3886. +  int m_currentField;
  3887. +  int m_reloadShaders;
  3888. +
  3889. +  struct YUVPLANE
  3890. +  {
  3891. +    GLuint id;
  3892. +    CRect  rect;
  3893. +
  3894. +    float  width;
  3895. +    float  height;
  3896. +
  3897. +    unsigned texwidth;
  3898. +    unsigned texheight;
  3899. +
  3900. +    unsigned flipindex;
  3901. +  };
  3902. +
  3903. +  typedef YUVPLANE           YUVPLANES[MAX_PLANES];
  3904. +  typedef YUVPLANES          YUVFIELDS[MAX_FIELDS];
  3905. +
  3906. +  struct YUVBUFFER
  3907. +  {
  3908. +    YUVFIELDS fields;
  3909. +    YV12Image image;
  3910. +    unsigned  flipindex; /* used to decide if this has been uploaded */
  3911. +
  3912. +    A10VLQueueItem *a10buffer;
  3913. +  };
  3914. +
  3915. +  // YV12 decoder textures
  3916. +  // field index 0 is full image, 1 is odd scanlines, 2 is even scanlines
  3917. +  YUVBUFFER m_buffers[NUM_BUFFERS];
  3918. +
  3919. +  void LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
  3920. +                , unsigned width,  unsigned height
  3921. +                , int stride, void* data );
  3922. +
  3923. +  Shaders::BaseYUV2RGBShader     *m_pYUVShader;
  3924. +  Shaders::BaseVideoFilterShader *m_pVideoFilterShader;
  3925. +
  3926. +  ESCALINGMETHOD m_scalingMethod;
  3927. +  ESCALINGMETHOD m_scalingMethodGui;
  3928. +
  3929. +  Features m_renderFeatures;
  3930. +  Features m_deinterlaceMethods;
  3931. +  Features m_deinterlaceModes;
  3932. +  Features m_scalingMethods;
  3933. +
  3934. +  // clear colour for "black" bars
  3935. +  float m_clearColour;
  3936. +
  3937. +  CEvent* m_eventTexturesDone[NUM_BUFFERS];
  3938. +
  3939. +};
  3940. +
  3941. +
  3942. +inline int NP2( unsigned x )
  3943. +{
  3944. +    --x;
  3945. +    x |= x >> 1;
  3946. +    x |= x >> 2;
  3947. +    x |= x >> 4;
  3948. +    x |= x >> 8;
  3949. +    x |= x >> 16;
  3950. +    return ++x;
  3951. +}
  3952. +#endif
  3953. +
  3954. +/*
  3955. + * Video layer functions
  3956. + */
  3957. +
  3958. +#define DISPQS 24
  3959. +
  3960. +typedef void (*A10VLCALLBACK)(void *callbackpriv, void *pictpriv, cedarv_picture_t &pict); //cleanup function
  3961. +
  3962. +struct A10VLQueueItem
  3963. +{
  3964. +  int               decnr;
  3965. +  A10VLCALLBACK     callback;
  3966. +  void             *callbackpriv;
  3967. +  void             *pictpriv;
  3968. +  cedarv_picture_t  pict;
  3969. +};
  3970. +
  3971. +bool A10VLInit(int &width, int &height, double &refreshRate);
  3972. +
  3973. +void A10VLExit();
  3974. +
  3975. +void A10VLHide();
  3976. +
  3977. +void A10VLWaitVSYNC();
  3978. +
  3979. +A10VLQueueItem *A10VLPutQueue(A10VLCALLBACK     callback,
  3980. +                              void             *callbackpriv,
  3981. +                              void             *pictpriv,
  3982. +                              cedarv_picture_t &pict);
  3983. +
  3984. +void A10VLFreeQueue();
  3985. +
  3986. +void A10VLDisplayQueueItem(A10VLQueueItem *pItem, CRect &srcRect, CRect &dstRect);
  3987. +
  3988. +int  A10VLDisplayPicture(cedarv_picture_t &pict, int refnr, CRect &srcRect, CRect &dstRect);
  3989. +
  3990. +#endif
  3991. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/Makefile.in xbmc_rellla/xbmc/cores/VideoRenderers/Makefile.in
  3992. --- xbmc_orig/xbmc/cores/VideoRenderers/Makefile.in 2013-06-12 16:21:05.000000000 +0200
  3993. +++ xbmc_rellla/xbmc/cores/VideoRenderers/Makefile.in   2013-06-12 17:13:43.000000000 +0200
  3994. @@ -18,6 +18,8 @@
  3995.  SRCS += OverlayRendererGL.cpp
  3996.  endif
  3997.  
  3998. +SRCS += LinuxRendererA10.cpp
  3999. +
  4000.  LIB = VideoRenderer.a
  4001.  
  4002.  include @abs_top_srcdir@/Makefile.include
  4003. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h xbmc_rellla/xbmc/cores/VideoRenderers/RenderFormats.h
  4004. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h 2013-06-12 16:21:05.000000000 +0200
  4005. +++ xbmc_rellla/xbmc/cores/VideoRenderers/RenderFormats.h   2013-06-12 17:13:43.000000000 +0200
  4006. @@ -33,6 +33,7 @@
  4007.    RENDER_FMT_VAAPI,
  4008.    RENDER_FMT_OMXEGL,
  4009.    RENDER_FMT_CVBREF,
  4010. +  RENDER_FMT_A10BUF,
  4011.    RENDER_FMT_BYPASS,
  4012.  };
  4013.  
  4014. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc_rellla/xbmc/cores/VideoRenderers/RenderManager.cpp
  4015. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp   2013-06-12 17:20:26.000000000 +0200
  4016. +++ xbmc_rellla/xbmc/cores/VideoRenderers/RenderManager.cpp 2013-06-12 17:13:43.000000000 +0200
  4017. @@ -38,7 +38,11 @@
  4018.  #if defined(HAS_GL)
  4019.    #include "LinuxRendererGL.h"
  4020.  #elif HAS_GLES == 2
  4021. +#ifdef ALLWINNERA10
  4022. +  #include "LinuxRendererA10.h"
  4023. +#else
  4024.    #include "LinuxRendererGLES.h"
  4025. +#endif
  4026.  #elif defined(HAS_DX)
  4027.    #include "WinRenderer.h"
  4028.  #elif defined(HAS_SDL)
  4029. @@ -341,7 +345,11 @@
  4030.  #if defined(HAS_GL)
  4031.      m_pRenderer = new CLinuxRendererGL();
  4032.  #elif HAS_GLES == 2
  4033. +#ifdef ALLWINNERA10
  4034. +    m_pRenderer = new CLinuxRendererA10();
  4035. +#else
  4036.      m_pRenderer = new CLinuxRendererGLES();
  4037. +#endif
  4038.  #elif defined(HAS_DX)
  4039.      m_pRenderer = new CWinRenderer();
  4040.  #elif defined(HAS_SDL)
  4041. @@ -862,6 +870,10 @@
  4042.    else if(pic.format == RENDER_FMT_VAAPI)
  4043.      m_pRenderer->AddProcessor(*pic.vaapi);
  4044.  #endif
  4045. +#ifdef ALLWINNERA10
  4046. +  else if (pic.format == RENDER_FMT_A10BUF)
  4047. +    m_pRenderer->AddProcessor(pic.a10buffer);
  4048. +#endif
  4049.    m_pRenderer->ReleaseImage(index, false);
  4050.  
  4051.    return index;
  4052. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h xbmc_rellla/xbmc/cores/VideoRenderers/RenderManager.h
  4053. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h 2013-06-12 17:20:26.000000000 +0200
  4054. +++ xbmc_rellla/xbmc/cores/VideoRenderers/RenderManager.h   2013-06-12 17:13:43.000000000 +0200
  4055. @@ -43,6 +43,7 @@
  4056.  class CLinuxRenderer;
  4057.  class CLinuxRendererGL;
  4058.  class CLinuxRendererGLES;
  4059. +class CLinuxRendererA10;
  4060.  
  4061.  class CXBMCRenderManager
  4062.  {
  4063. @@ -115,7 +116,11 @@
  4064.  #ifdef HAS_GL
  4065.    CLinuxRendererGL    *m_pRenderer;
  4066.  #elif HAS_GLES == 2
  4067. +#ifdef ALLWINNERA10
  4068. +  CLinuxRendererA10   *m_pRenderer;
  4069. +#else
  4070.    CLinuxRendererGLES  *m_pRenderer;
  4071. +#endif
  4072.  #elif defined(HAS_DX)
  4073.    CWinRenderer        *m_pRenderer;
  4074.  #elif defined(HAS_SDL)
  4075. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/system.h xbmc_rellla/xbmc/system.h
  4076. --- xbmc_orig/xbmc/system.h 2013-06-12 17:20:27.000000000 +0200
  4077. +++ xbmc_rellla/xbmc/system.h   2013-06-12 17:13:44.000000000 +0200
  4078. @@ -185,6 +185,9 @@
  4079.  #ifdef HAVE_ALSA
  4080.  #define HAS_ALSA
  4081.  #endif
  4082. +#if !defined(HAVE_X11) && !defined(ANDROID)
  4083. +#define HAS_LINUX_EVENTS
  4084. +#endif
  4085.  #endif
  4086.  
  4087.  #ifdef HAVE_LIBSSH
  4088. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeA10.cpp xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeA10.cpp
  4089. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeA10.cpp   1970-01-01 01:00:00.000000000 +0100
  4090. +++ xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeA10.cpp 2013-06-12 17:13:46.000000000 +0200
  4091. @@ -0,0 +1,158 @@
  4092. +/*
  4093. + *      Copyright (C) 2011-2012 Team XBMC
  4094. + *      http://www.xbmc.org
  4095. + *
  4096. + *  This Program is free software; you can redistribute it and/or modify
  4097. + *  it under the terms of the GNU General Public License as published by
  4098. + *  the Free Software Foundation; either version 2, or (at your option)
  4099. + *  any later version.
  4100. + *
  4101. + *  This Program is distributed in the hope that it will be useful,
  4102. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  4103. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4104. + *  GNU General Public License for more details.
  4105. + *
  4106. + *  You should have received a copy of the GNU General Public License
  4107. + *  along with XBMC; see the file COPYING.  If not, see
  4108. + *  <http://www.gnu.org/licenses/>.
  4109. + *
  4110. + */
  4111. +#include "system.h"
  4112. +#include <EGL/egl.h>
  4113. +#include "EGLNativeTypeA10.h"
  4114. +#include "utils/log.h"
  4115. +#include "guilib/gui3d.h"
  4116. +
  4117. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4118. +#include "cores/VideoRenderers/LinuxRendererA10.h"
  4119. +static struct mali_native_window g_fbwin;
  4120. +static double       g_refreshRate;
  4121. +#endif
  4122. +
  4123. +CEGLNativeTypeA10::CEGLNativeTypeA10()
  4124. +{
  4125. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4126. +  int width, height;
  4127. +
  4128. +  A10VLInit(width, height, g_refreshRate);
  4129. +  g_fbwin.width  = width;
  4130. +  g_fbwin.height = height;
  4131. +#endif
  4132. +}
  4133. +
  4134. +CEGLNativeTypeA10::~CEGLNativeTypeA10()
  4135. +{
  4136. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4137. +  A10VLExit();
  4138. +#endif
  4139. +}
  4140. +
  4141. +bool CEGLNativeTypeA10::CheckCompatibility()
  4142. +{
  4143. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4144. +  return true;
  4145. +#endif
  4146. +  return false;
  4147. +}
  4148. +
  4149. +void CEGLNativeTypeA10::Initialize()
  4150. +{
  4151. +  return;
  4152. +}
  4153. +void CEGLNativeTypeA10::Destroy()
  4154. +{
  4155. +  return;
  4156. +}
  4157. +
  4158. +bool CEGLNativeTypeA10::CreateNativeDisplay()
  4159. +{
  4160. +  m_nativeDisplay = EGL_DEFAULT_DISPLAY;
  4161. +  return true;
  4162. +}
  4163. +
  4164. +bool CEGLNativeTypeA10::CreateNativeWindow()
  4165. +{
  4166. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4167. +  m_nativeWindow = &g_fbwin;
  4168. +  return true;
  4169. +#else
  4170. +  return false;
  4171. +#endif
  4172. +}  
  4173. +
  4174. +bool CEGLNativeTypeA10::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
  4175. +{
  4176. +  if (!nativeDisplay)
  4177. +    return false;
  4178. +  *nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
  4179. +  return true;
  4180. +}
  4181. +
  4182. +bool CEGLNativeTypeA10::GetNativeWindow(XBNativeWindowType **nativeWindow) const
  4183. +{
  4184. +  if (!nativeWindow)
  4185. +    return false;
  4186. +  *nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
  4187. +  return true;
  4188. +}
  4189. +
  4190. +bool CEGLNativeTypeA10::DestroyNativeDisplay()
  4191. +{
  4192. +  return true;
  4193. +}
  4194. +
  4195. +bool CEGLNativeTypeA10::DestroyNativeWindow()
  4196. +{
  4197. +  return true;
  4198. +}
  4199. +
  4200. +bool CEGLNativeTypeA10::GetNativeResolution(RESOLUTION_INFO *res) const
  4201. +{
  4202. +#if defined(ALLWINNERA10) && !defined(TARGET_ANDROID)
  4203. +  res->iWidth = g_fbwin.width;
  4204. +  res->iHeight= g_fbwin.height;
  4205. +
  4206. +  res->fRefreshRate = g_refreshRate;
  4207. +  res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN;
  4208. +  res->iScreen       = 0;
  4209. +  res->bFullScreen   = true;
  4210. +  res->iSubtitles    = (int)(0.965 * res->iHeight);
  4211. +  res->fPixelRatio   = 1.0f;
  4212. +  res->iScreenWidth  = res->iWidth;
  4213. +  res->iScreenHeight = res->iHeight;
  4214. +  res->strMode.Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate,
  4215. +  res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
  4216. +  CLog::Log(LOGNOTICE,"Current resolution: %s\n",res->strMode.c_str());
  4217. +  return true;
  4218. +#else
  4219. +  return false;
  4220. +#endif
  4221. +}
  4222. +
  4223. +bool CEGLNativeTypeA10::SetNativeResolution(const RESOLUTION_INFO &res)
  4224. +{
  4225. +  return false;
  4226. +}
  4227. +
  4228. +bool CEGLNativeTypeA10::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
  4229. +{
  4230. +  RESOLUTION_INFO res;
  4231. +  bool ret = false;
  4232. +  ret = GetNativeResolution(&res);
  4233. +  if (ret && res.iWidth > 1 && res.iHeight > 1)
  4234. +  {
  4235. +    resolutions.push_back(res);
  4236. +    return true;
  4237. +  }
  4238. +  return false;
  4239. +}
  4240. +
  4241. +bool CEGLNativeTypeA10::GetPreferredResolution(RESOLUTION_INFO *res) const
  4242. +{
  4243. +  return false;
  4244. +}
  4245. +
  4246. +bool CEGLNativeTypeA10::ShowWindow(bool show)
  4247. +{
  4248. +  return false;
  4249. +}
  4250. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeA10.h xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeA10.h
  4251. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeA10.h 1970-01-01 01:00:00.000000000 +0100
  4252. +++ xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeA10.h   2013-06-12 17:13:46.000000000 +0200
  4253. @@ -0,0 +1,49 @@
  4254. +#pragma once
  4255. +
  4256. +/*
  4257. + *      Copyright (C) 2011-2012 Team XBMC
  4258. + *      http://www.xbmc.org
  4259. + *
  4260. + *  This Program is free software; you can redistribute it and/or modify
  4261. + *  it under the terms of the GNU General Public License as published by
  4262. + *  the Free Software Foundation; either version 2, or (at your option)
  4263. + *  any later version.
  4264. + *
  4265. + *  This Program is distributed in the hope that it will be useful,
  4266. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  4267. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4268. + *  GNU General Public License for more details.
  4269. + *
  4270. + *  You should have received a copy of the GNU General Public License
  4271. + *  along with XBMC; see the file COPYING.  If not, see
  4272. + *  <http://www.gnu.org/licenses/>.
  4273. + *
  4274. + */
  4275. +
  4276. +#include "EGLNativeType.h"
  4277. +class CEGLNativeTypeA10 : public CEGLNativeType
  4278. +{
  4279. +public:
  4280. +  CEGLNativeTypeA10();
  4281. +  virtual ~CEGLNativeTypeA10();
  4282. +  virtual std::string GetNativeName() const { return "A10"; };
  4283. +  virtual bool  CheckCompatibility();
  4284. +  virtual void  Initialize();
  4285. +  virtual void  Destroy();
  4286. +  virtual int   GetQuirks() { return EGL_QUIRK_NEED_WINDOW_FOR_RES; };
  4287. +
  4288. +  virtual bool  CreateNativeDisplay();
  4289. +  virtual bool  CreateNativeWindow();
  4290. +  virtual bool  GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
  4291. +  virtual bool  GetNativeWindow(XBNativeWindowType **nativeWindow) const;
  4292. +
  4293. +  virtual bool  DestroyNativeWindow();
  4294. +  virtual bool  DestroyNativeDisplay();
  4295. +
  4296. +  virtual bool  GetNativeResolution(RESOLUTION_INFO *res) const;
  4297. +  virtual bool  SetNativeResolution(const RESOLUTION_INFO &res);
  4298. +  virtual bool  ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions);
  4299. +  virtual bool  GetPreferredResolution(RESOLUTION_INFO *res) const;
  4300. +
  4301. +  virtual bool  ShowWindow(bool show);
  4302. +};
  4303. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
  4304. --- xbmc_orig/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp   2013-06-12 16:21:09.000000000 +0200
  4305. +++ xbmc_rellla/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp 2013-06-12 17:13:46.000000000 +0200
  4306. @@ -24,13 +24,24 @@
  4307.  #include "guilib/gui3d.h"
  4308.  #if defined(TARGET_ANDROID)
  4309.  #include "android/activity/XBMCApp.h"
  4310. +#ifdef ALLWINNERA10
  4311. +#include "cores/VideoRenderers/LinuxRendererA10.h"
  4312. +#endif
  4313.  #endif
  4314.  CEGLNativeTypeAndroid::CEGLNativeTypeAndroid()
  4315.  {
  4316. +#if defined(ALLWINNERA10) && defined(TARGET_ANDROID)
  4317. +  int width, height;
  4318. +
  4319. +  A10VLInit(width, height);
  4320. +#endif
  4321.  }
  4322.  
  4323.  CEGLNativeTypeAndroid::~CEGLNativeTypeAndroid()
  4324.  {
  4325. +#if defined(ALLWINNERA10) && defined(TARGET_ANDROID)
  4326. +  A10VLExit();
  4327. +#endif
  4328.  }
  4329.  
  4330.  bool CEGLNativeTypeAndroid::CheckCompatibility()
  4331. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/EGLWrapper.cpp xbmc_rellla/xbmc/windowing/egl/EGLWrapper.cpp
  4332. --- xbmc_orig/xbmc/windowing/egl/EGLWrapper.cpp 2013-06-12 17:20:27.000000000 +0200
  4333. +++ xbmc_rellla/xbmc/windowing/egl/EGLWrapper.cpp   2013-06-12 17:13:46.000000000 +0200
  4334. @@ -22,7 +22,10 @@
  4335.  
  4336.  #ifdef HAS_EGL
  4337.  
  4338. +#include "system_gl.h"
  4339. +
  4340.  #include "utils/log.h"
  4341. +#include "EGLNativeTypeA10.h"
  4342.  #include "EGLNativeTypeAndroid.h"
  4343.  #include "EGLNativeTypeAmlogic.h"
  4344.  #include "EGLNativeTypeRaspberryPI.h"
  4345. @@ -81,6 +84,7 @@
  4346.    // that we know will work
  4347.    if ((nativeGuess = CreateEGLNativeType<CEGLNativeTypeAndroid>(implementation)) ||
  4348.        (nativeGuess = CreateEGLNativeType<CEGLNativeTypeAmlogic>(implementation)) ||
  4349. +      (nativeGuess = CreateEGLNativeType<CEGLNativeTypeA10>(implementation)) ||
  4350.        (nativeGuess = CreateEGLNativeType<CEGLNativeTypeRaspberryPI>(implementation)))
  4351.    {
  4352.      m_nativeTypes = nativeGuess;
  4353. @@ -291,6 +295,20 @@
  4354.    EGLBoolean status;
  4355.    status = eglMakeCurrent(display, surface, surface, context);
  4356.    CheckError();
  4357. +
  4358. +  // For EGL backend, it needs to clear all the back buffers of the window
  4359. +  // surface before drawing anything, otherwise the image will be blinking
  4360. +  // heavily.  The default eglWindowSurface has 3 gdl surfaces as the back
  4361. +  // buffer, that's why glClear should be called 3 times.
  4362. +  eglSwapInterval(display, 0);
  4363. +  glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
  4364. +  glClear (GL_COLOR_BUFFER_BIT);
  4365. +  eglSwapBuffers(display, surface);
  4366. +  glClear (GL_COLOR_BUFFER_BIT);
  4367. +  eglSwapBuffers(display, surface);
  4368. +  glClear (GL_COLOR_BUFFER_BIT);
  4369. +  eglSwapBuffers(display, surface);
  4370. +
  4371.    return status;
  4372.  }
  4373.  
  4374. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/windowing/egl/Makefile xbmc_rellla/xbmc/windowing/egl/Makefile
  4375. --- xbmc_orig/xbmc/windowing/egl/Makefile   2013-06-12 16:21:09.000000000 +0200
  4376. +++ xbmc_rellla/xbmc/windowing/egl/Makefile 2013-06-12 17:13:46.000000000 +0200
  4377. @@ -1,6 +1,7 @@
  4378.  INCLUDES=-I.
  4379.  
  4380.  SRCS = WinSystemEGL.cpp
  4381. +SRCS+= EGLNativeTypeA10.cpp
  4382.  SRCS+= EGLNativeTypeAmlogic.cpp
  4383.  SRCS+= EGLNativeTypeAndroid.cpp
  4384.  SRCS+= EGLNativeTypeRaspberryPI.cpp
RAW Paste Data