From 8edf9b1fa44dbcc807e9298ce97791a12df85956 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Sun, 28 Oct 2012 02:46:56 +0200
Subject: [PATCH] sws: rgb has no range, avoid random results if the user tries
 to mess with it anyway.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 libswscale/utils.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index e300cae6f5..21fd718e4c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -789,11 +789,17 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
     memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
     memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
 
+    if(!isYUV(c->dstFormat) && !isGray(c->dstFormat))
+        dstRange = 0;
+    if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
+        srcRange = 0;
+
     c->brightness = brightness;
     c->contrast   = contrast;
     c->saturation = saturation;
     c->srcRange   = srcRange;
     c->dstRange   = dstRange;
+
     if (isYUV(c->dstFormat) || isGray(c->dstFormat))
         return -1;