From: Johann Date: Wed, 14 Mar 2018 00:37:28 +0000 (-0700) Subject: spatial svc: remove vpx_svc_get_message X-Git-Tag: v1.8.0~807 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0d57f682dfa9a6db2e458daab1722ebf5bcec02;p=platform%2Fupstream%2Flibvpx.git spatial svc: remove vpx_svc_get_message Print error messages as they are encountered. This was the default behavior. Removes a static analysis warning regarding the use of strncat: Null pointer argument in call to string length function As this is the only use of strncat in the library, remove it and the associated public function. Change-Id: Id55305c5a4d65f11da88c3a2203ff824200f526f --- diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index 118fdd7..ba25b71 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -646,7 +646,6 @@ int main(int argc, const char **argv) { struct vpx_usec_timer timer; int64_t cx_time = 0; memset(&svc_ctx, 0, sizeof(svc_ctx)); - svc_ctx.log_print = 1; exec_name = argv[0]; parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg); @@ -772,7 +771,6 @@ int main(int argc, const char **argv) { vpx_usec_timer_mark(&timer); cx_time += vpx_usec_timer_elapsed(&timer); - printf("%s", vpx_svc_get_message(&svc_ctx)); fflush(stdout); if (res != VPX_CODEC_OK) { die_codec(&codec, "Failed to encode frame"); @@ -931,7 +929,7 @@ int main(int argc, const char **argv) { 1000000 * (double)frame_cnt / (double)cx_time); vpx_img_free(&raw); // display average size, psnr - printf("%s", vpx_svc_dump_statistics(&svc_ctx)); + vpx_svc_dump_statistics(&svc_ctx); vpx_svc_release(&svc_ctx); return EXIT_SUCCESS; } diff --git a/vpx/exports_spatial_svc b/vpx/exports_spatial_svc index d258a1d..9d60cb6 100644 --- a/vpx/exports_spatial_svc +++ b/vpx/exports_spatial_svc @@ -1,6 +1,5 @@ text vpx_svc_dump_statistics text vpx_svc_encode -text vpx_svc_get_message text vpx_svc_init text vpx_svc_release text vpx_svc_set_options diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c index f633600..d883009 100644 --- a/vpx/src/svc_encodeframe.c +++ b/vpx/src/svc_encodeframe.c @@ -95,17 +95,11 @@ static const SvcInternal_t *get_const_svc_internal(const SvcContext *svc_ctx) { return (const SvcInternal_t *)svc_ctx->internal; } -static void svc_log_reset(SvcContext *svc_ctx) { - SvcInternal_t *const si = (SvcInternal_t *)svc_ctx->internal; - si->message_buffer[0] = '\0'; -} - static int svc_log(SvcContext *svc_ctx, SVC_LOG_LEVEL level, const char *fmt, ...) { char buf[512]; int retval = 0; va_list ap; - SvcInternal_t *const si = get_svc_internal(svc_ctx); if (level > svc_ctx->log_level) { return retval; @@ -115,16 +109,8 @@ static int svc_log(SvcContext *svc_ctx, SVC_LOG_LEVEL level, const char *fmt, retval = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - if (svc_ctx->log_print) { - printf("%s", buf); - } else { - strncat(si->message_buffer, buf, - sizeof(si->message_buffer) - strlen(si->message_buffer) - 1); - } + printf("%s", buf); - if (level == SVC_LOG_ERROR) { - si->codec_ctx->err_detail = si->message_buffer; - } return retval; } @@ -548,8 +534,6 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, return VPX_CODEC_INVALID_PARAM; } - svc_log_reset(svc_ctx); - res = vpx_codec_encode(codec_ctx, rawimg, pts, (uint32_t)duration, 0, deadline); if (res != VPX_CODEC_OK) { @@ -619,19 +603,13 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, return VPX_CODEC_OK; } -const char *vpx_svc_get_message(const SvcContext *svc_ctx) { - const SvcInternal_t *const si = get_const_svc_internal(svc_ctx); - if (svc_ctx == NULL || si == NULL) return NULL; - return si->message_buffer; -} - static double calc_psnr(double d) { if (d == 0) return 100; return -10.0 * log(d) / log(10.0); } // dump accumulated statistics and reset accumulated values -const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) { +void vpx_svc_dump_statistics(SvcContext *svc_ctx) { int number_of_frames; int i, j; uint32_t bytes_total = 0; @@ -641,12 +619,10 @@ const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) { double y_scale; SvcInternal_t *const si = get_svc_internal(svc_ctx); - if (svc_ctx == NULL || si == NULL) return NULL; - - svc_log_reset(svc_ctx); + if (svc_ctx == NULL || si == NULL) return; number_of_frames = si->psnr_pkt_received; - if (number_of_frames <= 0) return vpx_svc_get_message(svc_ctx); + if (number_of_frames <= 0) return; svc_log(svc_ctx, SVC_LOG_INFO, "\n"); for (i = 0; i < svc_ctx->spatial_layers; ++i) { @@ -686,7 +662,6 @@ const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) { si->psnr_pkt_received = 0; svc_log(svc_ctx, SVC_LOG_INFO, "Total Bytes=[%u]\n", bytes_total); - return vpx_svc_get_message(svc_ctx); } void vpx_svc_release(SvcContext *svc_ctx) { diff --git a/vpx/svc_context.h b/vpx/svc_context.h index 4627850..771db4f 100644 --- a/vpx/svc_context.h +++ b/vpx/svc_context.h @@ -35,10 +35,8 @@ typedef struct { int temporal_layers; // number of temporal layers int temporal_layering_mode; SVC_LOG_LEVEL log_level; // amount of information to display - int log_print; // when set, printf log messages instead of returning the - // message with svc_get_message - int output_rc_stat; // for outputting rc stats - int speed; // speed setting for codec + int output_rc_stat; // for outputting rc stats + int speed; // speed setting for codec int threads; int aqmode; // turns on aq-mode=3 (cyclic_refresh): 0=off, 1=on. // private storage for vpx_svc_encode @@ -71,7 +69,6 @@ typedef struct SvcInternal { int layer; int use_multiple_frame_contexts; - char message_buffer[2048]; vpx_codec_ctx_t *codec_ctx; } SvcInternal_t; @@ -106,12 +103,7 @@ void vpx_svc_release(SvcContext *svc_ctx); /** * dump accumulated statistics and reset accumulated values */ -const char *vpx_svc_dump_statistics(SvcContext *svc_ctx); - -/** - * get status message from previous encode - */ -const char *vpx_svc_get_message(const SvcContext *svc_ctx); +void vpx_svc_dump_statistics(SvcContext *svc_ctx); #ifdef __cplusplus } // extern "C"