From: Marco Paniconi Date: Thu, 30 Aug 2018 19:59:44 +0000 (-0700) Subject: vp9: Fix rate control stats for bypass mode in sample encoder X-Git-Tag: v1.8.0~380 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5d28602167bd70435213ae04b152b3edb153d2d;p=libvpx vp9: Fix rate control stats for bypass mode in sample encoder Allow rate control stats to work for bypass mode in vp9_spatial_svc_encoder.c Change-Id: I66764a006a73b1fd13c07b4fc4e0c88b2bb2a035 --- diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index 8e3f17e34..17beea15c 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -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