use some extra packing modes for CQM headers.
authorLoren Merritt <pengvado@videolan.org>
Sat, 31 Dec 2005 14:16:02 +0000 (14:16 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sat, 31 Dec 2005 14:16:02 +0000 (14:16 +0000)
fix typo in --cqm4p[yc].

git-svn-id: svn://svn.videolan.org/x264/trunk@392 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/set.c
x264.c

index f10f46b..eb59b86 100644 (file)
@@ -46,15 +46,31 @@ static void scaling_list_write( bs_t *s, x264_pps_t *pps, int idx )
     const uint8_t *def_list = (idx==CQM_4IC) ? pps->scaling_list[CQM_4IY]
                             : (idx==CQM_4PC) ? pps->scaling_list[CQM_4PY]
                             : x264_cqm_jvt[idx];
-    int j;
-    if( memcmp( list, def_list, len ) )
+    if( !memcmp( list, def_list, len ) )
+        bs_write( s, 1, 0 ); // scaling_list_present_flag
+    else if( !memcmp( list, x264_cqm_jvt[idx], len ) )
     {
         bs_write( s, 1, 1 ); // scaling_list_present_flag
-        for( j = 0; j < len; j++ )
-            bs_write_se( s, list[zigzag[j]] - (j>0 ? list[zigzag[j-1]] : 8) ); // delta
+        bs_write_se( s, -8 ); // use jvt list
     }
     else
-        bs_write( s, 1, 0 ); // scaling_list_present_flag
+    {
+        int j, run;
+        bs_write( s, 1, 1 ); // scaling_list_present_flag
+
+        // try run-length compression of trailing values
+        for( run = len; run > 1; run-- )
+            if( list[zigzag[run-1]] != list[zigzag[run-2]] )
+                break;
+        if( run < len && len - run < bs_size_se( (int8_t)-list[zigzag[run]] ) )
+            run = len;
+
+        for( j = 0; j < run; j++ )
+            bs_write_se( s, (int8_t)(list[zigzag[j]] - (j>0 ? list[zigzag[j-1]] : 8)) ); // delta
+
+        if( run < len )
+            bs_write_se( s, (int8_t)-list[zigzag[run]] );
+    }
 }
 
 void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
diff --git a/x264.c b/x264.c
index 0bc496a..f5d0dda 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -890,11 +890,11 @@ static int  Parse( int argc, char **argv,
                 break;
             case OPT_CQM4PY:
                 param->i_cqm_preset = X264_CQM_CUSTOM;
-                b_error |= parse_cqm( optarg, param->cqm_4iy, 16 );
+                b_error |= parse_cqm( optarg, param->cqm_4py, 16 );
                 break;
             case OPT_CQM4PC:
                 param->i_cqm_preset = X264_CQM_CUSTOM;
-                b_error |= parse_cqm( optarg, param->cqm_4ic, 16 );
+                b_error |= parse_cqm( optarg, param->cqm_4pc, 16 );
                 break;
             case OPT_CQM8I:
                 param->i_cqm_preset = X264_CQM_CUSTOM;