diff options
Diffstat (limited to 'vpx')
-rw-r--r-- | vpx/exports_enc | 2 | ||||
-rw-r--r-- | vpx/src/svc_encodeframe.c | 42 | ||||
-rw-r--r-- | vpx/svc_context.h | 11 |
3 files changed, 54 insertions, 1 deletions
diff --git a/vpx/exports_enc b/vpx/exports_enc index 99b1bfacc..155faf6f6 100644 --- a/vpx/exports_enc +++ b/vpx/exports_enc @@ -21,3 +21,5 @@ text vpx_svc_set_options text vpx_svc_set_quantizers text vpx_svc_set_scale_factors text vpx_svc_get_layer_resolution +text vpx_svc_get_rc_stats_buffer_size +text vpx_svc_get_rc_stats_buffer
\ No newline at end of file diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c index c7837244f..3e22fdf38 100644 --- a/vpx/src/svc_encodeframe.c +++ b/vpx/src/svc_encodeframe.c @@ -81,6 +81,10 @@ typedef struct SvcInternal { size_t buffer_size; void *buffer; + char *rc_stats_buf; + size_t rc_stats_buf_size; + size_t rc_stats_buf_used; + char message_buffer[2048]; vpx_codec_ctx_t *codec_ctx; } SvcInternal; @@ -569,7 +573,6 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, enc_cfg->ss_number_layers = si->layers; enc_cfg->ts_number_layers = 1; // Temporal layers not used in this encoder. enc_cfg->kf_mode = VPX_KF_DISABLED; - enc_cfg->g_pass = VPX_RC_ONE_PASS; // Lag in frames not currently supported enc_cfg->g_lag_in_frames = 0; @@ -851,6 +854,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, memset(&superframe, 0, sizeof(superframe)); svc_log_reset(svc_ctx); + si->rc_stats_buf_used = 0; si->layers = svc_ctx->spatial_layers; if (si->frame_within_gop >= si->kf_dist || @@ -923,6 +927,25 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, } break; } + case VPX_CODEC_STATS_PKT: { + size_t new_size = si->rc_stats_buf_used + + cx_pkt->data.twopass_stats.sz; + + if (new_size > si->rc_stats_buf_size) { + char *p = (char*)realloc(si->rc_stats_buf, new_size); + if (p == NULL) { + svc_log(svc_ctx, SVC_LOG_ERROR, "Error allocating stats buf\n"); + break; + } + si->rc_stats_buf = p; + si->rc_stats_buf_size = new_size; + } + + memcpy(si->rc_stats_buf + si->rc_stats_buf_used, + cx_pkt->data.twopass_stats.buf, cx_pkt->data.twopass_stats.sz); + si->rc_stats_buf_used += cx_pkt->data.twopass_stats.sz; + break; + } default: { break; } @@ -1077,7 +1100,24 @@ void vpx_svc_release(SvcContext *svc_ctx) { si = (SvcInternal *)svc_ctx->internal; if (si != NULL) { free(si->buffer); + if (si->rc_stats_buf) { + free(si->rc_stats_buf); + } free(si); svc_ctx->internal = NULL; } } + +size_t vpx_svc_get_rc_stats_buffer_size(const SvcContext *svc_ctx) { + const SvcInternal *const si = get_const_svc_internal(svc_ctx); + if (svc_ctx == NULL || si == NULL) return 0; + return si->rc_stats_buf_used; +} + +char *vpx_svc_get_rc_stats_buffer(const SvcContext *svc_ctx) { + const SvcInternal *const si = get_const_svc_internal(svc_ctx); + if (svc_ctx == NULL || si == NULL) return NULL; + return si->rc_stats_buf; +} + + diff --git a/vpx/svc_context.h b/vpx/svc_context.h index 98474ca91..5d0fbbd77 100644 --- a/vpx/svc_context.h +++ b/vpx/svc_context.h @@ -114,6 +114,17 @@ size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx); void *vpx_svc_get_buffer(const SvcContext *svc_ctx); /** + * return size of two pass rate control stats data to be returned by + * vpx_svc_get_rc_stats_buffer + */ +size_t vpx_svc_get_rc_stats_buffer_size(const SvcContext *svc_ctx); + +/** + * return buffer two pass of rate control stats data + */ +char *vpx_svc_get_rc_stats_buffer(const SvcContext *svc_ctx); + +/** * return spatial resolution of the specified layer */ vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx, |