diff --git a/libavfilter/vf_stretch4to3.c b/libavfilter/vf_stretch4to3.c
index 8fb72a3..c54c281 100644
--- a/libavfilter/vf_stretch4to3.c
+++ b/libavfilter/vf_stretch4to3.c
@@ -24,6 +24,8 @@
  * Stretch or squeeze video to four thirds the width
  */
 
+/* #define DEBUG */
+
 #include "avfilter.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
@@ -68,10 +70,6 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-//    STRETCHContext *priv_ctx = ctx->priv;
-
-//    av_log(ctx, AV_LOG_INFO, "query_formats\n");
-
     const enum PixelFormat pix_fmts[] = {
             PIX_FMT_YUV422P,
             PIX_FMT_YUV444P,
@@ -81,6 +79,10 @@
             PIX_FMT_YUVJ422P,
             PIX_FMT_YUVJ444P,
             PIX_FMT_NONE };
+
+#ifdef DEBUG
+    av_dlog(ctx, "query_formats()\n");
+#endif
 
     avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
 
@@ -171,8 +173,9 @@
     STRETCHContext *priv_ctx = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
 
-//    av_log(ctx, AV_LOG_INFO, "start_frame\n");
-
+#ifdef DEBUG
+    av_dlog(ctx, "start_frame()\n");
+#endif
     outlink->out_buf = avfilter_get_video_buffer(
             outlink,
             AV_PERM_WRITE,
@@ -183,7 +186,7 @@
     outlink->out_buf->video->h = priv_ctx->h;
     outlink->out_buf->video->sample_aspect_ratio = priv_ctx->sar;
 
-    avfilter_start_frame(outlink, outlink->out_buf);
+    avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
 }
 
 static void draw_slice_stretch(AVFilterLink *inlink, int slice_y, int slice_h, int slice_dir)
@@ -206,17 +209,21 @@
     int coef_tap, coef_phase; ///< coefficient column and row
     int32_t accumulator;      ///< accumulator for current pixel calculation
 
-//    av_log(ctx, AV_LOG_INFO, "draw_slice_stretch\n");
+#ifdef DEBUG
+    av_dlog(ctx, "draw_slice_stretch()\n");
+#endif
 
     for (plane = 0; plane < 4 && inpicref->data[plane] && outpicref->data[plane]; plane++) {
         plane_y_sub = (plane == 1 || plane == 2) ? priv_ctx->chroma_h_sub : 0;
-//        av_log(ctx, AV_LOG_INFO, "slice_h >> plane_y_sub:%d\n",slice_h >> plane_y_sub);
+#ifdef DEBUG
+        av_dlog(ctx, "plane: %d slice_h >> plane_y_sub:%d\n",plane, slice_h >> plane_y_sub);
+#endif
         for (slice_delta_y = 0; slice_delta_y < (slice_h >> plane_y_sub); slice_delta_y++) {
             input_y = (slice_y >> plane_y_sub) + slice_delta_y;
             input_pixel_pointer = input_line_start = inpicref->data[plane] + input_y * inpicref->linesize[plane];
             input_line_end = input_line_start + inpicref->linesize[plane];
             output_pixel_pointer = output_line_start = outpicref->data[plane] + input_y * outpicref->linesize[plane];
-            // walk along the input line is groups of 'stretch_down' pixels
+            // walk along the input line in groups of 'stretch_down' pixels
             // walk along the output line in groups of 'stretch_up' pixels
             // one set of coefficients said 'just copy the original pixel'
             // so output pixel 1 from the group of 4 is a direct copy
@@ -296,18 +303,22 @@
     int coef_tap, coef_phase; ///< coefficient column and row
     int32_t accumulator;      ///< accumulator for current pixel calculation
 
-//    av_log(ctx, AV_LOG_INFO, "draw_slice_squeeze\n");
+#ifdef DEBUG
+    av_dlog(ctx, "draw_slice_squeeze()\n");
+#endif
 
     for (plane = 0; plane < 4 && inpicref->data[plane] && outpicref->data[plane]; plane++) {
         plane_y_sub = (plane == 1 || plane == 2) ? priv_ctx->chroma_h_sub : 0;
-//        av_log(ctx, AV_LOG_INFO, "slice_h >> plane_y_sub:%d\n",slice_h >> plane_y_sub);
+#ifdef DEBUG
+        av_dlog(ctx, "plane: %d slice_h >> plane_y_sub:%d\n",plane, slice_h >> plane_y_sub);
+#endif
         for (slice_delta_y = 0; slice_delta_y < (slice_h >> plane_y_sub); slice_delta_y++) {
             input_y = (slice_y >> plane_y_sub) + slice_delta_y;
             input_line_start = inpicref->data[plane] + input_y * inpicref->linesize[plane];
             input_line_end = input_line_start + inpicref->linesize[plane];
             input_pixel_pointer = input_line_start - squeeze_tap_offset;
             output_pixel_pointer = outpicref->data[plane] + input_y * outpicref->linesize[plane];
-            // walk along the input line is groups of 4 pixels
+            // walk along the input line in groups of 4 pixels
             // walk along the output line in groups of 3 pixels
             // calculate the leading edge of the output image
             for (output_x = 0; output_x < 6; output_x += squeeze_up) {
@@ -360,12 +371,14 @@
 
 static void end_frame(AVFilterLink *inlink)
 {
-//    AVFilterContext *ctx = inlink->dst;
+#ifdef DEBUG
+    AVFilterContext *ctx = inlink->dst;
+    av_dlog(ctx, "end_frame()\n");
+#endif
 
-//    av_log(ctx, AV_LOG_INFO, "end_frame\n");
-
-    avfilter_end_frame(inlink->dst->outputs[0]);
     avfilter_unref_buffer(inlink->cur_buf);
+    avfilter_end_frame(inlink->dst->outputs[0]);
+    avfilter_unref_buffer(inlink->dst->outputs[0]->out_buf);
 }
 
 AVFilter avfilter_vf_stretch4to3 = {
@@ -377,7 +390,6 @@
                                             .name             = "default",
                                             .type             = AVMEDIA_TYPE_VIDEO,
                                             .config_props     = config_input_stretch,
-                                            .get_video_buffer = avfilter_null_get_video_buffer,
                                             .start_frame      = start_frame,
                                             .draw_slice       = draw_slice_stretch,
                                             .end_frame        = end_frame,
@@ -400,7 +412,6 @@
                                             .name             = "default",
                                             .type             = AVMEDIA_TYPE_VIDEO,
                                             .config_props     = config_input_squeeze,
-                                            .get_video_buffer = avfilter_null_get_video_buffer,
                                             .start_frame      = start_frame,
                                             .draw_slice       = draw_slice_squeeze,
                                             .end_frame        = end_frame,
