[xiph-commits] r14067 - in trunk/theora/lib: . dec enc

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Oct 30 07:03:57 PDT 2007


Author: xiphmont
Date: 2007-10-30 07:03:57 -0700 (Tue, 30 Oct 2007)
New Revision: 14067

Modified:
   trunk/theora/lib/dec/decode.c
   trunk/theora/lib/dec/state.c
   trunk/theora/lib/enc/dct_decode.c
   trunk/theora/lib/enc/encode.c
   trunk/theora/lib/internal.h
Log:
More debug output, this time for loop filters; not correct yet (doesn't account for borders)



Modified: trunk/theora/lib/dec/decode.c
===================================================================
--- trunk/theora/lib/dec/decode.c	2007-10-30 13:31:44 UTC (rev 14066)
+++ trunk/theora/lib/dec/decode.c	2007-10-30 14:03:57 UTC (rev 14067)
@@ -2256,69 +2256,85 @@
 
 #ifdef _TH_DEBUG_
     {
+      int x,y,i,j,k,xn,yn;
+      int plane;
+      int buf;
 
-      int x,y,i,j,k,l;
-      int w = _dec->state.info.frame_width;
-      int h = _dec->state.info.frame_height;
-
       /* dump fragment DCT components */
-      i=0;
-      for(y=0;y<(h>>3);y++){
-	for(x=0;x<(w>>3);x++,i++){
-	  TH_DEBUG("DCT Y [%d][%d] = {",x,y);
-	  if(!_dec->state.frags[i].coded)
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
-	    for(j=0;j<8;j++){
-	      TH_DEBUG("\n   ");
-	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 _dec->state.frags[i].quant[l],
-			 _dec->state.frags[i].freq[l],
-			 _dec->state.frags[i].time[l]);
-	    }
-	    TH_DEBUG(" }\n");
-	  }
+      for(plane=0;plane<3;plane++){
+	char *plstr;
+	int offset;
+	switch(plane){
+	case 0:
+	  plstr="Y";
+	  xn = _dec->state.info.frame_width>>3;
+	  yn = _dec->state.info.frame_height>>3;
+	  offset = 0; 
+	  break;
+	case 1:
+	  plstr="U";
+	  xn = _dec->state.info.frame_width>>4;
+	  yn = _dec->state.info.frame_height>>4;
+	  offset = xn*yn*4;
+	  break;
+	case 2:
+	  plstr="V";
+	  xn = _dec->state.info.frame_width>>4;
+	  yn = _dec->state.info.frame_height>>4;
+	  offset = xn*yn*5;
+	  break;
 	}
-      }
+	for(y=0;y<yn;y++){
+	  for(x=0;x<xn;x++,i++){
+	    
+	    for(buf=0;buf<3;buf++){
+	      int *ptr;
+	      char *bufn;
+	      
+	      i = offset + y*xn + x;
 
-      for(y=0;y<(h>>4);y++){
-	for(x=0;x<(w>>4);x++,i++){
-	  TH_DEBUG("DCT U [%d][%d] = {",x,y);
-	  if(!_dec->state.frags[i].coded)
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
-	    for(j=0;j<8;j++){
-	      TH_DEBUG("\n   ");
-	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 _dec->state.frags[i].quant[l],
-			 _dec->state.frags[i].freq[l],
-			 _dec->state.frags[i].time[l]);
+	      switch(buf){
+	      case 0:
+		bufn = "coded";
+		ptr = _dec->state.frags[i].quant;
+		break;
+	      case 1:
+		bufn = "coeff";
+		ptr = _dec->state.frags[i].freq;
+		break;
+	      case 2:
+		bufn = "recon";
+		ptr = _dec->state.frags[i].time;
+		break;
+	      }
+	      
+	      
+	      TH_DEBUG("%s %s [%d][%d] = {",bufn,plstr,x,y);
+	      if(!_dec->state.frags[i].coded)
+		TH_DEBUG(" not coded }\n");
+	      else{
+		int l=0;
+		for(j=0;j<8;j++){
+		  TH_DEBUG("\n   ");
+		  for(k=0;k<8;k++,l++){
+		    TH_DEBUG("%d ",
+			     (unsigned int)abs(ptr[l]));
+		  }
+		}
+		TH_DEBUG(" }\n");
+	      }
 	    }
-	    TH_DEBUG(" }\n");
-	  }
-	}
-      }
-
-      for(y=0;y<(h>>4);y++){
-	for(x=0;x<(w>>4);x++,i++){
-	  TH_DEBUG("DCT V [%d][%d] = {",x,y);
-	  if(!_dec->state.frags[i].coded)
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
+	    
+	    /* and the loop filter output, which is a flat struct */
+	    TH_DEBUG("loop %s [%d][%d] = {",plstr,x,y);
 	    for(j=0;j<8;j++){
+	      int l = (y*8+j)*(xn*8) + x*8;
 	      TH_DEBUG("\n   ");
 	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 _dec->state.frags[i].quant[l],
-			 _dec->state.frags[i].freq[l],
-			 _dec->state.frags[i].time[l]);
+		TH_DEBUG("%d ", _dec->state.loop_debug[plane].data[l]);
+	      
 	    }
-	    TH_DEBUG(" }\n");
+	    TH_DEBUG(" }\n\n");
 	  }
 	}
       }

Modified: trunk/theora/lib/dec/state.c
===================================================================
--- trunk/theora/lib/dec/state.c	2007-10-30 13:31:44 UTC (rev 14066)
+++ trunk/theora/lib/dec/state.c	2007-10-30 14:03:57 UTC (rev 14067)
@@ -515,10 +515,35 @@
   _state->ref_frame_idx[OC_FRAME_GOLD]=
    _state->ref_frame_idx[OC_FRAME_PREV]=
    _state->ref_frame_idx[OC_FRAME_SELF]=-1;
+
+#ifdef _TH_DEBUG_
+  _state->loop_debug[0].width = info->frame_width;
+  _state->loop_debug[0].height = info->frame_height;
+  _state->loop_debug[0].ystride = yhstride;
+  _state->loop_debug[0].data = malloc(yplane_sz);
+
+  _state->loop_debug[1].width = 
+    _state->loop_debug[2].width = 
+    info->frame_width>>!(info->pixel_fmt&1);
+  _state->loop_debug[1].height =
+    _state->loop_debug[2].height =
+    info->frame_height>>!(info->pixel_fmt&2);
+  _state->loop_debug[1].ystride = 
+    _state->loop_debug[2].ystride = chstride;
+  _state->loop_debug[1].data = malloc(cplane_sz);
+  _state->loop_debug[2].data = malloc(cplane_sz);
+
+#endif
 }
 
 static void oc_state_ref_bufs_clear(oc_theora_state *_state){
   _ogg_free(_state->ref_frame_data);
+
+#ifdef _TH_DEBUG_
+  _ogg_free(_state->loop_debug[0].data);
+  _ogg_free(_state->loop_debug[1].data);
+  _ogg_free(_state->loop_debug[2].data);
+#endif
 }
 
 
@@ -1058,6 +1083,7 @@
   _bv+=256;
   iplane=_state->ref_frame_bufs[_refi]+_pli;
   fplane=_state->fplanes+_pli;
+
   /*The following loops are constructed somewhat non-intuitively on purpose.
     The main idea is: if a block boundary has at least one coded fragment on
      it, the filter is applied to it.
@@ -1090,6 +1116,16 @@
     }
     frag0+=fplane->nhfrags;
   }
+
+#ifdef _TH_DEBUG_
+  int offset = _fragy0*fplane->nhfrags*8;
+  int len = (_fragy_end-_fragy0)*fplane->nhfrags*8*8;
+  memcpy(_state->loop_debug[_pli].data+offset, 
+	 _state->ref_frame_bufs[_refi][_pli].data+offset,
+	 len);
+#endif
+
+
 }
 
 #if defined(OC_DUMP_IMAGES)

Modified: trunk/theora/lib/enc/dct_decode.c
===================================================================
--- trunk/theora/lib/enc/dct_decode.c	2007-10-30 13:31:44 UTC (rev 14066)
+++ trunk/theora/lib/enc/dct_decode.c	2007-10-30 14:03:57 UTC (rev 14067)
@@ -1205,6 +1205,93 @@
   /* Apply a loop filter to edge pixels of updated blocks */
   LoopFilter(pbi);
 
+#ifdef _TH_DEBUG_
+    {
+      int x,y,i,j,k,xn,yn;
+      int plane;
+      int buf;
+
+      /* dump fragment DCT components */
+      for(plane=0;plane<3;plane++){
+	char *plstr;
+	int offset;
+	switch(plane){
+	case 0:
+	  plstr="Y";
+	  xn = pbi->HFragments;
+	  yn = pbi->VFragments;
+	  offset = 0; 
+	  break;
+	case 1:
+	  plstr="U";
+	  xn = pbi->HFragments>>1;
+	  yn = pbi->VFragments>>1;
+	  offset = pbi->VFragments * pbi->HFragments;
+	  break;
+	case 2:
+	  plstr="V";
+	  xn = pbi->HFragments>>1;
+	  yn = pbi->VFragments>>1;
+	  offset = pbi->VFragments * pbi->HFragments + 
+	    ((pbi->VFragments * pbi->HFragments) >> 2);
+	  break;
+	}
+	for(y=0;y<yn;y++){
+	  for(x=0;x<xn;x++,i++){
+	    
+	    for(buf=0;buf<3;buf++){
+	      Q_LIST_ENTRY (*ptr)[64];
+	      char *bufn;
+	      
+	      switch(buf){
+	      case 0:
+		bufn = "coded";
+		ptr = pbi->QFragQUAN;
+		break;
+	      case 1:
+		bufn = "coeff";
+		ptr = pbi->QFragFREQ;
+		break;
+	      case 2:
+		bufn = "recon";
+		ptr = pbi->QFragTIME;
+		break;
+	      }
+	      
+	      i = offset + y*xn + x;
+	      
+	      TH_DEBUG("%s %s [%d][%d] = {",bufn,plstr,x,y);
+	      if ( !pbi->display_fragments[i] ) 
+		TH_DEBUG(" not coded }\n");
+	      else{
+		int l=0;
+		for(j=0;j<8;j++){
+		  TH_DEBUG("\n   ");
+		  for(k=0;k<8;k++,l++){
+		    TH_DEBUG("%d ",
+			     (unsigned int)abs(ptr[i][l]));
+		  }
+		}
+		TH_DEBUG(" }\n");
+	      }
+	    }
+	    
+	    /* and the loop filter output, which is a flat struct */
+	    TH_DEBUG("loop %s [%d][%d] = {",plstr,x,y);
+	    for(j=0;j<8;j++){
+	      int l = (y*8+j)*(xn*8) + x*8 + offset*64;
+	      TH_DEBUG("\n   ");
+	      for(k=0;k<8;k++,l++)
+		TH_DEBUG("%d ", pbi->LastFrameRecon[l]);
+	      
+	    }
+	    TH_DEBUG(" }\n\n");
+	  }
+	}
+      }
+    }
+#endif
+
   /* We may need to update the UMV border */
   UpdateUMVBorder(pbi, pbi->LastFrameRecon);
 

Modified: trunk/theora/lib/enc/encode.c
===================================================================
--- trunk/theora/lib/enc/encode.c	2007-10-30 13:31:44 UTC (rev 14066)
+++ trunk/theora/lib/enc/encode.c	2007-10-30 14:03:57 UTC (rev 14067)
@@ -933,74 +933,6 @@
   /* Reconstruct the reference frames */
   ReconRefFrames(&cpi->pb);
 
-#ifdef _TH_DEBUG_
-    {
-      int x,y,i,j,k,l;
-
-      /* dump fragment DCT components */
-      i=0;
-      for(y=0;y<cpi->pb.VFragments;y++){
-	for(x=0;x<cpi->pb.HFragments;x++,i++){
-	  TH_DEBUG("DCT Y [%d][%d] = {",x,y);
-	  if ( !cpi->pb.display_fragments[i] ) 
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
-	    for(j=0;j<8;j++){
-	      TH_DEBUG("\n   ");
-	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 cpi->pb.QFragQUAN[i][l],
-			 cpi->pb.QFragFREQ[i][l],
-			 cpi->pb.QFragTIME[i][l]);
-	    }
-	    TH_DEBUG(" }\n");
-	  }
-	}
-      }
-
-      for(y=0;y<(cpi->pb.VFragments>>1);y++){
-	for(x=0;x<(cpi->pb.HFragments>>1);x++,i++){
-	  TH_DEBUG("DCT U [%d][%d] = {",x,y);
-	  if ( !cpi->pb.display_fragments[i] ) 
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
-	    for(j=0;j<8;j++){
-	      TH_DEBUG("\n   ");
-	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 cpi->pb.QFragQUAN[i][l],
-			 cpi->pb.QFragFREQ[i][l],
-			 cpi->pb.QFragTIME[i][l]);
-	    }
-	    TH_DEBUG(" }\n");
-	  }
-	}
-      }
-
-      for(y=0;y<(cpi->pb.VFragments>>1);y++){
-	for(x=0;x<(cpi->pb.HFragments>>1);x++,i++){
-	  TH_DEBUG("DCT V [%d][%d] = {",x,y);
-	  if ( !cpi->pb.display_fragments[i] ) 
-	    TH_DEBUG(" not coded }\n");
-	  else{
-	    l=0;
-	    for(j=0;j<8;j++){
-	      TH_DEBUG("\n   ");
-	      for(k=0;k<8;k++,l++)
-		TH_DEBUG("%d:%d:%d ",
-			 cpi->pb.QFragQUAN[i][l],
-			 cpi->pb.QFragFREQ[i][l],
-			 cpi->pb.QFragTIME[i][l]);
-	    }
-	    TH_DEBUG(" }\n");
-	  }
-	}
-      }
-    }
-#endif
-
   UpdateFragQIndex(&cpi->pb);
 
   /* Measure the inter reconstruction error for all the blocks that

Modified: trunk/theora/lib/internal.h
===================================================================
--- trunk/theora/lib/internal.h	2007-10-30 13:31:44 UTC (rev 14066)
+++ trunk/theora/lib/internal.h	2007-10-30 14:03:57 UTC (rev 14067)
@@ -16,6 +16,7 @@
  ********************************************************************/
 
 
+
 #if !defined(_internal_H)
 # define _internal_H (1)
 # include <stdlib.h>
@@ -361,6 +362,10 @@
   oc_quant_tables       dequant_table_data[2][3];
   /*Loop filter strength parameters.*/
   unsigned char         loop_filter_limits[64];
+
+#ifdef _TH_DEBUG_
+  th_ycbcr_buffer       loop_debug;
+#endif
 };
 
 



More information about the commits mailing list