void apply_deblocking_filter(de265_image* img) // decoder_context* ctx)
{
  decoder_context* ctx = img->decctx;

  char enabled_deblocking = derive_edgeFlags(img);

  if (enabled_deblocking)
    {
      // vertical filtering

      logtrace(LogDeblock,"VERTICAL\n");
      derive_boundaryStrength(img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
      edge_filtering_luma    (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());

      if (img->get_sps().ChromaArrayType != CHROMA_MONO) {
        edge_filtering_chroma  (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
      }
#if 0
      char buf[1000];
      sprintf(buf,"lf-after-V-%05d.yuv", ctx->img->PicOrderCntVal);
      write_picture_to_file(ctx->img, buf);
#endif

      // horizontal filtering

      logtrace(LogDeblock,"HORIZONTAL\n");
      derive_boundaryStrength(img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
      edge_filtering_luma    (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());

      if (img->get_sps().ChromaArrayType != CHROMA_MONO) {
        edge_filtering_chroma  (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
      }

#if 0
      sprintf(buf,"lf-after-H-%05d.yuv", ctx->img->PicOrderCntVal);
      write_picture_to_file(ctx->img, buf);
#endif
    }
}
void apply_deblocking_filter(de265_image* img)  
{
  decoder_context* ctx = img->decctx;

  char enabled_deblocking = derive_edgeFlags(img);

  if (enabled_deblocking)
    {
       

      logtrace(LogDeblock,"VERTICAL\n");
      derive_boundaryStrength(img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
      edge_filtering_luma    (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());

      if (img->get_sps().ChromaArrayType != CHROMA_MONO) {
        edge_filtering_chroma  (img, true ,0,img->get_deblk_height(),0,img->get_deblk_width());
      }
#if 0
      char buf[1000];
      sprintf(buf,"lf-after-V-%05d.yuv", ctx->img->PicOrderCntVal);
      write_picture_to_file(ctx->img, buf);
#endif

       

      logtrace(LogDeblock,"HORIZONTAL\n");
      derive_boundaryStrength(img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
      edge_filtering_luma    (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());

      if (img->get_sps().ChromaArrayType != CHROMA_MONO) {
        edge_filtering_chroma  (img, false ,0,img->get_deblk_height(),0,img->get_deblk_width());
      }

#if 0
      sprintf(buf,"lf-after-H-%05d.yuv", ctx->img->PicOrderCntVal);
      write_picture_to_file(ctx->img, buf);
#endif
    }
}