[xiph-commits] r13368 - trunk/theora/lib/enc

maikmerten at svn.xiph.org maikmerten at svn.xiph.org
Thu Jul 26 11:07:11 PDT 2007


Author: maikmerten
Date: 2007-07-26 11:07:10 -0700 (Thu, 26 Jul 2007)
New Revision: 13368

Modified:
   trunk/theora/lib/enc/encode.c
   trunk/theora/lib/enc/encoder_toplevel.c
Log:
Implement TH_ENCCTL_SET_SPLEVEL and TH_ENCCTL_GET_SPLEVEL_MAX.

0: Same as quick_p = 0 (exhaustive motion search)
1: Same as quick_p = 1 (default, combination of quick and exhaustive motion search)
2: No motion compensation at all. Very fast but impacts negatively on both image quality and bitrate. Perhaps useful for e.g. videoconferencing (little motion) on slow systems. Definately of limited use.

Modified: trunk/theora/lib/enc/encode.c
===================================================================
--- trunk/theora/lib/enc/encode.c	2007-07-26 04:37:43 UTC (rev 13367)
+++ trunk/theora/lib/enc/encode.c	2007-07-26 18:07:10 UTC (rev 13368)
@@ -1101,8 +1101,9 @@
 
   QIndex = (unsigned char)cpi->pb.FrameQIndex;
 
+  if(!cpi->MotionCompensation)
+    return 0;
 
-
   /* change the quatization matrix to the one at best Q to compute the
      new error score */
   cpi->MinImprovementForNewMV = (MvThreshTable[QIndex] << 12);

Modified: trunk/theora/lib/enc/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/enc/encoder_toplevel.c	2007-07-26 04:37:43 UTC (rev 13367)
+++ trunk/theora/lib/enc/encoder_toplevel.c	2007-07-26 18:07:10 UTC (rev 13368)
@@ -1383,7 +1383,9 @@
 
 
 int theora_control(theora_state *th,int req,void *buf,size_t buf_sz) {
-
+  
+  int value;
+  
   if(th == NULL)
     return TH_EFAULT;
 
@@ -1409,7 +1411,38 @@
       memcpy(&pbi->quant_info, &TH_VP31_QUANT_INFO, sizeof(th_quant_info));
       InitQTables(pbi);
       
-      return 0;  
+      return 0;
+    case TH_ENCCTL_SET_SPLEVEL:
+      if(buf == NULL || buf_sz != sizeof(int))
+        return TH_EINVAL;
+      
+      memcpy(&value, buf, sizeof(int));
+            
+      switch(value) {
+        case 0:
+          cpi->MotionCompensation = 1;
+          pbi->info.quick_p = 0;
+        break;
+        
+        case 1:
+          cpi->MotionCompensation = 1;
+          pbi->info.quick_p = 1;
+        break;
+        
+        case 2:
+          cpi->MotionCompensation = 0;
+          pbi->info.quick_p = 1;
+        break;
+        
+        default:
+          return TH_EINVAL;    
+      }
+      
+      return 0;
+    case TH_ENCCTL_GET_SPLEVEL_MAX:
+      value = 2;
+      memcpy(buf, &value, sizeof(int));
+      return 0;
     default:
       return TH_EIMPL;
   }



More information about the commits mailing list