diff options
author | Marco <marpan@google.com> | 2016-02-29 11:12:02 -0800 |
---|---|---|
committer | Marco <marpan@google.com> | 2016-02-29 11:13:42 -0800 |
commit | 729c99764236d737c5f723ed47e3a1e6bede1235 (patch) | |
tree | f02eaee897aab12b41e77d0f6caf120735f0504f /examples | |
parent | 55a09f7f459af7d428077d98ac96376376c0dc42 (diff) | |
download | libvpx-729c99764236d737c5f723ed47e3a1e6bede1235.tar.gz libvpx-729c99764236d737c5f723ed47e3a1e6bede1235.tar.bz2 libvpx-729c99764236d737c5f723ed47e3a1e6bede1235.zip |
vp8: multi-res-encoder: Fix timer around encoder in sample encoder.
Change-Id: I0131ab4767e2eb72838ab6e58dd77a85fbf508e0
Diffstat (limited to 'examples')
-rw-r--r-- | examples/vp8_multi_resolution_encoder.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/vp8_multi_resolution_encoder.c b/examples/vp8_multi_resolution_encoder.c index 0248edede..fc775ef7c 100644 --- a/examples/vp8_multi_resolution_encoder.c +++ b/examples/vp8_multi_resolution_encoder.c @@ -347,8 +347,7 @@ int main(int argc, char **argv) double psnr_totals[NUM_ENCODERS][4] = {{0,0}}; int psnr_count[NUM_ENCODERS] = {0}; - double cx_time = 0; - struct timeval tv1, tv2, difftv; + int64_t cx_time = 0; /* Set the required target bitrates for each resolution level. * If target bitrate for highest-resolution level is set to 0, @@ -582,6 +581,7 @@ int main(int argc, char **argv) while(frame_avail || got_data) { + struct vpx_usec_timer timer; vpx_codec_iter_t iter[NUM_ENCODERS]={NULL}; const vpx_codec_cx_pkt_t *pkt[NUM_ENCODERS]; @@ -636,18 +636,18 @@ int main(int argc, char **argv) vpx_codec_control(&codec[i], VP8E_SET_TEMPORAL_LAYER_ID, layer_id); } - gettimeofday(&tv1, NULL); /* Encode each frame at multi-levels */ /* Note the flags must be set to 0 in the encode call if they are set for each frame with the vpx_codec_control(), as done above. */ + vpx_usec_timer_start(&timer); if(vpx_codec_encode(&codec[0], frame_avail? &raw[0] : NULL, frame_cnt, 1, 0, arg_deadline)) { die_codec(&codec[0], "Failed to encode frame"); } - gettimeofday(&tv2, NULL); - timersub(&tv2, &tv1, &difftv); - cx_time += (double)(difftv.tv_sec * 1000000 + difftv.tv_usec); + vpx_usec_timer_mark(&timer); + cx_time += vpx_usec_timer_elapsed(&timer); + for (i=NUM_ENCODERS-1; i>=0 ; i--) { got_data = 0; @@ -686,8 +686,10 @@ int main(int argc, char **argv) frame_cnt++; } printf("\n"); - printf("FPS for encoding %d %f %f \n", frame_cnt, (float)cx_time / 1000000, - 1000000 * (double)frame_cnt / (double)cx_time); + printf("Frame cnt and encoding time/FPS stats for encoding: %d %f %f \n", + frame_cnt, + 1000 * (float)cx_time / (double)(frame_cnt * 1000000), + 1000000 * (double)frame_cnt / (double)cx_time); fclose(infile); |