Lines Matching defs:svc_ctx

82 static SvcInternal_t *get_svc_internal(SvcContext *svc_ctx) {
83 if (svc_ctx == NULL) return NULL;
84 if (svc_ctx->internal == NULL) {
89 svc_ctx->internal = si;
91 return (SvcInternal_t *)svc_ctx->internal;
95 const SvcContext *svc_ctx) {
96 if (svc_ctx == NULL) return NULL;
97 return (const SvcInternal_t *)svc_ctx->internal;
100 static void svc_log_reset(SvcContext *svc_ctx) {
101 SvcInternal_t *const si = (SvcInternal_t *)svc_ctx->internal;
105 static int svc_log(SvcContext *svc_ctx, SVC_LOG_LEVEL level,
110 SvcInternal_t *const si = get_svc_internal(svc_ctx);
112 if (level > svc_ctx->log_level) {
120 if (svc_ctx->log_print) {
158 static vpx_codec_err_t parse_layer_options_from_string(SvcContext *svc_ctx,
176 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
186 if (res == VPX_CODEC_OK && i != svc_ctx->spatial_layers) {
187 svc_log(svc_ctx, SVC_LOG_ERROR,
189 "but only %d specified\n", type, svc_ctx->spatial_layers, i);
203 static vpx_codec_err_t parse_options(SvcContext *svc_ctx, const char *options) {
208 SvcInternal_t *const si = get_svc_internal(svc_ctx);
221 svc_log(svc_ctx, SVC_LOG_ERROR, "option missing value: %s\n",
227 svc_ctx->spatial_layers = atoi(option_value);
229 svc_ctx->temporal_layers = atoi(option_value);
231 res = parse_layer_options_from_string(svc_ctx, SCALE_FACTOR, option_value,
236 res = parse_layer_options_from_string(svc_ctx, QUANTIZER, option_value,
241 res = parse_layer_options_from_string(svc_ctx, QUANTIZER, option_value,
246 res = parse_layer_options_from_string(svc_ctx, AUTO_ALT_REF, option_value,
250 res = parse_layer_options_from_string(svc_ctx, BITRATE, option_value,
256 svc_log(svc_ctx, SVC_LOG_ERROR, "invalid option: %s\n", option_name);
264 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
273 (svc_ctx->spatial_layers > 3 ||
274 svc_ctx->spatial_layers * svc_ctx->temporal_layers > 4))
277 for (i = 0; i < svc_ctx->spatial_layers; ++i)
279 if (alt_ref_enabled > REF_FRAMES - svc_ctx->spatial_layers) {
280 svc_log(svc_ctx, SVC_LOG_ERROR,
283 REF_FRAMES - svc_ctx->spatial_layers, alt_ref_enabled);
290 vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx,
292 SvcInternal_t *const si = get_svc_internal(svc_ctx);
293 if (svc_ctx == NULL || options == NULL || si == NULL) {
301 void assign_layer_bitrates(const SvcContext *svc_ctx,
304 const SvcInternal_t *const si = get_const_svc_internal(svc_ctx);
307 if (svc_ctx->temporal_layering_mode != 0) {
310 for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
311 enc_cfg->ss_target_bitrate[sl*svc_ctx->temporal_layers] = 0;
312 for (tl = 0; tl < svc_ctx->temporal_layers; ++tl) {
313 enc_cfg->ss_target_bitrate[sl*svc_ctx->temporal_layers]
314 += (unsigned int)si->bitrates[sl * svc_ctx->temporal_layers + tl];
315 enc_cfg->layer_target_bitrate[sl*svc_ctx->temporal_layers + tl]
316 = si->bitrates[sl * svc_ctx->temporal_layers + tl];
323 for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
331 for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
335 if (svc_ctx->temporal_layering_mode == 3) {
336 enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers] =
338 enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers + 1] =
340 enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers + 2] =
342 } else if (svc_ctx->temporal_layering_mode == 2) {
343 enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers] =
345 enc_cfg->layer_target_bitrate[sl * svc_ctx->temporal_layers + 1] =
356 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
364 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
383 vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
388 SvcInternal_t *const si = get_svc_internal(svc_ctx);
389 if (svc_ctx == NULL || codec_ctx == NULL || iface == NULL ||
401 svc_log(svc_ctx, SVC_LOG_ERROR, "key frame distance too small: %d\n",
407 if (svc_ctx->spatial_layers == 0)
408 svc_ctx->spatial_layers = VPX_SS_DEFAULT_LAYERS;
409 if (svc_ctx->spatial_layers < 1 ||
410 svc_ctx->spatial_layers > VPX_SS_MAX_LAYERS) {
411 svc_log(svc_ctx, SVC_LOG_ERROR, "spatial layers: invalid value: %d\n",
412 svc_ctx->spatial_layers);
417 // si->svc_params.temporal_layering_mode = svc_ctx->temporal_layering_mode;
418 if (svc_ctx->temporal_layering_mode == 3) {
419 svc_ctx->temporal_layers = 3;
420 } else if (svc_ctx->temporal_layering_mode == 2) {
421 svc_ctx->temporal_layers = 2;
433 res = parse_options(svc_ctx, si->options);
436 if (svc_ctx->spatial_layers < 1)
437 svc_ctx->spatial_layers = 1;
438 if (svc_ctx->spatial_layers > VPX_SS_MAX_LAYERS)
439 svc_ctx->spatial_layers = VPX_SS_MAX_LAYERS;
441 if (svc_ctx->temporal_layers < 1)
442 svc_ctx->temporal_layers = 1;
443 if (svc_ctx->temporal_layers > VPX_TS_MAX_LAYERS)
444 svc_ctx->temporal_layers = VPX_TS_MAX_LAYERS;
446 if (svc_ctx->temporal_layers * svc_ctx->spatial_layers > VPX_MAX_LAYERS) {
447 svc_log(svc_ctx, SVC_LOG_ERROR,
450 svc_ctx->spatial_layers * svc_ctx->temporal_layers,
454 assign_layer_bitrates(svc_ctx, enc_cfg);
457 for (i = 0; i < svc_ctx->spatial_layers; ++i)
461 if (svc_ctx->temporal_layers > 1) {
463 for (i = 0; i < svc_ctx->temporal_layers; ++i) {
465 svc_ctx->temporal_layers;
466 enc_cfg->ts_rate_decimator[i] = 1 << (svc_ctx->temporal_layers - 1 - i);
470 if (svc_ctx->threads)
471 enc_cfg->g_threads = svc_ctx->threads;
474 enc_cfg->ss_number_layers = svc_ctx->spatial_layers;
475 enc_cfg->ts_number_layers = svc_ctx->temporal_layers;
494 svc_log(svc_ctx, SVC_LOG_ERROR, "svc_enc_init error\n");
508 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx,
516 SvcInternal_t *const si = get_svc_internal(svc_ctx);
517 if (svc_ctx == NULL || codec_ctx == NULL || si == NULL) {
521 svc_log_reset(svc_ctx);
536 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
538 svc_log(svc_ctx, SVC_LOG_DEBUG,
546 svc_log(svc_ctx, SVC_LOG_DEBUG,
566 for (i = 0; i < svc_ctx->spatial_layers; ++i)
581 const char *vpx_svc_get_message(const SvcContext *svc_ctx) {
582 const SvcInternal_t *const si = get_const_svc_internal(svc_ctx);
583 if (svc_ctx == NULL || si == NULL) return NULL;
593 const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) {
602 SvcInternal_t *const si = get_svc_internal(svc_ctx);
603 if (svc_ctx == NULL || si == NULL) return NULL;
605 svc_log_reset(svc_ctx);
608 if (number_of_frames <= 0) return vpx_svc_get_message(svc_ctx);
610 svc_log(svc_ctx, SVC_LOG_INFO, "\n");
611 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
613 svc_log(svc_ctx, SVC_LOG_INFO,
629 svc_log(svc_ctx, SVC_LOG_INFO,
632 svc_log(svc_ctx, SVC_LOG_INFO,
648 svc_log(svc_ctx, SVC_LOG_INFO, "Total Bytes=[%u]\n", bytes_total);
649 return vpx_svc_get_message(svc_ctx);
652 void vpx_svc_release(SvcContext *svc_ctx) {
654 if (svc_ctx == NULL) return;
657 si = (SvcInternal_t *)svc_ctx->internal;
660 svc_ctx->internal = NULL;