Re: mpeg2enc reduction parameters -4 and -2 take value 0 ... or not?

Linards Ticmanis <[email protected]> Sun, 05 Sep 2010 22:30:30 +0200
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------020307060108010102020301
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Sorry, I missed some things in the diff I attached last time. New
(hopefully complete) version included here.

-- 
Linards Ticmanis

--------------020307060108010102020301
Content-Type: text/x-patch;
 name="reduction_0.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="reduction_0.diff"

diff -u -d -r1.59 mpeg2enc.1
--- docs/mpeg2enc.1	25 Mar 2008 03:04:59 -0000	1.59
+++ docs/mpeg2enc.1	5 Sep 2010 20:24:06 -0000
@@ -48,9 +48,9 @@
 .RB [ -z | --playback-field-order
 .IR b|t ]
 .RB [ -4 | --reduction-4x4
-.IR 1..4 ]
+.IR 0..4 ]
 .RB [ -2 | --reduction-2x2
-.IR 1..4 ]
+.IR 0..4 ]
 .RB [ -S | --sequence-length
 .IR size_MB ]
 .RB [ -B | --nonvideo-bitrate
@@ -588,9 +588,9 @@
 reducing the radius.  Speed gains are not huge and the impact on quality
 can be marked.
 .PP
-.BR -4|--reduction-4x4 \ 1..4
+.BR -4|--reduction-4x4 \ 0..4
 .PP
-.BR -2|--reduction-2x2 \ 1..4
+.BR -2|--reduction-2x2 \ 0..4
 .PP
 These options control how radical the encoder is in throwing away
 apparently poor candidate estimates during motion estimation.  A

diff -u -d -r1.80 mpeg2enc.cc
--- mpeg2enc/mpeg2enc.cc	29 Jan 2008 23:44:13 -0000	1.80
+++ mpeg2enc/mpeg2enc.cc	5 Sep 2010 20:24:07 -0000
@@ -490,10 +490,10 @@
 "    Motion compensation search radius [0..32] (default 16)\n"
 "--reduction-4x4|-4 num\n"
 "    Reduction factor for 4x4 subsampled candidate motion estimates\n"
-"    [1..4] [1 = max quality, 4 = max. speed] (default: 2)\n"
+"    [0..4] [0 = max quality, 4 = max. speed] (default: 2)\n"
 "--reduction-2x2|-2 num\n"
 "    Reduction factor for 2x2 subsampled candidate motion estimates\n"
-"    [1..4] [1 = max quality, 4 = max. speed] (default: 3)\n"
+"    [0..4] [0 = max quality, 4 = max. speed] (default: 3)\n"
 "--min-gop-size|-g num\n"
 "    Minimum size Group-of-Pictures (default depends on selected format)\n"
 "--max-gop-size|-G num\n"

diff -u -d -r1.28 motionsearch.c
--- utils/motionsearch.c	6 Dec 2006 23:59:36 -0000	1.28
+++ utils/motionsearch.c	5 Sep 2010 20:24:07 -0000
@@ -249,7 +249,7 @@
 	   out-of-range blocks...
 	*/
 	
-	threshold = 6*null_ctl_sad / (4*4*reduction);
+	threshold = reduction ? (6*null_ctl_sad / (4*4*reduction)) : INT_MAX;
 	s44orgblk = s44org+(ilow>>2)+qrowstride*(jlow>>2);
 	
 	/* Exhaustive search on 4*4 sub-sampled data.  This is affordable because
@@ -282,7 +282,7 @@
 	}
 	sub44set->len = sub44_num_mests;
 			
-	sub_mean_reduction( sub44set, 1+(reduction>1),  &mean_weight);
+	sub_mean_reduction( sub44set, reduction ? (1+(reduction>1)) : 0,  &mean_weight);
 
 
 	return sub44set->len;
@@ -317,7 +317,7 @@
 							   int reduction)
 {
 	int i,k,s;
-	int threshold = 6*null_ctl_sad / (2 * 2*reduction);
+	int threshold = reduction ? (6*null_ctl_sad / (2 * 2*reduction)) : INT_MAX;
 	
 	int min_weight;
 	int ilim = ihigh-i0;

diff -u -d -r1.10 build_sub22_mests.c
--- utils/altivec/build_sub22_mests.c	26 Nov 2006 19:32:24 -0000	1.10
+++ utils/altivec/build_sub22_mests.c	5 Sep 2010 20:24:07 -0000
@@ -23,6 +23,7 @@
 
 #include "altivec_motion.h"
 #include "vectorize.h"
+#include <limits.h>
 #include <math.h>
 #include "../mjpeg_logging.h"
 
@@ -193,7 +194,7 @@
     mres.x = ihigh - i0;    /* x <= (ihigh - i0) */
     mres.y = jhigh - j0;    /* y <= (jhigh - j0) */
     vio.init.xylim = mres;
-    threshold = 6 * null_ctl_sad / (reduction << 2);
+    threshold = reduction ? (6 * null_ctl_sad / (reduction << 2)) : INT_MAX;
     vio.init.threshold = threshold;
     xy22 = (vector signed char)VCONST(0,0,0,0, 0,0,2,0, 0,0,0,2, 0,0,2,2);
     xint = vu8(vec_splat_u32(0xf));

diff -u -d -r1.9 build_sub44_mests.c
--- utils/altivec/build_sub44_mests.c	26 Nov 2006 19:32:24 -0000	1.9
+++ utils/altivec/build_sub44_mests.c	5 Sep 2010 20:24:07 -0000
@@ -25,6 +25,7 @@
 #include "vectorize.h"
 #include "../fastintfns.h"
 #include "../mjpeg_logging.h"
+#include <limits.h>
 #include <math.h>
 #include <stdlib.h>
 
@@ -232,7 +233,7 @@
     increment = vec_splat_u8(4);
     /* }}} */
 
-    threshold = 6*null_ctl_sad / (4*4*reduction);
+    threshold = reduction ? (6*null_ctl_sad / (4*4*reduction)) : INT_MAX;
 
     y     = jlow  - j0;
     xlow  = ilow  - i0;
@@ -701,13 +702,13 @@
 
 #ifdef USE_SMR_PPC
     if (xl > 1)
-	xl = sub_mean_reduction_ppc(xl, sub44set, 1+(reduction > 1));
+      xl = sub_mean_reduction_ppc(xl, sub44set, reduction ? (1+(reduction > 1)) : 0);
     return xl;
 #else
 #  if ALTIVEC_TEST_FUNCTION(sub_mean_reduction)
-    ALTIVEC_TEST_SUFFIX(sub_mean_reduction)(sub44set, 1+(reduction>1), &mean_weight);
+    ALTIVEC_TEST_SUFFIX(sub_mean_reduction)(sub44set, reduction ? (1+(reduction>1)) : 0, &mean_weight);
 #  else
-    sub_mean_reduction_altivec(sub44set, 1+(reduction>1), &mean_weight);
+    sub_mean_reduction_altivec(sub44set, reduction ? (1+(reduction>1)) : 0, &mean_weight);
 #  endif
   return sub44set->len;
 #endif
@@ -736,7 +737,7 @@
     uint8_t *old_s44orgblk;
     int sub44_num_mests;
 
-    threshold = 6*null_ctl_sad / (4*4*reduction);
+    threshold = reduction ? (6*null_ctl_sad / (4*4*reduction)) : INT_MAX;
     s44orgblk = s44org+(ilow>>2)+qrowstride*(jlow>>2);
 
     sub44_num_mests = 0;
@@ -768,7 +769,7 @@
     sub44set->len = sub44_num_mests;
 
 #if 0
-    sub_mean_reduction(sub44set, 1+(reduction>1),  &mean_weight);
+    sub_mean_reduction(sub44set, reduction ? (1+(reduction>1)) : 0,  &mean_weight);
 #endif
 
     return sub44set->len;

diff -u -d -r1.6 build_sub22_mests.c
--- utils/mmxsse/build_sub22_mests.c	31 Jan 2005 00:57:28 -0000	1.6
+++ utils/mmxsse/build_sub22_mests.c	5 Sep 2010 20:24:08 -0000
@@ -2,6 +2,7 @@
 #include "mmxsse_motion.h"
 #include "fastintfns.h"
 
+#include <limits.h>
 #include <stdlib.h>
 
 int build_sub22_mests_mmxe( me_result_set *sub44set,
@@ -13,7 +14,7 @@
 				int reduction)
 {
 	int i,k,s;
-	int threshold = 6*null_ctl_sad / (2 * 2*reduction);
+	int threshold = reduction ? (6*null_ctl_sad / (2 * 2*reduction)) : INT_MAX;
 
 	int min_weight;
 	int ilim = ihigh-i0;

diff -u -d -r1.3 build_sub44_mests.c
--- utils/mmxsse/build_sub44_mests.c	10 Feb 2006 23:49:38 -0000	1.3
+++ utils/mmxsse/build_sub44_mests.c	5 Sep 2010 20:24:08 -0000
@@ -1,3 +1,4 @@
+#include <limits.h>
 #include "config.h"
 #include "mmxsse_motion.h"
 
@@ -16,7 +17,7 @@
 	int jend = jhigh-j0;
 	int mean_weight, threshold;
 	
-	threshold = 6*null_ctl_sad / (4*4*reduction);
+	threshold = reduction ? (6*null_ctl_sad / (4*4*reduction)) : INT_MAX;
 	s44orgblk = s44org+(ilow>>2)+qrowstride*(jlow>>2);
 	
 	sub44set->len = (*pmblocks_sub44_mests)( s44orgblk, s44blk,
@@ -28,6 +29,6 @@
 	
    /* If we're really pushing quality we reduce once otherwise twice. */
 			
-	sub_mean_reduction( sub44set, 1+(reduction>1),  &mean_weight);
+	sub_mean_reduction( sub44set, reduction ? (1+(reduction>1)) : 0,  &mean_weight);
 	return sub44set->len;
 }

--------------020307060108010102020301
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
--------------020307060108010102020301
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Mjpeg-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-developer

--------------020307060108010102020301--