aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavilla <davilla@svn>2010-01-26 21:24:37 +0000
committerdavilla <davilla@svn>2010-01-26 21:24:37 +0000
commit2523d3222d21fc73854d251609d334e6540ad1a3 (patch)
tree84251f380e4da417212fc1c1658f41a4cda4ddba
parent23a83cb825fbfd4f74e4430959e6ea021b7f5d9d (diff)
add YV12 to NV12 picture convertion for testing rendering and shaders
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@27198 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp58
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h2
2 files changed, 60 insertions, 0 deletions
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
index dd1956c290..20899db2e5 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
@@ -158,6 +158,64 @@ bool CDVDCodecUtils::CopyPicture(YV12Image* pImage, DVDVideoPicture *pSrc)
return true;
}
+DVDVideoPicture* CDVDCodecUtils::ConvertToNV12Picture(DVDVideoPicture *pSrc)
+{
+ // Clone a YV12 picture to new NV12 picture.
+ DVDVideoPicture* pPicture = new DVDVideoPicture;
+ if (pPicture)
+ {
+ *pPicture = *pSrc;
+
+ int w = pPicture->iWidth / 2;
+ int h = pPicture->iHeight / 2;
+ int size = w * h;
+ int totalsize = (pPicture->iWidth * pPicture->iHeight) + size * 2;
+ BYTE* data = new BYTE[totalsize];
+ if (data)
+ {
+ pPicture->data[0] = data;
+ pPicture->data[1] = pPicture->data[0] + (pPicture->iWidth * pPicture->iHeight);
+ pPicture->data[2] = NULL;
+ pPicture->data[3] = NULL;
+ pPicture->iLineSize[0] = pPicture->iWidth;
+ pPicture->iLineSize[1] = pPicture->iWidth;
+ pPicture->iLineSize[2] = 0;
+ pPicture->iLineSize[3] = 0;
+ pPicture->format = DVDVideoPicture::FMT_NV12;
+
+ // copy luma
+ uint8_t *s = pSrc->data[0];
+ uint8_t *d = pPicture->data[0];
+ for (int y = 0; y < pSrc->iHeight; y++)
+ {
+ fast_memcpy(d, s, pSrc->iWidth);
+ s += pSrc->iLineSize[0];
+ d += pPicture->iLineSize[0];
+ }
+
+ //copy chroma
+ uint8_t *s_u, *s_v, *d_uv;
+ for (int y = 0; y < pSrc->iHeight/2; y++) {
+ s_u = pSrc->data[1] + (y * pSrc->iLineSize[1]);
+ s_v = pSrc->data[2] + (y * pSrc->iLineSize[2]);
+ d_uv = pPicture->data[1] + (y * pPicture->iLineSize[1]);
+ for (int x = 0; x < pSrc->iWidth/2; x++) {
+ *d_uv++ = *s_u++;
+ *d_uv++ = *s_v++;
+ }
+ }
+
+ }
+ else
+ {
+ CLog::Log(LOGFATAL, "CDVDCodecUtils::AllocateNV12Picture, unable to allocate new video picture, out of memory.");
+ delete pPicture;
+ pPicture = NULL;
+ }
+ }
+ return pPicture;
+}
+
bool CDVDCodecUtils::CopyNV12Picture(YV12Image* pImage, DVDVideoPicture *pSrc)
{
BYTE *s = pSrc->data[0];
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
index ae3bffeeb8..f529d07ef0 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
@@ -32,6 +32,8 @@ public:
static void FreePicture(DVDVideoPicture* pPicture);
static bool CopyPicture(DVDVideoPicture* pDst, DVDVideoPicture* pSrc);
static bool CopyPicture(YV12Image* pDst, DVDVideoPicture *pSrc);
+
+ static DVDVideoPicture* ConvertToNV12Picture(DVDVideoPicture *pSrc);
static bool CopyNV12Picture(YV12Image* pImage, DVDVideoPicture *pSrc);
};