1
0

vp3stub.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "main.h"
  2. #include "../../vp32/include/duck_dxl.h"
  3. #include "vfw.h"
  4. extern "C" {
  5. void GetImageBufs(DXL_XIMAGE_HANDLE x, YV12_PLANES *p);
  6. };
  7. int vp3_postprocess=0;
  8. int vp3_targetcpu=0;
  9. class VP3_Decoder : public IVideoDecoder {
  10. public:
  11. VP3_Decoder(int w, int h, int uvflip);
  12. ~VP3_Decoder();
  13. int decode(int need_kf,
  14. void *in, int in_len,
  15. void **out, // out is set to a pointer to data
  16. unsigned int *out_type, // 'Y','V','1','2' is currently defined
  17. int *is_kf);
  18. void flush() { }
  19. private:
  20. int m_uvflip;
  21. int l_tcpu, l_pp;
  22. static int init;
  23. DXL_XIMAGE_HANDLE xim;
  24. YV12_PLANES vidbufdec;
  25. };
  26. int VP3_Decoder::init;
  27. VP3_Decoder::VP3_Decoder(int w, int h, int uvflip)
  28. {
  29. l_tcpu=-1;
  30. l_pp=-1;
  31. if (!init)
  32. {
  33. init=1;
  34. DXL_InitVideoEx(1,1);
  35. }
  36. m_uvflip=uvflip;
  37. vidbufdec.y.baseAddr=0;
  38. xim = DXL_AlterXImage( NULL, (unsigned char *)"" ,MAKEFOURCC('V','P','3','1'), DXRGBNULL,w,h);
  39. }
  40. VP3_Decoder::~VP3_Decoder()
  41. {
  42. if ( xim ) DXL_DestroyXImage( xim);
  43. }
  44. int VP3_Decoder::decode(int need_kf,
  45. void *in, int in_len,
  46. void **out, // out is set to a pointer to data
  47. unsigned int *out_type, // 'Y','V','1','2' is currently defined
  48. int *is_kf)
  49. {
  50. BYTE *data=(BYTE*)in;
  51. if (!xim) return -1;
  52. *out_type=NSV_MAKETYPE('Y','V','1','2');
  53. if (vp3_postprocess != l_pp || vp3_targetcpu != l_tcpu)
  54. {
  55. l_pp=vp3_postprocess;
  56. l_tcpu=vp3_targetcpu;
  57. if (l_pp)
  58. {
  59. int v=l_tcpu;
  60. if (v < 1) v=1;
  61. if (v > 100) v=100;
  62. vp31_SetParameter(xim,1, v);
  63. vp31_SetParameter(xim,0, 9);
  64. }
  65. else
  66. {
  67. vp31_SetParameter(xim,1, 0);
  68. vp31_SetParameter(xim,0, 0);
  69. }
  70. }
  71. DXL_AlterXImageData( xim, data);
  72. DXL_SetXImageCSize(xim, in_len);
  73. *is_kf=!(!in_len || data[0] > 0x7f);
  74. *out=NULL;
  75. if ((need_kf && !*is_kf) || !in_len)
  76. {
  77. return 0;
  78. }
  79. if (!DXL_dxImageToVScreen( xim, NULL))
  80. {
  81. GetImageBufs(xim,&vidbufdec);
  82. if (m_uvflip)
  83. {
  84. YV12_PLANE tmp=vidbufdec.v;
  85. vidbufdec.v=vidbufdec.u;
  86. vidbufdec.u=tmp;
  87. }
  88. *out=&vidbufdec;
  89. return 0;
  90. }
  91. return -1;
  92. }
  93. IVideoDecoder *VP3_CREATE(int w, int h, double framerate, unsigned int fmt, int *flip)
  94. {
  95. if (fmt == NSV_MAKETYPE('V','P','3',' ') || fmt == NSV_MAKETYPE('V','P','3','1'))
  96. {
  97. *flip=1;
  98. return new VP3_Decoder(w,h,fmt == NSV_MAKETYPE('V','P','3',' '));
  99. }
  100. return NULL;
  101. }