]> granicus.if.org Git - handbrake/commitdiff
lapsharp: blank frame buffer stride region
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 18 Jan 2019 22:27:14 +0000 (14:27 -0800)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 20 Jan 2019 17:20:47 +0000 (09:20 -0800)
Zero is not black.  Stride is used in computations and is assumed black.

Fixes https://github.com/HandBrake/HandBrake/issues/1751

libhb/fifo.c
libhb/internal.h
libhb/lapsharp.c

index 6bf6426789cc28cfc44ed426f95ad2fb5dc25c55..b631e46dbb1ce6e66d8edcc0ff3483169e7b7562 100644 (file)
@@ -597,6 +597,34 @@ hb_buffer_t * hb_frame_buffer_init( int pix_fmt, int width, int height )
     return buf;
 }
 
+void hb_frame_buffer_blank_stride(hb_buffer_t * buf)
+{
+    int pp, xx, yy, stride;
+
+    for (pp = 0; pp < 4; pp++)
+    {
+        if (buf->plane[pp].data != NULL)
+        {
+            stride = buf->plane[pp].stride;
+            for (yy = 0; yy < buf->plane[pp].height; yy++)
+            {
+                for (xx = buf->plane[pp].width; xx < stride; xx++)
+                {
+                    *(buf->plane[pp].data + (yy * stride) + xx) = 0x80;
+                }
+            }
+            for (yy = buf->plane[pp].height;
+                 yy < buf->plane[pp].height_stride; yy++)
+            {
+                for (xx = 0; xx < stride; xx++)
+                {
+                    *(buf->plane[pp].data + (yy * stride) + xx) = 0x80;
+                }
+            }
+        }
+    }
+}
+
 // this routine reallocs a buffer for an uncompressed YUV420 video frame
 // with dimensions width x height.
 void hb_video_buffer_realloc( hb_buffer_t * buf, int width, int height )
index cd46c12657edf55cbc28f13c4c1791e7bbf1aed1..1ad82d7f35874af9eb18838dda0b2f8fa5714ff6 100644 (file)
@@ -161,6 +161,7 @@ void hb_buffer_pool_free( void );
 hb_buffer_t * hb_buffer_init( int size );
 hb_buffer_t * hb_buffer_eof_init( void );
 hb_buffer_t * hb_frame_buffer_init( int pix_fmt, int w, int h);
+void          hb_frame_buffer_blank_stride(hb_buffer_t * buf);
 void          hb_buffer_init_planes( hb_buffer_t * b );
 void          hb_buffer_realloc( hb_buffer_t *, int size );
 void          hb_video_buffer_realloc( hb_buffer_t * b, int w, int h );
index eb1c72aeee98d2e48f20bde328e4c6199d6ab42f..29d3122f5c79f83c991e9c1ce276014c845f4899 100644 (file)
@@ -283,6 +283,7 @@ static int hb_lapsharp_work(hb_filter_object_t *filter,
         return HB_FILTER_DONE;
     }
 
+    hb_frame_buffer_blank_stride(in);
     out = hb_frame_buffer_init(in->f.fmt, in->f.width, in->f.height);
 
     int c;