]> granicus.if.org Git - libvpx/commitdiff
vp9: Fix rate control stats for bypass mode in sample encoder
authorMarco Paniconi <marpan@google.com>
Thu, 30 Aug 2018 19:59:44 +0000 (12:59 -0700)
committerMarco Paniconi <marpan@google.com>
Thu, 30 Aug 2018 20:01:34 +0000 (13:01 -0700)
Allow rate control stats to work for bypass mode
in vp9_spatial_svc_encoder.c

Change-Id: I66764a006a73b1fd13c07b4fc4e0c88b2bb2a035

examples/vp9_spatial_svc_encoder.c

index 8e3f17e34e4b24138ba0e169a57f446b3d29fd23..17beea15cab9113ef80c9c9339fde609ae1ed972 100644 (file)
@@ -976,34 +976,31 @@ int main(int argc, const char **argv) {
 #if OUTPUT_RC_STATS
             // TODO(marpan): Put this (to line728) in separate function.
             if (svc_ctx.output_rc_stat) {
+              int num_layers_encoded = 0;
               vpx_codec_control(&codec, VP9E_GET_SVC_LAYER_ID, &layer_id);
               parse_superframe_index(cx_pkt->data.frame.buf,
                                      cx_pkt->data.frame.sz, sizes_parsed,
                                      &count);
               if (enc_cfg.ss_number_layers == 1)
                 sizes[0] = cx_pkt->data.frame.sz;
-              if (svc_ctx.temporal_layering_mode !=
-                  VP9E_TEMPORAL_LAYERING_MODE_BYPASS) {
-                int num_layers_encoded = 0;
-                for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
-                  sizes[sl] = 0;
-                  if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
-                    sizes[sl] = sizes_parsed[num_layers_encoded];
-                    num_layers_encoded++;
-                  }
+              for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
+                sizes[sl] = 0;
+                if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
+                  sizes[sl] = sizes_parsed[num_layers_encoded];
+                  num_layers_encoded++;
                 }
-                for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
-                  unsigned int sl2;
-                  uint64_t tot_size = 0;
-                  for (sl2 = 0; sl2 <= sl; ++sl2) {
-                    if (cx_pkt->data.frame.spatial_layer_encoded[sl2])
-                      tot_size += sizes[sl2];
-                  }
-                  if (tot_size > 0)
-                    vpx_video_writer_write_frame(
-                        outfile[sl], cx_pkt->data.frame.buf, (size_t)(tot_size),
-                        cx_pkt->data.frame.pts);
+              }
+              for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
+                unsigned int sl2;
+                uint64_t tot_size = 0;
+                for (sl2 = 0; sl2 <= sl; ++sl2) {
+                  if (cx_pkt->data.frame.spatial_layer_encoded[sl2])
+                    tot_size += sizes[sl2];
                 }
+                if (tot_size > 0)
+                  vpx_video_writer_write_frame(
+                      outfile[sl], cx_pkt->data.frame.buf, (size_t)(tot_size),
+                      cx_pkt->data.frame.pts);
               }
               for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
                 if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
@@ -1089,15 +1086,6 @@ int main(int argc, const char **argv) {
     }
   }
 
-  // Compensate for the extra frame count for the bypass mode.
-  if (svc_ctx.temporal_layering_mode == VP9E_TEMPORAL_LAYERING_MODE_BYPASS) {
-    for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
-      const int layer =
-          sl * enc_cfg.ts_number_layers + layer_id.temporal_layer_id;
-      --rc.layer_input_frames[layer];
-    }
-  }
-
   printf("Processed %d frames\n", frame_cnt);
   fclose(infile);
 #if OUTPUT_RC_STATS