Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2011-08-11 02:02:49 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-08-11 02:02:49 +0400
commit5120ff34ceb2baee049582abded29ea597f3372b (patch)
tree3811dcdd8693f44517fb2e7fa6f1db9f92b99e65 /src/thirdparty/VirtualDub/Kasumi
parent24fc79bfb297d24b091e6950f9277edfe9e88c84 (diff)
update VirtualDub to v1.10.1-test11
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3643 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/thirdparty/VirtualDub/Kasumi')
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj4
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj.filters12
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/blt_spanutils_x86.h2
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/stdafx.h21
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit.h40
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit_base.h2
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit_gen.h10
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit_interlace.h123
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr.h154
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr_generic.h154
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/alphablt.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blitter.cpp52
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt.cpp24
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference.cpp89
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference_pal.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference_rgb.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv2yuv.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuvrev.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_setup.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils_x86.cpp3
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_uberblit.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/blt_x86.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/pixel.cpp371
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/pixmaputils.cpp100
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/region.cpp152
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/resample.cpp3
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/resample_kernels.cpp37
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/resample_stages.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/resample_stages_reference.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/resample_stages_x86.cpp27
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/stdafx.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/stretchblt_reference.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/tables.cpp1
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/triblt.cpp75
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit.cpp703
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_16f.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_gen.cpp136
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special_x86.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle_x86.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_v210.cpp19
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_generic.cpp545
-rw-r--r--src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_x86.cpp19
47 files changed, 2940 insertions, 318 deletions
diff --git a/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj b/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj
index 8ca5eefac..69aac6598 100644
--- a/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj
+++ b/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj
@@ -110,6 +110,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="source\alphablt.cpp" />
+ <ClCompile Include="source\blitter.cpp" />
<ClCompile Include="source\blt.cpp" />
<ClCompile Include="source\blt_reference.cpp" />
<ClCompile Include="source\blt_reference_pal.cpp" />
@@ -141,6 +142,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="source\uberblit_v210.cpp" />
+ <ClCompile Include="source\uberblit_ycbcr_generic.cpp" />
<ClCompile Include="source\uberblit_ycbcr_x86.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@@ -190,6 +192,7 @@
<ClInclude Include="h\uberblit_fill.h" />
<ClInclude Include="h\uberblit_gen.h" />
<ClInclude Include="h\uberblit_input.h" />
+ <ClInclude Include="h\uberblit_interlace.h" />
<ClInclude Include="h\uberblit_pal.h" />
<ClInclude Include="h\uberblit_resample.h" />
<ClInclude Include="h\uberblit_resample_special.h" />
@@ -200,6 +203,7 @@
<ClInclude Include="h\uberblit_swizzle_x86.h" />
<ClInclude Include="h\uberblit_v210.h" />
<ClInclude Include="h\uberblit_ycbcr.h" />
+ <ClInclude Include="h\uberblit_ycbcr_generic.h" />
<ClInclude Include="h\uberblit_ycbcr_x86.h" />
<ClInclude Include="..\h\vd2\Kasumi\blitter.h" />
<ClInclude Include="..\h\vd2\Kasumi\resample_kernels.h" />
diff --git a/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj.filters b/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj.filters
index 728a2eb51..e8840b9c5 100644
--- a/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj.filters
+++ b/src/thirdparty/VirtualDub/Kasumi/Kasumi.vcxproj.filters
@@ -133,6 +133,12 @@
<ClCompile Include="source\resample_stages_x64.cpp">
<Filter>Source Files %28x64%29</Filter>
</ClCompile>
+ <ClCompile Include="source\blitter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="source\uberblit_ycbcr_generic.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="h\bitutils.h">
@@ -243,6 +249,12 @@
<ClInclude Include="..\h\vd2\Kasumi\resample_kernels.h">
<Filter>Interface Header Files</Filter>
</ClInclude>
+ <ClInclude Include="h\uberblit_interlace.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="h\uberblit_ycbcr_generic.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<YASM Include="source\a_bltrgb.asm">
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/blt_spanutils_x86.h b/src/thirdparty/VirtualDub/Kasumi/h/blt_spanutils_x86.h
index c697485a2..d0893558a 100644
--- a/src/thirdparty/VirtualDub/Kasumi/h/blt_spanutils_x86.h
+++ b/src/thirdparty/VirtualDub/Kasumi/h/blt_spanutils_x86.h
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2007 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/stdafx.h b/src/thirdparty/VirtualDub/Kasumi/h/stdafx.h
new file mode 100644
index 000000000..28ae68d6c
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/h/stdafx.h
@@ -0,0 +1,21 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <vd2/system/vdtypes.h>
+#include <vd2/Kasumi/pixmap.h>
+#include <uberblit.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit.h
index 72f8ee060..161166096 100644
--- a/src/thirdparty/VirtualDub/Kasumi/h/uberblit.h
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit.h
@@ -37,31 +37,43 @@ enum VDPixmapFormatToken {
kVDPixSamp_422_JPEG = 0x000000C0,
kVDPixSamp_420_MPEG2 = 0x00000100,
kVDPixSamp_420_MPEG2INT = 0x00000140,
- kVDPixSamp_420_MPEG1 = 0x00000180,
- kVDPixSamp_420_DVPAL = 0x000001C0,
- kVDPixSamp_411 = 0x00000200,
- kVDPixSamp_410 = 0x00000240,
+ kVDPixSamp_420_MPEG2INT1= 0x00000180, // MPEG-2 interlaced, top field
+ kVDPixSamp_420_MPEG2INT2= 0x000001C0, // MPEG-2 interlaced, bottom field
+ kVDPixSamp_420_MPEG1 = 0x00000200,
+ kVDPixSamp_420_DVPAL = 0x00000240,
+ kVDPixSamp_411 = 0x00000280,
+ kVDPixSamp_410 = 0x000002C0,
kVDPixSamp_Mask = 0x00000FC0,
kVDPixSamp_Bits = 6,
kVDPixSpace_Pal = 0x00001000,
- kVDPixSpace_RGB = 0x00002000,
+// kVDPixSpace_RGB = 0x00002000,
kVDPixSpace_BGR = 0x00003000,
- kVDPixSpace_BGRA = 0x00004000,
+ kVDPixSpace_BGR_Studio = 0x00004000,
kVDPixSpace_Y_601 = 0x00005000,
kVDPixSpace_Y_709 = 0x00006000,
- kVDPixSpace_YCC_601 = 0x00007000,
- kVDPixSpace_YCC_709 = 0x00008000,
- kVDPixSpace_YCC_JPEG = 0x00009000,
+ kVDPixSpace_Y_601_FR = 0x00007000,
+ kVDPixSpace_Y_709_FR = 0x00008000,
+ kVDPixSpace_YCC_601 = 0x0000B000,
+ kVDPixSpace_YCC_709 = 0x0000C000,
+ kVDPixSpace_YCC_601_FR = 0x0000D000,
+ kVDPixSpace_YCC_709_FR = 0x0000E000,
kVDPixSpace_Mask = 0x0003F000,
};
+struct VDPixmapPlaneSamplingInfo {
+ int mX; ///< X offset of sample from center location, in 16ths of plane pixels.
+ int mY; ///< Y offset of sample from center location, in 16ths of plane pixels.
+ int mXBits; ///< Horizontal subsampling factor in bits.
+ int mYBits; ///< Vertical subsampling factor in bits.
+};
+
struct VDPixmapSamplingInfo {
- int mCXOffset16;
- int mCrYOffset16;
- int mCbYOffset16;
- int mCXBits;
- int mCYBits;
+ bool mbInterlaced;
+ VDPixmapPlaneSamplingInfo mPlane1Cr;
+ VDPixmapPlaneSamplingInfo mPlane1Cb;
+ VDPixmapPlaneSamplingInfo mPlane2Cr;
+ VDPixmapPlaneSamplingInfo mPlane2Cb;
};
uint32 VDPixmapGetFormatTokenFromFormat(int format);
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_base.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_base.h
index 675619a7b..e01ef73fe 100644
--- a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_base.h
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_base.h
@@ -31,7 +31,7 @@ public:
mWindow.resize(mWindowSize * 2);
for(sint32 i=0; i<mWindowSize; ++i)
- mWindow[i] = mWindow[i + mWindowSize] = &mWindowBuffer[mWindowPitch * outputCount * i];
+ mWindow[i] = mWindow[i + mWindowSize] = mWindowBuffer.data() + (mWindowPitch * outputCount * i);
mWindowIndex = 0;
mWindowLastY = -0x3FFFFFFF;
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_gen.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_gen.h
index 3937fbba7..205430161 100644
--- a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_gen.h
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_gen.h
@@ -5,6 +5,7 @@
#include "uberblit.h"
class IVDPixmapGenSrc;
+struct VDPixmapGenYCbCrBasis;
class VDPixmapUberBlitterDirectCopy : public IVDPixmapBlitter {
public:
@@ -106,6 +107,9 @@ public:
void interleave_X8R8G8B8();
void interleave_B8R8();
+ void merge_fields(uint32 w, uint32 h, uint32 bpr);
+ void split_fields(uint32 bpr);
+
void ycbcr601_to_rgb32();
void ycbcr709_to_rgb32();
void rgb32_to_ycbcr601();
@@ -119,6 +123,12 @@ public:
void ycbcr601_to_ycbcr709();
void ycbcr709_to_ycbcr601();
+ void ycbcr_to_rgb32_generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB);
+ void ycbcr_to_rgb32f_generic(const VDPixmapGenYCbCrBasis& basis);
+ void rgb32_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB, uint32 colorSpace);
+ void rgb32f_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basis, uint32 colorSpace);
+ void ycbcr_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basisDst, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& basisSrc, bool srcLimitedRange, uint32 colorSpace);
+
void pointh(float xoffset, float xfactor, uint32 w);
void pointv(float yoffset, float yfactor, uint32 h);
void linearh(float xoffset, float xfactor, uint32 w, bool interpOnly);
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_interlace.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_interlace.h
new file mode 100644
index 000000000..23adaa76b
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_interlace.h
@@ -0,0 +1,123 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifndef f_VD2_KASUMI_UBERBLIT_INTERLACE_H
+#define f_VD2_KASUMI_UBERBLIT_INTERLACE_H
+
+#include "uberblit_base.h"
+
+class VDPixmapGen_SplitFields : public IVDPixmapGen {
+public:
+ void AddWindowRequest(int minDY, int maxDY) {
+ mpSrc->AddWindowRequest(minDY*2, maxDY*2+1);
+ }
+
+ void Start() {
+ mpSrc->Start();
+ }
+
+ sint32 GetWidth(int) const { return mWidth; }
+ sint32 GetHeight(int idx) const { return mHeight[idx]; }
+
+ bool IsStateful() const {
+ return false;
+ }
+
+ uint32 GetType(uint32 output) const {
+ return mpSrc->GetType(mSrcIndex);
+ }
+
+ const void *GetRow(sint32 y, uint32 index) {
+ return mpSrc->GetRow(y+y+index, mSrcIndex);
+ }
+
+ void ProcessRow(void *dst, sint32 y) {
+ memcpy(dst, GetRow(y, 0), mBpr);
+ }
+
+ void Init(IVDPixmapGen *src, uint32 srcindex, uint32 bpr) {
+ mpSrc = src;
+ mSrcIndex = srcindex;
+ mBpr = bpr;
+ mWidth = src->GetWidth(srcindex);
+
+ uint32 h = src->GetHeight(srcindex);
+ mHeight[0] = (h + 1) >> 1;
+ mHeight[1] = h >> 1;
+ }
+
+protected:
+ IVDPixmapGen *mpSrc;
+ uint32 mSrcIndex;
+ sint32 mWidth;
+ sint32 mHeight[2];
+ uint32 mBpr;
+};
+
+class VDPixmapGen_MergeFields : public IVDPixmapGen {
+public:
+ void AddWindowRequest(int minDY, int maxDY) {
+ mpSrc[0]->AddWindowRequest(minDY >> 1, maxDY >> 1);
+ mpSrc[1]->AddWindowRequest(minDY >> 1, maxDY >> 1);
+ }
+
+ void Start() {
+ mpSrc[0]->Start();
+ mpSrc[1]->Start();
+ }
+
+ sint32 GetWidth(int) const { return mWidth; }
+ sint32 GetHeight(int) const { return mHeight; }
+
+ bool IsStateful() const {
+ return false;
+ }
+
+ uint32 GetType(uint32 output) const {
+ return mpSrc[0]->GetType(mSrcIndex[0]);
+ }
+
+ const void *GetRow(sint32 y, uint32 index) {
+ int srcIndex = y & 1;
+ return mpSrc[srcIndex]->GetRow(y >> 1, mSrcIndex[srcIndex]);
+ }
+
+ void ProcessRow(void *dst, sint32 y) {
+ memcpy(dst, GetRow(y, 0), mBpr);
+ }
+
+ void Init(IVDPixmapGen *src1, uint32 srcindex1, IVDPixmapGen *src2, uint32 srcindex2, uint32 w, uint32 h, uint32 bpr) {
+ mpSrc[0] = src1;
+ mpSrc[1] = src2;
+ mSrcIndex[0] = srcindex1;
+ mSrcIndex[1] = srcindex2;
+
+ mWidth = w;
+ mHeight = h;
+ mBpr = bpr;
+ }
+
+protected:
+ IVDPixmapGen *mpSrc[2];
+ uint32 mSrcIndex[2];
+ sint32 mWidth;
+ sint32 mHeight;
+ uint32 mBpr;
+};
+
+#endif
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr.h
index 2eb62da01..d6ad5a6a7 100644
--- a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr.h
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr.h
@@ -34,6 +34,60 @@ protected:
uint32 mSrcIndexCr;
};
+class VDPixmapGenYCbCrToRGB32Base : public VDPixmapGenYCbCrToRGBBase {
+public:
+ void Start() {
+ mpSrcY->Start();
+ mpSrcCb->Start();
+ mpSrcCr->Start();
+
+ StartWindow(mWidth * 4);
+ }
+};
+
+
+class VDPixmapGenYCbCrToRGB32FBase : public VDPixmapGenYCbCrToRGBBase {
+public:
+ void Start() {
+ mpSrcY->Start();
+ mpSrcCb->Start();
+ mpSrcCr->Start();
+
+ StartWindow(mWidth * 16);
+ }
+};
+
+
+class VDPixmapGenRGB32ToYCbCrBase : public VDPixmapGenWindowBasedOneSource {
+public:
+ void Init(IVDPixmapGen *src, uint32 srcindex) {
+ InitSource(src, srcindex);
+ }
+
+ void Start() {
+ StartWindow(mWidth, 3);
+ }
+
+ const void *GetRow(sint32 y, uint32 index) {
+ return (const uint8 *)VDPixmapGenWindowBasedOneSource::GetRow(y, index) + mWindowPitch * index;
+ }
+};
+
+class VDPixmapGenRGB32FToYCbCrBase : public VDPixmapGenWindowBasedOneSource {
+public:
+ void Init(IVDPixmapGen *src, uint32 srcindex) {
+ InitSource(src, srcindex);
+ }
+
+ void Start() {
+ StartWindow(mWidth * sizeof(float), 3);
+ }
+
+ const void *GetRow(sint32 y, uint32 index) {
+ return (const uint8 *)VDPixmapGenWindowBasedOneSource::GetRow(y, index) + mWindowPitch * index;
+ }
+};
+
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Rec.601 converters
@@ -53,16 +107,8 @@ protected:
//
///////////////////////////////////////////////////////////////////////////////////////////////////
-class VDPixmapGenYCbCr601ToRGB32 : public VDPixmapGenYCbCrToRGBBase {
+class VDPixmapGenYCbCr601ToRGB32 : public VDPixmapGenYCbCrToRGB32Base {
public:
- void Start() {
- mpSrcY->Start();
- mpSrcCb->Start();
- mpSrcCr->Start();
-
- StartWindow(mWidth * 4);
- }
-
uint32 GetType(uint32 output) const {
return (mpSrcY->GetType(mSrcIndexY) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_8888 | kVDPixSpace_BGR;
}
@@ -93,16 +139,8 @@ protected:
}
};
-class VDPixmapGenYCbCr601ToRGB32F : public VDPixmapGenYCbCrToRGBBase {
+class VDPixmapGenYCbCr601ToRGB32F : public VDPixmapGenYCbCrToRGB32FBase {
public:
- void Start() {
- mpSrcY->Start();
- mpSrcCb->Start();
- mpSrcCr->Start();
-
- StartWindow(mWidth * 16);
- }
-
uint32 GetType(uint32 output) const {
return (mpSrcY->GetType(mSrcIndexY) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_32Fx4_LE | kVDPixSpace_BGR;
}
@@ -132,29 +170,17 @@ protected:
}
};
-class VDPixmapGenRGB32ToYCbCr601 : public VDPixmapGenWindowBasedOneSource {
+class VDPixmapGenRGB32ToYCbCr601 : public VDPixmapGenRGB32ToYCbCrBase {
public:
- void Init(IVDPixmapGen *src, uint32 srcindex) {
- InitSource(src, srcindex);
- }
-
- void Start() {
- StartWindow(mWidth, 3);
- }
-
- const void *GetRow(sint32 y, uint32 index) {
- return (const uint8 *)VDPixmapGenWindowBasedOneSource::GetRow(y, index) + mWindowPitch * index;
- }
-
uint32 GetType(uint32 output) const {
return (mpSrc->GetType(mSrcIndex) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_8 | kVDPixSpace_YCC_601;
}
protected:
void Compute(void *dst0, sint32 y) {
- uint8 *dstCb = (uint8 *)dst0;
- uint8 *dstY = dstCb + mWindowPitch;
- uint8 *dstCr = dstY + mWindowPitch;
+ uint8 *dstCr = (uint8 *)dst0;
+ uint8 *dstY = dstCr + mWindowPitch;
+ uint8 *dstCb = dstY + mWindowPitch;
const uint8 *srcRGB = (const uint8 *)mpSrc->GetRow(y, mSrcIndex);
@@ -174,29 +200,17 @@ protected:
// ! 6416. - 4681. 28784. 0. !
// ! 1048576. 8388608. 8388608. 65536. !
- *dstCb++ = (28784*r - 24103*g - 4681*b + 8388608 + 32768) >> 16;
+ *dstCr++ = (28784*r - 24103*g - 4681*b + 8388608 + 32768) >> 16;
*dstY ++ = (16829*r + 33039*g + 6416*b + 1048576 + 32768) >> 16;
- *dstCr++ = (-9714*r - 19071*g + 28784*b + 8388608 + 32768) >> 16;
+ *dstCb++ = (-9714*r - 19071*g + 28784*b + 8388608 + 32768) >> 16;
}
}
};
-class VDPixmapGenRGB32FToYCbCr601 : public VDPixmapGenWindowBasedOneSource {
+class VDPixmapGenRGB32FToYCbCr601 : public VDPixmapGenRGB32FToYCbCrBase {
public:
- void Init(IVDPixmapGen *src, uint32 srcindex) {
- InitSource(src, srcindex);
- }
-
- void Start() {
- StartWindow(mWidth * sizeof(float), 3);
- }
-
- const void *GetRow(sint32 y, uint32 index) {
- return (const uint8 *)VDPixmapGenWindowBasedOneSource::GetRow(y, index) + mWindowPitch * index;
- }
-
uint32 GetType(uint32 output) const {
- return (mpSrc->GetType(mSrcIndex) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_32F_LE | kVDPixSpace_YCC_709;
+ return (mpSrc->GetType(mSrcIndex) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_32F_LE | kVDPixSpace_YCC_601;
}
protected:
@@ -207,6 +221,8 @@ protected:
const float *srcRGB = (const float *)mpSrc->GetRow(y, mSrcIndex);
+ VDCPUCleanupExtensions();
+
for(sint32 i=0; i<mWidth; ++i) {
float r = srcRGB[2];
float g = srcRGB[1];
@@ -339,9 +355,9 @@ public:
protected:
void Compute(void *dst0, sint32 y) {
- uint8 *dstCb = (uint8 *)dst0;
- uint8 *dstY = dstCb + mWindowPitch;
- uint8 *dstCr = dstY + mWindowPitch;
+ uint8 *dstCr = (uint8 *)dst0;
+ uint8 *dstY = dstCr + mWindowPitch;
+ uint8 *dstCb = dstY + mWindowPitch;
const uint8 *srcRGB = (const uint8 *)mpSrc->GetRow(y, mSrcIndex);
@@ -351,9 +367,9 @@ protected:
int b = (int)srcRGB[0];
srcRGB += 4;
- *dstCb++ = (28784*r - 26145*g - 2639*b + 8388608 + 32768) >> 16;
+ *dstCr++ = (28784*r - 26145*g - 2639*b + 8388608 + 32768) >> 16;
*dstY ++ = (11966*r + 40254*g + 4064*b + 1048576 + 32768) >> 16;
- *dstCr++ = (-6596*r - 22189*g + 28784*b + 8388608 + 32768) >> 16;
+ *dstCb++ = (-6596*r - 22189*g + 28784*b + 8388608 + 32768) >> 16;
}
}
};
@@ -378,9 +394,9 @@ public:
protected:
void Compute(void *dst0, sint32 y) {
- float *dstCb = (float *)dst0;
- float *dstY = dstCb + mWindowPitch;
- float *dstCr = dstY + mWindowPitch;
+ float *dstCr = (float *)dst0;
+ float *dstY = dstCr + mWindowPitch;
+ float *dstCb = dstY + mWindowPitch;
const float *srcRGB = (const float *)mpSrc->GetRow(y, mSrcIndex);
@@ -392,9 +408,9 @@ protected:
float b = srcRGB[0];
srcRGB += 4;
- *dstCb++ = -0.1006437f*r - 0.3385720f*g + 0.4392157f*b + (128.0f / 255.0f);
+ *dstCr++ = -0.1006437f*r - 0.3385720f*g + 0.4392157f*b + (128.0f / 255.0f);
*dstY++ = 0.1825859f*r + 0.6142306f*g + 0.0620071f*b + ( 16.0f / 255.0f);
- *dstCr++ = 0.4392157f*r - 0.3989422f*g - 0.0402735f*b + (128.0f / 255.0f);
+ *dstCb++ = 0.4392157f*r - 0.3989422f*g - 0.0402735f*b + (128.0f / 255.0f);
}
}
};
@@ -529,12 +545,12 @@ protected:
for(sint32 i=0; i<mWidth; ++i) {
float y = srcY[i];
- float cb = srcCb[i] - (128.0f / 255.0f);
- float cr = srcCr[i] - (128.0f / 255.0f);
+ float cb = srcCb[i];
+ float cr = srcCr[i];
- *dstY++ = y - 0.1155497f*cb - 0.2079376f*cr;
- *dstCb++ = 1.0186397f*cb + 0.1146180f*cr + (128.0f / 255.0f);
- *dstCr++ = 0.0750494f*cb + 1.0253271f*cr + (128.0f / 255.0f);
+ *dstY++ = y - 0.1155497f*cb - 0.2079376f*cr;
+ *dstCb++ = 1.0186397f*cb + 0.1146180f*cr;
+ *dstCr++ = 0.0750494f*cb + 1.0253271f*cr;
}
}
};
@@ -571,12 +587,12 @@ protected:
for(sint32 i=0; i<mWidth; ++i) {
float y = srcY[i];
- float cb = srcCb[i] - (128.0f / 255.0f);
- float cr = srcCr[i] - (128.0f / 255.0f);
+ float cb = srcCb[i];
+ float cr = srcCr[i];
*dstY++ = y - 0.1155497f*cb - 0.2079376f*cr;
- *dstCb++ = 0.9898538f*cb - 0.1106525f*cr + (128.0f / 255.0f);
- *dstCr++ = - 0.0724530f*cb + 0.9833978f*cr + (128.0f / 255.0f);
+ *dstCb++ = 0.9898538f*cb - 0.1106525f*cr;
+ *dstCr++ = - 0.0724530f*cb + 0.9833978f*cr;
}
}
};
diff --git a/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr_generic.h b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr_generic.h
new file mode 100644
index 000000000..3b8af02e8
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/h/uberblit_ycbcr_generic.h
@@ -0,0 +1,154 @@
+#ifndef f_VD2_KASUMI_UBERBLIT_YCBCR_GENERIC_H
+#define f_VD2_KASUMI_UBERBLIT_YCBCR_GENERIC_H
+
+#include "uberblit_ycbcr.h"
+
+struct VDPixmapGenYCbCrBasis {
+ float mKr;
+ float mKb;
+ float mToRGB[2][3];
+};
+
+extern const VDPixmapGenYCbCrBasis g_VDPixmapGenYCbCrBasis_601;
+extern const VDPixmapGenYCbCrBasis g_VDPixmapGenYCbCrBasis_709;
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenYCbCrToRGB32Generic : public VDPixmapGenYCbCrToRGB32Base {
+public:
+ VDPixmapGenYCbCrToRGB32Generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB);
+
+ uint32 GetType(uint32 output) const;
+
+protected:
+ virtual void Compute(void *dst0, sint32 y);
+
+ sint32 mCoY;
+ sint32 mCoRCr;
+ sint32 mCoGCr;
+ sint32 mCoGCb;
+ sint32 mCoBCb;
+ sint32 mBiasR;
+ sint32 mBiasG;
+ sint32 mBiasB;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenYCbCrToRGB32FGeneric : public VDPixmapGenYCbCrToRGB32FBase {
+public:
+ VDPixmapGenYCbCrToRGB32FGeneric(const VDPixmapGenYCbCrBasis& basis);
+
+ uint32 GetType(uint32 output) const;
+
+protected:
+ void Compute(void *dst0, sint32 y);
+
+ float mCoRCr;
+ float mCoGCr;
+ float mCoGCb;
+ float mCoBCb;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenRGB32ToYCbCrGeneric : public VDPixmapGenRGB32ToYCbCrBase {
+public:
+ VDPixmapGenRGB32ToYCbCrGeneric(const VDPixmapGenYCbCrBasis& basis, bool studioRGB, uint32 colorSpace);
+
+ uint32 GetType(uint32 output) const;
+
+protected:
+ void Compute(void *dst0, sint32 y);
+
+ sint32 mCoYR;
+ sint32 mCoYG;
+ sint32 mCoYB;
+ sint32 mCoCbR;
+ sint32 mCoCbG;
+ sint32 mCoCbB;
+ sint32 mCoCrR;
+ sint32 mCoCrG;
+ sint32 mCoCrB;
+ sint32 mCoYA;
+ sint32 mCoCbA;
+ sint32 mCoCrA;
+
+ const uint32 mColorSpace;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenRGB32FToYCbCrGeneric : public VDPixmapGenRGB32FToYCbCrBase {
+public:
+ VDPixmapGenRGB32FToYCbCrGeneric(const VDPixmapGenYCbCrBasis& basis, uint32 colorSpace);
+
+ uint32 GetType(uint32 output) const;
+
+protected:
+ void Compute(void *dst0, sint32 y);
+
+ float mCoYR;
+ float mCoYG;
+ float mCoYB;
+ float mCoCb;
+ float mCoCr;
+
+ const uint32 mColorSpace;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenYCbCrToYCbCrGeneric : public VDPixmapGenYCbCrToRGBBase {
+public:
+ VDPixmapGenYCbCrToYCbCrGeneric(const VDPixmapGenYCbCrBasis& dstBasis, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& srcBasis, bool srcLimitedRange, uint32 colorSpace);
+
+ void Start();
+ const void *GetRow(sint32 y, uint32 index);
+ uint32 GetType(uint32 output) const;
+
+protected:
+ void Compute(void *dst0, sint32 ypos);
+
+ sint32 mCoYY;
+ sint32 mCoYCb;
+ sint32 mCoYCr;
+ sint32 mCoYA;
+ sint32 mCoCbCb;
+ sint32 mCoCbCr;
+ sint32 mCoCbA;
+ sint32 mCoCrCb;
+ sint32 mCoCrCr;
+ sint32 mCoCrA;
+
+ const uint32 mColorSpace;
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+class VDPixmapGenYCbCrToYCbCrGeneric_32F : public VDPixmapGenYCbCrToRGBBase {
+public:
+ VDPixmapGenYCbCrToYCbCrGeneric_32F(const VDPixmapGenYCbCrBasis& dstBasis, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& srcBasis, bool srcLimitedRange, uint32 colorSpace);
+
+ void Start();
+ const void *GetRow(sint32 y, uint32 index);
+ uint32 GetType(uint32 output) const;
+
+protected:
+ void Compute(void *dst0, sint32 ypos);
+
+ float mCoYY;
+ float mCoYCb;
+ float mCoYCr;
+ float mCoYA;
+ float mCoCbCb;
+ float mCoCbCr;
+ float mCoCbA;
+ float mCoCrCb;
+ float mCoCrCr;
+ float mCoCrA;
+
+ const uint32 mColorSpace;
+};
+
+#endif
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/alphablt.cpp b/src/thirdparty/VirtualDub/Kasumi/source/alphablt.cpp
index a292ca2bd..93501ede4 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/alphablt.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/alphablt.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/math.h>
#include <vd2/system/cpuaccel.h>
#include <vd2/Kasumi/pixmap.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blitter.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blitter.cpp
new file mode 100644
index 000000000..0879424d2
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blitter.cpp
@@ -0,0 +1,52 @@
+#include <stdafx.h>
+#include <vd2/Kasumi/blitter.h>
+
+VDPixmapCachedBlitter::VDPixmapCachedBlitter()
+ : mSrcWidth(0)
+ , mSrcHeight(0)
+ , mSrcFormat(0)
+ , mDstWidth(0)
+ , mDstHeight(0)
+ , mDstFormat(0)
+ , mpCachedBlitter(NULL)
+{
+}
+
+VDPixmapCachedBlitter::~VDPixmapCachedBlitter() {
+ Invalidate();
+}
+
+void VDPixmapCachedBlitter::Blit(const VDPixmap& dst, const VDPixmap& src) {
+ VDASSERT(src.w == dst.w && src.h == dst.h);
+
+ if (!mpCachedBlitter ||
+ dst.w != mDstWidth ||
+ dst.h != mDstHeight ||
+ dst.format != mDstFormat ||
+ src.w != mSrcWidth ||
+ src.h != mSrcHeight ||
+ src.format != mSrcFormat)
+ {
+ if (mpCachedBlitter)
+ delete mpCachedBlitter;
+ mpCachedBlitter = VDPixmapCreateBlitter(dst, src);
+ if (!mpCachedBlitter)
+ return;
+
+ mDstWidth = dst.w;
+ mDstHeight = dst.h;
+ mDstFormat = dst.format;
+ mSrcWidth = src.w;
+ mSrcHeight = src.h;
+ mSrcFormat = src.format;
+ }
+
+ mpCachedBlitter->Blit(dst, src);
+}
+
+void VDPixmapCachedBlitter::Invalidate() {
+ if (mpCachedBlitter) {
+ delete mpCachedBlitter;
+ mpCachedBlitter = NULL;
+ }
+}
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt.cpp
index 75e5542a9..7a5d1c7c1 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vector>
#include <vd2/system/memory.h>
#include <vd2/system/cpuaccel.h>
@@ -189,6 +208,11 @@ bool VDNOINLINE VDPixmapBltTwoStage(const VDPixmap& dst, const VDPixmap& src, vd
}
bool VDPixmapBltFast(const VDPixmap& dst, const VDPixmap& src, vdpixsize w, vdpixsize h) {
+ if (w <= 0 || h <= 0) {
+ VDASSERT((w|h) >= 0);
+ return true;
+ }
+
if (VDPixmapBltDirect(dst, src, w, h))
return true;
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference.cpp
index c4dccce9f..4ee033bde 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
@@ -116,7 +135,40 @@ void VDPixmapInitBlittersReference(VDPixmapBlitterTable& table) {
kPixFormat_YUV420_Planar_Centered,
kPixFormat_YUV422_V210,
kPixFormat_YUV422_UYVY_709,
- kPixFormat_YUV420_NV12;
+ kPixFormat_YUV420_NV12,
+ kPixFormat_Y8_FR,
+ kPixFormat_YUV422_YUYV_709,
+ kPixFormat_YUV444_Planar_709,
+ kPixFormat_YUV422_Planar_709,
+ kPixFormat_YUV420_Planar_709,
+ kPixFormat_YUV411_Planar_709,
+ kPixFormat_YUV410_Planar_709,
+ kPixFormat_YUV422_UYVY_FR,
+ kPixFormat_YUV422_YUYV_FR,
+ kPixFormat_YUV444_Planar_FR,
+ kPixFormat_YUV422_Planar_FR,
+ kPixFormat_YUV420_Planar_FR,
+ kPixFormat_YUV411_Planar_FR,
+ kPixFormat_YUV410_Planar_FR,
+ kPixFormat_YUV422_UYVY_709_FR,
+ kPixFormat_YUV422_YUYV_709_FR,
+ kPixFormat_YUV444_Planar_709_FR,
+ kPixFormat_YUV422_Planar_709_FR,
+ kPixFormat_YUV420_Planar_709_FR,
+ kPixFormat_YUV411_Planar_709_FR,
+ kPixFormat_YUV410_Planar_709_FR,
+ kPixFormat_YUV420i_Planar,
+ kPixFormat_YUV420i_Planar_FR,
+ kPixFormat_YUV420i_Planar_709,
+ kPixFormat_YUV420i_Planar_709_FR,
+ kPixFormat_YUV420it_Planar,
+ kPixFormat_YUV420it_Planar_FR,
+ kPixFormat_YUV420it_Planar_709,
+ kPixFormat_YUV420it_Planar_709_FR,
+ kPixFormat_YUV420ib_Planar,
+ kPixFormat_YUV420ib_Planar_FR,
+ kPixFormat_YUV420ib_Planar_709,
+ kPixFormat_YUV420ib_Planar_709_FR;
uberblitDstFormats =
kPixFormat_XRGB1555,
@@ -137,7 +189,40 @@ void VDPixmapInitBlittersReference(VDPixmapBlitterTable& table) {
kPixFormat_YUV420_Planar_Centered,
kPixFormat_YUV422_V210,
kPixFormat_YUV422_UYVY_709,
- kPixFormat_YUV420_NV12;
+ kPixFormat_YUV420_NV12,
+ kPixFormat_Y8_FR,
+ kPixFormat_YUV422_YUYV_709,
+ kPixFormat_YUV444_Planar_709,
+ kPixFormat_YUV422_Planar_709,
+ kPixFormat_YUV420_Planar_709,
+ kPixFormat_YUV411_Planar_709,
+ kPixFormat_YUV410_Planar_709,
+ kPixFormat_YUV422_UYVY_FR,
+ kPixFormat_YUV422_YUYV_FR,
+ kPixFormat_YUV444_Planar_FR,
+ kPixFormat_YUV422_Planar_FR,
+ kPixFormat_YUV420_Planar_FR,
+ kPixFormat_YUV411_Planar_FR,
+ kPixFormat_YUV410_Planar_FR,
+ kPixFormat_YUV422_UYVY_709_FR,
+ kPixFormat_YUV422_YUYV_709_FR,
+ kPixFormat_YUV444_Planar_709_FR,
+ kPixFormat_YUV422_Planar_709_FR,
+ kPixFormat_YUV420_Planar_709_FR,
+ kPixFormat_YUV411_Planar_709_FR,
+ kPixFormat_YUV410_Planar_709_FR,
+ kPixFormat_YUV420i_Planar,
+ kPixFormat_YUV420i_Planar_FR,
+ kPixFormat_YUV420i_Planar_709,
+ kPixFormat_YUV420i_Planar_709_FR,
+ kPixFormat_YUV420it_Planar,
+ kPixFormat_YUV420it_Planar_FR,
+ kPixFormat_YUV420it_Planar_709,
+ kPixFormat_YUV420it_Planar_709_FR,
+ kPixFormat_YUV420ib_Planar,
+ kPixFormat_YUV420ib_Planar_FR,
+ kPixFormat_YUV420ib_Planar_709,
+ kPixFormat_YUV420ib_Planar_709_FR;
table.AddBlitter(uberblitSrcFormats, uberblitDstFormats, VDPixmapBlt_UberblitAdapter);
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_pal.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_pal.cpp
index 4a103de3b..4bf5a5f71 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_pal.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_pal.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_rgb.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_rgb.cpp
index ea49f260d..8f7c2df6a 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_rgb.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_rgb.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv.cpp
index 6f40eeaa0..ffd96052f 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/system/vdstl.h>
#include <vd2/system/cpuaccel.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv2yuv.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv2yuv.cpp
index b581e9bf7..093ac5360 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv2yuv.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuv2yuv.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/system/memory.h>
#include <vd2/system/vdstl.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuvrev.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuvrev.cpp
index d6f38bf65..d6f6ce75d 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuvrev.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_reference_yuvrev.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/cpuaccel.h>
#include <vd2/system/vdtypes.h>
#include <vd2/system/vdstl.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_setup.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_setup.cpp
index ce999221a..c4b3746a6 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_setup.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_setup.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "blt_setup.h"
void VDPixmapBlitterTable::Clear() {
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils.cpp
index 6baeeca36..07885b929 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "blt_spanutils.h"
#include "bitutils.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils_x86.cpp
index ea9e0599a..f529444ca 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_spanutils_x86.cpp
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2007 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <stdafx.h>
#include "blt_spanutils_x86.h"
#ifdef _MSC_VER
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_uberblit.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_uberblit.cpp
index dcaa20907..73eb269e8 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_uberblit.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_uberblit.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdalloc.h>
#include <vd2/Kasumi/pixmap.h>
#include "uberblit.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/blt_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/blt_x86.cpp
index af1519c5b..29cce407f 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/blt_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/blt_x86.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/pixel.cpp b/src/thirdparty/VirtualDub/Kasumi/source/pixel.cpp
index 4e7c7f4d6..e6eaada3f 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/pixel.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/pixel.cpp
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2007 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <stdafx.h>
#include <vd2/system/math.h>
#include <vd2/system/halffloat.h>
#include <vd2/Kasumi/pixmap.h>
@@ -109,8 +110,16 @@ uint32 VDPixmapSample(const VDPixmap& px, sint32 x, sint32 y) {
}
break;
+ case nsVDPixmap::kPixFormat_Y8_FR:
+ {
+ uint8 luma = ((const uint8 *)px.data + px.pitch*y)[x];
+
+ return (uint32)luma * 0x010101;
+ }
+ break;
+
case nsVDPixmap::kPixFormat_YUV444_Planar:
- return VDConvertYCbCrToRGB(VDPixmapSample8(px.data, px.pitch, x, y), VDPixmapSample8(px.data2, px.pitch2, x, y), VDPixmapSample8(px.data3, px.pitch3, x, y));
+ return VDConvertYCbCrToRGB(VDPixmapSample8(px.data, px.pitch, x, y), VDPixmapSample8(px.data2, px.pitch2, x, y), VDPixmapSample8(px.data3, px.pitch3, x, y), false, false);
case nsVDPixmap::kPixFormat_YUV422_Planar:
{
@@ -122,7 +131,8 @@ uint32 VDPixmapSample(const VDPixmap& px, sint32 x, sint32 y) {
return VDConvertYCbCrToRGB(
VDPixmapSample8(px.data, px.pitch, x, y),
VDPixmapInterpolateSample8(px.data2, px.pitch2, w2, h2, u, v),
- VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v));
+ VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v),
+ false, false);
}
case nsVDPixmap::kPixFormat_YUV420_Planar:
@@ -135,7 +145,8 @@ uint32 VDPixmapSample(const VDPixmap& px, sint32 x, sint32 y) {
return VDConvertYCbCrToRGB(
VDPixmapSample8(px.data, px.pitch, x, y),
VDPixmapInterpolateSample8(px.data2, px.pitch2, w2, h2, u, v),
- VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v));
+ VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v),
+ false, false);
}
case nsVDPixmap::kPixFormat_YUV411_Planar:
@@ -148,7 +159,8 @@ uint32 VDPixmapSample(const VDPixmap& px, sint32 x, sint32 y) {
return VDConvertYCbCrToRGB(
VDPixmapSample8(px.data, px.pitch, x, y),
VDPixmapInterpolateSample8(px.data2, px.pitch2, w2, h2, u, v),
- VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v));
+ VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v),
+ false, false);
}
case nsVDPixmap::kPixFormat_YUV410_Planar:
@@ -161,7 +173,8 @@ uint32 VDPixmapSample(const VDPixmap& px, sint32 x, sint32 y) {
return VDConvertYCbCrToRGB(
VDPixmapSample8(px.data, px.pitch, x, y),
VDPixmapInterpolateSample8(px.data2, px.pitch2, w2, h2, u, v),
- VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v));
+ VDPixmapInterpolateSample8(px.data3, px.pitch3, w2, h2, u, v),
+ false, false);
}
default:
@@ -212,18 +225,18 @@ uint32 VDPixmapInterpolateSample8To24(const void *data, ptrdiff_t pitch, uint32
x_256 &= ~(x_256 >> 31);
y_256 &= ~(y_256 >> 31);
- uint32 w_256 = (w - 1) << 8;
- uint32 h_256 = (h - 1) << 8;
- x_256 ^= (x_256 ^ w_256) & ((x_256 - w_256) >> 31);
- y_256 ^= (y_256 ^ h_256) & ((y_256 - h_256) >> 31);
+ sint32 w_256 = (w - 1) << 8;
+ sint32 h_256 = (h - 1) << 8;
+ x_256 += (w_256 - x_256) & ((w_256 - x_256) >> 31);
+ y_256 += (h_256 - y_256) & ((h_256 - y_256) >> 31);
const uint8 *row0 = (const uint8 *)data + pitch * (y_256 >> 8) + (x_256 >> 8);
const uint8 *row1 = row0;
- if ((uint32)y_256 < h_256)
+ if (y_256 < h_256)
row1 += pitch;
- ptrdiff_t xstep = (uint32)x_256 < w_256 ? 1 : 0;
+ ptrdiff_t xstep = x_256 < w_256 ? 1 : 0;
sint32 xoffset = x_256 & 255;
sint32 yoffset = y_256 & 255;
sint32 p00 = row0[0];
@@ -371,10 +384,10 @@ namespace {
return VDClampedRoundFixedToUint8Fast((float)(y-0x100000) * (1.1643836f/65536.0f/255.0f))*0x010101;
}
- uint32 InterpPlanarYCC888(const VDPixmap& px, sint32 x1, sint32 y1, sint32 x23, sint32 y23, uint32 w23, uint32 h23) {
- float y = (float)(sint32)VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
- float cb = (float)(sint32)VDPixmapInterpolateSample8To24(px.data2, px.pitch2, w23, h23, x23, y23);
- float cr = (float)(sint32)VDPixmapInterpolateSample8To24(px.data3, px.pitch3, w23, h23, x23, y23);
+ uint32 ConvertYCC72ToRGB24(sint32 iy, sint32 icb, sint32 icr) {
+ float y = (float)iy;
+ float cb = (float)icb;
+ float cr = (float)icr;
// ! 1.1643836 - 5.599D-17 1.5960268 - 222.92157 !
// ! 1.1643836 - 0.3917623 - 0.8129676 135.57529 !
@@ -386,17 +399,17 @@ namespace {
return (ir << 16) + (ig << 8) + ib;
}
- uint32 ConvertYCC72ToRGB24(sint32 iy, sint32 icb, sint32 icr) {
+ uint32 ConvertYCC72ToRGB24_FR(sint32 iy, sint32 icb, sint32 icr) {
float y = (float)iy;
float cb = (float)icb;
float cr = (float)icr;
- // ! 1.1643836 - 5.599D-17 1.5960268 - 222.92157 !
- // ! 1.1643836 - 0.3917623 - 0.8129676 135.57529 !
- // ! 1.1643836 2.0172321 - 1.110D-16 - 276.83585 !
- uint32 ir = VDClampedRoundFixedToUint8Fast((1.1643836f/65536.0f/255.0f)*y + (1.5960268f/65536.0f/255.0f)*cr - (222.92157f / 255.0f));
- uint32 ig = VDClampedRoundFixedToUint8Fast((1.1643836f/65536.0f/255.0f)*y - (0.3917623f/65536.0f/255.0f)*cb - (0.8129676f/65536.0f/255.0f)*cr + (135.57529f / 255.0f));
- uint32 ib = VDClampedRoundFixedToUint8Fast((1.1643836f/65536.0f/255.0f)*y + (2.0172321f/65536.0f/255.0f)*cb - (276.83585f / 255.0f));
+ // 1. 0. 1.402 - 179.456
+ // 1. - 0.3441363 - 0.7141363 135.45889
+ // 1. 1.772 - 2.220D-16 - 226.816
+ uint32 ir = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y + (1.4020000f/65536.0f/255.0f)*cr - (179.456f / 255.0f));
+ uint32 ig = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y - (0.3441363f/65536.0f/255.0f)*cb - (0.7141363f/65536.0f/255.0f)*cr + (135.45889f / 255.0f));
+ uint32 ib = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y + (1.7720000f/65536.0f/255.0f)*cb - (226.816f / 255.0f));
return (ir << 16) + (ig << 8) + ib;
}
@@ -416,7 +429,90 @@ namespace {
return (ir << 16) + (ig << 8) + ib;
}
+ uint32 ConvertYCC72ToRGB24_709_FR(sint32 iy, sint32 icb, sint32 icr) {
+ float y = (float)iy;
+ float cb = (float)icb;
+ float cr = (float)icr;
+
+ // 1. 0. 1.5748 - 201.5744
+ // 1. - 0.1873243 - 0.4681243 83.897414
+ // 1. 1.8556 0. - 237.5168
+ uint32 ir = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y + (1.5748f/65536.0f/255.0f)*cr - (201.5744f / 255.0f));
+ uint32 ig = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y - (0.1873243f/65536.0f/255.0f)*cb - (0.4681243f/65536.0f/255.0f)*cr + (83.897414f / 255.0f));
+ uint32 ib = VDClampedRoundFixedToUint8Fast((1.0f/65536.0f/255.0f)*y + (1.8556f/65536.0f/255.0f)*cb - (237.5168f / 255.0f));
+
+ return (ir << 16) + (ig << 8) + ib;
+ }
+
+ uint32 InterpPlanarYCC888(const VDPixmap& px, sint32 x1, sint32 y1, sint32 x23, sint32 y23, uint32 w23, uint32 h23) {
+ sint32 y = VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
+ sint32 cb = VDPixmapInterpolateSample8To24(px.data2, px.pitch2, w23, h23, x23, y23);
+ sint32 cr = VDPixmapInterpolateSample8To24(px.data3, px.pitch3, w23, h23, x23, y23);
+
+ return ConvertYCC72ToRGB24(y, cb, cr);
+ }
+
+ uint32 InterpPlanarYCC888_709(const VDPixmap& px, sint32 x1, sint32 y1, sint32 x23, sint32 y23, uint32 w23, uint32 h23) {
+ sint32 y = VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
+ sint32 cb = VDPixmapInterpolateSample8To24(px.data2, px.pitch2, w23, h23, x23, y23);
+ sint32 cr = VDPixmapInterpolateSample8To24(px.data3, px.pitch3, w23, h23, x23, y23);
+
+ return ConvertYCC72ToRGB24_709(y, cb, cr);
+ }
+
+ uint32 InterpPlanarYCC888_FR(const VDPixmap& px, sint32 x1, sint32 y1, sint32 x23, sint32 y23, uint32 w23, uint32 h23) {
+ sint32 y = VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
+ sint32 cb = VDPixmapInterpolateSample8To24(px.data2, px.pitch2, w23, h23, x23, y23);
+ sint32 cr = VDPixmapInterpolateSample8To24(px.data3, px.pitch3, w23, h23, x23, y23);
+
+ return ConvertYCC72ToRGB24_FR(y, cb, cr);
+ }
+
+ uint32 InterpPlanarYCC888_709_FR(const VDPixmap& px, sint32 x1, sint32 y1, sint32 x23, sint32 y23, uint32 w23, uint32 h23) {
+ sint32 y = VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
+ sint32 cb = VDPixmapInterpolateSample8To24(px.data2, px.pitch2, w23, h23, x23, y23);
+ sint32 cr = VDPixmapInterpolateSample8To24(px.data3, px.pitch3, w23, h23, x23, y23);
+
+ return ConvertYCC72ToRGB24_709_FR(y, cb, cr);
+ }
+
+ template<uint32 (*ConvFn)(sint32, sint32, sint32)>
+ uint32 InterpPlanarYCC888_420i(const VDPixmap& px, sint32 x1, sint32 y1) {
+ sint32 y = VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x1, y1);
+ sint32 cb;
+ sint32 cr;
+
+ const uint8 *src2 = (const uint8 *)px.data2;
+ const uint8 *src3 = (const uint8 *)px.data3;
+ const ptrdiff_t pitch2 = px.pitch2 + px.pitch2;
+ const ptrdiff_t pitch3 = px.pitch3 + px.pitch3;
+ const uint32 w23 = (px.w + 1) >> 1;
+ const uint32 h23 = (px.h + 1) >> 1;
+ const sint32 xc = (x1 >> 1) + 64;
+ sint32 yc = (y1 >> 1) + 64;
+
+ if (y1 & 1) {
+ yc -= 256;
+ cb = VDPixmapInterpolateSample8To24(src2, pitch2, w23, h23 >> 1, xc, yc);
+ cr = VDPixmapInterpolateSample8To24(src3, pitch3, w23, h23 >> 1, xc, yc);
+ } else {
+ cb = VDPixmapInterpolateSample8To24(src2 + px.pitch2, pitch2, w23, (h23 + 1) >> 1, xc, yc);
+ cr = VDPixmapInterpolateSample8To24(src3 + px.pitch3, pitch3, w23, (h23 + 1) >> 1, xc, yc);
+ }
+
+ return ConvFn(y, cb, cr);
+ }
+
uint32 SampleV210_Y(const void *src, ptrdiff_t srcpitch, sint32 x, sint32 y, uint32 w, uint32 h) {
+ if (x < 0)
+ x = 0;
+ if ((uint32)x >= w)
+ x = w - 1;
+ if (y < 0)
+ y = 0;
+ if ((uint32)y >= h)
+ y = h - 1;
+
const uint32 *p = (const uint32 *)((const char *)src + srcpitch*y) + (x / 6)*4;
switch((uint32)x % 6) {
@@ -431,6 +527,15 @@ namespace {
}
uint32 SampleV210_Cb(const void *src, ptrdiff_t srcpitch, sint32 x, sint32 y, uint32 w, uint32 h) {
+ if (x < 0)
+ x = 0;
+ if ((uint32)x >= w)
+ x = w - 1;
+ if (y < 0)
+ y = 0;
+ if ((uint32)y >= h)
+ y = h - 1;
+
const uint32 *p = (const uint32 *)((const char *)src + srcpitch*y) + (x / 3)*4;
switch((uint32)x % 3) {
@@ -442,6 +547,15 @@ namespace {
}
uint32 SampleV210_Cr(const void *src, ptrdiff_t srcpitch, sint32 x, sint32 y, uint32 w, uint32 h) {
+ if (x < 0)
+ x = 0;
+ if ((uint32)x >= w)
+ x = w - 1;
+ if (y < 0)
+ y = 0;
+ if ((uint32)y >= h)
+ y = h - 1;
+
const uint32 *p = (const uint32 *)((const char *)src + srcpitch*y) + (x / 3)*4;
switch((uint32)x % 3) {
@@ -494,6 +608,20 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
VDPixmapInterpolateSample8x4To24((const char *)px.data + 3, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
);
+ case nsVDPixmap::kPixFormat_YUV422_UYVY_FR:
+ return ConvertYCC72ToRGB24_FR(
+ VDPixmapInterpolateSample8x2To24((const char *)px.data + 1, px.pitch, px.w, px.h, x_256, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 0, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 2, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
+ );
+
+ case nsVDPixmap::kPixFormat_YUV422_YUYV_FR:
+ return ConvertYCC72ToRGB24_FR(
+ VDPixmapInterpolateSample8x2To24((const char *)px.data + 0, px.pitch, px.w, px.h, x_256, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 1, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 3, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
+ );
+
case nsVDPixmap::kPixFormat_YUV444_XVYU:
return ConvertYCC72ToRGB24(
VDPixmapInterpolateSample8x4To24((const char *)px.data + 1, px.pitch, px.w, px.h, x_256, y_256),
@@ -508,6 +636,27 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
VDPixmapInterpolateSample8x4To24((const char *)px.data + 2, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
);
+ case nsVDPixmap::kPixFormat_YUV422_YUYV_709:
+ return ConvertYCC72ToRGB24_709(
+ VDPixmapInterpolateSample8x2To24((const char *)px.data + 0, px.pitch, px.w, px.h, x_256, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 1, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 3, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
+ );
+
+ case nsVDPixmap::kPixFormat_YUV422_UYVY_709_FR:
+ return ConvertYCC72ToRGB24_709_FR(
+ VDPixmapInterpolateSample8x2To24((const char *)px.data + 1, px.pitch, px.w, px.h, x_256, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 0, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 2, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
+ );
+
+ case nsVDPixmap::kPixFormat_YUV422_YUYV_709_FR:
+ return ConvertYCC72ToRGB24_709_FR(
+ VDPixmapInterpolateSample8x2To24((const char *)px.data + 0, px.pitch, px.w, px.h, x_256, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 1, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256),
+ VDPixmapInterpolateSample8x4To24((const char *)px.data + 3, px.pitch, (px.w + 1) >> 1, px.h, (x_256 >> 1) + 128, y_256)
+ );
+
case nsVDPixmap::kPixFormat_YUV420_NV12:
return ConvertYCC72ToRGB24(
VDPixmapInterpolateSample8To24(px.data, px.pitch, px.w, px.h, x_256, y_256),
@@ -519,16 +668,22 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
return InterpPlanarYCC888(px, x_256, y_256, x_256, y_256, px.w, px.h);
case nsVDPixmap::kPixFormat_YUV422_Planar:
- return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 128, y_256, (px.w + 1) >> 1, px.h);
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 64, y_256, (px.w + 1) >> 1, px.h);
case nsVDPixmap::kPixFormat_YUV411_Planar:
- return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 2) + 128, y_256, (px.w + 3) >> 2, px.h);
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 2) + 96, y_256, (px.w + 3) >> 2, px.h);
case nsVDPixmap::kPixFormat_YUV420_Planar:
- return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 128, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 64, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420it_Planar:
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) + 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420ib_Planar:
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) - 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
case nsVDPixmap::kPixFormat_YUV410_Planar:
- return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 2) + 128, y_256 >> 2, (px.w + 3) >> 2, (px.h + 3) >> 2);
+ return InterpPlanarYCC888(px, x_256, y_256, (x_256 >> 2) + 96, y_256 >> 2, (px.w + 3) >> 2, (px.h + 3) >> 2);
case nsVDPixmap::kPixFormat_YUV420_Planar_Centered:
return InterpPlanarYCC888(px, x_256, y_256, x_256 >> 1, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
@@ -536,6 +691,81 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
case nsVDPixmap::kPixFormat_YUV422_Planar_Centered:
return InterpPlanarYCC888(px, x_256, y_256, x_256 >> 1, y_256, (px.w + 1) >> 1, px.h);
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, x_256, y_256, px.w, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 1) + 64, y_256, (px.w + 1) >> 1, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV411_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 2) + 96, y_256, (px.w + 3) >> 2, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 1) + 64, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420it_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) + 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420ib_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) - 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709:
+ return InterpPlanarYCC888_709(px, x_256, y_256, (x_256 >> 2) + 96, y_256 >> 2, (px.w + 3) >> 2, (px.h + 3) >> 2);
+
+ case nsVDPixmap::kPixFormat_YUV444_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, x_256, y_256, px.w, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV422_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 1) + 64, y_256, (px.w + 1) >> 1, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV411_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 2) + 96, y_256, (px.w + 3) >> 2, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV420_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 1) + 64, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420it_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) + 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420ib_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) - 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV410_Planar_FR:
+ return InterpPlanarYCC888_FR(px, x_256, y_256, (x_256 >> 2) + 96, y_256 >> 2, (px.w + 3) >> 2, (px.h + 3) >> 2);
+
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, x_256, y_256, px.w, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 1) + 64, y_256, (px.w + 1) >> 1, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV411_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 2) + 96, y_256, (px.w + 3) >> 2, px.h);
+
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 1) + 64, y_256 >> 1, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420it_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) + 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV420ib_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 1) + 64, (y_256 >> 1) - 32, (px.w + 1) >> 1, (px.h + 1) >> 1);
+
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709_FR:
+ return InterpPlanarYCC888_709_FR(px, x_256, y_256, (x_256 >> 2) + 96, y_256 >> 2, (px.w + 3) >> 2, (px.h + 3) >> 2);
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar:
+ return InterpPlanarYCC888_420i<ConvertYCC72ToRGB24 >(px, x_256, y_256);
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_FR:
+ return InterpPlanarYCC888_420i<ConvertYCC72ToRGB24_FR >(px, x_256, y_256);
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_709:
+ return InterpPlanarYCC888_420i<ConvertYCC72ToRGB24_709 >(px, x_256, y_256);
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_709_FR:
+ return InterpPlanarYCC888_420i<ConvertYCC72ToRGB24_709_FR>(px, x_256, y_256);
+
case nsVDPixmap::kPixFormat_YUV422_Planar_16F:
{
float y = VDPixmapInterpolateSample16F(px.data, px.pitch, px.w, px.h, x_256, y_256);
@@ -601,18 +831,18 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
float chroma_fx = (float)(chroma_x & 255) * (1.0f / 255.0f);
float chroma_fy = (float)(chroma_y & 255) * (1.0f / 255.0f);
- float cb0 = SampleV210_Cb(px.data, px.pitch, chroma_ix+0, chroma_iy+0, px.w, px.h) * (1.0f / 1023.0f);
- float cb1 = SampleV210_Cb(px.data, px.pitch, chroma_ix+1, chroma_iy+0, px.w, px.h) * (1.0f / 1023.0f);
- float cb2 = SampleV210_Cb(px.data, px.pitch, chroma_ix+0, chroma_iy+1, px.w, px.h) * (1.0f / 1023.0f);
- float cb3 = SampleV210_Cb(px.data, px.pitch, chroma_ix+1, chroma_iy+1, px.w, px.h) * (1.0f / 1023.0f);
+ float cb0 = SampleV210_Cb(px.data, px.pitch, chroma_ix+0, chroma_iy+0, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cb1 = SampleV210_Cb(px.data, px.pitch, chroma_ix+1, chroma_iy+0, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cb2 = SampleV210_Cb(px.data, px.pitch, chroma_ix+0, chroma_iy+1, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cb3 = SampleV210_Cb(px.data, px.pitch, chroma_ix+1, chroma_iy+1, chroma_w, chroma_h) * (1.0f / 1023.0f);
float cbt = cb0 + (cb1 - cb0)*chroma_fx;
float cbb = cb2 + (cb3 - cb2)*chroma_fx;
float cbr = cbt + (cbb - cbt)*chroma_fy;
- float cr0 = SampleV210_Cr(px.data, px.pitch, chroma_ix+0, chroma_iy+0, px.w, px.h) * (1.0f / 1023.0f);
- float cr1 = SampleV210_Cr(px.data, px.pitch, chroma_ix+1, chroma_iy+0, px.w, px.h) * (1.0f / 1023.0f);
- float cr2 = SampleV210_Cr(px.data, px.pitch, chroma_ix+0, chroma_iy+1, px.w, px.h) * (1.0f / 1023.0f);
- float cr3 = SampleV210_Cr(px.data, px.pitch, chroma_ix+1, chroma_iy+1, px.w, px.h) * (1.0f / 1023.0f);
+ float cr0 = SampleV210_Cr(px.data, px.pitch, chroma_ix+0, chroma_iy+0, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cr1 = SampleV210_Cr(px.data, px.pitch, chroma_ix+1, chroma_iy+0, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cr2 = SampleV210_Cr(px.data, px.pitch, chroma_ix+0, chroma_iy+1, chroma_w, chroma_h) * (1.0f / 1023.0f);
+ float cr3 = SampleV210_Cr(px.data, px.pitch, chroma_ix+1, chroma_iy+1, chroma_w, chroma_h) * (1.0f / 1023.0f);
float crt = cr0 + (cr1 - cr0)*chroma_fx;
float crb = cr2 + (cr3 - cr2)*chroma_fx;
float crr = crt + (crb - crt)*chroma_fy;
@@ -630,15 +860,39 @@ uint32 VDPixmapInterpolateSampleRGB24(const VDPixmap& px, sint32 x_256, sint32 y
}
}
-uint32 VDConvertYCbCrToRGB(uint8 y0, uint8 cb0, uint8 cr0) {
- sint32 y = y0 - 16;
+uint32 VDConvertYCbCrToRGB(uint8 y0, uint8 cb0, uint8 cr0, bool use709, bool useFullRange) {
+ sint32 y = y0;
sint32 cb = cb0 - 128;
sint32 cr = cr0 - 128;
-
- sint32 y2 = y * 76309 + 0x8000;
- sint32 r = y2 + cr * 104597;
- sint32 g = y2 + cr * -53279 + cb * -25674;
- sint32 b = y2 + cb * 132201;
+ sint32 r;
+ sint32 g;
+ sint32 b;
+
+ if (use709) {
+ if (useFullRange) {
+ sint32 y2 = (y << 16) + 0x8000;
+ r = y2 + cr * 103206;
+ g = y2 + cr * -30679 + cb * -12276;
+ b = y2 + cb * 121609;
+ } else {
+ sint32 y2 = (y - 16) * 76309 + 0x8000;
+ r = y2 + cr * 117489;
+ g = y2 + cr * -34925 + cb * -13975;
+ b = y2 + cb * 138438;
+ }
+ } else {
+ if (useFullRange) {
+ sint32 y2 = (y << 16) + 0x8000;
+ r = y2 + cr * 91181;
+ g = y2 + cr * -46802 + cb * -22554;
+ b = y2 + cb * 166130;
+ } else {
+ sint32 y2 = (y - 16) * 76309 + 0x8000;
+ r = y2 + cr * 104597;
+ g = y2 + cr * -53279 + cb * -25674;
+ b = y2 + cb * 132201;
+ }
+ }
r &= ~(r >> 31);
g &= ~(g >> 31);
@@ -651,17 +905,38 @@ uint32 VDConvertYCbCrToRGB(uint8 y0, uint8 cb0, uint8 cr0) {
}
uint32 VDConvertRGBToYCbCr(uint32 c) {
- return VDConvertRGBToYCbCr((uint8)(c >> 16), (uint8)(c >> 8), (uint8)c);
+ return VDConvertRGBToYCbCr((uint8)(c >> 16), (uint8)(c >> 8), (uint8)c, false, false);
}
-uint32 VDConvertRGBToYCbCr(uint8 r8, uint8 g8, uint8 b8) {
+uint32 VDConvertRGBToYCbCr(uint8 r8, uint8 g8, uint8 b8, bool use709, bool useFullRange) {
sint32 r = r8;
sint32 g = g8;
sint32 b = b8;
- sint32 yt = 1052*r + 2065*g + 401*b;
- sint32 y = (yt + 0x10800) >> 4;
- sint32 cr = (10507932*r - yt*2987 + 0x80800000U) >> 8;
- sint32 cb = ( 8312025*b - yt*2363 + 0x80800000U) >> 24;
+ sint32 y;
+ sint32 cb;
+ sint32 cr;
+
+ if (use709) {
+ if (useFullRange) {
+ y = ( 13933*r + 46871*g + 4732*b + 0x8000) >> 8;
+ cb = ( -7509*r - 25259*g + 32768*b + 0x808000) >> 16;
+ cr = ( 32768*r - 29763*g - 3005*b + 0x808000);
+ } else {
+ y = ( 11966*r + 40254*g + 4064*b + 0x8000) >> 8;
+ cb = ( -6596*r - 22189*g + 28784*b + 0x808000) >> 16;
+ cr = ( 28784*r - 26145*g + 2639*b + 0x808000);
+ }
+ } else {
+ if (useFullRange) {
+ y = ( 19595*r + 38470*g + 7471*b + 0x8000) >> 8;
+ cb = (-11058*r - 21710*g + 32768*b + 0x808000) >> 16;
+ cr = ( 32768*r - 27439*g + 5329*b + 0x808000);
+ } else {
+ y = ( 16829*r + 33039*g + 6416*b + 0x108000) >> 8;
+ cb = ( -9714*r - 19071*g + 28784*b + 0x808000) >> 16;
+ cr = ( 28784*r - 24103*g - 4681*b + 0x808000);
+ }
+ }
return (uint8)cb + (y & 0xff00) + (cr&0xff0000);
}
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/pixmaputils.cpp b/src/thirdparty/VirtualDub/Kasumi/source/pixmaputils.cpp
index 1134a1e69..d43335a1b 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/pixmaputils.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/pixmaputils.cpp
@@ -1,3 +1,23 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
+#include <vd2/system/vdtypes.h>
#include <vd2/Kasumi/pixmaputils.h>
#include <vd2/system/memory.h>
@@ -27,8 +47,47 @@ extern VDPixmapFormatInfo g_vdPixmapFormats[] = {
/* V210 */ { "v210", true,24, 1, 2, 0, 64, 0, 0, 0, 1, 0 },
/* YUV422_UYVY_709 */ { "UYVY-709", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
/* NV12 */ { "NV12", false, 1, 1, 0, 0, 1, 1, 1, 1, 2, 0 },
+ /* Y8-FR */ { "I8", false, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0 },
+ /* YUV422_YUYV_709 */ { "YUYV-709", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
+ /* YUV444_Planar_709 */ { "YUV444-709", false, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0 },
+ /* YUV422_Planar_709 */ { "YUV422-709", false, 1, 1, 0, 0, 1, 2, 1, 0, 1, 0 },
+ /* YUV420_Planar_709 */ { "YUV420-709", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV411_Planar_709 */ { "YUV411-709", false, 1, 1, 0, 0, 1, 2, 2, 0, 1, 0 },
+ /* YUV410_Planar_709 */ { "YUV410-709", false, 1, 1, 0, 0, 1, 2, 2, 2, 1, 0 },
+ /* YUV422_UYVY_FR */ { "UYVY-FR", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
+ /* YUV422_YUYV_FR */ { "YUYV-FR", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
+ /* YUV444_Planar_FR */ { "YUV444-FR", false, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0 },
+ /* YUV422_Planar_FR */ { "YUV422-FR", false, 1, 1, 0, 0, 1, 2, 1, 0, 1, 0 },
+ /* YUV420_Planar_FR */ { "YUV420-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV411_Planar_FR */ { "YUV411-FR", false, 1, 1, 0, 0, 1, 2, 2, 0, 1, 0 },
+ /* YUV410_Planar_FR */ { "YUV410-FR", false, 1, 1, 0, 0, 1, 2, 2, 2, 1, 0 },
+ /* YUV422_UYVY_FR_709 */ { "UYVY-709-FR", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
+ /* YUV422_YUYV_FR_709 */ { "YUYV-709-FR", true, 2, 1, 1, 0, 4, 0, 0, 0, 0, 0 },
+ /* YUV444_Planar_FR_709 */ { "YUV444-709-FR", false, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0 },
+ /* YUV422_Planar_FR_709 */ { "YUV422-709-FR", false, 1, 1, 0, 0, 1, 2, 1, 0, 1, 0 },
+ /* YUV420_Planar_FR_709 */ { "YUV420-709-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV411_Planar_FR_709 */ { "YUV411-709-FR", false, 1, 1, 0, 0, 1, 2, 2, 0, 1, 0 },
+ /* YUV410_Planar_FR_709 */ { "YUV410-709-FR", false, 1, 1, 0, 0, 1, 2, 2, 2, 1, 0 },
+ /* YUV420i_Planar */ { "YUV420i", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420i_Planar_FR */ { "YUV420i-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420i_Planar_709 */ { "YUV420i-709", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420i_Planar_709_FR */ { "YUV420i-709-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420it_Planar */ { "YUV420it", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420it_Planar_FR */ { "YUV420it-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420it_Planar_709 */ { "YUV420it-709", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420it_Planar_709_FR */ { "YUV420it-709-FR",false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420ib_Planar */ { "YUV420ib", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420ib_Planar_FR */ { "YUV420ib-FR", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420ib_Planar_709 */ { "YUV420ib-709", false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
+ /* YUV420ib_Planar_709_FR */ { "YUV420ib-709-FR",false, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0 },
};
+namespace {
+ void check() {
+ VDASSERTCT(sizeof(g_vdPixmapFormats)/sizeof(g_vdPixmapFormats[0]) == nsVDPixmap::kPixFormat_Max_Standard);
+ }
+}
+
#ifdef _DEBUG
bool VDIsValidPixmapPlane(const void *p, ptrdiff_t pitch, vdpixsize w, vdpixsize h) {
bool isvalid;
@@ -270,13 +329,48 @@ VDPixmap VDPixmapExtractField(const VDPixmap& src, bool field2) {
if (info.qh == 1)
vdptrstep(px.data, px.pitch);
- if (!info.auxhbits) {
+ if (!info.auxhbits ||
+ src.format == nsVDPixmap::kPixFormat_YUV420i_Planar ||
+ src.format == nsVDPixmap::kPixFormat_YUV420i_Planar_FR ||
+ src.format == nsVDPixmap::kPixFormat_YUV420i_Planar_709 ||
+ src.format == nsVDPixmap::kPixFormat_YUV420i_Planar_709_FR) {
+
vdptrstep(px.data2, px.pitch2);
vdptrstep(px.data3, px.pitch3);
}
}
}
+ switch(src.format) {
+ case nsVDPixmap::kPixFormat_YUV420i_Planar:
+ if (field2)
+ px.format = nsVDPixmap::kPixFormat_YUV420ib_Planar;
+ else
+ px.format = nsVDPixmap::kPixFormat_YUV420it_Planar;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_FR:
+ if (field2)
+ px.format = nsVDPixmap::kPixFormat_YUV420ib_Planar_FR;
+ else
+ px.format = nsVDPixmap::kPixFormat_YUV420it_Planar_FR;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_709:
+ if (field2)
+ px.format = nsVDPixmap::kPixFormat_YUV420ib_Planar_709;
+ else
+ px.format = nsVDPixmap::kPixFormat_YUV420it_Planar_709;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV420i_Planar_709_FR:
+ if (field2)
+ px.format = nsVDPixmap::kPixFormat_YUV420ib_Planar_709_FR;
+ else
+ px.format = nsVDPixmap::kPixFormat_YUV420it_Planar_709_FR;
+ break;
+ }
+
px.h >>= 1;
px.pitch += px.pitch;
px.pitch2 += px.pitch2;
@@ -454,7 +548,9 @@ void VDPixmapBuffer::init(const VDPixmapLayout& layout) {
if (srcinfo.palsize) {
palette = (const uint32 *)(p + linsize);
- memcpy((void *)palette, layout.palette, 4*srcinfo.palsize);
+
+ if (layout.palette)
+ memcpy((void *)palette, layout.palette, 4*srcinfo.palsize);
}
#ifdef _DEBUG
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/region.cpp b/src/thirdparty/VirtualDub/Kasumi/source/region.cpp
index 283f43cf8..de605abc0 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/region.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/region.cpp
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2007 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <stdafx.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
#include <vd2/Kasumi/region.h>
@@ -1005,67 +1006,94 @@ bool VDPixmapFillRegionAntialiased_16x_8x(const VDPixmap& dst, const VDPixmapReg
}
bool VDPixmapFillRegionAntialiased8x(const VDPixmap& dst, const VDPixmapRegion& region, int x, int y, uint32 color) {
- if (dst.format == nsVDPixmap::kPixFormat_YUV444_Planar ||
- dst.format == nsVDPixmap::kPixFormat_YUV422_Planar ||
- dst.format == nsVDPixmap::kPixFormat_YUV420_Planar ||
- dst.format == nsVDPixmap::kPixFormat_YUV410_Planar) {
- VDPixmap pxY;
- VDPixmap pxCb;
- VDPixmap pxCr;
-
- pxY.format = nsVDPixmap::kPixFormat_Y8;
- pxY.data = dst.data;
- pxY.pitch = dst.pitch;
- pxY.w = dst.w;
- pxY.h = dst.h;
-
- pxCb.format = nsVDPixmap::kPixFormat_Y8;
- pxCb.data = dst.data2;
- pxCb.pitch = dst.pitch2;
- pxCb.w = dst.w;
- pxCb.h = dst.h;
-
- pxCr.format = nsVDPixmap::kPixFormat_Y8;
- pxCr.data = dst.data3;
- pxCr.pitch = dst.pitch3;
- pxCr.w = dst.w;
- pxCr.h = dst.h;
-
- uint32 colorY = (color >> 8) & 0xff;
- uint32 colorCb = (color >> 0) & 0xff;
- uint32 colorCr = (color >> 16) & 0xff;
-
- VDPixmapFillRegionAntialiased8x(pxY, region, x, y, colorY);
-
- switch(dst.format) {
- case nsVDPixmap::kPixFormat_YUV410_Planar:
- pxCr.w = pxCb.w = dst.w >> 2;
- pxCr.h = pxCb.h = dst.h >> 2;
- x >>= 2;
- y >>= 2;
- VDPixmapFillRegionAntialiased_32x_32x(pxCb, region, x, y, colorCb);
- VDPixmapFillRegionAntialiased_32x_32x(pxCr, region, x, y, colorCr);
- return true;
- case nsVDPixmap::kPixFormat_YUV420_Planar:
- pxCr.w = pxCb.w = dst.w >> 1;
- pxCr.h = pxCb.h = dst.h >> 1;
- x >>= 1;
- y >>= 1;
- x += 2;
- VDPixmapFillRegionAntialiased_16x_16x(pxCb, region, x, y, colorCb);
- VDPixmapFillRegionAntialiased_16x_16x(pxCr, region, x, y, colorCr);
- return true;
- case nsVDPixmap::kPixFormat_YUV422_Planar:
- pxCr.w = pxCb.w = dst.w >> 1;
- x >>= 1;
- x += 2;
- VDPixmapFillRegionAntialiased_16x_8x(pxCb, region, x, y, colorCb);
- VDPixmapFillRegionAntialiased_16x_8x(pxCr, region, x, y, colorCr);
- return true;
- case nsVDPixmap::kPixFormat_YUV444_Planar:
- VDPixmapFillRegionAntialiased8x(pxCb, region, x, y, colorCb);
- VDPixmapFillRegionAntialiased8x(pxCr, region, x, y, colorCr);
- return true;
+ switch(dst.format) {
+ case nsVDPixmap::kPixFormat_YUV444_Planar:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709_FR:
+ case nsVDPixmap::kPixFormat_YUV422_Planar:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709_FR:
+ case nsVDPixmap::kPixFormat_YUV420_Planar:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709_FR:
+ case nsVDPixmap::kPixFormat_YUV410_Planar:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709_FR:
+ {
+ VDPixmap pxY;
+ VDPixmap pxCb;
+ VDPixmap pxCr;
+
+ pxY.format = nsVDPixmap::kPixFormat_Y8;
+ pxY.data = dst.data;
+ pxY.pitch = dst.pitch;
+ pxY.w = dst.w;
+ pxY.h = dst.h;
+
+ pxCb.format = nsVDPixmap::kPixFormat_Y8;
+ pxCb.data = dst.data2;
+ pxCb.pitch = dst.pitch2;
+ pxCb.w = dst.w;
+ pxCb.h = dst.h;
+
+ pxCr.format = nsVDPixmap::kPixFormat_Y8;
+ pxCr.data = dst.data3;
+ pxCr.pitch = dst.pitch3;
+ pxCr.w = dst.w;
+ pxCr.h = dst.h;
+
+ uint32 colorY = (color >> 8) & 0xff;
+ uint32 colorCb = (color >> 0) & 0xff;
+ uint32 colorCr = (color >> 16) & 0xff;
+
+ VDPixmapFillRegionAntialiased8x(pxY, region, x, y, colorY);
+
+ switch(dst.format) {
+ case nsVDPixmap::kPixFormat_YUV410_Planar:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 2;
+ pxCr.h = pxCb.h = dst.h >> 2;
+ x >>= 2;
+ y >>= 2;
+ VDPixmapFillRegionAntialiased_32x_32x(pxCb, region, x, y, colorCb);
+ VDPixmapFillRegionAntialiased_32x_32x(pxCr, region, x, y, colorCr);
+ return true;
+ case nsVDPixmap::kPixFormat_YUV420_Planar:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 1;
+ pxCr.h = pxCb.h = dst.h >> 1;
+ x >>= 1;
+ y >>= 1;
+ x += 2;
+ VDPixmapFillRegionAntialiased_16x_16x(pxCb, region, x, y, colorCb);
+ VDPixmapFillRegionAntialiased_16x_16x(pxCr, region, x, y, colorCr);
+ return true;
+ case nsVDPixmap::kPixFormat_YUV422_Planar:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 1;
+ x >>= 1;
+ x += 2;
+ VDPixmapFillRegionAntialiased_16x_8x(pxCb, region, x, y, colorCb);
+ VDPixmapFillRegionAntialiased_16x_8x(pxCr, region, x, y, colorCr);
+ return true;
+ case nsVDPixmap::kPixFormat_YUV444_Planar:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709_FR:
+ VDPixmapFillRegionAntialiased8x(pxCb, region, x, y, colorCb);
+ VDPixmapFillRegionAntialiased8x(pxCr, region, x, y, colorCr);
+ return true;
+ }
}
}
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/resample.cpp b/src/thirdparty/VirtualDub/Kasumi/source/resample.cpp
index 4d1aef5f5..d52fece16 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/resample.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/resample.cpp
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2004 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <stdafx.h>
#include <float.h>
#include <math.h>
#include <vd2/system/vdalloc.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/resample_kernels.cpp b/src/thirdparty/VirtualDub/Kasumi/source/resample_kernels.cpp
index 010364e1a..86911b325 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/resample_kernels.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/resample_kernels.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <math.h>
#include <vd2/Kasumi/resample_kernels.h>
@@ -42,6 +61,24 @@ void VDResamplerAxis::Compute(sint32 count, sint32 u0, sint32 w, sint32 kernel_w
dx_postcopy = 0;
dx_dualclip = 0;
+ if (dudx == 0) {
+ if (u < -du_kern)
+ dx_precopy = w;
+ else if (u >= u_limit)
+ dx_postcopy = w;
+ else if (u < 0) {
+ if (u + du_kern < u_limit)
+ dx_preclip = w;
+ else
+ dx_dualclip = w;
+ } else if (u + du_kern >= u_limit)
+ dx_postclip = w;
+ else
+ dx_active = w;
+
+ return;
+ }
+
sint32 dx_temp = dx;
sint32 u_start = u;
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages.cpp b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages.cpp
index fcea6c669..15b44273d 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/math.h>
#include <vd2/system/vdstl.h>
#include <vd2/Kasumi/resample_kernels.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_reference.cpp b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_reference.cpp
index 94bee7c9e..72d4e9b79 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_reference.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_reference.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/memory.h>
#include <vd2/system/cpuaccel.h>
#include <vd2/Kasumi/pixmaputils.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_x86.cpp
index bc4db574f..123fa17c4 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/resample_stages_x86.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <numeric>
#include "blt_spanutils_x86.h"
#include "resample_stages_x86.h"
@@ -564,7 +583,7 @@ xloop:
void VDResamplerSeparableTableRowStage8MMX::Process(void *dst, const void *src, uint32 w) {
int byteOffset = (int)(ptrdiff_t)src & 3;
- const sint16 *ksrc = &mRowKernels[mRowKernelSize * byteOffset];
+ const sint16 *ksrc = mRowKernels.data() + (mRowKernelSize * byteOffset);
#if 0
int kwidth = mAlignedKernelWidth;
uint8 *dst2 = (uint8 *)dst;
@@ -694,7 +713,7 @@ void VDResamplerSeparableTableRowStage8MMX::Process(void *dst, const void *src,
if (w & 3)
vdasm_resize_table_row_8_MMX((char *)dst + (w & ~3), src, w & 3, ksrc + mTailOffset[byteOffset], ksize);
- } else {
+ } else if (w) {
vdasm_resize_table_row_8_MMX(dst, src, w, ksrc, ksize);
}
#endif
@@ -1197,7 +1216,7 @@ void VDResamplerSeparableTableRowStage8SSE41::RedoRowFilters(const VDResamplerAx
void VDResamplerSeparableTableRowStage8SSE41::Process(void *dst, const void *src, uint32 w) {
int byteOffset = (int)(ptrdiff_t)src & 7;
- const sint16 *ksrc = &mRowKernels[mRowKernelSize * byteOffset];
+ const sint16 *ksrc = mRowKernels.data() + (mRowKernelSize * byteOffset);
int ksize = mKernelSizeByOffset[byteOffset];
if (mbQuadOptimizationEnabled[byteOffset]) {
@@ -1210,7 +1229,7 @@ void VDResamplerSeparableTableRowStage8SSE41::Process(void *dst, const void *src
if (w & 3)
vdasm_resize_table_row_8_SSE41((char *)dst + (w & ~3), src, w & 3, ksrc + mTailOffset[byteOffset], ksize);
- } else {
+ } else if (w) {
vdasm_resize_table_row_8_SSE41(dst, src, w, ksrc, ksize);
}
}
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/stdafx.cpp b/src/thirdparty/VirtualDub/Kasumi/source/stdafx.cpp
new file mode 100644
index 000000000..8eed47b75
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/source/stdafx.cpp
@@ -0,0 +1,19 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include "stdafx.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/stretchblt_reference.cpp b/src/thirdparty/VirtualDub/Kasumi/source/stretchblt_reference.cpp
index 8a57ada41..19d140ee6 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/stretchblt_reference.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/stretchblt_reference.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/memory.h>
#include <vd2/system/cpuaccel.h>
#include <vd2/Kasumi/pixmap.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/tables.cpp b/src/thirdparty/VirtualDub/Kasumi/source/tables.cpp
index bf1987500..4107ded95 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/tables.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/tables.cpp
@@ -1,5 +1,6 @@
// Automatically generated by Asuka 'maketables.'" DO NOT EDIT!
+#include <stdafx.h>
#include <vd2/system/vdtypes.h>
extern "C" const sint32 kVDCubicInterpTableFX14_075[256][4]={
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/triblt.cpp b/src/thirdparty/VirtualDub/Kasumi/source/triblt.cpp
index 8fe16138a..bf0752353 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/triblt.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/triblt.cpp
@@ -1,6 +1,6 @@
// VirtualDub - Video processing and capture application
// Graphics support library
-// Copyright (C) 1998-2008 Avery Lee
+// Copyright (C) 1998-2009 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#include <stdafx.h>
#include <math.h>
#include <vector>
#include <vd2/system/math.h>
@@ -1429,7 +1430,7 @@ bool VDPixmapTriFill(VDPixmap& dst, const uint32 c, const VDTriBltVertex *pVerti
return true;
}
-bool VDPixmapTriFill(VDPixmap& dst, const VDTriColorVertex *pVertices, int nVertices, const int *pIndices, int nIndices, const float pTransform[16]) {
+bool VDPixmapTriFill(VDPixmap& dst, const VDTriColorVertex *pVertices, int nVertices, const int *pIndices, int nIndices, const float pTransform[16], const float *chroma_yoffset) {
VDPixmap pxY;
VDPixmap pxCb;
VDPixmap pxCr;
@@ -1441,9 +1442,21 @@ bool VDPixmapTriFill(VDPixmap& dst, const VDTriColorVertex *pVertices, int nVert
case nsVDPixmap::kPixFormat_Y8:
break;
case nsVDPixmap::kPixFormat_YUV444_Planar:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709_FR:
case nsVDPixmap::kPixFormat_YUV422_Planar:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709_FR:
case nsVDPixmap::kPixFormat_YUV420_Planar:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709_FR:
case nsVDPixmap::kPixFormat_YUV410_Planar:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709_FR:
pxY.format = nsVDPixmap::kPixFormat_Y8;
pxY.data = dst.data;
pxY.pitch = dst.pitch;
@@ -1453,27 +1466,49 @@ bool VDPixmapTriFill(VDPixmap& dst, const VDTriColorVertex *pVertices, int nVert
pxCb.format = nsVDPixmap::kPixFormat_Y8;
pxCb.data = dst.data2;
pxCb.pitch = dst.pitch2;
+ pxCb.w = dst.w;
pxCb.h = dst.h;
pxCr.format = nsVDPixmap::kPixFormat_Y8;
pxCr.data = dst.data3;
pxCr.pitch = dst.pitch3;
+ pxCr.w = dst.w;
pxCr.h = dst.h;
- if (dst.format == nsVDPixmap::kPixFormat_YUV410_Planar) {
- pxCr.w = pxCb.w = dst.w >> 2;
- pxCr.h = pxCb.h = dst.h >> 2;
- ycbcr_xoffset = 0.75f / (float)pxCr.w;
- } else if (dst.format == nsVDPixmap::kPixFormat_YUV420_Planar) {
- pxCr.w = pxCb.w = dst.w >> 1;
- pxCr.h = pxCb.h = dst.h >> 1;
- ycbcr_xoffset = 0.5f / (float)pxCr.w;
- } else if (dst.format == nsVDPixmap::kPixFormat_YUV422_Planar) {
- pxCr.w = pxCb.w = dst.w >> 1;
- ycbcr_xoffset = 0.5f / (float)pxCr.w;
- } else if (dst.format == nsVDPixmap::kPixFormat_YUV444_Planar) {
- pxCr.w = pxCb.w = dst.w;
- ycbcr_xoffset = 0.0f;
+ switch(dst.format) {
+ case nsVDPixmap::kPixFormat_YUV410_Planar:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV410_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 2;
+ pxCr.h = pxCb.h = dst.h >> 2;
+ ycbcr_xoffset = 0.75f / (float)pxCr.w;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV420_Planar:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV420_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 1;
+ pxCr.h = pxCb.h = dst.h >> 1;
+ ycbcr_xoffset = 0.5f / (float)pxCr.w;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV422_Planar:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV422_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w >> 1;
+ ycbcr_xoffset = 0.5f / (float)pxCr.w;
+ break;
+
+ case nsVDPixmap::kPixFormat_YUV444_Planar:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_FR:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709:
+ case nsVDPixmap::kPixFormat_YUV444_Planar_709_FR:
+ pxCr.w = pxCb.w = dst.w;
+ ycbcr_xoffset = 0.0f;
+ break;
}
ycbcr = true;
@@ -1511,6 +1546,14 @@ bool VDPixmapTriFill(VDPixmap& dst, const VDTriColorVertex *pVertices, int nVert
xf_ycbcr[2] += xf_ycbcr[14]*ycbcr_xoffset;
xf_ycbcr[3] += xf_ycbcr[15]*ycbcr_xoffset;
+ // translate in y by chroma_yoffset
+ if (chroma_yoffset) {
+ xf_ycbcr[4] += xf_ycbcr[12]*(*chroma_yoffset);
+ xf_ycbcr[5] += xf_ycbcr[13]*(*chroma_yoffset);
+ xf_ycbcr[6] += xf_ycbcr[14]*(*chroma_yoffset);
+ xf_ycbcr[7] += xf_ycbcr[15]*(*chroma_yoffset);
+ }
+
TransformVerts(xsrc, pVertices, nVertices, xf_ycbcr);
switch(plane) {
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit.cpp
index 6dc1b4334..d6caf3707 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit.cpp
@@ -1,7 +1,27 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/Kasumi/pixmap.h>
#include <vd2/Kasumi/pixmaputils.h>
#include "uberblit.h"
#include "uberblit_gen.h"
+#include "uberblit_ycbcr_generic.h"
uint32 VDPixmapGetFormatTokenFromFormat(int format) {
using namespace nsVDPixmap;
@@ -29,6 +49,39 @@ uint32 VDPixmapGetFormatTokenFromFormat(int format) {
case kPixFormat_YUV422_V210: return kVDPixType_V210 | kVDPixSamp_422 | kVDPixSpace_YCC_601;
case kPixFormat_YUV422_UYVY_709: return kVDPixType_B8G8_R8G8 | kVDPixSamp_422 | kVDPixSpace_YCC_709;
case kPixFormat_YUV420_NV12: return kVDPixType_8_B8R8 | kVDPixSamp_420_MPEG2 | kVDPixSpace_YCC_601;
+ case kPixFormat_Y8_FR: return kVDPixType_8 | kVDPixSamp_444 | kVDPixSpace_Y_601_FR;
+ case kPixFormat_YUV422_YUYV_709: return kVDPixType_G8B8_G8R8 | kVDPixSamp_422 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV444_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_444 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV422_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_422 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV420_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV411_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_411 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV410_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_410 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV422_UYVY_FR: return kVDPixType_B8G8_R8G8 | kVDPixSamp_422 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV422_YUYV_FR: return kVDPixType_G8B8_G8R8 | kVDPixSamp_422 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV444_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_444 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV422_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_422 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV420_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV411_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_411 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV410_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_410 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV422_UYVY_709_FR: return kVDPixType_B8G8_R8G8 | kVDPixSamp_422 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV422_YUYV_709_FR: return kVDPixType_G8B8_G8R8 | kVDPixSamp_422 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV444_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_444 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV422_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_422 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV420_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV411_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_411 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV410_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_410 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV420i_Planar: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT | kVDPixSpace_YCC_601;
+ case kPixFormat_YUV420i_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV420i_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV420i_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV420it_Planar: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT1 | kVDPixSpace_YCC_601;
+ case kPixFormat_YUV420it_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT1 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV420it_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT1 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV420it_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT1 | kVDPixSpace_YCC_709_FR;
+ case kPixFormat_YUV420ib_Planar: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT2 | kVDPixSpace_YCC_601;
+ case kPixFormat_YUV420ib_Planar_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT2 | kVDPixSpace_YCC_601_FR;
+ case kPixFormat_YUV420ib_Planar_709: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT2 | kVDPixSpace_YCC_709;
+ case kPixFormat_YUV420ib_Planar_709_FR: return kVDPixType_8_8_8 | kVDPixSamp_420_MPEG2INT2 | kVDPixSpace_YCC_709_FR;
default:
VDASSERT(false);
return 0;
@@ -37,16 +90,18 @@ uint32 VDPixmapGetFormatTokenFromFormat(int format) {
const VDPixmapSamplingInfo& VDPixmapGetSamplingInfo(uint32 samplingToken) {
static const VDPixmapSamplingInfo kPixmapSamplingInfo[]={
- /* Null */ { 0, 0, 0, 0, 0 },
- /* 444 */ { 0, 0, 0, 0, 0 },
- /* 422 */ { -4, 0, 0, 1, 0 },
- /* 422_JPEG */ { 0, 0, 0, 1, 0 },
- /* 420_MPEG2 */ { -4, 0, 0, 1, 1 },
- /* 420_MPEG2INT */ { -4, 0, 0, 1, 1 },
- /* 420_MPEG1 */ { 0, 0, 0, 1, 1 },
- /* 420_DVPAL */ { -4, 0, 0, 1, 1 },
- /* 411 */ { -6, 0, 0, 2, 0 },
- /* 410 */ { -6, 0, 0, 2, 2 }
+ /* Null */ { false, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
+ /* 444 */ { false, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
+ /* 422 */ { false, { -4, 0, 1, 0 }, { -4, 0, 1, 0 } },
+ /* 422_JPEG */ { false, { 0, 0, 1, 0 }, { 0, 0, 1, 0 } },
+ /* 420_MPEG2 */ { false, { -4, 0, 1, 1 }, { -4, 0, 1, 1 } },
+ /* 420_MPEG2INT */ { true , { -4, -2, 1, 1 }, { -4, -2, 1, 1 }, { -4, +2, 1, 1 }, { -4, +2, 1, 1 } },
+ /* 420_MPEG2INT1*/ { false, { -4, -2, 1, 1 }, { -4, -2, 1, 1 } },
+ /* 420_MPEG2INT2*/ { false, { -4, +2, 1, 1 }, { -4, +2, 1, 1 } },
+ /* 420_MPEG1 */ { false, { 0, 0, 1, 1 }, { 0, 0, 1, 1 } },
+ /* 420_DVPAL */ { true , { -4, 0, 1, 1 }, { -4, 0, 1, 1 } },
+ /* 411 */ { false, { -6, 0, 2, 0 }, { -6, 0, 2, 0 } },
+ /* 410 */ { false, { -6, 0, 2, 2 }, { -6, 0, 2, 2 } },
};
uint32 index = (samplingToken & kVDPixSamp_Mask) >> kVDPixSamp_Bits;
@@ -55,6 +110,43 @@ const VDPixmapSamplingInfo& VDPixmapGetSamplingInfo(uint32 samplingToken) {
}
namespace {
+ uint32 GetChromaPlaneBpr(uint32 w, uint32 srcToken) {
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_1:
+ case kVDPixType_2:
+ case kVDPixType_4:
+ case kVDPixType_8:
+ case kVDPixType_555_LE:
+ case kVDPixType_565_LE:
+ case kVDPixType_1555_LE:
+ case kVDPixType_16F_LE:
+ case kVDPixType_888:
+ case kVDPixType_8888:
+ case kVDPixType_16Fx4_LE:
+ case kVDPixType_32F_LE:
+ case kVDPixType_32Fx4_LE:
+ case kVDPixType_B8G8_R8G8:
+ case kVDPixType_G8B8_G8R8:
+ case kVDPixType_V210:
+ case kVDPixType_8_B8R8:
+ case kVDPixType_B8R8:
+ default:
+ return 0;
+
+ case kVDPixType_8_8_8:
+ return w;
+
+ case kVDPixType_16F_16F_16F_LE:
+ return w*2;
+
+ case kVDPixType_32F_32F_32F_LE:
+ return w*4;
+ }
+ }
+
+ void BlitterConvertSampling(VDPixmapUberBlitterGenerator& gen, const VDPixmapSamplingInfo& dstInfo, const VDPixmapSamplingInfo& srcInfo, sint32 cw, sint32 ch);
+ void BlitterConvertPlaneSampling(VDPixmapUberBlitterGenerator& gen, const VDPixmapPlaneSamplingInfo& dstInfo, const VDPixmapPlaneSamplingInfo& srcInfo, sint32 cw, sint32 ch);
+
uint32 BlitterConvertSampling(VDPixmapUberBlitterGenerator& gen, uint32 srcToken, uint32 dstSamplingToken, sint32 w, sint32 h) {
// if the source type is 16F, we have to convert to 32F
if ((srcToken & kVDPixType_Mask) == kVDPixType_16F_16F_16F_LE) {
@@ -75,28 +167,176 @@ namespace {
const VDPixmapSamplingInfo& srcInfo = VDPixmapGetSamplingInfo(srcToken);
const VDPixmapSamplingInfo& dstInfo = VDPixmapGetSamplingInfo(dstSamplingToken);
+ // Check if we have an interlacing mismatch. If so, then we have to convert up to
+ // full resolution vertically in order to split or merge fields.
+ const sint32 cw = -(-w >> dstInfo.mPlane1Cr.mXBits);
+ const sint32 ch = -(-h >> dstInfo.mPlane1Cr.mYBits);
+ const uint32 cbpr = GetChromaPlaneBpr(cw, srcToken);
+
+ if (dstInfo.mbInterlaced || srcInfo.mbInterlaced) {
+ const sint32 src_cw = -(-w >> srcInfo.mPlane1Cr.mXBits);
+
+ const sint32 ch1 = (ch + 1) >> 1;
+ const sint32 ch2 = ch >> 1;
+
+ if (dstInfo.mbInterlaced) {
+ if (srcInfo.mbInterlaced) {
+ // interlaced -> interlaced: split fields, resample, merge fields
+ //
+ // cr y cb
+ gen.split_fields(cbpr);
+
+ // cr-odd cr-even y cb
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane2Cr, srcInfo.mPlane2Cr, cw, ch2);
+
+ // cr-odd' cr-even y cb
+ gen.swap(1);
+
+ // cr-even cr-odd' y cb
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cr, srcInfo.mPlane1Cr, cw, ch1);
+
+ // cr-even' cr-odd' y cb
+ gen.swap(1);
+
+ // cr-odd' cr-even' y cb
+ gen.merge_fields(cw, ch, cbpr);
+
+ // cr' y cb
+ gen.swap(2);
+
+ // cb' y cr'
+ gen.split_fields(cbpr);
+
+ // cb-odd cb-even y cr'
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane2Cb, srcInfo.mPlane2Cb, cw, ch2);
+
+ // cb-odd' cb-even y cr'
+ gen.swap(1);
+
+ // cb-even cb-odd' y cr'
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cb, srcInfo.mPlane1Cb, cw, ch1);
+
+ // cb-even' cb-odd' y cr'
+ gen.swap(1);
+
+ // cb-odd' cb-even' y cr'
+ gen.merge_fields(cw, ch, cbpr);
+
+ // cb' y cr'
+ gen.swap(2);
+
+ // cr' y cb'
+ } else {
+ // non-interlaced -> interlaced
+ VDPixmapPlaneSamplingInfo crPlaneInt(srcInfo.mPlane1Cr);
+ VDPixmapPlaneSamplingInfo crPlaneFieldInt(srcInfo.mPlane1Cr);
+ VDPixmapPlaneSamplingInfo cbPlaneInt(srcInfo.mPlane1Cb);
+ VDPixmapPlaneSamplingInfo cbPlaneFieldInt(srcInfo.mPlane1Cb);
+
+ crPlaneInt.mX = dstInfo.mPlane1Cr.mX;
+ crPlaneInt.mXBits = dstInfo.mPlane1Cr.mXBits;
+ crPlaneInt.mY = 0;
+ crPlaneInt.mYBits = 0;
+ crPlaneFieldInt.mX = dstInfo.mPlane1Cr.mX;
+ crPlaneFieldInt.mXBits = dstInfo.mPlane1Cr.mXBits;
+ crPlaneFieldInt.mY = 0;
+ crPlaneFieldInt.mYBits = 0;
+
+ cbPlaneInt.mX = dstInfo.mPlane1Cb.mX;
+ cbPlaneInt.mXBits = dstInfo.mPlane1Cb.mXBits;
+ cbPlaneFieldInt.mX = dstInfo.mPlane1Cb.mX;
+ cbPlaneFieldInt.mXBits = dstInfo.mPlane1Cb.mXBits;
+ cbPlaneFieldInt.mY = 0;
+ cbPlaneFieldInt.mYBits = 0;
+
+ // cr y cb
+ BlitterConvertPlaneSampling(gen, crPlaneInt, srcInfo.mPlane1Cr, cw, h);
+
+ // cr' y cb
+ gen.split_fields(cbpr);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cr, crPlaneFieldInt, cw, ch1);
+ gen.swap(1);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane2Cr, crPlaneFieldInt, cw, ch2);
+ gen.swap(1);
+ gen.merge_fields(cw, ch, cbpr);
+
+ gen.swap(2);
+ BlitterConvertPlaneSampling(gen, cbPlaneInt, srcInfo.mPlane1Cb, cw, h);
+ gen.split_fields(cbpr);
+ gen.swap(1);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cb, cbPlaneFieldInt, cw, ch1);
+ gen.swap(1);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cb, cbPlaneFieldInt, cw, ch2);
+ gen.merge_fields(cw, ch, cbpr);
+ gen.swap(2);
+ }
+ } else {
+ sint32 src_cbpr = src_cw;
+
+ // interlaced -> non-interlaced
+ VDPixmapPlaneSamplingInfo crPlaneFieldInt(srcInfo.mPlane1Cr);
+ VDPixmapPlaneSamplingInfo crPlaneInt(srcInfo.mPlane1Cr);
+ VDPixmapPlaneSamplingInfo cbPlaneFieldInt(srcInfo.mPlane1Cb);
+ VDPixmapPlaneSamplingInfo cbPlaneInt(srcInfo.mPlane1Cb);
+
+ crPlaneFieldInt.mY = 0;
+ crPlaneFieldInt.mYBits = 0;
+ crPlaneInt.mY = 0;
+ crPlaneInt.mYBits = 0;
+ cbPlaneFieldInt.mY = 0;
+ cbPlaneFieldInt.mYBits = 0;
+ cbPlaneInt.mY = 0;
+ cbPlaneInt.mYBits = 0;
+
+ // cr y cb
+ gen.split_fields(src_cbpr);
+ BlitterConvertPlaneSampling(gen, crPlaneFieldInt, srcInfo.mPlane1Cr, src_cw, (h + 1) >> 1);
+ gen.swap(1);
+ BlitterConvertPlaneSampling(gen, crPlaneFieldInt, srcInfo.mPlane2Cr, src_cw, h >> 1);
+ gen.swap(1);
+ gen.merge_fields(src_cw, h, src_cbpr);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cr, crPlaneInt, cw, ch);
+ gen.swap(2);
+
+ // cr' y cb
+ gen.split_fields(src_cbpr);
+ BlitterConvertPlaneSampling(gen, cbPlaneFieldInt, srcInfo.mPlane1Cb, src_cw, (h + 1) >> 1);
+ gen.swap(1);
+ BlitterConvertPlaneSampling(gen, cbPlaneFieldInt, srcInfo.mPlane2Cb, src_cw, h >> 1);
+ gen.swap(1);
+ gen.merge_fields(src_cw, h, src_cbpr);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cb, cbPlaneInt, cw, ch);
+ gen.swap(2);
+ }
+ } else {
+ // non-interlaced -> non-interlaced
+ BlitterConvertSampling(gen, dstInfo, srcInfo, cw, ch);
+ }
+
+ return (srcToken & ~kVDPixSamp_Mask) | (dstSamplingToken & kVDPixSamp_Mask);
+ }
+
+ void BlitterConvertSampling(VDPixmapUberBlitterGenerator& gen, const VDPixmapSamplingInfo& dstInfo, const VDPixmapSamplingInfo& srcInfo, sint32 cw, sint32 ch) {
+ gen.swap(2);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cb, srcInfo.mPlane1Cb, cw, ch);
+ gen.swap(2);
+ BlitterConvertPlaneSampling(gen, dstInfo.mPlane1Cr, srcInfo.mPlane1Cr, cw, ch);
+ }
+
+ void BlitterConvertPlaneSampling(VDPixmapUberBlitterGenerator& gen, const VDPixmapPlaneSamplingInfo& dstInfo, const VDPixmapPlaneSamplingInfo& srcInfo, sint32 cw, sint32 ch) {
// convert destination chroma origin to luma space
- int c_x = ((8 + dstInfo.mCXOffset16) << dstInfo.mCXBits) - 8;
- int cr_y = ((8 + dstInfo.mCrYOffset16) << dstInfo.mCYBits) - 8;
- int cb_y = ((8 + dstInfo.mCbYOffset16) << dstInfo.mCYBits) - 8;
+ int c_x = ((8 + dstInfo.mX) << dstInfo.mXBits) - 8;
+ int c_y = ((8 + dstInfo.mY) << dstInfo.mYBits) - 8;
// convert luma chroma location to source chroma space
- c_x = ((8 + c_x) >> srcInfo.mCXBits) - 8 - srcInfo.mCXOffset16;
- cr_y = ((8 + cr_y) >> srcInfo.mCYBits) - 8 - srcInfo.mCrYOffset16;
- cb_y = ((8 + cb_y) >> srcInfo.mCYBits) - 8 - srcInfo.mCbYOffset16;
+ c_x = ((8 + c_x) >> srcInfo.mXBits) - 8 - srcInfo.mX;
+ c_y = ((8 + c_y) >> srcInfo.mYBits) - 8 - srcInfo.mY;
float cxo = c_x / 16.0f + 0.5f;
- float cxf = ((16 << dstInfo.mCXBits) >> srcInfo.mCXBits) / 16.0f;
- float cyf = ((16 << dstInfo.mCYBits) >> srcInfo.mCYBits) / 16.0f;
- sint32 cw = -(-w >> dstInfo.mCXBits);
- sint32 ch = -(-h >> dstInfo.mCYBits);
-
- gen.swap(2);
- gen.linear(cxo, cxf, cw, cb_y / 16.0f + 0.5f, cyf, ch);
- gen.swap(2);
- gen.linear(cxo, cxf, cw, cr_y / 16.0f + 0.5f, cyf, ch);
+ float cxf = ((16 << dstInfo.mXBits) >> srcInfo.mXBits) / 16.0f;
+ float cyf = ((16 << dstInfo.mYBits) >> srcInfo.mYBits) / 16.0f;
- return (srcToken & ~kVDPixSamp_Mask) | (dstSamplingToken & kVDPixSamp_Mask);
+ gen.linear(cxo, cxf, cw, c_y / 16.0f + 0.5f, cyf, ch);
}
uint32 BlitterConvertType(VDPixmapUberBlitterGenerator& gen, uint32 srcToken, uint32 dstToken, sint32 w, sint32 h) {
@@ -257,8 +497,8 @@ namespace {
case kVDPixType_8_B8R8:
{
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- int cw = -(-w >> sampInfo.mCXBits);
- int ch = -(-h >> sampInfo.mCYBits);
+ int cw = -(-w >> sampInfo.mPlane1Cr.mXBits);
+ int ch = -(-h >> sampInfo.mPlane1Cr.mYBits);
gen.dup();
gen.extract_8in16(1, cw, ch);
@@ -284,7 +524,7 @@ namespace {
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSamp_Mask)) | kVDPixType_B8G8_R8G8;
break;
case kVDPixType_G8B8_G8R8:
- gen.swap_8in16(w, h, w*2);
+ gen.swap_8in16(w, h, ((w + 1) & ~1)*2);
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSamp_Mask)) | kVDPixType_B8G8_R8G8;
break;
default:
@@ -303,7 +543,7 @@ namespace {
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSamp_Mask)) | kVDPixType_G8B8_G8R8;
break;
case kVDPixType_B8G8_R8G8:
- gen.swap_8in16(w, h, w*2);
+ gen.swap_8in16(w, h, ((w + 1) & ~1)*2);
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSamp_Mask)) | kVDPixType_G8B8_G8R8;
break;
default:
@@ -521,12 +761,12 @@ IVDPixmapBlitter *VDPixmapCreateBlitter(const VDPixmapLayout& dst, const VDPixma
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- int cxbits = sampInfo.mCXBits;
- int cybits = sampInfo.mCYBits;
+ int cxbits = sampInfo.mPlane1Cb.mXBits;
+ int cybits = sampInfo.mPlane1Cb.mYBits;
int w2 = -(-w >> cxbits);
int h2 = -(-h >> cybits);
gen.ldsrc(0, 2, 0, 0, w2, h2, cbtoken, w2);
- gen.ldsrc(0, 0, 0, 0, w, h, srcToken, w);
+ gen.ldsrc(0, 0, 0, 0, w, h, ytoken, w);
gen.ldsrc(0, 1, 0, 0, w2, h2, crtoken, w2);
}
break;
@@ -539,12 +779,12 @@ IVDPixmapBlitter *VDPixmapCreateBlitter(const VDPixmapLayout& dst, const VDPixma
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- int cxbits = sampInfo.mCXBits;
- int cybits = sampInfo.mCYBits;
+ int cxbits = sampInfo.mPlane1Cb.mXBits;
+ int cybits = sampInfo.mPlane1Cb.mYBits;
int w2 = -(-w >> cxbits);
int h2 = -(-h >> cybits);
gen.ldsrc(0, 2, 0, 0, w2, h2, cbtoken, w2 * 2);
- gen.ldsrc(0, 0, 0, 0, w, h, srcToken, w*2);
+ gen.ldsrc(0, 0, 0, 0, w, h, ytoken, w*2);
gen.ldsrc(0, 1, 0, 0, w2, h2, crtoken, w2 * 2);
}
break;
@@ -557,12 +797,12 @@ IVDPixmapBlitter *VDPixmapCreateBlitter(const VDPixmapLayout& dst, const VDPixma
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- int cxbits = sampInfo.mCXBits;
- int cybits = sampInfo.mCYBits;
+ int cxbits = sampInfo.mPlane1Cb.mXBits;
+ int cybits = sampInfo.mPlane1Cb.mYBits;
int w2 = -(-w >> cxbits);
int h2 = -(-h >> cybits);
gen.ldsrc(0, 2, 0, 0, w2, h2, cbtoken, w2 * 4);
- gen.ldsrc(0, 0, 0, 0, w, h, srcToken, w*4);
+ gen.ldsrc(0, 0, 0, 0, w, h, ytoken, w*4);
gen.ldsrc(0, 1, 0, 0, w2, h2, crtoken, w2 * 4);
}
break;
@@ -578,11 +818,11 @@ IVDPixmapBlitter *VDPixmapCreateBlitter(const VDPixmapLayout& dst, const VDPixma
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- int cxbits = sampInfo.mCXBits;
- int cybits = sampInfo.mCYBits;
+ int cxbits = sampInfo.mPlane1Cb.mXBits;
+ int cybits = sampInfo.mPlane1Cb.mYBits;
int w2 = -(-w >> cxbits);
int h2 = -(-h >> cybits);
- gen.ldsrc(0, 0, 0, 0, w, h, srcToken, w);
+ gen.ldsrc(0, 0, 0, 0, w, h, ytoken, w);
gen.ldsrc(0, 1, 0, 0, w2, h2, ctoken, w2*2);
}
break;
@@ -636,10 +876,29 @@ IVDPixmapBlitter *VDPixmapCreateBlitter(const VDPixmapLayout& dst, const VDPixma
// the auxiliary channels
const VDPixmapSamplingInfo& sampInfo = VDPixmapGetSamplingInfo(srcToken);
- if ((dstToken & kVDPixSpace_Mask) != kVDPixSpace_Y_601 && (dstToken & kVDPixSpace_Mask) != kVDPixSpace_Y_709) {
- if (sampInfo.mCXBits | sampInfo.mCYBits | sampInfo.mCXOffset16 | sampInfo.mCbYOffset16 | sampInfo.mCrYOffset16)
- srcToken = BlitterConvertSampling(gen, srcToken, kVDPixSamp_444, w, h);
+#if 0
+ // This check is currently disabled because we currently do need the chroma planes
+ // if we're doing a color space conversion, even if we are going to Y-only.
+ switch(dstToken & kVDPixSpace_Mask) {
+// case kVDPixSpace_Y_601:
+// case kVDPixSpace_Y_709:
+// case kVDPixSpace_Y_601_FR:
+// case kVDPixSpace_Y_709_FR:
+// break;
+
+ default:
+#endif
+ if (sampInfo.mPlane1Cb.mXBits |
+ sampInfo.mPlane1Cb.mYBits |
+ sampInfo.mPlane1Cb.mX |
+ sampInfo.mPlane1Cb.mY |
+ sampInfo.mPlane1Cr.mX |
+ sampInfo.mPlane1Cr.mY)
+ srcToken = BlitterConvertSampling(gen, srcToken, kVDPixSamp_444, w, h);
+#if 0
+ break;
}
+#endif
// change color spaces
uint32 dstSpace = dstToken & kVDPixSpace_Mask;
@@ -699,10 +958,48 @@ space_reconvert:
}
break;
+ case kVDPixSpace_YCC_709_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ gen.ycbcr_to_rgb32_generic(g_VDPixmapGenYCbCrBasis_709, false);
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_BGR | kVDPixType_8888;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
+ case kVDPixSpace_YCC_601_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ gen.ycbcr_to_rgb32_generic(g_VDPixmapGenYCbCrBasis_601, false);
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_BGR | kVDPixType_8888;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
case kVDPixSpace_Y_601:
targetSpace = kVDPixSpace_YCC_601;
goto space_reconvert;
+ case kVDPixSpace_Y_709:
+ targetSpace = kVDPixSpace_YCC_709;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_601_FR:
+ targetSpace = kVDPixSpace_YCC_601_FR;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_709_FR:
+ targetSpace = kVDPixSpace_YCC_709_FR;
+ goto space_reconvert;
+
case kVDPixSpace_Pal:
switch(srcToken & kVDPixType_Mask) {
case kVDPixType_1:
@@ -736,49 +1033,123 @@ space_reconvert:
break;
}
break;
+
case kVDPixSpace_Y_601:
- if (srcSpace == kVDPixSpace_YCC_601) {
- gen.pop();
- gen.swap(1);
- gen.pop();
- switch(srcToken & kVDPixType_Mask) {
- case kVDPixType_32F_32F_32F_LE:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_601 | kVDPixType_32F_LE;
- break;
- case kVDPixType_16F_16F_16F_LE:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_601 | kVDPixType_16F_LE;
- break;
- case kVDPixType_8_8_8:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_601 | kVDPixType_8;
- break;
+ switch(srcSpace) {
+ case kVDPixSpace_YCC_601:
+ gen.pop();
+ gen.swap(1);
+ gen.pop();
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_32F_32F_32F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_32F_LE;
+ break;
+ case kVDPixType_16F_16F_16F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_16F_LE;
+ break;
+ case kVDPixType_8_8_8:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8;
+ break;
+
+ default:
+ VDASSERT(false);
+ }
+ srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
+ break;
- default:
- VDASSERT(false);
- }
- srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
- break;
- } else if (srcSpace == kVDPixSpace_YCC_709) {
- gen.pop();
- gen.swap(1);
- gen.pop();
- switch(srcToken & kVDPixType_Mask) {
- case kVDPixType_32F_32F_32F_LE:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_709 | kVDPixType_32F_LE;
- break;
- case kVDPixType_16F_16F_16F_LE:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_709 | kVDPixType_16F_LE;
- break;
- case kVDPixType_8_8_8:
- srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_Y_709 | kVDPixType_8;
- break;
+ default:
+ targetSpace = kVDPixSpace_YCC_601;
+ goto space_reconvert;
+ }
+ break;
- default:
- VDASSERT(false);
- }
- srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
- break;
+ case kVDPixSpace_Y_601_FR:
+ switch(srcSpace) {
+ case kVDPixSpace_YCC_601_FR:
+ gen.pop();
+ gen.swap(1);
+ gen.pop();
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_32F_32F_32F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_32F_LE;
+ break;
+ case kVDPixType_16F_16F_16F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_16F_LE;
+ break;
+ case kVDPixType_8_8_8:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8;
+ break;
+
+ default:
+ VDASSERT(false);
+ }
+ srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
+ break;
+
+ default:
+ targetSpace = kVDPixSpace_YCC_601_FR;
+ goto space_reconvert;
+ }
+ break;
+
+ case kVDPixSpace_Y_709:
+ switch(srcSpace) {
+ case kVDPixSpace_YCC_709:
+ gen.pop();
+ gen.swap(1);
+ gen.pop();
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_32F_32F_32F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_32F_LE;
+ break;
+ case kVDPixType_16F_16F_16F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_16F_LE;
+ break;
+ case kVDPixType_8_8_8:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8;
+ break;
+
+ default:
+ VDASSERT(false);
+ }
+ srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
+ break;
+
+ default:
+ targetSpace = kVDPixSpace_YCC_709;
+ goto space_reconvert;
}
- // fall through
+ break;
+
+ case kVDPixSpace_Y_709_FR:
+ switch(srcSpace) {
+ case kVDPixSpace_YCC_709_FR:
+ gen.pop();
+ gen.swap(1);
+ gen.pop();
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_32F_32F_32F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_32F_LE;
+ break;
+ case kVDPixType_16F_16F_16F_LE:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_16F_LE;
+ break;
+ case kVDPixType_8_8_8:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8;
+ break;
+
+ default:
+ VDASSERT(false);
+ }
+ srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8, w, h);
+ break;
+
+ default:
+ targetSpace = kVDPixSpace_YCC_709_FR;
+ goto space_reconvert;
+ }
+ break;
+
case kVDPixSpace_YCC_601:
switch(srcSpace) {
case kVDPixSpace_BGR:
@@ -791,9 +1162,9 @@ space_reconvert:
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_YCC_601 | kVDPixType_8;
{
- const VDPixmapSamplingInfo& sinfo = VDPixmapGetSamplingInfo(dstToken);
- int cw = ((w - 1) >> sinfo.mCXBits) + 1;
- int ch = ((h - 1) >> sinfo.mCYBits) + 1;
+ const VDPixmapSamplingInfo& sinfo = VDPixmapGetSamplingInfo(srcToken);
+ int cw = ((w - 1) >> sinfo.mPlane1Cb.mXBits) + 1;
+ int ch = ((h - 1) >> sinfo.mPlane1Cb.mYBits) + 1;
gen.ldconst(0x80, cw, cw, ch, srcToken);
}
@@ -801,14 +1172,51 @@ space_reconvert:
gen.dup();
gen.swap(2);
gen.swap(1);
- srcToken = kVDPixSpace_YCC_601 | kVDPixType_8_8_8 | (dstToken & kVDPixSamp_Mask);
+ srcToken = kVDPixSpace_YCC_601 | kVDPixType_8_8_8 | (srcToken & kVDPixSamp_Mask);
break;
+
+ case kVDPixSpace_Y_601_FR:
+ targetSpace = kVDPixSpace_YCC_601_FR;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_709_FR:
+ targetSpace = kVDPixSpace_YCC_709_FR;
+ goto space_reconvert;
+
case kVDPixSpace_YCC_709:
VDASSERT((srcToken & kVDPixType_Mask) == kVDPixType_8_8_8);
gen.ycbcr709_to_ycbcr601();
srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_601;
break;
+ case kVDPixSpace_YCC_601_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ case kVDPixType_32F_32F_32F_LE:
+ gen.ycbcr_to_ycbcr_generic(g_VDPixmapGenYCbCrBasis_601, true, g_VDPixmapGenYCbCrBasis_601, false, kVDPixSpace_YCC_601);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_601;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
+ case kVDPixSpace_YCC_709_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ case kVDPixType_32F_32F_32F_LE:
+ gen.ycbcr_to_ycbcr_generic(g_VDPixmapGenYCbCrBasis_601, true, g_VDPixmapGenYCbCrBasis_709, false, kVDPixSpace_YCC_601);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_601;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
case kVDPixSpace_Pal:
targetSpace = kVDPixSpace_BGR;
goto space_reconvert;
@@ -818,6 +1226,7 @@ space_reconvert:
break;
}
break;
+
case kVDPixSpace_YCC_709:
switch(srcSpace) {
case kVDPixSpace_BGR:
@@ -825,14 +1234,14 @@ space_reconvert:
gen.rgb32_to_ycbcr709();
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_YCC_709 | kVDPixType_8_8_8;
break;
- case kVDPixSpace_Y_709:
case kVDPixSpace_Y_601:
+ case kVDPixSpace_Y_709:
srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixSpace_YCC_709 | kVDPixType_8;
{
- const VDPixmapSamplingInfo& sinfo = VDPixmapGetSamplingInfo(dstToken);
- int cw = ((w - 1) >> sinfo.mCXBits) + 1;
- int ch = ((h - 1) >> sinfo.mCYBits) + 1;
+ const VDPixmapSamplingInfo& sinfo = VDPixmapGetSamplingInfo(srcToken);
+ int cw = ((w - 1) >> sinfo.mPlane1Cb.mXBits) + 1;
+ int ch = ((h - 1) >> sinfo.mPlane1Cb.mYBits) + 1;
gen.ldconst(0x80, cw, cw, ch, srcToken);
}
@@ -840,22 +1249,126 @@ space_reconvert:
gen.dup();
gen.swap(2);
gen.swap(1);
- srcToken = kVDPixSpace_YCC_709 | kVDPixType_8_8_8 | (dstToken & kVDPixSamp_Mask);
+ srcToken = kVDPixSpace_YCC_709 | kVDPixType_8_8_8 | (srcToken & kVDPixSamp_Mask);
break;
case kVDPixSpace_YCC_601:
- VDASSERT((srcToken & kVDPixType_Mask) == kVDPixType_8_8_8 || (srcToken & kVDPixType_Mask) == kVDPixType_32F_32F_32F_LE);
- gen.ycbcr601_to_ycbcr709();
+ if ((srcToken & kVDPixType_Mask) == kVDPixType_8_8_8)
+ gen.ycbcr601_to_ycbcr709();
+ else
+ gen.ycbcr_to_ycbcr_generic(g_VDPixmapGenYCbCrBasis_709, true, g_VDPixmapGenYCbCrBasis_601, true, kVDPixSpace_YCC_709);
+
srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_709;
break;
+
+ case kVDPixSpace_YCC_601_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ case kVDPixType_32F_32F_32F_LE:
+ gen.ycbcr_to_ycbcr_generic(g_VDPixmapGenYCbCrBasis_709, true, g_VDPixmapGenYCbCrBasis_601, false, kVDPixSpace_YCC_709);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_709;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
+ case kVDPixSpace_YCC_709_FR:
+ switch(srcToken & kVDPixType_Mask) {
+ case kVDPixType_8_8_8:
+ case kVDPixType_32F_32F_32F_LE:
+ gen.ycbcr_to_ycbcr_generic(g_VDPixmapGenYCbCrBasis_709, true, g_VDPixmapGenYCbCrBasis_709, false, kVDPixSpace_YCC_709);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | kVDPixSpace_YCC_709;
+ break;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ break;
+
+ case kVDPixSpace_Y_601_FR:
+ targetSpace = kVDPixSpace_YCC_601_FR;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_709_FR:
+ targetSpace = kVDPixSpace_YCC_709_FR;
+ goto space_reconvert;
+
case kVDPixSpace_Pal:
targetSpace = kVDPixSpace_BGR;
goto space_reconvert;
+
default:
VDASSERT(false);
break;
}
break;
+ case kVDPixSpace_YCC_601_FR:
+ case kVDPixSpace_YCC_709_FR:
+ {
+ const VDPixmapGenYCbCrBasis& dstBasis = *(targetSpace == kVDPixSpace_YCC_601_FR ? &g_VDPixmapGenYCbCrBasis_601 : &g_VDPixmapGenYCbCrBasis_709);
+
+ switch(srcSpace) {
+ case kVDPixSpace_BGR:
+ srcToken = BlitterConvertType(gen, srcToken, kVDPixType_8888, w, h);
+ gen.rgb32_to_ycbcr_generic(dstBasis, false, targetSpace);
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8_8_8;
+ break;
+ case kVDPixSpace_Y_601_FR:
+ case kVDPixSpace_Y_709_FR:
+ srcToken = (srcToken & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | targetSpace | kVDPixType_8;
+
+ {
+ const VDPixmapSamplingInfo& sinfo = VDPixmapGetSamplingInfo(srcToken);
+ int cw = ((w - 1) >> sinfo.mPlane1Cb.mXBits) + 1;
+ int ch = ((h - 1) >> sinfo.mPlane1Cb.mYBits) + 1;
+
+ gen.ldconst(0x80, cw, cw, ch, srcToken);
+ }
+
+ gen.dup();
+ gen.swap(2);
+ gen.swap(1);
+ srcToken = (srcToken & ~kVDPixType_Mask) | kVDPixType_8_8_8;
+ break;
+ case kVDPixSpace_YCC_601:
+ gen.ycbcr_to_ycbcr_generic(dstBasis, false, g_VDPixmapGenYCbCrBasis_601, true, targetSpace);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | targetSpace;
+ break;
+ case kVDPixSpace_YCC_709:
+ gen.ycbcr_to_ycbcr_generic(dstBasis, false, g_VDPixmapGenYCbCrBasis_709, true, targetSpace);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | targetSpace;
+ break;
+ case kVDPixSpace_YCC_601_FR:
+ gen.ycbcr_to_ycbcr_generic(dstBasis, false, g_VDPixmapGenYCbCrBasis_601, false, targetSpace);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | targetSpace;
+ break;
+ case kVDPixSpace_YCC_709_FR:
+ gen.ycbcr_to_ycbcr_generic(dstBasis, false, g_VDPixmapGenYCbCrBasis_709, false, targetSpace);
+ srcToken = (srcToken & ~kVDPixSpace_Mask) | targetSpace;
+ break;
+ case kVDPixSpace_Pal:
+ targetSpace = kVDPixSpace_BGR;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_601:
+ targetSpace = kVDPixSpace_YCC_601;
+ goto space_reconvert;
+
+ case kVDPixSpace_Y_709:
+ targetSpace = kVDPixSpace_YCC_709;
+ goto space_reconvert;
+
+ default:
+ VDASSERT(false);
+ break;
+ }
+ }
+ break;
+
default:
VDASSERT(false);
break;
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_16f.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_16f.cpp
index 3e9af1a1b..34422884b 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_16f.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_16f.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/halffloat.h>
#include "uberblit_16f.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_gen.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_gen.cpp
index f93ca322e..3f652863a 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_gen.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_gen.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/vdalloc.h>
#include <vd2/Kasumi/pixmaputils.h>
#include "uberblit.h"
@@ -7,11 +26,13 @@
#include "uberblit_resample.h"
#include "uberblit_resample_special.h"
#include "uberblit_ycbcr.h"
+#include "uberblit_ycbcr_generic.h"
#include "uberblit_rgb.h"
#include "uberblit_swizzle.h"
#include "uberblit_pal.h"
#include "uberblit_16f.h"
#include "uberblit_v210.h"
+#include "uberblit_interlace.h"
#ifdef VD_CPU_X86
#include "uberblit_swizzle_x86.h"
@@ -64,8 +85,8 @@ void VDPixmapUberBlitterDirectCopy::Blit(const VDPixmap& dst, const vdrect32 *rD
void *p = dst.data;
void *p2 = dst.data2;
void *p3 = dst.data3;
- int w = dst.w;
- int h = dst.h;
+ int w = std::min<int>(dst.w, src.w);
+ int h = std::min<int>(dst.h, src.h);
if (formatInfo.qchunky) {
w = (w + formatInfo.qw - 1) / formatInfo.qw;
@@ -1284,6 +1305,34 @@ void VDPixmapUberBlitterGenerator::interleave_B8R8() {
mStack.pop_back();
}
+void VDPixmapUberBlitterGenerator::merge_fields(uint32 w, uint32 h, uint32 bpr) {
+ StackEntry *args = &mStack.back() - 1;
+
+ VDPixmapGen_MergeFields *src = new VDPixmapGen_MergeFields;
+
+ src->Init(args[0].mpSrc, args[0].mSrcIndex, args[1].mpSrc, args[1].mSrcIndex, w, h, bpr);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ MarkDependency(src, args[1].mpSrc);
+ args[0] = StackEntry(src, 0);
+ mStack.pop_back();
+}
+
+void VDPixmapUberBlitterGenerator::split_fields(uint32 bpr) {
+ StackEntry *args = &mStack.back();
+
+ VDPixmapGen_SplitFields *src = new VDPixmapGen_SplitFields;
+
+ src->Init(args[0].mpSrc, args[0].mSrcIndex, bpr);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+
+ args[0] = StackEntry(src, 0);
+ mStack.push_back(StackEntry(src, 1));
+}
+
void VDPixmapUberBlitterGenerator::ycbcr601_to_rgb32() {
StackEntry *args = &mStack.back() - 2;
@@ -1458,6 +1507,89 @@ void VDPixmapUberBlitterGenerator::ycbcr709_to_ycbcr601() {
args[2] = StackEntry(src, 2);
}
+void VDPixmapUberBlitterGenerator::ycbcr_to_rgb32_generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB) {
+ StackEntry *args = &mStack.back() - 2;
+
+ VDPixmapGenYCbCrToRGB32Generic *src = new VDPixmapGenYCbCrToRGB32Generic(basis, studioRGB);
+
+ src->Init(args[0].mpSrc, args[0].mSrcIndex, args[1].mpSrc, args[1].mSrcIndex, args[2].mpSrc, args[2].mSrcIndex);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ MarkDependency(src, args[1].mpSrc);
+ MarkDependency(src, args[2].mpSrc);
+ args[0] = StackEntry(src, 0);
+ mStack.pop_back();
+ mStack.pop_back();
+}
+
+void VDPixmapUberBlitterGenerator::ycbcr_to_rgb32f_generic(const VDPixmapGenYCbCrBasis& basis) {
+ StackEntry *args = &mStack.back() - 2;
+
+ VDPixmapGenYCbCrToRGB32FGeneric *src = new VDPixmapGenYCbCrToRGB32FGeneric(basis);
+
+ src->Init(args[0].mpSrc, args[0].mSrcIndex, args[1].mpSrc, args[1].mSrcIndex, args[2].mpSrc, args[2].mSrcIndex);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ MarkDependency(src, args[1].mpSrc);
+ MarkDependency(src, args[2].mpSrc);
+ args[0] = StackEntry(src, 0);
+ mStack.pop_back();
+ mStack.pop_back();
+}
+
+void VDPixmapUberBlitterGenerator::rgb32_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB, uint32 colorSpace) {
+ StackEntry *args = &mStack.back();
+
+ VDPixmapGenRGB32ToYCbCrGeneric *src = new VDPixmapGenRGB32ToYCbCrGeneric(basis, studioRGB, colorSpace);
+ src->Init(args[0].mpSrc, args[0].mSrcIndex);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ args[0] = StackEntry(src, 0);
+ mStack.push_back(StackEntry(src, 1));
+ mStack.push_back(StackEntry(src, 2));
+}
+
+void VDPixmapUberBlitterGenerator::rgb32f_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basis, uint32 colorSpace) {
+ StackEntry *args = &mStack.back();
+
+ VDPixmapGenRGB32FToYCbCrGeneric *src = new VDPixmapGenRGB32FToYCbCrGeneric(basis, colorSpace);
+ src->Init(args[0].mpSrc, args[0].mSrcIndex);
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ args[0] = StackEntry(src, 0);
+ mStack.push_back(StackEntry(src, 1));
+ mStack.push_back(StackEntry(src, 2));
+}
+
+void VDPixmapUberBlitterGenerator::ycbcr_to_ycbcr_generic(const VDPixmapGenYCbCrBasis& basisDst, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& basisSrc, bool srcLimitedRange, uint32 colorSpace) {
+ StackEntry *args = &mStack.back() - 2;
+
+ IVDPixmapGen *src;
+ if ((args[0].mpSrc->GetType(args[0].mSrcIndex) & kVDPixType_Mask) == kVDPixType_32F_LE) {
+ VDPixmapGenYCbCrToYCbCrGeneric_32F *src2 = new VDPixmapGenYCbCrToYCbCrGeneric_32F(basisDst, dstLimitedRange, basisSrc, srcLimitedRange, colorSpace);
+
+ src2->Init(args[0].mpSrc, args[0].mSrcIndex, args[1].mpSrc, args[1].mSrcIndex, args[2].mpSrc, args[2].mSrcIndex);
+ src = src2;
+ } else {
+ VDPixmapGenYCbCrToYCbCrGeneric *src2 = new VDPixmapGenYCbCrToYCbCrGeneric(basisDst, dstLimitedRange, basisSrc, srcLimitedRange, colorSpace);
+
+ src2->Init(args[0].mpSrc, args[0].mSrcIndex, args[1].mpSrc, args[1].mSrcIndex, args[2].mpSrc, args[2].mSrcIndex);
+ src = src2;
+ }
+
+ mGenerators.push_back(src);
+ MarkDependency(src, args[0].mpSrc);
+ MarkDependency(src, args[1].mpSrc);
+ MarkDependency(src, args[2].mpSrc);
+ args[0] = StackEntry(src, 0);
+ args[1] = StackEntry(src, 1);
+ args[2] = StackEntry(src, 2);
+}
+
IVDPixmapBlitter *VDPixmapUberBlitterGenerator::create() {
vdautoptr<VDPixmapUberBlitter> blitter(new VDPixmapUberBlitter);
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample.cpp
index 1363fb730..8174d6721 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <float.h>
#include <math.h>
#include <vd2/system/vdstl.h>
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special.cpp
index 0c649dd5c..b162dbcc0 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "uberblit_resample_special.h"
#include "blt_spanutils.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special_x86.cpp
index b1828fcca..990e0520e 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_resample_special_x86.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "uberblit_resample_special_x86.h"
#include "blt_spanutils.h"
#include "blt_spanutils_x86.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle.cpp
index 4cb5e4409..d65c317a2 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "uberblit_swizzle.h"
void VDPixmapGen_Swap8In16::Init(IVDPixmapGen *gen, int srcIndex, uint32 w, uint32 h, uint32 bpr) {
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle_x86.cpp
index 3a87d5a68..311ecde84 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_swizzle_x86.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "uberblit_swizzle_x86.h"
#ifdef VD_COMPILER_MSVC
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_v210.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_v210.cpp
index 78793f477..1e558aabd 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_v210.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_v210.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include <vd2/system/halffloat.h>
#include <vd2/system/math.h>
#include "uberblit_v210.h"
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_generic.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_generic.cpp
new file mode 100644
index 000000000..3820c7254
--- /dev/null
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_generic.cpp
@@ -0,0 +1,545 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
+#include <vd2/system/vectors.h>
+#include "uberblit_ycbcr_generic.h"
+
+extern const VDPixmapGenYCbCrBasis g_VDPixmapGenYCbCrBasis_601 = {
+ 0.299f,
+ 0.114f,
+ {
+ 0.0f, -0.3441363f, 1.772f,
+ 1.402f, -0.7141363f, 0.0f,
+ }
+};
+
+extern const VDPixmapGenYCbCrBasis g_VDPixmapGenYCbCrBasis_709 = {
+ 0.2126f,
+ 0.0722f,
+ {
+ 0.0f, -0.1873243f, 1.8556f,
+ 1.5748f, -0.4681243f, 0.0f,
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenYCbCrToRGB32Generic::VDPixmapGenYCbCrToRGB32Generic(const VDPixmapGenYCbCrBasis& basis, bool studioRGB) {
+ float scale;
+ float bias;
+
+ if (studioRGB) {
+ scale = 65536.0f * (219.0f / 255.0f);
+ bias = 65536.0f * (16.0f / 255.0f + 0.5f);
+ } else {
+ scale = 65536.0f;
+ bias = 32768.0f;
+ }
+
+ float scale255 = scale * 255.0f;
+
+ mCoY = VDRoundToInt32(scale);
+ mCoRCr = VDRoundToInt32(basis.mToRGB[1][0] * scale);
+ mCoGCr = VDRoundToInt32(basis.mToRGB[1][1] * scale);
+ mCoGCb = VDRoundToInt32(basis.mToRGB[0][1] * scale);
+ mCoBCb = VDRoundToInt32(basis.mToRGB[0][2] * scale);
+ mBiasR = VDRoundToInt32(bias) - 128*mCoRCr;
+ mBiasG = VDRoundToInt32(bias) - 128*(mCoGCr + mCoGCb);
+ mBiasB = VDRoundToInt32(bias) - 128*mCoBCb;
+}
+
+uint32 VDPixmapGenYCbCrToRGB32Generic::GetType(uint32 output) const {
+ return (mpSrcY->GetType(mSrcIndexY) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_8888 | kVDPixSpace_BGR;
+}
+
+void VDPixmapGenYCbCrToRGB32Generic::Compute(void *dst0, sint32 y) {
+ uint8 *dst = (uint8 *)dst0;
+ const uint8 *srcY = (const uint8 *)mpSrcY->GetRow(y, mSrcIndexY);
+ const uint8 *srcCb = (const uint8 *)mpSrcCb->GetRow(y, mSrcIndexCb);
+ const uint8 *srcCr = (const uint8 *)mpSrcCr->GetRow(y, mSrcIndexCr);
+
+ const sint32 coY = mCoY;
+ const sint32 coRCr = mCoRCr;
+ const sint32 coGCr = mCoGCr;
+ const sint32 coGCb = mCoGCb;
+ const sint32 coBCb = mCoBCb;
+ const sint32 biasR = mBiasR;
+ const sint32 biasG = mBiasG;
+ const sint32 biasB = mBiasB;
+
+ const sint32 w = mWidth;
+ for(sint32 i=0; i<w; ++i) {
+ sint32 y = srcY[i];
+ sint32 cb = srcCb[i];
+ sint32 cr = srcCr[i];
+
+ y *= coY;
+
+ sint32 r = biasR + y + coRCr * cr;
+ sint32 g = biasG + y + coGCr * cr + coGCb * cb;
+ sint32 b = biasB + y + coBCb * cb;
+
+ // clip low
+ r &= ~r >> 31;
+ g &= ~g >> 31;
+ b &= ~b >> 31;
+
+ // clip high
+ sint32 clipR = 0xffffff - r;
+ sint32 clipG = 0xffffff - g;
+ sint32 clipB = 0xffffff - b;
+ r |= clipR >> 31;
+ g |= clipG >> 31;
+ b |= clipB >> 31;
+
+ dst[0] = (uint8)(b >> 16);
+ dst[1] = (uint8)(g >> 16);
+ dst[2] = (uint8)(r >> 16);
+ dst[3] = 0xff;
+
+ dst += 4;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenYCbCrToRGB32FGeneric::VDPixmapGenYCbCrToRGB32FGeneric(const VDPixmapGenYCbCrBasis& basis) {
+ mCoRCr = basis.mToRGB[1][0];
+ mCoGCr = basis.mToRGB[1][1];
+ mCoGCb = basis.mToRGB[0][1];
+ mCoBCb = basis.mToRGB[0][2];
+}
+
+uint32 VDPixmapGenYCbCrToRGB32FGeneric::GetType(uint32 output) const {
+ return (mpSrcY->GetType(mSrcIndexY) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_32Fx4_LE | kVDPixSpace_BGR;
+}
+
+void VDPixmapGenYCbCrToRGB32FGeneric::Compute(void *dst0, sint32 y) {
+ float *dst = (float *)dst0;
+ const float *srcY = (const float *)mpSrcY->GetRow(y, mSrcIndexY);
+ const float *srcCb = (const float *)mpSrcCb->GetRow(y, mSrcIndexCb);
+ const float *srcCr = (const float *)mpSrcCr->GetRow(y, mSrcIndexCr);
+
+ VDCPUCleanupExtensions();
+
+ const float coRCr = mCoRCr;
+ const float coGCr = mCoGCr;
+ const float coGCb = mCoGCb;
+ const float coBCb = mCoBCb;
+
+ for(sint32 i=0; i<mWidth; ++i) {
+ float y = srcY[i];
+ float cb = srcCb[i] - (128.0f / 255.0f);
+ float cr = srcCr[i] - (128.0f / 255.0f);
+
+ dst[0] = y + coRCr * cr;
+ dst[1] = y + coGCr * cr + coGCb * cb;
+ dst[2] = y + coBCb * cb;
+ dst[3] = 1.0f;
+ dst += 4;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenRGB32ToYCbCrGeneric::VDPixmapGenRGB32ToYCbCrGeneric(const VDPixmapGenYCbCrBasis& basis, bool studioRGB, uint32 colorSpace)
+ : mColorSpace(colorSpace)
+{
+ float scale;
+ float bias;
+
+ if (studioRGB) {
+ scale = 255.0f / 219.0f;
+ bias = -16.0f;
+ } else {
+ scale = 1.0f;
+ bias = 0.0f;
+ }
+
+
+ // compute Y coefficients
+ float coYR = basis.mKr;
+ float coYG = (1.0f - basis.mKr - basis.mKb);
+ float coYB = basis.mKb;
+
+ mCoYR = VDRoundToInt32(scale * coYR * 65536.0f);
+ mCoYG = VDRoundToInt32(scale * coYG * 65536.0f);
+ mCoYB = VDRoundToInt32(scale * coYB * 65536.0f);
+ mCoYA = 0x8000;
+
+ // Cb = 0.5 * (B-Y) / (1-Kb)
+ const float coCb = 0.5f / (1.0f - basis.mKb);
+ float coCbR = (0.0f - coYR) * coCb;
+ float coCbG = (0.0f - coYG) * coCb;
+ float coCbB = (1.0f - coYB) * coCb;
+ float coCbA = (coCbR + coCbG + coCbB) * bias;
+
+ // Cr = 0.5 * (R-Y) / (1-Kr)
+ const float coCr = 0.5f / (1.0f - basis.mKr);
+ float coCrR = (1.0f - coYR) * coCr;
+ float coCrG = (0.0f - coYG) * coCr;
+ float coCrB = (0.0f - coYB) * coCr;
+ float coCrA = (coCrR + coCrG + coCrB) * bias;
+
+ mCoCbR = VDRoundToInt32(coCbR * 65536.0f);
+ mCoCbG = VDRoundToInt32(coCbG * 65536.0f);
+ mCoCbB = VDRoundToInt32(coCbB * 65536.0f);
+ mCoCbA = VDRoundToInt32(coCbA * 65536.0f) + 0x808000;
+
+ mCoCrR = VDRoundToInt32(coCrR * 65536.0f);
+ mCoCrG = VDRoundToInt32(coCrG * 65536.0f);
+ mCoCrB = VDRoundToInt32(coCrB * 65536.0f);
+ mCoCrA = VDRoundToInt32(coCrA * 65536.0f) + 0x808000;
+}
+
+uint32 VDPixmapGenRGB32ToYCbCrGeneric::GetType(uint32 output) const {
+ return (mpSrc->GetType(mSrcIndex) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_8 | mColorSpace;
+}
+
+void VDPixmapGenRGB32ToYCbCrGeneric::Compute(void *dst0, sint32 y) {
+ uint8 *dstCr = (uint8 *)dst0;
+ uint8 *dstY = dstCr + mWindowPitch;
+ uint8 *dstCb = dstY + mWindowPitch;
+
+ const uint8 *srcRGB = (const uint8 *)mpSrc->GetRow(y, mSrcIndex);
+
+ const sint32 coYR = mCoYR;
+ const sint32 coYG = mCoYG;
+ const sint32 coYB = mCoYB;
+ const sint32 coCbR = mCoCbR;
+ const sint32 coCbG = mCoCbG;
+ const sint32 coCbB = mCoCbB;
+ const sint32 coCrR = mCoCrR;
+ const sint32 coCrG = mCoCrG;
+ const sint32 coCrB = mCoCrB;
+ const sint32 coYA = mCoYA;
+ const sint32 coCbA = mCoCbA;
+ const sint32 coCrA = mCoCrA;
+
+ const sint32 w = mWidth;
+ for(sint32 i=0; i<w; ++i) {
+ int r = (int)srcRGB[2];
+ int g = (int)srcRGB[1];
+ int b = (int)srcRGB[0];
+ srcRGB += 4;
+
+ // Normally, this can be optimized by encoding the chroma channels as
+ // (R-Y) and (B-Y) differences. However, us working in fixed point complicates
+ // things here, so for now we do a full 4x3 matrix.
+
+ sint32 y16 = coYR * r + coYG * g + coYB * b + coYA;
+ sint32 cb16 = coCbR * r + coCbG * g + coCbB * b + coCbA;
+ sint32 cr16 = coCrR * r + coCrG * g + coCrB * b + coCrA;
+
+ // Quite annoyingly, we have to clip chroma on the high end since the transformation
+ // targets [0,1] instead of [0,1). This occurs due to the bias by +0.5 to make
+ // reference black for chroma fall on 128 instead of 127.5. The resulting
+ // transformation is the one used for JFIF and also for TIFF with the full
+ // range ReferenceBlack/ReferenceWhite values.
+
+ cb16 |= (0xffffff - cb16) >> 31;
+ cr16 |= (0xffffff - cr16) >> 31;
+
+ *dstCb++ = (uint8)(cb16 >> 16);
+ *dstY ++ = (uint8)( y16 >> 16);
+ *dstCr++ = (uint8)(cr16 >> 16);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenRGB32FToYCbCrGeneric::VDPixmapGenRGB32FToYCbCrGeneric(const VDPixmapGenYCbCrBasis& basis, uint32 colorSpace)
+ : mColorSpace(colorSpace)
+{
+ mCoYR = basis.mKr;
+ mCoYG = 1.0f - basis.mKr - basis.mKb;
+ mCoYB = basis.mKb;
+
+ // Cb = 0.5 * (B-Y) / (1-Kb)
+ mCoCb = 0.5f / (1.0f - basis.mKb);
+
+ // Cr = 0.5 * (R-Y) / (1-Kr)
+ mCoCr = 0.5f / (1.0f - basis.mKr);
+}
+
+uint32 VDPixmapGenRGB32FToYCbCrGeneric::GetType(uint32 output) const {
+ return (mpSrc->GetType(mSrcIndex) & ~(kVDPixType_Mask | kVDPixSpace_Mask)) | kVDPixType_32F_LE | mColorSpace;
+}
+
+void VDPixmapGenRGB32FToYCbCrGeneric::Compute(void *dst0, sint32 y) {
+ float *dstCr = (float *)dst0;
+ float *dstY = dstCr + mWindowPitch;
+ float *dstCb = dstY + mWindowPitch;
+
+ const float *srcRGB = (const float *)mpSrc->GetRow(y, mSrcIndex);
+
+ VDCPUCleanupExtensions();
+
+ const float coYR = mCoYR;
+ const float coYG = mCoYG;
+ const float coYB = mCoYB;
+ const float coCb = mCoCb;
+ const float coCr = mCoCr;
+
+ const sint32 w = mWidth;
+ for(sint32 i=0; i<w; ++i) {
+ float r = srcRGB[2];
+ float g = srcRGB[1];
+ float b = srcRGB[0];
+ srcRGB += 4;
+
+ float y = coYR * r + coYG * g + coYB * b;
+
+ *dstY++ = y;
+ *dstCb++ = coCb * (b - y) + (128.0f / 255.0f);
+ *dstCr++ = coCr * (r - y) + (128.0f / 255.0f);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenYCbCrToYCbCrGeneric::VDPixmapGenYCbCrToYCbCrGeneric(const VDPixmapGenYCbCrBasis& dstBasis, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& srcBasis, bool srcLimitedRange, uint32 colorSpace)
+ : mColorSpace(colorSpace)
+{
+ vdfloat3x3 dstToRGB;
+ dstToRGB.m[0] = vdfloat3c(1, 1, 1);
+ dstToRGB.m[1] = vdfloat3c(dstBasis.mToRGB[0]);
+ dstToRGB.m[2] = vdfloat3c(dstBasis.mToRGB[1]);
+
+ if (dstLimitedRange) {
+ dstToRGB.m[0] *= (255.0f / 219.0f);
+ dstToRGB.m[1] *= (128.0f / 112.0f);
+ dstToRGB.m[2] *= (128.0f / 112.0f);
+ }
+
+ vdfloat3x3 srcToRGB;
+ srcToRGB.m[0] = vdfloat3c(1, 1, 1);
+ srcToRGB.m[1] = vdfloat3c(srcBasis.mToRGB[0]);
+ srcToRGB.m[2] = vdfloat3c(srcBasis.mToRGB[1]);
+
+ if (srcLimitedRange) {
+ srcToRGB.m[0] *= (255.0f / 219.0f);
+ srcToRGB.m[1] *= (128.0f / 112.0f);
+ srcToRGB.m[2] *= (128.0f / 112.0f);
+ }
+
+ vdfloat3x3 xf(srcToRGB * ~dstToRGB);
+
+ // We should get a transform that looks like this:
+ //
+ // |k 0 0|
+ // [y cb cr 1] |a c e| = [y' cb' cr]
+ // |b d f|
+ // |x y z|
+
+ VDASSERT(fabsf(xf.m[0].v[1]) < 1e-5f);
+ VDASSERT(fabsf(xf.m[0].v[2]) < 1e-5f);
+
+ mCoYY = VDRoundToInt32(xf.m[0].v[0] * 65536.0f);
+ mCoYCb = VDRoundToInt32(xf.m[1].v[0] * 65536.0f);
+ mCoYCr = VDRoundToInt32(xf.m[2].v[0] * 65536.0f);
+ mCoCbCb = VDRoundToInt32(xf.m[1].v[1] * 65536.0f);
+ mCoCbCr = VDRoundToInt32(xf.m[2].v[1] * 65536.0f);
+ mCoCrCb = VDRoundToInt32(xf.m[1].v[2] * 65536.0f);
+ mCoCrCr = VDRoundToInt32(xf.m[2].v[2] * 65536.0f);
+
+ vdfloat3c srcBias(0, 128.0f/255.0f, 128.0f/255.0f);
+ if (srcLimitedRange)
+ srcBias.set(16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f);
+
+ vdfloat3c dstBias(0, 128.0f/255.0f, 128.0f/255.0f);
+ if (dstLimitedRange)
+ dstBias.set(16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f);
+
+ vdfloat3 bias = -srcBias * xf + dstBias;
+
+ mCoYA = VDRoundToInt32(bias.x * 255.0f * 65536.0f) + 0x8000;
+ mCoCbA = VDRoundToInt32(bias.y * 255.0f * 65536.0f) + 0x8000;
+ mCoCrA = VDRoundToInt32(bias.z * 255.0f * 65536.0f) + 0x8000;
+}
+
+void VDPixmapGenYCbCrToYCbCrGeneric::Start() {
+ mpSrcY->Start();
+ mpSrcCb->Start();
+ mpSrcCr->Start();
+
+ StartWindow(mWidth, 3);
+}
+
+const void *VDPixmapGenYCbCrToYCbCrGeneric::GetRow(sint32 y, uint32 index) {
+ return (const uint8 *)VDPixmapGenYCbCrToRGBBase::GetRow(y, index) + mWindowPitch * index;
+}
+
+uint32 VDPixmapGenYCbCrToYCbCrGeneric::GetType(uint32 output) const {
+ return (mpSrcY->GetType(mSrcIndexY) & ~kVDPixSpace_Mask) | mColorSpace;
+}
+
+void VDPixmapGenYCbCrToYCbCrGeneric::Compute(void *dst0, sint32 ypos) {
+ uint8 *dstCr = (uint8 *)dst0;
+ uint8 *dstY = dstCr + mWindowPitch;
+ uint8 *dstCb = dstY + mWindowPitch;
+
+ const uint8 *srcY = (const uint8 *)mpSrcY ->GetRow(ypos, mSrcIndexY );
+ const uint8 *srcCb = (const uint8 *)mpSrcCb->GetRow(ypos, mSrcIndexCb);
+ const uint8 *srcCr = (const uint8 *)mpSrcCr->GetRow(ypos, mSrcIndexCr);
+
+ const sint32 coYY = mCoYY;
+ const sint32 coYCb = mCoYCb;
+ const sint32 coYCr = mCoYCr;
+ const sint32 coYA = mCoYA;
+ const sint32 coCbCb = mCoCbCb;
+ const sint32 coCbCr = mCoCbCr;
+ const sint32 coCbA = mCoCbA;
+ const sint32 coCrCb = mCoCrCb;
+ const sint32 coCrCr = mCoCrCr;
+ const sint32 coCrA = mCoCrA;
+
+ for(sint32 i=0; i<mWidth; ++i) {
+ sint32 y = srcY[i];
+ sint32 cb = srcCb[i];
+ sint32 cr = srcCr[i];
+
+ sint32 y2 = y*coYY + cb*coYCb + cr*coYCr + coYA;
+ sint32 cb2 = cb*coCbCb + cr*coCbCr + coCbA;
+ sint32 cr2 = cb*coCrCb + cr*coCrCr + coCrA;
+
+ y2 &= ~y2 >> 31;
+ cb2 &= ~cb2 >> 31;
+ cr2 &= ~cr2 >> 31;
+
+ y2 |= (0xffffff - y2) >> 31;
+ cb2 |= (0xffffff - cb2) >> 31;
+ cr2 |= (0xffffff - cr2) >> 31;
+
+ *dstY++ = (uint8)(y2 >> 16);
+ *dstCb++ = (uint8)(cb2 >> 16);
+ *dstCr++ = (uint8)(cr2 >> 16);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+VDPixmapGenYCbCrToYCbCrGeneric_32F::VDPixmapGenYCbCrToYCbCrGeneric_32F(const VDPixmapGenYCbCrBasis& dstBasis, bool dstLimitedRange, const VDPixmapGenYCbCrBasis& srcBasis, bool srcLimitedRange, uint32 colorSpace)
+ : mColorSpace(colorSpace)
+{
+ vdfloat3x3 dstToRGB;
+ dstToRGB.m[0] = vdfloat3c(1, 1, 1);
+ dstToRGB.m[1] = vdfloat3c(dstBasis.mToRGB[0]);
+ dstToRGB.m[2] = vdfloat3c(dstBasis.mToRGB[1]);
+
+ if (dstLimitedRange) {
+ dstToRGB.m[0] *= (255.0f / 219.0f);
+ dstToRGB.m[1] *= (255.0f / 224.0f);
+ dstToRGB.m[2] *= (255.0f / 224.0f);
+ }
+
+ vdfloat3x3 srcToRGB;
+ srcToRGB.m[0] = vdfloat3c(1, 1, 1);
+ srcToRGB.m[1] = vdfloat3c(srcBasis.mToRGB[0]);
+ srcToRGB.m[2] = vdfloat3c(srcBasis.mToRGB[1]);
+
+ if (srcLimitedRange) {
+ srcToRGB.m[0] *= (255.0f / 219.0f);
+ srcToRGB.m[1] *= (255.0f / 224.0f);
+ srcToRGB.m[2] *= (255.0f / 224.0f);
+ }
+
+ vdfloat3x3 xf(srcToRGB * ~dstToRGB);
+
+ // We should get a transform that looks like this:
+ //
+ // |k 0 0|
+ // [y cb cr 1] |a c e| = [y' cb' cr]
+ // |b d f|
+ // |x y z|
+
+ VDASSERT(fabsf(xf.m[0].v[1]) < 1e-5f);
+ VDASSERT(fabsf(xf.m[0].v[2]) < 1e-5f);
+
+ mCoYY = xf.m[0].v[0];
+ mCoYCb = xf.m[1].v[0];
+ mCoYCr = xf.m[2].v[0];
+ mCoCbCb = xf.m[1].v[1];
+ mCoCbCr = xf.m[2].v[1];
+ mCoCrCb = xf.m[1].v[2];
+ mCoCrCr = xf.m[2].v[2];
+
+ vdfloat3c srcBias(0, 128.0f/255.0f, 128.0f/255.0f);
+ if (srcLimitedRange)
+ srcBias.set(16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f);
+
+ vdfloat3c dstBias(0, 128.0f/255.0f, 128.0f/255.0f);
+ if (dstLimitedRange)
+ dstBias.set(16.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f);
+
+ vdfloat3 bias = -srcBias * xf + dstBias;
+
+ mCoYA = bias.x;
+ mCoCbA = bias.y;
+ mCoCrA = bias.z;
+}
+
+void VDPixmapGenYCbCrToYCbCrGeneric_32F::Start() {
+ mpSrcY->Start();
+ mpSrcCb->Start();
+ mpSrcCr->Start();
+
+ StartWindow(mWidth * sizeof(float), 3);
+}
+
+const void *VDPixmapGenYCbCrToYCbCrGeneric_32F::GetRow(sint32 y, uint32 index) {
+ return (const uint8 *)VDPixmapGenYCbCrToRGBBase::GetRow(y, index) + mWindowPitch * index;
+}
+
+uint32 VDPixmapGenYCbCrToYCbCrGeneric_32F::GetType(uint32 output) const {
+ return (mpSrcY->GetType(mSrcIndexY) & ~kVDPixSpace_Mask) | mColorSpace;
+}
+
+void VDPixmapGenYCbCrToYCbCrGeneric_32F::Compute(void *dst0, sint32 ypos) {
+ float *dstCr = (float *)dst0;
+ float *dstY = vdptroffset(dstCr, mWindowPitch);
+ float *dstCb = vdptroffset(dstY, mWindowPitch);
+
+ const float *srcY = (const float *)mpSrcY ->GetRow(ypos, mSrcIndexY );
+ const float *srcCb = (const float *)mpSrcCb->GetRow(ypos, mSrcIndexCb);
+ const float *srcCr = (const float *)mpSrcCr->GetRow(ypos, mSrcIndexCr);
+
+ VDCPUCleanupExtensions();
+
+ const float coYY = mCoYY;
+ const float coYCb = mCoYCb;
+ const float coYCr = mCoYCr;
+ const float coYA = mCoYA;
+ const float coCbCb = mCoCbCb;
+ const float coCbCr = mCoCbCr;
+ const float coCbA = mCoCbA;
+ const float coCrCb = mCoCrCb;
+ const float coCrCr = mCoCrCr;
+ const float coCrA = mCoCrA;
+
+ for(sint32 i=0; i<mWidth; ++i) {
+ float y = srcY [i];
+ float cb = srcCb[i];
+ float cr = srcCr[i];
+
+ *dstY++ = y*coYY + cb*coYCb + cr*coYCr + coYA;
+ *dstCb++ = cb*coCbCb + cr*coCbCr + coCbA;
+ *dstCr++ = cb*coCrCb + cr*coCrCr + coCrA;
+ }
+}
diff --git a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_x86.cpp b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_x86.cpp
index d34f731f1..4a2b10563 100644
--- a/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_x86.cpp
+++ b/src/thirdparty/VirtualDub/Kasumi/source/uberblit_ycbcr_x86.cpp
@@ -1,3 +1,22 @@
+// VirtualDub - Video processing and capture application
+// Graphics support library
+// Copyright (C) 1998-2009 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#include <stdafx.h>
#include "uberblit_ycbcr_x86.h"
extern "C" void vdasm_pixblt_XRGB8888_to_YUV444Planar_scan_SSE2(void *dstY, void *dstCb, void *dstCr, const void *srcRGB, uint32 count, const void *coeffs);