[xiph-commits] r16322 - in branches/theora-gumboot/lib: . dec enc

gumboot at svn.xiph.org gumboot at svn.xiph.org
Wed Jul 22 19:34:32 PDT 2009


Author: gumboot
Date: 2009-07-22 19:34:31 -0700 (Wed, 22 Jul 2009)
New Revision: 16322

Modified:
   branches/theora-gumboot/lib/dec/decode.c
   branches/theora-gumboot/lib/dec/huffdec.c
   branches/theora-gumboot/lib/dec/internal.c
   branches/theora-gumboot/lib/enc/
   branches/theora-gumboot/lib/enc/encode.c
   branches/theora-gumboot/lib/enc/tokenize.c
   branches/theora-gumboot/lib/internal.h
Log:
Remove some inline assembly that wasn't really helping.  extend OC_FZIG_ZAG to 128 elements with lots of safety padding.  Merge the encoder fix from change 16321.  Fix the temporary buffer during Huffman table construction at 511 elements, which I believe to be the correct worst-case.

This revision has a broken encoder, but so does the previous revision so I'm checking this in anyway.



Modified: branches/theora-gumboot/lib/dec/decode.c
===================================================================
--- branches/theora-gumboot/lib/dec/decode.c	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/dec/decode.c	2009-07-23 02:34:31 UTC (rev 16322)
@@ -315,6 +315,10 @@
     }
     _dec->pp_sharp_mod[qi]=-(qsum>>11);
   }
+  /*For each fragment, allocate one byte for every DCT coefficient token, plus
+     one byte for extra-bits for each token, plus one more byte for the long
+     EOB run, just in case it's the very last token and has a run length of
+     one.*/
   _dec->dct_tokens=(unsigned char *)_ogg_malloc((64+64+1)*
    _dec->state.nfrags*sizeof(_dec->dct_tokens[0]));
   memcpy(_dec->state.loop_filter_limits,_setup->qinfo.loop_filter_limits,
@@ -1366,42 +1370,17 @@
   eob_runs=_pipe->eob_runs[_pli];
   for(qti=0;qti<2;qti++)dc_quant[qti]=_pipe->dequant[_pli][0][qti][0];
   for(fragii=0;fragii<ncoded_fragis;fragii++){
-    /*This array is made twice as large as necessary so that an invalid zero
-       run cannot cause a buffer overflow.*/
-    OC_ALIGN8(ogg_int16_t dct_coeffs[128]);
+    /*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[65]);
     ptrdiff_t   fragi;
     int         last_zzi;
     int         zzi;
     ogg_uint16_t const*ac_quant;
     fragi=coded_fragis[fragii];
-#if defined(OC_X86_ASM)
-    /*First zero the buffer.*/
-    /*On K7, etc., this could be replaced with movntq and sfence.*/
-    __asm__ __volatile__(
-      "pxor %%mm0,%%mm0\n\t"
-      "movq %%mm0,(%[y])\n\t"
-      "movq %%mm0,8(%[y])\n\t"
-      "movq %%mm0,16(%[y])\n\t"
-      "movq %%mm0,24(%[y])\n\t"
-      "movq %%mm0,32(%[y])\n\t"
-      "movq %%mm0,40(%[y])\n\t"
-      "movq %%mm0,48(%[y])\n\t"
-      "movq %%mm0,56(%[y])\n\t"
-      "movq %%mm0,64(%[y])\n\t"
-      "movq %%mm0,72(%[y])\n\t"
-      "movq %%mm0,80(%[y])\n\t"
-      "movq %%mm0,88(%[y])\n\t"
-      "movq %%mm0,96(%[y])\n\t"
-      "movq %%mm0,104(%[y])\n\t"
-      "movq %%mm0,112(%[y])\n\t"
-      "movq %%mm0,120(%[y])\n\t"
-      :
-      :[y]"r"(dct_coeffs)
-      :"memory"
-    );
-#else
-    memset(dct_coeffs,0,64*sizeof(*dct_coeffs));
-#endif
+    for(zzi=0;zzi<64;zzi++)
+      dct_coeffs[zzi]=0;
     qti=frags[fragi].mb_mode!=OC_MODE_INTRA;
     ac_quant=_pipe->dequant[_pli][frags[fragi].qii][qti];
     /*Decode the AC coefficients.*/

Modified: branches/theora-gumboot/lib/dec/huffdec.c
===================================================================
--- branches/theora-gumboot/lib/dec/huffdec.c	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/dec/huffdec.c	2009-07-23 02:34:31 UTC (rev 16322)
@@ -371,7 +371,7 @@
  oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]){
   int i;
   for(i=0;i<TH_NHUFFMAN_TABLES;i++){
-    oc_huff_node nodes[63+13*2+4*6+5*14];
+    oc_huff_node nodes[511];
     int          ret;
     /*Unpack the full tree into a temporary buffer.*/
     ret=oc_huff_tree_unpack(_opb,nodes,sizeof(nodes)/sizeof(*nodes));

Modified: branches/theora-gumboot/lib/dec/internal.c
===================================================================
--- branches/theora-gumboot/lib/dec/internal.c	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/dec/internal.c	2009-07-23 02:34:31 UTC (rev 16322)
@@ -26,7 +26,7 @@
    block.
   All zig zag indices beyond 63 are sent to coefficient 64, so that zero runs
    past the end of a block in bogus streams get mapped to a known location.*/
-const unsigned char OC_FZIG_ZAG[64]={
+const unsigned char OC_FZIG_ZAG[128]={
    0, 1, 8,16, 9, 2, 3,10,
   17,24,32,25,18,11, 4, 5,
   12,19,26,33,40,48,41,34,
@@ -34,7 +34,15 @@
   35,42,49,56,57,50,43,36,
   29,22,15,23,30,37,44,51,
   58,59,52,45,38,31,39,46,
-  53,60,61,54,47,55,62,63
+  53,60,61,54,47,55,62,63,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64,
+  64,64,64,64,64,64,64,64
 };
 
 /*A map from the coefficient number in a block to its index in the zig zag


Property changes on: branches/theora-gumboot/lib/enc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/theora-thusnelda/lib/enc:16321

Modified: branches/theora-gumboot/lib/enc/encode.c
===================================================================
--- branches/theora-gumboot/lib/enc/encode.c	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/enc/encode.c	2009-07-23 02:34:31 UTC (rev 16322)
@@ -1058,7 +1058,7 @@
   _enc->coded_mbis=
    (unsigned *)_ogg_malloc(_enc->state.nmbs*sizeof(*_enc->coded_mbis));
   hdec=!(_enc->state.info.pixel_fmt&1);
-  vdec=!(_enc->state.info.pixel_fmt&1);
+  vdec=!(_enc->state.info.pixel_fmt&2);
   /*If chroma is sub-sampled in the vertical direction, we have to encode two
      super block rows of Y' for each super block row of Cb and Cr.*/
   _enc->mcu_nvsbs=1<<vdec;

Modified: branches/theora-gumboot/lib/enc/tokenize.c
===================================================================
--- branches/theora-gumboot/lib/enc/tokenize.c	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/enc/tokenize.c	2009-07-23 02:34:31 UTC (rev 16322)
@@ -641,34 +641,8 @@
   }
   /*Emit the tokens from the best path through the trellis.*/
   stack=*_stack;
-#if defined(OC_X86_ASM)
-  int dc=_qdct[0];
-  __asm__ __volatile__(
-    "pxor %%mm0,%%mm0\n\t"
-    "movq %%mm0,(%[y])\n\t"
-    "movq %%mm0,8(%[y])\n\t"
-    "movq %%mm0,16(%[y])\n\t"
-    "movq %%mm0,24(%[y])\n\t"
-    "movq %%mm0,32(%[y])\n\t"
-    "movq %%mm0,40(%[y])\n\t"
-    "movq %%mm0,48(%[y])\n\t"
-    "movq %%mm0,56(%[y])\n\t"
-    "movq %%mm0,64(%[y])\n\t"
-    "movq %%mm0,72(%[y])\n\t"
-    "movq %%mm0,80(%[y])\n\t"
-    "movq %%mm0,88(%[y])\n\t"
-    "movq %%mm0,96(%[y])\n\t"
-    "movq %%mm0,104(%[y])\n\t"
-    "movq %%mm0,112(%[y])\n\t"
-    "movq %%mm0,120(%[y])\n\t"
-    :
-    :[y]"r"(_qdct)
-    :"memory"
-  );
-  _qdct[0]=dc;
-#else
-  memset(_qdct+1,0,63*sizeof(*_qdct));
-#endif
+  for(zzi=1;zzi<64;zzi++)
+    _qdct[zzi]=0;
   zzi=1;
   ti=best_flags>>1&1;
   bits=tokens[zzi][ti].bits;

Modified: branches/theora-gumboot/lib/internal.h
===================================================================
--- branches/theora-gumboot/lib/internal.h	2009-07-23 01:21:08 UTC (rev 16321)
+++ branches/theora-gumboot/lib/internal.h	2009-07-23 02:34:31 UTC (rev 16322)
@@ -397,7 +397,7 @@
 
 /*A map from the index in the zig zag scan to the coefficient number in a
    block.*/
-extern const unsigned char OC_FZIG_ZAG[64];
+extern const unsigned char OC_FZIG_ZAG[128];
 /*A map from the coefficient number in a block to its index in the zig zag
    scan.*/
 extern const unsigned char OC_IZIG_ZAG[64];



More information about the commits mailing list