[xiph-commits] r17129 - in trunk/theora-exp: lib tools unix

tterribe at svn.xiph.org tterribe at svn.xiph.org
Mon Apr 5 19:04:50 PDT 2010


Author: tterribe
Date: 2010-04-05 19:04:50 -0700 (Mon, 05 Apr 2010)
New Revision: 17129

Modified:
   trunk/theora-exp/lib/encode.c
   trunk/theora-exp/lib/encvbr.c
   trunk/theora-exp/lib/impmap.c
   trunk/theora-exp/lib/internal.c
   trunk/theora-exp/lib/state.c
   trunk/theora-exp/tools/csfgen.c
   trunk/theora-exp/tools/extgen.c
   trunk/theora-exp/tools/yuv2yuv4mpeg.c
   trunk/theora-exp/unix/Makefile
Log:
Various minor fixes and additions that have accumulated over the years but
 never found their way into svn.
Do not infer from this commit that any of this code is being actively
 maintained.


Modified: trunk/theora-exp/lib/encode.c
===================================================================
--- trunk/theora-exp/lib/encode.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/lib/encode.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -1296,12 +1296,157 @@
   return ret;
 }
 
+#if defined(OC_DUMP_IMAGES)
+static void oc_enc_dump_mc_diff(oc_enc_ctx *_enc){
+  int pli;
+  for(pli=0;pli<3;pli++){
+    oc_fragment_plane *fplane;
+    int                src_ystride;
+    int                dst_framei;
+    int                dst_ystride;
+    int                fragi;
+    src_ystride=_enc->state.input[pli].ystride;
+    dst_framei=_enc->state.ref_frame_idx[OC_FRAME_SELF];
+    dst_ystride=_enc->state.ref_frame_bufs[dst_framei][pli].ystride;
+    fplane=_enc->state.fplanes+pli;
+    for(fragi=fplane->froffset;fragi<fplane->froffset+fplane->nfrags;fragi++){
+      oc_fragment   *frag;
+      ogg_int16_t    pix_buf[64];
+      unsigned char *dst;
+      unsigned char *ref0;
+      unsigned char *ref1;
+      unsigned char *src;
+      int            pixi;
+      int            ref_ystride;
+      int            ref_framei;
+      int            mvoffsets[2];
+      int            y;
+      int            x;
+      frag=_enc->state.frags+fragi;
+      src=frag->buffer[OC_FRAME_IO];
+      if(frag->coded){
+        if(frag->mbmode!=OC_MODE_INTRA){
+          ref_framei=_enc->state.ref_frame_idx[
+           OC_FRAME_FOR_MODE[frag->mbmode]];
+          ref_ystride=_enc->state.ref_frame_bufs[ref_framei][pli].ystride;
+          if(oc_state_get_mv_offsets(&_enc->state,mvoffsets,
+           frag->mv[0],frag->mv[1],ref_ystride,pli)>1){
+            ref0=frag->buffer[ref_framei]+mvoffsets[0];
+            ref1=frag->buffer[ref_framei]+mvoffsets[1];
+            if(frag->border!=NULL){
+              ogg_int64_t mask;
+              mask=frag->border->mask;
+              for(pixi=y=0;y<8;y++){
+                for(x=0;x<8;x++,pixi++){
+                  pix_buf[pixi]=(ogg_int16_t)(((int)mask&1)?
+                   src[x]-((int)ref0[x]+ref1[x]>>1):0);
+                  mask>>=1;
+                }
+                src+=src_ystride;
+                ref0+=ref_ystride;
+                ref1+=ref_ystride;
+              }
+            }
+            else{
+              for(pixi=y=0;y<8;y++){
+                for(x=0;x<8;x++,pixi++){
+                  pix_buf[pixi]=(ogg_int16_t)(src[x]-((int)ref0[x]+ref1[x]>>1));
+                }
+                src+=src_ystride;
+                ref0+=ref_ystride;
+                ref1+=ref_ystride;
+              }
+            }
+          }
+          else{
+            ref0=frag->buffer[ref_framei]+mvoffsets[0];
+            if(frag->border!=NULL){
+              ogg_int64_t mask;
+              mask=frag->border->mask;
+              for(pixi=y=0;y<8;y++){
+                for(x=0;x<8;x++,pixi++){
+                  pix_buf[pixi]=(ogg_int16_t)(((int)mask&1)?src[x]-(int)ref0[x]:0);
+                  mask>>=1;
+                }
+                src+=src_ystride;
+                ref0+=ref_ystride;
+              }
+            }
+            else{
+              for(pixi=y=0;y<8;y++){
+                for(x=0;x<8;x++,pixi++){
+                  pix_buf[pixi]=(ogg_int16_t)(src[x]-(int)ref0[x]);
+                }
+                src+=src_ystride;
+                ref0+=ref_ystride;
+              }
+            }
+          }
+        }
+        else{
+          if(frag->border!=NULL){
+            ogg_int64_t mask;
+            mask=frag->border->mask;
+            for(pixi=y=0;y<8;y++){
+              for(x=0;x<8;x++,pixi++){
+                pix_buf[pixi]=(ogg_int16_t)(((int)mask&1)?src[x]-128:0);
+                mask>>=1;
+              }
+              src+=src_ystride;
+            }
+          }
+          else{
+            for(pixi=y=0;y<8;y++){
+              for(x=0;x<8;x++,pixi++)pix_buf[pixi]=(ogg_int16_t)(src[x]-128);
+              src+=src_ystride;
+            }
+          }
+        }
+      }
+      else{
+        ref_framei=_enc->state.ref_frame_idx[OC_FRAME_PREV];
+        ref_ystride=_enc->state.ref_frame_bufs[ref_framei][pli].ystride;
+        ref0=frag->buffer[ref_framei];
+        if(frag->border!=NULL){
+          ogg_int64_t mask;
+          mask=frag->border->mask;
+          for(pixi=y=0;y<8;y++){
+            for(x=0;x<8;x++,pixi++){
+              pix_buf[pixi]=(ogg_int16_t)(((int)mask&1)?src[x]-ref0[x]:0);
+              mask>>=1;
+            }
+            src+=src_ystride;
+            ref0+=ref_ystride;
+          }
+        }
+        else{
+          for(pixi=y=0;y<8;y++){
+            for(x=0;x<8;x++,pixi++)pix_buf[pixi]=(ogg_int16_t)(src[x]-ref0[x]);
+            src+=src_ystride;
+            ref0+=ref_ystride;
+          }
+        }
+      }
+      dst=frag->buffer[dst_framei];
+      for(pixi=y=0;y<8;y++){
+        for(x=0;x<8;x++,pixi++)dst[x]=(pix_buf[pixi]>>1)+128;
+        dst+=dst_ystride;
+      }
+    }
+  }
+  oc_state_dump_frame(&_enc->state,OC_FRAME_SELF,"mc");
+}
+#endif
+
 /*Performs a motion-compensated fDCT for each fragment coded in a mode other
    than INTRA.*/
 void oc_enc_do_inter_dcts(oc_enc_ctx *_enc){
   int *coded_fragi;
   int *coded_fragi_end;
   int  pli;
+#if defined(OC_DUMP_IMAGES)
+  oc_enc_dump_mc_diff(_enc);
+#endif
   coded_fragi_end=coded_fragi=_enc->state.coded_fragis;
   for(pli=0;pli<3;pli++){
     coded_fragi_end+=_enc->state.ncoded_fragis[pli];
@@ -1481,6 +1626,9 @@
   _enc->state.curframe_num++;
   /*Fill the fragment array with pointers into the user buffer.*/
   oc_state_fill_buffer_ptrs(&_enc->state,OC_FRAME_IO,img);
+#if defined(OC_DUMP_IMAGES)
+  oc_state_dump_frame(&_enc->state,OC_FRAME_IO,"in");
+#endif
   /*Reset the encoding pipeline.*/
   ret=(*_enc->pipe->pipe_start)(_enc->pipe);
   if(ret<0)return ret;

Modified: trunk/theora-exp/lib/encvbr.c
===================================================================
--- trunk/theora-exp/lib/encvbr.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/lib/encvbr.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -1067,7 +1067,8 @@
       /*Bit costs are stored in the table with extra precision.
         Round them down to whole bits here.*/
       /*LOOP VECTORIZES.*/
-      for(modei=0;modei<OC_NMODES;modei++){
+      bits[0]=bits[0]+(1<<OC_BIT_SCALE-1)>>OC_BIT_SCALE-4;
+      for(modei=1;modei<OC_NMODES;modei++){
         bits[modei]=bits[modei]+(1<<OC_BIT_SCALE-1)>>OC_BIT_SCALE;
       }
       /*Estimate the cost of coding the label for each mode.
@@ -1080,11 +1081,11 @@
       /*Add the motion vector bits for each mode that requires them.*/
       mbpmvbitsa=oc_mvbitsa(mbinfo->mvs[0][OC_FRAME_PREV][0],
        mbinfo->mvs[0][OC_FRAME_PREV][1]);
-      mbgmvbitsa=oc_mvbitsa(mbinfo->mvs[1][OC_FRAME_GOLD][0],
+      mbgmvbitsa=oc_mvbitsa(mbinfo->mvs[0][OC_FRAME_GOLD][0],
        mbinfo->mvs[0][OC_FRAME_GOLD][1]);
       mb4mvbitsa=mb4mvbitsb=0;
       for(codedi=0;codedi<ncoded_luma;codedi++){
-        mb4mvbitsa=oc_mvbitsa(bmvs[0][coded[codedi]][0],
+        mb4mvbitsa+=oc_mvbitsa(bmvs[0][coded[codedi]][0],
          bmvs[0][coded[codedi]][1]);
         mb4mvbitsb+=12;
       }

Modified: trunk/theora-exp/lib/impmap.c
===================================================================
--- trunk/theora-exp/lib/impmap.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/lib/impmap.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -1826,7 +1826,7 @@
     png_bytep    *image;
     FILE         *fp;
     char          fname[16];
-    sprintf(fname,"%08iseg.png",_impmap->enc->state.curframe_num);
+    sprintf(fname,"%08iseg.png",(int)_impmap->enc->state.curframe_num);
     fp=fopen(fname,"wb");
     if(fp==NULL)return;
     image=(png_bytep *)oc_malloc_2d(_height,_width,sizeof(image[0][0]));

Modified: trunk/theora-exp/lib/internal.c
===================================================================
--- trunk/theora-exp/lib/internal.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/lib/internal.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -262,7 +262,7 @@
   _lmbmv: The luma macro-block level motion vector to fill in for use in
            prediction.
   _lbmvs: The luma block-level motion vectors.*/
-static void oc_set_chroma_mvs11(oc_mv _cbmvs[4][2],const oc_mv _lbmvs[4]){
+static void oc_set_chroma_mvs11(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
   memcpy(_cbmvs,_lbmvs,4*sizeof(_lbmvs[0]));
 }
 

Modified: trunk/theora-exp/lib/state.c
===================================================================
--- trunk/theora-exp/lib/state.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/lib/state.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -1022,7 +1022,6 @@
   int            y_stride;
   int            u_stride;
   int            v_stride;
-  int            framei;
   int            width;
   int            height;
   int            imgi;
@@ -1054,13 +1053,24 @@
     fclose(fp);
     return TH_EFAULT;
   }
-  framei=_state->ref_frame_idx[_frame];
-  y_row=_state->ref_frame_bufs[framei][0].data;
-  u_row=_state->ref_frame_bufs[framei][1].data;
-  v_row=_state->ref_frame_bufs[framei][2].data;
-  y_stride=_state->ref_frame_bufs[framei][0].ystride;
-  u_stride=_state->ref_frame_bufs[framei][1].ystride;
-  v_stride=_state->ref_frame_bufs[framei][2].ystride;
+  if(_frame!=OC_FRAME_IO){
+    int framei;
+    framei=_state->ref_frame_idx[_frame];
+    y_row=_state->ref_frame_bufs[framei][0].data;
+    u_row=_state->ref_frame_bufs[framei][1].data;
+    v_row=_state->ref_frame_bufs[framei][2].data;
+    y_stride=_state->ref_frame_bufs[framei][0].ystride;
+    u_stride=_state->ref_frame_bufs[framei][1].ystride;
+    v_stride=_state->ref_frame_bufs[framei][2].ystride;
+  }
+  else{
+    y_row=_state->input[0].data;
+    u_row=_state->input[1].data;
+    v_row=_state->input[2].data;
+    y_stride=_state->input[0].ystride;
+    u_stride=_state->input[1].ystride;
+    v_stride=_state->input[2].ystride;
+  }
   /*Chroma up-sampling is just done with a box filter.
     This is very likely what will actually be used in practice on a real
      display, and also removes one more layer to search in for the source of
@@ -1106,7 +1116,7 @@
   png_set_compression_level(png,Z_BEST_COMPRESSION);
   png_set_IHDR(png,info,width,height,16,PNG_COLOR_TYPE_RGB,
    PNG_INTERLACE_NONE,PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT);
-  switch(_state->info.colorspace){
+  switch((int)_state->info.colorspace){
     case TH_CS_ITU_REC_470M:{
       png_set_gAMA(png,info,2.2);
       png_set_cHRM_fixed(png,info,31006,31616,

Modified: trunk/theora-exp/tools/csfgen.c
===================================================================
--- trunk/theora-exp/tools/csfgen.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/tools/csfgen.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -343,7 +343,7 @@
   The advantage of using Cannon's scheme over theirs is that Cannon's is very
    simple, and contains no unexplained magic constants.
   Current results from Chandler and Hemami give only a small benefit over
-   JPEG200.
+   JPEG2000.
 
   @ARTICLE{Can85,
     author="Mark W. Cannon, Jr.",

Modified: trunk/theora-exp/tools/extgen.c
===================================================================
--- trunk/theora-exp/tools/extgen.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/tools/extgen.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -60,7 +60,7 @@
   },
   {
     +0.7071075439453125,-0.8314685295335948,
-    +0.3826904296875,    +0.1950868454296142,
+    +0.3826904296875,   +0.1950868454296142,
     -0.7071075439453125,+0.9807858711574227,
     -0.9238739013671875,+0.5555783333256841
   },
@@ -114,9 +114,9 @@
 
 
 
-/*Computes the Cholesky factorization L L^T of the matrix G^T G, where G is the
-   currently selected bass functions restricted to the region of spatial
-   support.
+/*Computes the Cholesky factorization L L^T of the matrix G^T G, where G
+   contains the currently selected basis functions restricted to the region of
+   spatial support.
   The reciprocal of the diagonal element is stored instead of the diagonal
    itself, so that the division only needs to be done once.
   _l:   The L matrix to compute.

Modified: trunk/theora-exp/tools/yuv2yuv4mpeg.c
===================================================================
--- trunk/theora-exp/tools/yuv2yuv4mpeg.c	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/tools/yuv2yuv4mpeg.c	2010-04-06 02:04:50 UTC (rev 17129)
@@ -97,10 +97,10 @@
      "  Name  Width  Height  -an   -ad\n"
      "        720    576     128   117\n"
      "  CIF   352    288     128   117\n"
-     "  QCIF  144    176     128   117\n"
+     "  QCIF  176    144     128   117\n"
      "        720    480     4320  4739\n"
      "  SIF   352    240     4320  4739\n"
-     " The HD TV sizes (1920x1080, 1280x720), really do use square pixels.\n"
+     " The HD TV sizes (1920x1080, 1280x720) really do use square pixels.\n"
      " -o<offset>      The first frame number to use in -d mode.\n"
      "                 If unspecified, 0 is used.\n");
     return -1;

Modified: trunk/theora-exp/unix/Makefile
===================================================================
--- trunk/theora-exp/unix/Makefile	2010-04-05 17:28:02 UTC (rev 17128)
+++ trunk/theora-exp/unix/Makefile	2010-04-06 02:04:50 UTC (rev 17129)
@@ -28,11 +28,16 @@
 CFLAGS += -O3 -fomit-frame-pointer -fforce-addr -finline-functions
 #CFLAGS += -ftree-vectorize -ftree-vectorizer-verbose=9
 #CFLAGS += -march=core2
+#CFLAGS += -DOC_DUMP_IMAGES
 # The -g flag will generally include debugging information.
 #CFLAGS += -g
 # Libraries to link with, and the location of library files.
 # Add -lpng -lz if you want to use -DOC_DUMP_IMAGES.
-LIBS = -logg -lvorbis -lvorbisenc `sdl-config --libs`
+LIBS = -logg -lvorbis -lvorbisenc
+SDL_LIBS = `sdl-config --libs`
+ifeq ($(findstring -DOC_DUMP_IMAGES,${CFLAGS}),-DOC_DUMP_IMAGES)
+    LIBS += -lpng -lz
+endif
 
 # ANYTHING BELOW THIS LINE PROBABLY DOES NOT NEED EDITING
 CINCLUDE := -I../include ${CINCLUDE}
@@ -198,7 +203,7 @@
 # player_example
 ${PLAYER_EXAMPLE_TARGET}: ${PLAYER_EXAMPLE_OBJS} ${LIBTHEORADEC_TARGET}
 	mkdir -p ${TARGETBINDIR}
-	${CC} ${CFLAGS} -o $@ ${PLAYER_EXAMPLE_OBJS} ${LIBS} \
+	${CC} ${CFLAGS} -o $@ ${PLAYER_EXAMPLE_OBJS} ${SDL_LIBS} ${LIBS} \
          ${LIBTHEORADEC_TARGET}
 
 # rehuff



More information about the commits mailing list