| 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 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO); | 168 RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO); |
| 169 // RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile); | 169 // RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile); |
| 170 RANGE_CHECK_BOOL(cfg, rc_resize_allowed); | 170 RANGE_CHECK_BOOL(cfg, rc_resize_allowed); |
| 171 RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); | 171 RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); |
| 172 RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); | 172 RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); |
| 173 RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); | 173 RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); |
| 174 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS); | 174 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS); |
| 175 | 175 |
| 176 RANGE_CHECK(cfg, ss_number_layers, 1, | 176 RANGE_CHECK(cfg, ss_number_layers, 1, |
| 177 VPX_SS_MAX_LAYERS); /*Spatial layers max */ | 177 VPX_SS_MAX_LAYERS); /*Spatial layers max */ |
| 178 |
| 179 RANGE_CHECK(cfg, ts_number_layers, 1, VPX_TS_MAX_LAYERS); |
| 180 if (cfg->ts_number_layers > 1) { |
| 181 unsigned int i; |
| 182 for (i = 1; i < cfg->ts_number_layers; ++i) { |
| 183 if (cfg->ts_target_bitrate[i] < cfg->ts_target_bitrate[i-1]) { |
| 184 ERROR("ts_target_bitrate entries are not increasing"); |
| 185 } |
| 186 } |
| 187 RANGE_CHECK(cfg, ts_rate_decimator[cfg->ts_number_layers-1], 1, 1); |
| 188 for (i = cfg->ts_number_layers-2; i > 0; --i) { |
| 189 if (cfg->ts_rate_decimator[i-1] != 2*cfg->ts_rate_decimator[i]) { |
| 190 ERROR("ts_rate_decimator factors are not powers of 2"); |
| 191 } |
| 192 } |
| 193 } |
| 194 |
| 178 /* VP8 does not support a lower bound on the keyframe interval in | 195 /* VP8 does not support a lower bound on the keyframe interval in |
| 179 * automatic keyframe placement mode. | 196 * automatic keyframe placement mode. |
| 180 */ | 197 */ |
| 181 if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist | 198 if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist |
| 182 && cfg->kf_min_dist > 0) | 199 && cfg->kf_min_dist > 0) |
| 183 ERROR("kf_min_dist not supported in auto mode, use 0 " | 200 ERROR("kf_min_dist not supported in auto mode, use 0 " |
| 184 "or kf_max_dist instead."); | 201 "or kf_max_dist instead."); |
| 185 | 202 |
| 186 RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref); | 203 RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref); |
| 187 RANGE_CHECK(vp8_cfg, cpu_used, -16, 16); | 204 RANGE_CHECK(vp8_cfg, cpu_used, -16, 16); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 198 | 215 |
| 199 // TODO(yaowu): remove this when ssim tuning is implemented for vp9 | 216 // TODO(yaowu): remove this when ssim tuning is implemented for vp9 |
| 200 if (vp8_cfg->tuning == VP8_TUNE_SSIM) | 217 if (vp8_cfg->tuning == VP8_TUNE_SSIM) |
| 201 ERROR("Option --tune=ssim is not currently supported in VP9."); | 218 ERROR("Option --tune=ssim is not currently supported in VP9."); |
| 202 | 219 |
| 203 if (cfg->g_pass == VPX_RC_LAST_PASS) { | 220 if (cfg->g_pass == VPX_RC_LAST_PASS) { |
| 204 size_t packet_sz = sizeof(FIRSTPASS_STATS); | 221 size_t packet_sz = sizeof(FIRSTPASS_STATS); |
| 205 int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); | 222 int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); |
| 206 FIRSTPASS_STATS *stats; | 223 FIRSTPASS_STATS *stats; |
| 207 | 224 |
| 208 if (!cfg->rc_twopass_stats_in.buf) | 225 if (cfg->rc_twopass_stats_in.buf == NULL) |
| 209 ERROR("rc_twopass_stats_in.buf not set."); | 226 ERROR("rc_twopass_stats_in.buf not set."); |
| 210 | 227 |
| 211 if (cfg->rc_twopass_stats_in.sz % packet_sz) | 228 if (cfg->rc_twopass_stats_in.sz % packet_sz) |
| 212 ERROR("rc_twopass_stats_in.sz indicates truncated packet."); | 229 ERROR("rc_twopass_stats_in.sz indicates truncated packet."); |
| 213 | 230 |
| 214 if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) | 231 if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) |
| 215 ERROR("rc_twopass_stats_in requires at least two packets."); | 232 ERROR("rc_twopass_stats_in requires at least two packets."); |
| 216 | 233 |
| 217 stats = (void *)((char *)cfg->rc_twopass_stats_in.buf | 234 stats = (void *)((char *)cfg->rc_twopass_stats_in.buf |
| 218 + (n_packets - 1) * packet_sz); | 235 + (n_packets - 1) * packet_sz); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 289 } |
| 273 | 290 |
| 274 if (cfg.g_pass == VPX_RC_FIRST_PASS) { | 291 if (cfg.g_pass == VPX_RC_FIRST_PASS) { |
| 275 oxcf->allow_lag = 0; | 292 oxcf->allow_lag = 0; |
| 276 oxcf->lag_in_frames = 0; | 293 oxcf->lag_in_frames = 0; |
| 277 } else { | 294 } else { |
| 278 oxcf->allow_lag = (cfg.g_lag_in_frames) > 0; | 295 oxcf->allow_lag = (cfg.g_lag_in_frames) > 0; |
| 279 oxcf->lag_in_frames = cfg.g_lag_in_frames; | 296 oxcf->lag_in_frames = cfg.g_lag_in_frames; |
| 280 } | 297 } |
| 281 | 298 |
| 282 // VBR only supported for now. | 299 oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK; |
| 283 // CBR code has been deprectated for experimental phase. | |
| 284 // CQ mode not yet tested | |
| 285 oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK; | |
| 286 if (cfg.rc_end_usage == VPX_CQ) | 300 if (cfg.rc_end_usage == VPX_CQ) |
| 287 oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; | 301 oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; |
| 288 else if (cfg.rc_end_usage == VPX_Q) | 302 else if (cfg.rc_end_usage == VPX_Q) |
| 289 oxcf->end_usage = USAGE_CONSTANT_QUALITY; | 303 oxcf->end_usage = USAGE_CONSTANT_QUALITY; |
| 290 else if (cfg.rc_end_usage == VPX_CBR) | 304 else if (cfg.rc_end_usage == VPX_CBR) |
| 291 oxcf->end_usage = USAGE_STREAM_FROM_SERVER; | 305 oxcf->end_usage = USAGE_STREAM_FROM_SERVER; |
| 292 | 306 |
| 293 oxcf->target_bandwidth = cfg.rc_target_bitrate; | 307 oxcf->target_bandwidth = cfg.rc_target_bitrate; |
| 294 oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct; | 308 oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct; |
| 295 | 309 |
| 296 oxcf->best_allowed_q = cfg.rc_min_quantizer; | 310 oxcf->best_allowed_q = cfg.rc_min_quantizer; |
| 297 oxcf->worst_allowed_q = cfg.rc_max_quantizer; | 311 oxcf->worst_allowed_q = cfg.rc_max_quantizer; |
| 298 oxcf->cq_level = vp8_cfg.cq_level; | 312 oxcf->cq_level = vp8_cfg.cq_level; |
| 299 oxcf->fixed_q = -1; | 313 oxcf->fixed_q = -1; |
| 300 | 314 |
| 301 oxcf->under_shoot_pct = cfg.rc_undershoot_pct; | 315 oxcf->under_shoot_pct = cfg.rc_undershoot_pct; |
| 302 oxcf->over_shoot_pct = cfg.rc_overshoot_pct; | 316 oxcf->over_shoot_pct = cfg.rc_overshoot_pct; |
| 303 | 317 |
| 304 oxcf->maximum_buffer_size = cfg.rc_buf_sz; | 318 oxcf->maximum_buffer_size = cfg.rc_buf_sz; |
| 305 oxcf->starting_buffer_level = cfg.rc_buf_initial_sz; | 319 oxcf->starting_buffer_level = cfg.rc_buf_initial_sz; |
| 306 oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz; | 320 oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz; |
| 307 | 321 |
| 308 oxcf->drop_frames_water_mark = cfg.rc_dropframe_thresh; | 322 oxcf->drop_frames_water_mark = cfg.rc_dropframe_thresh; |
| 309 | 323 |
| 310 oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; | 324 oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; |
| 311 oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct; | 325 oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct; |
| 312 oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct; | 326 oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct; |
| 313 | 327 |
| 314 oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO | 328 oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO |
| 315 && cfg.kf_min_dist != cfg.kf_max_dist; | 329 && cfg.kf_min_dist != cfg.kf_max_dist; |
| 316 // oxcf->kf_min_dist = cfg.kf_min_dis; | 330 // oxcf->kf_min_dist = cfg.kf_min_dis; |
| 317 oxcf->key_freq = cfg.kf_max_dist; | 331 oxcf->key_freq = cfg.kf_max_dist; |
| 318 | 332 |
| 319 // oxcf->delete_first_pass_file = cfg.g_delete_firstpassfile; | |
| 320 // strcpy(oxcf->first_pass_file, cfg.g_firstpass_file); | |
| 321 | |
| 322 oxcf->cpu_used = vp8_cfg.cpu_used; | 333 oxcf->cpu_used = vp8_cfg.cpu_used; |
| 323 oxcf->encode_breakout = vp8_cfg.static_thresh; | 334 oxcf->encode_breakout = vp8_cfg.static_thresh; |
| 324 oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref; | 335 oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref; |
| 325 oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity; | 336 oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity; |
| 326 oxcf->sharpness = vp8_cfg.sharpness; | 337 oxcf->sharpness = vp8_cfg.sharpness; |
| 327 | 338 |
| 328 oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in; | 339 oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in; |
| 329 oxcf->output_pkt_list = vp8_cfg.pkt_list; | 340 oxcf->output_pkt_list = vp8_cfg.pkt_list; |
| 330 | 341 |
| 331 oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames; | 342 oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames; |
| 332 oxcf->arnr_strength = vp8_cfg.arnr_strength; | 343 oxcf->arnr_strength = vp8_cfg.arnr_strength; |
| 333 oxcf->arnr_type = vp8_cfg.arnr_type; | 344 oxcf->arnr_type = vp8_cfg.arnr_type; |
| 334 | 345 |
| 335 oxcf->tuning = vp8_cfg.tuning; | 346 oxcf->tuning = vp8_cfg.tuning; |
| 336 | 347 |
| 337 oxcf->tile_columns = vp8_cfg.tile_columns; | 348 oxcf->tile_columns = vp8_cfg.tile_columns; |
| 338 oxcf->tile_rows = vp8_cfg.tile_rows; | 349 oxcf->tile_rows = vp8_cfg.tile_rows; |
| 339 | 350 |
| 340 oxcf->lossless = vp8_cfg.lossless; | 351 oxcf->lossless = vp8_cfg.lossless; |
| 341 | 352 |
| 342 oxcf->error_resilient_mode = cfg.g_error_resilient; | 353 oxcf->error_resilient_mode = cfg.g_error_resilient; |
| 343 oxcf->frame_parallel_decoding_mode = vp8_cfg.frame_parallel_decoding_mode; | 354 oxcf->frame_parallel_decoding_mode = vp8_cfg.frame_parallel_decoding_mode; |
| 344 | 355 |
| 345 oxcf->aq_mode = vp8_cfg.aq_mode; | 356 oxcf->aq_mode = vp8_cfg.aq_mode; |
| 346 | 357 |
| 347 oxcf->ss_number_layers = cfg.ss_number_layers; | 358 oxcf->ss_number_layers = cfg.ss_number_layers; |
| 359 |
| 360 oxcf->ts_number_layers = cfg.ts_number_layers; |
| 361 |
| 362 if (oxcf->ts_number_layers > 1) { |
| 363 memcpy(oxcf->ts_target_bitrate, cfg.ts_target_bitrate, |
| 364 sizeof(cfg.ts_target_bitrate)); |
| 365 memcpy(oxcf->ts_rate_decimator, cfg.ts_rate_decimator, |
| 366 sizeof(cfg.ts_rate_decimator)); |
| 367 } else if (oxcf->ts_number_layers == 1) { |
| 368 oxcf->ts_target_bitrate[0] = oxcf->target_bandwidth; |
| 369 oxcf->ts_rate_decimator[0] = 1; |
| 370 } |
| 371 |
| 348 /* | 372 /* |
| 349 printf("Current VP9 Settings: \n"); | 373 printf("Current VP9 Settings: \n"); |
| 350 printf("target_bandwidth: %d\n", oxcf->target_bandwidth); | 374 printf("target_bandwidth: %d\n", oxcf->target_bandwidth); |
| 351 printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity); | 375 printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity); |
| 352 printf("sharpness: %d\n", oxcf->sharpness); | 376 printf("sharpness: %d\n", oxcf->sharpness); |
| 353 printf("cpu_used: %d\n", oxcf->cpu_used); | 377 printf("cpu_used: %d\n", oxcf->cpu_used); |
| 354 printf("Mode: %d\n", oxcf->mode); | 378 printf("Mode: %d\n", oxcf->mode); |
| 355 // printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file); | |
| 356 printf("auto_key: %d\n", oxcf->auto_key); | 379 printf("auto_key: %d\n", oxcf->auto_key); |
| 357 printf("key_freq: %d\n", oxcf->key_freq); | 380 printf("key_freq: %d\n", oxcf->key_freq); |
| 358 printf("end_usage: %d\n", oxcf->end_usage); | 381 printf("end_usage: %d\n", oxcf->end_usage); |
| 359 printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct); | 382 printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct); |
| 360 printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct); | 383 printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct); |
| 361 printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level); | 384 printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level); |
| 362 printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level); | 385 printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level); |
| 363 printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size); | 386 printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size); |
| 364 printf("fixed_q: %d\n", oxcf->fixed_q); | 387 printf("fixed_q: %d\n", oxcf->fixed_q); |
| 365 printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q); | 388 printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 389 /* Prevent increasing lag_in_frames. This check is stricter than it needs | 412 /* Prevent increasing lag_in_frames. This check is stricter than it needs |
| 390 * to be -- the limit is not increasing past the first lag_in_frames | 413 * to be -- the limit is not increasing past the first lag_in_frames |
| 391 * value, but we don't track the initial config, only the last successful | 414 * value, but we don't track the initial config, only the last successful |
| 392 * config. | 415 * config. |
| 393 */ | 416 */ |
| 394 if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames)) | 417 if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames)) |
| 395 ERROR("Cannot increase lag_in_frames"); | 418 ERROR("Cannot increase lag_in_frames"); |
| 396 | 419 |
| 397 res = validate_config(ctx, cfg, &ctx->vp8_cfg); | 420 res = validate_config(ctx, cfg, &ctx->vp8_cfg); |
| 398 | 421 |
| 399 if (!res) { | 422 if (res == VPX_CODEC_OK) { |
| 400 ctx->cfg = *cfg; | 423 ctx->cfg = *cfg; |
| 401 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); | 424 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); |
| 402 vp9_change_config(ctx->cpi, &ctx->oxcf); | 425 vp9_change_config(ctx->cpi, &ctx->oxcf); |
| 403 } | 426 } |
| 404 | 427 |
| 405 return res; | 428 return res; |
| 406 } | 429 } |
| 407 | 430 |
| 408 | 431 |
| 409 int vp9_reverse_trans(int q); | 432 int vp9_reverse_trans(int q); |
| 410 | 433 |
| 411 | 434 |
| 412 static vpx_codec_err_t get_param(vpx_codec_alg_priv_t *ctx, | 435 static vpx_codec_err_t get_param(vpx_codec_alg_priv_t *ctx, |
| 413 int ctrl_id, | 436 int ctrl_id, |
| 414 va_list args) { | 437 va_list args) { |
| 415 void *arg = va_arg(args, void *); | 438 void *arg = va_arg(args, void *); |
| 416 | 439 |
| 417 #define MAP(id, var) case id: *(RECAST(id, arg)) = var; break | 440 #define MAP(id, var) case id: *(RECAST(id, arg)) = var; break |
| 418 | 441 |
| 419 if (!arg) | 442 if (arg == NULL) return VPX_CODEC_INVALID_PARAM; |
| 420 return VPX_CODEC_INVALID_PARAM; | |
| 421 | 443 |
| 422 switch (ctrl_id) { | 444 switch (ctrl_id) { |
| 423 MAP(VP8E_GET_LAST_QUANTIZER, vp9_get_quantizer(ctx->cpi)); | 445 MAP(VP8E_GET_LAST_QUANTIZER, vp9_get_quantizer(ctx->cpi)); |
| 424 MAP(VP8E_GET_LAST_QUANTIZER_64, | 446 MAP(VP8E_GET_LAST_QUANTIZER_64, |
| 425 vp9_reverse_trans(vp9_get_quantizer(ctx->cpi))); | 447 vp9_reverse_trans(vp9_get_quantizer(ctx->cpi))); |
| 426 } | 448 } |
| 427 | 449 |
| 428 return VPX_CODEC_OK; | 450 return VPX_CODEC_OK; |
| 429 #undef MAP | 451 #undef MAP |
| 430 } | 452 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 452 MAP(VP8E_SET_TUNING, xcfg.tuning); | 474 MAP(VP8E_SET_TUNING, xcfg.tuning); |
| 453 MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); | 475 MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); |
| 454 MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); | 476 MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); |
| 455 MAP(VP9E_SET_LOSSLESS, xcfg.lossless); | 477 MAP(VP9E_SET_LOSSLESS, xcfg.lossless); |
| 456 MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode); | 478 MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode); |
| 457 MAP(VP9E_SET_AQ_MODE, xcfg.aq_mode); | 479 MAP(VP9E_SET_AQ_MODE, xcfg.aq_mode); |
| 458 } | 480 } |
| 459 | 481 |
| 460 res = validate_config(ctx, &ctx->cfg, &xcfg); | 482 res = validate_config(ctx, &ctx->cfg, &xcfg); |
| 461 | 483 |
| 462 if (!res) { | 484 if (res == VPX_CODEC_OK) { |
| 463 ctx->vp8_cfg = xcfg; | 485 ctx->vp8_cfg = xcfg; |
| 464 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); | 486 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); |
| 465 vp9_change_config(ctx->cpi, &ctx->oxcf); | 487 vp9_change_config(ctx->cpi, &ctx->oxcf); |
| 466 } | 488 } |
| 467 | 489 |
| 468 return res; | 490 return res; |
| 469 #undef MAP | 491 #undef MAP |
| 470 } | 492 } |
| 471 | 493 |
| 472 | 494 |
| 473 static vpx_codec_err_t vp9e_common_init(vpx_codec_ctx_t *ctx) { | 495 static vpx_codec_err_t vp9e_common_init(vpx_codec_ctx_t *ctx) { |
| 474 vpx_codec_err_t res = VPX_CODEC_OK; | 496 vpx_codec_err_t res = VPX_CODEC_OK; |
| 475 struct vpx_codec_alg_priv *priv; | 497 struct vpx_codec_alg_priv *priv; |
| 476 vpx_codec_enc_cfg_t *cfg; | 498 vpx_codec_enc_cfg_t *cfg; |
| 477 unsigned int i; | 499 unsigned int i; |
| 478 | 500 |
| 479 VP9_PTR optr; | 501 VP9_PTR optr; |
| 480 | 502 |
| 481 if (!ctx->priv) { | 503 if (ctx->priv == NULL) { |
| 482 priv = calloc(1, sizeof(struct vpx_codec_alg_priv)); | 504 priv = calloc(1, sizeof(struct vpx_codec_alg_priv)); |
| 483 | 505 |
| 484 if (!priv) { | 506 if (priv == NULL) return VPX_CODEC_MEM_ERROR; |
| 485 return VPX_CODEC_MEM_ERROR; | |
| 486 } | |
| 487 | 507 |
| 488 ctx->priv = &priv->base; | 508 ctx->priv = &priv->base; |
| 489 ctx->priv->sz = sizeof(*ctx->priv); | 509 ctx->priv->sz = sizeof(*ctx->priv); |
| 490 ctx->priv->iface = ctx->iface; | 510 ctx->priv->iface = ctx->iface; |
| 491 ctx->priv->alg_priv = priv; | 511 ctx->priv->alg_priv = priv; |
| 492 ctx->priv->init_flags = ctx->init_flags; | 512 ctx->priv->init_flags = ctx->init_flags; |
| 493 ctx->priv->enc.total_encoders = 1; | 513 ctx->priv->enc.total_encoders = 1; |
| 494 | 514 |
| 495 if (ctx->config.enc) { | 515 if (ctx->config.enc) { |
| 496 /* Update the reference to the config structure to an | 516 /* Update the reference to the config structure to an |
| (...skipping 16 matching lines...) Expand all Loading... |
| 513 priv->vp8_cfg = extracfg_map[i].cfg; | 533 priv->vp8_cfg = extracfg_map[i].cfg; |
| 514 priv->vp8_cfg.pkt_list = &priv->pkt_list.head; | 534 priv->vp8_cfg.pkt_list = &priv->pkt_list.head; |
| 515 | 535 |
| 516 // Maximum buffer size approximated based on having multiple ARF. | 536 // Maximum buffer size approximated based on having multiple ARF. |
| 517 priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 8; | 537 priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 8; |
| 518 | 538 |
| 519 if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096; | 539 if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096; |
| 520 | 540 |
| 521 priv->cx_data = malloc(priv->cx_data_sz); | 541 priv->cx_data = malloc(priv->cx_data_sz); |
| 522 | 542 |
| 523 if (!priv->cx_data) { | 543 if (priv->cx_data == NULL) return VPX_CODEC_MEM_ERROR; |
| 524 return VPX_CODEC_MEM_ERROR; | |
| 525 } | |
| 526 | 544 |
| 527 vp9_initialize_enc(); | 545 vp9_initialize_enc(); |
| 528 | 546 |
| 529 res = validate_config(priv, &priv->cfg, &priv->vp8_cfg); | 547 res = validate_config(priv, &priv->cfg, &priv->vp8_cfg); |
| 530 | 548 |
| 531 if (!res) { | 549 if (res == VPX_CODEC_OK) { |
| 532 set_vp9e_config(&ctx->priv->alg_priv->oxcf, | 550 set_vp9e_config(&ctx->priv->alg_priv->oxcf, |
| 533 ctx->priv->alg_priv->cfg, | 551 ctx->priv->alg_priv->cfg, |
| 534 ctx->priv->alg_priv->vp8_cfg); | 552 ctx->priv->alg_priv->vp8_cfg); |
| 535 optr = vp9_create_compressor(&ctx->priv->alg_priv->oxcf); | 553 optr = vp9_create_compressor(&ctx->priv->alg_priv->oxcf); |
| 536 | 554 |
| 537 if (!optr) | 555 if (optr == NULL) |
| 538 res = VPX_CODEC_MEM_ERROR; | 556 res = VPX_CODEC_MEM_ERROR; |
| 539 else | 557 else |
| 540 ctx->priv->alg_priv->cpi = optr; | 558 ctx->priv->alg_priv->cpi = optr; |
| 541 } | 559 } |
| 542 } | 560 } |
| 543 | 561 |
| 544 return res; | 562 return res; |
| 545 } | 563 } |
| 546 | 564 |
| 547 | 565 |
| 548 static vpx_codec_err_t vp9e_init(vpx_codec_ctx_t *ctx, | 566 static vpx_codec_err_t vp9e_init(vpx_codec_ctx_t *ctx, |
| 549 vpx_codec_priv_enc_mr_cfg_t *data) { | 567 vpx_codec_priv_enc_mr_cfg_t *data) { |
| 550 return vp9e_common_init(ctx); | 568 return vp9e_common_init(ctx); |
| 551 } | 569 } |
| 552 | 570 |
| 553 static vpx_codec_err_t vp9e_destroy(vpx_codec_alg_priv_t *ctx) { | 571 static vpx_codec_err_t vp9e_destroy(vpx_codec_alg_priv_t *ctx) { |
| 554 free(ctx->cx_data); | 572 free(ctx->cx_data); |
| 555 vp9_remove_compressor(&ctx->cpi); | 573 vp9_remove_compressor(&ctx->cpi); |
| 556 free(ctx); | 574 free(ctx); |
| 557 return VPX_CODEC_OK; | 575 return VPX_CODEC_OK; |
| 558 } | 576 } |
| 559 | 577 |
| 560 static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, | 578 static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, |
| 561 unsigned long duration, | 579 unsigned long duration, |
| 562 unsigned long deadline) { | 580 unsigned long deadline) { |
| 563 unsigned int new_qc; | 581 unsigned int new_qc; |
| 564 | 582 |
| 565 /* Use best quality mode if no deadline is given. */ | 583 /* Use best quality mode if no deadline is given. */ |
| 566 if (deadline) | 584 new_qc = MODE_BESTQUALITY; |
| 567 new_qc = MODE_GOODQUALITY; | 585 |
| 568 else | 586 if (deadline) { |
| 569 new_qc = MODE_BESTQUALITY; | 587 uint64_t duration_us; |
| 588 |
| 589 /* Convert duration parameter from stream timebase to microseconds */ |
| 590 duration_us = (uint64_t)duration * 1000000 |
| 591 * (uint64_t)ctx->cfg.g_timebase.num |
| 592 / (uint64_t)ctx->cfg.g_timebase.den; |
| 593 |
| 594 /* If the deadline is more that the duration this frame is to be shown, |
| 595 * use good quality mode. Otherwise use realtime mode. |
| 596 */ |
| 597 new_qc = (deadline > duration_us) ? MODE_GOODQUALITY : MODE_REALTIME; |
| 598 } |
| 570 | 599 |
| 571 if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS) | 600 if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS) |
| 572 new_qc = MODE_FIRSTPASS; | 601 new_qc = MODE_FIRSTPASS; |
| 573 else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS) | 602 else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS) |
| 574 new_qc = (new_qc == MODE_BESTQUALITY) | 603 new_qc = (new_qc == MODE_BESTQUALITY) |
| 575 ? MODE_SECONDPASS_BEST | 604 ? MODE_SECONDPASS_BEST |
| 576 : MODE_SECONDPASS; | 605 : MODE_SECONDPASS; |
| 577 | 606 |
| 578 if (ctx->oxcf.mode != new_qc) { | 607 if (ctx->oxcf.mode != new_qc) { |
| 579 ctx->oxcf.mode = new_qc; | 608 ctx->oxcf.mode = new_qc; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 /* Handle fixed keyframe intervals */ | 713 /* Handle fixed keyframe intervals */ |
| 685 if (ctx->cfg.kf_mode == VPX_KF_AUTO | 714 if (ctx->cfg.kf_mode == VPX_KF_AUTO |
| 686 && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { | 715 && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { |
| 687 if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) { | 716 if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) { |
| 688 flags |= VPX_EFLAG_FORCE_KF; | 717 flags |= VPX_EFLAG_FORCE_KF; |
| 689 ctx->fixed_kf_cntr = 1; | 718 ctx->fixed_kf_cntr = 1; |
| 690 } | 719 } |
| 691 } | 720 } |
| 692 | 721 |
| 693 /* Initialize the encoder instance on the first frame. */ | 722 /* Initialize the encoder instance on the first frame. */ |
| 694 if (!res && ctx->cpi) { | 723 if (res == VPX_CODEC_OK && ctx->cpi != NULL) { |
| 695 unsigned int lib_flags; | 724 unsigned int lib_flags; |
| 696 YV12_BUFFER_CONFIG sd; | 725 YV12_BUFFER_CONFIG sd; |
| 697 int64_t dst_time_stamp, dst_end_time_stamp; | 726 int64_t dst_time_stamp, dst_end_time_stamp; |
| 698 size_t size, cx_data_sz; | 727 size_t size, cx_data_sz; |
| 699 unsigned char *cx_data; | 728 unsigned char *cx_data; |
| 700 | 729 |
| 701 /* Set up internal flags */ | 730 /* Set up internal flags */ |
| 702 if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) | 731 if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) |
| 703 ((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1; | 732 ((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1; |
| 704 | 733 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 while (cx_data_sz >= ctx->cx_data_sz / 2 && | 773 while (cx_data_sz >= ctx->cx_data_sz / 2 && |
| 745 -1 != vp9_get_compressed_data(ctx->cpi, &lib_flags, &size, | 774 -1 != vp9_get_compressed_data(ctx->cpi, &lib_flags, &size, |
| 746 cx_data, &dst_time_stamp, | 775 cx_data, &dst_time_stamp, |
| 747 &dst_end_time_stamp, !img)) { | 776 &dst_end_time_stamp, !img)) { |
| 748 if (size) { | 777 if (size) { |
| 749 vpx_codec_pts_t round, delta; | 778 vpx_codec_pts_t round, delta; |
| 750 vpx_codec_cx_pkt_t pkt; | 779 vpx_codec_cx_pkt_t pkt; |
| 751 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; | 780 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; |
| 752 | 781 |
| 753 /* Pack invisible frames with the next visible frame */ | 782 /* Pack invisible frames with the next visible frame */ |
| 754 if (!cpi->common.show_frame) { | 783 if (cpi->common.show_frame == 0) { |
| 755 if (!ctx->pending_cx_data) | 784 if (ctx->pending_cx_data == 0) |
| 756 ctx->pending_cx_data = cx_data; | 785 ctx->pending_cx_data = cx_data; |
| 757 ctx->pending_cx_data_sz += size; | 786 ctx->pending_cx_data_sz += size; |
| 758 ctx->pending_frame_sizes[ctx->pending_frame_count++] = size; | 787 ctx->pending_frame_sizes[ctx->pending_frame_count++] = size; |
| 759 ctx->pending_frame_magnitude |= size; | 788 ctx->pending_frame_magnitude |= size; |
| 760 cx_data += size; | 789 cx_data += size; |
| 761 cx_data_sz -= size; | 790 cx_data_sz -= size; |
| 762 continue; | 791 continue; |
| 763 } | 792 } |
| 764 | 793 |
| 765 /* Add the frame packet to the list of returned packets. */ | 794 /* Add the frame packet to the list of returned packets. */ |
| 766 round = (vpx_codec_pts_t)1000000 * ctx->cfg.g_timebase.num / 2 - 1; | 795 round = (vpx_codec_pts_t)1000000 * ctx->cfg.g_timebase.num / 2 - 1; |
| 767 delta = (dst_end_time_stamp - dst_time_stamp); | 796 delta = (dst_end_time_stamp - dst_time_stamp); |
| 768 pkt.kind = VPX_CODEC_CX_FRAME_PKT; | 797 pkt.kind = VPX_CODEC_CX_FRAME_PKT; |
| 769 pkt.data.frame.pts = | 798 pkt.data.frame.pts = |
| 770 (dst_time_stamp * ctx->cfg.g_timebase.den + round) | 799 (dst_time_stamp * ctx->cfg.g_timebase.den + round) |
| 771 / ctx->cfg.g_timebase.num / 10000000; | 800 / ctx->cfg.g_timebase.num / 10000000; |
| 772 pkt.data.frame.duration = (unsigned long) | 801 pkt.data.frame.duration = (unsigned long) |
| 773 ((delta * ctx->cfg.g_timebase.den + round) | 802 ((delta * ctx->cfg.g_timebase.den + round) |
| 774 / ctx->cfg.g_timebase.num / 10000000); | 803 / ctx->cfg.g_timebase.num / 10000000); |
| 775 pkt.data.frame.flags = lib_flags << 16; | 804 pkt.data.frame.flags = lib_flags << 16; |
| 776 | 805 |
| 777 if (lib_flags & FRAMEFLAGS_KEY) | 806 if (lib_flags & FRAMEFLAGS_KEY) |
| 778 pkt.data.frame.flags |= VPX_FRAME_IS_KEY; | 807 pkt.data.frame.flags |= VPX_FRAME_IS_KEY; |
| 779 | 808 |
| 780 if (!cpi->common.show_frame) { | 809 if (cpi->common.show_frame == 0) { |
| 781 pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE; | 810 pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE; |
| 782 | 811 |
| 783 // This timestamp should be as close as possible to the | 812 // This timestamp should be as close as possible to the |
| 784 // prior PTS so that if a decoder uses pts to schedule when | 813 // prior PTS so that if a decoder uses pts to schedule when |
| 785 // to do this, we start right after last frame was decoded. | 814 // to do this, we start right after last frame was decoded. |
| 786 // Invisible frames have no duration. | 815 // Invisible frames have no duration. |
| 787 pkt.data.frame.pts = ((cpi->last_time_stamp_seen | 816 pkt.data.frame.pts = ((cpi->last_time_stamp_seen |
| 788 * ctx->cfg.g_timebase.den + round) | 817 * ctx->cfg.g_timebase.den + round) |
| 789 / ctx->cfg.g_timebase.num / 10000000) + 1; | 818 / ctx->cfg.g_timebase.num / 10000000) + 1; |
| 790 pkt.data.frame.duration = 0; | 819 pkt.data.frame.duration = 0; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 873 |
| 845 | 874 |
| 846 static const vpx_codec_cx_pkt_t *vp9e_get_cxdata(vpx_codec_alg_priv_t *ctx, | 875 static const vpx_codec_cx_pkt_t *vp9e_get_cxdata(vpx_codec_alg_priv_t *ctx, |
| 847 vpx_codec_iter_t *iter) { | 876 vpx_codec_iter_t *iter) { |
| 848 return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter); | 877 return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter); |
| 849 } | 878 } |
| 850 | 879 |
| 851 static vpx_codec_err_t vp9e_set_reference(vpx_codec_alg_priv_t *ctx, | 880 static vpx_codec_err_t vp9e_set_reference(vpx_codec_alg_priv_t *ctx, |
| 852 int ctr_id, | 881 int ctr_id, |
| 853 va_list args) { | 882 va_list args) { |
| 854 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); | 883 vpx_ref_frame_t *frame = va_arg(args, vpx_ref_frame_t *); |
| 855 | 884 |
| 856 if (data) { | 885 if (frame != NULL) { |
| 857 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data; | |
| 858 YV12_BUFFER_CONFIG sd; | 886 YV12_BUFFER_CONFIG sd; |
| 859 | 887 |
| 860 image2yuvconfig(&frame->img, &sd); | 888 image2yuvconfig(&frame->img, &sd); |
| 861 vp9_set_reference_enc(ctx->cpi, ref_frame_to_vp9_reframe(frame->frame_type), | 889 vp9_set_reference_enc(ctx->cpi, ref_frame_to_vp9_reframe(frame->frame_type), |
| 862 &sd); | 890 &sd); |
| 863 return VPX_CODEC_OK; | 891 return VPX_CODEC_OK; |
| 864 } else { | 892 } else { |
| 865 return VPX_CODEC_INVALID_PARAM; | 893 return VPX_CODEC_INVALID_PARAM; |
| 866 } | 894 } |
| 867 } | 895 } |
| 868 | 896 |
| 869 static vpx_codec_err_t vp9e_copy_reference(vpx_codec_alg_priv_t *ctx, | 897 static vpx_codec_err_t vp9e_copy_reference(vpx_codec_alg_priv_t *ctx, |
| 870 int ctr_id, | 898 int ctr_id, |
| 871 va_list args) { | 899 va_list args) { |
| 872 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); | 900 vpx_ref_frame_t *frame = va_arg(args, vpx_ref_frame_t *); |
| 873 | 901 |
| 874 if (data) { | 902 if (frame != NULL) { |
| 875 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data; | |
| 876 YV12_BUFFER_CONFIG sd; | 903 YV12_BUFFER_CONFIG sd; |
| 877 | 904 |
| 878 image2yuvconfig(&frame->img, &sd); | 905 image2yuvconfig(&frame->img, &sd); |
| 879 vp9_copy_reference_enc(ctx->cpi, | 906 vp9_copy_reference_enc(ctx->cpi, |
| 880 ref_frame_to_vp9_reframe(frame->frame_type), &sd); | 907 ref_frame_to_vp9_reframe(frame->frame_type), &sd); |
| 881 return VPX_CODEC_OK; | 908 return VPX_CODEC_OK; |
| 882 } else { | 909 } else { |
| 883 return VPX_CODEC_INVALID_PARAM; | 910 return VPX_CODEC_INVALID_PARAM; |
| 884 } | 911 } |
| 885 } | 912 } |
| 886 | 913 |
| 887 static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx, | 914 static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx, |
| 888 int ctr_id, | 915 int ctr_id, |
| 889 va_list args) { | 916 va_list args) { |
| 890 vp9_ref_frame_t *data = va_arg(args, vp9_ref_frame_t *); | 917 vp9_ref_frame_t *frame = va_arg(args, vp9_ref_frame_t *); |
| 891 | 918 |
| 892 if (data) { | 919 if (frame != NULL) { |
| 893 YV12_BUFFER_CONFIG* fb; | 920 YV12_BUFFER_CONFIG* fb; |
| 894 | 921 |
| 895 vp9_get_reference_enc(ctx->cpi, data->idx, &fb); | 922 vp9_get_reference_enc(ctx->cpi, frame->idx, &fb); |
| 896 yuvconfig2image(&data->img, fb, NULL); | 923 yuvconfig2image(&frame->img, fb, NULL); |
| 897 return VPX_CODEC_OK; | 924 return VPX_CODEC_OK; |
| 898 } else { | 925 } else { |
| 899 return VPX_CODEC_INVALID_PARAM; | 926 return VPX_CODEC_INVALID_PARAM; |
| 900 } | 927 } |
| 901 } | 928 } |
| 902 | 929 |
| 903 static vpx_codec_err_t vp9e_set_previewpp(vpx_codec_alg_priv_t *ctx, | 930 static vpx_codec_err_t vp9e_set_previewpp(vpx_codec_alg_priv_t *ctx, |
| 904 int ctr_id, | 931 int ctr_id, |
| 905 va_list args) { | 932 va_list args) { |
| 906 #if CONFIG_VP9_POSTPROC | 933 #if CONFIG_VP9_POSTPROC |
| 907 vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *); | 934 vp8_postproc_cfg_t *config = va_arg(args, vp8_postproc_cfg_t *); |
| 908 (void)ctr_id; | 935 (void)ctr_id; |
| 909 | 936 |
| 910 if (data) { | 937 if (config != NULL) { |
| 911 ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data); | 938 ctx->preview_ppcfg = *config; |
| 912 return VPX_CODEC_OK; | 939 return VPX_CODEC_OK; |
| 913 } else { | 940 } else { |
| 914 return VPX_CODEC_INVALID_PARAM; | 941 return VPX_CODEC_INVALID_PARAM; |
| 915 } | 942 } |
| 916 #else | 943 #else |
| 917 (void)ctx; | 944 (void)ctx; |
| 918 (void)ctr_id; | 945 (void)ctr_id; |
| 919 (void)args; | 946 (void)args; |
| 920 return VPX_CODEC_INCAPABLE; | 947 return VPX_CODEC_INCAPABLE; |
| 921 #endif | 948 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 static vpx_codec_err_t vp9e_set_activemap(vpx_codec_alg_priv_t *ctx, | 1002 static vpx_codec_err_t vp9e_set_activemap(vpx_codec_alg_priv_t *ctx, |
| 976 int ctr_id, | 1003 int ctr_id, |
| 977 va_list args) { | 1004 va_list args) { |
| 978 // TODO(yaowu): Need to re-implement and test for VP9. | 1005 // TODO(yaowu): Need to re-implement and test for VP9. |
| 979 return VPX_CODEC_INVALID_PARAM; | 1006 return VPX_CODEC_INVALID_PARAM; |
| 980 } | 1007 } |
| 981 | 1008 |
| 982 static vpx_codec_err_t vp9e_set_scalemode(vpx_codec_alg_priv_t *ctx, | 1009 static vpx_codec_err_t vp9e_set_scalemode(vpx_codec_alg_priv_t *ctx, |
| 983 int ctr_id, | 1010 int ctr_id, |
| 984 va_list args) { | 1011 va_list args) { |
| 985 vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *); | 1012 vpx_scaling_mode_t *scalemode = va_arg(args, vpx_scaling_mode_t *); |
| 986 | 1013 |
| 987 if (data) { | 1014 if (scalemode != NULL) { |
| 988 int res; | 1015 int res; |
| 989 vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data; | |
| 990 res = vp9_set_internal_size(ctx->cpi, | 1016 res = vp9_set_internal_size(ctx->cpi, |
| 991 (VPX_SCALING)scalemode.h_scaling_mode, | 1017 (VPX_SCALING)scalemode->h_scaling_mode, |
| 992 (VPX_SCALING)scalemode.v_scaling_mode); | 1018 (VPX_SCALING)scalemode->v_scaling_mode); |
| 993 | 1019 return (res == 0) ? VPX_CODEC_OK : VPX_CODEC_INVALID_PARAM; |
| 994 if (!res) { | |
| 995 return VPX_CODEC_OK; | |
| 996 } else { | |
| 997 return VPX_CODEC_INVALID_PARAM; | |
| 998 } | |
| 999 } else { | 1020 } else { |
| 1000 return VPX_CODEC_INVALID_PARAM; | 1021 return VPX_CODEC_INVALID_PARAM; |
| 1001 } | 1022 } |
| 1002 } | 1023 } |
| 1003 | 1024 |
| 1004 static vpx_codec_err_t vp9e_set_svc(vpx_codec_alg_priv_t *ctx, int ctr_id, | 1025 static vpx_codec_err_t vp9e_set_svc(vpx_codec_alg_priv_t *ctx, int ctr_id, |
| 1005 va_list args) { | 1026 va_list args) { |
| 1006 int data = va_arg(args, int); | 1027 int data = va_arg(args, int); |
| 1007 vp9_set_svc(ctx->cpi, data); | 1028 vp9_set_svc(ctx->cpi, data); |
| 1029 // CBR mode for SVC with both temporal and spatial layers not yet supported. |
| 1030 if (data == 1 && |
| 1031 ctx->cfg.rc_end_usage == VPX_CBR && |
| 1032 ctx->cfg.ss_number_layers > 1 && |
| 1033 ctx->cfg.ts_number_layers > 1) { |
| 1034 return VPX_CODEC_INVALID_PARAM; |
| 1035 } |
| 1036 return VPX_CODEC_OK; |
| 1037 } |
| 1038 |
| 1039 static vpx_codec_err_t vp9e_set_svc_layer_id(vpx_codec_alg_priv_t *ctx, |
| 1040 int ctr_id, |
| 1041 va_list args) { |
| 1042 vpx_svc_layer_id_t *data = va_arg(args, vpx_svc_layer_id_t *); |
| 1043 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; |
| 1044 cpi->svc.spatial_layer_id = data->spatial_layer_id; |
| 1045 cpi->svc.temporal_layer_id = data->temporal_layer_id; |
| 1046 // Checks on valid layer_id input. |
| 1047 if (cpi->svc.temporal_layer_id < 0 || |
| 1048 cpi->svc.temporal_layer_id >= (int)ctx->cfg.ts_number_layers) { |
| 1049 return VPX_CODEC_INVALID_PARAM; |
| 1050 } |
| 1051 if (cpi->svc.spatial_layer_id < 0 || |
| 1052 cpi->svc.spatial_layer_id >= ctx->cfg.ss_number_layers) { |
| 1053 return VPX_CODEC_INVALID_PARAM; |
| 1054 } |
| 1008 return VPX_CODEC_OK; | 1055 return VPX_CODEC_OK; |
| 1009 } | 1056 } |
| 1010 | 1057 |
| 1011 static vpx_codec_err_t vp9e_set_svc_parameters(vpx_codec_alg_priv_t *ctx, | 1058 static vpx_codec_err_t vp9e_set_svc_parameters(vpx_codec_alg_priv_t *ctx, |
| 1012 int ctr_id, va_list args) { | 1059 int ctr_id, va_list args) { |
| 1013 vpx_svc_parameters_t *data = va_arg(args, vpx_svc_parameters_t *); | |
| 1014 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; | 1060 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi; |
| 1015 vpx_svc_parameters_t params; | 1061 vpx_svc_parameters_t *params = va_arg(args, vpx_svc_parameters_t *); |
| 1016 | 1062 |
| 1017 if (data == NULL) { | 1063 if (params == NULL) return VPX_CODEC_INVALID_PARAM; |
| 1064 |
| 1065 cpi->svc.spatial_layer_id = params->spatial_layer; |
| 1066 cpi->svc.temporal_layer_id = params->temporal_layer; |
| 1067 |
| 1068 cpi->lst_fb_idx = params->lst_fb_idx; |
| 1069 cpi->gld_fb_idx = params->gld_fb_idx; |
| 1070 cpi->alt_fb_idx = params->alt_fb_idx; |
| 1071 |
| 1072 if (vp9_set_size_literal(ctx->cpi, params->width, params->height) != 0) |
| 1018 return VPX_CODEC_INVALID_PARAM; | 1073 return VPX_CODEC_INVALID_PARAM; |
| 1019 } | |
| 1020 | 1074 |
| 1021 params = *(vpx_svc_parameters_t *)data; | 1075 ctx->cfg.rc_max_quantizer = params->max_quantizer; |
| 1022 | 1076 ctx->cfg.rc_min_quantizer = params->min_quantizer; |
| 1023 cpi->current_layer = params.layer; | |
| 1024 cpi->lst_fb_idx = params.lst_fb_idx; | |
| 1025 cpi->gld_fb_idx = params.gld_fb_idx; | |
| 1026 cpi->alt_fb_idx = params.alt_fb_idx; | |
| 1027 | |
| 1028 if (vp9_set_size_literal(ctx->cpi, params.width, params.height) != 0) { | |
| 1029 return VPX_CODEC_INVALID_PARAM; | |
| 1030 } | |
| 1031 | |
| 1032 ctx->cfg.rc_max_quantizer = params.max_quantizer; | |
| 1033 ctx->cfg.rc_min_quantizer = params.min_quantizer; | |
| 1034 | 1077 |
| 1035 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); | 1078 set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); |
| 1036 vp9_change_config(ctx->cpi, &ctx->oxcf); | 1079 vp9_change_config(ctx->cpi, &ctx->oxcf); |
| 1037 | 1080 |
| 1038 return VPX_CODEC_OK; | 1081 return VPX_CODEC_OK; |
| 1039 } | 1082 } |
| 1040 | 1083 |
| 1041 static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { | 1084 static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { |
| 1042 {VP8_SET_REFERENCE, vp9e_set_reference}, | 1085 {VP8_SET_REFERENCE, vp9e_set_reference}, |
| 1043 {VP8_COPY_REFERENCE, vp9e_copy_reference}, | 1086 {VP8_COPY_REFERENCE, vp9e_copy_reference}, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1062 {VP8E_SET_ARNR_TYPE, set_param}, | 1105 {VP8E_SET_ARNR_TYPE, set_param}, |
| 1063 {VP8E_SET_TUNING, set_param}, | 1106 {VP8E_SET_TUNING, set_param}, |
| 1064 {VP8E_SET_CQ_LEVEL, set_param}, | 1107 {VP8E_SET_CQ_LEVEL, set_param}, |
| 1065 {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, | 1108 {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, |
| 1066 {VP9E_SET_LOSSLESS, set_param}, | 1109 {VP9E_SET_LOSSLESS, set_param}, |
| 1067 {VP9E_SET_FRAME_PARALLEL_DECODING, set_param}, | 1110 {VP9E_SET_FRAME_PARALLEL_DECODING, set_param}, |
| 1068 {VP9E_SET_AQ_MODE, set_param}, | 1111 {VP9E_SET_AQ_MODE, set_param}, |
| 1069 {VP9_GET_REFERENCE, get_reference}, | 1112 {VP9_GET_REFERENCE, get_reference}, |
| 1070 {VP9E_SET_SVC, vp9e_set_svc}, | 1113 {VP9E_SET_SVC, vp9e_set_svc}, |
| 1071 {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters}, | 1114 {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters}, |
| 1115 {VP9E_SET_SVC_LAYER_ID, vp9e_set_svc_layer_id}, |
| 1072 { -1, NULL}, | 1116 { -1, NULL}, |
| 1073 }; | 1117 }; |
| 1074 | 1118 |
| 1075 static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { | 1119 static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { |
| 1076 { | 1120 { |
| 1077 0, | 1121 0, |
| 1078 { // NOLINT | 1122 { // NOLINT |
| 1079 0, /* g_usage */ | 1123 0, /* g_usage */ |
| 1080 0, /* g_threads */ | 1124 0, /* g_threads */ |
| 1081 0, /* g_profile */ | 1125 0, /* g_profile */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1112 50, /* rc_two_pass_vbrbias */ | 1156 50, /* rc_two_pass_vbrbias */ |
| 1113 0, /* rc_two_pass_vbrmin_section */ | 1157 0, /* rc_two_pass_vbrmin_section */ |
| 1114 2000, /* rc_two_pass_vbrmax_section */ | 1158 2000, /* rc_two_pass_vbrmax_section */ |
| 1115 | 1159 |
| 1116 /* keyframing settings (kf) */ | 1160 /* keyframing settings (kf) */ |
| 1117 VPX_KF_AUTO, /* g_kfmode*/ | 1161 VPX_KF_AUTO, /* g_kfmode*/ |
| 1118 0, /* kf_min_dist */ | 1162 0, /* kf_min_dist */ |
| 1119 9999, /* kf_max_dist */ | 1163 9999, /* kf_max_dist */ |
| 1120 | 1164 |
| 1121 VPX_SS_DEFAULT_LAYERS, /* ss_number_layers */ | 1165 VPX_SS_DEFAULT_LAYERS, /* ss_number_layers */ |
| 1122 | 1166 1, /* ts_number_layers */ |
| 1167 {0}, /* ts_target_bitrate */ |
| 1168 {0}, /* ts_rate_decimator */ |
| 1169 0, /* ts_periodicity */ |
| 1170 {0}, /* ts_layer_id */ |
| 1123 #if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION) | 1171 #if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION) |
| 1124 1, /* g_delete_first_pass_file */ | |
| 1125 "vp8.fpf" /* first pass filename */ | 1172 "vp8.fpf" /* first pass filename */ |
| 1126 #endif | 1173 #endif |
| 1127 } | 1174 } |
| 1128 }, | 1175 }, |
| 1129 { -1, {NOT_IMPLEMENTED}} | 1176 { -1, {NOT_IMPLEMENTED}} |
| 1130 }; | 1177 }; |
| 1131 | 1178 |
| 1132 | 1179 |
| 1133 #ifndef VERSION_STRING | 1180 #ifndef VERSION_STRING |
| 1134 #define VERSION_STRING | 1181 #define VERSION_STRING |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1152 }, | 1199 }, |
| 1153 { // NOLINT | 1200 { // NOLINT |
| 1154 vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ | 1201 vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ |
| 1155 vp9e_encode, /* vpx_codec_encode_fn_t encode; */ | 1202 vp9e_encode, /* vpx_codec_encode_fn_t encode; */ |
| 1156 vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ | 1203 vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ |
| 1157 vp9e_set_config, | 1204 vp9e_set_config, |
| 1158 NOT_IMPLEMENTED, | 1205 NOT_IMPLEMENTED, |
| 1159 vp9e_get_preview, | 1206 vp9e_get_preview, |
| 1160 } /* encoder functions */ | 1207 } /* encoder functions */ |
| 1161 }; | 1208 }; |
| OLD | NEW |