| 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 17 matching lines...) Expand all Loading... |
| 28 #include "vp9/common/vp9_systemdependent.h" | 28 #include "vp9/common/vp9_systemdependent.h" |
| 29 #include "vp9/common/vp9_tile_common.h" | 29 #include "vp9/common/vp9_tile_common.h" |
| 30 | 30 |
| 31 #include "vp9/encoder/vp9_aq_complexity.h" | 31 #include "vp9/encoder/vp9_aq_complexity.h" |
| 32 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" | 32 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" |
| 33 #include "vp9/encoder/vp9_aq_variance.h" | 33 #include "vp9/encoder/vp9_aq_variance.h" |
| 34 #include "vp9/encoder/vp9_bitstream.h" | 34 #include "vp9/encoder/vp9_bitstream.h" |
| 35 #include "vp9/encoder/vp9_context_tree.h" | 35 #include "vp9/encoder/vp9_context_tree.h" |
| 36 #include "vp9/encoder/vp9_encodeframe.h" | 36 #include "vp9/encoder/vp9_encodeframe.h" |
| 37 #include "vp9/encoder/vp9_encodemv.h" | 37 #include "vp9/encoder/vp9_encodemv.h" |
| 38 #include "vp9/encoder/vp9_encoder.h" |
| 38 #include "vp9/encoder/vp9_ethread.h" | 39 #include "vp9/encoder/vp9_ethread.h" |
| 39 #include "vp9/encoder/vp9_firstpass.h" | 40 #include "vp9/encoder/vp9_firstpass.h" |
| 40 #include "vp9/encoder/vp9_mbgraph.h" | 41 #include "vp9/encoder/vp9_mbgraph.h" |
| 41 #include "vp9/encoder/vp9_encoder.h" | |
| 42 #include "vp9/encoder/vp9_picklpf.h" | 42 #include "vp9/encoder/vp9_picklpf.h" |
| 43 #include "vp9/encoder/vp9_ratectrl.h" | 43 #include "vp9/encoder/vp9_ratectrl.h" |
| 44 #include "vp9/encoder/vp9_rd.h" | 44 #include "vp9/encoder/vp9_rd.h" |
| 45 #include "vp9/encoder/vp9_resize.h" |
| 45 #include "vp9/encoder/vp9_segmentation.h" | 46 #include "vp9/encoder/vp9_segmentation.h" |
| 47 #include "vp9/encoder/vp9_skin_detection.h" |
| 46 #include "vp9/encoder/vp9_speed_features.h" | 48 #include "vp9/encoder/vp9_speed_features.h" |
| 47 #if CONFIG_INTERNAL_STATS | 49 #if CONFIG_INTERNAL_STATS |
| 48 #include "vp9/encoder/vp9_ssim.h" | 50 #include "vp9/encoder/vp9_ssim.h" |
| 49 #endif | 51 #endif |
| 52 #include "vp9/encoder/vp9_svc_layercontext.h" |
| 50 #include "vp9/encoder/vp9_temporal_filter.h" | 53 #include "vp9/encoder/vp9_temporal_filter.h" |
| 51 #include "vp9/encoder/vp9_resize.h" | |
| 52 #include "vp9/encoder/vp9_svc_layercontext.h" | |
| 53 #include "vp9/encoder/vp9_skin_detection.h" | |
| 54 | 54 |
| 55 #define AM_SEGMENT_ID_INACTIVE 7 | 55 #define AM_SEGMENT_ID_INACTIVE 7 |
| 56 #define AM_SEGMENT_ID_ACTIVE 0 | 56 #define AM_SEGMENT_ID_ACTIVE 0 |
| 57 | 57 |
| 58 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ | 58 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ |
| 59 | 59 |
| 60 #define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv | 60 #define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv |
| 61 // for altref computation. | 61 // for altref computation. |
| 62 #define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision | 62 #define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision |
| 63 // mv. Choose a very high value for | 63 // mv. Choose a very high value for |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 break; | 1316 break; |
| 1317 | 1317 |
| 1318 default: | 1318 default: |
| 1319 assert(0 && "cm->bit_depth should be VPX_BITS_8, " | 1319 assert(0 && "cm->bit_depth should be VPX_BITS_8, " |
| 1320 "VPX_BITS_10 or VPX_BITS_12"); | 1320 "VPX_BITS_10 or VPX_BITS_12"); |
| 1321 } | 1321 } |
| 1322 } | 1322 } |
| 1323 } | 1323 } |
| 1324 #endif // CONFIG_VP9_HIGHBITDEPTH | 1324 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 1325 | 1325 |
| 1326 static void realloc_segmentation_maps(VP9_COMP *cpi) { |
| 1327 VP9_COMMON *const cm = &cpi->common; |
| 1328 |
| 1329 // Create the encoder segmentation map and set all entries to 0 |
| 1330 vpx_free(cpi->segmentation_map); |
| 1331 CHECK_MEM_ERROR(cm, cpi->segmentation_map, |
| 1332 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); |
| 1333 |
| 1334 // Create a map used for cyclic background refresh. |
| 1335 if (cpi->cyclic_refresh) |
| 1336 vp9_cyclic_refresh_free(cpi->cyclic_refresh); |
| 1337 CHECK_MEM_ERROR(cm, cpi->cyclic_refresh, |
| 1338 vp9_cyclic_refresh_alloc(cm->mi_rows, cm->mi_cols)); |
| 1339 |
| 1340 // Create a map used to mark inactive areas. |
| 1341 vpx_free(cpi->active_map.map); |
| 1342 CHECK_MEM_ERROR(cm, cpi->active_map.map, |
| 1343 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); |
| 1344 |
| 1345 // And a place holder structure is the coding context |
| 1346 // for use if we want to save and restore it |
| 1347 vpx_free(cpi->coding_context.last_frame_seg_map_copy); |
| 1348 CHECK_MEM_ERROR(cm, cpi->coding_context.last_frame_seg_map_copy, |
| 1349 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); |
| 1350 } |
| 1351 |
| 1326 void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { | 1352 void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { |
| 1327 VP9_COMMON *const cm = &cpi->common; | 1353 VP9_COMMON *const cm = &cpi->common; |
| 1328 RATE_CONTROL *const rc = &cpi->rc; | 1354 RATE_CONTROL *const rc = &cpi->rc; |
| 1329 | 1355 |
| 1330 if (cm->profile != oxcf->profile) | 1356 if (cm->profile != oxcf->profile) |
| 1331 cm->profile = oxcf->profile; | 1357 cm->profile = oxcf->profile; |
| 1332 cm->bit_depth = oxcf->bit_depth; | 1358 cm->bit_depth = oxcf->bit_depth; |
| 1333 cm->color_space = oxcf->color_space; | 1359 cm->color_space = oxcf->color_space; |
| 1334 | 1360 |
| 1335 if (cm->profile <= PROFILE_1) | 1361 if (cm->profile <= PROFILE_1) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 cm->interp_filter = cpi->sf.default_interp_filter; | 1403 cm->interp_filter = cpi->sf.default_interp_filter; |
| 1378 | 1404 |
| 1379 cm->display_width = cpi->oxcf.width; | 1405 cm->display_width = cpi->oxcf.width; |
| 1380 cm->display_height = cpi->oxcf.height; | 1406 cm->display_height = cpi->oxcf.height; |
| 1381 cm->width = cpi->oxcf.width; | 1407 cm->width = cpi->oxcf.width; |
| 1382 cm->height = cpi->oxcf.height; | 1408 cm->height = cpi->oxcf.height; |
| 1383 | 1409 |
| 1384 if (cpi->initial_width) { | 1410 if (cpi->initial_width) { |
| 1385 if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) { | 1411 if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) { |
| 1386 vp9_free_context_buffers(cm); | 1412 vp9_free_context_buffers(cm); |
| 1387 vp9_alloc_context_buffers(cm, cm->width, cm->height); | 1413 vp9_alloc_compressor_data(cpi); |
| 1414 realloc_segmentation_maps(cpi); |
| 1388 cpi->initial_width = cpi->initial_height = 0; | 1415 cpi->initial_width = cpi->initial_height = 0; |
| 1389 } | 1416 } |
| 1390 } | 1417 } |
| 1391 update_frame_size(cpi); | 1418 update_frame_size(cpi); |
| 1392 | 1419 |
| 1393 if ((cpi->svc.number_temporal_layers > 1 && | 1420 if ((cpi->svc.number_temporal_layers > 1 && |
| 1394 cpi->oxcf.rc_mode == VPX_CBR) || | 1421 cpi->oxcf.rc_mode == VPX_CBR) || |
| 1395 ((cpi->svc.number_temporal_layers > 1 || | 1422 ((cpi->svc.number_temporal_layers > 1 || |
| 1396 cpi->svc.number_spatial_layers > 1) && | 1423 cpi->svc.number_spatial_layers > 1) && |
| 1397 cpi->oxcf.pass != 1)) { | 1424 cpi->oxcf.pass != 1)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 cpi->use_svc = 0; | 1519 cpi->use_svc = 0; |
| 1493 cpi->common.buffer_pool = pool; | 1520 cpi->common.buffer_pool = pool; |
| 1494 | 1521 |
| 1495 init_config(cpi, oxcf); | 1522 init_config(cpi, oxcf); |
| 1496 vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); | 1523 vp9_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc); |
| 1497 | 1524 |
| 1498 cm->current_video_frame = 0; | 1525 cm->current_video_frame = 0; |
| 1499 cpi->partition_search_skippable_frame = 0; | 1526 cpi->partition_search_skippable_frame = 0; |
| 1500 cpi->tile_data = NULL; | 1527 cpi->tile_data = NULL; |
| 1501 | 1528 |
| 1502 // TODO(aconverse): Realloc these tables on frame resize | 1529 realloc_segmentation_maps(cpi); |
| 1503 // Create the encoder segmentation map and set all entries to 0 | |
| 1504 CHECK_MEM_ERROR(cm, cpi->segmentation_map, | |
| 1505 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); | |
| 1506 | |
| 1507 // Create a map used for cyclic background refresh. | |
| 1508 CHECK_MEM_ERROR(cm, cpi->cyclic_refresh, | |
| 1509 vp9_cyclic_refresh_alloc(cm->mi_rows, cm->mi_cols)); | |
| 1510 | |
| 1511 CHECK_MEM_ERROR(cm, cpi->active_map.map, | |
| 1512 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); | |
| 1513 | |
| 1514 // And a place holder structure is the coding context | |
| 1515 // for use if we want to save and restore it | |
| 1516 CHECK_MEM_ERROR(cm, cpi->coding_context.last_frame_seg_map_copy, | |
| 1517 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); | |
| 1518 | 1530 |
| 1519 CHECK_MEM_ERROR(cm, cpi->nmvcosts[0], | 1531 CHECK_MEM_ERROR(cm, cpi->nmvcosts[0], |
| 1520 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts[0]))); | 1532 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts[0]))); |
| 1521 CHECK_MEM_ERROR(cm, cpi->nmvcosts[1], | 1533 CHECK_MEM_ERROR(cm, cpi->nmvcosts[1], |
| 1522 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts[1]))); | 1534 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts[1]))); |
| 1523 CHECK_MEM_ERROR(cm, cpi->nmvcosts_hp[0], | 1535 CHECK_MEM_ERROR(cm, cpi->nmvcosts_hp[0], |
| 1524 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts_hp[0]))); | 1536 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts_hp[0]))); |
| 1525 CHECK_MEM_ERROR(cm, cpi->nmvcosts_hp[1], | 1537 CHECK_MEM_ERROR(cm, cpi->nmvcosts_hp[1], |
| 1526 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts_hp[1]))); | 1538 vpx_calloc(MV_VALS, sizeof(*cpi->nmvcosts_hp[1]))); |
| 1527 CHECK_MEM_ERROR(cm, cpi->nmvsadcosts[0], | 1539 CHECK_MEM_ERROR(cm, cpi->nmvsadcosts[0], |
| (...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 if (flags & VP8_EFLAG_NO_UPD_ARF) | 4295 if (flags & VP8_EFLAG_NO_UPD_ARF) |
| 4284 upd ^= VP9_ALT_FLAG; | 4296 upd ^= VP9_ALT_FLAG; |
| 4285 | 4297 |
| 4286 vp9_update_reference(cpi, upd); | 4298 vp9_update_reference(cpi, upd); |
| 4287 } | 4299 } |
| 4288 | 4300 |
| 4289 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { | 4301 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) { |
| 4290 vp9_update_entropy(cpi, 0); | 4302 vp9_update_entropy(cpi, 0); |
| 4291 } | 4303 } |
| 4292 } | 4304 } |
| OLD | NEW |