From afd0d3eee084ec8dbe24ea39c9d7d992a40ca915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 9 Sep 2015 10:28:45 +0300 Subject: [PATCH] Remove encoderstate dependency from cli module. Changes function print_frame_info to use a kvz_frame_info struct to get the data to be printed. --- src/cli.c | 27 ++++++++++++--------------- src/cli.h | 4 +++- src/encmain.c | 5 +++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cli.c b/src/cli.c index 3a590df6..689f70a7 100644 --- a/src/cli.c +++ b/src/cli.c @@ -24,7 +24,6 @@ */ #include "cli.h" -#include "encoderstate.h" #include #include @@ -356,28 +355,26 @@ void print_help(void) } -void print_frame_info(encoder_state_t *state, double frame_psnr[3]) +void print_frame_info(const kvz_frame_info *const info, + const double frame_psnr[3], + const uint32_t bytes) { fprintf(stderr, "POC %4d QP %2d (%c-frame) %10d bits PSNR: %2.4f %2.4f %2.4f", - state->global->poc, - state->global->QP, - "BPI"[state->global->slicetype % 3], state->stats_bitstream_length << 3, + info->poc, + info->qp, + "BPI"[info->slice_type % 3], + bytes << 3, frame_psnr[0], frame_psnr[1], frame_psnr[2]); - if (state->global->slicetype != KVZ_SLICE_I) { + if (info->slice_type != KVZ_SLICE_I) { // Print reference picture lists - int ref_list_len[2]; - int ref_list_poc[2][16]; - - kvz_encoder_get_ref_lists(state, ref_list_len, ref_list_poc); - fprintf(stderr, " [L0 "); - for (int j = ref_list_len[0] - 1; j >= 0; j--) { - fprintf(stderr, "%d ", ref_list_poc[0][j]); + for (int j = info->ref_list_len[0] - 1; j >= 0; j--) { + fprintf(stderr, "%d ", info->ref_list[0][j]); } fprintf(stderr, "] [L1 "); - for (int j = 0; j < ref_list_len[1]; j++) { - fprintf(stderr, "%d ", ref_list_poc[1][j]); + for (int j = 0; j < info->ref_list_len[1]; j++) { + fprintf(stderr, "%d ", info->ref_list[1][j]); } fprintf(stderr, "]"); } diff --git a/src/cli.h b/src/cli.h index 190fe73f..f2dc82a7 100644 --- a/src/cli.h +++ b/src/cli.h @@ -49,6 +49,8 @@ void cmdline_opts_free(const kvz_api *api, cmdline_opts_t *opts); void print_version(void); void print_help(void); -void print_frame_info(encoder_state_t *state, double frame_psnr[3]); +void print_frame_info(const kvz_frame_info *const info, + const double frame_psnr[3], + const uint32_t bytes); #endif diff --git a/src/encmain.c b/src/encmain.c index 58356b99..170be23c 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -212,7 +212,8 @@ int main(int argc, char *argv[]) kvz_data_chunk* chunks_out = NULL; kvz_picture *img_rec = NULL; uint32_t len_out = 0; - if (!api->encoder_encode(enc, img_in, &chunks_out, &len_out, &img_rec, NULL)) { + kvz_frame_info info_out; + if (!api->encoder_encode(enc, img_in, &chunks_out, &len_out, &img_rec, &info_out)) { fprintf(stderr, "Failed to encode image.\n"); api->picture_free(img_in); goto exit_failure; @@ -269,7 +270,7 @@ int main(int argc, char *argv[]) psnr_sum[1] += frame_psnr[1]; psnr_sum[2] += frame_psnr[2]; - print_frame_info(state, frame_psnr); + print_frame_info(&info_out, frame_psnr, len_out); } api->picture_free(img_in);