| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 | 13 |
| 14 #include "./vpx_config.h" | 14 #include "./vpx_config.h" |
| 15 #include "vpx/vpx_codec.h" | 15 #include "vpx/vpx_encoder.h" |
| 16 #include "vpx_ports/vpx_once.h" | 16 #include "vpx_ports/vpx_once.h" |
| 17 #include "vpx/internal/vpx_codec_internal.h" | 17 #include "vpx/internal/vpx_codec_internal.h" |
| 18 #include "./vpx_version.h" | 18 #include "./vpx_version.h" |
| 19 #include "vp9/encoder/vp9_encoder.h" | 19 #include "vp9/encoder/vp9_encoder.h" |
| 20 #include "vpx/vp8cx.h" | 20 #include "vpx/vp8cx.h" |
| 21 #include "vp9/encoder/vp9_firstpass.h" | 21 #include "vp9/encoder/vp9_firstpass.h" |
| 22 #include "vp9/vp9_iface_common.h" | 22 #include "vp9/vp9_iface_common.h" |
| 23 | 23 |
| 24 struct vp9_extracfg { | 24 struct vp9_extracfg { |
| 25 int cpu_used; // available cpu percentage in 1/16 | 25 int cpu_used; // available cpu percentage in 1/16 |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 } | 1291 } |
| 1292 return VPX_CODEC_OK; | 1292 return VPX_CODEC_OK; |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 static vpx_codec_err_t ctrl_set_svc_layer_id(vpx_codec_alg_priv_t *ctx, | 1295 static vpx_codec_err_t ctrl_set_svc_layer_id(vpx_codec_alg_priv_t *ctx, |
| 1296 va_list args) { | 1296 va_list args) { |
| 1297 vpx_svc_layer_id_t *const data = va_arg(args, vpx_svc_layer_id_t *); | 1297 vpx_svc_layer_id_t *const data = va_arg(args, vpx_svc_layer_id_t *); |
| 1298 VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; | 1298 VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; |
| 1299 SVC *const svc = &cpi->svc; | 1299 SVC *const svc = &cpi->svc; |
| 1300 | 1300 |
| 1301 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) |
| 1301 svc->spatial_layer_id = data->spatial_layer_id; | 1302 svc->spatial_layer_id = data->spatial_layer_id; |
| 1303 #endif |
| 1302 svc->temporal_layer_id = data->temporal_layer_id; | 1304 svc->temporal_layer_id = data->temporal_layer_id; |
| 1303 // Checks on valid layer_id input. | 1305 // Checks on valid layer_id input. |
| 1304 if (svc->temporal_layer_id < 0 || | 1306 if (svc->temporal_layer_id < 0 || |
| 1305 svc->temporal_layer_id >= (int)ctx->cfg.ts_number_layers) { | 1307 svc->temporal_layer_id >= (int)ctx->cfg.ts_number_layers) { |
| 1306 return VPX_CODEC_INVALID_PARAM; | 1308 return VPX_CODEC_INVALID_PARAM; |
| 1307 } | 1309 } |
| 1308 if (svc->spatial_layer_id < 0 || | 1310 if (svc->spatial_layer_id < 0 || |
| 1309 svc->spatial_layer_id >= (int)ctx->cfg.ss_number_layers) { | 1311 svc->spatial_layer_id >= (int)ctx->cfg.ss_number_layers) { |
| 1310 return VPX_CODEC_INVALID_PARAM; | 1312 return VPX_CODEC_INVALID_PARAM; |
| 1311 } | 1313 } |
| 1312 return VPX_CODEC_OK; | 1314 return VPX_CODEC_OK; |
| 1313 } | 1315 } |
| 1314 | 1316 |
| 1315 static vpx_codec_err_t ctrl_get_svc_layer_id(vpx_codec_alg_priv_t *ctx, | 1317 static vpx_codec_err_t ctrl_get_svc_layer_id(vpx_codec_alg_priv_t *ctx, |
| 1316 va_list args) { | 1318 va_list args) { |
| 1317 vpx_svc_layer_id_t *data = va_arg(args, vpx_svc_layer_id_t *); | 1319 vpx_svc_layer_id_t *data = va_arg(args, vpx_svc_layer_id_t *); |
| 1318 VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; | 1320 VP9_COMP *const cpi = (VP9_COMP *)ctx->cpi; |
| 1319 SVC *const svc = &cpi->svc; | 1321 SVC *const svc = &cpi->svc; |
| 1320 | 1322 |
| 1323 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) |
| 1321 data->spatial_layer_id = svc->spatial_layer_id; | 1324 data->spatial_layer_id = svc->spatial_layer_id; |
| 1325 #endif |
| 1322 data->temporal_layer_id = svc->temporal_layer_id; | 1326 data->temporal_layer_id = svc->temporal_layer_id; |
| 1323 | 1327 |
| 1324 return VPX_CODEC_OK; | 1328 return VPX_CODEC_OK; |
| 1325 } | 1329 } |
| 1326 | 1330 |
| 1327 static vpx_codec_err_t ctrl_set_svc_parameters(vpx_codec_alg_priv_t *ctx, | 1331 static vpx_codec_err_t ctrl_set_svc_parameters(vpx_codec_alg_priv_t *ctx, |
| 1328 va_list args) { | 1332 va_list args) { |
| 1329 VP9_COMP *const cpi = ctx->cpi; | 1333 VP9_COMP *const cpi = ctx->cpi; |
| 1330 vpx_svc_extra_cfg_t *const params = va_arg(args, vpx_svc_extra_cfg_t *); | 1334 vpx_svc_extra_cfg_t *const params = va_arg(args, vpx_svc_extra_cfg_t *); |
| 1331 int i; | 1335 int i; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 {VP8E_SET_TUNING, ctrl_set_tuning}, | 1394 {VP8E_SET_TUNING, ctrl_set_tuning}, |
| 1391 {VP8E_SET_CQ_LEVEL, ctrl_set_cq_level}, | 1395 {VP8E_SET_CQ_LEVEL, ctrl_set_cq_level}, |
| 1392 {VP8E_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_rc_max_intra_bitrate_pct}, | 1396 {VP8E_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_rc_max_intra_bitrate_pct}, |
| 1393 {VP9E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct}, | 1397 {VP9E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct}, |
| 1394 {VP9E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct}, | 1398 {VP9E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct}, |
| 1395 {VP9E_SET_LOSSLESS, ctrl_set_lossless}, | 1399 {VP9E_SET_LOSSLESS, ctrl_set_lossless}, |
| 1396 {VP9E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode}, | 1400 {VP9E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode}, |
| 1397 {VP9E_SET_AQ_MODE, ctrl_set_aq_mode}, | 1401 {VP9E_SET_AQ_MODE, ctrl_set_aq_mode}, |
| 1398 {VP9E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost}, | 1402 {VP9E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost}, |
| 1399 {VP9E_SET_SVC, ctrl_set_svc}, | 1403 {VP9E_SET_SVC, ctrl_set_svc}, |
| 1404 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) |
| 1400 {VP9E_SET_SVC_PARAMETERS, ctrl_set_svc_parameters}, | 1405 {VP9E_SET_SVC_PARAMETERS, ctrl_set_svc_parameters}, |
| 1401 {VP9E_REGISTER_CX_CALLBACK, ctrl_register_cx_callback}, | 1406 {VP9E_REGISTER_CX_CALLBACK, ctrl_register_cx_callback}, |
| 1407 #endif |
| 1402 {VP9E_SET_SVC_LAYER_ID, ctrl_set_svc_layer_id}, | 1408 {VP9E_SET_SVC_LAYER_ID, ctrl_set_svc_layer_id}, |
| 1403 {VP9E_SET_TUNE_CONTENT, ctrl_set_tune_content}, | 1409 {VP9E_SET_TUNE_CONTENT, ctrl_set_tune_content}, |
| 1404 {VP9E_SET_COLOR_SPACE, ctrl_set_color_space}, | 1410 {VP9E_SET_COLOR_SPACE, ctrl_set_color_space}, |
| 1405 {VP9E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity}, | 1411 {VP9E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity}, |
| 1406 | 1412 |
| 1407 // Getters | 1413 // Getters |
| 1408 {VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer}, | 1414 {VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer}, |
| 1409 {VP8E_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64}, | 1415 {VP8E_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64}, |
| 1410 {VP9_GET_REFERENCE, ctrl_get_reference}, | 1416 {VP9_GET_REFERENCE, ctrl_get_reference}, |
| 1417 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION) |
| 1411 {VP9E_GET_SVC_LAYER_ID, ctrl_get_svc_layer_id}, | 1418 {VP9E_GET_SVC_LAYER_ID, ctrl_get_svc_layer_id}, |
| 1419 #endif |
| 1412 | 1420 |
| 1413 { -1, NULL}, | 1421 { -1, NULL}, |
| 1414 }; | 1422 }; |
| 1415 | 1423 |
| 1416 static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { | 1424 static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { |
| 1417 { | 1425 { |
| 1418 0, | 1426 0, |
| 1419 { // NOLINT | 1427 { // NOLINT |
| 1420 0, // g_usage | 1428 0, // g_usage |
| 1421 8, // g_threads | 1429 8, // g_threads |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1435 25, // g_lag_in_frames | 1443 25, // g_lag_in_frames |
| 1436 | 1444 |
| 1437 0, // rc_dropframe_thresh | 1445 0, // rc_dropframe_thresh |
| 1438 0, // rc_resize_allowed | 1446 0, // rc_resize_allowed |
| 1439 0, // rc_scaled_width | 1447 0, // rc_scaled_width |
| 1440 0, // rc_scaled_height | 1448 0, // rc_scaled_height |
| 1441 60, // rc_resize_down_thresold | 1449 60, // rc_resize_down_thresold |
| 1442 30, // rc_resize_up_thresold | 1450 30, // rc_resize_up_thresold |
| 1443 | 1451 |
| 1444 VPX_VBR, // rc_end_usage | 1452 VPX_VBR, // rc_end_usage |
| 1445 #if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION) | |
| 1446 {NULL, 0}, // rc_twopass_stats_in | 1453 {NULL, 0}, // rc_twopass_stats_in |
| 1447 {NULL, 0}, // rc_firstpass_mb_stats_in | 1454 {NULL, 0}, // rc_firstpass_mb_stats_in |
| 1448 #endif | |
| 1449 256, // rc_target_bandwidth | 1455 256, // rc_target_bandwidth |
| 1450 0, // rc_min_quantizer | 1456 0, // rc_min_quantizer |
| 1451 63, // rc_max_quantizer | 1457 63, // rc_max_quantizer |
| 1452 25, // rc_undershoot_pct | 1458 25, // rc_undershoot_pct |
| 1453 25, // rc_overshoot_pct | 1459 25, // rc_overshoot_pct |
| 1454 | 1460 |
| 1455 6000, // rc_max_buffer_size | 1461 6000, // rc_max_buffer_size |
| 1456 4000, // rc_buffer_initial_size | 1462 4000, // rc_buffer_initial_size |
| 1457 5000, // rc_buffer_optimal_size | 1463 5000, // rc_buffer_optimal_size |
| 1458 | 1464 |
| 1459 50, // rc_two_pass_vbrbias | 1465 50, // rc_two_pass_vbrbias |
| 1460 0, // rc_two_pass_vbrmin_section | 1466 0, // rc_two_pass_vbrmin_section |
| 1461 2000, // rc_two_pass_vbrmax_section | 1467 2000, // rc_two_pass_vbrmax_section |
| 1462 | 1468 |
| 1463 // keyframing settings (kf) | 1469 // keyframing settings (kf) |
| 1464 VPX_KF_AUTO, // g_kfmode | 1470 VPX_KF_AUTO, // g_kfmode |
| 1465 0, // kf_min_dist | 1471 0, // kf_min_dist |
| 1466 9999, // kf_max_dist | 1472 9999, // kf_max_dist |
| 1467 | 1473 |
| 1468 VPX_SS_DEFAULT_LAYERS, // ss_number_layers | 1474 VPX_SS_DEFAULT_LAYERS, // ss_number_layers |
| 1469 {0}, | 1475 {0}, |
| 1470 {0}, // ss_target_bitrate | 1476 {0}, // ss_target_bitrate |
| 1471 1, // ts_number_layers | 1477 1, // ts_number_layers |
| 1472 {0}, // ts_target_bitrate | 1478 {0}, // ts_target_bitrate |
| 1473 {0}, // ts_rate_decimator | 1479 {0}, // ts_rate_decimator |
| 1474 0, // ts_periodicity | 1480 0, // ts_periodicity |
| 1475 {0}, // ts_layer_id | 1481 {0}, // ts_layer_id |
| 1476 #if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION) | |
| 1477 "vp8.fpf" // first pass filename | |
| 1478 #endif | |
| 1479 } | 1482 } |
| 1480 }, | 1483 }, |
| 1481 }; | 1484 }; |
| 1482 | 1485 |
| 1483 #ifndef VERSION_STRING | 1486 #ifndef VERSION_STRING |
| 1484 #define VERSION_STRING | 1487 #define VERSION_STRING |
| 1485 #endif | 1488 #endif |
| 1486 CODEC_INTERFACE(vpx_codec_vp9_cx) = { | 1489 CODEC_INTERFACE(vpx_codec_vp9_cx) = { |
| 1487 "WebM Project VP9 Encoder" VERSION_STRING, | 1490 "WebM Project VP9 Encoder" VERSION_STRING, |
| 1488 VPX_CODEC_INTERNAL_ABI_VERSION, | 1491 VPX_CODEC_INTERNAL_ABI_VERSION, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1504 1, // 1 cfg map | 1507 1, // 1 cfg map |
| 1505 encoder_usage_cfg_map, // vpx_codec_enc_cfg_map_t | 1508 encoder_usage_cfg_map, // vpx_codec_enc_cfg_map_t |
| 1506 encoder_encode, // vpx_codec_encode_fn_t | 1509 encoder_encode, // vpx_codec_encode_fn_t |
| 1507 encoder_get_cxdata, // vpx_codec_get_cx_data_fn_t | 1510 encoder_get_cxdata, // vpx_codec_get_cx_data_fn_t |
| 1508 encoder_set_config, // vpx_codec_enc_config_set_fn_t | 1511 encoder_set_config, // vpx_codec_enc_config_set_fn_t |
| 1509 NULL, // vpx_codec_get_global_headers_fn_t | 1512 NULL, // vpx_codec_get_global_headers_fn_t |
| 1510 encoder_get_preview, // vpx_codec_get_preview_frame_fn_t | 1513 encoder_get_preview, // vpx_codec_get_preview_frame_fn_t |
| 1511 NULL // vpx_codec_enc_mr_get_mem_loc_fn_t | 1514 NULL // vpx_codec_enc_mr_get_mem_loc_fn_t |
| 1512 } | 1515 } |
| 1513 }; | 1516 }; |
| OLD | NEW |