changeset 19987:f00912e9480b

Add support for YUVJ formats
author lucabe
date Wed, 27 Sep 2006 11:41:36 +0000
parents 6d2433bc7600
children 56abe3a92f68
files libswscale/swscale.c
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale.c	Wed Sep 27 11:24:28 2006 +0000
+++ b/libswscale/swscale.c	Wed Sep 27 11:41:36 2006 +0000
@@ -1841,6 +1841,23 @@
 	return 0;	
 }
 
+static int handle_jpeg(int *format)
+{
+	switch (*format) {
+		case PIX_FMT_YUVJ420P:
+			*format = PIX_FMT_YUV420P;
+			return 1;
+		case PIX_FMT_YUVJ422P:
+			*format = PIX_FMT_YUV422P;
+			return 1;
+		case PIX_FMT_YUVJ444P:
+			*format = PIX_FMT_YUV444P;
+			return 1;
+		default:
+			return 0;
+	}
+}
+
 SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
                          SwsFilter *srcFilter, SwsFilter *dstFilter, double *param){
 
@@ -1848,6 +1865,7 @@
 	int i;
 	int usesVFilter, usesHFilter;
 	int unscaled, needsDither;
+	int srcRange, dstRange;
 	SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
 #if defined(ARCH_X86) || defined(ARCH_X86_64)
 	if(flags & SWS_CPU_CAPS_MMX)
@@ -1874,6 +1892,9 @@
 		     && (fmt_depth(dstFormat))<24
 		     && ((fmt_depth(dstFormat))<(fmt_depth(srcFormat)) || (!(isRGB(srcFormat) || isBGR(srcFormat))));
 
+	srcRange = handle_jpeg(&srcFormat);
+	dstRange = handle_jpeg(&dstFormat);
+
 	if(!isSupportedIn(srcFormat)) 
 	{
 		MSG_ERR("swScaler: %s is not supported as input format\n", sws_format_name(srcFormat));
@@ -1951,7 +1972,7 @@
 	c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
 	c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
 
-	sws_setColorspaceDetails(c, Inverse_Table_6_9[SWS_CS_DEFAULT], 0, Inverse_Table_6_9[SWS_CS_DEFAULT] /* FIXME*/, 0, 0, 1<<16, 1<<16); 
+	sws_setColorspaceDetails(c, Inverse_Table_6_9[SWS_CS_DEFAULT], srcRange, Inverse_Table_6_9[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16); 
 
 	/* unscaled special Cases */
 	if(unscaled && !usesHFilter && !usesVFilter)