[xiph-commits] r7829 - in trunk/oggdsf/src/lib: codecs/theora/filters/dsfTheoraEncoder core/directshow/dsfAbstractVideoEncoder

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Wed Sep 22 04:36:26 PDT 2004


Author: illiminable
Date: 2004-09-22 04:36:25 -0700 (Wed, 22 Sep 2004)
New Revision: 7829

Modified:
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeInputPin.cpp
Log:
* Added encoding support for UYVY type.

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp	2004-09-22 10:59:35 UTC (rev 7828)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.cpp	2004-09-22 11:36:25 UTC (rev 7829)
@@ -735,6 +735,76 @@
 	}
 	return 0;
 }
+
+
+long TheoraEncodeInputPin::encodeUYVYToYV12(unsigned char* inBuf, long inNumBytes) {
+	//UYVY :: U0 Y0 V0 Y1   - Ugly Yellow Victor Yello
+	unsigned char* locSourceUptoPtr = inBuf;  //View only... don't delete locUptoPtr
+
+	//UYVY is U0 Y0 V0 Y1 U0 Y2 V0 Y3
+	//YUY2 is Y0 U0 Y1 V0 Y2 U1 Y3 V1
+	// it has twice as much sampling height as YV12 so downsample it.
+
+	char* locYUpto = mYUV.y;
+	char* locUUpto = mYUV.u;
+	char* locVUpto = mYUV.v;
+
+	
+
+	//After downsampling... from each block of 8, we get 4 y samples and 1 each of u and v
+
+
+	for (int i = 0; i < mHeight / 2; i++) {
+		//TO DO: Draw memory layouts.
+
+		//***Part of the average method... store the pointer to the last of the previous line
+		//locLastUUpto = locUUpto;
+		//locLastVUpto = locVUpto;
+		//***
+
+		for (int j = 0; j < mWidth / 2; j++) {
+			*(locUUpto++) = *(locSourceUptoPtr++);			//U for Ugly
+			*(locYUpto++) = *(locSourceUptoPtr++);			//Y for Yellow
+			
+			*(locVUpto++) = *(locSourceUptoPtr++);			//V for Victor
+			*(locYUpto++) = *(locSourceUptoPtr++);			//Y for Yellow
+			
+		}
+
+		
+		//***Drop line method
+		for (int j = 0; j < mWidth / 2; j++) {
+			//Ignore the second line
+			
+			locSourceUptoPtr++;								//U for ugly
+			*(locYUpto++) = *(locSourceUptoPtr++);			//Y for yellow
+
+			locSourceUptoPtr++;								//V for victor
+			*(locYUpto++) = *(locSourceUptoPtr++);			//Y for yellow
+			
+		}
+		//***
+
+		//*** PArt of the Alternate method to average...
+		//for (int j = 0; j < mWidth / 2; j++) {
+		//	//Ignore the second line
+		//	*(locYUpto++) = *(locSourceUptoPtr++);
+		//	*(locLastUUpto++) = ((short)(*locLastUUpto) + ((short)(*locUUpto))) / 2;
+		//	
+		//	*(locYUpto++) = *(locSourceUptoPtr++);
+		//	*(locLastVUpto++) = ((short)(*locLastVUpto) + ((short)(*locVUpto))) / 2;
+		//	
+		//}
+		//***
+
+
+
+	}
+	return 0;
+}
+
+
+
 //PURE VIRTUALS
 long TheoraEncodeInputPin::encodeData(unsigned char* inBuf, long inNumBytes) {
 
@@ -777,6 +847,10 @@
 		//Should be more specifc.
 		//debugLog<<"About to encode YV12 to YV12"<<endl;
 		encodeYV12ToYV12(inBuf, inNumBytes);
+	} else if (mPinInputType.subtype == MEDIASUBTYPE_UYVY) {
+		
+		
+		encodeUYVYToYV12(inBuf, inNumBytes);
 	} else {
 
 		//FATAL ERROR

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h	2004-09-22 10:59:35 UTC (rev 7828)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h	2004-09-22 11:36:25 UTC (rev 7829)
@@ -77,6 +77,7 @@
 	long encodeAYUVtoYV12(unsigned char* inBuf, long inNumBytes);
 	long encodeRGB24toYV12(unsigned char* inBuf, long inNumBytes);
 	long encodeRGB32toYV12(unsigned char* inBuf, long inNumBytes);
+	long encodeUYVYToYV12(unsigned char* inBuf, long inNumBytes);
 	//
 //	bool fillTheoraInfo(theora_info* outTheora, sTheoraFormatBlock* inTheoraFormatBlock); 		
 	//

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeInputPin.cpp	2004-09-22 10:59:35 UTC (rev 7828)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeInputPin.cpp	2004-09-22 11:36:25 UTC (rev 7829)
@@ -123,6 +123,7 @@
 	if	( (inMediaType->majortype == MEDIATYPE_Video) &&
 			(	inMediaType->subtype == MEDIASUBTYPE_YV12 ||	
 				inMediaType->subtype == MEDIASUBTYPE_YUY2 ||
+				inMediaType->subtype == MEDIASUBTYPE_UYVY ||
 				inMediaType->subtype == MEDIASUBTYPE_AYUV ||
 				inMediaType->subtype == MEDIASUBTYPE_RGB32 ||
 				inMediaType->subtype == MEDIASUBTYPE_RGB24
@@ -162,6 +163,7 @@
 
 	if  (	inMediaType->subtype == MEDIASUBTYPE_YV12 || 
 			inMediaType->subtype == MEDIASUBTYPE_YUY2 ||
+			inMediaType->subtype == MEDIASUBTYPE_UYVY ||
 			inMediaType->subtype == MEDIASUBTYPE_AYUV ||
 			inMediaType->subtype == MEDIASUBTYPE_RGB32 ||
 			inMediaType->subtype == MEDIASUBTYPE_RGB24
@@ -201,6 +203,10 @@
 		case 4:
 			outMediaType->SetType(&MEDIATYPE_Video);
 			outMediaType->SetSubtype(&MEDIASUBTYPE_AYUV);
+		case 5:
+			outMediaType->SetType(&MEDIATYPE_Video);
+			outMediaType->SetSubtype(&MEDIASUBTYPE_UYVY);
+
 		default:
 			return VFW_S_NO_MORE_ITEMS;
 	}



More information about the commits mailing list