[FFmpeg-devel] [PATCH] Move param initialization and colorspace details from sws_getContext() to sws_init_context().

Stefano Sabatini stefano.sabatini-lala
Wed Sep 29 18:00:27 CEST 2010


Allow to automatically set the default parameters without explicitely
set them, also simplify conversion to the new sws_init_context() API.
---
 utils.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/utils.c b/utils.c
index 938af9e..bee5a3a 100644
--- a/utils.c
+++ b/utils.c
@@ -761,10 +761,17 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
     int dstW= c->dstW;
     int dstH= c->dstH;
     int flags;
+    c->srcRange = handle_jpeg(&c->srcFormat);
+    c->dstRange = handle_jpeg(&c->dstFormat);
     enum PixelFormat srcFormat= c->srcFormat;
     enum PixelFormat dstFormat= c->dstFormat;
 
     flags= c->flags = update_flags_cpu(c->flags);
+    if (!c->param[0]) c->param[0] = SWS_PARAM_DEFAULT;
+    if (!c->param[1]) c->param[1] = SWS_PARAM_DEFAULT;
+
+    sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, c->dstRange, 0, 1<<16, 1<<16);
+
 #if ARCH_X86
     if (flags & SWS_CPU_CAPS_MMX)
         __asm__ volatile("emms\n\t"::: "memory");
@@ -1151,20 +1158,9 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
     c->srcH= srcH;
     c->dstW= dstW;
     c->dstH= dstH;
-    c->srcRange = handle_jpeg(&srcFormat);
-    c->dstRange = handle_jpeg(&dstFormat);
     c->srcFormat= srcFormat;
     c->dstFormat= dstFormat;
 
-    if (param) {
-        c->param[0] = param[0];
-        c->param[1] = param[1];
-    } else {
-        c->param[0] =
-        c->param[1] = SWS_PARAM_DEFAULT;
-    }
-    sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, c->dstRange, 0, 1<<16, 1<<16);
-
     if(sws_init_context(c, srcFilter, dstFilter) < 0){
         sws_freeContext(c);
         return NULL;
-- 
1.7.1




More information about the ffmpeg-devel mailing list