[xiph-commits] r17166 - branches/theora-gumboot/lib
gumboot at svn.xiph.org
gumboot at svn.xiph.org
Fri Apr 23 11:16:54 PDT 2010
Author: gumboot
Date: 2010-04-23 11:16:54 -0700 (Fri, 23 Apr 2010)
New Revision: 17166
Modified:
branches/theora-gumboot/lib/decode.c
branches/theora-gumboot/lib/internal.h
branches/theora-gumboot/lib/state.c
Log:
Set up the per-superblock bitmap of coded blocks, and use it to reduce the damage done so far.
Modified: branches/theora-gumboot/lib/decode.c
===================================================================
--- branches/theora-gumboot/lib/decode.c 2010-04-23 16:25:21 UTC (rev 17165)
+++ branches/theora-gumboot/lib/decode.c 2010-04-23 18:16:54 UTC (rev 17166)
@@ -480,6 +480,7 @@
static void oc_dec_mark_all_intra(oc_dec_ctx *_dec){
const oc_sb_map *sb_maps;
oc_sb_flags *sb_flags;
+ ogg_uint16_t *sb_masks;
oc_fragment *frags;
ptrdiff_t *coded_fragis;
ptrdiff_t ncoded_fragis;
@@ -491,14 +492,17 @@
prev_ncoded_fragis=ncoded_fragis=0;
sb_maps=(const oc_sb_map *)_dec->state.sb_maps;
sb_flags=_dec->state.sb_flags;
+ sb_masks=_dec->state.sb_masks;
frags=_dec->state.frags;
sbi=nsbs=0;
for(pli=0;pli<3;pli++){
nsbs+=_dec->state.fplanes[pli].nsbs;
for(;sbi<nsbs;sbi++){
int quadi;
+ ogg_uint16_t bmask;
sb_flags[sbi].coded_fully=1;
sb_flags[sbi].coded_partially=0;
+ bmask=0;
for(quadi=0;quadi<4;quadi++)if(sb_flags[sbi].quad_valid&1<<quadi){
int bi;
for(bi=0;bi<4;bi++){
@@ -508,9 +512,11 @@
frags[fragi].coded=1;
frags[fragi].mb_mode=OC_MODE_INTRA;
coded_fragis[ncoded_fragis++]=fragi;
+ bmask|=1<<(quadi<<2|bi);
}
}
}
+ sb_masks[sbi]=bmask;
}
_dec->state.ncoded_fragis[pli]=ncoded_fragis-prev_ncoded_fragis;
prev_ncoded_fragis=ncoded_fragis;
@@ -597,6 +603,7 @@
static void oc_dec_coded_flags_unpack(oc_dec_ctx *_dec){
const oc_sb_map *sb_maps;
const oc_sb_flags *sb_flags;
+ ogg_uint16_t *sb_masks;
oc_fragment *frags;
unsigned nsbs;
unsigned sbi;
@@ -619,6 +626,7 @@
else flag=0;
sb_maps=(const oc_sb_map *)_dec->state.sb_maps;
sb_flags=_dec->state.sb_flags;
+ sb_masks=_dec->state.sb_masks;
frags=_dec->state.frags;
sbi=nsbs=run_count=0;
coded_fragis=_dec->state.coded_fragis;
@@ -627,7 +635,9 @@
for(pli=0;pli<3;pli++){
nsbs+=_dec->state.fplanes[pli].nsbs;
for(;sbi<nsbs;sbi++){
+ ogg_uint16_t bmask;
int quadi;
+ bmask=0;
for(quadi=0;quadi<4;quadi++)if(sb_flags[sbi].quad_valid&1<<quadi){
int bi;
for(bi=0;bi<4;bi++){
@@ -648,9 +658,11 @@
if(coded)coded_fragis[ncoded_fragis++]=fragi;
else *(uncoded_fragis-++nuncoded_fragis)=fragi;
frags[fragi].coded=coded;
+ bmask|=coded<<(quadi<<2|bi);
}
}
}
+ sb_masks[sbi]=bmask;
}
_dec->state.ncoded_fragis[pli]=ncoded_fragis-prev_ncoded_fragis;
prev_ncoded_fragis=ncoded_fragis;
@@ -1574,61 +1586,51 @@
counts.*/
static void oc_dec_frags_recon_mcu_plane(oc_dec_ctx *_dec,
oc_dec_pipeline_state *_pipe,int _pli){
+ oc_fragment *frags;
+ ogg_uint16_t *sb_masks;
int sbi, sb_end;
- int nhfrags;
- nhfrags = _dec->state.fplanes[_pli].nhfrags;
+ sb_masks = _dec->state.sb_masks;
+ frags=_dec->state.frags;
sbi = _dec->state.fplanes[_pli].sboffset + (_pipe->fragy0[_pli] >> 2) * _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++)
{
+ ptrdiff_t *fragip;
+ ogg_uint16_t bmask;
int quadi;
- oc_sb_flags sb_flags = _dec->state.sb_flags[sbi];
- if (sb_flags.coded_fully == 0 && sb_flags.coded_partially == 0)
- continue;
+ bmask = sb_masks[sbi];
+ if (bmask == 0) continue;
- /* at this point I would like to pull a bitmap of coded blocks in the
- * current superblock, and all the subsequent conditional stuff would be
- * against that one uint16_t, but we don't have it yet. */
+ fragip = _dec->state.sb_maps[sbi][0];
- for (quadi = 0; quadi < 4; quadi++)
+ for (quadi = 0; quadi < 16; quadi += 4, bmask >>= 4, fragip += 4)
{
- int last_zzi[4] = { -1 };
/*This array is made one element larger because the zig-zag index array
uses the final element as a dumping ground for out-of-range indices
to protect us from buffer overflow.*/
OC_ALIGN8(ogg_int16_t dct_coeffs[4][64 + 8]);
int bi;
- if ((sb_flags.quad_valid & 1 << quadi) == 0)
+ if ((bmask & 15) == 0)
continue;
for (bi = 0; bi < 4; bi++)
{
ptrdiff_t fragi;
- fragi=_dec->state.sb_maps[sbi][quadi][bi];
- if (fragi < 0) continue;
- if (_dec->state.frags[fragi].coded == 0) continue;
+ int last_zzi;
+ if ((bmask & (1 << bi)) == 0) continue;
+ fragi = fragip[bi];
+ assert(fragi >= 0 && frags[fragi].coded);
- last_zzi[bi] = oc_dec_get_dct_coeffs(dct_coeffs[bi], _dec, _pipe, _pli, _dec->state.frags + fragi);
+ last_zzi = oc_dec_get_dct_coeffs(dct_coeffs[bi], _dec, _pipe, _pli, frags + fragi);
+ 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[bi],last_zzi,dc_quant);
}
-
- for (bi = 0; bi < 4; bi++)
- {
- ogg_uint16_t dc_quant;
- ptrdiff_t fragi;
- fragi=_dec->state.sb_maps[sbi][quadi][bi];
- if (fragi < 0) continue;
- if (_dec->state.frags[fragi].coded == 0) continue;
-
- dc_quant = _pipe->dequant[_pli][0][_dec->state.frags[fragi].mb_mode!=OC_MODE_INTRA][0];
- oc_state_frag_recon(&_dec->state,fragi,_pli, dct_coeffs[bi],last_zzi[bi],dc_quant);
- }
}
-
}
/*Right now the reconstructed MCU has only the coded blocks in it.*/
Modified: branches/theora-gumboot/lib/internal.h
===================================================================
--- branches/theora-gumboot/lib/internal.h 2010-04-23 16:25:21 UTC (rev 17165)
+++ branches/theora-gumboot/lib/internal.h 2010-04-23 18:16:54 UTC (rev 17166)
@@ -325,6 +325,8 @@
oc_sb_map *sb_maps;
/*The list of super block flags, indexed in image order.*/
oc_sb_flags *sb_flags;
+ /*The list of super block block masks, indexed in image order.*/
+ ogg_uint16_t *sb_masks;
/*The total number of super blocks in a single frame.*/
unsigned nsbs;
/*The fragments from each color plane that belong to each macro block.
Modified: branches/theora-gumboot/lib/state.c
===================================================================
--- branches/theora-gumboot/lib/state.c 2010-04-23 16:25:21 UTC (rev 17165)
+++ branches/theora-gumboot/lib/state.c 2010-04-23 18:16:54 UTC (rev 17166)
@@ -426,6 +426,7 @@
_state->nsbs=nsbs;
_state->sb_maps=_ogg_malloc(nsbs*sizeof(*_state->sb_maps));
_state->sb_flags=_ogg_calloc(nsbs,sizeof(*_state->sb_flags));
+ _state->sb_masks=_ogg_calloc(nsbs,sizeof(*_state->sb_masks));
_state->nhmbs=yhsbs<<1;
_state->nvmbs=yvsbs<<1;
_state->nmbs=nmbs;
@@ -433,8 +434,8 @@
_state->mb_modes=_ogg_calloc(nmbs,sizeof(*_state->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->mb_maps==NULL||_state->mb_modes==NULL||
- _state->coded_fragis==NULL){
+ _state->sb_flags==NULL||_state->sb_masks==NULL||_state->mb_maps==NULL||
+ _state->mb_modes==NULL||_state->coded_fragis==NULL){
return TH_EFAULT;
}
/*Create the mapping from super blocks to fragments.*/
@@ -457,6 +458,7 @@
_ogg_free(_state->coded_fragis);
_ogg_free(_state->mb_modes);
_ogg_free(_state->mb_maps);
+ _ogg_free(_state->sb_masks);
_ogg_free(_state->sb_flags);
_ogg_free(_state->sb_maps);
_ogg_free(_state->frag_mvs);
More information about the commits
mailing list