ref: b0d57f682dfa9a6db2e458daab1722ebf5bcec02
parent: 6f9163db9518fb7af6d35960c6f365c92a749807
author: Johann <johannkoenig@google.com>
date: Tue Mar 13 13:37:28 EDT 2018
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
--- a/examples/vp9_spatial_svc_encoder.c
+++ b/examples/vp9_spatial_svc_encoder.c
@@ -646,7 +646,6 @@
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 @@
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 @@
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;
}
--- 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
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -95,17 +95,11 @@
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 @@
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 @@
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,12 +603,6 @@
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);
@@ -631,7 +609,7 @@
}
// 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 @@
double y_scale;
SvcInternal_t *const si = get_svc_internal(svc_ctx);
- if (svc_ctx == NULL || si == NULL) return NULL;
+ if (svc_ctx == NULL || si == NULL) return;
- svc_log_reset(svc_ctx);
-
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 @@
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) {
--- a/vpx/svc_context.h
+++ b/vpx/svc_context.h
@@ -35,10 +35,8 @@
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 @@
int layer;
int use_multiple_frame_contexts;
- char message_buffer[2048];
vpx_codec_ctx_t *codec_ctx;
} SvcInternal_t;
@@ -106,12 +103,7 @@
/**
* 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"