SHARE
TWEET

Untitled

a guest Jun 18th, 2013 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/Application.cpp xbmc_vidonme/xbmc/Application.cpp
  2. --- xbmc_orig/xbmc/Application.cpp      2013-06-12 16:46:43.000000000 +0200
  3. +++ xbmc_vidonme/xbmc/Application.cpp   2013-06-12 16:40:34.000000000 +0200
  4. @@ -5080,7 +5080,9 @@
  5.      m_pPlayer->DoAudioWork();
  6.  
  7.    // do any processing that isn't needed on each run
  8. +
  9.    if( m_slowTimer.GetElapsedMilliseconds() > 500 )
  10. +
  11.    {
  12.      m_slowTimer.Reset();
  13.      ProcessSlow();
  14. @@ -5613,6 +5615,17 @@
  15.    return false;
  16.  }
  17.  
  18. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  19. +void CApplication::OnA10Created()
  20. +{
  21. +       if( !m_pPlayer )
  22. +               return;
  23. +
  24. +       //need switch to fullscreen
  25. +       SwitchToFullScreen();
  26. +       m_pPlayer->OnA10Created();
  27. +}
  28. +#endif
  29.  void CApplication::Minimize()
  30.  {
  31.    g_Windowing.Minimize();
  32. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/Application.h xbmc_vidonme/xbmc/Application.h
  33. --- xbmc_orig/xbmc/Application.h        2013-06-12 16:46:43.000000000 +0200
  34. +++ xbmc_vidonme/xbmc/Application.h     2013-06-12 16:40:34.000000000 +0200
  35. @@ -360,6 +360,9 @@
  36.  
  37.    bool SwitchToFullScreen();
  38.  
  39. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  40. +  void OnA10Created();
  41. +#endif
  42.    CSplash* GetSplash() { return m_splash; }
  43.    void SetRenderGUI(bool renderGUI);
  44.  protected:
  45. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/a10/DllLibcedarv.h xbmc_vidonme/xbmc/cores/a10/DllLibcedarv.h
  46. --- xbmc_orig/xbmc/cores/a10/DllLibcedarv.h     1970-01-01 01:00:00.000000000 +0100
  47. +++ xbmc_vidonme/xbmc/cores/a10/DllLibcedarv.h  2013-06-12 16:40:35.000000000 +0200
  48. @@ -0,0 +1,60 @@
  49. +#pragma once
  50. +/*
  51. + *      Copyright (C) 2012 Team XBMC
  52. + *      http://www.xbmc.org
  53. + *
  54. + *  This Program is free software; you can redistribute it and/or modify
  55. + *  it under the terms of the GNU General Public License as published by
  56. + *  the Free Software Foundation; either version 2, or (at your option)
  57. + *  any later version.
  58. + *
  59. + *  This Program is distributed in the hope that it will be useful,
  60. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  61. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  62. + *  GNU General Public License for more details.
  63. + *
  64. + *  You should have received a copy of the GNU General Public License
  65. + *  along with XBMC; see the file COPYING.  If not, see
  66. + *  <http://www.gnu.org/licenses/>.
  67. + *
  68. + */
  69. +#ifndef __DLLLIBCEDARVH__
  70. +#define __DLLLIBCEDARVH__
  71. +
  72. +#include "system.h"
  73. +
  74. +#include "DynamicDll.h"
  75. +
  76. +
  77. +class DllLibA10decoderInterface
  78. +{
  79. +public:
  80. +  virtual ~DllLibA10decoderInterface() {};
  81. +
  82. +  virtual cedarv_decoder_t* libcedarv_init(int *ret)=0;
  83. +  virtual int libcedarv_exit(cedarv_decoder_t *p)=0;
  84. +  virtual int mem_get_phy_addr(int addr)=0;
  85. +  virtual void* mem_palloc(unsigned int size, unsigned int align)=0;
  86. +  virtual void mem_pfree(void* p)=0;
  87. +};
  88. +
  89. +class DllLibA10decoder : public DllDynamic, DllLibA10decoderInterface
  90. +{
  91. +  DECLARE_DLL_WRAPPER(DllLibA10decoder, "libbdv.so")
  92. +
  93. +  DEFINE_METHOD1(cedarv_decoder_t *,            libcedarv_init, (int *p1))
  94. +  DEFINE_METHOD1(int,            libcedarv_exit, (cedarv_decoder_t *p1))
  95. +  DEFINE_METHOD1(int,            mem_get_phy_addr, (int p1))
  96. +  DEFINE_METHOD2(void*,          mem_palloc, (unsigned int p1, unsigned int p2))
  97. +  DEFINE_METHOD1(void,          mem_pfree, (void *p1))
  98. +
  99. +  BEGIN_METHOD_RESOLVE()
  100. +    RESOLVE_METHOD(libcedarv_init)
  101. +    RESOLVE_METHOD(libcedarv_exit)
  102. +    RESOLVE_METHOD(mem_get_phy_addr)
  103. +    RESOLVE_METHOD(mem_palloc)
  104. +    RESOLVE_METHOD(mem_pfree)
  105. +  END_METHOD_RESOLVE()
  106. +};
  107. +
  108. +#endif //__DLLLIBCEDARV__
  109. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/a10/drv_display_sun4i.h xbmc_vidonme/xbmc/cores/a10/drv_display_sun4i.h
  110. --- xbmc_orig/xbmc/cores/a10/drv_display_sun4i.h        1970-01-01 01:00:00.000000000 +0100
  111. +++ xbmc_vidonme/xbmc/cores/a10/drv_display_sun4i.h     2013-06-12 16:40:35.000000000 +0200
  112. @@ -0,0 +1,794 @@
  113. +#ifndef __DRV_DISPLAY_H__
  114. +#define __DRV_DISPLAY_H__
  115. +
  116. +#define __bool signed char
  117. +
  118. +typedef struct {__u8  alpha;__u8 red;__u8 green; __u8 blue; }__disp_color_t;
  119. +typedef struct {__s32 x; __s32 y; __u32 width; __u32 height;}__disp_rect_t;
  120. +typedef struct {__u32 width;__u32 height;                   }__disp_rectsz_t;
  121. +typedef struct {__s32 x; __s32 y;                           }__disp_pos_t;
  122. +
  123. +
  124. +typedef enum
  125. +{
  126. +    DISP_FORMAT_1BPP        =0x0,
  127. +    DISP_FORMAT_2BPP        =0x1,
  128. +    DISP_FORMAT_4BPP        =0x2,
  129. +    DISP_FORMAT_8BPP        =0x3,
  130. +    DISP_FORMAT_RGB655      =0x4,
  131. +    DISP_FORMAT_RGB565      =0x5,
  132. +    DISP_FORMAT_RGB556      =0x6,
  133. +    DISP_FORMAT_ARGB1555    =0x7,
  134. +    DISP_FORMAT_RGBA5551    =0x8,
  135. +    DISP_FORMAT_ARGB888     =0x9,//alpha padding to 0xff
  136. +    DISP_FORMAT_ARGB8888    =0xa,
  137. +    DISP_FORMAT_RGB888      =0xb,
  138. +    DISP_FORMAT_ARGB4444    =0xc,
  139. +
  140. +    DISP_FORMAT_YUV444      =0x10,
  141. +    DISP_FORMAT_YUV422      =0x11,
  142. +    DISP_FORMAT_YUV420      =0x12,
  143. +    DISP_FORMAT_YUV411      =0x13,
  144. +    DISP_FORMAT_CSIRGB      =0x14,
  145. +}__disp_pixel_fmt_t;
  146. +
  147. +
  148. +typedef enum
  149. +{
  150. +    DISP_MOD_INTERLEAVED        =0x1,   //interleaved,1¸öµØÖ·
  151. +    DISP_MOD_NON_MB_PLANAR      =0x0,   //ÎÞºê¿éƽÃæģʽ,3¸öµØÖ·,RGB/YUVÿ¸öchannel·Ö±ð´æ·Å
  152. +    DISP_MOD_NON_MB_UV_COMBINED =0x2,   //ÎÞºê¿éUV´ò°üģʽ,2¸öµØÖ·,YºÍUV·Ö±ð´æ·Å
  153. +    DISP_MOD_MB_PLANAR          =0x4,   //ºê¿éƽÃæģʽ,3¸öµØÖ·,RGB/YUVÿ¸öchannel·Ö±ð´æ·Å
  154. +    DISP_MOD_MB_UV_COMBINED     =0x6,   //ºê¿éUV´ò°üģʽ ,2¸öµØÖ·,YºÍUV·Ö±ð´æ·Å
  155. +}__disp_pixel_mod_t;
  156. +
  157. +typedef enum
  158. +{
  159. +//for interleave argb8888
  160. +    DISP_SEQ_ARGB   =0x0,//AÔÚ¸ßλ
  161. +    DISP_SEQ_BGRA   =0x2,
  162. +    
  163. +//for nterleaved yuv422
  164. +    DISP_SEQ_UYVY   =0x3,  
  165. +    DISP_SEQ_YUYV   =0x4,
  166. +    DISP_SEQ_VYUY   =0x5,
  167. +    DISP_SEQ_YVYU   =0x6,
  168. +    
  169. +//for interleaved yuv444
  170. +    DISP_SEQ_AYUV   =0x7,  
  171. +    DISP_SEQ_VUYA   =0x8,
  172. +    
  173. +//for uv_combined yuv420
  174. +    DISP_SEQ_UVUV   =0x9,  
  175. +    DISP_SEQ_VUVU   =0xa,
  176. +    
  177. +//for 16bpp rgb
  178. +    DISP_SEQ_P10    = 0xd,//p1ÔÚ¸ßλ
  179. +    DISP_SEQ_P01    = 0xe,//p0ÔÚ¸ßλ
  180. +    
  181. +//for planar format or 8bpp rgb
  182. +    DISP_SEQ_P3210  = 0xf,//p3ÔÚ¸ßλ
  183. +    DISP_SEQ_P0123  = 0x10,//p0ÔÚ¸ßλ
  184. +    
  185. +//for 4bpp rgb
  186. +    DISP_SEQ_P76543210  = 0x11,
  187. +    DISP_SEQ_P67452301  = 0x12,
  188. +    DISP_SEQ_P10325476  = 0x13,
  189. +    DISP_SEQ_P01234567  = 0x14,
  190. +    
  191. +//for 2bpp rgb
  192. +    DISP_SEQ_2BPP_BIG_BIG       = 0x15,//15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
  193. +    DISP_SEQ_2BPP_BIG_LITTER    = 0x16,//12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3
  194. +    DISP_SEQ_2BPP_LITTER_BIG    = 0x17,//3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12
  195. +    DISP_SEQ_2BPP_LITTER_LITTER = 0x18,//0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  196. +    
  197. +//for 1bpp rgb
  198. +    DISP_SEQ_1BPP_BIG_BIG       = 0x19,//31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
  199. +    DISP_SEQ_1BPP_BIG_LITTER    = 0x1a,//24,25,26,27,28,29,30,31,16,17,18,19,20,21,22,23,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7
  200. +    DISP_SEQ_1BPP_LITTER_BIG    = 0x1b,//7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24
  201. +    DISP_SEQ_1BPP_LITTER_LITTER = 0x1c,//0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
  202. +}__disp_pixel_seq_t;
  203. +
  204. +typedef enum
  205. +{
  206. +    DISP_3D_SRC_MODE_TB = 0x0,//top bottom
  207. +    DISP_3D_SRC_MODE_FP = 0x1,//frame packing,left and right picture in separate address
  208. +    DISP_3D_SRC_MODE_SSF = 0x2,//side by side full
  209. +    DISP_3D_SRC_MODE_SSH = 0x3,//side by side half
  210. +    DISP_3D_SRC_MODE_LI = 0x4,//line interleaved
  211. +}__disp_3d_src_mode_t;
  212. +
  213. +typedef enum
  214. +{
  215. +    DISP_3D_OUT_MODE_CI_1 = 0x5,//column interlaved 1
  216. +    DISP_3D_OUT_MODE_CI_2 = 0x6,//column interlaved 2
  217. +    DISP_3D_OUT_MODE_CI_3 = 0x7,//column interlaved 3
  218. +    DISP_3D_OUT_MODE_CI_4 = 0x8,//column interlaved 4
  219. +    DISP_3D_OUT_MODE_LIRGB = 0x9,//line interleaved rgb
  220. +
  221. +    DISP_3D_OUT_MODE_TB = 0x0,//top bottom
  222. +    DISP_3D_OUT_MODE_FP = 0x1,//frame packing
  223. +    DISP_3D_OUT_MODE_SSF = 0x2,//side by side full
  224. +    DISP_3D_OUT_MODE_SSH = 0x3,//side by side half
  225. +    DISP_3D_OUT_MODE_LI = 0x4,//line interleaved
  226. +    DISP_3D_OUT_MODE_FA = 0xa,//field alternative
  227. +}__disp_3d_out_mode_t;
  228. +
  229. +typedef enum
  230. +{
  231. +    DISP_BT601  = 0,
  232. +    DISP_BT709  = 1,
  233. +    DISP_YCC    = 2,
  234. +    DISP_VXYCC  = 3,
  235. +}__disp_cs_mode_t;
  236. +
  237. +typedef enum
  238. +{
  239. +    DISP_COLOR_RANGE_16_255 = 0,
  240. +    DISP_COLOR_RANGE_0_255 = 1,
  241. +    DISP_COLOR_RANGE_16_235 = 2,
  242. +}__disp_color_range_t;
  243. +
  244. +typedef enum
  245. +{
  246. +    DISP_OUTPUT_TYPE_NONE   = 0,
  247. +    DISP_OUTPUT_TYPE_LCD    = 1,
  248. +    DISP_OUTPUT_TYPE_TV     = 2,
  249. +    DISP_OUTPUT_TYPE_HDMI   = 4,
  250. +    DISP_OUTPUT_TYPE_VGA    = 8,
  251. +}__disp_output_type_t;
  252. +
  253. +typedef enum
  254. +{
  255. +    DISP_TV_NONE    = 0,
  256. +    DISP_TV_CVBS    = 1,
  257. +    DISP_TV_YPBPR   = 2,
  258. +    DISP_TV_SVIDEO  = 4,
  259. +}__disp_tv_output_t;
  260. +
  261. +typedef enum
  262. +{
  263. +    DISP_TV_MOD_480I                = 0,
  264. +    DISP_TV_MOD_576I                = 1,
  265. +    DISP_TV_MOD_480P                = 2,
  266. +    DISP_TV_MOD_576P                = 3,
  267. +    DISP_TV_MOD_720P_50HZ           = 4,
  268. +    DISP_TV_MOD_720P_60HZ           = 5,
  269. +    DISP_TV_MOD_1080I_50HZ          = 6,
  270. +    DISP_TV_MOD_1080I_60HZ          = 7,
  271. +    DISP_TV_MOD_1080P_24HZ          = 8,
  272. +    DISP_TV_MOD_1080P_50HZ          = 9,
  273. +    DISP_TV_MOD_1080P_60HZ          = 0xa,
  274. +    DISP_TV_MOD_1080P_24HZ_3D_FP    = 0x17,
  275. +    DISP_TV_MOD_720P_50HZ_3D_FP     = 0x18,
  276. +    DISP_TV_MOD_720P_60HZ_3D_FP     = 0x19,
  277. +    DISP_TV_MOD_1080P_25HZ          = 0x1a,
  278. +    DISP_TV_MOD_1080P_30HZ          = 0x1b,
  279. +    DISP_TV_MOD_PAL                 = 0xb,
  280. +    DISP_TV_MOD_PAL_SVIDEO          = 0xc,
  281. +    DISP_TV_MOD_NTSC                = 0xe,
  282. +    DISP_TV_MOD_NTSC_SVIDEO         = 0xf,
  283. +    DISP_TV_MOD_PAL_M               = 0x11,
  284. +    DISP_TV_MOD_PAL_M_SVIDEO        = 0x12,
  285. +    DISP_TV_MOD_PAL_NC              = 0x14,
  286. +    DISP_TV_MOD_PAL_NC_SVIDEO       = 0x15,
  287. +    DISP_TV_MODE_NUM               = 0x1c,
  288. +}__disp_tv_mode_t;
  289. +
  290. +typedef enum
  291. +{
  292. +    DISP_TV_DAC_SRC_COMPOSITE = 0,
  293. +    DISP_TV_DAC_SRC_LUMA = 1,
  294. +    DISP_TV_DAC_SRC_CHROMA = 2,
  295. +    DISP_TV_DAC_SRC_Y = 4,
  296. +    DISP_TV_DAC_SRC_PB = 5,
  297. +    DISP_TV_DAC_SRC_PR = 6,
  298. +    DISP_TV_DAC_SRC_NONE = 7,
  299. +}__disp_tv_dac_source;
  300. +
  301. +typedef enum
  302. +{
  303. +    DISP_VGA_H1680_V1050    = 0,
  304. +    DISP_VGA_H1440_V900     = 1,
  305. +    DISP_VGA_H1360_V768     = 2,
  306. +    DISP_VGA_H1280_V1024    = 3,
  307. +    DISP_VGA_H1024_V768     = 4,
  308. +    DISP_VGA_H800_V600      = 5,
  309. +    DISP_VGA_H640_V480      = 6,
  310. +    DISP_VGA_H1440_V900_RB  = 7,//not support yet
  311. +    DISP_VGA_H1680_V1050_RB = 8,//not support yet
  312. +    DISP_VGA_H1920_V1080_RB = 9,
  313. +    DISP_VGA_H1920_V1080    = 0xa,
  314. +    DISP_VGA_H1280_V720     = 0xb,
  315. +    DISP_VGA_MODE_NUM       = 0xc,
  316. +}__disp_vga_mode_t;
  317. +
  318. +
  319. +typedef enum
  320. +{
  321. +    DISP_LCDC_SRC_DE_CH1    = 0,
  322. +    DISP_LCDC_SRC_DE_CH2    = 1,
  323. +    DISP_LCDC_SRC_DMA       = 2,
  324. +    DISP_LCDC_SRC_WHITE     = 3,
  325. +    DISP_LCDC_SRC_BLACK     = 4,
  326. +    DISP_LCDC_SRC_BLUT      = 5,
  327. +}__disp_lcdc_src_t;
  328. +
  329. +typedef enum
  330. +{
  331. +    DISP_LCD_BRIGHT_LEVEL0  = 0,
  332. +    DISP_LCD_BRIGHT_LEVEL1  = 1,
  333. +    DISP_LCD_BRIGHT_LEVEL2  = 2,
  334. +    DISP_LCD_BRIGHT_LEVEL3  = 3,
  335. +    DISP_LCD_BRIGHT_LEVEL4  = 4,
  336. +    DISP_LCD_BRIGHT_LEVEL5  = 5,
  337. +    DISP_LCD_BRIGHT_LEVEL6  = 6,
  338. +    DISP_LCD_BRIGHT_LEVEL7  = 7,
  339. +    DISP_LCD_BRIGHT_LEVEL8  = 8,
  340. +    DISP_LCD_BRIGHT_LEVEL9  = 9,
  341. +    DISP_LCD_BRIGHT_LEVEL10 = 0xa,
  342. +    DISP_LCD_BRIGHT_LEVEL11 = 0xb,
  343. +    DISP_LCD_BRIGHT_LEVEL12 = 0xc,
  344. +    DISP_LCD_BRIGHT_LEVEL13 = 0xd,
  345. +    DISP_LCD_BRIGHT_LEVEL14 = 0xe,
  346. +    DISP_LCD_BRIGHT_LEVEL15 = 0xf,
  347. +}__disp_lcd_bright_t;
  348. +
  349. +typedef enum
  350. +{
  351. +    DISP_LAYER_WORK_MODE_NORMAL     = 0,    //normal work mode
  352. +    DISP_LAYER_WORK_MODE_PALETTE    = 1,    //palette work mode
  353. +    DISP_LAYER_WORK_MODE_INTER_BUF  = 2,    //internal frame buffer work mode
  354. +    DISP_LAYER_WORK_MODE_GAMMA      = 3,    //gamma correction work mode
  355. +    DISP_LAYER_WORK_MODE_SCALER     = 4,    //scaler work mode
  356. +}__disp_layer_work_mode_t;
  357. +
  358. +typedef enum
  359. +{
  360. +    DISP_VIDEO_NATUAL       = 0,
  361. +    DISP_VIDEO_SOFT         = 1,
  362. +    DISP_VIDEO_VERYSOFT     = 2,
  363. +    DISP_VIDEO_SHARP        = 3,
  364. +    DISP_VIDEO_VERYSHARP    = 4
  365. +}__disp_video_smooth_t;
  366. +
  367. +typedef enum
  368. +{
  369. +    DISP_HWC_MOD_H32_V32_8BPP = 0,
  370. +    DISP_HWC_MOD_H64_V64_2BPP = 1,
  371. +    DISP_HWC_MOD_H64_V32_4BPP = 2,
  372. +    DISP_HWC_MOD_H32_V64_4BPP = 3,
  373. +}__disp_hwc_mode_t;
  374. +
  375. +typedef enum
  376. +{
  377. +    DISP_EXIT_MODE_CLEAN_ALL    = 0,
  378. +    DISP_EXIT_MODE_CLEAN_PARTLY = 1,//only clean interrupt temply
  379. +}__disp_exit_mode_t;
  380. +
  381. +
  382. +typedef enum//only for debug!!!
  383. +{
  384. +    DISP_REG_SCALER0 = 0,
  385. +    DISP_REG_SCALER1 = 1,
  386. +    DISP_REG_IMAGE0 = 2,
  387. +    DISP_REG_IMAGE1 = 3,
  388. +    DISP_REG_LCDC0 = 4,
  389. +    DISP_REG_LCDC1 = 5,
  390. +    DISP_REG_TVEC0 = 6,
  391. +    DISP_REG_TVEC1 = 7,
  392. +    DISP_REG_CCMU = 8,
  393. +    DISP_REG_PIOC = 9,
  394. +    DISP_REG_PWM = 10,
  395. +}__disp_reg_index_t;
  396. +
  397. +
  398. +typedef struct
  399. +{
  400. +    __u32                   addr[3];    // frame bufferµÄÄÚÈݵØÖ·£¬¶ÔÓÚrgbÀàÐÍ£¬Ö»ÓÐaddr[0]ÓÐЧ
  401. +    __disp_rectsz_t         size;//µ¥Î»ÊÇpixel
  402. +    __disp_pixel_fmt_t      format;
  403. +    __disp_pixel_seq_t      seq;
  404. +    __disp_pixel_mod_t      mode;
  405. +    __bool                  br_swap;    // blue red color swap flag, FALSE:RGB; TRUE:BGR,only used in rgb format
  406. +    __disp_cs_mode_t        cs_mode;    //color space
  407. +    __bool                  b_trd_src; //if 3d source, used for scaler mode layer
  408. +    __disp_3d_src_mode_t    trd_mode; //source 3d mode, used for scaler mode layer
  409. +    __u32                   trd_right_addr[3];//used when in frame packing 3d mode
  410. +}__disp_fb_t;
  411. +
  412. +typedef struct
  413. +{
  414. +    __disp_layer_work_mode_t    mode;       //layer work mode
  415. +    __bool                      b_from_screen;
  416. +    __u8                        pipe;       //layer pipe,0/1,if in scaler mode, scaler0 must be pipe0, scaler1 must be pipe1
  417. +    __u8                        prio;       //layer priority,can get layer prio,but never set layer prio,´Óµ×ÖÁ¶¥,ÓÅÏȼ¶ÓɵÍÖÁ¸ß
  418. +    __bool                      alpha_en;   //layer global alpha enable
  419. +    __u16                       alpha_val;  //layer global alpha value
  420. +    __bool                      ck_enable;  //layer color key enable
  421. +    __disp_rect_t               src_win;    // framebuffer source window,only care x,y if is not scaler mode
  422. +    __disp_rect_t               scn_win;    // screen window
  423. +    __disp_fb_t                 fb;         //framebuffer
  424. +    __bool                      b_trd_out;  //if output 3d mode, used for scaler mode layer
  425. +    __disp_3d_out_mode_t        out_trd_mode; //output 3d mode, used for scaler mode layer
  426. +}__disp_layer_info_t;
  427. +
  428. +typedef struct
  429. +{
  430. +    __disp_color_t   ck_max;
  431. +    __disp_color_t   ck_min;
  432. +    __u32             red_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
  433. +    __u32             green_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
  434. +    __u32             blue_match_rule;//0/1:always match; 2:match if min<=color<=max; 3:match if color>max or color<min
  435. +}__disp_colorkey_t;
  436. +
  437. +typedef struct
  438. +{
  439. +    __s32   id;
  440. +    __u32   addr[3];
  441. +    __u32   addr_right[3];//used when in frame packing 3d mode
  442. +    __bool  interlace;
  443. +    __bool  top_field_first;
  444. +    __u32   frame_rate; // *FRAME_RATE_BASE(ÏÖÔÚ¶¨Îª1000)
  445. +    __u32   flag_addr;//dit maf flag address
  446. +    __u32   flag_stride;//dit maf flag line stride
  447. +    __bool  maf_valid;
  448. +    __bool  pre_frame_valid;
  449. +}__disp_video_fb_t;
  450. +
  451. +typedef struct
  452. +{
  453. +    __bool maf_enable;
  454. +    __bool pre_frame_enable;
  455. +}__disp_dit_info_t;
  456. +
  457. +typedef struct
  458. +{
  459. +    __disp_hwc_mode_t     pat_mode;
  460. +    __u32                 addr;
  461. +}__disp_hwc_pattern_t;
  462. +
  463. +typedef struct
  464. +{
  465. +    __disp_fb_t     input_fb;
  466. +    __disp_rect_t   source_regn;
  467. +    __disp_fb_t     output_fb;
  468. +    __disp_rect_t   out_regn;
  469. +}__disp_scaler_para_t;
  470. +
  471. +typedef struct
  472. +{
  473. +    __disp_fb_t       fb;
  474. +    __disp_rect_t   src_win;//source region,only care x,y because of not scaler
  475. +    __disp_rect_t   scn_win;// sceen region
  476. +}__disp_sprite_block_para_t;
  477. +
  478. +typedef struct
  479. +{
  480. +    __disp_rectsz_t screen_size;//used when the screen is not displaying on any output device(lcd/hdmi/vga/tv)
  481. +    __disp_fb_t     output_fb;
  482. +}__disp_capture_screen_para_t;
  483. +
  484. +typedef struct
  485. +{
  486. +    __s32 (*Hdmi_open)(void);
  487. +    __s32 (*Hdmi_close)(void);
  488. +    __s32 (*hdmi_set_mode)(__disp_tv_mode_t mode);
  489. +    __s32 (*hdmi_mode_support)(__disp_tv_mode_t mode);
  490. +    __s32 (*hdmi_get_HPD_status)(void);
  491. +    __s32 (*hdmi_set_pll)(__u32 pll, __u32 clk);
  492. +}__disp_hdmi_func;
  493. +
  494. +typedef struct
  495. +{
  496. +       __u32   lcd_x;
  497. +       __u32   lcd_y;
  498. +       __u32   lcd_dclk_freq;
  499. +       __u32   lcd_pwm_not_used;
  500. +       __u32   lcd_pwm_ch;
  501. +       __u32   lcd_pwm_freq;
  502. +       __u32   lcd_pwm_pol;
  503. +       __u32   lcd_srgb;
  504. +       __u32   lcd_swap;
  505. +
  506. +       __u32   lcd_if; //0:hv(sync+de); 1:8080; 2:ttl; 3:lvds
  507. +
  508. +       __u32   lcd_uf;
  509. +       __u32   lcd_vt;
  510. +       __u32   lcd_ht;
  511. +       __u32   lcd_vbp;
  512. +       __u32   lcd_hbp;
  513. +
  514. +       __u32   lcd_hv_if;
  515. +       __u32   lcd_hv_smode;
  516. +       __u32   lcd_hv_s888_if;
  517. +       __u32   lcd_hv_syuv_if;
  518. +       __u32   lcd_hv_vspw;
  519. +       __u32   lcd_hv_hspw;
  520. +       __u32   lcd_hv_lde_used;
  521. +       __u32   lcd_hv_lde_iovalue;
  522. +
  523. +       __u32   lcd_ttl_stvh;
  524. +       __u32   lcd_ttl_stvdl;
  525. +       __u32   lcd_ttl_stvdp;
  526. +       __u32   lcd_ttl_ckvt;
  527. +       __u32   lcd_ttl_ckvh;
  528. +       __u32   lcd_ttl_ckvd;
  529. +       __u32   lcd_ttl_oevt;
  530. +       __u32   lcd_ttl_oevh;
  531. +       __u32   lcd_ttl_oevd;
  532. +       __u32   lcd_ttl_sthh;
  533. +       __u32   lcd_ttl_sthd;
  534. +       __u32   lcd_ttl_oehh;
  535. +       __u32   lcd_ttl_oehd;
  536. +       __u32   lcd_ttl_revd;
  537. +       __u32   lcd_ttl_datarate;
  538. +       __u32   lcd_ttl_revsel;
  539. +       __u32   lcd_ttl_datainv_en;
  540. +       __u32   lcd_ttl_datainv_sel;
  541. +
  542. +       __u32   lcd_lvds_ch;        // 0: single channel; 1:dual channel
  543. +       __u32   lcd_lvds_mode;      // 0:NS mode; 1:JEIDA mode
  544. +       __u32   lcd_lvds_bitwidth;  // 0:24bit; 1:18bit
  545. +       __u32   lcd_lvds_io_cross;      // 0:normal; 1:pn cross
  546. +      
  547. +       __u32   lcd_cpu_if;//0:18bit; 1:16bit mode0; 2:16bit mode1; 3:16bit mode2; 4:16bit mode3; 5:9bit; 6:8bit 256K; 7:8bit 65K
  548. +       __u32   lcd_cpu_da;
  549. +       __u32   lcd_frm;
  550. +
  551. +       __u32   lcd_io_cfg0;
  552. +       __u32   lcd_io_cfg1;
  553. +       __u32   lcd_io_strength;
  554. +
  555. +       __u32   lcd_gamma_correction_en;
  556. +       __u32   lcd_gamma_tbl[256];
  557. +
  558. +       __u32   lcd_hv_srgb_seq0;
  559. +       __u32   lcd_hv_srgb_seq1;
  560. +       __u32   lcd_hv_syuv_seq;
  561. +       __u32   lcd_hv_syuv_fdly;
  562. +
  563. +       __u32   port_index;
  564. +       __u32   start_delay;//not need to config for user
  565. +       __u32   tcon_index; //not need to config for user
  566. +}__panel_para_t;
  567. +
  568. +typedef struct
  569. +{
  570. +       __u32   pixel_clk;//khz
  571. +       __u32   hor_pixels;
  572. +       __u32   ver_pixels;
  573. +       __u32   hor_total_time;
  574. +       __u32   hor_front_porch;
  575. +       __u32   hor_sync_time; 
  576. +       __u32   hor_back_porch;
  577. +       __u32   ver_total_time;
  578. +       __u32   ver_front_porch;
  579. +       __u32   ver_sync_time;
  580. +       __u32   ver_back_porch;
  581. +}__disp_tcon_timing_t;
  582. +
  583. +typedef struct
  584. +{
  585. +       __u32 base_lcdc0;
  586. +       __u32 base_lcdc1;
  587. +       __u32 base_pioc;
  588. +       __u32 base_ccmu;
  589. +       __u32 base_pwm;
  590. +}__reg_bases_t;
  591. +
  592. +typedef void (*LCD_FUNC) (__u32 sel);
  593. +typedef struct lcd_function
  594. +{
  595. +    LCD_FUNC func;
  596. +    __u32 delay;//ms
  597. +}__lcd_function_t;
  598. +
  599. +typedef struct lcd_flow
  600. +{
  601. +    __lcd_function_t func[5];
  602. +    __u32 func_num;
  603. +    __u32 cur_step;
  604. +}__lcd_flow_t;
  605. +
  606. +typedef struct
  607. +{
  608. +    void (*cfg_panel_info)(__panel_para_t * info);
  609. +    __s32 (*cfg_open_flow)(__u32 sel);
  610. +    __s32 (*cfg_close_flow)(__u32 sel);
  611. +    __s32 (*lcd_user_defined_func)(__u32 sel, __u32 para1, __u32 para2, __u32 para3);
  612. +}__lcd_panel_fun_t;
  613. +
  614. +typedef struct
  615. +{
  616. +    __bool enable;
  617. +    __u32 active_state;
  618. +    __u32 duty_ns;
  619. +    __u32 period_ns;
  620. +}__pwm_info_t;
  621. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  622. +
  623. +typedef enum
  624. +{
  625. +    FB_MODE_SCREEN0 = 0,
  626. +    FB_MODE_SCREEN1 = 1,
  627. +    FB_MODE_DUAL_SAME_SCREEN_TB = 2,//two screen, top buffer for screen0, bottom buffer for screen1
  628. +    FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS = 3,//two screen, they have same contents;
  629. +}__fb_mode_t;
  630. +
  631. +typedef struct
  632. +{
  633. +       __fb_mode_t                 fb_mode;
  634. +       __disp_layer_work_mode_t    mode;
  635. +       __u32                       buffer_num;
  636. +       __u32                       width;
  637. +       __u32                       height;
  638. +      
  639. +       __u32                       output_width;//used when scaler mode
  640. +       __u32                       output_height;//used when scaler mode
  641. +      
  642. +       __u32                       primary_screen_id;//used when FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS
  643. +       __u32                       aux_output_width;//used when FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS
  644. +       __u32                       aux_output_height;//used when FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS
  645. +
  646. +//maybe not used anymore
  647. +       __u32                       line_length;//in byte unit
  648. +       __u32                       smem_len;
  649. +       __u32                       ch1_offset;//use when PLANAR or UV_COMBINED mode
  650. +       __u32                       ch2_offset;//use when PLANAR mode
  651. +}__disp_fb_create_para_t;
  652. +
  653. +typedef enum
  654. +{
  655. +    DISP_INIT_MODE_SCREEN0 = 0,//fb0 for screen0
  656. +    DISP_INIT_MODE_SCREEN1 = 1,//fb0 for screen1
  657. +    DISP_INIT_MODE_TWO_DIFF_SCREEN = 2,//fb0 for screen0 and fb1 for screen1
  658. +    DISP_INIT_MODE_TWO_SAME_SCREEN = 3,//fb0(up buffer for screen0, down buffer for screen1)
  659. +    DISP_INIT_MODE_SCREEN0_PARTLY = 4,//fb0(fb size fix to 1920*1080,but the source window is variable according to the output)
  660. +}__disp_init_mode_t;
  661. +
  662. +
  663. +typedef struct
  664. +{
  665. +    __bool                  b_init;
  666. +    __disp_init_mode_t      disp_mode;
  667. +
  668. +    //for screen0 and screen1
  669. +    __disp_output_type_t    output_type[2];
  670. +    __disp_tv_mode_t        tv_mode[2];
  671. +    __disp_vga_mode_t       vga_mode[2];
  672. +
  673. +    //for fb0 and fb1
  674. +    __u32                   buffer_num[2];
  675. +    __bool                  scaler_mode[2];
  676. +    __disp_pixel_fmt_t      format[2];
  677. +    __disp_pixel_seq_t      seq[2];
  678. +    __bool                  br_swap[2];
  679. +}__disp_init_t;
  680. +
  681. +
  682. +typedef enum tag_DISP_CMD
  683. +{
  684. +//----disp global----
  685. +    DISP_CMD_RESERVE0 = 0x00,
  686. +    DISP_CMD_RESERVE1 = 0x01,
  687. +    DISP_CMD_SET_BKCOLOR = 0x3f,//fail when the value is 0x02 in linux,why???
  688. +    DISP_CMD_GET_BKCOLOR = 0x03,
  689. +    DISP_CMD_SET_COLORKEY = 0x04,
  690. +    DISP_CMD_GET_COLORKEY = 0x05,
  691. +    DISP_CMD_SET_PALETTE_TBL = 0x06,
  692. +    DISP_CMD_GET_PALETTE_TBL = 0x07,
  693. +    DISP_CMD_SCN_GET_WIDTH = 0x08,
  694. +    DISP_CMD_SCN_GET_HEIGHT = 0x09,
  695. +    DISP_CMD_GET_OUTPUT_TYPE = 0x0a,
  696. +    DISP_CMD_SET_EXIT_MODE = 0x0c,
  697. +    DISP_CMD_SET_GAMMA_TABLE = 0x0d,
  698. +    DISP_CMD_GAMMA_CORRECTION_ON = 0x0e,
  699. +    DISP_CMD_GAMMA_CORRECTION_OFF = 0x0f,
  700. +    DISP_CMD_START_CMD_CACHE =0x10,
  701. +    DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE = 0x11,
  702. +    DISP_CMD_SET_BRIGHT = 0x12,
  703. +    DISP_CMD_SET_CONTRAST = 0x13,
  704. +    DISP_CMD_SET_SATURATION = 0x14,
  705. +    DISP_CMD_GET_BRIGHT = 0x16,
  706. +    DISP_CMD_GET_CONTRAST = 0x17,
  707. +    DISP_CMD_GET_SATURATION = 0x18,
  708. +    DISP_CMD_ENHANCE_ON = 0x1a,
  709. +    DISP_CMD_ENHANCE_OFF = 0x1b,
  710. +    DISP_CMD_GET_ENHANCE_EN = 0x1c,
  711. +    DISP_CMD_CLK_ON = 0x1d,
  712. +    DISP_CMD_CLK_OFF = 0x1e,
  713. +    DISP_CMD_SET_SCREEN_SIZE = 0x1f,//when the screen is not used to display(lcd/tv/vga/hdmi) directly, maybe capture the screen and scaler to dram, or as a layer of another screen
  714. +    DISP_CMD_CAPTURE_SCREEN = 0x20,//caputre screen and scaler to dram
  715. +    DISP_CMD_DE_FLICKER_ON = 0x21,
  716. +    DISP_CMD_DE_FLICKER_OFF = 0x22,
  717. +    DISP_CMD_GET_DE_FLICKER_EN = 0x23,
  718. +    DISP_CMD_DRC_ON = 0x24,
  719. +    DISP_CMD_DRC_OFF = 0x25,
  720. +    DISP_CMD_GET_DRC_EN = 0x26,
  721. +    DISP_CMD_DE_FLICKER_SET_WINDOW = 0x27,
  722. +    DISP_CMD_DRC_SET_WINDOW = 0x28,
  723. +    DISP_CMD_SET_HUE = 0x29,
  724. +    DISP_CMD_GET_HUE = 0x2a,
  725. +
  726. +//----layer----
  727. +    DISP_CMD_LAYER_REQUEST = 0x40,
  728. +    DISP_CMD_LAYER_RELEASE = 0x41,
  729. +    DISP_CMD_LAYER_OPEN = 0x42,
  730. +    DISP_CMD_LAYER_CLOSE = 0x43,
  731. +    DISP_CMD_LAYER_SET_FB = 0x44,
  732. +    DISP_CMD_LAYER_GET_FB = 0x45,
  733. +    DISP_CMD_LAYER_SET_SRC_WINDOW = 0x46,
  734. +    DISP_CMD_LAYER_GET_SRC_WINDOW = 0x47,
  735. +    DISP_CMD_LAYER_SET_SCN_WINDOW = 0x48,
  736. +    DISP_CMD_LAYER_GET_SCN_WINDOW = 0x49,
  737. +    DISP_CMD_LAYER_SET_PARA = 0x4a,
  738. +    DISP_CMD_LAYER_GET_PARA = 0x4b,
  739. +    DISP_CMD_LAYER_ALPHA_ON = 0x4c,
  740. +    DISP_CMD_LAYER_ALPHA_OFF = 0x4d,
  741. +    DISP_CMD_LAYER_GET_ALPHA_EN = 0x4e,
  742. +    DISP_CMD_LAYER_SET_ALPHA_VALUE = 0x4f,
  743. +    DISP_CMD_LAYER_GET_ALPHA_VALUE = 0x50,
  744. +    DISP_CMD_LAYER_CK_ON = 0x51,
  745. +    DISP_CMD_LAYER_CK_OFF = 0x52,
  746. +    DISP_CMD_LAYER_GET_CK_EN = 0x53,
  747. +    DISP_CMD_LAYER_SET_PIPE = 0x54,
  748. +    DISP_CMD_LAYER_GET_PIPE = 0x55,
  749. +    DISP_CMD_LAYER_TOP = 0x56,
  750. +    DISP_CMD_LAYER_BOTTOM = 0x57,
  751. +    DISP_CMD_LAYER_GET_PRIO = 0x58,
  752. +    DISP_CMD_LAYER_SET_SMOOTH = 0x59,
  753. +    DISP_CMD_LAYER_GET_SMOOTH = 0x5a,
  754. +    DISP_CMD_LAYER_SET_BRIGHT = 0x5b,//ÁÁ¶È
  755. +    DISP_CMD_LAYER_SET_CONTRAST = 0x5c,//¶Ô±È¶È
  756. +    DISP_CMD_LAYER_SET_SATURATION = 0x5d,//±¥ºÍ¶È
  757. +    DISP_CMD_LAYER_SET_HUE = 0x5e,//É«µ÷,É«¶È
  758. +    DISP_CMD_LAYER_GET_BRIGHT = 0x5f,
  759. +    DISP_CMD_LAYER_GET_CONTRAST = 0x60,
  760. +    DISP_CMD_LAYER_GET_SATURATION = 0x61,
  761. +    DISP_CMD_LAYER_GET_HUE = 0x62,
  762. +    DISP_CMD_LAYER_ENHANCE_ON = 0x63,
  763. +    DISP_CMD_LAYER_ENHANCE_OFF = 0x64,
  764. +    DISP_CMD_LAYER_GET_ENHANCE_EN = 0x65,
  765. +    DISP_CMD_LAYER_VPP_ON = 0x67,
  766. +    DISP_CMD_LAYER_VPP_OFF = 0x68,
  767. +    DISP_CMD_LAYER_GET_VPP_EN = 0x69,
  768. +    DISP_CMD_LAYER_SET_LUMA_SHARP_LEVEL = 0x6a,
  769. +    DISP_CMD_LAYER_GET_LUMA_SHARP_LEVEL = 0x6b,
  770. +    DISP_CMD_LAYER_SET_CHROMA_SHARP_LEVEL = 0x6c,
  771. +    DISP_CMD_LAYER_GET_CHROMA_SHARP_LEVEL = 0x6d,
  772. +    DISP_CMD_LAYER_SET_WHITE_EXTEN_LEVEL = 0x6e,
  773. +    DISP_CMD_LAYER_GET_WHITE_EXTEN_LEVEL = 0x6f,
  774. +    DISP_CMD_LAYER_SET_BLACK_EXTEN_LEVEL = 0x70,
  775. +    DISP_CMD_LAYER_GET_BLACK_EXTEN_LEVEL = 0x71,
  776. +
  777. +//----scaler----
  778. +    DISP_CMD_SCALER_REQUEST = 0x80,
  779. +    DISP_CMD_SCALER_RELEASE = 0x81,
  780. +    DISP_CMD_SCALER_EXECUTE = 0x82,
  781. +    DISP_CMD_SCALER_EXECUTE_EX = 0x83,
  782. +
  783. +//----hwc----
  784. +    DISP_CMD_HWC_OPEN = 0xc0,
  785. +    DISP_CMD_HWC_CLOSE = 0xc1,
  786. +    DISP_CMD_HWC_SET_POS = 0xc2,
  787. +    DISP_CMD_HWC_GET_POS = 0xc3,
  788. +    DISP_CMD_HWC_SET_FB = 0xc4,
  789. +    DISP_CMD_HWC_SET_PALETTE_TABLE = 0xc5,
  790. +
  791. +//----video----
  792. +    DISP_CMD_VIDEO_START = 0x100,
  793. +    DISP_CMD_VIDEO_STOP = 0x101,
  794. +    DISP_CMD_VIDEO_SET_FB = 0x102,
  795. +    DISP_CMD_VIDEO_GET_FRAME_ID = 0x103,
  796. +    DISP_CMD_VIDEO_GET_DIT_INFO = 0x104,
  797. +
  798. +//----lcd----
  799. +    DISP_CMD_LCD_ON = 0x140,
  800. +    DISP_CMD_LCD_OFF = 0x141,
  801. +    DISP_CMD_LCD_SET_BRIGHTNESS = 0x142,
  802. +    DISP_CMD_LCD_GET_BRIGHTNESS = 0x143,
  803. +    DISP_CMD_LCD_CPUIF_XY_SWITCH = 0x146,
  804. +    DISP_CMD_LCD_CHECK_OPEN_FINISH = 0x14a,
  805. +    DISP_CMD_LCD_CHECK_CLOSE_FINISH = 0x14b,
  806. +    DISP_CMD_LCD_SET_SRC = 0x14c,
  807. +    DISP_CMD_LCD_USER_DEFINED_FUNC = 0x14d,
  808. +
  809. +//----tv----
  810. +    DISP_CMD_TV_ON = 0x180,
  811. +    DISP_CMD_TV_OFF = 0x181,
  812. +    DISP_CMD_TV_SET_MODE = 0x182,
  813. +    DISP_CMD_TV_GET_MODE = 0x183,
  814. +    DISP_CMD_TV_AUTOCHECK_ON = 0x184,
  815. +    DISP_CMD_TV_AUTOCHECK_OFF = 0x185,
  816. +    DISP_CMD_TV_GET_INTERFACE = 0x186,
  817. +    DISP_CMD_TV_SET_SRC = 0x187,
  818. +    DISP_CMD_TV_GET_DAC_STATUS = 0x188,
  819. +    DISP_CMD_TV_SET_DAC_SOURCE = 0x189,
  820. +    DISP_CMD_TV_GET_DAC_SOURCE = 0x18a,
  821. +
  822. +//----hdmi----
  823. +    DISP_CMD_HDMI_ON = 0x1c0,
  824. +    DISP_CMD_HDMI_OFF = 0x1c1,
  825. +    DISP_CMD_HDMI_SET_MODE = 0x1c2,
  826. +    DISP_CMD_HDMI_GET_MODE = 0x1c3,
  827. +    DISP_CMD_HDMI_SUPPORT_MODE = 0x1c4,
  828. +    DISP_CMD_HDMI_GET_HPD_STATUS = 0x1c5,
  829. +       DISP_CMD_HDMI_SET_SRC = 0x1c6,
  830. +
  831. +//----vga----
  832. +    DISP_CMD_VGA_ON = 0x200,
  833. +    DISP_CMD_VGA_OFF = 0x201,
  834. +    DISP_CMD_VGA_SET_MODE = 0x202,
  835. +    DISP_CMD_VGA_GET_MODE = 0x203,
  836. +       DISP_CMD_VGA_SET_SRC = 0x204,
  837. +
  838. +//----sprite----
  839. +    DISP_CMD_SPRITE_OPEN = 0x240,
  840. +    DISP_CMD_SPRITE_CLOSE = 0x241,
  841. +    DISP_CMD_SPRITE_SET_FORMAT = 0x242,
  842. +    DISP_CMD_SPRITE_GLOBAL_ALPHA_ENABLE = 0x243,
  843. +    DISP_CMD_SPRITE_GLOBAL_ALPHA_DISABLE = 0x244,
  844. +    DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_ENABLE = 0x252,
  845. +    DISP_CMD_SPRITE_SET_GLOBAL_ALPHA_VALUE = 0x245,
  846. +    DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_VALUE = 0x253,
  847. +    DISP_CMD_SPRITE_SET_ORDER = 0x246,
  848. +    DISP_CMD_SPRITE_GET_TOP_BLOCK = 0x250,
  849. +    DISP_CMD_SPRITE_GET_BOTTOM_BLOCK = 0x251,
  850. +    DISP_CMD_SPRITE_SET_PALETTE_TBL = 0x247,
  851. +    DISP_CMD_SPRITE_GET_BLOCK_NUM = 0x259,
  852. +    DISP_CMD_SPRITE_BLOCK_REQUEST = 0x248,
  853. +    DISP_CMD_SPRITE_BLOCK_RELEASE = 0x249,
  854. +    DISP_CMD_SPRITE_BLOCK_OPEN = 0x257,
  855. +    DISP_CMD_SPRITE_BLOCK_CLOSE = 0x258,
  856. +    DISP_CMD_SPRITE_BLOCK_SET_SOURCE_WINDOW = 0x25a,
  857. +    DISP_CMD_SPRITE_BLOCK_GET_SOURCE_WINDOW = 0x25b,
  858. +    DISP_CMD_SPRITE_BLOCK_SET_SCREEN_WINDOW = 0x24a,
  859. +    DISP_CMD_SPRITE_BLOCK_GET_SCREEN_WINDOW = 0x24c,
  860. +    DISP_CMD_SPRITE_BLOCK_SET_FB = 0x24b,
  861. +    DISP_CMD_SPRITE_BLOCK_GET_FB = 0x24d,
  862. +    DISP_CMD_SPRITE_BLOCK_SET_PARA = 0x25c,
  863. +    DISP_CMD_SPRITE_BLOCK_GET_PARA = 0x25d,
  864. +    DISP_CMD_SPRITE_BLOCK_SET_TOP = 0x24e,
  865. +    DISP_CMD_SPRITE_BLOCK_SET_BOTTOM = 0x24f,
  866. +    DISP_CMD_SPRITE_BLOCK_GET_PREV_BLOCK = 0x254,
  867. +    DISP_CMD_SPRITE_BLOCK_GET_NEXT_BLOCK = 0x255,
  868. +    DISP_CMD_SPRITE_BLOCK_GET_PRIO = 0x256,
  869. +
  870. +//----framebuffer----
  871. +       DISP_CMD_FB_REQUEST = 0x280,
  872. +       DISP_CMD_FB_RELEASE = 0x281,
  873. +       DISP_CMD_FB_GET_PARA = 0x282,
  874. +       DISP_CMD_GET_DISP_INIT_PARA = 0x283,
  875. +      
  876. +//---for Displayer Test --------      
  877. +       DISP_CMD_MEM_REQUEST = 0x2c0,
  878. +       DISP_CMD_MEM_RELASE = 0x2c1,
  879. +       DISP_CMD_MEM_GETADR = 0x2c2,
  880. +       DISP_CMD_MEM_SELIDX = 0x2c3,
  881. +      
  882. +       DISP_CMD_SUSPEND = 0x2d0,
  883. +       DISP_CMD_RESUME = 0x2d1,
  884. +
  885. +       DISP_CMD_PRINT_REG = 0x2e0,
  886. +
  887. +//---pwm --------     
  888. +    DISP_CMD_PWM_SET_PARA = 0x300,
  889. +    DISP_CMD_PWM_GET_PARA = 0x301,
  890. +}__disp_cmd_t;
  891. +
  892. +#define FBIOGET_LAYER_HDL_0 0x4700
  893. +#define FBIOGET_LAYER_HDL_1 0x4701
  894. +
  895. +#define FBIO_CLOSE 0x4710
  896. +#define FBIO_OPEN 0x4711
  897. +#define FBIO_ALPHA_ON 0x4712
  898. +#define FBIO_ALPHA_OFF 0x4713
  899. +#define FBIOPUT_ALPHA_VALUE 0x4714
  900. +
  901. +#define FBIO_DISPLAY_SCREEN0_ONLY 0x4720
  902. +#define FBIO_DISPLAY_SCREEN1_ONLY 0x4721
  903. +#define FBIO_DISPLAY_TWO_SAME_SCREEN_TB 0x4722
  904. +#define FBIO_DISPLAY_TWO_DIFF_SCREEN_SAME_CONTENTS 0x4723
  905. +
  906. +#endif
  907. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/a10/libcedarv.h xbmc_vidonme/xbmc/cores/a10/libcedarv.h
  908. --- xbmc_orig/xbmc/cores/a10/libcedarv.h        1970-01-01 01:00:00.000000000 +0100
  909. +++ xbmc_vidonme/xbmc/cores/a10/libcedarv.h     2013-06-12 16:40:35.000000000 +0200
  910. @@ -0,0 +1,348 @@
  911. +
  912. +#ifndef LIBCEDARV_H
  913. +#define LIBCEDARV_H
  914. +
  915. +#ifdef __cplusplus
  916. +extern "C" {
  917. +#endif
  918. +    
  919. +    #include "libve_typedef.h"
  920. +    
  921. +    //*         Display Time Window
  922. +    //* |<---window_width--->|<---window_width--->|
  923. +    //* |<--------------------------------------->|
  924. +    //*                      ^
  925. +    //*                  Frame PTS
  926. +    #define DISPLAY_TIME_WINDOW_WIDTH   15      //* when current time fall in one picture's display time window,  this picture
  927. +                                                //* can be show, otherwise it maybe too early or too late to show this picture.
  928. +                                  
  929. +    #define CEDARV_BVOP_DEC_LATE_THRESHOLD     60              //* decode B-VOP time late threshold, if the later than this value, the B-VOP
  930. +                                                               //* will be dropped without decoded.
  931. +    #define CEDARV_VOP_DEC_LATE_THRESHOLD      1000            //* decode vop too late threshold, if the time of vop decode is later than this
  932. +                                                               //* value, the no-key frames before next key frame will be dropped all.
  933. +    
  934. +    typedef enum CEDARV_STREAM_FORMAT
  935. +    {
  936. +        CEDARV_STREAM_FORMAT_UNKNOW,
  937. +        CEDARV_STREAM_FORMAT_MPEG2,
  938. +        CEDARV_STREAM_FORMAT_MPEG4,
  939. +        CEDARV_STREAM_FORMAT_REALVIDEO,
  940. +        CEDARV_STREAM_FORMAT_H264,
  941. +        CEDARV_STREAM_FORMAT_VC1,
  942. +        CEDARV_STREAM_FORMAT_AVS,
  943. +        CEDARV_STREAM_FORMAT_MJPEG,  
  944. +        CEDARV_STREAM_FORMAT_VP8,
  945. +        CEDARV_STREAM_FORMAT_NETWORK
  946. +    }cedarv_stream_format_e;
  947. +    
  948. +    typedef enum CEDARV_SUB_FORMAT
  949. +    {
  950. +        CEDARV_SUB_FORMAT_UNKNOW = 0,
  951. +        CEDARV_MPEG2_SUB_FORMAT_MPEG1,
  952. +        CEDARV_MPEG2_SUB_FORMAT_MPEG2,
  953. +        CEDARV_MPEG4_SUB_FORMAT_XVID,
  954. +        CEDARV_MPEG4_SUB_FORMAT_DIVX3,
  955. +        CEDARV_MPEG4_SUB_FORMAT_DIVX4,
  956. +        CEDARV_MPEG4_SUB_FORMAT_DIVX5,
  957. +        CEDARV_MPEG4_SUB_FORMAT_SORENSSON_H263,
  958. +        CEDARV_MPEG4_SUB_FORMAT_H263,
  959. +        CEDARV_MPEG4_SUB_FORMAT_RMG2,          //* H263 coded video stream muxed in '.rm' file.
  960. +        CEDARV_MPEG4_SUB_FORMAT_VP6,
  961. +        CEDARV_MPEG4_SUB_FORMAT_WMV1,
  962. +        CEDARV_MPEG4_SUB_FORMAT_WMV2,
  963. +        CEDARV_MPEG4_SUB_FORMAT_DIVX2,         //MSMPEG4V2
  964. +        CEDARV_MPEG4_SUB_FORMAT_DIVX1,         //MSMPEG4V1
  965. +    }cedarv_sub_format_e;
  966. +    
  967. +    typedef enum CEDARV_CONTAINER_FORMAT
  968. +    {
  969. +       CEDARV_CONTAINER_FORMAT_UNKNOW,
  970. +       CEDARV_CONTAINER_FORMAT_AVI,
  971. +       CEDARV_CONTAINER_FORMAT_ASF,
  972. +       CEDARV_CONTAINER_FORMAT_DAT,
  973. +       CEDARV_CONTAINER_FORMAT_FLV,
  974. +       CEDARV_CONTAINER_FORMAT_MKV,
  975. +       CEDARV_CONTAINER_FORMAT_MOV,
  976. +       CEDARV_CONTAINER_FORMAT_MPG,
  977. +       CEDARV_CONTAINER_FORMAT_PMP,
  978. +       CEDARV_CONTAINER_FORMAT_RM,
  979. +       CEDARV_CONTAINER_FORMAT_TS,
  980. +       CEDARV_CONTAINER_FORMAT_VOB,
  981. +       CEDARV_CONTAINER_FORMAT_WEBM,
  982. +       CEDARV_CONTAINER_FORMAT_OGM,
  983. +    }cedarv_container_format_e;
  984. +
  985. +       typedef enum CEDARV_3D_MODE
  986. +       {
  987. +               //* for 2D pictures.
  988. +               CEDARV_3D_MODE_NONE                             = 0,
  989. +
  990. +               //* for double stream video like MVC and MJPEG.
  991. +               CEDARV_3D_MODE_DOUBLE_STREAM,
  992. +
  993. +               //* for single stream video.
  994. +               CEDARV_3D_MODE_SIDE_BY_SIDE,
  995. +               CEDARV_3D_MODE_TOP_TO_BOTTOM,
  996. +               CEDARV_3D_MODE_LINE_INTERLEAVE,
  997. +               CEDARV_3D_MODE_COLUME_INTERLEAVE
  998. +
  999. +       }cedarv_3d_mode_e;
  1000. +
  1001. +       typedef enum CEDARV_ANAGLAGH_TRANSFORM_MODE
  1002. +       {
  1003. +               //* for transmission from 'size by size' or 'top to bottom' mode to 'anaglagh' modes.
  1004. +               //* these values are just for output, 3d mode in stream information structure should
  1005. +               //* not set to these values.
  1006. +               CEDARV_ANAGLAGH_RED_BLUE,
  1007. +               CEDARV_ANAGLAGH_RED_GREEN,
  1008. +               CEDARV_ANAGLAGH_RED_CYAN,
  1009. +               CEDARV_ANAGLAGH_COLOR,
  1010. +               CEDARV_ANAGLAGH_HALF_COLOR,
  1011. +               CEDARV_ANAGLAGH_OPTIMIZED,
  1012. +               CEDARV_ANAGLAGH_YELLOW_BLUE,
  1013. +               CEDARV_ANAGLAGH_NONE,
  1014. +       }cedarv_anaglath_trans_mode_e;
  1015. +
  1016. +    typedef struct CEDARV_STREAM_INFORMATION
  1017. +    {
  1018. +        cedarv_stream_format_e         format;
  1019. +        cedarv_sub_format_e            sub_format;
  1020. +        cedarv_container_format_e      container_format;
  1021. +        u32                            video_width;     //* video picture width, if unknown please set it to 0;
  1022. +        u32                            video_height;    //* video picture height, if unknown please set it to 0;
  1023. +        u32                            frame_rate;      //* frame rate, multiplied by 1000, ex. 29.970 frames per second then frame_rate = 29970;
  1024. +        u32                            frame_duration;  //* how many us one frame should be display;
  1025. +        u32                            aspect_ratio;    //* pixel width to pixel height ratio, multiplied by 1000;
  1026. +        u32                            init_data_len;   //* data length of the initial data for decoder;
  1027. +        u8*                            init_data;       //* some decoders may need initial data to start up;
  1028. +        u32                            is_pts_correct;  //* used for h.264 decoder current;
  1029. +
  1030. +        cedarv_3d_mode_e                       _3d_mode;
  1031. +    }cedarv_stream_info_t;
  1032. +    
  1033. +    
  1034. +    #define CEDARV_FLAG_PTS_VALID              0x2
  1035. +    #define CEDARV_FLAG_FIRST_PART             0x8
  1036. +    #define CEDARV_FLAG_LAST_PART              0x10
  1037. +       #define CEDARV_FLAG_MPEG4_EMPTY_FRAME   0x20
  1038. +       #define CEDARV_FLAG_DECODE_NO_DELAY     0x40000000
  1039. +    #define CEDARV_FLAG_DATA_INVALID           0x80000000
  1040. +    
  1041. +    typedef struct CEDARV_STREAM_DATA_INFORMATION
  1042. +    {
  1043. +        u32 flags;
  1044. +        u32 lengh;
  1045. +        u64 pts;
  1046. +        u32    type;
  1047. +    }cedarv_stream_data_info_t;
  1048. +    
  1049. +    
  1050. +    typedef enum CEDARV_PIXEL_FORMAT
  1051. +    {
  1052. +        CEDARV_PIXEL_FORMAT_1BPP       = 0x0,
  1053. +        CEDARV_PIXEL_FORMAT_2BPP       = 0x1,
  1054. +        CEDARV_PIXEL_FORMAT_4BPP       = 0x2,
  1055. +        CEDARV_PIXEL_FORMAT_8BPP       = 0x3,
  1056. +        CEDARV_PIXEL_FORMAT_RGB655     = 0x4,
  1057. +        CEDARV_PIXEL_FORMAT_RGB565     = 0x5,
  1058. +        CEDARV_PIXEL_FORMAT_RGB556     = 0x6,
  1059. +        CEDARV_PIXEL_FORMAT_ARGB1555   = 0x7,
  1060. +        CEDARV_PIXEL_FORMAT_RGBA5551   = 0x8,
  1061. +        CEDARV_PIXEL_FORMAT_RGB888     = 0x9,
  1062. +        CEDARV_PIXEL_FORMAT_ARGB8888   = 0xa,
  1063. +        CEDARV_PIXEL_FORMAT_YUV444     = 0xb,
  1064. +        CEDARV_PIXEL_FORMAT_YUV422     = 0xc,
  1065. +        CEDARV_PIXEL_FORMAT_YUV420     = 0xd,
  1066. +        CEDARV_PIXEL_FORMAT_YUV411     = 0xe,
  1067. +        CEDARV_PIXEL_FORMAT_CSIRGB     = 0xf,
  1068. +        CEDARV_PIXEL_FORMAT_AW_YUV420  = 0x10,
  1069. +        CEDARV_PIXEL_FORMAT_AW_YUV422  = 0x11,
  1070. +        CEDARV_PIXEL_FORMAT_AW_YUV411  = 0x12
  1071. +    }cedarv_pixel_format_e;
  1072. +    
  1073. +       #define CEDARV_PICT_PROP_NO_SYNC   0x1
  1074. +        
  1075. +    typedef struct CEDARV_PICTURE_INFORMATION
  1076. +    {
  1077. +        u32                     id;                     //* picture id assigned by outside, decoder do not use this field;
  1078. +                                
  1079. +               u32                                             width;                                  //* width of picture content;
  1080. +               u32                                             height;                                 //* height of picture content;
  1081. +        u32                     top_offset;                            //* display region top offset;
  1082. +        u32                     left_offset;                   //* display region left offset;
  1083. +        u32                     display_width;                 //* display region width;
  1084. +        u32                     display_height;                        //* display region height;
  1085. +        u32                     store_width;            //* stored picture width;
  1086. +        u32                     store_height;           //* stored picture height;
  1087. +
  1088. +        u8                      rotate_angle;           //* how this picture has been rotated, 0: no rotate, 1: 90 degree (clock wise), 2: 180, 3: 270, 4: horizon flip, 5: vertical flig;
  1089. +        u8                      horizontal_scale_ratio; //* what ratio this picture has been scaled down at horizon size, 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8;
  1090. +        u8                      vertical_scale_ratio;   //* what ratio this picture has been scaled down at vetical size, 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8;
  1091. +        u32                     frame_rate;             //* frame_rate, multiplied by 1000;
  1092. +        u32                     aspect_ratio;           //* pixel width to pixel height ratio, multiplied by 1000;
  1093. +        u32                     pict_prop;              //* picture property flags
  1094. +        u8                      is_progressive;         //* progressive or interlace picture;
  1095. +        u8                      top_field_first;        //* display top field first;
  1096. +        u8                      repeat_top_field;       //* if interlace picture, whether repeat the top field when display;
  1097. +        u8                      repeat_bottom_field;    //* if interlace picture, whether repeat the bottom field when display;
  1098. +        cedarv_pixel_format_e   pixel_format;
  1099. +        u64                     pts;                    //* presentation time stamp, in unit of milli-second;
  1100. +        u64                     pcr;                    //* program clock reference;
  1101. +
  1102. +        cedarv_3d_mode_e               _3d_mode;
  1103. +        cedarv_anaglath_trans_mode_e anaglath_transform_mode;
  1104. +
  1105. +        u32                            size_y;
  1106. +        u32                            size_u;
  1107. +        u32                            size_v;
  1108. +        u32                            size_alpha;
  1109. +        
  1110. +        u8*                     y;                      //* pixel data, it is interpreted based on pixel_format;
  1111. +        u8*                     u;                      //* pixel data, it is interpreted based on pixel_format;
  1112. +        u8*                     v;                      //* pixel data, it is interpreted based on pixel_format;
  1113. +        u8*                     alpha;                  //* pixel data, it is interpreted based on pixel_format;
  1114. +
  1115. +        u32                                            size_y2;
  1116. +        u32                                            size_u2;
  1117. +        u32                                            size_v2;
  1118. +        u32                                            size_alpha2;
  1119. +
  1120. +        u8 *                                   y2;
  1121. +        u8 *                                   u2;
  1122. +        u8 *                                   v2;
  1123. +        u8 *                                   alpha2;
  1124. +
  1125. +        u32                                            display_3d_mode;                //* this value has nothing to do with decoder, it is used for video render to
  1126. +                                                                                                       //* pass display mode to overlay module.
  1127. +        u32                     flag_addr;//dit maf flag address
  1128. +        u32                     flag_stride;//dit maf flag line stride
  1129. +        u8                      maf_valid;
  1130. +        u8                      pre_frame_valid;
  1131. +    }cedarv_picture_t;
  1132. +    
  1133. +    typedef enum CEDARV_RESULT
  1134. +    {
  1135. +        CEDARV_RESULT_OK                      = 0x0,      //* operation success;
  1136. +        CEDARV_RESULT_FRAME_DECODED           = 0x1,      //* decode operation decodes one frame;
  1137. +        CEDARV_RESULT_KEYFRAME_DECODED        = 0x3,      //* decode operation decodes one key frame;
  1138. +        CEDARV_RESULT_NO_FRAME_BUFFER         = 0x4,      //* fail when try to get an empty frame buffer;
  1139. +        CEDARV_RESULT_NO_BITSTREAM            = 0x5,      //* fail when try to get bitstream frame;
  1140. +        
  1141. +        CEDARV_RESULT_ERR_FAIL                = -1,       //* operation fail;
  1142. +        CEDARV_RESULT_ERR_INVALID_PARAM       = -2,       //* failure caused by invalid function parameter;
  1143. +        CEDARV_RESULT_ERR_INVALID_STREAM      = -3,       //* failure caused by invalid video stream data;
  1144. +        CEDARV_RESULT_ERR_NO_MEMORY           = -4,       //* failure caused by memory allocation fail;
  1145. +        CEDARV_RESULT_ERR_UNSUPPORTED         = -5,       //* failure caused by not supported stream content;
  1146. +    }cedarv_result_e;
  1147. +    
  1148. +    
  1149. +    typedef enum CEDARV_STATUS
  1150. +    {
  1151. +        CEDARV_STATUS_STOP,
  1152. +        CEDARV_STATUS_PAUSE,
  1153. +        CEDARV_STATUS_PLAY,
  1154. +        CEDARV_STATUS_FORWARD,
  1155. +        CEDARV_STATUS_BACKWARD,
  1156. +        CEDARV_STATUS_PREVIEW
  1157. +    }cedarv_status_e;
  1158. +    
  1159. +    typedef enum CEDARV_IO_COMMAND
  1160. +    {
  1161. +        CEDARV_COMMAND_PLAY,
  1162. +        CEDARV_COMMAND_PAUSE,
  1163. +        CEDARV_COMMAND_FORWARD,
  1164. +        CEDARV_COMMAND_BACKWARD,
  1165. +        CEDARV_COMMAND_STOP,
  1166. +        CEDARV_COMMAND_JUMP,
  1167. +        CEDARV_COMMAND_ROTATE,
  1168. +        CEDARV_COMMAND_SET_TOTALMEMSIZE,
  1169. +
  1170. +        CEDARV_COMMAND_DROP_B_FRAME,
  1171. +        CEDARV_COMMAND_DISABLE_3D,
  1172. +        CEDARV_COMMAN_SET_SYS_TIME,
  1173. +        //* for preview application.
  1174. +        CEDARV_COMMAND_PREVIEW_MODE,           //* aux = 0, pbuffer = NULL,
  1175. +                                                                               //* return value always CEDARV_RESULT_OK, should be called before the 'open' fuction.
  1176. +        //reset vdeclib
  1177. +        CEDARV_COMMAND_RESET,
  1178. +
  1179. +        //* set max output size for scale mode.
  1180. +        CEDARV_COMMAND_SET_MAX_OUTPUT_HEIGHT,
  1181. +        CEDARV_COMMAND_SET_MAX_OUTPUT_WIDTH,
  1182. +
  1183. +        CEDARV_COMMAND_GET_STREAM_INFO,        //* param = cedarv_stream_info_t*
  1184. +
  1185. +        //* for mpeg2 tag play.
  1186. +        CEDARV_COMMAND_GET_SEQUENCE_INFO,
  1187. +        CEDARV_COMMAND_SET_SEQUENCE_INFO,
  1188. +
  1189. +        //* for transforming 3d 'size by size' or 'top to bottom' pictures to 'anaglagh' pictures.
  1190. +        CEDARV_COMMAND_SET_STREAM_3D_MODE,                     //* reset the 3d mode of input stream.
  1191. +        CEDARV_COMMAND_SET_ANAGLATH_TRANS_MODE,                //* select an output 3d mode, this will be used only to decide which analagh transform mode is used.
  1192. +        CEDARV_COMMAND_OPEN_ANAGLATH_TRANSFROM,        //* open ve anaglath transformation
  1193. +        CEDARV_COMMAND_CLOSE_ANAGLATH_TRANSFROM,       //* close ve anaglath transformation
  1194. +        CEDARV_COMMAND_GET_CHIP_VERSION,
  1195. +
  1196. +        CEDARV_COMMAND_FLUSH,
  1197. +        CEDARV_COMMAND_CLOSE_MAF,
  1198. +        CEDARV_COMMAND_SET_DEMUX_TYPE
  1199. +    }cedarv_io_cmd_e;
  1200. +    
  1201. +    
  1202. +    typedef struct CEDARV_QUALITY
  1203. +    {
  1204. +        u32 vbv_buffer_usage;       //* persentage of the VBV buffer;
  1205. +        u32 frame_num_in_vbv;       //* bitstream frame number in vbv;
  1206. +    }cedarv_quality_t;
  1207. +    
  1208. +    typedef enum CDX_DECODE_VIDEO_STREAM_TYPE
  1209. +       {
  1210. +       CDX_VIDEO_STREAM_MAJOR = 0,
  1211. +       CDX_VIDEO_STREAM_MINOR,
  1212. +       CDX_VIDEO_STREAM_NONE,
  1213. +    }CDX_VIDEO_STREAM_TYPE;
  1214. +      
  1215. +    typedef struct CEDARV_DECODER   cedarv_decoder_t;
  1216. +    struct CEDARV_DECODER
  1217. +    {
  1218. +        CDX_VIDEO_STREAM_TYPE video_stream_type;
  1219. +
  1220. +        s32 (*open)(cedarv_decoder_t* p);
  1221. +        s32 (*close)(cedarv_decoder_t* p);
  1222. +        s32 (*decode)(cedarv_decoder_t* p);
  1223. +        s32 (*ioctrl)(cedarv_decoder_t* p, u32 cmd, u32 param);
  1224. +        s32 (*request_write)(cedarv_decoder_t*p, u32 require_size, u8** buf0, u32* size0, u8** buf1, u32* size1);
  1225. +        s32 (*update_data)(cedarv_decoder_t* p, cedarv_stream_data_info_t* data_info);
  1226. +        
  1227. +        s32 (*display_request)(cedarv_decoder_t* p, cedarv_picture_t* picture);
  1228. +        s32 (*display_release)(cedarv_decoder_t* p, u32 frame_index);
  1229. +        s32 (*picture_ready)(cedarv_decoder_t* p);
  1230. +        s32 (*display_dump_picture)(cedarv_decoder_t* p, cedarv_picture_t* picture);
  1231. +        s32 (*set_vstream_info)(cedarv_decoder_t* p, cedarv_stream_info_t* info);
  1232. +        
  1233. +        s32 (*query_quality)(cedarv_decoder_t* p, cedarv_quality_t* vq);
  1234. +        
  1235. +        void (*release_frame_buffer_sem)(void* cookie);
  1236. +        void (*free_vbs_buffer_sem)(void* cookie);
  1237. +        
  1238. +        void *cedarx_cookie;
  1239. +    };
  1240. +
  1241. +    cedarv_decoder_t* libcedarv_init(s32 *ret);
  1242. +    s32 libcedarv_exit(cedarv_decoder_t* p);
  1243. +
  1244. +    void libcedarv_free_vbs_buffer_sem(void* vdecoder);
  1245. +
  1246. +    #define LIBVE_DEBUG
  1247. +    #ifdef LIBVE_DEBUG
  1248. +    #define __msg(msg...) {printf("%s:%d   ", __FILE__, __LINE__); printf(msg); printf("\n");}
  1249. +    #else
  1250. +    #define __msg(msg...) ((void)0)
  1251. +    #endif
  1252. +
  1253. +#ifdef __cplusplus
  1254. +}
  1255. +#endif
  1256. +
  1257. +
  1258. +#endif
  1259. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/a10/libve_typedef.h xbmc_vidonme/xbmc/cores/a10/libve_typedef.h
  1260. --- xbmc_orig/xbmc/cores/a10/libve_typedef.h    1970-01-01 01:00:00.000000000 +0100
  1261. +++ xbmc_vidonme/xbmc/cores/a10/libve_typedef.h 2013-06-12 16:40:35.000000000 +0200
  1262. @@ -0,0 +1,265 @@
  1263. +
  1264. +#ifndef LIBVE_TYPEDEF_H
  1265. +#define LIBVE_TYPEDEF_H
  1266. +
  1267. +#ifdef __cplusplus
  1268. +extern "C" {
  1269. +#endif
  1270. +
  1271. +    //*******************************************************//
  1272. +    //*************** Basic type definition. ****************//
  1273. +    //*******************************************************//
  1274. +    #ifndef u8
  1275. +        typedef unsigned char u8;    
  1276. +    #endif
  1277. +    #ifndef u16
  1278. +        typedef unsigned short u16;    
  1279. +    #endif
  1280. +    #ifndef u32
  1281. +        typedef unsigned int u32;    
  1282. +    #endif
  1283. +    #ifndef u64
  1284. +        #ifdef COMPILER_ARMCC
  1285. +               typedef unsigned __int64 u64;
  1286. +        #else
  1287. +               typedef unsigned long long u64;
  1288. +        #endif
  1289. +    #endif
  1290. +    #ifndef s8
  1291. +        typedef signed char s8;    
  1292. +    #endif
  1293. +    #ifndef s16
  1294. +        typedef signed short s16;    
  1295. +    #endif
  1296. +    #ifndef s32
  1297. +        typedef signed int s32;    
  1298. +    #endif
  1299. +    #ifndef s64
  1300. +        #ifdef COMPILER_ARMCC
  1301. +               typedef signed __int64 s64;
  1302. +        #else
  1303. +               typedef signed long long s64;
  1304. +        #endif
  1305. +    #endif
  1306. +    #ifndef Handle
  1307. +        typedef void* Handle;
  1308. +    #endif
  1309. +    #ifndef NULL
  1310. +        #define NULL ((void*)0)
  1311. +    #endif
  1312. +    
  1313. +    //*******************************************************//
  1314. +    //************ Define Stream Coding Formats. ************//
  1315. +    //*******************************************************//
  1316. +    typedef enum STREAM_FORMAT
  1317. +    {
  1318. +        STREAM_FORMAT_UNKNOW,
  1319. +        STREAM_FORMAT_MPEG2,
  1320. +        STREAM_FORMAT_MPEG4,
  1321. +        STREAM_FORMAT_REALVIDEO,
  1322. +        STREAM_FORMAT_H264,
  1323. +        STREAM_FORMAT_VC1,
  1324. +        STREAM_FORMAT_AVS,
  1325. +        STREAM_FORMAT_MJPEG,
  1326. +        STREAM_FORMAT_VP8
  1327. +    }stream_format_e;
  1328. +    
  1329. +    typedef enum STREAM_SUB_FORMAT
  1330. +    {
  1331. +        STREAM_SUB_FORMAT_UNKNOW = 0,
  1332. +        MPEG2_SUB_FORMAT_MPEG1,
  1333. +        MPEG2_SUB_FORMAT_MPEG2,
  1334. +        MPEG4_SUB_FORMAT_XVID,
  1335. +        MPEG4_SUB_FORMAT_DIVX3,
  1336. +        MPEG4_SUB_FORMAT_DIVX4,
  1337. +        MPEG4_SUB_FORMAT_DIVX5,
  1338. +        MPEG4_SUB_FORMAT_SORENSSON_H263,
  1339. +        MPEG4_SUB_FORMAT_H263,
  1340. +        MPEG4_SUB_FORMAT_RMG2,         //* H263 coded video stream muxed in '.rm' file.
  1341. +        MPEG4_SUB_FORMAT_VP6,
  1342. +        MPEG4_SUB_FORMAT_WMV1,
  1343. +        MPEG4_SUB_FORMAT_WMV2,
  1344. +        MPEG4_SUB_FORMAT_DIVX2,                //MSMPEGV2
  1345. +        MPEG4_SUB_FORMAT_DIVX1         //MSMPEGV1
  1346. +    }stream_sub_format_e;
  1347. +    
  1348. +    typedef enum CONTAINER_FORMAT
  1349. +    {
  1350. +       CONTAINER_FORMAT_UNKNOW,
  1351. +       CONTAINER_FORMAT_AVI,
  1352. +       CONTAINER_FORMAT_ASF,
  1353. +       CONTAINER_FORMAT_DAT,
  1354. +       CONTAINER_FORMAT_FLV,
  1355. +       CONTAINER_FORMAT_MKV,
  1356. +       CONTAINER_FORMAT_MOV,
  1357. +       CONTAINER_FORMAT_MPG,
  1358. +       CONTAINER_FORMAT_PMP,
  1359. +       CONTAINER_FORMAT_RM,
  1360. +       CONTAINER_FORMAT_TS,
  1361. +       CONTAINER_FORMAT_VOB,
  1362. +       CONTAINER_FORMAT_WEBM,
  1363. +       CONTAINER_FORMAT_OGM,
  1364. +    }container_format_e;
  1365. +
  1366. +    //*******************************************************//
  1367. +    //**************** Define Pixel Formats. ****************//
  1368. +    //*******************************************************//
  1369. +    typedef enum PIXEL_FORMAT
  1370. +    {
  1371. +        PIXEL_FORMAT_1BPP       = 0x0,
  1372. +        PIXEL_FORMAT_2BPP       = 0x1,
  1373. +        PIXEL_FORMAT_4BPP       = 0x2,
  1374. +        PIXEL_FORMAT_8BPP       = 0x3,
  1375. +        PIXEL_FORMAT_RGB655     = 0x4,
  1376. +        PIXEL_FORMAT_RGB565     = 0x5,
  1377. +        PIXEL_FORMAT_RGB556     = 0x6,
  1378. +        PIXEL_FORMAT_ARGB1555   = 0x7,
  1379. +        PIXEL_FORMAT_RGBA5551   = 0x8,
  1380. +        PIXEL_FORMAT_RGB888     = 0x9,
  1381. +        PIXEL_FORMAT_ARGB8888   = 0xa,
  1382. +        PIXEL_FORMAT_YUV444     = 0xb,
  1383. +        PIXEL_FORMAT_YUV422     = 0xc,
  1384. +        PIXEL_FORMAT_YUV420     = 0xd,
  1385. +        PIXEL_FORMAT_YUV411     = 0xe,
  1386. +        PIXEL_FORMAT_CSIRGB     = 0xf,
  1387. +
  1388. +        PIXEL_FORMAT_AW_YUV420  = 0x10,
  1389. +        PIXEL_FORMAT_AW_YUV422 = 0x11,
  1390. +        PIXEL_FORMAT_AW_YUV411  = 0x12
  1391. +    }pixel_format_e;
  1392. +    
  1393. +
  1394. +       //*******************************************************//
  1395. +       //************** Define DRAM Memory Type. ***************//
  1396. +       //*******************************************************//
  1397. +       typedef enum MEMORY_TYPE
  1398. +       {
  1399. +               MEMTYPE_DDR1_16BITS,
  1400. +               MEMTYPE_DDR1_32BITS,
  1401. +               MEMTYPE_DDR2_16BITS,
  1402. +               MEMTYPE_DDR2_32BITS,
  1403. +               MEMTYPE_DDR3_16BITS,
  1404. +               MEMTYPE_DDR3_32BITS
  1405. +       }memtype_e;
  1406. +
  1407. +       typedef enum LIBVE_3D_MODE
  1408. +       {
  1409. +               //* for 2D pictures.
  1410. +               _3D_MODE_NONE                           = 0,
  1411. +
  1412. +               //* for double stream video like MVC and MJPEG.
  1413. +               _3D_MODE_DOUBLE_STREAM,
  1414. +
  1415. +               //* for single stream video.
  1416. +               _3D_MODE_SIDE_BY_SIDE,
  1417. +               _3D_MODE_TOP_TO_BOTTOM,
  1418. +               _3D_MODE_LINE_INTERLEAVE,
  1419. +               _3D_MODE_COLUME_INTERLEAVE,
  1420. +
  1421. +               _3D_MODE_MAX
  1422. +
  1423. +       }_3d_mode_e;
  1424. +
  1425. +       typedef enum LIBVE_ANAGLAGH_TRANSFORM_MODE
  1426. +       {
  1427. +               ANAGLAGH_RED_BLUE               = 0,
  1428. +               ANAGLAGH_RED_GREEN,
  1429. +               ANAGLAGH_RED_CYAN,
  1430. +               ANAGLAGH_COLOR,
  1431. +               ANAGLAGH_HALF_COLOR,
  1432. +               ANAGLAGH_OPTIMIZED,
  1433. +               ANAGLAGH_YELLOW_BLUE,
  1434. +               ANAGLAGH_NONE,
  1435. +       }anaglath_trans_mode_e;
  1436. +
  1437. +#define CEDARV_PICT_PROP_NO_SYNC    0x1
  1438. +#define CEDARV_FLAG_DECODE_NO_DELAY 0x40000000
  1439. +
  1440. +       //*******************************************************//
  1441. +       //************ Define Video Frame Structure. ************//
  1442. +       //*******************************************************//
  1443. +       typedef struct VIDEO_PICTURE
  1444. +       {
  1445. +               u32                             id;                     //* picture id assigned by outside, decoder do not use this field;
  1446. +
  1447. +               u32                                             width;                                  //* width of picture content;
  1448. +               u32                                             height;                                 //* height of picture content;
  1449. +        u32                            store_width;            //* stored picture width;
  1450. +        u32                            store_height;           //* stored picture height;
  1451. +        u32                            top_offset;                             //* display region top offset;
  1452. +        u32                            left_offset;                    //* display region left offset;
  1453. +        u32                            display_width;                  //* display region width;
  1454. +        u32                            display_height;                 //* display region height;
  1455. +        
  1456. +        u8                             rotate_angle;           //* how this picture has been rotated, 0: no rotate, 1: 90 degree (clock wise), 2: 180, 3: 270, 4: horizon flip, 5: vertical flig;
  1457. +        u8                             horizontal_scale_ratio; //* what ratio this picture has been scaled down at horizon size, 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8;
  1458. +        u8                             vertical_scale_ratio;   //* what ratio this picture has been scaled down at vetical size, 0: 1/1, 1: 1/2, 2: 1/4, 3: 1/8;
  1459. +        
  1460. +        u32                            frame_rate;             //* frame_rate, multiplied by 1000;
  1461. +        u32                            aspect_ratio;           //* pixel width to pixel height ratio, multiplied by 1000;
  1462. +        u32                     pict_prop;              //* picture property flags
  1463. +        u8                             is_progressive;         //* progressive or interlace picture;
  1464. +        u8                             top_field_first;        //* display top field first;
  1465. +        u8                             repeat_top_field;       //* if interlace picture, whether repeat the top field when display;
  1466. +        u8                             repeat_bottom_field;    //* if interlace picture, whether repeat the bottom field when display;
  1467. +        pixel_format_e                 pixel_format;
  1468. +        u64                            pts;                    //* presentation time stamp, in unit of milli-second;
  1469. +        u64                            pcr;                    //* program clock reference;
  1470. +
  1471. +               _3d_mode_e                      _3d_mode;
  1472. +               anaglath_trans_mode_e   anaglath_transform_mode;
  1473. +               u32                             size_y;
  1474. +               u32                             size_u;
  1475. +               u32                             size_v;
  1476. +               u32                             size_alpha;
  1477. +
  1478. +               u8*                             y;                      //* pixel data, it is interpreted based on pixel_format;
  1479. +               u8*                             u;                      //* pixel data, it is interpreted based on pixel_format;
  1480. +               u8*                             v;                      //* pixel data, it is interpreted based on pixel_format;
  1481. +               u8*                             alpha;                  //* pixel data, it is interpreted based on pixel_format;
  1482. +
  1483. +               u32                             size_y2;
  1484. +               u32                             size_u2;
  1485. +               u32                             size_v2;
  1486. +               u32                             size_alpha2;
  1487. +
  1488. +               u8*                             y2;                      //* pixel data, it is interpreted based on pixel_format;
  1489. +               u8*                             u2;                      //* pixel data, it is interpreted based on pixel_format;
  1490. +               u8*                             v2;                      //* pixel data, it is interpreted based on pixel_format;
  1491. +               u8*                             alpha2;                  //* pixel data, it is interpreted based on pixel_format;
  1492. +               u32                                     flag_addr;//dit maf flag address
  1493. +           u32                                         flag_stride;//dit maf flag line stride
  1494. +           u8                                          maf_valid;
  1495. +           u8                                          pre_frame_valid;
  1496. +       }vpicture_t;
  1497. +
  1498. +       //*******************************************************//
  1499. +       //********** Define Bitstream Frame Structure. **********//
  1500. +       //*******************************************************//
  1501. +
  1502. +       //* define stream type for double stream video, such as MVC.
  1503. +       //* in that case two video streams is send into libve.
  1504. +       typedef enum CEDARV_STREAM_TYPE
  1505. +       {
  1506. +               CEDARV_STREAM_TYPE_MAJOR,
  1507. +               CEDARV_STREAM_TYPE_MINOR,
  1508. +       }cedarv_stream_type_e;
  1509. +
  1510. +       typedef struct VIDEO_STREAM_DATA
  1511. +       {
  1512. +               u8*                                     data;           //* stream data start address;
  1513. +               u32                                     length;         //* stream length in unit of byte;
  1514. +               u64                                     pts;            //* presentation time stamp, in unit of milli-second;
  1515. +               u64                                     pcr;            //* program clock reference;
  1516. +               u8                                      valid;          //* whether this stream frame is valid;
  1517. +               u32                                             id;                             //* stream frame identification.
  1518. +               cedarv_stream_type_e    stream_type;    //* major or minor stream in MVC.
  1519. +               u32                     pict_prop;
  1520. +       }vstream_data_t;
  1521. +
  1522. +#ifdef __cplusplus
  1523. +}
  1524. +#endif
  1525. +
  1526. +#endif
  1527. +
  1528. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
  1529. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp  2013-06-12 16:46:43.000000000 +0200
  1530. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp       2013-06-12 16:40:35.000000000 +0200
  1531. @@ -25,6 +25,10 @@
  1532.  #include "utils/fastmemcpy.h"
  1533.  #include "DllSwScale.h"
  1534.  
  1535. +#if defined(__VIDONME_A10CODEC__)
  1536. +#include "cores/a10/libcedarv.h"
  1537. +#endif
  1538. +
  1539.  // allocate a new picture (PIX_FMT_YUV420P)
  1540.  DVDVideoPicture* CDVDCodecUtils::AllocatePicture(int iWidth, int iHeight)
  1541.  {
  1542. @@ -159,6 +163,26 @@
  1543.    return true;
  1544.  }
  1545.  
  1546. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  1547. +
  1548. +bool CDVDCodecUtils::CopyPicture(YV12Image* pImage, const cedarv_picture_t *pSrc)
  1549. +{
  1550. +  BYTE *d = pImage->plane[0];
  1551. +  int y_len = pSrc->size_y;
  1552. +  int u_len = pSrc->size_u;
  1553. +  int v_len = pSrc->size_v;
  1554. +
  1555. +  int w = pImage->width * pImage->bpp;
  1556. +  int h = pImage->height;
  1557. +
  1558. +  CLog::Log(LOGDEBUG, "CopyPicture:w:%d -- h:%d - y:%d - u:%d- v:%d\n", w, h, y_len, u_len,v_len);
  1559. +  fast_memcpy (d, pSrc->y, u_len);
  1560. +
  1561. +  return true;
  1562. +}
  1563. +
  1564. +#endif
  1565. +
  1566.  DVDVideoPicture* CDVDCodecUtils::ConvertToNV12Picture(DVDVideoPicture *pSrc)
  1567.  {
  1568.    // Clone a YV12 picture to new NV12 picture.
  1569. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
  1570. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h    2013-06-12 16:21:05.000000000 +0200
  1571. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h 2013-06-12 16:40:35.000000000 +0200
  1572. @@ -25,6 +25,10 @@
  1573.  
  1574.  struct YV12Image;
  1575.  
  1576. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  1577. +#include "cores/a10/libcedarv.h"
  1578. +#endif
  1579. +
  1580.  class CDVDCodecUtils
  1581.  {
  1582.  public:
  1583. @@ -32,6 +36,9 @@
  1584.    static void FreePicture(DVDVideoPicture* pPicture);
  1585.    static bool CopyPicture(DVDVideoPicture* pDst, DVDVideoPicture* pSrc);
  1586.    static bool CopyPicture(YV12Image* pDst, DVDVideoPicture *pSrc);
  1587. + #if defined(__DVDFAB_FUNC_A10CODEC__)
  1588. +  static bool CopyPicture(YV12Image* pDst, const cedarv_picture_t *pSrc);
  1589. +#endif
  1590.    
  1591.    static DVDVideoPicture* ConvertToNV12Picture(DVDVideoPicture *pSrc);
  1592.    static DVDVideoPicture* ConvertToYUV422PackedPicture(DVDVideoPicture *pSrc, ERenderFormat format);
  1593. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
  1594. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp        2013-06-12 16:46:43.000000000 +0200
  1595. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp     2013-06-12 16:40:35.000000000 +0200
  1596. @@ -30,6 +30,12 @@
  1597.  #if defined(HAVE_VIDEOTOOLBOXDECODER)
  1598.  #include "Video/DVDVideoCodecVideoToolBox.h"
  1599.  #endif
  1600. +
  1601. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  1602. +#include "Video/DVDVideoCodecA10.h"
  1603. +#include "Application.h"
  1604. +#endif
  1605. +
  1606.  #include "Video/DVDVideoCodecFFmpeg.h"
  1607.  #include "Video/DVDVideoCodecOpenMax.h"
  1608.  #include "Video/DVDVideoCodecLibMpeg2.h"
  1609. @@ -170,6 +176,9 @@
  1610.    hwSupport += "VAAPI:no ";
  1611.  #endif
  1612.  
  1613. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  1614. +  hwSupport += "A10:yes";
  1615. +#endif
  1616.    CLog::Log(LOGDEBUG, "CDVDFactoryCodec: compiled in hardware support: %s", hwSupport.c_str());
  1617.  
  1618.    // dvd's have weird still-frames in it, which is not fully supported in ffmpeg
  1619. @@ -177,6 +186,30 @@
  1620.    {
  1621.      if( (pCodec = OpenCodec(new CDVDVideoCodecLibMpeg2(), hint, options)) ) return pCodec;
  1622.    }
  1623. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  1624. +
  1625. +  if(!hint.software)
  1626. +  {
  1627. +         //all will using a10 codec
  1628. +         /*
  1629. +         if (hint.codec == CODEC_ID_H264 ||
  1630. +                 hint.codec == CODEC_ID_MPEG2VIDEO ||
  1631. +                 hint.codec == CODEC_ID_VC1 ||
  1632. +                 hint.codec == CODEC_ID_MPEG4)
  1633. +          */
  1634. +         {
  1635. +                 if(pCodec = OpenCodec(new CDVDVideoCodecA10(), hint, options))
  1636. +                 {
  1637. +                         CLog::Log(LOGDEBUG, "CDVDFactoryCodec, create a10 codec. info application");
  1638. +
  1639. +                         //TODO, this function need check it
  1640. +                         g_application.OnA10Created();
  1641. +                         return pCodec;
  1642. +                 }
  1643. +         }
  1644. +  }
  1645. +
  1646. +#endif
  1647.  #if defined(HAVE_LIBVDADECODER)
  1648.    if (!hint.software && g_guiSettings.GetBool("videoplayer.usevda"))
  1649.    {
  1650. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp
  1651. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp 1970-01-01 01:00:00.000000000 +0100
  1652. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.cpp      2013-06-12 16:40:35.000000000 +0200
  1653. @@ -0,0 +1,736 @@
  1654. +#include "DVDVideoCodecA10.h"
  1655. +#include "DVDClock.h"
  1656. +#include "utils/log.h"
  1657. +#include "threads/Atomics.h"
  1658. +
  1659. +#include <sys/ioctl.h>
  1660. +#include <math.h>
  1661. +#include "transform_color_format.h"
  1662. +
  1663. +#include "cores/VideoRenderers/LinuxRendererA10.h"
  1664. +#include "cores/VideoRenderers/RenderFlags.h"
  1665. +
  1666. +#define A10DEBUG
  1667. +#define MEDIAINFO
  1668. +
  1669. +extern void A10VLExit();
  1670. +extern bool A10VLInit(int &width, int &height);
  1671. +
  1672. +static bool a10IsEnabled = false;
  1673. +
  1674. +void EnableA10Renderer ()
  1675. +{
  1676. +       a10IsEnabled = true;
  1677. +}
  1678. +
  1679. +bool IsEnableA10Renderer ()
  1680. +{
  1681. +       return false;
  1682. +}
  1683. +
  1684. +#define _4CC(c1,c2,c3,c4) (((u32)(c4)<<24)|((u32)(c3)<<16)|((u32)(c2)<<8)|(u32)(c1))
  1685. +
  1686. +static void freecallback(void *callbackpriv, void *pictpriv, cedarv_picture_t &pict)
  1687. +{
  1688. +       ((CDVDVideoCodecA10*)callbackpriv)->FreePicture(pictpriv, pict);
  1689. +}
  1690. +
  1691. +CDVDVideoCodecA10::CDVDVideoCodecA10()
  1692. +{
  1693. +       m_hcedarv  = NULL;
  1694. +       m_yuvdata  = NULL;
  1695. +       m_hwrender = false;
  1696. +       memset(&m_picture, 0, sizeof(m_picture));
  1697. +
  1698. +       //check libbdv dll is loaded
  1699. +
  1700. +       if( !g_libbdv.IsLoaded() )
  1701. +       {
  1702. +               g_libbdv.EnableDelayedUnload(false);
  1703. +               if( !g_libbdv.Load() )
  1704. +                       CLog::Log(LOGERROR, "Load codec failed !");
  1705. +       }
  1706. +
  1707. +       m_convert_bitstream = false;
  1708. +}
  1709. +
  1710. +CDVDVideoCodecA10::~CDVDVideoCodecA10()
  1711. +{
  1712. +       Dispose();
  1713. +       A10VLExit();
  1714. +}
  1715. +
  1716. +bool CDVDVideoCodecA10::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
  1717. +{
  1718. +       //check dll is load success
  1719. +
  1720. +       if( !g_libbdv.IsLoaded() )
  1721. +       {
  1722. +               CLog::Log(LOGERROR, "Load failed, cannot start the codec!");
  1723. +               return false;
  1724. +       }
  1725. +
  1726. +       CLog::Log(LOGDEBUG, "--------------------- CDVDVideoCodecA10: Open, %d------------------------ ", hints.codec);
  1727. +
  1728. +       s32 ret;
  1729. +
  1730. +       if (getenv("NOA10")) {
  1731. +               CLog::Log(LOGERROR, "--------------------- CDVDVideoCodecA10: disable ------------------------ ");
  1732. +               CLog::Log(LOGNOTICE, "A10: disabled.\n");
  1733. +               return false;
  1734. +       }
  1735. +
  1736. +       m_aspect = hints.aspect;
  1737. +
  1738. +       memset(&m_info, 0, sizeof(m_info));
  1739. +
  1740. +       m_info.frame_duration = 0;
  1741. +       m_info.video_width = hints.width;
  1742. +       m_info.video_height = hints.height;
  1743. +       m_info.aspect_ratio = 1000;
  1744. +       m_info.sub_format = CEDARV_SUB_FORMAT_UNKNOW;
  1745. +       m_info.container_format = CEDARV_CONTAINER_FORMAT_UNKNOW;
  1746. +       m_info.init_data_len = 0;
  1747. +       m_info.init_data = NULL;
  1748. +
  1749. +       switch(hints.codec) {
  1750. +               //TODO: all the mapping ...
  1751. +
  1752. +               //*CEDARV_STREAM_FORMAT_MPEG2
  1753. +       case CODEC_ID_MPEG1VIDEO:
  1754. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG2;
  1755. +               m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG1;
  1756. +               break;
  1757. +       case CODEC_ID_MPEG2VIDEO:
  1758. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG2;
  1759. +               m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG2;
  1760. +               break;
  1761. +
  1762. +               //*CEDARV_STREAM_FORMAT_H264
  1763. +       case CODEC_ID_H264:
  1764. +               m_info.format = CEDARV_STREAM_FORMAT_H264;
  1765. +               m_info.init_data_len = hints.extrasize;
  1766. +               m_info.init_data = (u8*)hints.extradata;
  1767. +               if(hints.codec_tag==27) //M2TS and TS
  1768. +                       m_info.container_format = CEDARV_CONTAINER_FORMAT_TS;
  1769. +              
  1770. +#if 0
  1771. +               //disable it temporary
  1772. +               // valid avcC data (bitstream) always starts with the value 1 (version)
  1773. +               if ( *(char*)hints.extradata == 1 )
  1774. +               {
  1775. +                       CLog::Log(LOGDEBUG, "A10: try to enable bitstream convert.");
  1776. +
  1777. +                       m_convert_bitstream = bitstream_convert_init(hints.extradata, hints.extrasize);
  1778. +
  1779. +                       if( m_convert_bitstream )
  1780. +                       {
  1781. +                               CLog::Log(LOGDEBUG, "A10: enable bitstream convert.");
  1782. +                       }
  1783. +               }
  1784. +#endif
  1785. +
  1786. +               break;
  1787. +
  1788. +               //*CEDARV_STREAM_FORMAT_MPEG4
  1789. +       case CODEC_ID_MPEG4:
  1790. +               m_info.format = CEDARV_STREAM_FORMAT_MPEG4;
  1791. +                switch(m_hints.codec_tag)
  1792. +                {
  1793. +                  case _4CC('D','I','V','X'):
  1794. +                    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX4;
  1795. +                    break;
  1796. +                  case _4CC('D','X','5','0'):
  1797. +                  case _4CC('D','I','V','5'):
  1798. +                    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX5;
  1799. +                    break;
  1800. +                  case _4CC('X','V','I','D'):
  1801. +                  case _4CC('M','P','4','V'):
  1802. +                  case _4CC('P','M','P','4'):
  1803. +                  case _4CC('F','M','P','4'):
  1804. +                    m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_XVID;
  1805. +                    break;
  1806. +                  default:
  1807. +                    CLog::Log(LOGERROR, "A10: (MPEG4)Codec Tag %d is unknown.\n", m_hints.codec_tag);
  1808. +                    return false;
  1809. +                }
  1810. +               break;
  1811. +
  1812. +               //DIVX4
  1813. +               //DIVX5
  1814. +               //SORENSSON_H263
  1815. +               //H263
  1816. +               //RMG2
  1817. +
  1818. +               //VP6
  1819. +       case CODEC_ID_VP6F:
  1820. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1821. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_VP6;
  1822. +               m_info.init_data_len = hints.extrasize;
  1823. +               m_info.init_data     = (u8*)hints.extradata;
  1824. +               break;
  1825. +               //WMV1
  1826. +       case CODEC_ID_WMV1:
  1827. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1828. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV1;
  1829. +               break;
  1830. +               //WMV2
  1831. +       case CODEC_ID_WMV2:
  1832. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1833. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV2;
  1834. +               break;
  1835. +               //DIVX1
  1836. +       case CODEC_ID_MSMPEG4V1:
  1837. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1838. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX1;
  1839. +               break;
  1840. +               //DIVX2
  1841. +       case CODEC_ID_MSMPEG4V2:
  1842. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1843. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX2;
  1844. +               break;
  1845. +               //DIVX3
  1846. +       case CODEC_ID_MSMPEG4V3:
  1847. +               m_info.format     = CEDARV_STREAM_FORMAT_MPEG4;
  1848. +               m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX3;
  1849. +               break;
  1850. +
  1851. +               //*CEDARV_STREAM_FORMAT_REALVIDEO
  1852. +       case CODEC_ID_RV10:
  1853. +       case CODEC_ID_RV20:
  1854. +       case CODEC_ID_RV30:
  1855. +       case CODEC_ID_RV40:
  1856. +               m_info.format = CEDARV_STREAM_FORMAT_REALVIDEO;
  1857. +               break;
  1858. +
  1859. +               //*CEDARV_STREAM_FORMAT_VC1
  1860. +       case CODEC_ID_VC1:
  1861. +               m_info.format     = CEDARV_STREAM_FORMAT_VC1;
  1862. +               break;
  1863. +
  1864. +               //*CEDARV_STREAM_FORMAT_AVS
  1865. +
  1866. +               //*CEDARV_STREAM_FORMAT_MJPEG
  1867. +       case CODEC_ID_MJPEG:
  1868. +               m_info.format = CEDARV_STREAM_FORMAT_MJPEG;
  1869. +               break;
  1870. +
  1871. +               //*CEDARV_STREAM_FORMAT_VP8
  1872. +       case CODEC_ID_VP8:
  1873. +               m_info.format = CEDARV_STREAM_FORMAT_VP8;
  1874. +               break;
  1875. +
  1876. +               //*
  1877. +       default:
  1878. +               CLog::Log(LOGERROR, "A10: codecid %d is unknown.\n", hints.codec);
  1879. +               return false;
  1880. +       }
  1881. +
  1882. +       m_hcedarv = g_libbdv.libcedarv_init(&ret);
  1883. +       if (ret < 0) {
  1884. +               CLog::Log(LOGERROR, "A10: libcedarv_init failed. (%d)\n", ret);
  1885. +               return false;
  1886. +       }
  1887. +
  1888. +       ret = m_hcedarv->set_vstream_info(m_hcedarv, &m_info);
  1889. +       if (ret < 0) {
  1890. +               CLog::Log(LOGERROR, "A10: set_vstream_m_info failed. (%d), id(%d), format(%d)\n", ret, hints.codec, m_info.format);
  1891. +               return false;
  1892. +       }
  1893. +
  1894. +       ret = m_hcedarv->open(m_hcedarv);
  1895. +       if(ret < 0) {
  1896. +               CLog::Log(LOGERROR, "A10: open failed. (%d)\n", ret);
  1897. +               return false;
  1898. +       }
  1899. +
  1900. +       ret = m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_PLAY, 0);
  1901. +       if (ret < 0) {
  1902. +               CLog::Log(LOGERROR, "A10: CEDARV_COMMAND_PLAY failed. (%d)\n", ret);
  1903. +               return false;
  1904. +       }
  1905. +
  1906. +       CLog::Log(LOGDEBUG, "A10: cedar open.");
  1907. +
  1908. +       int width = 0, height = 0;
  1909. +       A10VLInit (width, height);
  1910. +
  1911. +       /*
  1912. +       pthread_attr_t attr;
  1913. +       pthread_attr_init(&attr);
  1914. +       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  1915. +       pthread_create(&m_thread_t, &attr, thread_decode, this);
  1916. +       pthread_attr_destroy(&attr);
  1917. +       */
  1918. +       return true;
  1919. +}
  1920. +
  1921. +bool CDVDVideoCodecA10::DoOpen()
  1922. +{
  1923. +       s32 ret;
  1924. +
  1925. +       m_hcedarv = g_libbdv.libcedarv_init(&ret);
  1926. +       if (ret < 0)
  1927. +       {
  1928. +               CLog::Log(LOGERROR, "A10: libcedarv_init failed. (%d)\n", ret);
  1929. +               goto Error;
  1930. +       }
  1931. +
  1932. +       ret = m_hcedarv->set_vstream_info(m_hcedarv, &m_info);
  1933. +       if (ret < 0)
  1934. +       {
  1935. +               CLog::Log(LOGERROR, "A10: set_vstream_info failed. (%d)\n", ret);
  1936. +               goto Error;
  1937. +       }
  1938. +
  1939. +       ret = m_hcedarv->open(m_hcedarv);
  1940. +       if (ret < 0)
  1941. +       {
  1942. +               CLog::Log(LOGERROR, "A10: open failed. (%d)\n", ret);
  1943. +               goto Error;
  1944. +       }
  1945. +
  1946. +       ret = m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_PLAY, 0);
  1947. +       if (ret < 0)
  1948. +       {
  1949. +               CLog::Log(LOGERROR, "A10: CEDARV_COMMAND_PLAY failed. (%d)\n", ret);
  1950. +               goto Error;
  1951. +       }
  1952. +
  1953. +       CLog::Log(LOGDEBUG, "A10: cedar open.");
  1954. +       return true;
  1955. +
  1956. +Error:
  1957. +
  1958. +       Dispose();
  1959. +       return false;
  1960. +}
  1961. +
  1962. +/*
  1963. +* Dispose, Free all resources
  1964. +*/
  1965. +void CDVDVideoCodecA10::Dispose()
  1966. +{
  1967. +       CLog::Log(LOGDEBUG, "A10: cedar dispose.");
  1968. +        A10VLFreeQueue();
  1969. +       /*if (m_yuvdata)
  1970. +       {
  1971. +       free(m_yuvdata);
  1972. +       m_yuvdata = NULL;
  1973. +       }
  1974. +       */
  1975. +       if (m_hcedarv)
  1976. +       {
  1977. +               m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_STOP, 0);
  1978. +               m_hcedarv->close(m_hcedarv);
  1979. +               g_libbdv.libcedarv_exit(m_hcedarv);
  1980. +               m_hcedarv = NULL;
  1981. +               CLog::Log(LOGDEBUG, "A10: cedar dispose.");
  1982. +       }
  1983. +
  1984. +       if (m_convert_bitstream)
  1985. +       {
  1986. +               if (m_sps_pps_context.sps_pps_data)
  1987. +               {
  1988. +                       free(m_sps_pps_context.sps_pps_data);
  1989. +                       m_sps_pps_context.sps_pps_data = NULL;
  1990. +               }
  1991. +       }
  1992. +}
  1993. +
  1994. +/*
  1995. +* returns one or a combination of VC_ messages
  1996. +* pData and iSize can be NULL, this means we should flush the rest of the data.
  1997. +*/
  1998. +int CDVDVideoCodecA10::Decode(BYTE* pData, int iSize, double dts, double pts)
  1999. +{
  2000. +       s32                        ret;
  2001. +       u8                        *buf0, *buf1;
  2002. +       u32                        bufsize0, bufsize1;
  2003. +       cedarv_stream_data_info_t  dinf;
  2004. +       cedarv_picture_t           picture;
  2005. +
  2006. +       int demuxer_bytes = iSize;
  2007. +       uint8_t *demuxer_content = pData;
  2008. +       bool bitstream_convered  = false;
  2009. +
  2010. +       if (!pData)
  2011. +               return VC_BUFFER;
  2012. +
  2013. +       if (!m_hcedarv)
  2014. +               return VC_ERROR;
  2015. +
  2016. +       //bitstream support
  2017. +#if 0
  2018. +       if (m_convert_bitstream)
  2019. +       {
  2020. +               // convert demuxer packet from bitstream to bytestream (AnnexB)
  2021. +               int bytestream_size = 0;
  2022. +               uint8_t *bytestream_buff = NULL;
  2023. +
  2024. +               bitstream_convert(demuxer_content, demuxer_bytes, &bytestream_buff, &bytestream_size);
  2025. +               if (bytestream_buff && (bytestream_size > 0))
  2026. +               {
  2027. +                       bitstream_convered = true;
  2028. +                       demuxer_bytes = bytestream_size;
  2029. +                       demuxer_content = bytestream_buff;
  2030. +               }
  2031. +       }
  2032. +#endif
  2033. +
  2034. +       ret = m_hcedarv->request_write(m_hcedarv, demuxer_bytes, &buf0, &bufsize0, &buf1, &bufsize1);
  2035. +
  2036. +       if(ret < 0)
  2037. +       {
  2038. +               CLog::Log(LOGERROR, "A10: request_write failed.\n");
  2039. +               return VC_ERROR;
  2040. +       }
  2041. +       if (bufsize1)
  2042. +       {
  2043. +               memcpy(buf0, demuxer_content, bufsize0);
  2044. +               memcpy(buf1, demuxer_content+bufsize0, bufsize1);
  2045. +       }
  2046. +       else
  2047. +       {
  2048. +               memcpy(buf0, demuxer_content, demuxer_bytes);
  2049. +       }
  2050. +
  2051. +       memset(&dinf, 0, sizeof(dinf));
  2052. +       dinf.lengh = iSize;
  2053. +#ifdef CEDARV_FLAG_DECODE_NO_DELAY
  2054. +       dinf.flags = CEDARV_FLAG_FIRST_PART | CEDARV_FLAG_LAST_PART | CEDARV_FLAG_DECODE_NO_DELAY;
  2055. +#else
  2056. +       dinf.flags = CEDARV_FLAG_FIRST_PART | CEDARV_FLAG_LAST_PART;
  2057. +#endif
  2058. +
  2059. +        dinf.pts = llrint(pts);
  2060. +        dinf.flags |= CEDARV_FLAG_PTS_VALID;
  2061. +       m_hcedarv->update_data(m_hcedarv, &dinf);
  2062. +
  2063. +       ret = m_hcedarv->decode(m_hcedarv);
  2064. +
  2065. +
  2066. +       //bitstream support
  2067. +       if (bitstream_convered)
  2068. +               free(demuxer_content);
  2069. +
  2070. +       if (ret > 3 || ret < 0)
  2071. +       {
  2072. +               CLog::Log(LOGERROR, "A10: decode(%d): %d\n", iSize, ret);
  2073. +       }
  2074. +
  2075. +       if (ret == 4)
  2076. +       {
  2077. +               CLog::Log(LOGNOTICE, "A10: Out of decoder frame buffers. Freeing the queue.\n");
  2078. +                A10VLFreeQueue();
  2079. +
  2080. +               m_hcedarv->decode(m_hcedarv);
  2081. +       }
  2082. +
  2083. +       ret = m_hcedarv->display_request(m_hcedarv, &picture);
  2084. +
  2085. +       if (ret > 3 || ret < -1)
  2086. +       {
  2087. +               CLog::Log(LOGERROR, "A10: display_request(%d): %d\n", iSize, ret);
  2088. +       }
  2089. +
  2090. +       if (ret == 0)
  2091. +       {
  2092. +               float aspect_ratio = m_aspect;
  2093. +               m_picture.pts     = pts;
  2094. +               m_picture.dts     = dts;
  2095. +               m_picture.iWidth  = picture.display_width;
  2096. +               m_picture.iHeight = picture.display_height;
  2097. +
  2098. +               if (picture.is_progressive) m_picture.iFlags &= ~DVP_FLAG_INTERLACED;
  2099. +               else                        m_picture.iFlags |= DVP_FLAG_INTERLACED;
  2100. +
  2101. +               /* XXX: we suppose the screen has a 1.0 pixel ratio */ // CDVDVideo will compensate it.
  2102. +               if (aspect_ratio <= 0.0)
  2103. +                       aspect_ratio = (float)m_picture.iWidth / (float)m_picture.iHeight;
  2104. +
  2105. +               m_picture.iDisplayHeight = m_picture.iHeight;
  2106. +               m_picture.iDisplayWidth  = ((int)lrint(m_picture.iHeight * aspect_ratio)) & -3;
  2107. +               if (m_picture.iDisplayWidth > m_picture.iWidth)
  2108. +               {
  2109. +                       m_picture.iDisplayWidth  = m_picture.iWidth;
  2110. +                       m_picture.iDisplayHeight = ((int)lrint(m_picture.iWidth / aspect_ratio)) & -3;
  2111. +               }
  2112. +#if 0
  2113. +               {
  2114. +                       u32 width32;
  2115. +                       u32 height32;
  2116. +                       u32 height64;
  2117. +                       u32 ysize;
  2118. +                       u32 csize;
  2119. +
  2120. +                       m_picture.format = RENDER_FMT_YUV420P;
  2121. +
  2122. +                       width32  = (picture.display_width  + 31) & ~31;
  2123. +                       height32 = (picture.display_height + 31) & ~31;
  2124. +                       height64 = (picture.display_height + 63) & ~63;
  2125. +
  2126. +                       ysize = width32*height32;   //* for y.
  2127. +                       csize = width32*height64/2; //* for u and v together.
  2128. +
  2129. +                       int             display_height_align;
  2130. +                       int             display_width_align;
  2131. +                       int             dst_c_stride;
  2132. +                       int             dst_y_size;
  2133. +                       int             dst_c_size;
  2134. +                       int             alloc_size;
  2135. +
  2136. +                       picture.display_height = (picture.display_height + 7) & (~7);
  2137. +                       display_height_align = (picture.display_height + 1) & (~1);
  2138. +                       display_width_align  = (picture.display_width + 15) & (~15);
  2139. +                       dst_y_size           = display_width_align * display_height_align;
  2140. +                       dst_c_stride         = (picture.display_width/2 + 15) & (~15);
  2141. +                       dst_c_size           = dst_c_stride * (display_height_align/2);
  2142. +                       alloc_size           = dst_y_size + dst_c_size * 2;
  2143. +
  2144. +
  2145. +                       if (!m_yuvdata) {
  2146. +                               m_yuvdata = (u8*)calloc(alloc_size, 1);
  2147. +                               if (!m_yuvdata) {
  2148. +                                       CLog::Log(LOGERROR, "A10: can not alloc m_yuvdata!");
  2149. +                                       m_hcedarv->display_release(m_hcedarv, picture.id);
  2150. +                                       return VC_ERROR;
  2151. +                               }
  2152. +                       }
  2153. +                       TransformToYUVPlaner (&picture, m_yuvdata, display_height_align, display_width_align, dst_c_stride, dst_y_size, dst_c_size);
  2154. +                       if (!(m_picture.iFlags & DVP_FLAG_ALLOCATED)) {
  2155. +                               u32 width16  = (picture.display_width  + 15) & ~15;
  2156. +
  2157. +                               m_picture.iFlags |= DVP_FLAG_ALLOCATED;
  2158. +
  2159. +                               m_picture.iLineSize[0] = display_width_align;   //Y
  2160. +                               m_picture.iLineSize[1] = dst_c_stride; //U
  2161. +                               m_picture.iLineSize[2] = dst_c_stride; //V
  2162. +                               m_picture.iLineSize[3] = 0;
  2163. +
  2164. +                               m_picture.data[0] = m_yuvdata;
  2165. +                               m_picture.data[1] = m_yuvdata+dst_y_size + dst_c_size;
  2166. +                               m_picture.data[2] = m_yuvdata+dst_y_size;
  2167. +
  2168. +                       }
  2169. +
  2170. +
  2171. +                       m_hcedarv->display_release(m_hcedarv, picture.id);
  2172. +               }
  2173. +#else
  2174. +                //u8 *y_p = (u8 *)g_libbdv.mem_palloc (picture.size_y, 1024);
  2175. +                //u8 *u_p = (u8 *)g_libbdv.mem_palloc (picture.size_u, 1024);
  2176. +                //memcpy (y_p, picture.y, picture.size_y);
  2177. +                //memcpy (u_p, picture.u, picture.size_u);
  2178. +               //m_hcedarv->display_release(m_hcedarv, picture.id);
  2179. +                //picture.y = y_p;
  2180. +                //picture.u = u_p;
  2181. +               m_picture.format     = RENDER_FMT_A10BUF;
  2182. +               m_picture.a10buffer  = A10VLPutQueue(freecallback, (void*)this, NULL, picture);
  2183. +               m_picture.iFlags    |= DVP_FLAG_ALLOCATED;
  2184. +#endif
  2185. +
  2186. +               return VC_PICTURE | VC_BUFFER;
  2187. +       }
  2188. +
  2189. +       CLog::Log(LOGINFO, "A10: Decode need more data");
  2190. +
  2191. +       return VC_BUFFER;
  2192. +}
  2193. +
  2194. +/*
  2195. +* Reset the decoder.
  2196. +* Should be the same as calling Dispose and Open after each other
  2197. +*/
  2198. +void CDVDVideoCodecA10::Reset()
  2199. +{
  2200. +       CLog::Log(LOGDEBUG, "A10: reset requested");
  2201. +       m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_RESET, 0);
  2202. +}
  2203. +
  2204. +/*
  2205. +* returns true if successfull
  2206. +* the data is valid until the next Decode call
  2207. +*/
  2208. +bool CDVDVideoCodecA10::GetPicture(DVDVideoPicture* pDvdVideoPicture)
  2209. +{
  2210. +       if (m_picture.iFlags & DVP_FLAG_ALLOCATED)
  2211. +       {
  2212. +               *pDvdVideoPicture = m_picture;
  2213. +               return true;
  2214. +       }
  2215. +       return false;
  2216. +}
  2217. +
  2218. +void CDVDVideoCodecA10::SetDropState(bool bDrop)
  2219. +{
  2220. +}
  2221. +
  2222. +const char* CDVDVideoCodecA10::GetName()
  2223. +{
  2224. +       return "A10";
  2225. +}
  2226. +
  2227. +void CDVDVideoCodecA10::FreePicture(void *pictpriv, cedarv_picture_t &pict)
  2228. +{
  2229. +       m_hcedarv->display_release(m_hcedarv, pict.id);
  2230. +        //g_libbdv.mem_pfree (pict.y);
  2231. +        //g_libbdv.mem_pfree (pict.u);        
  2232. +}
  2233. +
  2234. +////////////////////////////////////////////////////////////////////////////////////////////
  2235. +bool CDVDVideoCodecA10::bitstream_convert_init(void *in_extradata, int in_extrasize)
  2236. +{
  2237. +       // based on h264_mp4toannexb_bsf.c (ffmpeg)
  2238. +       // which is Copyright (c) 2007 Benoit Fouet <benoit.fouet@free.fr>
  2239. +       // and Licensed GPL 2.1 or greater
  2240. +
  2241. +       m_sps_pps_size = 0;
  2242. +       m_sps_pps_context.sps_pps_data = NULL;
  2243. +
  2244. +       // nothing to filter
  2245. +       if (!in_extradata || in_extrasize < 6)
  2246. +               return false;
  2247. +
  2248. +       uint16_t unit_size;
  2249. +       uint32_t total_size = 0;
  2250. +       uint8_t *out = NULL, unit_nb, sps_done = 0;
  2251. +       const uint8_t *extradata = (uint8_t*)in_extradata + 4;
  2252. +       static const uint8_t nalu_header[4] = {0, 0, 0, 1};
  2253. +
  2254. +       // retrieve length coded size
  2255. +       m_sps_pps_context.length_size = (*extradata++ & 0x3) + 1;
  2256. +       if (m_sps_pps_context.length_size == 3)
  2257. +       {
  2258. +               CLog::Log(LOGDEBUG, "A10: bitstream_convert_init length_size.");
  2259. +               return false;
  2260. +       }
  2261. +
  2262. +       // retrieve sps and pps unit(s)
  2263. +       unit_nb = *extradata++ & 0x1f;  // number of sps unit(s)
  2264. +       if (!unit_nb)
  2265. +       {
  2266. +               unit_nb = *extradata++;       // number of pps unit(s)
  2267. +               sps_done++;
  2268. +       }
  2269. +       while (unit_nb--)
  2270. +       {
  2271. +               unit_size = extradata[0] << 8 | extradata[1];
  2272. +               total_size += unit_size + 4;
  2273. +               if ( (extradata + 2 + unit_size) > ((uint8_t*)in_extradata + in_extrasize) )
  2274. +               {
  2275. +                       free(out);
  2276. +                       return false;
  2277. +               }
  2278. +               out = (uint8_t*)realloc(out, total_size);
  2279. +               if (!out)
  2280. +                       return false;
  2281. +
  2282. +               memcpy(out + total_size - unit_size - 4, nalu_header, 4);
  2283. +               memcpy(out + total_size - unit_size, extradata + 2, unit_size);
  2284. +               extradata += 2 + unit_size;
  2285. +
  2286. +               if (!unit_nb && !sps_done++)
  2287. +                       unit_nb = *extradata++;     // number of pps unit(s)
  2288. +       }
  2289. +
  2290. +       m_sps_pps_context.sps_pps_data = out;
  2291. +       m_sps_pps_context.size = total_size;
  2292. +       m_sps_pps_context.first_idr = 1;
  2293. +
  2294. +       return true;
  2295. +}
  2296. +
  2297. +bool CDVDVideoCodecA10::bitstream_convert(BYTE* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size)
  2298. +{
  2299. +       // based on h264_mp4toannexb_bsf.c (ffmpeg)
  2300. +       // which is Copyright (c) 2007 Benoit Fouet <benoit.fouet@free.fr>
  2301. +       // and Licensed GPL 2.1 or greater
  2302. +
  2303. +       uint8_t *buf = pData;
  2304. +       uint32_t buf_size = iSize;
  2305. +       uint8_t  unit_type;
  2306. +       int32_t  nal_size;
  2307. +       uint32_t cumul_size = 0;
  2308. +       const uint8_t *buf_end = buf + buf_size;
  2309. +
  2310. +       do
  2311. +       {
  2312. +               if (buf + m_sps_pps_context.length_size > buf_end)
  2313. +                       goto fail;
  2314. +
  2315. +               if (m_sps_pps_context.length_size == 1)
  2316. +                       nal_size = buf[0];
  2317. +               else if (m_sps_pps_context.length_size == 2)
  2318. +                       nal_size = buf[0] << 8 | buf[1];
  2319. +               else
  2320. +                       nal_size = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
  2321. +
  2322. +               buf += m_sps_pps_context.length_size;
  2323. +               unit_type = *buf & 0x1f;
  2324. +
  2325. +               if (buf + nal_size > buf_end || nal_size < 0)
  2326. +                       goto fail;
  2327. +
  2328. +               // prepend only to the first type 5 NAL unit of an IDR picture
  2329. +               if (m_sps_pps_context.first_idr && unit_type == 5)
  2330. +               {
  2331. +                       bitstream_alloc_and_copy(poutbuf, poutbuf_size,
  2332. +                               m_sps_pps_context.sps_pps_data, m_sps_pps_context.size, buf, nal_size);
  2333. +                       m_sps_pps_context.first_idr = 0;
  2334. +               }
  2335. +               else
  2336. +               {
  2337. +                       bitstream_alloc_and_copy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size);
  2338. +                       if (!m_sps_pps_context.first_idr && unit_type == 1)
  2339. +                               m_sps_pps_context.first_idr = 1;
  2340. +               }
  2341. +
  2342. +               buf += nal_size;
  2343. +               cumul_size += nal_size + m_sps_pps_context.length_size;
  2344. +       } while (cumul_size < buf_size);
  2345. +
  2346. +       return true;
  2347. +
  2348. +fail:
  2349. +       free(*poutbuf);
  2350. +       *poutbuf = NULL;
  2351. +       *poutbuf_size = 0;
  2352. +       return false;
  2353. +}
  2354. +
  2355. +void CDVDVideoCodecA10::bitstream_alloc_and_copy(
  2356. +       uint8_t **poutbuf,      int *poutbuf_size,
  2357. +       const uint8_t *sps_pps, uint32_t sps_pps_size,
  2358. +       const uint8_t *in,      uint32_t in_size)
  2359. +{
  2360. +       // based on h264_mp4toannexb_bsf.c (ffmpeg)
  2361. +       // which is Copyright (c) 2007 Benoit Fouet <benoit.fouet@free.fr>
  2362. +       // and Licensed GPL 2.1 or greater
  2363. +
  2364. +#define CHD_WB32(p, d) { \
  2365. +       ((uint8_t*)(p))[3] = (d); \
  2366. +       ((uint8_t*)(p))[2] = (d) >> 8; \
  2367. +       ((uint8_t*)(p))[1] = (d) >> 16; \
  2368. +       ((uint8_t*)(p))[0] = (d) >> 24; }
  2369. +
  2370. +       uint32_t offset = *poutbuf_size;
  2371. +       uint8_t nal_header_size = offset ? 3 : 4;
  2372. +
  2373. +       *poutbuf_size += sps_pps_size + in_size + nal_header_size;
  2374. +       *poutbuf = (uint8_t*)realloc(*poutbuf, *poutbuf_size);
  2375. +       if (sps_pps)
  2376. +               memcpy(*poutbuf + offset, sps_pps, sps_pps_size);
  2377. +
  2378. +       memcpy(*poutbuf + sps_pps_size + nal_header_size + offset, in, in_size);
  2379. +       if (!offset)
  2380. +       {
  2381. +               CHD_WB32(*poutbuf + sps_pps_size, 1);
  2382. +       }
  2383. +       else
  2384. +       {
  2385. +               (*poutbuf + offset + sps_pps_size)[0] = 0;
  2386. +               (*poutbuf + offset + sps_pps_size)[1] = 0;
  2387. +               (*poutbuf + offset + sps_pps_size)[2] = 1;
  2388. +       }
  2389. +}
  2390. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h
  2391. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h   1970-01-01 01:00:00.000000000 +0100
  2392. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h        2013-06-12 16:40:35.000000000 +0200
  2393. @@ -0,0 +1,169 @@
  2394. +#pragma once
  2395. +
  2396. +/*
  2397. + *      Copyright (C) 2005-2008 Team XBMC
  2398. + *      http://www.xbmc.org
  2399. + *
  2400. + *  This Program is free software; you can redistribute it and/or modify
  2401. + *  it under the terms of the GNU General Public License as published by
  2402. + *  the Free Software Foundation; either version 2, or (at your option)
  2403. + *  any later version.
  2404. + *
  2405. + *  This Program is distributed in the hope that it will be useful,
  2406. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  2407. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2408. + *  GNU General Public License for more details.
  2409. + *
  2410. + *  You should have received a copy of the GNU General Public License
  2411. + *  along with XBMC; see the file COPYING.  If not, write to
  2412. + *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  2413. + *  http://www.gnu.org/copyleft/gpl.html
  2414. + *
  2415. + */
  2416. +
  2417. +#include "guilib/Geometry.h"
  2418. +#include "DVDVideoCodec.h"
  2419. +#include "DVDStreamInfo.h"
  2420. +
  2421. +extern "C" {
  2422. +#include "cores/a10/libcedarv.h"
  2423. +#include "cores/a10/DllLibcedarv.h"
  2424. +};
  2425. +
  2426. +class CDVDVideoCodecA10 : public CDVDVideoCodec
  2427. +{
  2428. +public:
  2429. +
  2430. +  CDVDVideoCodecA10();
  2431. +  virtual ~CDVDVideoCodecA10();
  2432. +
  2433. +  /*
  2434. +   * Open the decoder, returns true on success
  2435. +   */
  2436. +  bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
  2437. +
  2438. +  /*
  2439. +   * Dispose, Free all resources
  2440. +   */
  2441. +  void Dispose();
  2442. +
  2443. +  /*
  2444. +   * returns one or a combination of VC_ messages
  2445. +   * pData and iSize can be NULL, this means we should flush the rest of the data.
  2446. +   */
  2447. +  int Decode(BYTE* pData, int iSize, double dts, double pts);
  2448. +
  2449. + /*
  2450. +   * Reset the decoder.
  2451. +   * Should be the same as calling Dispose and Open after each other
  2452. +   */
  2453. +  void Reset();
  2454. +
  2455. +  /*
  2456. +   * returns true if successfull
  2457. +   * the data is valid until the next Decode call
  2458. +   */
  2459. +  bool GetPicture(DVDVideoPicture* pDvdVideoPicture);
  2460. +
  2461. +
  2462. +  /*
  2463. +   * returns true if successfull
  2464. +   * the data is cleared to zero
  2465. +   */
  2466. +  /*-->super
  2467. +  bool ClearPicture(DVDVideoPicture* pDvdVideoPicture);
  2468. +  */
  2469. +
  2470. +  /*
  2471. +   * returns true if successfull
  2472. +   * the data is valid until the next Decode call
  2473. +   * userdata can be anything, for now we use it for closed captioning
  2474. +   */
  2475. +  /*-->super
  2476. +  bool GetUserData(DVDVideoUserData* pDvdVideoUserData);
  2477. +  */
  2478. +
  2479. +  /*
  2480. +   * will be called by video player indicating if a frame will eventually be dropped
  2481. +   * codec can then skip actually decoding the data, just consume the data set picture headers
  2482. +   */
  2483. +  void SetDropState(bool bDrop);
  2484. +
  2485. +  /*
  2486. +   * returns the number of demuxer bytes in any internal buffers
  2487. +   */
  2488. +  /*-->super
  2489. +  int GetDataSize(void);
  2490. +  */
  2491. +
  2492. +  /*
  2493. +   * returns the time in seconds for demuxer bytes in any internal buffers
  2494. +   */
  2495. +  /*-->super
  2496. +  virtual double GetTimeSize(void);
  2497. +  */
  2498. +
  2499. +  /*
  2500. +   * set the type of filters that should be applied at decoding stage if possible
  2501. +   */
  2502. +  /*-->super
  2503. +  unsigned int SetFilters(unsigned int filters);
  2504. +  */
  2505. +
  2506. +  /*
  2507. +   *
  2508. +   * should return codecs name
  2509. +   */
  2510. +  const char* GetName();
  2511. +
  2512. +  /*
  2513. +   *
  2514. +   * How many packets should player remember, so codec
  2515. +   * can recover should something cause it to flush
  2516. +   * outside of players control
  2517. +   */
  2518. +  /*-->super
  2519. +  virtual unsigned GetConvergeCount();
  2520. +  */
  2521. +
  2522. +  void FreePicture(void *pictpriv, cedarv_picture_t &pict);
  2523. +
  2524. +private:
  2525. +
  2526. +  bool DoOpen();
  2527. +
  2528. +  //rendering
  2529. +  bool m_hwrender;
  2530. +
  2531. +  //decoding
  2532. +  cedarv_stream_info_t  m_info;
  2533. +  float                 m_aspect;
  2534. +  CDVDStreamInfo        m_hints;
  2535. +  cedarv_decoder_t     *m_hcedarv;
  2536. +  int                   m_hscaler;
  2537. +  u8                   *m_yuvdata;
  2538. +  DVDVideoPicture       m_picture;
  2539. +
  2540. +protected:
  2541. +
  2542. +  // bitstream to bytestream (Annex B) conversion support.
  2543. +  bool bitstream_convert_init(void *in_extradata, int in_extrasize);
  2544. +  bool bitstream_convert(BYTE* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size);
  2545. +  void bitstream_alloc_and_copy( uint8_t **poutbuf, int *poutbuf_size,
  2546. +               const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size);
  2547. +
  2548. +  typedef struct a10_bitstream_ctx {
  2549. +         uint8_t  length_size;
  2550. +         uint8_t  first_idr;
  2551. +         uint8_t *sps_pps_data;
  2552. +         uint32_t size;
  2553. +  } a10_bitstream_ctx;
  2554. +
  2555. +  uint32_t          m_sps_pps_size;
  2556. +  a10_bitstream_ctx m_sps_pps_context;
  2557. +  bool              m_convert_bitstream;
  2558. +};
  2559. +
  2560. +//////////////////////////////////////////////////////////////////////////
  2561. +
  2562. +static DllLibA10decoder g_libbdv;
  2563. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
  2564. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h      2013-06-12 16:46:43.000000000 +0200
  2565. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h   2013-06-12 16:40:35.000000000 +0200
  2566. @@ -38,6 +38,7 @@
  2567.  class COpenMax;
  2568.  class COpenMaxVideo;
  2569.  struct OpenMaxVideoBuffer;
  2570. +struct A10VLQueueItem;
  2571.  
  2572.  // should be entirely filled by all codecs
  2573.  struct DVDVideoPicture
  2574. @@ -69,6 +70,10 @@
  2575.      struct {
  2576.        struct __CVBuffer *cvBufferRef;
  2577.      };
  2578. +
  2579. +    struct {
  2580. +      A10VLQueueItem *a10buffer;
  2581. +    };
  2582.    };
  2583.  
  2584.    unsigned int iFlags;
  2585. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.c xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.c
  2586. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.c     1970-01-01 01:00:00.000000000 +0100
  2587. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.c  2013-06-12 16:40:35.000000000 +0200
  2588. @@ -0,0 +1,467 @@
  2589. +
  2590. +#define LOG_NDEBUG 0
  2591. +#define LOG_TAG "transform.c"
  2592. +
  2593. +#include "transform_color_format.h"
  2594. +#include <unistd.h>
  2595. +#include <stdlib.h>
  2596. +#include <memory.h>
  2597. +
  2598. +enum FORMAT_CONVERT_COLORFORMAT
  2599. +{
  2600. +       CONVERT_COLOR_FORMAT_NONE = 0,
  2601. +       CONVERT_COLOR_FORMAT_YUV420PLANNER,
  2602. +       CONVERT_COLOR_FORMAT_YUV422PLANNER,
  2603. +       CONVERT_COLOR_FORMAT_YUV420MB,
  2604. +       CONVERT_COLOR_FORMAT_YUV422MB,
  2605. +};
  2606. +
  2607. +typedef struct ScalerParameter
  2608. +{
  2609. +       int mode; //0: YV12 1:thumb yuv420p
  2610. +       int format_in;
  2611. +       int format_out;
  2612. +
  2613. +       int width_in;
  2614. +       int height_in;
  2615. +
  2616. +       int width_out;
  2617. +       int height_out;
  2618. +
  2619. +       void *addr_y_in;
  2620. +       void *addr_c_in;
  2621. +       unsigned int addr_y_out;
  2622. +       unsigned int addr_u_out;
  2623. +       unsigned int addr_v_out;
  2624. +}ScalerParameter;
  2625. +
  2626. +#if 0 //Don't HAVE_NEON
  2627. +static void map32x32_to_yuv_Y(unsigned char* srcY, unsigned char* tarY, unsigned int coded_width, unsigned int coded_height)
  2628. +{
  2629. +       unsigned int i,j,l,m,n;
  2630. +       unsigned int mb_width,mb_height,twomb_line,recon_width;
  2631. +       unsigned long offset;
  2632. +       unsigned char *ptr;
  2633. +
  2634. +       ptr = srcY;
  2635. +       mb_width = (coded_width+15)>>4;
  2636. +       mb_height = (coded_height+15)>>4;
  2637. +       twomb_line = (mb_height+1)>>1;
  2638. +       recon_width = (mb_width+1)&0xfffffffe;
  2639. +
  2640. +       for(i=0;i<twomb_line;i++)
  2641. +       {
  2642. +               for(j=0;j<recon_width;j+=2)
  2643. +               {
  2644. +                       for(l=0;l<32;l++)
  2645. +                       {
  2646. +                               //first mb
  2647. +                               m=i*32 + l;
  2648. +                               n= j*16;
  2649. +                               if(m<coded_height && n<coded_width)
  2650. +                               {
  2651. +                                       offset = m*coded_width + n;
  2652. +                                       memcpy(tarY+offset,ptr,16);
  2653. +                                       ptr += 16;
  2654. +                               }
  2655. +                               else
  2656. +                                       ptr += 16;
  2657. +
  2658. +                               //second mb
  2659. +                               n= j*16+16;
  2660. +                               if(m<coded_height && n<coded_width)
  2661. +                               {
  2662. +                                       offset = m*coded_width + n;
  2663. +                                       memcpy(tarY+offset,ptr,16);
  2664. +                                       ptr += 16;
  2665. +                               }
  2666. +                               else
  2667. +                                       ptr += 16;
  2668. +                       }
  2669. +               }
  2670. +       }
  2671. +}
  2672. +
  2673. +static void map32x32_to_yuv_C(int mode,unsigned char* srcC,unsigned char* tarCb,unsigned char* tarCr,unsigned int coded_width,unsigned int coded_height)
  2674. +{
  2675. +       unsigned int i,j,l,m,n,k;
  2676. +       unsigned int mb_width,mb_height,fourmb_line,recon_width;
  2677. +       unsigned char line[16];
  2678. +       unsigned long offset;
  2679. +       unsigned char *ptr;
  2680. +
  2681. +       ptr = srcC;
  2682. +       mb_width = (coded_width+7)>>3;
  2683. +       mb_height = (coded_height+7)>>3;
  2684. +       fourmb_line = (mb_height+3)>>2;
  2685. +       recon_width = (mb_width+1)&0xfffffffe;
  2686. +
  2687. +       for(i=0;i<fourmb_line;i++)
  2688. +       {
  2689. +               for(j=0;j<recon_width;j+=2)
  2690. +               {
  2691. +                       for(l=0;l<32;l++)
  2692. +                       {
  2693. +                               //first mb
  2694. +                               m=i*32 + l;
  2695. +                               n= j*8;
  2696. +                               if(m<coded_height && n<coded_width)
  2697. +                               {
  2698. +                                       offset = m*coded_width + n;
  2699. +                                       memcpy(line,ptr,16);
  2700. +                                       for(k=0;k<8;k++)
  2701. +                                       {
  2702. +                                               *(tarCb + offset + k) = 0xaa;//line[2*k];
  2703. +                                               *(tarCr + offset + k) = 0x55; //line[2*k+1];
  2704. +                                       }
  2705. +                                       ptr += 16;
  2706. +                               }
  2707. +                               else
  2708. +                                       ptr += 16;
  2709. +
  2710. +                               //second mb
  2711. +                               n= j*8+8;
  2712. +                               if(m<coded_height && n<coded_width)
  2713. +                               {
  2714. +                                       offset = m*coded_width + n;
  2715. +                                       memcpy(line,ptr,16);
  2716. +                                       for(k=0;k<8;k++)
  2717. +                                       {
  2718. +                                               *(tarCb + offset + k) = 0xaa;//line[2*k];
  2719. +                                               *(tarCr + offset + k) = 0x55;//line[2*k+1];
  2720. +                                       }
  2721. +                                       ptr += 16;
  2722. +                               }
  2723. +                               else
  2724. +                                       ptr += 16;
  2725. +                       }
  2726. +               }
  2727. +       }
  2728. +}
  2729. +
  2730. +static void map32x32_to_yuv_C_422(int mode,unsigned char* srcC,unsigned char* tarCb,unsigned char* tarCr,unsigned int coded_width,unsigned int coded_height) {
  2731. +       ;
  2732. +}
  2733. +
  2734. +#else
  2735. +
  2736. +
  2737. +static void map32x32_to_yuv_Y(unsigned char* srcY,
  2738. +                                     unsigned char* tarY,
  2739. +                                     unsigned int   coded_width,
  2740. +                                     unsigned int   coded_height)
  2741. +{
  2742. +       unsigned int i,j,l,m,n;
  2743. +       unsigned int mb_width,mb_height,twomb_line,recon_width;
  2744. +       unsigned long offset;
  2745. +       unsigned char *ptr;
  2746. +       unsigned char *dst_asm,*src_asm;
  2747. +
  2748. +       ptr = srcY;
  2749. +       mb_width = (coded_width+15)>>4;
  2750. +       mb_height = (coded_height+15)>>4;
  2751. +       twomb_line = (mb_height+1)>>1;
  2752. +       recon_width = (mb_width+1)&0xfffffffe;
  2753. +
  2754. +       for(i=0;i<twomb_line;i++)
  2755. +       {
  2756. +               for(j=0;j<mb_width/2;j++)
  2757. +               {
  2758. +                       for(l=0;l<32;l++)
  2759. +                       {
  2760. +                               //first mb
  2761. +                               m=i*32 + l;
  2762. +                               n= j*32;
  2763. +                               offset = m*coded_width + n;
  2764. +                               //memcpy(tarY+offset,ptr,32);
  2765. +                               dst_asm = tarY+offset;
  2766. +                               src_asm = ptr;
  2767. +                               asm volatile (
  2768. +                                       "vld1.8         {d0 - d3}, [%[src_asm]]              \n\t"
  2769. +                                       "vst1.8         {d0 - d3}, [%[dst_asm]]              \n\t"
  2770. +                                       : [dst_asm] "+r" (dst_asm), [src_asm] "+r" (src_asm)
  2771. +                                       :  //[srcY] "r" (srcY)
  2772. +                                       : "cc", "memory", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d28", "d29", "d30", "d31"
  2773. +                                       );
  2774. +
  2775. +                               ptr += 32;
  2776. +                       }
  2777. +               }
  2778. +
  2779. +               //LOGV("mb_width:%d",mb_width);
  2780. +               if(mb_width & 1)
  2781. +               {
  2782. +                       j = mb_width-1;
  2783. +                       for(l=0;l<32;l++)
  2784. +                       {
  2785. +                               //first mb
  2786. +                               m=i*32 + l;
  2787. +                               n= j*16;
  2788. +                               if(m<coded_height && n<coded_width)
  2789. +                               {
  2790. +                                       offset = m*coded_width + n;
  2791. +                                       //memcpy(tarY+offset,ptr,16);
  2792. +                                       dst_asm = tarY+offset;
  2793. +                                       src_asm = ptr;
  2794. +                                       asm volatile (
  2795. +                                               "vld1.8         {d0 - d1}, [%[src_asm]]              \n\t"
  2796. +                                               "vst1.8         {d0 - d1}, [%[dst_asm]]              \n\t"
  2797. +                                               : [dst_asm] "+r" (dst_asm), [src_asm] "+r" (src_asm)
  2798. +                                               :  //[srcY] "r" (srcY)
  2799. +                                               : "cc", "memory", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d28", "d29", "d30", "d31"
  2800. +                                               );
  2801. +                               }
  2802. +
  2803. +                               ptr += 16;
  2804. +                               ptr += 16;
  2805. +                       }
  2806. +               }
  2807. +       }
  2808. +}
  2809. +
  2810. +static void map32x32_to_yuv_C(int mode,
  2811. +                                     unsigned char* srcC,
  2812. +                                     unsigned char* tarCb,
  2813. +                                     unsigned char* tarCr,
  2814. +                                     unsigned int coded_width,
  2815. +                                     unsigned int coded_height)
  2816. +{
  2817. +       unsigned int i,j,l,m,n,k;
  2818. +       unsigned int mb_width,mb_height,fourmb_line,recon_width;
  2819. +       unsigned long offset;
  2820. +       unsigned char *ptr;
  2821. +       unsigned char *dst0_asm,*dst1_asm,*src_asm;
  2822. +       unsigned char line[16];
  2823. +       int dst_stride = mode==0 ? (coded_width + 15) & (~15) : coded_width;
  2824. +
  2825. +       ptr = srcC;
  2826. +       mb_width = (coded_width+7)>>3;
  2827. +       mb_height = (coded_height+7)>>3;
  2828. +       fourmb_line = (mb_height+3)>>2;
  2829. +       recon_width = (mb_width+1)&0xfffffffe;
  2830. +
  2831. +       for(i=0;i<fourmb_line;i++)
  2832. +       {
  2833. +               for(j=0;j<mb_width/2;j++)
  2834. +               {
  2835. +                       for(l=0;l<32;l++)
  2836. +                       {
  2837. +                               //first mb
  2838. +                               m=i*32 + l;
  2839. +                               n= j*16;
  2840. +                               if(m<coded_height && n<coded_width)
  2841. +                               {
  2842. +                                       offset = m*dst_stride + n;
  2843. +
  2844. +                                       dst0_asm = tarCb + offset;
  2845. +                                       dst1_asm = tarCr+offset;
  2846. +                                       src_asm = ptr;
  2847. +//                                     for(k=0;k<16;k++)
  2848. +//                                     {
  2849. +//                                             dst0_asm[k] = src_asm[2*k];
  2850. +//                                             dst1_asm[k] = src_asm[2*k+1];
  2851. +//                                     }
  2852. +                                       asm volatile (
  2853. +                                               "vld1.8         {d0 - d3}, [%[src_asm]]              \n\t"
  2854. +                                                       "vuzp.8         d0, d1              \n\t"
  2855. +                                                       "vuzp.8         d2, d3              \n\t"
  2856. +                                                       "vst1.8         {d0}, [%[dst0_asm]]!              \n\t"
  2857. +                                                       "vst1.8         {d2}, [%[dst0_asm]]!              \n\t"
  2858. +                                                       "vst1.8         {d1}, [%[dst1_asm]]!              \n\t"
  2859. +                                                       "vst1.8         {d3}, [%[dst1_asm]]!              \n\t"
  2860. +                                                : [dst0_asm] "+r" (dst0_asm), [dst1_asm] "+r" (dst1_asm), [src_asm] "+r" (src_asm)
  2861. +                                                :  //[srcY] "r" (srcY)
  2862. +                                                : "cc", "memory", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d28", "d29", "d30", "d31"
  2863. +                                                );
  2864. +                               }
  2865. +
  2866. +                               ptr += 32;
  2867. +                       }
  2868. +               }
  2869. +
  2870. +               if(mb_width & 1)
  2871. +               {
  2872. +                       j= mb_width-1;
  2873. +                       for(l=0;l<32;l++)
  2874. +                       {
  2875. +                               m=i*32 + l;
  2876. +                               n= j*8;
  2877. +
  2878. +                               if(m<coded_height && n<coded_width)
  2879. +                               {
  2880. +                                       offset = m*dst_stride + n;
  2881. +                                       memcpy(line,ptr,16);
  2882. +                                       for(k=0;k<8;k++)
  2883. +                                       {
  2884. +                                               *(tarCb + offset + k) = line[2*k];
  2885. +                                               *(tarCr + offset + k) = line[2*k+1];
  2886. +                                       }
  2887. +                               }
  2888. +
  2889. +                               ptr += 16;
  2890. +                               ptr += 16;
  2891. +                       }
  2892. +               }
  2893. +       }
  2894. +}
  2895. +
  2896. +static void map32x32_to_yuv_C_422(int mode,
  2897. +                                         unsigned char* srcC,
  2898. +                                         unsigned char* tarCb,
  2899. +                                         unsigned char* tarCr,
  2900. +                                         unsigned int coded_width,
  2901. +                                         unsigned int coded_height)
  2902. +{
  2903. +       unsigned int i,j,l,m,n,k;
  2904. +       unsigned int mb_width,mb_height,twomb_line,recon_width;
  2905. +       unsigned long offset;
  2906. +       unsigned char *ptr;
  2907. +       unsigned char *dst0_asm,*dst1_asm,*src_asm;
  2908. +       unsigned char line[16];
  2909. +
  2910. +       ptr = srcC;
  2911. +       mb_width = (coded_width+7)>>3;
  2912. +       mb_height = (coded_height+7)>>3;
  2913. +       twomb_line = (mb_height+1)>>1;
  2914. +       recon_width = (mb_width+1)&0xfffffffe;
  2915. +
  2916. +       for(i=0;i<twomb_line;i++)
  2917. +       {
  2918. +               for(j=0;j<mb_width/2;j++)
  2919. +               {
  2920. +                       for(l=0;l<16;l++)
  2921. +                       {
  2922. +                               //first mb
  2923. +                               m=i*16 + l;
  2924. +                               n= j*16;
  2925. +                               if(m<coded_height && n<coded_width)
  2926. +                               {
  2927. +                                       offset = m*coded_width + n;
  2928. +
  2929. +                                       dst0_asm = tarCb + offset;
  2930. +                                       dst1_asm = tarCr+offset;
  2931. +                                       src_asm = ptr;
  2932. +//                                     for(k=0;k<16;k++)
  2933. +//                                     {
  2934. +//                                             dst0_asm[k] = src_asm[2*k];
  2935. +//                                             dst1_asm[k] = src_asm[2*k+1];
  2936. +//                                     }
  2937. +                                       asm volatile (
  2938. +                                               "vld1.8         {d0 - d3}, [%[src_asm]]              \n\t"
  2939. +                                                       "vuzp.8         d0, d1              \n\t"
  2940. +                                                       "vuzp.8         d2, d3              \n\t"
  2941. +                                                       "vst1.8         {d0}, [%[dst0_asm]]!              \n\t"
  2942. +                                                       "vst1.8         {d2}, [%[dst0_asm]]!              \n\t"
  2943. +                                                       "vst1.8         {d1}, [%[dst1_asm]]!              \n\t"
  2944. +                                                       "vst1.8         {d3}, [%[dst1_asm]]!              \n\t"
  2945. +                                                : [dst0_asm] "+r" (dst0_asm), [dst1_asm] "+r" (dst1_asm), [src_asm] "+r" (src_asm)
  2946. +                                                :  //[srcY] "r" (srcY)
  2947. +                                                : "cc", "memory", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d28", "d29", "d30", "d31"
  2948. +                                                );
  2949. +                               }
  2950. +
  2951. +                               ptr += 32;
  2952. +                               ptr += 32;
  2953. +                       }
  2954. +               }
  2955. +
  2956. +               if(mb_width & 1)
  2957. +               {
  2958. +                       j= mb_width-1;
  2959. +                       for(l=0;l<16;l++)
  2960. +                       {
  2961. +                               m=i*32 + l;
  2962. +                               n= j*8;
  2963. +
  2964. +                               if(m<coded_height && n<coded_width)
  2965. +                               {
  2966. +                                       offset = m*coded_width + n;
  2967. +                                       memcpy(line,ptr,16);
  2968. +                                       for(k=0;k<8;k++)
  2969. +                                       {
  2970. +                                               *(tarCb + offset + k) = line[2*k];
  2971. +                                               *(tarCr + offset + k) = line[2*k+1];
  2972. +                                       }
  2973. +                               }
  2974. +
  2975. +                               ptr += 32;
  2976. +                               ptr += 32;
  2977. +                       }
  2978. +               }
  2979. +       }
  2980. +}
  2981. +#endif
  2982. +
  2983. +
  2984. +static void SoftwarePictureScaler(ScalerParameter *cdx_scaler_para)
  2985. +{
  2986. +       map32x32_to_yuv_Y(cdx_scaler_para->addr_y_in,
  2987. +                                 (unsigned char*)cdx_scaler_para->addr_y_out,
  2988. +                                 cdx_scaler_para->width_out,
  2989. +                                 cdx_scaler_para->height_out);
  2990. +
  2991. +       if (cdx_scaler_para->format_in == CONVERT_COLOR_FORMAT_YUV422MB)
  2992. +               map32x32_to_yuv_C_422(cdx_scaler_para->mode,
  2993. +                                             cdx_scaler_para->addr_c_in,
  2994. +                                             (unsigned char*)cdx_scaler_para->addr_u_out,
  2995. +                                             (unsigned char*)cdx_scaler_para->addr_v_out,
  2996. +                                             cdx_scaler_para->width_out / 2,
  2997. +                                             cdx_scaler_para->height_out / 2);
  2998. +       else
  2999. +               map32x32_to_yuv_C(cdx_scaler_para->mode,
  3000. +                                         cdx_scaler_para->addr_c_in,
  3001. +                                         (unsigned char*)cdx_scaler_para->addr_u_out,
  3002. +                                         (unsigned char*)cdx_scaler_para->addr_v_out,
  3003. +                                         cdx_scaler_para->width_out / 2,
  3004. +                                         cdx_scaler_para->height_out / 2);
  3005. +
  3006. +       return;
  3007. +}
  3008. +
  3009. +void TransformToYUVPlaner(cedarv_picture_t* pict, void* ybuf, int display_height_align, int display_width_align,
  3010. +int dst_c_stride,
  3011. +int dst_y_size, int dst_c_size)
  3012. +{
  3013. +       ScalerParameter cdx_scaler_para;
  3014. +       //int             display_height_align;
  3015. +       //int             display_width_align;
  3016. +       //int             dst_c_stride;
  3017. +       //int             dst_y_size;
  3018. +       //int             dst_c_size;
  3019. +       //int             alloc_size;
  3020. +
  3021. +       if(pict == NULL)
  3022. +               return;
  3023. +
  3024. +       /*
  3025. +        pict->display_height = (pict->display_height + 7) & (~7);
  3026. +       display_height_align = (pict->display_height + 1) & (~1);
  3027. +       display_width_align  = (pict->display_width + 15) & (~15);
  3028. +       dst_y_size           = display_width_align * display_height_align;
  3029. +       dst_c_stride         = (pict->display_width/2 + 15) & (~15);
  3030. +       dst_c_size           = dst_c_stride * (display_height_align/2);
  3031. +       alloc_size           = dst_y_size + dst_c_size * 2;
  3032. +*/
  3033. +       cdx_scaler_para.mode       = 0;
  3034. +       cdx_scaler_para.format_in  = (pict->pixel_format == CEDARV_PIXEL_FORMAT_AW_YUV422) ? CONVERT_COLOR_FORMAT_YUV422MB : CONVERT_COLOR_FORMAT_YUV420MB;
  3035. +       cdx_scaler_para.format_out = CONVERT_COLOR_FORMAT_YUV420PLANNER;
  3036. +       cdx_scaler_para.width_in   = pict->width;
  3037. +       cdx_scaler_para.height_in  = pict->height;
  3038. +       cdx_scaler_para.addr_y_in  = (void*)pict->y;
  3039. +       cdx_scaler_para.addr_c_in  = (void*)pict->u;
  3040. +#if 0
  3041. +       cedarx_cache_op(cdx_scaler_para.addr_y_in, cdx_scaler_para.addr_y_in+pict->size_y, CEDARX_DCACHE_FLUSH);
  3042. +       cedarx_cache_op(cdx_scaler_para.addr_c_in, cdx_scaler_para.addr_c_in+pict->size_u, CEDARX_DCACHE_FLUSH);
  3043. +#endif
  3044. +       cdx_scaler_para.width_out  = display_width_align;
  3045. +       cdx_scaler_para.height_out = display_height_align;
  3046. +
  3047. +       cdx_scaler_para.addr_y_out = (unsigned int)ybuf;
  3048. +       cdx_scaler_para.addr_v_out = cdx_scaler_para.addr_y_out + dst_y_size;
  3049. +       cdx_scaler_para.addr_u_out = cdx_scaler_para.addr_v_out + dst_c_size;
  3050. +
  3051. +    //* use neon accelarator instruction to transform the pixel format, slow if buffer is not cached(DMA mode).
  3052. +       SoftwarePictureScaler(&cdx_scaler_para);
  3053. +
  3054. +       return;
  3055. +}
  3056. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.h xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.h
  3057. --- xbmc_orig/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.h     1970-01-01 01:00:00.000000000 +0100
  3058. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDCodecs/Video/transform_color_format.h  2013-06-12 16:40:35.000000000 +0200
  3059. @@ -0,0 +1,20 @@
  3060. +
  3061. +#ifndef TRANSFORM_COLOR_FORMAT_H
  3062. +#define TRANSFORM_COLOR_FORMAT_H
  3063. +
  3064. +#include "cores/a10/libcedarv.h"
  3065. +
  3066. +#ifdef __cplusplus
  3067. +extern "C" {
  3068. +#endif
  3069. +
  3070. +void TransformToYUVPlaner(cedarv_picture_t* pict, void* ybuf, int display_height_align, int display_width_align,
  3071. +int dst_c_stride,
  3072. +int dst_y_size, int dst_c_size);
  3073. +
  3074. +#ifdef __cplusplus
  3075. +}
  3076. +#endif
  3077. +
  3078. +#endif
  3079. +
  3080. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDPlayer.cpp xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayer.cpp
  3081. --- xbmc_orig/xbmc/cores/dvdplayer/DVDPlayer.cpp        2013-06-12 16:46:43.000000000 +0200
  3082. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayer.cpp     2013-06-12 16:40:35.000000000 +0200
  3083. @@ -2892,7 +2892,12 @@
  3084.        hint.aspect = aspect;
  3085.        hint.forced_aspect = true;
  3086.      }
  3087. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3088. +       //DVD always using a10 codec
  3089. +       hint.software = false;
  3090. +#else
  3091.      hint.software = true;
  3092. +#endif
  3093.    }
  3094.  
  3095.    boost::shared_ptr<CPVRClient> client;
  3096. @@ -4131,3 +4136,9 @@
  3097.        !g_PVRManager.IsPlayingRecording() &&
  3098.        g_advancedSettings.m_bPVRCacheInDvdPlayer;
  3099.  }
  3100. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3101. +void CDVDPlayer::OnA10Created()
  3102. +{
  3103. +       m_ready.Set();
  3104. +}
  3105. +#endif
  3106. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDPlayer.h xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayer.h
  3107. --- xbmc_orig/xbmc/cores/dvdplayer/DVDPlayer.h  2013-06-12 16:46:43.000000000 +0200
  3108. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayer.h       2013-06-12 16:40:35.000000000 +0200
  3109. @@ -267,6 +267,9 @@
  3110.    virtual int GetCacheLevel() const ;
  3111.  
  3112.    virtual int OnDVDNavResult(void* pData, int iMessage);
  3113. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3114. +  virtual void OnA10Created();
  3115. +#endif
  3116.  protected:
  3117.    friend class CSelectionStreams;
  3118.  
  3119. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
  3120. --- xbmc_orig/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp   2013-06-12 16:46:43.000000000 +0200
  3121. +++ xbmc_vidonme/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp        2013-06-12 16:40:35.000000000 +0200
  3122. @@ -194,7 +194,24 @@
  3123.    formats  = g_renderManager.SupportedFormats();
  3124.  #endif
  3125.  
  3126. -
  3127. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3128. +  CDVDVideoCodec* codec = NULL;
  3129. +  if( m_messageQueue.IsInited() )
  3130. +  {
  3131. +         //the second to create codec, need free the previous codec and then create new codec 
  3132. +         codec = NULL;
  3133. +  }
  3134. +  else
  3135. +  {
  3136. +         //the first time, create codec using old code
  3137. +         codec = CDVDFactoryCodec::CreateVideoCodec(hint, surfaces);
  3138. +         if(!codec)
  3139. +         {
  3140. +                 CLog::Log(LOGERROR, "Unsupported video codec");
  3141. +                 return false;
  3142. +         }
  3143. +  }
  3144. +#else
  3145.    CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec);
  3146.    CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, surfaces, formats);
  3147.    if(!codec)
  3148. @@ -202,6 +219,7 @@
  3149.      CLog::Log(LOGERROR, "Unsupported video codec");
  3150.      return false;
  3151.    }
  3152. +#endif
  3153.  
  3154.    if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && !g_VideoReferenceClock.IsRunning())
  3155.    {
  3156. @@ -255,6 +273,22 @@
  3157.  
  3158.    if (m_pVideoCodec)
  3159.      delete m_pVideoCodec;
  3160. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3161. +  if( !codec )
  3162. +  {
  3163. +         unsigned int surfaces = 0;
  3164. +
  3165. +         //need create codec here. the box must create codec success.
  3166. +         CLog::Log(LOGNOTICE, "Creating next video codec with codec id: %i", hint.codec);
  3167. +         codec = CDVDFactoryCodec::CreateVideoCodec(hint, surfaces);
  3168. +
  3169. +         if(!codec)
  3170. +         {
  3171. +                 CLog::Log(LOGERROR, "Creating next video codec failed");
  3172. +                 return;
  3173. +         }
  3174. +  }
  3175. +#endif
  3176.  
  3177.    m_pVideoCodec = codec;
  3178.    m_hints   = hint;
  3179. @@ -1137,6 +1171,11 @@
  3180.        case RENDER_FMT_CVBREF:
  3181.          formatstr = "BGRA";
  3182.          break;
  3183. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3184. +         case RENDER_FMT_A10BUF:
  3185. +        formatstr = "A10BUF";
  3186. +        break;
  3187. +#endif
  3188.        case RENDER_FMT_BYPASS:
  3189.          formatstr = "BYPASS";
  3190.          break;
  3191. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/IPlayer.h xbmc_vidonme/xbmc/cores/IPlayer.h
  3192. --- xbmc_orig/xbmc/cores/IPlayer.h      2013-06-12 16:46:43.000000000 +0200
  3193. +++ xbmc_vidonme/xbmc/cores/IPlayer.h   2013-06-12 16:40:35.000000000 +0200
  3194. @@ -229,6 +229,9 @@
  3195.     */
  3196.    virtual void GetSubtitleCapabilities(std::vector<int> &subCaps) { subCaps.assign(1,IPC_SUBS_ALL); };
  3197.  
  3198. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  3199. +  virtual void OnA10Created(){return;}
  3200. +#endif
  3201.  protected:
  3202.    IPlayerCallback& m_callback;
  3203.  };
  3204. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp xbmc_vidonme/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp
  3205. --- xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp    1970-01-01 01:00:00.000000000 +0100
  3206. +++ xbmc_vidonme/xbmc/cores/VideoRenderers/LinuxRendererA10.cpp 2013-06-12 16:40:35.000000000 +0200
  3207. @@ -0,0 +1,2007 @@
  3208. +/*
  3209. + *      Copyright (C) 2010-2012 Team XBMC
  3210. + *      http://www.xbmc.org
  3211. + *
  3212. + *  This Program is free software; you can redistribute it and/or modify
  3213. + *  it under the terms of the GNU General Public License as published by
  3214. + *  the Free Software Foundation; either version 2, or (at your option)
  3215. + *  any later version.
  3216. + *
  3217. + *  This Program is distributed in the hope that it will be useful,
  3218. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  3219. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3220. + *  GNU General Public License for more details.
  3221. + *
  3222. + *  You should have received a copy of the GNU General Public License
  3223. + *  along with XBMC; see the file COPYING.  If not, see
  3224. + *  <http://www.gnu.org/licenses/>.
  3225. + *
  3226. + */
  3227. +
  3228. +#include "system.h"
  3229. +#if (defined HAVE_CONFIG_H) && (!defined WIN32)
  3230. +  #include "config.h"
  3231. +#endif
  3232. +
  3233. +#if HAS_GLES == 2
  3234. +#include "system_gl.h"
  3235. +
  3236. +#include <locale.h>
  3237. +#include <sys/ioctl.h>
  3238. +#include "guilib/MatrixGLES.h"
  3239. +#include "LinuxRendererA10.h"
  3240. +#include "utils/log.h"
  3241. +#include "utils/fastmemcpy.h"
  3242. +#include "utils/MathUtils.h"
  3243. +#include "utils/GLUtils.h"
  3244. +#include "settings/Settings.h"
  3245. +#include "settings/AdvancedSettings.h"
  3246. +#include "settings/GUISettings.h"
  3247. +#include "guilib/FrameBufferObject.h"
  3248. +#include "VideoShaders/YUV2RGBShader.h"
  3249. +#include "VideoShaders/VideoFilterShader.h"
  3250. +#include "windowing/WindowingFactory.h"
  3251. +#include "dialogs/GUIDialogKaiToast.h"
  3252. +#include "guilib/Texture.h"
  3253. +#include "threads/SingleLock.h"
  3254. +#include "RenderCapture.h"
  3255. +#include "RenderFormats.h"
  3256. +#include "xbmc/Application.h"
  3257. +
  3258. +#include "cores/a10/libcedarv.h"
  3259. +#include "cores/a10/DllLibcedarv.h"
  3260. +
  3261. +extern DllLibA10decoder g_libbdv;
  3262. +
  3263. +using namespace Shaders;
  3264. +
  3265. +CLinuxRendererA10::CLinuxRendererA10()
  3266. +{
  3267. +  m_textureTarget = GL_TEXTURE_2D;
  3268. +
  3269. +  for (int i = 0; i < NUM_BUFFERS; i++)
  3270. +  {
  3271. +    m_eventTexturesDone[i] = new CEvent(false,true);
  3272. +    memset(&m_buffers, 0, sizeof(m_buffers));
  3273. +  }
  3274. +
  3275. +  m_renderMethod = RENDER_GLSL;
  3276. +  m_oldRenderMethod = m_renderMethod;
  3277. +  m_renderQuality = RQ_SINGLEPASS;
  3278. +  m_iFlags = 0;
  3279. +  m_format = RENDER_FMT_NONE;
  3280. +
  3281. +  m_iYV12RenderBuffer = 0;
  3282. +  m_flipindex = 0;
  3283. +  m_currentField = FIELD_FULL;
  3284. +  m_reloadShaders = 0;
  3285. +  m_pYUVShader = NULL;
  3286. +  m_pVideoFilterShader = NULL;
  3287. +  m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
  3288. +  m_scalingMethodGui = (ESCALINGMETHOD)-1;
  3289. +
  3290. +  // default texture handlers to YUV
  3291. +  m_textureUpload = &CLinuxRendererA10::UploadYV12Texture;
  3292. +  m_textureCreate = &CLinuxRendererA10::CreateYV12Texture;
  3293. +  m_textureDelete = &CLinuxRendererA10::DeleteYV12Texture;
  3294. +
  3295. +  //check libbdv dll is loaded
  3296. +
  3297. +  if( !g_libbdv.IsLoaded() )
  3298. +  {
  3299. +         g_libbdv.EnableDelayedUnload(false);
  3300. +         if( !g_libbdv.Load() )
  3301. +                 CLog::Log(LOGERROR, "Load codec failed !");
  3302. +  }
  3303. +
  3304. +}
  3305. +
  3306. +CLinuxRendererA10::~CLinuxRendererA10()
  3307. +{
  3308. +  UnInit();
  3309. +  for (int i = 0; i < NUM_BUFFERS; i++)
  3310. +    delete m_eventTexturesDone[i];
  3311. +
  3312. +  if (m_pYUVShader)
  3313. +  {
  3314. +    m_pYUVShader->Free();
  3315. +    delete m_pYUVShader;
  3316. +    m_pYUVShader = NULL;
  3317. +  }
  3318. +}
  3319. +
  3320. +void CLinuxRendererA10::ManageTextures()
  3321. +{
  3322. +  //m_iYV12RenderBuffer = 0;
  3323. +  return;
  3324. +}
  3325. +
  3326. +bool CLinuxRendererA10::ValidateRenderTarget()
  3327. +{
  3328. +  if (!m_bValidated)
  3329. +  {
  3330. +    CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
  3331. +
  3332. +     // create the yuv textures
  3333. +    LoadShaders();
  3334. +
  3335. +    for (int i = 0 ; i < NUM_BUFFERS ; i++)
  3336. +      (this->*m_textureCreate)(i);
  3337. +
  3338. +    m_bValidated = true;
  3339. +    return true;
  3340. +  }
  3341. +  return false;
  3342. +}
  3343. +
  3344. +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)
  3345. +{
  3346. +  m_sourceWidth = width;
  3347. +  m_sourceHeight = height;
  3348. +  m_renderOrientation = orientation;
  3349. +
  3350. +  // Save the flags.
  3351. +  m_iFlags = flags;
  3352. +  m_format = format;
  3353. +
  3354. +  // Calculate the input frame aspect ratio.
  3355. +  CalculateFrameAspectRatio(d_width, d_height);
  3356. +  ChooseBestResolution(fps);
  3357. +  SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode);
  3358. +  ManageDisplay();
  3359. +
  3360. +  m_bConfigured = true;
  3361. +  m_bImageReady = false;
  3362. +  m_scalingMethodGui = (ESCALINGMETHOD)-1;
  3363. +
  3364. +  m_bValidated = false;
  3365. +
  3366. +  for (int i = 0 ; i< NUM_BUFFERS; i++)
  3367. +    m_buffers[i].image.flags = 0;
  3368. +
  3369. +  m_iLastRenderBuffer = -1;
  3370. +
  3371. +  m_RenderUpdateCallBackFn = NULL;
  3372. +  m_RenderUpdateCallBackCtx = NULL;
  3373. +  if ((m_format == RENDER_FMT_BYPASS) && g_application.GetCurrentPlayer())
  3374. +  {
  3375. +    //TODO
  3376. +  }
  3377. +
  3378. +  return true;
  3379. +}
  3380. +
  3381. +int CLinuxRendererA10::NextYV12Texture()
  3382. +{
  3383. +  return (m_iYV12RenderBuffer + 1) % NUM_BUFFERS;
  3384. +}
  3385. +
  3386. +int CLinuxRendererA10::GetImage(YV12Image *image, int source, bool readonly)
  3387. +{
  3388. +  if (!image) return -1;
  3389. +  if (!m_bValidated) return -1;
  3390. +
  3391. +  /* take next available buffer */
  3392. +  if( source == AUTOSOURCE )
  3393. +   source = NextYV12Texture();
  3394. +
  3395. +  if (m_renderMethod & RENDER_A10BUF )
  3396. +  {
  3397. +    return source;
  3398. +  }
  3399. +
  3400. +  YV12Image &im = m_buffers[source].image;
  3401. +
  3402. +  if ((im.flags&(~IMAGE_FLAG_READY)) != 0)
  3403. +  {
  3404. +     CLog::Log(LOGDEBUG, "CLinuxRenderer::GetImage - request image but none to give");
  3405. +     return -1;
  3406. +  }
  3407. +
  3408. +  if( readonly )
  3409. +    im.flags |= IMAGE_FLAG_READING;
  3410. +  else
  3411. +  {
  3412. +    if( !m_eventTexturesDone[source]->WaitMSec(500) )
  3413. +      CLog::Log(LOGWARNING, "%s - Timeout waiting for texture %d", __FUNCTION__, source);
  3414. +
  3415. +    im.flags |= IMAGE_FLAG_WRITING;
  3416. +  }
  3417. +
  3418. +  // copy the image - should be operator of YV12Image
  3419. +  for (int p=0;p<MAX_PLANES;p++)
  3420. +  {
  3421. +    image->plane[p]  = im.plane[p];
  3422. +    image->stride[p] = im.stride[p];
  3423. +  }
  3424. +  image->width    = im.width;
  3425. +  image->height   = im.height;
  3426. +  image->flags    = im.flags;
  3427. +  image->cshift_x = im.cshift_x;
  3428. +  image->cshift_y = im.cshift_y;
  3429. +  image->bpp      = 1;
  3430. +
  3431. +  return source;
  3432. +
  3433. +  return -1;
  3434. +}
  3435. +
  3436. +void CLinuxRendererA10::ReleaseImage(int source, bool preserve)
  3437. +{
  3438. +  YV12Image &im = m_buffers[source].image;
  3439. +
  3440. +  if( im.flags & IMAGE_FLAG_WRITING )
  3441. +    m_eventTexturesDone[source]->Set();
  3442. +
  3443. +  im.flags &= ~IMAGE_FLAG_INUSE;
  3444. +  im.flags |= IMAGE_FLAG_READY;
  3445. +  /* if image should be preserved reserve it so it's not auto seleceted */
  3446. +
  3447. +  if( preserve )
  3448. +    im.flags |= IMAGE_FLAG_RESERVED;
  3449. +
  3450. +  m_bImageReady = true;
  3451. +}
  3452. +
  3453. +void CLinuxRendererA10::CalculateTextureSourceRects(int source, int num_planes)
  3454. +{
  3455. +  YUVBUFFER& buf    =  m_buffers[source];
  3456. +  YV12Image* im     = &buf.image;
  3457. +  YUVFIELDS& fields =  buf.fields;
  3458. +
  3459. +  // calculate the source rectangle
  3460. +  for(int field = 0; field < 3; field++)
  3461. +  {
  3462. +    for(int plane = 0; plane < num_planes; plane++)
  3463. +    {
  3464. +      YUVPLANE& p = fields[field][plane];
  3465. +
  3466. +      p.rect = m_sourceRect;
  3467. +      p.width  = im->width;
  3468. +      p.height = im->height;
  3469. +
  3470. +      if(field != FIELD_FULL)
  3471. +      {
  3472. +        /* correct for field offsets and chroma offsets */
  3473. +        float offset_y = 0.5;
  3474. +        if(plane != 0)
  3475. +          offset_y += 0.5;
  3476. +        if(field == FIELD_BOT)
  3477. +          offset_y *= -1;
  3478. +
  3479. +        p.rect.y1 += offset_y;
  3480. +        p.rect.y2 += offset_y;
  3481. +
  3482. +        /* half the height if this is a field */
  3483. +        p.height  *= 0.5f;
  3484. +        p.rect.y1 *= 0.5f;
  3485. +        p.rect.y2 *= 0.5f;
  3486. +      }
  3487. +
  3488. +      if(plane != 0)
  3489. +      {
  3490. +        p.width   /= 1 << im->cshift_x;
  3491. +        p.height  /= 1 << im->cshift_y;
  3492. +
  3493. +        p.rect.x1 /= 1 << im->cshift_x;
  3494. +        p.rect.x2 /= 1 << im->cshift_x;
  3495. +        p.rect.y1 /= 1 << im->cshift_y;
  3496. +        p.rect.y2 /= 1 << im->cshift_y;
  3497. +      }
  3498. +
  3499. +      if (m_textureTarget == GL_TEXTURE_2D)
  3500. +      {
  3501. +        p.height  /= p.texheight;
  3502. +        p.rect.y1 /= p.texheight;
  3503. +        p.rect.y2 /= p.texheight;
  3504. +        p.width   /= p.texwidth;
  3505. +        p.rect.x1 /= p.texwidth;
  3506. +        p.rect.x2 /= p.texwidth;
  3507. +      }
  3508. +    }
  3509. +  }
  3510. +}
  3511. +
  3512. +void CLinuxRendererA10::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
  3513. +                                , unsigned width, unsigned height
  3514. +                                , int stride, void* data )
  3515. +{
  3516. +  if(plane.flipindex == flipindex)
  3517. +    return;
  3518. +
  3519. +  const GLvoid *pixelData = data;
  3520. +
  3521. +  int bps = glFormatElementByteCount(type);
  3522. +
  3523. +  glBindTexture(m_textureTarget, plane.id);
  3524. +
  3525. +  // OpenGL ES does not support strided texture input.
  3526. +  if(stride != width * bps)
  3527. +  {
  3528. +    unsigned char* src = (unsigned char*)data;
  3529. +    for (int y = 0; y < height;++y, src += stride)
  3530. +      glTexSubImage2D(m_textureTarget, 0, 0, y, width, 1, type, GL_UNSIGNED_BYTE, src);
  3531. +  } else {
  3532. +    glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, pixelData);
  3533. +  }
  3534. +
  3535. +  /* check if we need to load any border pixels */
  3536. +  if(height < plane.texheight)
  3537. +    glTexSubImage2D( m_textureTarget, 0
  3538. +                   , 0, height, width, 1
  3539. +                   , type, GL_UNSIGNED_BYTE
  3540. +                   , (unsigned char*)pixelData + stride * (height-1));
  3541. +
  3542. +  if(width  < plane.texwidth)
  3543. +    glTexSubImage2D( m_textureTarget, 0
  3544. +                   , width, 0, 1, height
  3545. +                   , type, GL_UNSIGNED_BYTE
  3546. +                   , (unsigned char*)pixelData + bps * (width-1));
  3547. +
  3548. +  glBindTexture(m_textureTarget, 0);
  3549. +
  3550. +  plane.flipindex = flipindex;
  3551. +}
  3552. +
  3553. +void CLinuxRendererA10::Reset()
  3554. +{
  3555. +  for(int i=0; i<NUM_BUFFERS; i++)
  3556. +  {
  3557. +    /* reset all image flags, this will cleanup textures later */
  3558. +    m_buffers[i].image.flags = 0;
  3559. +    /* reset texture locks, a bit ugly, could result in tearing */
  3560. +    m_eventTexturesDone[i]->Set();
  3561. +  }
  3562. +}
  3563. +
  3564. +void CLinuxRendererA10::Update(bool bPauseDrawing)
  3565. +{
  3566. +  if (!m_bConfigured) return;
  3567. +  ManageDisplay();
  3568. +  ManageTextures();
  3569. +}
  3570. +
  3571. +void CLinuxRendererA10::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
  3572. +{
  3573. +  if (!m_bConfigured) return;
  3574. +
  3575. +  // if its first pass, just init textures and return
  3576. +  if (ValidateRenderTarget())
  3577. +    return;
  3578. +
  3579. +  if (m_renderMethod & RENDER_BYPASS)
  3580. +  {
  3581. +    ManageDisplay();
  3582. +    ManageTextures();
  3583. +    // if running bypass, then the player might need the src/dst rects
  3584. +    // for sizing video playback on a layer other than the gles layer.
  3585. +    if (m_RenderUpdateCallBackFn)
  3586. +      (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect);
  3587. +
  3588. +    g_graphicsContext.BeginPaint();
  3589. +
  3590. +    glEnable(GL_BLEND);
  3591. +    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  3592. +    glClearColor(0, 0, 0, 0);
  3593. +    glClear(GL_COLOR_BUFFER_BIT);
  3594. +
  3595. +    g_graphicsContext.EndPaint();
  3596. +    return;
  3597. +  }
  3598. +  else if (m_renderMethod & RENDER_A10BUF)
  3599. +  {
  3600. +    ManageDisplay();
  3601. +    ManageTextures();
  3602. +
  3603. +    if (m_RenderUpdateCallBackFn)
  3604. +      (*m_RenderUpdateCallBackFn)(m_RenderUpdateCallBackCtx, m_sourceRect, m_destRect);
  3605. +
  3606. +      g_graphicsContext.BeginPaint();
  3607. +
  3608. +      glEnable(GL_BLEND);
  3609. +      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  3610. +      glClearColor(0.0/255, 0.0/255, 0.0/255, 0);
  3611. +      glClear(GL_COLOR_BUFFER_BIT);
  3612. +      glClearColor(0, 0, 0, 0);
  3613. +
  3614. +      g_graphicsContext.EndPaint();
  3615. +  }
  3616. +
  3617. +  // this needs to be checked after texture validation
  3618. +  if (!m_bImageReady) return;
  3619. +
  3620. +  int index = m_iYV12RenderBuffer;
  3621. +  YUVBUFFER& buf =  m_buffers[index];
  3622. +
  3623. +  if (m_renderMethod & RENDER_A10BUF)
  3624. +  {
  3625. +    A10VLDisplayQueueItem(buf.a10buffer, m_sourceRect, m_destRect);
  3626. +    m_iLastRenderBuffer = index;
  3627. +    VerifyGLState();
  3628. +    return;
  3629. +  }
  3630. +
  3631. +  if (!buf.fields[FIELD_FULL][0].id || !buf.image.flags) return;
  3632. +
  3633. +  ManageDisplay();
  3634. +  ManageTextures();
  3635. +
  3636. +  g_graphicsContext.BeginPaint();
  3637. +
  3638. +  if( !m_eventTexturesDone[index]->WaitMSec(500))
  3639. +  {
  3640. +    CLog::Log(LOGWARNING, "%s - Timeout waiting for texture %d", __FUNCTION__, index);
  3641. +
  3642. +    // render the previous frame if this one isn't ready yet
  3643. +    if (m_iLastRenderBuffer > -1)
  3644. +    {
  3645. +      m_iYV12RenderBuffer = m_iLastRenderBuffer;
  3646. +      index = m_iYV12RenderBuffer;
  3647. +    }
  3648. +  }
  3649. +  else
  3650. +    m_iLastRenderBuffer = index;
  3651. +
  3652. +  if (clear)
  3653. +  {
  3654. +    glClearColor(m_clearColour, m_clearColour, m_clearColour, 0);
  3655. +    glClear(GL_COLOR_BUFFER_BIT);
  3656. +    glClearColor(0,0,0,0);
  3657. +  }
  3658. +
  3659. +  if (alpha<255)
  3660. +  {
  3661. +    glEnable(GL_BLEND);
  3662. +    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  3663. +    if (m_pYUVShader)
  3664. +      m_pYUVShader->SetAlpha(alpha / 255.0f);
  3665. +  }
  3666. +  else
  3667. +  {
  3668. +    glDisable(GL_BLEND);
  3669. +    if (m_pYUVShader)
  3670. +      m_pYUVShader->SetAlpha(1.0f);
  3671. +  }
  3672. +
  3673. +  if ((flags & RENDER_FLAG_TOP) && (flags & RENDER_FLAG_BOT))
  3674. +    CLog::Log(LOGERROR, "GLES: Cannot render stipple!");
  3675. +  else
  3676. +    Render(flags, index);
  3677. +
  3678. +  VerifyGLState();
  3679. +  glEnable(GL_BLEND);
  3680. +
  3681. +  g_graphicsContext.EndPaint();
  3682. +}
  3683. +
  3684. +void CLinuxRendererA10::FlipPage(int source)
  3685. +{
  3686. +  if( source >= 0 && source < NUM_BUFFERS )
  3687. +    m_iYV12RenderBuffer = source;
  3688. +  else
  3689. +    m_iYV12RenderBuffer = NextYV12Texture();
  3690. +
  3691. +  m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
  3692. +
  3693. +  return;
  3694. +}
  3695. +
  3696. +unsigned int CLinuxRendererA10::PreInit()
  3697. +{
  3698. +  CSingleLock lock(g_graphicsContext);
  3699. +  m_bConfigured = false;
  3700. +  m_bValidated = false;
  3701. +  UnInit();
  3702. +  m_resolution = g_guiSettings.m_LookAndFeelResolution;
  3703. +  if ( m_resolution == RES_WINDOW )
  3704. +    m_resolution = RES_DESKTOP;
  3705. +
  3706. +  m_iYV12RenderBuffer = 0;
  3707. +
  3708. +  m_formats.push_back(RENDER_FMT_YUV420P);
  3709. +  m_formats.push_back(RENDER_FMT_BYPASS);
  3710. +  m_formats.push_back(RENDER_FMT_A10BUF);
  3711. +
  3712. +  // setup the background colour
  3713. +  m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
  3714. +
  3715. +  return true;
  3716. +}
  3717. +
  3718. +void CLinuxRendererA10::UpdateVideoFilter()
  3719. +{
  3720. +  if (m_scalingMethodGui == g_settings.m_currentVideoSettings.m_ScalingMethod)
  3721. +    return;
  3722. +  m_scalingMethodGui = g_settings.m_currentVideoSettings.m_ScalingMethod;
  3723. +  m_scalingMethod    = m_scalingMethodGui;
  3724. +
  3725. +  if(!Supports(m_scalingMethod))
  3726. +  {
  3727. +    CLog::Log(LOGWARNING, "CLinuxRendererA10::UpdateVideoFilter - choosen scaling method %d, is not supported by renderer", (int)m_scalingMethod);
  3728. +    m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
  3729. +  }
  3730. +
  3731. +  if (m_pVideoFilterShader)
  3732. +  {
  3733. +    m_pVideoFilterShader->Free();
  3734. +    delete m_pVideoFilterShader;
  3735. +    m_pVideoFilterShader = NULL;
  3736. +  }
  3737. +  m_fbo.Cleanup();
  3738. +
  3739. +  VerifyGLState();
  3740. +
  3741. +  switch (m_scalingMethod)
  3742. +  {
  3743. +  case VS_SCALINGMETHOD_NEAREST:
  3744. +    SetTextureFilter(GL_NEAREST);
  3745. +    m_renderQuality = RQ_SINGLEPASS;
  3746. +    return;
  3747. +
  3748. +  case VS_SCALINGMETHOD_LINEAR:
  3749. +    SetTextureFilter(GL_LINEAR);
  3750. +    m_renderQuality = RQ_SINGLEPASS;
  3751. +    return;
  3752. +
  3753. +  case VS_SCALINGMETHOD_CUBIC:
  3754. +    CLog::Log(LOGERROR, "GLES: CUBIC not supported!");
  3755. +    break;
  3756. +
  3757. +  case VS_SCALINGMETHOD_LANCZOS2:
  3758. +  case VS_SCALINGMETHOD_LANCZOS3:
  3759. +  case VS_SCALINGMETHOD_SINC8:
  3760. +  case VS_SCALINGMETHOD_NEDI:
  3761. +    CLog::Log(LOGERROR, "GL: TODO: This scaler has not yet been implemented");
  3762. +    break;
  3763. +
  3764. +  default:
  3765. +    break;
  3766. +  }
  3767. +
  3768. +  CGUIDialogKaiToast::QueueNotification("Video Renderering", "Failed to init video filters/scalers, falling back to bilinear scaling");
  3769. +  CLog::Log(LOGERROR, "GL: Falling back to bilinear due to failure to init scaler");
  3770. +  if (m_pVideoFilterShader)
  3771. +  {
  3772. +    m_pVideoFilterShader->Free();
  3773. +    delete m_pVideoFilterShader;
  3774. +    m_pVideoFilterShader = NULL;
  3775. +  }
  3776. +  m_fbo.Cleanup();
  3777. +
  3778. +  SetTextureFilter(GL_LINEAR);
  3779. +  m_renderQuality = RQ_SINGLEPASS;
  3780. +}
  3781. +
  3782. +void CLinuxRendererA10::LoadShaders(int field)
  3783. +{
  3784. +  int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod");
  3785. +  CLog::Log(LOGDEBUG, "GL: Requested render method: %d", requestedMethod);
  3786. +
  3787. +  if (m_pYUVShader)
  3788. +  {
  3789. +    m_pYUVShader->Free();
  3790. +    delete m_pYUVShader;
  3791. +    m_pYUVShader = NULL;
  3792. +  }
  3793. +
  3794. +  switch(requestedMethod)
  3795. +  {
  3796. +    case RENDER_METHOD_AUTO:
  3797. +    case RENDER_METHOD_GLSL:
  3798. +      if (m_format == RENDER_FMT_A10BUF)
  3799. +      {
  3800. +        CLog::Log(LOGNOTICE, "using A10 render method");
  3801. +        m_renderMethod = RENDER_A10BUF;
  3802. +        break;
  3803. +      }
  3804. +      // Try GLSL shaders if supported and user requested auto or GLSL.
  3805. +      // create regular progressive scan shader
  3806. +      m_pYUVShader = new YUV2RGBProgressiveShader(false, m_iFlags, m_format);
  3807. +      CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader");
  3808. +
  3809. +      if (m_pYUVShader && m_pYUVShader->CompileAndLink())
  3810. +      {
  3811. +        m_renderMethod = RENDER_GLSL;
  3812. +        UpdateVideoFilter();
  3813. +        break;
  3814. +      }
  3815. +      else
  3816. +      {
  3817. +        m_pYUVShader->Free();
  3818. +        delete m_pYUVShader;
  3819. +        m_pYUVShader = NULL;
  3820. +        CLog::Log(LOGERROR, "GL: Error enabling YUV2RGB GLSL shader");
  3821. +      }
  3822. +      break;
  3823. +    default:
  3824. +      // Use software YUV 2 RGB conversion if user requested it or GLSL failed
  3825. +      CLog::Log(LOGERROR, "no software rendering.");
  3826. +      break;
  3827. +  }
  3828. +
  3829. +  // Now that we now the render method, setup texture function handlers
  3830. +  if (m_format == RENDER_FMT_BYPASS || m_format == RENDER_FMT_A10BUF)
  3831. +  {
  3832. +    m_textureUpload = &CLinuxRendererA10::UploadBYPASSTexture;
  3833. +    m_textureCreate = &CLinuxRendererA10::CreateBYPASSTexture;
  3834. +    m_textureDelete = &CLinuxRendererA10::DeleteBYPASSTexture;
  3835. +  }
  3836. +  else
  3837. +  {
  3838. +    // default to YV12 texture handlers
  3839. +    m_textureUpload = &CLinuxRendererA10::UploadYV12Texture;
  3840. +    m_textureCreate = &CLinuxRendererA10::CreateYV12Texture;
  3841. +    m_textureDelete = &CLinuxRendererA10::DeleteYV12Texture;
  3842. +  }
  3843. +
  3844. +  if (m_oldRenderMethod != m_renderMethod)
  3845. +  {
  3846. +    CLog::Log(LOGDEBUG, "CLinuxRendererA10: Reorder drawpoints due to method change from %i to %i", m_oldRenderMethod, m_renderMethod);
  3847. +    ReorderDrawPoints();
  3848. +    m_oldRenderMethod = m_renderMethod;
  3849. +  }
  3850. +}
  3851. +
  3852. +void CLinuxRendererA10::UnInit()
  3853. +{
  3854. +  CLog::Log(LOGDEBUG, "LinuxRendererGL: Cleaning up GL resources");
  3855. +  CSingleLock lock(g_graphicsContext);
  3856. +
  3857. +  A10VLHide();
  3858. +
  3859. +  // YV12 textures
  3860. +  for (int i = 0; i < NUM_BUFFERS; ++i)
  3861. +    (this->*m_textureDelete)(i);
  3862. +
  3863. +  // cleanup framebuffer object if it was in use
  3864. +  m_fbo.Cleanup();
  3865. +  m_bValidated = false;
  3866. +  m_bImageReady = false;
  3867. +  m_bConfigured = false;
  3868. +  m_RenderUpdateCallBackFn = NULL;
  3869. +  m_RenderUpdateCallBackCtx = NULL;
  3870. +}
  3871. +
  3872. +inline void CLinuxRendererA10::ReorderDrawPoints()
  3873. +{
  3874. +
  3875. +  CBaseRenderer::ReorderDrawPoints();//call base impl. for rotating the points
  3876. +}
  3877. +
  3878. +void CLinuxRendererA10::Render(DWORD flags, int index)
  3879. +{
  3880. +  // If rendered directly by the hardware
  3881. +  if (m_renderMethod & RENDER_BYPASS)
  3882. +    return;
  3883. +
  3884. +  // obtain current field, if interlaced
  3885. +  if( flags & RENDER_FLAG_TOP)
  3886. +    m_currentField = FIELD_TOP;
  3887. +
  3888. +  else if (flags & RENDER_FLAG_BOT)
  3889. +    m_currentField = FIELD_BOT;
  3890. +
  3891. +  else
  3892. +    m_currentField = FIELD_FULL;
  3893. +
  3894. +  (this->*m_textureUpload)(index);
  3895. +
  3896. +  if (m_renderMethod & RENDER_GLSL)
  3897. +  {
  3898. +    UpdateVideoFilter();
  3899. +    switch(m_renderQuality)
  3900. +    {
  3901. +    case RQ_LOW:
  3902. +    case RQ_SINGLEPASS:
  3903. +      RenderSinglePass(index, m_currentField);
  3904. +      VerifyGLState();
  3905. +      break;
  3906. +
  3907. +    case RQ_MULTIPASS:
  3908. +      RenderMultiPass(index, m_currentField);
  3909. +      VerifyGLState();
  3910. +      break;
  3911. +    }
  3912. +  }
  3913. +}
  3914. +
  3915. +void CLinuxRendererA10::RenderSinglePass(int index, int field)
  3916. +{
  3917. +  YV12Image &im     = m_buffers[index].image;
  3918. +  YUVFIELDS &fields = m_buffers[index].fields;
  3919. +  YUVPLANES &planes = fields[field];
  3920. +
  3921. +  if (m_reloadShaders)
  3922. +  {
  3923. +    m_reloadShaders = 0;
  3924. +    LoadShaders(field);
  3925. +  }
  3926. +
  3927. +  glDisable(GL_DEPTH_TEST);
  3928. +
  3929. +  // Y
  3930. +  glActiveTexture(GL_TEXTURE0);
  3931. +  glEnable(m_textureTarget);
  3932. +  glBindTexture(m_textureTarget, planes[0].id);
  3933. +
  3934. +  // U
  3935. +  glActiveTexture(GL_TEXTURE1);
  3936. +  glEnable(m_textureTarget);
  3937. +  glBindTexture(m_textureTarget, planes[1].id);
  3938. +
  3939. +  // V
  3940. +  glActiveTexture(GL_TEXTURE2);
  3941. +  glEnable(m_textureTarget);
  3942. +  glBindTexture(m_textureTarget, planes[2].id);
  3943. +
  3944. +  glActiveTexture(GL_TEXTURE0);
  3945. +  VerifyGLState();
  3946. +
  3947. +  m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f);
  3948. +  m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f);
  3949. +  m_pYUVShader->SetWidth(im.width);
  3950. +  m_pYUVShader->SetHeight(im.height);
  3951. +  if     (field == FIELD_TOP)
  3952. +    m_pYUVShader->SetField(1);
  3953. +  else if(field == FIELD_BOT)
  3954. +    m_pYUVShader->SetField(0);
  3955. +
  3956. +  m_pYUVShader->SetMatrices(g_matrices.GetMatrix(MM_PROJECTION), g_matrices.GetMatrix(MM_MODELVIEW));
  3957. +  m_pYUVShader->Enable();
  3958. +
  3959. +  GLubyte idx[4] = {0, 1, 3, 2};        //determines order of triangle strip
  3960. +  GLfloat m_vert[4][3];
  3961. +  GLfloat m_tex[3][4][2];
  3962. +
  3963. +  GLint vertLoc = m_pYUVShader->GetVertexLoc();
  3964. +  GLint Yloc    = m_pYUVShader->GetYcoordLoc();
  3965. +  GLint Uloc    = m_pYUVShader->GetUcoordLoc();
  3966. +  GLint Vloc    = m_pYUVShader->GetVcoordLoc();
  3967. +
  3968. +  glVertexAttribPointer(vertLoc, 3, GL_FLOAT, 0, 0, m_vert);
  3969. +  glVertexAttribPointer(Yloc, 2, GL_FLOAT, 0, 0, m_tex[0]);
  3970. +  glVertexAttribPointer(Uloc, 2, GL_FLOAT, 0, 0, m_tex[1]);
  3971. +  glVertexAttribPointer(Vloc, 2, GL_FLOAT, 0, 0, m_tex[2]);
  3972. +
  3973. +  glEnableVertexAttribArray(vertLoc);
  3974. +  glEnableVertexAttribArray(Yloc);
  3975. +  glEnableVertexAttribArray(Uloc);
  3976. +  glEnableVertexAttribArray(Vloc);
  3977. +
  3978. +  // Setup vertex position values
  3979. +  for(int i = 0; i < 4; i++)
  3980. +  {
  3981. +    m_vert[i][0] = m_rotatedDestCoords[i].x;
  3982. +    m_vert[i][1] = m_rotatedDestCoords[i].y;
  3983. +    m_vert[i][2] = 0.0f;// set z to 0
  3984. +  }
  3985. +
  3986. +  // Setup texture coordinates
  3987. +  for (int i=0; i<3; i++)
  3988. +  {
  3989. +    m_tex[i][0][0] = m_tex[i][3][0] = planes[i].rect.x1;
  3990. +    m_tex[i][0][1] = m_tex[i][1][1] = planes[i].rect.y1;
  3991. +    m_tex[i][1][0] = m_tex[i][2][0] = planes[i].rect.x2;
  3992. +    m_tex[i][2][1] = m_tex[i][3][1] = planes[i].rect.y2;
  3993. +  }
  3994. +
  3995. +  glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx);
  3996. +
  3997. +  VerifyGLState();
  3998. +
  3999. +  m_pYUVShader->Disable();
  4000. +  VerifyGLState();
  4001. +
  4002. +  glDisableVertexAttribArray(vertLoc);
  4003. +  glDisableVertexAttribArray(Yloc);
  4004. +  glDisableVertexAttribArray(Uloc);
  4005. +  glDisableVertexAttribArray(Vloc);
  4006. +
  4007. +  glActiveTexture(GL_TEXTURE1);
  4008. +  glDisable(m_textureTarget);
  4009. +
  4010. +  glActiveTexture(GL_TEXTURE2);
  4011. +  glDisable(m_textureTarget);
  4012. +
  4013. +  glActiveTexture(GL_TEXTURE0);
  4014. +  glDisable(m_textureTarget);
  4015. +
  4016. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4017. +
  4018. +  VerifyGLState();
  4019. +}
  4020. +
  4021. +void CLinuxRendererA10::RenderMultiPass(int index, int field)
  4022. +{
  4023. +  // TODO: Multipass rendering does not currently work! FIX!
  4024. +  CLog::Log(LOGERROR, "GLES: MULTIPASS rendering was called! But it doesnt work!!!");
  4025. +  return;
  4026. +
  4027. +  YV12Image &im     = m_buffers[index].image;
  4028. +  YUVPLANES &planes = m_buffers[index].fields[field];
  4029. +
  4030. +  if (m_reloadShaders)
  4031. +  {
  4032. +    m_reloadShaders = 0;
  4033. +    LoadShaders(m_currentField);
  4034. +  }
  4035. +
  4036. +  glDisable(GL_DEPTH_TEST);
  4037. +
  4038. +  // Y
  4039. +  glEnable(m_textureTarget);
  4040. +  glActiveTexture(GL_TEXTURE0);
  4041. +  glBindTexture(m_textureTarget, planes[0].id);
  4042. +  VerifyGLState();
  4043. +
  4044. +  // U
  4045. +  glActiveTexture(GL_TEXTURE1);
  4046. +  glEnable(m_textureTarget);
  4047. +  glBindTexture(m_textureTarget, planes[1].id);
  4048. +  VerifyGLState();
  4049. +
  4050. +  // V
  4051. +  glActiveTexture(GL_TEXTURE2);
  4052. +  glEnable(m_textureTarget);
  4053. +  glBindTexture(m_textureTarget, planes[2].id);
  4054. +  VerifyGLState();
  4055. +
  4056. +  glActiveTexture(GL_TEXTURE0);
  4057. +  VerifyGLState();
  4058. +
  4059. +  // make sure the yuv shader is loaded and ready to go
  4060. +  if (!m_pYUVShader || (!m_pYUVShader->OK()))
  4061. +  {
  4062. +    CLog::Log(LOGERROR, "GL: YUV shader not active, cannot do multipass render");
  4063. +    return;
  4064. +  }
  4065. +
  4066. +  m_fbo.BeginRender();
  4067. +  VerifyGLState();
  4068. +
  4069. +  m_pYUVShader->SetBlack(g_settings.m_currentVideoSettings.m_Brightness * 0.01f - 0.5f);
  4070. +  m_pYUVShader->SetContrast(g_settings.m_currentVideoSettings.m_Contrast * 0.02f);
  4071. +  m_pYUVShader->SetWidth(im.width);
  4072. +  m_pYUVShader->SetHeight(im.height);
  4073. +  if     (field == FIELD_TOP)
  4074. +    m_pYUVShader->SetField(1);
  4075. +  else if(field == FIELD_BOT)
  4076. +    m_pYUVShader->SetField(0);
  4077. +
  4078. +  VerifyGLState();
  4079. +//TODO
  4080. +//  glPushAttrib(GL_VIEWPORT_BIT);
  4081. +//  glPushAttrib(GL_SCISSOR_BIT);
  4082. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4083. +  g_matrices.PushMatrix();
  4084. +  g_matrices.LoadIdentity();
  4085. +  VerifyGLState();
  4086. +
  4087. +  g_matrices.MatrixMode(MM_PROJECTION);
  4088. +  g_matrices.PushMatrix();
  4089. +  g_matrices.LoadIdentity();
  4090. +  VerifyGLState();
  4091. +  g_matrices.Ortho2D(0, m_sourceWidth, 0, m_sourceHeight);
  4092. +  glViewport(0, 0, m_sourceWidth, m_sourceHeight);
  4093. +  glScissor(0, 0, m_sourceWidth, m_sourceHeight);
  4094. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4095. +  VerifyGLState();
  4096. +
  4097. +
  4098. +  if (!m_pYUVShader->Enable())
  4099. +  {
  4100. +    CLog::Log(LOGERROR, "GL: Error enabling YUV shader");
  4101. +  }
  4102. +
  4103. +  float imgwidth  = planes[0].rect.x2 - planes[0].rect.x1;
  4104. +  float imgheight = planes[0].rect.y2 - planes[0].rect.y1;
  4105. +  if (m_textureTarget == GL_TEXTURE_2D)
  4106. +  {
  4107. +    imgwidth  *= planes[0].texwidth;
  4108. +    imgheight *= planes[0].texheight;
  4109. +  }
  4110. +
  4111. +  // 1st Pass to video frame size
  4112. +//TODO
  4113. +//  glBegin(GL_QUADS);
  4114. +//
  4115. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y1);
  4116. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y1);
  4117. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y1);
  4118. +//  glVertex2f(0.0f    , 0.0f);
  4119. +//
  4120. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y1);
  4121. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y1);
  4122. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y1);
  4123. +//  glVertex2f(imgwidth, 0.0f);
  4124. +//
  4125. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x2, planes[0].rect.y2);
  4126. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x2, planes[1].rect.y2);
  4127. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x2, planes[2].rect.y2);
  4128. +//  glVertex2f(imgwidth, imgheight);
  4129. +//
  4130. +//  glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y2);
  4131. +//  glMultiTexCoord2fARB(GL_TEXTURE1, planes[1].rect.x1, planes[1].rect.y2);
  4132. +//  glMultiTexCoord2fARB(GL_TEXTURE2, planes[2].rect.x1, planes[2].rect.y2);
  4133. +//  glVertex2f(0.0f    , imgheight);
  4134. +//
  4135. +//  glEnd();
  4136. +//  VerifyGLState();
  4137. +
  4138. +  m_pYUVShader->Disable();
  4139. +
  4140. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4141. +  g_matrices.PopMatrix(); // pop modelview
  4142. +  g_matrices.MatrixMode(MM_PROJECTION);
  4143. +  g_matrices.PopMatrix(); // pop projection
  4144. +//TODO
  4145. +//  glPopAttrib(); // pop scissor
  4146. +//  glPopAttrib(); // pop viewport
  4147. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4148. +  VerifyGLState();
  4149. +
  4150. +  m_fbo.EndRender();
  4151. +
  4152. +  glActiveTexture(GL_TEXTURE1);
  4153. +  glDisable(m_textureTarget);
  4154. +  glActiveTexture(GL_TEXTURE2);
  4155. +  glDisable(m_textureTarget);
  4156. +  glActiveTexture(GL_TEXTURE0);
  4157. +  glDisable(m_textureTarget);
  4158. +
  4159. +  glEnable(GL_TEXTURE_2D);
  4160. +  glBindTexture(GL_TEXTURE_2D, m_fbo.Texture());
  4161. +  VerifyGLState();
  4162. +
  4163. +  // Use regular normalized texture coordinates
  4164. +
  4165. +  // 2nd Pass to screen size with optional video filter
  4166. +
  4167. +  if (m_pVideoFilterShader)
  4168. +  {
  4169. +    m_fbo.SetFiltering(GL_TEXTURE_2D, GL_NEAREST);
  4170. +    m_pVideoFilterShader->SetSourceTexture(0);
  4171. +    m_pVideoFilterShader->SetWidth(m_sourceWidth);
  4172. +    m_pVideoFilterShader->SetHeight(m_sourceHeight);
  4173. +    m_pVideoFilterShader->Enable();
  4174. +  }
  4175. +  else
  4176. +    m_fbo.SetFiltering(GL_TEXTURE_2D, GL_LINEAR);
  4177. +
  4178. +  VerifyGLState();
  4179. +
  4180. +  imgwidth  /= m_sourceWidth;
  4181. +  imgheight /= m_sourceHeight;
  4182. +
  4183. +//TODO
  4184. +//  glBegin(GL_QUADS);
  4185. +//
  4186. +//  glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f    , 0.0f);
  4187. +//  glVertex4f(m_destRect.x1, m_destRect.y1, 0, 1.0f );
  4188. +//
  4189. +//  glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, 0.0f);
  4190. +//  glVertex4f(m_destRect.x2, m_destRect.y1, 0, 1.0f);
  4191. +//
  4192. +//  glMultiTexCoord2fARB(GL_TEXTURE0, imgwidth, imgheight);
  4193. +//  glVertex4f(m_destRect.x2, m_destRect.y2, 0, 1.0f);
  4194. +//
  4195. +//  glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f    , imgheight);
  4196. +//  glVertex4f(m_destRect.x1, m_destRect.y2, 0, 1.0f);
  4197. +//
  4198. +//  glEnd();
  4199. +
  4200. +  VerifyGLState();
  4201. +
  4202. +  if (m_pVideoFilterShader)
  4203. +    m_pVideoFilterShader->Disable();
  4204. +
  4205. +  VerifyGLState();
  4206. +
  4207. +  glDisable(m_textureTarget);
  4208. +  VerifyGLState();
  4209. +}
  4210. +
  4211. +bool CLinuxRendererA10::RenderCapture(CRenderCapture* capture)
  4212. +{
  4213. +  if (!m_bValidated)
  4214. +    return false;
  4215. +
  4216. +  // save current video rect
  4217. +  CRect saveSize = m_destRect;
  4218. +  saveRotatedCoords();//backup current m_rotatedDestCoords
  4219. +
  4220. +  // new video rect is thumbnail size
  4221. +  m_destRect.SetRect(0, 0, (float)capture->GetWidth(), (float)capture->GetHeight());
  4222. +  syncDestRectToRotatedPoints();//syncs the changed destRect to m_rotatedDestCoords
  4223. +  // clear framebuffer and invert Y axis to get non-inverted image
  4224. +  glDisable(GL_BLEND);
  4225. +
  4226. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4227. +  g_matrices.PushMatrix();
  4228. +  g_matrices.Translatef(0.0f, capture->GetHeight(), 0.0f);
  4229. +  g_matrices.Scalef(1.0f, -1.0f, 1.0f);
  4230. +
  4231. +  capture->BeginRender();
  4232. +
  4233. +  Render(RENDER_FLAG_NOOSD, m_iYV12RenderBuffer);
  4234. +  // read pixels
  4235. +  glReadPixels(0, g_graphicsContext.GetHeight() - capture->GetHeight(), capture->GetWidth(), capture->GetHeight(),
  4236. +               GL_RGBA, GL_UNSIGNED_BYTE, capture->GetRenderBuffer());
  4237. +
  4238. +  // OpenGLES returns in RGBA order but CRenderCapture needs BGRA order
  4239. +  // XOR Swap RGBA -> BGRA
  4240. +  unsigned char* pixels = (unsigned char*)capture->GetRenderBuffer();
  4241. +  for (int i = 0; i < capture->GetWidth() * capture->GetHeight(); i++, pixels+=4)
  4242. +  {
  4243. +    std::swap(pixels[0], pixels[2]);
  4244. +  }
  4245. +
  4246. +  capture->EndRender();
  4247. +
  4248. +  // revert model view matrix
  4249. +  g_matrices.MatrixMode(MM_MODELVIEW);
  4250. +  g_matrices.PopMatrix();
  4251. +
  4252. +  // restore original video rect
  4253. +  m_destRect = saveSize;
  4254. +  restoreRotatedCoords();//restores the previous state of the rotated dest coords
  4255. +
  4256. +  return true;
  4257. +}
  4258. +
  4259. +//********************************************************************************************************
  4260. +// YV12 Texture creation, deletion, copying + clearing
  4261. +//********************************************************************************************************
  4262. +void CLinuxRendererA10::UploadYV12Texture(int source)
  4263. +{
  4264. +  YUVBUFFER& buf    =  m_buffers[source];
  4265. +  YV12Image* im     = &buf.image;
  4266. +  YUVFIELDS& fields =  buf.fields;
  4267. +
  4268. +
  4269. +  if (!(im->flags&IMAGE_FLAG_READY))
  4270. +  {
  4271. +    m_eventTexturesDone[source]->Set();
  4272. +    return;
  4273. +  }
  4274. +
  4275. +  bool deinterlacing;
  4276. +  if (m_currentField == FIELD_FULL)
  4277. +    deinterlacing = false;
  4278. +  else
  4279. +    deinterlacing = true;
  4280. +
  4281. +  glEnable(m_textureTarget);
  4282. +  VerifyGLState();
  4283. +
  4284. +  glPixelStorei(GL_UNPACK_ALIGNMENT,1);
  4285. +
  4286. +  if (deinterlacing)
  4287. +  {
  4288. +    // Load Y fields
  4289. +    LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
  4290. +        , im->width, im->height >> 1
  4291. +        , im->stride[0]*2, im->plane[0] );
  4292. +
  4293. +    LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
  4294. +        , im->width, im->height >> 1
  4295. +        , im->stride[0]*2, im->plane[0] + im->stride[0]) ;
  4296. +  }
  4297. +  else
  4298. +  {
  4299. +    // Load Y plane
  4300. +    LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
  4301. +        , im->width, im->height
  4302. +        , im->stride[0], im->plane[0] );
  4303. +  }
  4304. +
  4305. +  VerifyGLState();
  4306. +
  4307. +  glPixelStorei(GL_UNPACK_ALIGNMENT,1);
  4308. +
  4309. +  if (deinterlacing)
  4310. +  {
  4311. +    // Load Even U & V Fields
  4312. +    LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
  4313. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  4314. +        , im->stride[1]*2, im->plane[1] );
  4315. +
  4316. +    LoadPlane( fields[FIELD_TOP][2], GL_LUMINANCE, buf.flipindex
  4317. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  4318. +        , im->stride[2]*2, im->plane[2] );
  4319. +
  4320. +    // Load Odd U & V Fields
  4321. +    LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
  4322. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  4323. +        , im->stride[1]*2, im->plane[1] + im->stride[1] );
  4324. +
  4325. +    LoadPlane( fields[FIELD_BOT][2], GL_LUMINANCE, buf.flipindex
  4326. +        , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
  4327. +        , im->stride[2]*2, im->plane[2] + im->stride[2] );
  4328. +
  4329. +  }
  4330. +  else
  4331. +  {
  4332. +    LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
  4333. +        , im->width >> im->cshift_x, im->height >> im->cshift_y
  4334. +        , im->stride[1], im->plane[1] );
  4335. +
  4336. +    LoadPlane( fields[FIELD_FULL][2], GL_LUMINANCE, buf.flipindex
  4337. +        , im->width >> im->cshift_x, im->height >> im->cshift_y
  4338. +        , im->stride[2], im->plane[2] );
  4339. +  }
  4340. +
  4341. +  m_eventTexturesDone[source]->Set();
  4342. +
  4343. +  CalculateTextureSourceRects(source, 3);
  4344. +
  4345. +  glDisable(m_textureTarget);
  4346. +}
  4347. +
  4348. +void CLinuxRendererA10::DeleteYV12Texture(int index)
  4349. +{
  4350. +  YV12Image &im     = m_buffers[index].image;
  4351. +  YUVFIELDS &fields = m_buffers[index].fields;
  4352. +
  4353. +  if( fields[FIELD_FULL][0].id == 0 ) return;
  4354. +
  4355. +  /* finish up all textures, and delete them */
  4356. +  g_graphicsContext.BeginPaint();  //FIXME
  4357. +  for(int f = 0;f<MAX_FIELDS;f++)
  4358. +  {
  4359. +    for(int p = 0;p<MAX_PLANES;p++)
  4360. +    {
  4361. +      if( fields[f][p].id )
  4362. +      {
  4363. +        if (glIsTexture(fields[f][p].id))
  4364. +          glDeleteTextures(1, &fields[f][p].id);
  4365. +        fields[f][p].id = 0;
  4366. +      }
  4367. +    }
  4368. +  }
  4369. +  g_graphicsContext.EndPaint();
  4370. +
  4371. +  for(int p = 0;p<MAX_PLANES;p++)
  4372. +  {
  4373. +    if (im.plane[p])
  4374. +    {
  4375. +      delete [] im.plane[p];
  4376. +      im.plane[p] = NULL;
  4377. +    }
  4378. +  }
  4379. +}
  4380. +
  4381. +bool CLinuxRendererA10::CreateYV12Texture(int index)
  4382. +{
  4383. +  /* since we also want the field textures, pitch must be texture aligned */
  4384. +  YV12Image &im     = m_buffers[index].image;
  4385. +  YUVFIELDS &fields = m_buffers[index].fields;
  4386. +
  4387. +  DeleteYV12Texture(index);
  4388. +
  4389. +  im.height = m_sourceHeight;
  4390. +  im.width  = m_sourceWidth;
  4391. +  im.cshift_x = 1;
  4392. +  im.cshift_y = 1;
  4393. +
  4394. +  im.stride[0] = im.width;
  4395. +  im.stride[1] = im.width >> im.cshift_x;
  4396. +  im.stride[2] = im.width >> im.cshift_x;
  4397. +
  4398. +  im.planesize[0] = im.stride[0] * im.height;
  4399. +  im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
  4400. +  im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
  4401. +
  4402. +  for (int i = 0; i < MAX_PLANES; i++)
  4403. +    im.plane[i] = new BYTE[im.planesize[i]];
  4404. +
  4405. +  glEnable(m_textureTarget);
  4406. +  for(int f = 0;f<MAX_FIELDS;f++)
  4407. +  {
  4408. +    for(int p = 0;p<MAX_PLANES;p++)
  4409. +    {
  4410. +      if (!glIsTexture(fields[f][p].id))
  4411. +      {
  4412. +        glGenTextures(1, &fields[f][p].id);
  4413. +        VerifyGLState();
  4414. +      }
  4415. +    }
  4416. +  }
  4417. +
  4418. +  // YUV
  4419. +  for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
  4420. +  {
  4421. +    int fieldshift = (f==FIELD_FULL) ? 0 : 1;
  4422. +    YUVPLANES &planes = fields[f];
  4423. +
  4424. +    planes[0].texwidth  = im.width;
  4425. +    planes[0].texheight = im.height >> fieldshift;
  4426. +
  4427. +    planes[1].texwidth  = planes[0].texwidth  >> im.cshift_x;
  4428. +    planes[1].texheight = planes[0].texheight >> im.cshift_y;
  4429. +    planes[2].texwidth  = planes[0].texwidth  >> im.cshift_x;
  4430. +    planes[2].texheight = planes[0].texheight >> im.cshift_y;
  4431. +
  4432. +    for(int p = 0; p < 3; p++)
  4433. +    {
  4434. +      YUVPLANE &plane = planes[p];
  4435. +      if (plane.texwidth * plane.texheight == 0)
  4436. +        continue;
  4437. +
  4438. +      glBindTexture(m_textureTarget, plane.id);
  4439. +      CLog::Log(LOGDEBUG,  "GL: Creating YUV NPOT texture of size %d x %d", plane.texwidth, plane.texheight);
  4440. +
  4441. +      glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, plane.texwidth, plane.texheight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
  4442. +
  4443. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  4444. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  4445. +      glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  4446. +      glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  4447. +      VerifyGLState();
  4448. +    }
  4449. +  }
  4450. +  glDisable(m_textureTarget);
  4451. +  m_eventTexturesDone[index]->Set();
  4452. +  return true;
  4453. +}
  4454. +
  4455. +//********************************************************************************************************
  4456. +// BYPASS creation, deletion, copying + clearing
  4457. +//********************************************************************************************************
  4458. +void CLinuxRendererA10::UploadBYPASSTexture(int index)
  4459. +{
  4460. +  m_eventTexturesDone[index]->Set();
  4461. +}
  4462. +
  4463. +void CLinuxRendererA10::DeleteBYPASSTexture(int index)
  4464. +{
  4465. +}
  4466. +
  4467. +bool CLinuxRendererA10::CreateBYPASSTexture(int index)
  4468. +{
  4469. +  m_eventTexturesDone[index]->Set();
  4470. +  return true;
  4471. +}
  4472. +
  4473. +void CLinuxRendererA10::SetTextureFilter(GLenum method)
  4474. +{
  4475. +  for (int i = 0 ; i<NUM_BUFFERS ; i++)
  4476. +  {
  4477. +    YUVFIELDS &fields = m_buffers[i].fields;
  4478. +
  4479. +    for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
  4480. +    {
  4481. +      glBindTexture(m_textureTarget, fields[f][0].id);
  4482. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  4483. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  4484. +      VerifyGLState();
  4485. +
  4486. +      glBindTexture(m_textureTarget, fields[f][1].id);
  4487. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  4488. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  4489. +      VerifyGLState();
  4490. +
  4491. +      glBindTexture(m_textureTarget, fields[f][2].id);
  4492. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, method);
  4493. +      glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, method);
  4494. +      VerifyGLState();
  4495. +    }
  4496. +  }
  4497. +}
  4498. +
  4499. +bool CLinuxRendererA10::Supports(ERENDERFEATURE feature)
  4500. +{
  4501. +  // Player controls render, let it dictate available render features
  4502. +  if((m_renderMethod & RENDER_BYPASS))
  4503. +  {
  4504. +    Features::iterator itr = std::find(m_renderFeatures.begin(),m_renderFeatures.end(), feature);
  4505. +    return itr != m_renderFeatures.end();
  4506. +  }
  4507. +
  4508. +  if(feature == RENDERFEATURE_BRIGHTNESS)
  4509. +    return false;
  4510. +
  4511. +  if(feature == RENDERFEATURE_CONTRAST)
  4512. +    return false;
  4513. +
  4514. +  if(feature == RENDERFEATURE_GAMMA)
  4515. +    return false;
  4516. +
  4517. +  if(feature == RENDERFEATURE_NOISE)
  4518. +    return false;
  4519. +
  4520. +  if(feature == RENDERFEATURE_SHARPNESS)
  4521. +    return false;
  4522. +
  4523. +  if (feature == RENDERFEATURE_NONLINSTRETCH)
  4524. +    return false;
  4525. +
  4526. +  return false;
  4527. +}
  4528. +
  4529. +bool CLinuxRendererA10::SupportsMultiPassRendering()
  4530. +{
  4531. +  return false;
  4532. +}
  4533. +
  4534. +bool CLinuxRendererA10::Supports(EDEINTERLACEMODE mode)
  4535. +{
  4536. +  // Player controls render, let it dictate available deinterlace modes
  4537. +  if((m_renderMethod & RENDER_BYPASS))
  4538. +  {
  4539. +    Features::iterator itr = std::find(m_deinterlaceModes.begin(),m_deinterlaceModes.end(), mode);
  4540. +    return itr != m_deinterlaceModes.end();
  4541. +  }
  4542. +
  4543. +  if (mode == VS_DEINTERLACEMODE_OFF)
  4544. +    return true;
  4545. +
  4546. +  if(mode == VS_DEINTERLACEMODE_AUTO || mode == VS_DEINTERLACEMODE_FORCE)
  4547. +    return true;
  4548. +
  4549. +  return false;
  4550. +}
  4551. +
  4552. +bool CLinuxRendererA10::Supports(EINTERLACEMETHOD method)
  4553. +{
  4554. +  // Player controls render, let it dictate available deinterlace methods
  4555. +  if((m_renderMethod & RENDER_BYPASS))
  4556. +  {
  4557. +    Features::iterator itr = std::find(m_deinterlaceMethods.begin(),m_deinterlaceMethods.end(), method);
  4558. +    return itr != m_deinterlaceMethods.end();
  4559. +  }
  4560. +
  4561. +  if(method == VS_INTERLACEMETHOD_AUTO)
  4562. +    return true;
  4563. +
  4564. +#if defined(__i386__) || defined(__x86_64__)
  4565. +  if(method == VS_INTERLACEMETHOD_DEINTERLACE
  4566. +  || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
  4567. +  || method == VS_INTERLACEMETHOD_SW_BLEND)
  4568. +#else
  4569. +  if(method == VS_INTERLACEMETHOD_SW_BLEND)
  4570. +#endif
  4571. +    return true;
  4572. +
  4573. +  return false;
  4574. +}
  4575. +
  4576. +bool CLinuxRendererA10::Supports(ESCALINGMETHOD method)
  4577. +{
  4578. +  // Player controls render, let it dictate available scaling methods
  4579. +  if((m_renderMethod & RENDER_BYPASS))
  4580. +  {
  4581. +    Features::iterator itr = std::find(m_scalingMethods.begin(),m_scalingMethods.end(), method);
  4582. +    return itr != m_scalingMethods.end();
  4583. +  }
  4584. +
  4585. +  if(method == VS_SCALINGMETHOD_NEAREST
  4586. +  || method == VS_SCALINGMETHOD_LINEAR)
  4587. +    return true;
  4588. +
  4589. +  return false;
  4590. +}
  4591. +
  4592. +EINTERLACEMETHOD CLinuxRendererA10::AutoInterlaceMethod()
  4593. +{
  4594. +  // Player controls render, let it pick the auto-deinterlace method
  4595. +  if((m_renderMethod & RENDER_BYPASS))
  4596. +  {
  4597. +    if (m_deinterlaceMethods.size())
  4598. +      return ((EINTERLACEMETHOD)m_deinterlaceMethods[0]);
  4599. +    else
  4600. +      return VS_INTERLACEMETHOD_NONE;
  4601. +  }
  4602. +
  4603. +#if defined(__i386__) || defined(__x86_64__)
  4604. +  return VS_INTERLACEMETHOD_DEINTERLACE_HALF;
  4605. +#else
  4606. +  return VS_INTERLACEMETHOD_SW_BLEND;
  4607. +#endif
  4608. +}
  4609. +
  4610. +void CLinuxRendererA10::AddProcessor(struct A10VLQueueItem *buffer)
  4611. +{
  4612. +  YUVBUFFER &buf = m_buffers[NextYV12Texture()];
  4613. +
  4614. +  buf.a10buffer = buffer;
  4615. +}
  4616. +
  4617. +/*
  4618. + * Video layer functions
  4619. + */
  4620. +
  4621. +static int             g_hdisp = -1;
  4622. +static int             g_screenid = 0;
  4623. +static int             g_syslayer = 0x64;
  4624. +static int             g_hlayer = 0;
  4625. +static int             g_width;
  4626. +static int             g_height;
  4627. +static CRect           g_srcRect;
  4628. +static CRect           g_dstRect;
  4629. +static int             g_lastnr;
  4630. +static int             g_decnr;
  4631. +static int             g_wridx;
  4632. +static int             g_rdidx;
  4633. +static A10VLQueueItem  g_dispq[DISPQS];
  4634. +static pthread_mutex_t g_dispq_mutex;
  4635. +
  4636. +static __disp_layer_info_t             UIOLdLayerAttr;
  4637. +
  4638. +bool A10VLInit(int &width, int &height)
  4639. +{
  4640. +  unsigned long       args[4];
  4641. +  __disp_layer_info_t layera;
  4642. +  unsigned int        i;
  4643. +
  4644. +  if (g_hdisp != -1) return true;
  4645. +
  4646. +  pthread_mutex_init(&g_dispq_mutex, NULL);
  4647. +
  4648. +  g_hdisp = open("/dev/disp", O_RDWR);
  4649. +  if (g_hdisp == -1)
  4650. +  {
  4651. +    CLog::Log(LOGERROR, "A10: open /dev/disp failed. (%d)", errno);
  4652. +    return false;
  4653. +  }
  4654. +
  4655. +  args[0] = g_screenid;
  4656. +  args[1] = 0;
  4657. +  args[2] = 0;
  4658. +  args[3] = 0;
  4659. +  width  = g_width  = ioctl(g_hdisp, DISP_CMD_SCN_GET_WIDTH , args);
  4660. +  height = g_height = ioctl(g_hdisp, DISP_CMD_SCN_GET_HEIGHT, args);
  4661. +
  4662. +  args[0] = g_screenid;
  4663. +  args[1] = g_syslayer;
  4664. +  args[2] = (unsigned long) (&UIOLdLayerAttr);
  4665. +
  4666. +  ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  4667. +
  4668. +  if (g_height > 720)
  4669. +  {
  4670. +    //set workmode scaler (system layer)
  4671. +    args[0] = g_screenid;
  4672. +    args[1] = g_syslayer;
  4673. +    args[2] = (unsigned long) (&layera);
  4674. +    args[3] = 0;
  4675. +    ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  4676. +    layera.mode = DISP_LAYER_WORK_MODE_SCALER;
  4677. +    args[0] = g_screenid;
  4678. +    args[1] = g_syslayer;
  4679. +    args[2] = (unsigned long) (&layera);
  4680. +    args[3] = 0;
  4681. +    ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args);
  4682. +  }
  4683. +  else
  4684. +  {
  4685. +    //#### (1280-720), src(0/0/1280/720), scn(32/18/1216/684)
  4686. +    //set workmode normal (system layer)
  4687. +    args[0] = g_screenid;
  4688. +    args[1] = g_syslayer;
  4689. +    args[2] = (unsigned long) (&layera);
  4690. +    args[3] = 0;
  4691. +    ioctl(g_hdisp, DISP_CMD_LAYER_GET_PARA, args);
  4692. +    //source window information
  4693. +    layera.src_win.x      = 0;
  4694. +    layera.src_win.y      = 0;
  4695. +    layera.src_win.width  = g_width;
  4696. +    layera.src_win.height = g_height;
  4697. +    //screen window information
  4698. +    layera.scn_win.x      = 0;
  4699. +    layera.scn_win.y      = 0;
  4700. +    layera.scn_win.width  = g_width;
  4701. +    layera.scn_win.height = g_height;
  4702. +    //layera.mode = DISP_LAYER_WORK_MODE_NORMAL;
  4703. +    layera.mode = DISP_LAYER_WORK_MODE_SCALER;
  4704. +    args[0] = g_screenid;
  4705. +    args[1] = g_syslayer;
  4706. +    args[2] = (unsigned long) (&layera);
  4707. +    args[3] = 0;
  4708. +    ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args);
  4709. +
  4710. +  }
  4711. +
  4712. +  args[0] = g_screenid;
  4713. +  args[1] = DISP_LAYER_WORK_MODE_SCALER;
  4714. +  args[2] = 0;
  4715. +  args[3] = 0;
  4716. +  g_hlayer = ioctl(g_hdisp, DISP_CMD_LAYER_REQUEST, args);
  4717. +  if (g_hlayer <= 0)
  4718. +  {
  4719. +    g_hlayer = 0;
  4720. +    CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_REQUEST failed.\n");
  4721. +    return false;
  4722. +  }
  4723. +
  4724. +  memset(&g_srcRect, 0, sizeof(g_srcRect));
  4725. +  memset(&g_dstRect, 0, sizeof(g_dstRect));
  4726. +
  4727. +  g_lastnr = -1;
  4728. +  g_decnr  = 0;
  4729. +  g_rdidx  = 0;
  4730. +  g_wridx  = 0;
  4731. +
  4732. +  for (i = 0; i < DISPQS; i++)
  4733. +    g_dispq[i].pict.id = -1;
  4734. +
  4735. +  return true;
  4736. +}
  4737. +
  4738. +static int _inited = 0;
  4739. +static int _currentOSDLevel = 0;
  4740. +
  4741. +void A10VLShowOSD ()
  4742. +{
  4743. +  unsigned long args[4];
  4744. +
  4745. +  if (g_hlayer && _currentOSDLevel == 0)
  4746. +  {
  4747. +    _currentOSDLevel = 255;
  4748. +
  4749. +    args[0] = g_screenid;
  4750. +    args[1] = g_hlayer;
  4751. +    args[2] = 0;
  4752. +    args[3] = 0;
  4753. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  4754. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4755. +    
  4756. +    args[0] = g_screenid;
  4757. +    args[1] = g_syslayer;
  4758. +    args[2] = 0;
  4759. +    args[3] = 0;
  4760. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  4761. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4762. +
  4763. +
  4764. +    args[0] = g_screenid;
  4765. +    args[1] = g_syslayer;
  4766. +    args[2] = 255;
  4767. +    args[3] = 0;
  4768. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_SET_ALPHA_VALUE, args))
  4769. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4770. +
  4771. +    args[0] = g_screenid;
  4772. +    args[1] = g_hlayer;
  4773. +    args[2] = 128;
  4774. +    args[3] = 0;
  4775. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_SET_ALPHA_VALUE, args))
  4776. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4777. +
  4778. +    args[0] = g_screenid;
  4779. +    args[1] = g_syslayer;
  4780. +    args[2] = 0;
  4781. +    args[3] = 0;
  4782. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  4783. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4784. +
  4785. +    args[0] = g_screenid;
  4786. +    args[1] = g_hlayer;
  4787. +    args[2] = 0;
  4788. +    args[3] = 0;
  4789. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  4790. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4791. +  }
  4792. +}
  4793. +
  4794. +void A10VLHideOSD ()
  4795. +{
  4796. +  unsigned long args[4];
  4797. +
  4798. +  if (g_hlayer && _currentOSDLevel == 255)
  4799. +  {
  4800. +    _currentOSDLevel = 0;
  4801. +
  4802. +    args[0] = g_screenid;
  4803. +    args[1] = g_hlayer;
  4804. +    args[2] = 0;
  4805. +    args[3] = 0;
  4806. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  4807. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4808. +    
  4809. +    args[0] = g_screenid;
  4810. +    args[1] = g_syslayer;
  4811. +    args[2] = 0;
  4812. +    args[3] = 0;
  4813. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  4814. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4815. +
  4816. +
  4817. +    args[0] = g_screenid;
  4818. +    args[1] = g_syslayer;
  4819. +    args[2] = 0;
  4820. +    args[3] = 0;
  4821. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_SET_ALPHA_VALUE, args))
  4822. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4823. +
  4824. +    args[0] = g_screenid;
  4825. +    args[1] = g_hlayer;
  4826. +    args[2] = 255;
  4827. +    args[3] = 0;
  4828. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_SET_ALPHA_VALUE, args))
  4829. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4830. +
  4831. +    args[0] = g_screenid;
  4832. +    args[1] = g_syslayer;
  4833. +    args[2] = 0;
  4834. +    args[3] = 0;
  4835. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  4836. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4837. +
  4838. +    args[0] = g_screenid;
  4839. +    args[1] = g_hlayer;
  4840. +    args[2] = 0;
  4841. +    args[3] = 0;
  4842. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  4843. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4844. +  }
  4845. +}
  4846. +
  4847. +void A10VLExit()
  4848. +{
  4849. +  unsigned long args[4];
  4850. +  _inited = 0;
  4851. +  _currentOSDLevel = 0;
  4852. +
  4853. +  if (g_hlayer)
  4854. +  {
  4855. +    //stop video
  4856. +    args[0] = g_screenid;
  4857. +    args[1] = g_hlayer;
  4858. +    args[2] = 0;
  4859. +    args[3] = 0;
  4860. +    ioctl(g_hdisp, DISP_CMD_VIDEO_STOP, args);
  4861. +
  4862. +    args[0] = g_screenid;
  4863. +    args[1] = g_hlayer;
  4864. +    args[2] = 0;
  4865. +    args[3] = 0;
  4866. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_BOTTOM, args))
  4867. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_BOTTOM failed.\n");
  4868. +
  4869. +    //close layer
  4870. +    args[0] = g_screenid;
  4871. +    args[1] = g_hlayer;
  4872. +    args[2] = 0;
  4873. +    args[3] = 0;
  4874. +    ioctl(g_hdisp, DISP_CMD_LAYER_CLOSE, args);
  4875. +
  4876. +    //release layer
  4877. +    args[0] = g_screenid;
  4878. +    args[1] = g_hlayer;
  4879. +    args[2] = 0;
  4880. +    args[3] = 0;
  4881. +    ioctl(g_hdisp, DISP_CMD_LAYER_RELEASE, args);
  4882. +    g_hlayer = 0;
  4883. +
  4884. +    args[0] = g_screenid;
  4885. +    args[1] = g_syslayer;
  4886. +    args[2] = 0;
  4887. +    args[3] = 0;
  4888. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_OFF, args))
  4889. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4890. +    args[0] = g_screenid;
  4891. +    args[1] = g_syslayer;
  4892. +    args[2] = 255;
  4893. +    args[3] = 0;
  4894. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_SET_ALPHA_VALUE, args))
  4895. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4896. +
  4897. +    args[0] = g_screenid;
  4898. +    args[1] = g_syslayer;
  4899. +    args[2] = 0;
  4900. +    args[3] = 0;
  4901. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_ALPHA_ON, args))
  4902. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  4903. +
  4904. +    args[0] = g_screenid;
  4905. +    args[1] = g_syslayer;
  4906. +    args[2] = (unsigned long) (&UIOLdLayerAttr);
  4907. +    ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args);
  4908. +  }
  4909. +  
  4910. +  if (g_hdisp != -1)
  4911. +  {
  4912. +    close(g_hdisp);
  4913. +    g_hdisp = -1;
  4914. +  }
  4915. +}
  4916. +void A10VLHide()
  4917. +{
  4918. +  unsigned long args[4];
  4919. +
  4920. +  if (g_hlayer)
  4921. +  {
  4922. +    //stop video
  4923. +    args[0] = g_screenid;
  4924. +    args[1] = g_hlayer;
  4925. +    args[2] = 0;
  4926. +    args[3] = 0;
  4927. +    ioctl(g_hdisp, DISP_CMD_VIDEO_STOP, args);
  4928. +
  4929. +    //close layer
  4930. +    args[0] = g_screenid;
  4931. +    args[1] = g_hlayer;
  4932. +    args[2] = 0;
  4933. +    args[3] = 0;
  4934. +    ioctl(g_hdisp, DISP_CMD_LAYER_CLOSE, args);
  4935. +  }
  4936. +
  4937. +  memset(&g_srcRect, 0, sizeof(g_srcRect));
  4938. +  memset(&g_dstRect, 0, sizeof(g_dstRect));
  4939. +}
  4940. +
  4941. +A10VLQueueItem *A10VLPutQueue(A10VLCALLBACK     callback,
  4942. +                              void             *callbackpriv,
  4943. +                              void             *pictpriv,
  4944. +                              cedarv_picture_t &pict)
  4945. +{
  4946. +  A10VLQueueItem *pRet;
  4947. +
  4948. +  pthread_mutex_lock(&g_dispq_mutex);
  4949. +
  4950. +  pRet = &g_dispq[g_wridx];
  4951. +
  4952. +  pRet->decnr        = g_decnr++;
  4953. +  pRet->callback     = callback;
  4954. +  pRet->callbackpriv = callbackpriv;
  4955. +  pRet->pictpriv     = pictpriv;
  4956. +  pRet->pict         = pict;
  4957. +
  4958. +  g_wridx++;
  4959. +  if (g_wridx >= DISPQS)
  4960. +    g_wridx = 0;
  4961. +
  4962. +  pthread_mutex_unlock(&g_dispq_mutex);
  4963. +
  4964. +  return pRet;
  4965. +}
  4966. +
  4967. +static void A10VLFreeQueueItem(A10VLQueueItem *pItem)
  4968. +{
  4969. +  if ((int)pItem->pict.id != -1)
  4970. +  {
  4971. +    if (pItem->callback)
  4972. +      pItem->callback(pItem->callbackpriv, pItem->pictpriv, pItem->pict);
  4973. +    pItem->pict.id = -1;
  4974. +  }
  4975. +}
  4976. +
  4977. +void A10VLFreeQueue()
  4978. +{
  4979. +  int i;
  4980. +
  4981. +  pthread_mutex_lock(&g_dispq_mutex);
  4982. +
  4983. +  for (i = 0; i < DISPQS; i++)
  4984. +    A10VLFreeQueueItem(&g_dispq[i]);
  4985. +
  4986. +  pthread_mutex_unlock(&g_dispq_mutex);
  4987. +}
  4988. +
  4989. +void A10VLDisplayQueueItem(A10VLQueueItem *pItem, CRect &srcRect, CRect &dstRect)
  4990. +{
  4991. +  int i;
  4992. +  int curnr;
  4993. +
  4994. +  pthread_mutex_lock(&g_dispq_mutex);
  4995. +
  4996. +  if (!pItem || (pItem->pict.id == -1) || (g_lastnr == pItem->decnr))
  4997. +  {
  4998. +    pthread_mutex_unlock(&g_dispq_mutex);
  4999. +    return;
  5000. +  }
  5001. +
  5002. +  curnr = A10VLDisplayPicture(pItem->pict, pItem->decnr, srcRect, dstRect);
  5003. +
  5004. +  if (curnr != g_lastnr)
  5005. +  {
  5006. +    //free older frames, displayed or not
  5007. +    for (i = 0; i < DISPQS; i++)
  5008. +    {
  5009. +      if(g_dispq[g_rdidx].decnr < curnr)
  5010. +      {
  5011. +        A10VLFreeQueueItem(&g_dispq[g_rdidx]);
  5012. +
  5013. +        g_rdidx++;
  5014. +        if (g_rdidx >= DISPQS)
  5015. +          g_rdidx = 0;
  5016. +
  5017. +      } else break;
  5018. +    }
  5019. +
  5020. +  }
  5021. +
  5022. +  g_lastnr = curnr;
  5023. +
  5024. +  pthread_mutex_unlock(&g_dispq_mutex);
  5025. +}
  5026. +
  5027. +int A10VLDisplayPicture(cedarv_picture_t &picture,
  5028. +                        int               refnr,
  5029. +                        CRect            &srcRect,
  5030. +                        CRect            &dstRect)
  5031. +{
  5032. +  unsigned long       args[4];
  5033. +  __disp_layer_info_t layera;
  5034. +  __disp_video_fb_t   frmbuf;
  5035. +  __disp_colorkey_t   colorkey;
  5036. +
  5037. +  memset(&frmbuf, 0, sizeof(__disp_video_fb_t));
  5038. +  frmbuf.id              = refnr;
  5039. +  frmbuf.interlace       = picture.is_progressive? 0 : 1;
  5040. +  frmbuf.top_field_first = picture.top_field_first;
  5041. +  //frmbuf.frame_rate      = picture.frame_rate;
  5042. +  frmbuf.addr[0]         = g_libbdv.mem_get_phy_addr((u32)picture.y);
  5043. +  frmbuf.addr[1]         = g_libbdv.mem_get_phy_addr((u32)picture.u);
  5044. +
  5045. +  //if (_inited == 0)
  5046. +  if ((g_srcRect != srcRect) || (g_dstRect != dstRect))
  5047. +  {
  5048. +    int screen_width, screen_height;
  5049. +
  5050. +    _inited = 1;
  5051. +
  5052. +    //query screen dimensions
  5053. +    args[0] = g_screenid;
  5054. +    args[1] = 0;
  5055. +    args[2] = 0;
  5056. +    args[3] = 0;
  5057. +    screen_width = ioctl(g_hdisp, DISP_CMD_SCN_GET_WIDTH, args);
  5058. +
  5059. +    args[0] = g_screenid;
  5060. +    args[1] = 0;
  5061. +    args[2] = 0;
  5062. +    args[3] = 0;
  5063. +    screen_height = ioctl(g_hdisp, DISP_CMD_SCN_GET_HEIGHT, args);
  5064. +
  5065. +    memset(&layera, 0, sizeof(layera));
  5066. +    //set video layer attribute
  5067. +    layera.mode          = DISP_LAYER_WORK_MODE_SCALER;
  5068. +    layera.b_from_screen = 0; //what is this? if enabled all is black
  5069. +    layera.pipe          = 1;
  5070. +    //use alpha blend
  5071. +    layera.alpha_en      = 0;
  5072. +    layera.alpha_val     = 0xff;
  5073. +    layera.ck_enable     = 0;
  5074. +    layera.b_trd_out     = 0;
  5075. +    layera.out_trd_mode  = (__disp_3d_out_mode_t)0;
  5076. +    //frame buffer pst and size information
  5077. +    if (picture.display_height < 720)
  5078. +    {
  5079. +      layera.fb.cs_mode = DISP_BT601;
  5080. +    }
  5081. +    else
  5082. +    {
  5083. +      layera.fb.cs_mode = DISP_BT709;
  5084. +    }
  5085. +
  5086. +    float w = (float)picture.width;
  5087. +    float h = (float)picture.height;
  5088. +    float h1 = g_width * h / w;
  5089. +
  5090. +    layera.fb.mode        = DISP_MOD_MB_UV_COMBINED;
  5091. +    layera.fb.format      = picture.pixel_format == CEDARV_PIXEL_FORMAT_AW_YUV422 ? DISP_FORMAT_YUV422 : DISP_FORMAT_YUV420;
  5092. +    layera.fb.br_swap     = 0;
  5093. +    layera.fb.seq         = DISP_SEQ_UVUV;
  5094. +    layera.fb.addr[0]     = frmbuf.addr[0];
  5095. +    layera.fb.addr[1]     = frmbuf.addr[1];
  5096. +    layera.fb.b_trd_src   = 0;
  5097. +    layera.fb.trd_mode    = (__disp_3d_src_mode_t)0;
  5098. +    layera.fb.size.width  = picture.display_width;
  5099. +    layera.fb.size.height = picture.display_height;
  5100. +    //source window information
  5101. +    layera.src_win.x      = 0;
  5102. +    layera.src_win.y      = 0;
  5103. +    layera.src_win.width  = picture.width;
  5104. +    layera.src_win.height = picture.height;
  5105. +    //screen window information
  5106. +    layera.scn_win.x      = 0;
  5107. +    layera.scn_win.y      = 0;
  5108. +    layera.scn_win.width  = g_width;
  5109. +    layera.scn_win.height = g_height;
  5110. +
  5111. +    args[0] = g_screenid;
  5112. +    args[1] = g_hlayer;
  5113. +    args[2] = (unsigned long)&layera;
  5114. +    args[3] = 0;
  5115. +    if(ioctl(g_hdisp, DISP_CMD_LAYER_SET_PARA, args))
  5116. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_SET_PARA failed.\n");
  5117. +
  5118. +    //open layer
  5119. +    args[0] = g_screenid;
  5120. +    args[1] = g_hlayer;
  5121. +    args[2] = 0;
  5122. +    args[3] = 0;
  5123. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_OPEN, args))
  5124. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_OPEN failed.\n");
  5125. +
  5126. +    //put behind system layer
  5127. +    args[0] = g_screenid;
  5128. +    args[1] = g_hlayer;
  5129. +    args[2] = 0;
  5130. +    args[3] = 0;
  5131. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_BOTTOM, args))
  5132. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_BOTTOM failed.\n");
  5133. +
  5134. +    //turn off colorkey (system layer)
  5135. +    args[0] = g_screenid;
  5136. +    args[1] = g_syslayer;
  5137. +    args[2] = 0;
  5138. +    args[3] = 0;
  5139. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_CK_OFF, args))
  5140. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_OFF failed.\n");
  5141. +
  5142. +      colorkey.ck_min.alpha = 128;
  5143. +      colorkey.ck_min.red   = 1;
  5144. +      colorkey.ck_min.green = 1;
  5145. +      colorkey.ck_min.blue  = 1;
  5146. +      colorkey.ck_max = colorkey.ck_min;
  5147. +      colorkey.ck_max.alpha = 128;
  5148. +      colorkey.red_match_rule   = 2;
  5149. +      colorkey.green_match_rule = 2;
  5150. +      colorkey.blue_match_rule  = 2;
  5151. +
  5152. +      colorkey.ck_min.alpha                 = 0xff;
  5153. +      colorkey.ck_min.red                   = 0x0; //0x01;
  5154. +      colorkey.ck_min.green                 = 0x0; //0x03;
  5155. +      colorkey.ck_min.blue                  = 0x0; //0x05;
  5156. +      colorkey.ck_max.alpha                 = 0xff;
  5157. +      colorkey.ck_max.red                   = 0x0; //0x01;
  5158. +      colorkey.ck_max.green                 = 0x0; //0x03;
  5159. +      colorkey.ck_max.blue                  = 0x0; //0x05;
  5160. +
  5161. +      colorkey.red_match_rule               = 2;
  5162. +      colorkey.green_match_rule             = 2;
  5163. +      colorkey.blue_match_rule              = 2;
  5164. +
  5165. +
  5166. +    args[0] = g_screenid;
  5167. +    args[1] = (unsigned long)&colorkey;
  5168. +    args[2] = 0;
  5169. +    args[3] = 0;
  5170. +    if (ioctl(g_hdisp, DISP_CMD_SET_COLORKEY, args))
  5171. +      CLog::Log(LOGERROR, "A10: DISP_CMD_SET_COLORKEY failed.\n");
  5172. +    
  5173. +    //turn on colorkey
  5174. +    args[0] = g_screenid;
  5175. +    args[1] = g_hlayer;
  5176. +    args[2] = 0;
  5177. +    args[3] = 0;
  5178. +    if (ioctl(g_hdisp, DISP_CMD_LAYER_CK_ON, args))
  5179. +      CLog::Log(LOGERROR, "A10: DISP_CMD_LAYER_CK_ON failed.\n");
  5180. +
  5181. +
  5182. +    
  5183. +    //start video
  5184. +    args[0] = g_screenid;
  5185. +    args[1] = g_hlayer;
  5186. +    args[2] = 0;
  5187. +    args[3] = 0;
  5188. +    if (ioctl(g_hdisp, DISP_CMD_VIDEO_START, args))
  5189. +      CLog::Log(LOGERROR, "A10: DISP_CMD_VIDEO_START failed.\n");
  5190. +
  5191. +    g_srcRect = srcRect;
  5192. +    g_dstRect = dstRect;
  5193. +
  5194. +    g_android_mouse_count = 0;
  5195. +  }
  5196. +
  5197. +  args[0] = g_screenid;
  5198. +  args[1] = g_hlayer;
  5199. +  args[2] = (unsigned long)&frmbuf;
  5200. +  args[3] = 0;
  5201. +  if (ioctl(g_hdisp, DISP_CMD_VIDEO_SET_FB, args))
  5202. +    CLog::Log(LOGERROR, "A10: DISP_CMD_VIDEO_SET_FB failed.\n");
  5203. +
  5204. +  //CLog::Log(LOGDEBUG, "A10: render %d\n", buffer->picture.id);
  5205. +
  5206. +  args[0] = g_screenid;
  5207. +  args[1] = g_hlayer;
  5208. +  args[2] = 0;
  5209. +  args[3] = 0;
  5210. +  return ioctl(g_hdisp, DISP_CMD_VIDEO_GET_FRAME_ID, args);
  5211. +}
  5212. +
  5213. +#endif
  5214. +
  5215. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.h xbmc_vidonme/xbmc/cores/VideoRenderers/LinuxRendererA10.h
  5216. --- xbmc_orig/xbmc/cores/VideoRenderers/LinuxRendererA10.h      1970-01-01 01:00:00.000000000 +0100
  5217. +++ xbmc_vidonme/xbmc/cores/VideoRenderers/LinuxRendererA10.h   2013-06-12 16:40:35.000000000 +0200
  5218. @@ -0,0 +1,317 @@
  5219. +#ifndef LinuxRendererA10_RENDERER
  5220. +#define LinuxRendererA10_RENDERER
  5221. +
  5222. +/*
  5223. + *      Copyright (C) 2010-2012 Team XBMC and others
  5224. + *      http://www.xbmc.org
  5225. + *
  5226. + *  This Program is free software; you can redistribute it and/or modify
  5227. + *  it under the terms of the GNU General Public License as published by
  5228. + *  the Free Software Foundation; either version 2, or (at your option)
  5229. + *  any later version.
  5230. + *
  5231. + *  This Program is distributed in the hope that it will be useful,
  5232. + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  5233. + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5234. + *  GNU General Public License for more details.
  5235. + *
  5236. + *  You should have received a copy of the GNU General Public License
  5237. + *  along with XBMC; see the file COPYING.  If not, see
  5238. + *  <http://www.gnu.org/licenses/>.
  5239. + *
  5240. + */
  5241. +
  5242. +#if HAS_GLES == 2
  5243. +
  5244. +#include "system_gl.h"
  5245. +
  5246. +#include "xbmc/guilib/FrameBufferObject.h"
  5247. +#include "xbmc/guilib/Shader.h"
  5248. +#include "settings/VideoSettings.h"
  5249. +#include "RenderFlags.h"
  5250. +#include "guilib/GraphicContext.h"
  5251. +#include "BaseRenderer.h"
  5252. +#include "xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
  5253. +#include "xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecA10.h"
  5254. +
  5255. +extern "C" {
  5256. +#include "cores/a10/libcedarv.h"
  5257. +}
  5258. +
  5259. +class CRenderCapture;
  5260. +
  5261. +class CBaseTexture;
  5262. +namespace Shaders { class BaseYUV2RGBShader; }
  5263. +namespace Shaders { class BaseVideoFilterShader; }
  5264. +
  5265. +typedef std::vector<int>     Features;
  5266. +
  5267. +#define NUM_BUFFERS 6
  5268. +
  5269. +
  5270. +#undef ALIGN
  5271. +#define ALIGN(value, alignment) (((value)+((alignment)-1))&~((alignment)-1))
  5272. +#define CLAMP(a, min, max) ((a) > (max) ? (max) : ( (a) < (min) ? (min) : a ))
  5273. +
  5274. +#define AUTOSOURCE -1
  5275. +
  5276. +#define IMAGE_FLAG_WRITING   0x01 /* image is in use after a call to GetImage, caller may be reading or writing */
  5277. +#define IMAGE_FLAG_READING   0x02 /* image is in use after a call to GetImage, caller is only reading */
  5278. +#define IMAGE_FLAG_DYNAMIC   0x04 /* image was allocated due to a call to GetImage */
  5279. +#define IMAGE_FLAG_RESERVED  0x08 /* image is reserved, must be asked for specifically used to preserve images */
  5280. +#define IMAGE_FLAG_READY     0x16 /* image is ready to be uploaded to texture memory */
  5281. +#define IMAGE_FLAG_INUSE (IMAGE_FLAG_WRITING | IMAGE_FLAG_READING | IMAGE_FLAG_RESERVED)
  5282. +
  5283. +struct DRAWRECT
  5284. +{
  5285. +  float left;
  5286. +  float top;
  5287. +  float right;
  5288. +  float bottom;
  5289. +};
  5290. +
  5291. +struct YUVRANGE
  5292. +{
  5293. +  int y_min, y_max;
  5294. +  int u_min, u_max;
  5295. +  int v_min, v_max;
  5296. +};
  5297. +
  5298. +struct YUVCOEF
  5299. +{
  5300. +  float r_up, r_vp;
  5301. +  float g_up, g_vp;
  5302. +  float b_up, b_vp;
  5303. +};
  5304. +
  5305. +enum RenderMethod
  5306. +{
  5307. +  RENDER_GLSL   = 0x001,
  5308. +  RENDER_A10BUF = 0x100,
  5309. +  RENDER_BYPASS = 0x400
  5310. +};
  5311. +
  5312. +enum RenderQuality
  5313. +{
  5314. +  RQ_LOW=1,
  5315. +  RQ_SINGLEPASS,
  5316. +  RQ_MULTIPASS,
  5317. +};
  5318. +
  5319. +#define PLANE_Y 0
  5320. +#define PLANE_U 1
  5321. +#define PLANE_V 2
  5322. +
  5323. +#define FIELD_FULL 0
  5324. +#define FIELD_TOP 1
  5325. +#define FIELD_BOT 2
  5326. +
  5327. +class CEvent;
  5328. +
  5329. +struct A10VLQueueItem;
  5330. +
  5331. +class CLinuxRendererA10 : public CBaseRenderer
  5332. +{
  5333. +public:
  5334. +  CLinuxRendererA10();
  5335. +  virtual ~CLinuxRendererA10();
  5336. +
  5337. +  virtual void Update(bool bPauseDrawing);
  5338. +  virtual void SetupScreenshot() {};
  5339. +
  5340. +  bool RenderCapture(CRenderCapture* capture);
  5341. +
  5342. +  // Player functions
  5343. +  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);
  5344. +  virtual bool         IsConfigured() { return m_bConfigured; }
  5345. +  virtual int          GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
  5346. +  virtual void         ReleaseImage(int source, bool preserve = false);
  5347. +  virtual void         FlipPage(int source);
  5348. +  virtual unsigned int PreInit();
  5349. +  virtual void         UnInit();
  5350. +  virtual void         Reset(); /* resets renderer after seek for example */
  5351. +  virtual void         ReorderDrawPoints();
  5352. +
  5353. +  virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
  5354. +
  5355. +  // Feature support
  5356. +  virtual bool SupportsMultiPassRendering();
  5357. +  virtual bool Supports(ERENDERFEATURE feature);
  5358. +  virtual bool Supports(EDEINTERLACEMODE mode);
  5359. +  virtual bool Supports(EINTERLACEMETHOD method);
  5360. +  virtual bool Supports(ESCALINGMETHOD method);
  5361. +
  5362. +  virtual EINTERLACEMETHOD AutoInterlaceMethod();
  5363. +
  5364. +  virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
  5365. +
  5366. +  virtual void AddProcessor(struct A10VLQueueItem *pVidBuff);
  5367. +
  5368. +protected:
  5369. +  virtual void Render(DWORD flags, int index);
  5370. +
  5371. +  virtual void ManageTextures();
  5372. +  int  NextYV12Texture();
  5373. +  virtual bool ValidateRenderTarget();
  5374. +  virtual void LoadShaders(int field=FIELD_FULL);
  5375. +  void SetTextureFilter(GLenum method);
  5376. +  void UpdateVideoFilter();
  5377. +
  5378. +  // textures
  5379. +  void (CLinuxRendererA10::*m_textureUpload)(int index);
  5380. +  void (CLinuxRendererA10::*m_textureDelete)(int index);
  5381. +  bool (CLinuxRendererA10::*m_textureCreate)(int index);
  5382. +
  5383. +  void UploadYV12Texture(int index);
  5384. +  void DeleteYV12Texture(int index);
  5385. +  bool CreateYV12Texture(int index);
  5386. +
  5387. +  void UploadBYPASSTexture(int index);
  5388. +  void DeleteBYPASSTexture(int index);
  5389. +  bool CreateBYPASSTexture(int index);
  5390. +
  5391. +  void CalculateTextureSourceRects(int source, int num_planes);
  5392. +
  5393. +  // renderers
  5394. +  void RenderMultiPass(int index, int field);     // multi pass glsl renderer
  5395. +  void RenderSinglePass(int index, int field);    // single pass glsl renderer
  5396. +
  5397. +  CFrameBufferObject m_fbo;
  5398. +
  5399. +  int m_iYV12RenderBuffer;
  5400. +  int m_iLastRenderBuffer;
  5401. +
  5402. +  bool m_bConfigured;
  5403. +  bool m_bValidated;
  5404. +  std::vector<ERenderFormat> m_formats;
  5405. +  bool m_bImageReady;
  5406. +  ERenderFormat m_format;
  5407. +  GLenum m_textureTarget;
  5408. +  unsigned short m_renderMethod;
  5409. +  unsigned short m_oldRenderMethod;
  5410. +  RenderQuality m_renderQuality;
  5411. +  unsigned int m_flipindex; // just a counter to keep track of if a image has been uploaded
  5412. +  bool m_StrictBinding;
  5413. +
  5414. +  // Raw data used by renderer
  5415. +  int m_currentField;
  5416. +  int m_reloadShaders;
  5417. +
  5418. +  struct YUVPLANE
  5419. +  {
  5420. +    GLuint id;
  5421. +    CRect  rect;
  5422. +
  5423. +    float  width;
  5424. +    float  height;
  5425. +
  5426. +    unsigned texwidth;
  5427. +    unsigned texheight;
  5428. +
  5429. +    unsigned flipindex;
  5430. +  };
  5431. +
  5432. +  typedef YUVPLANE           YUVPLANES[MAX_PLANES];
  5433. +  typedef YUVPLANES          YUVFIELDS[MAX_FIELDS];
  5434. +
  5435. +  struct YUVBUFFER
  5436. +  {
  5437. +    YUVFIELDS fields;
  5438. +    YV12Image image;
  5439. +    unsigned  flipindex; /* used to decide if this has been uploaded */
  5440. +
  5441. +    A10VLQueueItem *a10buffer;
  5442. +  };
  5443. +
  5444. +  // YV12 decoder textures
  5445. +  // field index 0 is full image, 1 is odd scanlines, 2 is even scanlines
  5446. +  YUVBUFFER m_buffers[NUM_BUFFERS];
  5447. +
  5448. +  void LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
  5449. +                , unsigned width,  unsigned height
  5450. +                , int stride, void* data );
  5451. +
  5452. +  Shaders::BaseYUV2RGBShader     *m_pYUVShader;
  5453. +  Shaders::BaseVideoFilterShader *m_pVideoFilterShader;
  5454. +
  5455. +  ESCALINGMETHOD m_scalingMethod;
  5456. +  ESCALINGMETHOD m_scalingMethodGui;
  5457. +
  5458. +  Features m_renderFeatures;
  5459. +  Features m_deinterlaceMethods;
  5460. +  Features m_deinterlaceModes;
  5461. +  Features m_scalingMethods;
  5462. +
  5463. +  // clear colour for "black" bars
  5464. +  float m_clearColour;
  5465. +
  5466. +  CEvent* m_eventTexturesDone[NUM_BUFFERS];
  5467. +
  5468. +};
  5469. +
  5470. +
  5471. +inline int NP2( unsigned x )
  5472. +{
  5473. +    --x;
  5474. +    x |= x >> 1;
  5475. +    x |= x >> 2;
  5476. +    x |= x >> 4;
  5477. +    x |= x >> 8;
  5478. +    x |= x >> 16;
  5479. +    return ++x;
  5480. +}
  5481. +#endif
  5482. +
  5483. +/*
  5484. + * Video layer functions
  5485. + */
  5486. +
  5487. +extern "C" {
  5488. +#include "cores/a10/libcedarv.h"
  5489. +#include "cores/a10/drv_display_sun4i.h"
  5490. +}
  5491. +
  5492. +#define DISPQS 20
  5493. +
  5494. +typedef void (*A10VLCALLBACK)(void *callbackpriv, void *pictpriv, cedarv_picture_t &pict); //cleanup function
  5495. +
  5496. +struct A10VLQueueItem
  5497. +{
  5498. +  int               decnr;
  5499. +  A10VLCALLBACK     callback;
  5500. +  void             *callbackpriv;
  5501. +  void             *pictpriv;
  5502. +  cedarv_picture_t  pict;
  5503. +};
  5504. +
  5505. +typedef struct
  5506. +{
  5507. +  int width_in;
  5508. +  int height_in;
  5509. +  int width_out;
  5510. +  int height_out;
  5511. +  u32 addr_y_in;
  5512. +  u32 addr_c_in;
  5513. +  u32 addr_y_out;
  5514. +  u32 addr_u_out;
  5515. +  u32 addr_v_out;
  5516. +} A10VLScalerParameter;
  5517. +
  5518. +bool A10VLInit(int &width, int &height);
  5519. +
  5520. +void A10VLExit();
  5521. +
  5522. +void A10VLHide();
  5523. +
  5524. +A10VLQueueItem *A10VLPutQueue(A10VLCALLBACK     callback,
  5525. +                              void             *callbackpriv,
  5526. +                              void             *pictpriv,
  5527. +                              cedarv_picture_t &pict);
  5528. +
  5529. +void A10VLFreeQueue();
  5530. +
  5531. +void A10VLDisplayQueueItem(A10VLQueueItem *pItem, CRect &srcRect, CRect &dstRect);
  5532. +
  5533. +int  A10VLDisplayPicture(cedarv_picture_t &pict, int refnr, CRect &srcRect, CRect &dstRect);
  5534. +
  5535. +#endif
  5536. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h xbmc_vidonme/xbmc/cores/VideoRenderers/RenderFormats.h
  5537. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderFormats.h 2013-06-12 16:21:05.000000000 +0200
  5538. +++ xbmc_vidonme/xbmc/cores/VideoRenderers/RenderFormats.h      2013-06-12 16:40:35.000000000 +0200
  5539. @@ -33,6 +33,9 @@
  5540.    RENDER_FMT_VAAPI,
  5541.    RENDER_FMT_OMXEGL,
  5542.    RENDER_FMT_CVBREF,
  5543. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  5544. +  RENDER_FMT_A10BUF,
  5545. +#endif
  5546.    RENDER_FMT_BYPASS,
  5547.  };
  5548.  
  5549. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc_vidonme/xbmc/cores/VideoRenderers/RenderManager.cpp
  5550. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.cpp       2013-06-12 16:46:43.000000000 +0200
  5551. +++ xbmc_vidonme/xbmc/cores/VideoRenderers/RenderManager.cpp    2013-06-12 16:40:35.000000000 +0200
  5552. @@ -38,7 +38,11 @@
  5553.  #if defined(HAS_GL)
  5554.    #include "LinuxRendererGL.h"
  5555.  #elif HAS_GLES == 2
  5556. +  #if defined(__DVDFAB_FUNC_A10CODEC__)
  5557. +  #include "LinuxRendererA10.h"
  5558. +  #else
  5559.    #include "LinuxRendererGLES.h"
  5560. +  #endif
  5561.  #elif defined(HAS_DX)
  5562.    #include "WinRenderer.h"
  5563.  #elif defined(HAS_SDL)
  5564. @@ -328,7 +332,11 @@
  5565.  #if defined(HAS_GL)
  5566.      m_pRenderer = new CLinuxRendererGL();
  5567.  #elif HAS_GLES == 2
  5568. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  5569. +       m_pRenderer = new CLinuxRendererA10();
  5570. +#else
  5571.      m_pRenderer = new CLinuxRendererGLES();
  5572. +#endif //__DVDFAB_FUNC_A10CODEC__
  5573.  #elif defined(HAS_DX)
  5574.      m_pRenderer = new CWinRenderer();
  5575.  #elif defined(HAS_SDL)
  5576. @@ -844,6 +852,11 @@
  5577.    else if(pic.format == RENDER_FMT_VAAPI)
  5578.      m_pRenderer->AddProcessor(*pic.vaapi);
  5579.  #endif
  5580. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  5581. + else if (pic.format == RENDER_FMT_A10BUF)
  5582. +    m_pRenderer->AddProcessor(pic.a10buffer);
  5583. +#endif
  5584. +
  5585.    m_pRenderer->ReleaseImage(index, false);
  5586.  
  5587.    return index;
  5588. diff -b -u -r -N '--exclude=.git' xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h xbmc_vidonme/xbmc/cores/VideoRenderers/RenderManager.h
  5589. --- xbmc_orig/xbmc/cores/VideoRenderers/RenderManager.h 2013-06-12 16:46:43.000000000 +0200
  5590. +++ xbmc_vidonme/xbmc/cores/VideoRenderers/RenderManager.h      2013-06-12 16:40:35.000000000 +0200
  5591. @@ -30,6 +30,10 @@
  5592.  #include "settings/VideoSettings.h"
  5593.  #include "OverlayRenderer.h"
  5594.  
  5595. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  5596. +#include "cores/a10/libcedarv.h"
  5597. +#endif
  5598. +
  5599.  class CRenderCapture;
  5600.  
  5601.  namespace DXVA { class CProcessor; }
  5602. @@ -43,6 +47,7 @@
  5603.  class CLinuxRenderer;
  5604.  class CLinuxRendererGL;
  5605.  class CLinuxRendererGLES;
  5606. +class CLinuxRendererA10;
  5607.  
  5608.  class CXBMCRenderManager
  5609.  {
  5610. @@ -113,7 +118,11 @@
  5611.  #ifdef HAS_GL
  5612.    CLinuxRendererGL    *m_pRenderer;
  5613.  #elif HAS_GLES == 2
  5614. +#if defined(__DVDFAB_FUNC_A10CODEC__)
  5615. +  CLinuxRendererA10   *m_pRenderer;
  5616. +#else
  5617.    CLinuxRendererGLES  *m_pRenderer;
  5618. +#endif //__DVDFAB_FUNC_A10CODEC__
  5619.  #elif defined(HAS_DX)
  5620.    CWinRenderer        *m_pRenderer;
  5621.  #elif defined(HAS_SDL)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top