Lines Matching defs:svc_ctx

215 static SvcInternal *get_svc_internal(SvcContext *svc_ctx) {
216 if (svc_ctx == NULL) return NULL;
217 if (svc_ctx->internal == NULL) {
222 svc_ctx->internal = si;
224 return (SvcInternal *)svc_ctx->internal;
227 static const SvcInternal *get_const_svc_internal(const SvcContext *svc_ctx) {
228 if (svc_ctx == NULL) return NULL;
229 return (const SvcInternal *)svc_ctx->internal;
232 static void svc_log_reset(SvcContext *svc_ctx) {
233 SvcInternal *const si = (SvcInternal *)svc_ctx->internal;
237 static int svc_log(SvcContext *svc_ctx, SVC_LOG_LEVEL level,
242 SvcInternal *const si = get_svc_internal(svc_ctx);
244 if (level > svc_ctx->log_level) {
252 if (svc_ctx->log_print) {
265 static vpx_codec_err_t set_option_encoding_mode(SvcContext *svc_ctx,
268 svc_ctx->encoding_mode = INTER_LAYER_PREDICTION_I;
270 svc_ctx->encoding_mode = ALT_INTER_LAYER_PREDICTION_IP;
272 svc_ctx->encoding_mode = INTER_LAYER_PREDICTION_IP;
274 svc_ctx->encoding_mode = USE_GOLDEN_FRAME;
276 svc_log(svc_ctx, SVC_LOG_ERROR, "invalid encoding mode: %s", value_str);
282 static vpx_codec_err_t parse_quantizer_values(SvcContext *svc_ctx,
292 SvcInternal *const si = get_svc_internal(svc_ctx);
306 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
310 svc_log(svc_ctx, SVC_LOG_ERROR,
321 si->quantizer_keyframe[i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers]
324 si->quantizer[i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers] = q;
327 if (res == VPX_CODEC_OK && found != svc_ctx->spatial_layers) {
328 svc_log(svc_ctx, SVC_LOG_ERROR,
330 svc_ctx->spatial_layers, found);
337 static void log_invalid_scale_factor(SvcContext *svc_ctx, const char *value) {
338 svc_log(svc_ctx, SVC_LOG_ERROR, "svc scale-factors: invalid value %s\n",
342 static vpx_codec_err_t parse_scale_factors(SvcContext *svc_ctx,
352 SvcInternal *const si = get_svc_internal(svc_ctx);
360 for (i = 0; i < svc_ctx->spatial_layers; ++i) {
365 log_invalid_scale_factor(svc_ctx, token);
370 log_invalid_scale_factor(svc_ctx, token);
376 log_invalid_scale_factor(svc_ctx, token);
383 si->scaling_factor_num[i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers] =
385 si->scaling_factor_den[i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers] =
388 if (res == VPX_CODEC_OK && found != svc_ctx->spatial_layers) {
389 svc_log(svc_ctx, SVC_LOG_ERROR,
391 svc_ctx->spatial_layers, found);
405 static vpx_codec_err_t parse_options(SvcContext *svc_ctx, const char *options) {
422 svc_log(svc_ctx, SVC_LOG_ERROR, "option missing value: %s\n",
428 res = set_option_encoding_mode(svc_ctx, option_value);
431 svc_ctx->spatial_layers = atoi(option_value);
433 res = parse_scale_factors(svc_ctx, option_value);
436 res = parse_quantizer_values(svc_ctx, option_value, 0);
439 SvcInternal *const si = get_svc_internal(svc_ctx);
440 memcpy(get_svc_internal(svc_ctx)->quantizer_keyframe, si->quantizer,
444 res = parse_quantizer_values(svc_ctx, option_value, 1);
448 svc_log(svc_ctx, SVC_LOG_ERROR, "invalid option: %s\n", option_name);
458 vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options) {
459 SvcInternal *const si = get_svc_internal(svc_ctx);
460 if (svc_ctx == NULL || options == NULL || si == NULL) {
468 vpx_codec_err_t vpx_svc_set_quantizers(SvcContext *svc_ctx,
471 SvcInternal *const si = get_svc_internal(svc_ctx);
472 if (svc_ctx == NULL || quantizers == NULL || si == NULL) {
485 vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx,
487 SvcInternal *const si = get_svc_internal(svc_ctx);
488 if (svc_ctx == NULL || scale_factors == NULL || si == NULL) {
496 vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
501 SvcInternal *const si = get_svc_internal(svc_ctx);
502 if (svc_ctx == NULL || codec_ctx == NULL || iface == NULL ||
514 svc_log(svc_ctx, SVC_LOG_ERROR, "key frame distance too small: %d\n",
520 if (svc_ctx->spatial_layers == 0)
521 svc_ctx->spatial_layers = VPX_SS_DEFAULT_LAYERS;
522 if (svc_ctx->spatial_layers < 1 ||
523 svc_ctx->spatial_layers > VPX_SS_MAX_LAYERS) {
524 svc_log(svc_ctx, SVC_LOG_ERROR, "spatial layers: invalid value: %d\n",
525 svc_ctx->spatial_layers);
529 res = parse_quantizer_values(svc_ctx, si->quantizers, 0);
532 res = parse_quantizer_values(svc_ctx, si->quantizers_keyframe, 1);
536 res = parse_scale_factors(svc_ctx, si->scale_factors);
541 res = parse_options(svc_ctx, si->options);
544 si->layers = svc_ctx->spatial_layers;
557 int pos = i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers;
603 svc_log(svc_ctx, SVC_LOG_ERROR, "svc_enc_init error\n");
666 static void calculate_enc_frame_flags(SvcContext *svc_ctx) {
668 SvcInternal *const si = get_svc_internal(svc_ctx);
677 switch (svc_ctx->encoding_mode) {
729 svc_log(svc_ctx, SVC_LOG_ERROR, "unexpected encoding mode: %d\n",
730 svc_ctx->encoding_mode);
736 vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx,
741 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
743 if (svc_ctx == NULL || si == NULL || width == NULL || height == NULL) {
766 static void set_svc_parameters(SvcContext *svc_ctx,
770 SvcInternal *const si = get_svc_internal(svc_ctx);
778 if (svc_ctx->encoding_mode == ALT_INTER_LAYER_PREDICTION_IP &&
785 if (VPX_CODEC_OK != vpx_svc_get_layer_resolution(svc_ctx, layer,
788 svc_log(svc_ctx, SVC_LOG_ERROR, "vpx_svc_get_layer_resolution failed\n");
793 if (vpx_svc_is_keyframe(svc_ctx)) {
813 svc_ctx->encoding_mode == ALT_INTER_LAYER_PREDICTION_IP &&
818 if (svc_ctx->encoding_mode == ALT_INTER_LAYER_PREDICTION_IP) {
827 svc_log(svc_ctx, SVC_LOG_DEBUG, "SVC frame: %d, layer: %d, %dx%d, q: %d\n",
832 svc_log(svc_ctx, SVC_LOG_DEBUG, "flags == VPX_EFLAG_FORCE_KF\n");
835 svc_ctx, SVC_LOG_DEBUG, "Using: LST/GLD/ALT [%2d|%2d|%2d]\n",
840 svc_ctx, SVC_LOG_DEBUG, "Updating: LST/GLD/ALT [%2d|%2d|%2d]\n",
853 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
862 SvcInternal *const si = get_svc_internal(svc_ctx);
863 if (svc_ctx == NULL || codec_ctx == NULL || si == NULL) {
868 svc_log_reset(svc_ctx);
871 si->layers = svc_ctx->spatial_layers;
880 svc_log(svc_ctx, SVC_LOG_DEBUG,
888 if (svc_ctx->encoding_mode == ALT_INTER_LAYER_PREDICTION_IP &&
890 svc_log(svc_ctx, SVC_LOG_DEBUG, "Skip encoding layer %d\n", si->layer);
895 calculate_enc_frame_flags(svc_ctx);
896 set_svc_parameters(svc_ctx, codec_ctx);
911 svc_log(svc_ctx, SVC_LOG_DEBUG,
917 svc_log(svc_ctx, SVC_LOG_ERROR, "Error allocating LayerData\n");
929 svc_log(svc_ctx, SVC_LOG_DEBUG,
935 svc_log(svc_ctx, SVC_LOG_DEBUG,
954 svc_log(svc_ctx, SVC_LOG_ERROR, "Error allocating stats buf\n");
999 svc_log(svc_ctx, SVC_LOG_DEBUG, "SVC frame: %d, kf: %d, size: %d, "
1012 const char *vpx_svc_get_message(const SvcContext *svc_ctx) {
1013 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1014 if (svc_ctx == NULL || si == NULL) return NULL;
1018 void *vpx_svc_get_buffer(const SvcContext *svc_ctx) {
1019 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1020 if (svc_ctx == NULL || si == NULL) return NULL;
1024 size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx) {
1025 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1026 if (svc_ctx == NULL || si == NULL) return 0;
1030 int vpx_svc_get_encode_frame_count(const SvcContext *svc_ctx) {
1031 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1032 if (svc_ctx == NULL || si == NULL) return 0;
1036 int vpx_svc_is_keyframe(const SvcContext *svc_ctx) {
1037 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1038 if (svc_ctx == NULL || si == NULL) return 0;
1042 void vpx_svc_set_keyframe(SvcContext *svc_ctx) {
1043 SvcInternal *const si = get_svc_internal(svc_ctx);
1044 if (svc_ctx == NULL || si == NULL) return;
1054 const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) {
1063 SvcInternal *const si = get_svc_internal(svc_ctx);
1064 if (svc_ctx == NULL || si == NULL) return NULL;
1066 svc_log_reset(svc_ctx);
1069 if (si->encode_frame_count <= 0) return vpx_svc_get_message(svc_ctx);
1071 svc_log(svc_ctx, SVC_LOG_INFO, "\n");
1076 if (svc_ctx->encoding_mode == ALT_INTER_LAYER_PREDICTION_IP &&
1080 svc_log(svc_ctx, SVC_LOG_INFO,
1096 svc_log(svc_ctx, SVC_LOG_INFO,
1099 svc_log(svc_ctx, SVC_LOG_INFO,
1115 svc_log(svc_ctx, SVC_LOG_INFO, "Total Bytes=[%u]\n", bytes_total);
1116 return vpx_svc_get_message(svc_ctx);
1119 void vpx_svc_release(SvcContext *svc_ctx) {
1121 if (svc_ctx == NULL) return;
1124 si = (SvcInternal *)svc_ctx->internal;
1131 svc_ctx->internal = NULL;
1135 size_t vpx_svc_get_rc_stats_buffer_size(const SvcContext *svc_ctx) {
1136 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1137 if (svc_ctx == NULL || si == NULL) return 0;
1141 char *vpx_svc_get_rc_stats_buffer(const SvcContext *svc_ctx) {
1142 const SvcInternal *const si = get_const_svc_internal(svc_ctx);
1143 if (svc_ctx == NULL || si == NULL) return NULL;