| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 if (svc_ctx->threads) | 470 if (svc_ctx->threads) |
| 471 enc_cfg->g_threads = svc_ctx->threads; | 471 enc_cfg->g_threads = svc_ctx->threads; |
| 472 | 472 |
| 473 // Modify encoder configuration | 473 // Modify encoder configuration |
| 474 enc_cfg->ss_number_layers = svc_ctx->spatial_layers; | 474 enc_cfg->ss_number_layers = svc_ctx->spatial_layers; |
| 475 enc_cfg->ts_number_layers = svc_ctx->temporal_layers; | 475 enc_cfg->ts_number_layers = svc_ctx->temporal_layers; |
| 476 | 476 |
| 477 if (enc_cfg->rc_end_usage == VPX_CBR) { | 477 if (enc_cfg->rc_end_usage == VPX_CBR) { |
| 478 enc_cfg->rc_resize_allowed = 0; | 478 enc_cfg->rc_resize_allowed = 0; |
| 479 enc_cfg->rc_min_quantizer = 2; | 479 enc_cfg->rc_min_quantizer = 2; |
| 480 enc_cfg->rc_max_quantizer = 63; | 480 enc_cfg->rc_max_quantizer = 56; |
| 481 enc_cfg->rc_undershoot_pct = 50; | 481 enc_cfg->rc_undershoot_pct = 50; |
| 482 enc_cfg->rc_overshoot_pct = 50; | 482 enc_cfg->rc_overshoot_pct = 50; |
| 483 enc_cfg->rc_buf_initial_sz = 20; | 483 enc_cfg->rc_buf_initial_sz = 500; |
| 484 enc_cfg->rc_buf_optimal_sz = 600; | 484 enc_cfg->rc_buf_optimal_sz = 600; |
| 485 enc_cfg->rc_buf_sz = 1000; | 485 enc_cfg->rc_buf_sz = 1000; |
| 486 } | 486 } |
| 487 | 487 |
| 488 if (enc_cfg->g_error_resilient == 0 && si->use_multiple_frame_contexts == 0) | 488 if (enc_cfg->g_error_resilient == 0 && si->use_multiple_frame_contexts == 0) |
| 489 enc_cfg->g_error_resilient = 1; | 489 enc_cfg->g_error_resilient = 1; |
| 490 | 490 |
| 491 // Initialize codec | 491 // Initialize codec |
| 492 res = vpx_codec_enc_init(codec_ctx, iface, enc_cfg, VPX_CODEC_USE_PSNR); | 492 res = vpx_codec_enc_init(codec_ctx, iface, enc_cfg, VPX_CODEC_USE_PSNR); |
| 493 if (res != VPX_CODEC_OK) { | 493 if (res != VPX_CODEC_OK) { |
| 494 svc_log(svc_ctx, SVC_LOG_ERROR, "svc_enc_init error\n"); | 494 svc_log(svc_ctx, SVC_LOG_ERROR, "svc_enc_init error\n"); |
| 495 return res; | 495 return res; |
| 496 } | 496 } |
| 497 | 497 if (svc_ctx->spatial_layers > 1 || svc_ctx->temporal_layers > 1) { |
| 498 vpx_codec_control(codec_ctx, VP9E_SET_SVC, 1); | 498 vpx_codec_control(codec_ctx, VP9E_SET_SVC, 1); |
| 499 vpx_codec_control(codec_ctx, VP9E_SET_SVC_PARAMETERS, &si->svc_params); | 499 vpx_codec_control(codec_ctx, VP9E_SET_SVC_PARAMETERS, &si->svc_params); |
| 500 | 500 } |
| 501 return VPX_CODEC_OK; | 501 return VPX_CODEC_OK; |
| 502 } | 502 } |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * Encode a frame into multiple layers | 505 * Encode a frame into multiple layers |
| 506 * Create a superframe containing the individual layers | 506 * Create a superframe containing the individual layers |
| 507 */ | 507 */ |
| 508 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, | 508 vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, |
| 509 vpx_codec_ctx_t *codec_ctx, | 509 vpx_codec_ctx_t *codec_ctx, |
| 510 struct vpx_image *rawimg, | 510 struct vpx_image *rawimg, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 if (svc_ctx == NULL) return; | 654 if (svc_ctx == NULL) return; |
| 655 // do not use get_svc_internal as it will unnecessarily allocate an | 655 // do not use get_svc_internal as it will unnecessarily allocate an |
| 656 // SvcInternal_t if it was not already allocated | 656 // SvcInternal_t if it was not already allocated |
| 657 si = (SvcInternal_t *)svc_ctx->internal; | 657 si = (SvcInternal_t *)svc_ctx->internal; |
| 658 if (si != NULL) { | 658 if (si != NULL) { |
| 659 free(si); | 659 free(si); |
| 660 svc_ctx->internal = NULL; | 660 svc_ctx->internal = NULL; |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 | 663 |
| OLD | NEW |