[vlc-devel] [PATCH 09/24] [codec/dirac] Enable adjusting of motion block parameters

davidf+nntp at woaf.net davidf+nntp at woaf.net
Thu Oct 30 12:29:38 CET 2008


From: David Flynn <davidf at rd.bbc.co.uk>


Signed-off-by: David Flynn <davidf at rd.bbc.co.uk>
---
 modules/codec/dirac.c |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/modules/codec/dirac.c b/modules/codec/dirac.c
index 70489bb..bf29e68 100644
--- a/modules/codec/dirac.c
+++ b/modules/codec/dirac.c
@@ -48,6 +48,13 @@
 # define DIRAC_RESEARCH_VERSION_ATLEAST(x,y,z) 0
 #endif
 
+#ifndef MIN
+# define MIN(x,y) (((x) < (y)) ? (x) : (y))
+#endif
+#ifndef MAX
+# define MAX(x,y) (((x) > (y)) ? (x) : (y))
+#endif
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -553,29 +560,42 @@ static int OpenEncoder( vlc_object_t *p_this )
     if( val.psz_string )
         free( val.psz_string );
 
+    /*
+     * {x,y}b{len,sep} must be multiples of 4
+     */
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_WIDTH, &val );
     if( val.i_int > -1 )
-        p_sys->ctx.enc_params.xbsep = val.i_int;
+        p_sys->ctx.enc_params.xbsep = val.i_int / 4 * 4;
 
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_HEIGHT, &val );
     if( val.i_int > -1 )
-        p_sys->ctx.enc_params.ybsep = val.i_int;
+        p_sys->ctx.enc_params.ybsep = val.i_int / 4 * 4;
 
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_HOVERLAP, &val );
     if( val.i_int > -1 )
-        p_sys->ctx.enc_params.xblen = val.i_int / 0;
+        p_sys->ctx.enc_params.xblen = p_sys->ctx.enc_params.xbsep * (100 + val.i_int) / 400 * 4;
 
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_VOVERLAP, &val );
     if( val.i_int > -1 )
-        p_sys->ctx.enc_params.yblen = val.i_int / 0;
+        p_sys->ctx.enc_params.yblen = p_sys->ctx.enc_params.ybsep * (100 + val.i_int) / 400 * 4;
 
+    /*
+     * {x,y}blen >= {x,y}bsep
+     * {x,y}blen <= 2* {x,y}bsep
+     */
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_XBLEN, &val );
-    if( val.i_int > -1 )
-        p_sys->ctx.enc_params.xblen = val.i_int;
+    if( val.i_int > -1 ) {
+        int xblen = MAX( val.i_int, p_sys->ctx.enc_params.xbsep );
+        xblen = MIN( xblen, 2 * p_sys->ctx.enc_params.xbsep );
+        p_sys->ctx.enc_params.xblen = xblen;
+    }
 
     var_Get( p_enc, ENC_CFG_PREFIX ENC_MCBLK_YBLEN, &val );
-    if( val.i_int > -1 )
-        p_sys->ctx.enc_params.yblen = val.i_int;
+    if( val.i_int > -1 ) {
+        int yblen = MAX( val.i_int, p_sys->ctx.enc_params.ybsep );
+        yblen = MIN( yblen, 2 * p_sys->ctx.enc_params.ybsep );
+        p_sys->ctx.enc_params.yblen = yblen;
+    }
 
 #if 0
     var_Get( p_enc, ENC_CFG_PREFIX ENC_ME_FULLSEARCH, &val );
-- 
1.5.6.5




More information about the vlc-devel mailing list