mpeg2enc reduction parameters -4 and -2 take value 0 ... or not?
Linards Ticmanis <[email protected]> Sun, 05 Sep 2010 20:06:11 +0200
| Newsgroups | gmane.comp.video.mjpeg.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------070709030606050408060709
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Currently, the mpeg2enc search reduction parameters --reduction-4x4 and
--reduction-2x2 accept a numerical value of zero (although the
documentation says otherwise), but then the whole thing comes down with
a segfault due to division by zero.
Of course it would be possible to just fix the parameter checking code
to kill this bug, but I said to myself "what the hell" and implemented
the "zero reduction". No idea whether it makes any sense, I'm just doing
a few tests but I can't of course test all imaginable scenarios.
Any opinions on this?
I've included the diff for this change.
--
Linards Ticmanis
--------------070709030606050408060709
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 17:51:38 -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 -u -r1.80 mpeg2enc.cc
--- mpeg2enc/mpeg2enc.cc 29 Jan 2008 23:44:13 -0000 1.80
+++ mpeg2enc/mpeg2enc.cc 5 Sep 2010 17:59:38 -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 17:51:39 -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
@@ -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 17:51:39 -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 17:51:39 -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;
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 17:51:39 -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 17:51:39 -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,
--------------070709030606050408060709
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
--------------070709030606050408060709
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
--------------070709030606050408060709--