[xiph-commits] r17255 - branches/theora-gumboot/lib

gumboot at svn.xiph.org gumboot at svn.xiph.org
Sat May 29 07:53:16 PDT 2010


Author: gumboot
Date: 2010-05-29 07:53:16 -0700 (Sat, 29 May 2010)
New Revision: 17255

Modified:
   branches/theora-gumboot/lib/decode.c
   branches/theora-gumboot/lib/internal.h
   branches/theora-gumboot/lib/state.c
Log:
Finally start going back the other way -- oc_dec_mb_modes_unpack() becomes simpler.


Modified: branches/theora-gumboot/lib/decode.c
===================================================================
--- branches/theora-gumboot/lib/decode.c	2010-05-29 12:52:40 UTC (rev 17254)
+++ branches/theora-gumboot/lib/decode.c	2010-05-29 14:53:16 UTC (rev 17255)
@@ -27,6 +27,7 @@
 # include <cairo.h>
 #endif
 
+#include <assert.h>
 
 /*No post-processing.*/
 #define OC_PP_LEVEL_DISABLED  (0)
@@ -698,16 +699,18 @@
 
 /*Unpacks the list of macro block modes for INTER frames.*/
 static void oc_dec_mb_modes_unpack(oc_dec_ctx *_dec){
-  const oc_mb_map     *mb_maps;
-  signed char         *mb_modes;
-  const oc_fragment   *frags;
   const unsigned char *alphabet;
   unsigned char        scheme0_alphabet[8];
   const ogg_int16_t   *mode_tree;
-  size_t               nmbs;
   size_t               mbi;
+  size_t               nhsbs;
+  size_t               nhmbs;
   long                 val;
   int                  mode_scheme;
+  ogg_uint16_t        *sb_masks;
+  signed char         *rmb_modes[4];
+  signed char         *mb_modes;
+  int                  sbx,sby;
   val=oc_pack_read(&_dec->opb,3);
   mode_scheme=(int)val;
   if(mode_scheme==0){
@@ -726,23 +729,25 @@
   }
   else alphabet=OC_MODE_ALPHABETS[mode_scheme-1];
   mode_tree=mode_scheme==7?OC_CLC_MODE_TREE:OC_VLC_MODE_TREE;
+  sb_masks=_dec->state.sb_masks;
+  nhsbs=_dec->state.fplanes[0].nhsbs;
+  nhmbs=_dec->state.nhmbs;
+  rmb_modes[0]=_dec->state.raster_mb_modes;
+  rmb_modes[1]=rmb_modes[0]+nhmbs;
+  rmb_modes[2]=rmb_modes[1]+1;
+  rmb_modes[3]=rmb_modes[0]+1;
   mb_modes=_dec->state.mb_modes;
-  mb_maps=(const oc_mb_map *)_dec->state.mb_maps;
-  nmbs=_dec->state.nmbs;
-  frags=_dec->state.frags;
-  for(mbi=0;mbi<nmbs;mbi++){
-    if(mb_modes[mbi]!=OC_MODE_INVALID){
-      int bi;
-      /*Check for a coded luma block in this macro block.*/
-      for(bi=0;bi<4&&!frags[mb_maps[mbi][0][bi]].coded;bi++);
-      /*We found one, decode a mode.*/
-      if(bi<4){
-        mb_modes[mbi]=alphabet[oc_huff_token_decode(&_dec->opb,mode_tree)];
+  for (mbi=sby=0;sby<_dec->state.fplanes[0].nsbs;sby+=nhsbs,mbi+=nhmbs)
+    for (sbx=0;sbx<nhsbs;sbx++,mbi+=2){
+      int i,mask=sb_masks[sby+sbx];
+      for (i=0;i<4;i++,mask>>=4){
+        if (rmb_modes[i][mbi]!=OC_MODE_INVALID)
+          rmb_modes[i][mbi]=(mask&15)
+           ?alphabet[oc_huff_token_decode(&_dec->opb,mode_tree)]
+           :OC_MODE_INTER_NOMV;
+        *mb_modes++=rmb_modes[i][mbi];/*legacy*/
       }
-      /*There were none: INTER_NOMV is forced.*/
-      else mb_modes[mbi]=OC_MODE_INTER_NOMV;
     }
-  }
 }
 
 
@@ -1527,8 +1532,6 @@
    (fragy_end-fragy0)*(ptrdiff_t)nhfrags-ncoded_fragis;
 }
 
-#include <stdio.h>
-#include <assert.h>
 static int oc_dec_get_dct_coeffs(ogg_int16_t dct_coeffs[65],
  oc_dec_ctx *_dec,oc_dec_pipeline_state *_pipe,int _pli, const oc_fragment *_fragp){
   unsigned char       *dct_tokens;
@@ -1609,20 +1612,41 @@
  oc_dec_pipeline_state *_pipe,int _pli){
   oc_fragment             *frags;
   ogg_uint16_t            *sb_masks;
-  int sbi, sb_end;
+  int                      mbi,
+                           mb_stepx,
+                           mb_stepy;
+  int                      sbi,
+                           sb_end,
+                           sb_newline;
+  int                      pixel_fmt;
+  int                      mbo[4]={0,_dec->state.nhmbs,_dec->state.nhmbs+1,1};
 
   sb_masks = _dec->state.sb_masks;
   frags=_dec->state.frags;
 
+  pixel_fmt=_pli?TH_PF_NFORMATS/*_dec->state.info.pixel_fmt*/:TH_PF_444;
+
   sbi = _dec->state.fplanes[_pli].sboffset + (_pipe->fragy0[_pli] >> 2) * _dec->state.fplanes[_pli].nhsbs;
+  sb_newline=sbi+_dec->state.fplanes[_pli].nhsbs;
   sb_end = _dec->state.fplanes[_pli].sboffset + (_pipe->fragy_end[_pli] + 3 >> 2) * _dec->state.fplanes[_pli].nhsbs;
 
-  for ( ; sbi < sb_end; sbi++)
+  mb_stepx=!(pixel_fmt&2)?1:2;
+  mb_stepy=!(pixel_fmt&1)?1:2;
+
+  mbi=(_pipe->fragy0[_pli]>>mb_stepy-1)*_dec->state.nhmbs;
+
+  for ( ; sbi < sb_end; sbi++,mbi+=1<<3-mb_stepx)
   {
     ptrdiff_t *fragip;
     ogg_uint16_t bmask;
     int quadi;
 
+    if(sbi>=sb_newline){
+      mbi-=_dec->state.nhmbs;
+      mbi+=_dec->state.nhmbs<<3-mb_stepy;
+      sb_newline+=_dec->state.fplanes[_pli].nhsbs;
+    }
+
     bmask = sb_masks[sbi];
     if (bmask == 0) continue;
 
@@ -1639,8 +1663,8 @@
       if ((bmask & 15) == 0)
         continue;
 
-      if (_pli == 0) /* or if the mode and subblocks and quantisation are compatible */
-      {
+      switch (pixel_fmt){
+      case TH_PF_444:{
         static const char rasterise[16] =
         {
           0, 1, 3, 2,
@@ -1669,12 +1693,16 @@
           mask |= 1 << obi;
           mv = &_dec->state.frag_mvs[fragi]; /* this just captures any valid pointer for the moment */
         }
+
+        assert(_dec->state.frame_type==OC_INTRA_FRAME||mb_mode==_dec->state.raster_mb_modes[mbi+mbo[quadi>>2]]);
         if (mb_mode==OC_MODE_INTER_MV_FOUR)
           oc_state_4mv_recon(&_dec->state,frag_buf_off,_pli,dct_coeffs,last_zzi,dc_quant,mask,&_dec->state.frag_mvs[fragip[quadi==12?2:0]]);
-        else
+        else{
+//        assert(mv[0]==_dec->state.raster_mvs[mbi][0][0]&&mv[1]==_dec->state.raster_mvs[mbi][0][1]);
           oc_state_quad_recon(&_dec->state,frag_buf_off,_pli,dct_coeffs,last_zzi,dc_quant,mask,OC_FRAME_FOR_MODE(mb_mode),*mv);
-      }
-      else
+        }
+      }break;
+      default:
         for (bi = 0; bi < 4; bi++)
         {
           ptrdiff_t fragi;
@@ -1687,6 +1715,7 @@
           ogg_uint16_t dc_quant = _pipe->dequant[_pli][0][frags[fragi].mb_mode!=OC_MODE_INTRA][0];
           oc_state_frag_recon(&_dec->state,fragi,_pli, dct_coeffs[0],last_zzi,dc_quant);
         }
+      }
     }
   }
 

Modified: branches/theora-gumboot/lib/internal.h
===================================================================
--- branches/theora-gumboot/lib/internal.h	2010-05-29 12:52:40 UTC (rev 17254)
+++ branches/theora-gumboot/lib/internal.h	2010-05-29 14:53:16 UTC (rev 17255)
@@ -344,6 +344,10 @@
     A negative number indicates the macro block lies entirely outside the
      coded frame.*/
   signed char        *mb_modes;
+
+  signed char        *raster_mb_modes;
+  oc_mv             (*raster_mb_mvs)[4];
+
   /*The number of macro blocks in the X direction.*/
   unsigned            nhmbs;
   /*The number of macro blocks in the Y direction.*/

Modified: branches/theora-gumboot/lib/state.c
===================================================================
--- branches/theora-gumboot/lib/state.c	2010-05-29 12:52:40 UTC (rev 17254)
+++ branches/theora-gumboot/lib/state.c	2010-05-29 14:53:16 UTC (rev 17255)
@@ -226,6 +226,8 @@
   oc_mb_fill_cmapping_func  mb_fill_cmapping;
   unsigned                  sbi;
   int                       y;
+  int                       nhmbs;
+  nhmbs=_fplanes[0].nhsbs<<1;
   mb_fill_cmapping=OC_MB_FILL_CMAPPING_TABLE[_pixel_fmt];
   /*Loop through the luma plane super blocks.*/
   for(sbi=y=0;y<_fplanes[0].nvfrags;y+=4){
@@ -246,7 +248,7 @@
           memset(_mb_maps[mbi],0xFF,sizeof(_mb_maps[mbi]));
           /*Make sure this macro block is within the encoded region.*/
           if(mbx>=_fplanes[0].nhfrags||mby>=_fplanes[0].nvfrags){
-            _mb_modes[mbi]=OC_MODE_INVALID;
+            _mb_modes[(mby>>1)*nhmbs+(mbx>>1)]=OC_MODE_INVALID;
             continue;
           }
           /*Fill in the fragment indices for the luma plane.*/
@@ -432,10 +434,13 @@
   _state->nmbs=nmbs;
   _state->mb_maps=_ogg_calloc(nmbs,sizeof(*_state->mb_maps));
   _state->mb_modes=_ogg_calloc(nmbs,sizeof(*_state->mb_modes));
+  _state->raster_mb_modes=_ogg_calloc(nmbs,sizeof(*_state->raster_mb_modes));
+  _state->raster_mb_mvs=_ogg_calloc(nmbs,sizeof(*_state->raster_mb_modes));
   _state->coded_fragis=_ogg_malloc(nfrags*sizeof(*_state->coded_fragis));
   if(_state->frags==NULL||_state->frag_mvs==NULL||_state->sb_maps==NULL||
    _state->sb_flags==NULL||_state->sb_masks==NULL||_state->mb_maps==NULL||
-   _state->mb_modes==NULL||_state->coded_fragis==NULL){
+   _state->mb_modes==NULL||_state->coded_fragis==NULL
+   ||_state->raster_mb_modes==NULL||_state->raster_mb_mvs==NULL){
     return TH_EFAULT;
   }
   /*Create the mapping from super blocks to fragments.*/
@@ -447,7 +452,7 @@
      fplane->nhfrags,fplane->nvfrags);
   }
   /*Create the mapping from macro blocks to fragments.*/
-  oc_mb_create_mapping(_state->mb_maps,_state->mb_modes,
+  oc_mb_create_mapping(_state->mb_maps,_state->raster_mb_modes,
    _state->fplanes,_state->info.pixel_fmt);
   /*Initialize the invalid and borderi fields of each fragment.*/
   oc_state_border_init(_state);
@@ -455,6 +460,8 @@
 }
 
 static void oc_state_frarray_clear(oc_theora_state *_state){
+  _ogg_free(_state->raster_mb_mvs);
+  _ogg_free(_state->raster_mb_modes);
   _ogg_free(_state->coded_fragis);
   _ogg_free(_state->mb_modes);
   _ogg_free(_state->mb_maps);



More information about the commits mailing list