On Tue, Sep 30, 2003 at 10:05:07AM -0700, Steven M. Schultz wrote:
> 
> On Tue, 30 Sep 2003, Richard Ellis wrote:
> 
> > Note the w: and h: sizes.  The border was specified as -b
> > 4,4,-4,-4, and when a -4 signed int is stuffed into an unsigned
> > int variable, 65532 is the resultant value.
> 
>       That's the -4 exactly - what should have happened is that the
>       frame width and the relative border offset should have been
>       added together - 720 + -4 would give 716 regardless of the
>       unsigned/signed nature of the border value (since 720 + 65532
>       within 16 bits will give 716 just as 720 - 4 does).
>       Similarily for the height, the 65532 should have become 476
>       (480 - 4 or 480 + 65532 within 16 bits).
> ...
>       Probably Be easier to update the manpage and remove the
>       reference to relative offsets - it's obviously not a heavily
>       used feature ;)

Well, your message gave me an idea of where to potentially "attack"
the problem.  As far as I can see from black_border() in denoise.c,
the uint16't are promoted back to int before they get used.  So
black_border() doesn't appear to rely on the w/h variables being
constrained to a uint16.  So I made up this little patch to turn on
the relative settings for the height and width argument of -b to
yuvdenoise.

See what you think of my solution.  Unfortunately, it's not against
current cvs, but I've seldom ever had any luck cvs'ing anything out
of sourceforge because the sourceforge instructions are incomplete as
to exactly what parameters to give cvs to pull what stuff out of cvs. 
Primarially the "tags".  There seems to be no easy way to figure out
the "tags" without inside knowlege of what tags exist.

diff -ur mjpegtools-1.6.1.90.orig/yuvdenoise/global.h 
mjpegtools-1.6.1.90/yuvdenoise/global.h
--- mjpegtools-1.6.1.90.orig/yuvdenoise/global.h        Tue Sep 30 18:09:41 2003
+++ mjpegtools-1.6.1.90/yuvdenoise/global.h     Tue Sep 30 18:02:21 2003
@@ -91,8 +91,8 @@
     {
       uint16_t  x;
       uint16_t  y;
-      uint16_t  w;
-      uint16_t  h;      
+      int16_t  w;
+      int16_t  h;      
     } border;
     
   };
diff -ur mjpegtools-1.6.1.90.orig/yuvdenoise/main.c 
mjpegtools-1.6.1.90/yuvdenoise/main.c
--- mjpegtools-1.6.1.90.orig/yuvdenoise/main.c  Tue Sep 30 18:07:48 2003
+++ mjpegtools-1.6.1.90/yuvdenoise/main.c       Tue Sep 30 18:12:13 2003
@@ -153,6 +153,16 @@
       denoiser.border.h        = denoiser.frame.h;
   }
 
+  /* handle relative border height/width offsets. */
+  if ( denoiser.border.w < 0 )
+  {
+      denoiser.border.w = denoiser.frame.w - denoiser.border.x + denoiser.border.w;
+  }
+  if ( denoiser.border.h < 0 )
+  {
+      denoiser.border.h = denoiser.frame.h - denoiser.border.y + denoiser.border.h;
+  }
+
   /* stream is interlaced and shall not be
    * deinterlaced ?
    */ 

Reply via email to