OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void vp9_compute_skin_map(VP9_COMP *const cpi, FILE *yuv_skinmap_file) { | 53 void vp9_compute_skin_map(VP9_COMP *const cpi, FILE *yuv_skinmap_file) { |
54 int i, j, mi_row, mi_col; | 54 int i, j, mi_row, mi_col; |
55 VP9_COMMON *const cm = &cpi->common; | 55 VP9_COMMON *const cm = &cpi->common; |
56 uint8_t *y; | 56 uint8_t *y; |
57 const uint8_t *src_y = cpi->Source->y_buffer; | 57 const uint8_t *src_y = cpi->Source->y_buffer; |
58 const uint8_t *src_u = cpi->Source->u_buffer; | 58 const uint8_t *src_u = cpi->Source->u_buffer; |
59 const uint8_t *src_v = cpi->Source->v_buffer; | 59 const uint8_t *src_v = cpi->Source->v_buffer; |
60 const int src_ystride = cpi->Source->y_stride; | 60 const int src_ystride = cpi->Source->y_stride; |
61 const int src_uvstride = cpi->Source->uv_stride; | 61 const int src_uvstride = cpi->Source->uv_stride; |
62 YV12_BUFFER_CONFIG skinmap; | 62 YV12_BUFFER_CONFIG skinmap; |
63 vpx_memset(&skinmap, 0, sizeof(YV12_BUFFER_CONFIG)); | 63 memset(&skinmap, 0, sizeof(YV12_BUFFER_CONFIG)); |
64 if (vp9_alloc_frame_buffer(&skinmap, cm->width, cm->height, | 64 if (vp9_alloc_frame_buffer(&skinmap, cm->width, cm->height, |
65 cm->subsampling_x, cm->subsampling_y, | 65 cm->subsampling_x, cm->subsampling_y, |
66 VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment)) { | 66 VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment)) { |
67 vp9_free_frame_buffer(&skinmap); | 67 vp9_free_frame_buffer(&skinmap); |
68 return; | 68 return; |
69 } | 69 } |
70 vpx_memset(skinmap.buffer_alloc, 128, skinmap.frame_size); | 70 memset(skinmap.buffer_alloc, 128, skinmap.frame_size); |
71 y = skinmap.y_buffer; | 71 y = skinmap.y_buffer; |
72 // Loop through 8x8 blocks and set skin map based on center pixel of block. | 72 // Loop through 8x8 blocks and set skin map based on center pixel of block. |
73 // Set y to white for skin block, otherwise set to source with gray scale. | 73 // Set y to white for skin block, otherwise set to source with gray scale. |
74 // Ignore rightmost/bottom boundary blocks. | 74 // Ignore rightmost/bottom boundary blocks. |
75 for (mi_row = 0; mi_row < cm->mi_rows - 1; ++mi_row) { | 75 for (mi_row = 0; mi_row < cm->mi_rows - 1; ++mi_row) { |
76 for (mi_col = 0; mi_col < cm->mi_cols - 1; ++mi_col) { | 76 for (mi_col = 0; mi_col < cm->mi_cols - 1; ++mi_col) { |
77 // Use middle pixel for each 8x8 block for skin detection. | 77 // Use middle pixel for each 8x8 block for skin detection. |
78 // If middle pixel is skin, assign whole 8x8 block to skin. | 78 // If middle pixel is skin, assign whole 8x8 block to skin. |
79 const uint8_t ysource = src_y[4 * src_ystride + 4]; | 79 const uint8_t ysource = src_y[4 * src_ystride + 4]; |
80 const uint8_t usource = src_u[2 * src_uvstride + 2]; | 80 const uint8_t usource = src_u[2 * src_uvstride + 2]; |
(...skipping 14 matching lines...) Expand all Loading... |
95 } | 95 } |
96 y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3); | 96 y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3); |
97 src_y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3); | 97 src_y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3); |
98 src_u += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2); | 98 src_u += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2); |
99 src_v += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2); | 99 src_v += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2); |
100 } | 100 } |
101 vp9_write_yuv_frame_420(&skinmap, yuv_skinmap_file); | 101 vp9_write_yuv_frame_420(&skinmap, yuv_skinmap_file); |
102 vp9_free_frame_buffer(&skinmap); | 102 vp9_free_frame_buffer(&skinmap); |
103 } | 103 } |
104 #endif | 104 #endif |
OLD | NEW |