From 877b73ada7fac3204f00b6a7f1418be13b679922 Mon Sep 17 00:00:00 2001 From: xiphmont Date: Tue, 30 Oct 2007 21:34:52 +0000 Subject: [PATCH] More debugging output code (disabled by default) git-svn-id: http://svn.xiph.org/trunk@14070 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- theora/lib/dec/decode.c | 65 +++++++++++++++++++++++++++++---------- theora/lib/dec/state.c | 75 ++++++++++++++++++++++++--------------------- theora/lib/enc/dct_decode.c | 18 +++++------ theora/lib/internal.h | 8 ++--- 4 files changed, 99 insertions(+), 67 deletions(-) diff --git a/theora/lib/dec/decode.c b/theora/lib/dec/decode.c index 7409d86ab..20ed95a14 100644 --- a/theora/lib/dec/decode.c +++ b/theora/lib/dec/decode.c @@ -1664,6 +1664,40 @@ static void oc_dec_frags_recon_mcu_plane(oc_dec_ctx *_dec, _pipe->uncoded_fragis[_pli]-=_pipe->nuncoded_fragis[_pli]; oc_state_frag_copy(&_dec->state,_pipe->uncoded_fragis[_pli], _pipe->nuncoded_fragis[_pli],OC_FRAME_SELF,OC_FRAME_PREV,_pli); + +#ifdef _TH_DEBUG_ + { + int i,j,k; + int framei=_dec->state.ref_frame_idx[OC_FRAME_SELF]; + int ystride=_dec->state.ref_frame_bufs[framei][_pli].ystride; + int *fragi_end = _pipe->coded_fragis[_pli]; + int *fragi = fragi_end-_pipe->ncoded_fragis[_pli]; + + for(;fragistate.frags+*fragi; + unsigned char *src=frag->buffer[framei]; + for(i=0,j=0;j<8;j++){ + for(k=0;k<8;k++,i++) + frag->recon[i] = src[k]; + src+=ystride; + } + } + + fragi = _pipe->uncoded_fragis[_pli]; + fragi_end = fragi+_pipe->nuncoded_fragis[_pli]; + + for(;fragistate.frags+*fragi; + unsigned char *src=frag->buffer[framei]; + for(i=0,j=0;j<8;j++){ + for(k=0;k<8;k++,i++) + frag->recon[i] = src[k]; + src+=ystride; + } + } + } +#endif + } /*Filter a horizontal block edge.*/ @@ -2287,54 +2321,51 @@ int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op, for(y=0;ystate.frags[i].quant; break; case 1: + codecheck=1; bufn = "coeff"; ptr = _dec->state.frags[i].freq; break; case 2: - bufn = "recon"; + codecheck=1; + bufn = "idct"; ptr = _dec->state.frags[i].time; break; + case 3: + bufn = "recon"; + ptr = _dec->state.frags[i].loop; + break; } TH_DEBUG("%s %s [%d][%d] = {",bufn,plstr,x,y); - if(!_dec->state.frags[i].coded) + if(codecheck && !_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("%d ",ptr[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; - TH_DEBUG("\n "); - for(k=0;k<8;k++,l++) - TH_DEBUG("%d ", _dec->state.loop_debug[plane].data[l]); - - } - TH_DEBUG(" }\n\n"); + TH_DEBUG("\n"); } } } diff --git a/theora/lib/dec/state.c b/theora/lib/dec/state.c index 6232db0b9..8f9b37766 100644 --- a/theora/lib/dec/state.c +++ b/theora/lib/dec/state.c @@ -515,35 +515,10 @@ static void oc_state_ref_bufs_init(oc_theora_state *_state){ _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 } @@ -1112,20 +1087,50 @@ void oc_state_loop_filter_frag_rows_c(oc_theora_state *_state,int *_bv, iplane->ystride,_bv); } } + + +#ifdef _TH_DEBUG_ + { + int i,j,k,l; + unsigned char *src; + + for(l=0;l<5;l++){ + oc_fragment *f; + switch(l){ + case 0: + f = frag; + break; + case 1: /* left */ + if(frag == frag0)continue; + f = frag-1; + break; + case 2: /* bottom (top once flipped) */ + if(frag0 == frag_top)continue; + f = frag - fplane->nhfrags; + break; + case 3: /* right */ + if(frag+1 >= frag_end) continue; + f = frag + 1; + break; + case 4: /* top (bottom once flipped) */ + if(frag+fplane->nhfrags >= frag_bot)continue; + f = frag + fplane->nhfrags; + break; + } + + src = f->buffer[_refi]; + for(i=0,j=0;j<8;j++){ + for(k=0;k<8;k++,i++) + f->loop[i] = src[k]; + src+=iplane->ystride; + } + } + } +#endif frag++; } 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) diff --git a/theora/lib/enc/dct_decode.c b/theora/lib/enc/dct_decode.c index af6d17fa6..7d9a6f512 100644 --- a/theora/lib/enc/dct_decode.c +++ b/theora/lib/enc/dct_decode.c @@ -127,7 +127,6 @@ static void ExpandKFBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber ){ /* Get the pixel index for the first pixel in the fragment. */ dsp_recon_intra8x8 (pbi->dsp, (unsigned char *)(&pbi->ThisFrameRecon[ReconPixelIndex]), (ogg_int16_t *)pbi->ReconDataBuffer, ReconPixelsPerLine); - } static void ExpandBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber){ @@ -1207,7 +1206,7 @@ void ReconRefFrames (PB_INSTANCE *pbi){ #ifdef _TH_DEBUG_ { - int x,y,i,j,k,xn,yn; + int x,y,i,j,k,xn,yn,stride; int plane; int buf; @@ -1221,12 +1220,14 @@ void ReconRefFrames (PB_INSTANCE *pbi){ xn = pbi->HFragments; yn = pbi->VFragments; offset = 0; + stride = pbi->YStride; break; case 1: plstr="U"; xn = pbi->HFragments>>1; yn = pbi->VFragments>>1; - offset = pbi->VFragments * pbi->HFragments; + offset = pbi->VFragments * pbi->HFragments; + stride = pbi->UVStride; break; case 2: plstr="V"; @@ -1234,6 +1235,7 @@ void ReconRefFrames (PB_INSTANCE *pbi){ yn = pbi->VFragments>>1; offset = pbi->VFragments * pbi->HFragments + ((pbi->VFragments * pbi->HFragments) >> 2); + stride = pbi->UVStride; break; } for(y=0;yQFragFREQ; break; case 2: - bufn = "recon"; + bufn = "idct"; ptr = pbi->QFragTIME; break; } @@ -1268,8 +1270,7 @@ void ReconRefFrames (PB_INSTANCE *pbi){ 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("%d ",ptr[i][l]); } } TH_DEBUG(" }\n"); @@ -1277,13 +1278,12 @@ void ReconRefFrames (PB_INSTANCE *pbi){ } /* and the loop filter output, which is a flat struct */ - TH_DEBUG("loop %s [%d][%d] = {",plstr,x,y); + TH_DEBUG("recon %s [%d][%d] = {",plstr,x,y); for(j=0;j<8;j++){ - int l = (y*8+j)*(xn*8) + x*8 + offset*64; + int l = pbi->recon_pixel_index_table[i] + j*stride; TH_DEBUG("\n "); for(k=0;k<8;k++,l++) TH_DEBUG("%d ", pbi->LastFrameRecon[l]); - } TH_DEBUG(" }\n\n"); } diff --git a/theora/lib/internal.h b/theora/lib/internal.h index 2d77c0c30..25545968f 100644 --- a/theora/lib/internal.h +++ b/theora/lib/internal.h @@ -15,8 +15,6 @@ ********************************************************************/ - - #if !defined(_internal_H) # define _internal_H (1) # include @@ -240,6 +238,8 @@ typedef struct{ int quant[64]; int freq[64]; int time[64]; + int recon[64]; + int loop[64]; #endif }oc_fragment; @@ -362,10 +362,6 @@ struct oc_theora_state{ 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 }; -- 2.11.4.GIT