]> granicus.if.org Git - libvpx/commitdiff
Further work on extended Q range.
authorPaul Wilkins <paulwilkins@google.com>
Thu, 24 Nov 2011 18:25:03 +0000 (18:25 +0000)
committerPaul Wilkins <paulwilkins@google.com>
Tue, 29 Nov 2011 17:59:23 +0000 (17:59 +0000)
Fixed bug in firspass.c call to vp8_initialize_rd_consts()

This was passing in vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q)
 instead of (cm->base_qindex + cm->y1dc_delta_q).

It just so happens that for the value 26 used for cm->base_qindex in the
unextended Q case,  the two give similar results. However, when using
the extended Q range the two are very different.

Also added more stats output and partly disabled another broken feature.

Change-Id: Iddf6cf5ea8467c44b7c133f38e629f6ba6f2581e

vp8/common/quant_common.c
vp8/encoder/firstpass.c
vp8/encoder/onyx_if.c
vp8/encoder/rdopt.c

index 71c4e7d45f442ea6bb7e236d444c1e7070421a1c..d9a7592683a57e91a24d85679d73b33c169ba882 100644 (file)
@@ -102,8 +102,8 @@ int vp8_dc_uv_quant(int QIndex, int Delta)
 
     QIndex = QIndex + Delta;
 
-    if (QIndex > 117)
-        QIndex = 117;
+    if (QIndex > 127)
+        QIndex = 127;
     else if (QIndex < 0)
         QIndex = 0;
 
index 4f3b75ce21c6abeaa629709779a56938e741a167..81d3b3509c85e7c7f615b00b0a61016cd1f04df8 100644 (file)
@@ -535,7 +535,7 @@ void vp8_first_pass(VP8_COMP *cpi)
     //if ( 0 )
     {
         int flag[2] = {1, 1};
-        vp8_initialize_rd_consts(cpi, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
+        vp8_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
         vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
         vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
     }
@@ -895,8 +895,8 @@ static double calc_correction_factor( double err_per_mb,
     double error_term = err_per_mb / err_devisor;
     double correction_factor;
 
-    // Adjustment based on Q to power term.
-    power_term = pt_low + (Q * 0.01);
+    // Adjustment based on actual quantizer to power term.
+    power_term = (vp8_convert_qindex_to_q(Q) * 0.01) + 0.36;
     power_term = (power_term > pt_high) ? pt_high : power_term;
 
     // Adjustments to error term
@@ -973,6 +973,7 @@ static int estimate_max_q(VP8_COMP *cpi,
 
     // Estimate of overhead bits per mb
     // Correction to overhead bits for min allowed Q.
+    // PGW TODO.. This code is broken for the extended Q range
     overhead_bits_per_mb = overhead_bits / num_mbs;
     overhead_bits_per_mb *= pow( 0.98, (double)cpi->twopass.maxq_min_limit );
 
@@ -1013,7 +1014,8 @@ static int estimate_max_q(VP8_COMP *cpi,
     // Adjust maxq_min_limit and maxq_max_limit limits based on
     // averaga q observed in clip for non kf/gf.arf frames
     // Give average a chance to settle though.
-    if ( (cpi->ni_frames >
+    // PGW TODO.. This code is broken for the extended Q range
+    /*if ( (cpi->ni_frames >
                   ((unsigned int)cpi->twopass.total_stats->count >> 8)) &&
          (cpi->ni_frames > 150) )
     {
@@ -1021,7 +1023,7 @@ static int estimate_max_q(VP8_COMP *cpi,
                                   ? (cpi->ni_av_qi + 32) : cpi->worst_quality;
         cpi->twopass.maxq_min_limit = ((cpi->ni_av_qi - 32) > cpi->best_quality)
                                   ? (cpi->ni_av_qi - 32) : cpi->best_quality;
-    }
+    }*/
 
     return Q;
 }
index d44b69c9df19687caec0a986bb840ff152d01d6f..89c44269e7c1192983d1a5301ffece50bea87668 100644 (file)
@@ -4645,17 +4645,26 @@ static void encode_frame_to_data_rate
         vp8_clear_system_state();  //__asm emms;
 
         if (cpi->twopass.total_left_stats->coded_error != 0.0)
-            fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
-                       "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+            fprintf(f, "%10d %10d %10d %10d %10d %10d %10d"
+                       "%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
+                       "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
                        "%10.3f %8d\n",
                        cpi->common.current_video_frame, cpi->this_frame_target,
                        cpi->projected_frame_size,
                        (cpi->projected_frame_size - cpi->this_frame_target),
                        (int)cpi->total_target_vs_actual,
                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target),
-                       (int)cpi->total_actual_bits, cm->base_qindex,
-                       cpi->active_best_quality, cpi->active_worst_quality,
-                       cpi->ni_av_qi, cpi->cq_target_quality,
+                       (int)cpi->total_actual_bits,
+                       vp8_convert_qindex_to_q(cm->base_qindex),
+#if CONFIG_EXTEND_QRANGE
+                        (double)vp8_dc_quant(cm->base_qindex,0)/4.0,
+#else
+                        (double)vp8_dc_quant(cm->base_qindex,0),
+#endif
+                       vp8_convert_qindex_to_q(cpi->active_best_quality),
+                       vp8_convert_qindex_to_q(cpi->active_worst_quality),
+                       vp8_convert_qindex_to_q(cpi->ni_av_qi),
+                       vp8_convert_qindex_to_q(cpi->cq_target_quality),
                        cpi->zbin_over_quant,
                        //cpi->avg_frame_qindex, cpi->zbin_over_quant,
                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
@@ -4667,17 +4676,26 @@ static void encode_frame_to_data_rate
                            cpi->twopass.total_left_stats->coded_error,
                        cpi->tot_recode_hits);
         else
-            fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
-                       "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+            fprintf(f, "%10d %10d %10d %10d %10d %10d %10d"
+                       "%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
+                       "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
                        "%8d\n",
                        cpi->common.current_video_frame,
                        cpi->this_frame_target, cpi->projected_frame_size,
                        (cpi->projected_frame_size - cpi->this_frame_target),
                        (int)cpi->total_target_vs_actual,
                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target),
-                       (int)cpi->total_actual_bits, cm->base_qindex,
-                       cpi->active_best_quality, cpi->active_worst_quality,
-                       cpi->ni_av_qi, cpi->cq_target_quality,
+                       (int)cpi->total_actual_bits,
+                       vp8_convert_qindex_to_q(cm->base_qindex),
+#if CONFIG_EXTEND_QRANGE
+                        (double)vp8_dc_quant(cm->base_qindex,0)/4.0,
+#else
+                        (double)vp8_dc_quant(cm->base_qindex,0),
+#endif
+                       vp8_convert_qindex_to_q(cpi->active_best_quality),
+                       vp8_convert_qindex_to_q(cpi->active_worst_quality),
+                       vp8_convert_qindex_to_q(cpi->ni_av_qi),
+                       vp8_convert_qindex_to_q(cpi->cq_target_quality),
                        cpi->zbin_over_quant,
                        //cpi->avg_frame_qindex, cpi->zbin_over_quant,
                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
index 76eec8a80fa3aab1c79c9b3299bcd45022a601f5..a3dab72f60acc3fda780d8d863127bd2edc83670 100644 (file)
@@ -255,8 +255,6 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex)
     if (q < 8)
         q = 8;
 
-
-
 #if CONFIG_EXTEND_QRANGE
     cpi->RDMULT *= 16;
 #endif