/src/ffmpeg/libavcodec/videodsp_template.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2002-2012 Michael Niedermayer |
3 | | * Copyright (C) 2012 Ronald S. Bultje |
4 | | * |
5 | | * This file is part of FFmpeg. |
6 | | * |
7 | | * FFmpeg is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * FFmpeg is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with FFmpeg; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #include "bit_depth_template.c" |
23 | | |
24 | | static void FUNC(emulated_edge_mc)(uint8_t *buf, const uint8_t *src, |
25 | | ptrdiff_t buf_linesize, |
26 | | ptrdiff_t src_linesize, |
27 | | int block_w, int block_h, |
28 | | int src_x, int src_y, int w, int h) |
29 | 343M | { |
30 | 343M | int x, y; |
31 | 343M | int start_y, start_x, end_y, end_x; |
32 | | |
33 | 343M | if (!w || !h) |
34 | 498k | return; |
35 | | |
36 | 343M | av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize)); |
37 | | |
38 | 343M | if (src_y >= h) { |
39 | 14.6M | src -= src_y * src_linesize; |
40 | 14.6M | src += (h - 1) * src_linesize; |
41 | 14.6M | src_y = h - 1; |
42 | 328M | } else if (src_y <= -block_h) { |
43 | 13.6M | src -= src_y * src_linesize; |
44 | 13.6M | src += (1 - block_h) * src_linesize; |
45 | 13.6M | src_y = 1 - block_h; |
46 | 13.6M | } |
47 | 343M | if (src_x >= w) { |
48 | | // The subtracted expression has an unsigned type and must thus not be negative |
49 | 20.0M | src -= (1 + src_x - w) * sizeof(pixel); |
50 | 20.0M | src_x = w - 1; |
51 | 323M | } else if (src_x <= -block_w) { |
52 | 14.2M | src += (1 - block_w - src_x) * sizeof(pixel); |
53 | 14.2M | src_x = 1 - block_w; |
54 | 14.2M | } |
55 | | |
56 | 343M | start_y = FFMAX(0, -src_y); |
57 | 343M | start_x = FFMAX(0, -src_x); |
58 | 343M | end_y = FFMIN(block_h, h-src_y); |
59 | 343M | end_x = FFMIN(block_w, w-src_x); |
60 | 343M | av_assert2(start_y < end_y && block_h); |
61 | 343M | av_assert2(start_x < end_x && block_w); |
62 | | |
63 | 343M | w = end_x - start_x; |
64 | 343M | src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel); |
65 | 343M | buf += start_x * sizeof(pixel); |
66 | | |
67 | | // top |
68 | 594M | for (y = 0; y < start_y; y++) { |
69 | 250M | memcpy(buf, src, w * sizeof(pixel)); |
70 | 250M | buf += buf_linesize; |
71 | 250M | } |
72 | | |
73 | | // copy existing part |
74 | 3.68G | for (; y < end_y; y++) { |
75 | 3.33G | memcpy(buf, src, w * sizeof(pixel)); |
76 | 3.33G | src += src_linesize; |
77 | 3.33G | buf += buf_linesize; |
78 | 3.33G | } |
79 | | |
80 | | // bottom |
81 | 343M | src -= src_linesize; |
82 | 904M | for (; y < block_h; y++) { |
83 | 560M | memcpy(buf, src, w * sizeof(pixel)); |
84 | 560M | buf += buf_linesize; |
85 | 560M | } |
86 | | |
87 | 343M | buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel); |
88 | 4.49G | while (block_h--) { |
89 | 4.15G | pixel *bufp = (pixel *) buf; |
90 | | |
91 | | // left |
92 | 7.31G | for(x = 0; x < start_x; x++) { |
93 | 3.16G | bufp[x] = bufp[start_x]; |
94 | 3.16G | } |
95 | | |
96 | | // right |
97 | 15.1G | for (x = end_x; x < block_w; x++) { |
98 | 10.9G | bufp[x] = bufp[end_x - 1]; |
99 | 10.9G | } |
100 | 4.15G | buf += buf_linesize; |
101 | 4.15G | } |
102 | 343M | } videodsp.c:emulated_edge_mc_8 Line | Count | Source | 29 | 261M | { | 30 | 261M | int x, y; | 31 | 261M | int start_y, start_x, end_y, end_x; | 32 | | | 33 | 261M | if (!w || !h) | 34 | 498k | return; | 35 | | | 36 | 260M | av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize)); | 37 | | | 38 | 260M | if (src_y >= h) { | 39 | 11.7M | src -= src_y * src_linesize; | 40 | 11.7M | src += (h - 1) * src_linesize; | 41 | 11.7M | src_y = h - 1; | 42 | 249M | } else if (src_y <= -block_h) { | 43 | 7.42M | src -= src_y * src_linesize; | 44 | 7.42M | src += (1 - block_h) * src_linesize; | 45 | 7.42M | src_y = 1 - block_h; | 46 | 7.42M | } | 47 | 260M | if (src_x >= w) { | 48 | | // The subtracted expression has an unsigned type and must thus not be negative | 49 | 14.4M | src -= (1 + src_x - w) * sizeof(pixel); | 50 | 14.4M | src_x = w - 1; | 51 | 246M | } else if (src_x <= -block_w) { | 52 | 6.29M | src += (1 - block_w - src_x) * sizeof(pixel); | 53 | 6.29M | src_x = 1 - block_w; | 54 | 6.29M | } | 55 | | | 56 | 260M | start_y = FFMAX(0, -src_y); | 57 | 260M | start_x = FFMAX(0, -src_x); | 58 | 260M | end_y = FFMIN(block_h, h-src_y); | 59 | 260M | end_x = FFMIN(block_w, w-src_x); | 60 | 260M | av_assert2(start_y < end_y && block_h); | 61 | 260M | av_assert2(start_x < end_x && block_w); | 62 | | | 63 | 260M | w = end_x - start_x; | 64 | 260M | src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel); | 65 | 260M | buf += start_x * sizeof(pixel); | 66 | | | 67 | | // top | 68 | 427M | for (y = 0; y < start_y; y++) { | 69 | 166M | memcpy(buf, src, w * sizeof(pixel)); | 70 | 166M | buf += buf_linesize; | 71 | 166M | } | 72 | | | 73 | | // copy existing part | 74 | 2.74G | for (; y < end_y; y++) { | 75 | 2.48G | memcpy(buf, src, w * sizeof(pixel)); | 76 | 2.48G | src += src_linesize; | 77 | 2.48G | buf += buf_linesize; | 78 | 2.48G | } | 79 | | | 80 | | // bottom | 81 | 260M | src -= src_linesize; | 82 | 656M | for (; y < block_h; y++) { | 83 | 395M | memcpy(buf, src, w * sizeof(pixel)); | 84 | 395M | buf += buf_linesize; | 85 | 395M | } | 86 | | | 87 | 260M | buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel); | 88 | 3.31G | while (block_h--) { | 89 | 3.05G | pixel *bufp = (pixel *) buf; | 90 | | | 91 | | // left | 92 | 4.69G | for(x = 0; x < start_x; x++) { | 93 | 1.64G | bufp[x] = bufp[start_x]; | 94 | 1.64G | } | 95 | | | 96 | | // right | 97 | 10.4G | for (x = end_x; x < block_w; x++) { | 98 | 7.41G | bufp[x] = bufp[end_x - 1]; | 99 | 7.41G | } | 100 | 3.05G | buf += buf_linesize; | 101 | 3.05G | } | 102 | 260M | } |
videodsp.c:emulated_edge_mc_16 Line | Count | Source | 29 | 82.6M | { | 30 | 82.6M | int x, y; | 31 | 82.6M | int start_y, start_x, end_y, end_x; | 32 | | | 33 | 82.6M | if (!w || !h) | 34 | 0 | return; | 35 | | | 36 | 82.6M | av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize)); | 37 | | | 38 | 82.6M | if (src_y >= h) { | 39 | 2.93M | src -= src_y * src_linesize; | 40 | 2.93M | src += (h - 1) * src_linesize; | 41 | 2.93M | src_y = h - 1; | 42 | 79.7M | } else if (src_y <= -block_h) { | 43 | 6.25M | src -= src_y * src_linesize; | 44 | 6.25M | src += (1 - block_h) * src_linesize; | 45 | 6.25M | src_y = 1 - block_h; | 46 | 6.25M | } | 47 | 82.6M | if (src_x >= w) { | 48 | | // The subtracted expression has an unsigned type and must thus not be negative | 49 | 5.60M | src -= (1 + src_x - w) * sizeof(pixel); | 50 | 5.60M | src_x = w - 1; | 51 | 77.0M | } else if (src_x <= -block_w) { | 52 | 7.97M | src += (1 - block_w - src_x) * sizeof(pixel); | 53 | 7.97M | src_x = 1 - block_w; | 54 | 7.97M | } | 55 | | | 56 | 82.6M | start_y = FFMAX(0, -src_y); | 57 | 82.6M | start_x = FFMAX(0, -src_x); | 58 | 82.6M | end_y = FFMIN(block_h, h-src_y); | 59 | 82.6M | end_x = FFMIN(block_w, w-src_x); | 60 | 82.6M | av_assert2(start_y < end_y && block_h); | 61 | 82.6M | av_assert2(start_x < end_x && block_w); | 62 | | | 63 | 82.6M | w = end_x - start_x; | 64 | 82.6M | src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel); | 65 | 82.6M | buf += start_x * sizeof(pixel); | 66 | | | 67 | | // top | 68 | 166M | for (y = 0; y < start_y; y++) { | 69 | 84.0M | memcpy(buf, src, w * sizeof(pixel)); | 70 | 84.0M | buf += buf_linesize; | 71 | 84.0M | } | 72 | | | 73 | | // copy existing part | 74 | 934M | for (; y < end_y; y++) { | 75 | 851M | memcpy(buf, src, w * sizeof(pixel)); | 76 | 851M | src += src_linesize; | 77 | 851M | buf += buf_linesize; | 78 | 851M | } | 79 | | | 80 | | // bottom | 81 | 82.6M | src -= src_linesize; | 82 | 248M | for (; y < block_h; y++) { | 83 | 165M | memcpy(buf, src, w * sizeof(pixel)); | 84 | 165M | buf += buf_linesize; | 85 | 165M | } | 86 | | | 87 | 82.6M | buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel); | 88 | 1.18G | while (block_h--) { | 89 | 1.10G | pixel *bufp = (pixel *) buf; | 90 | | | 91 | | // left | 92 | 2.62G | for(x = 0; x < start_x; x++) { | 93 | 1.52G | bufp[x] = bufp[start_x]; | 94 | 1.52G | } | 95 | | | 96 | | // right | 97 | 4.66G | for (x = end_x; x < block_w; x++) { | 98 | 3.55G | bufp[x] = bufp[end_x - 1]; | 99 | 3.55G | } | 100 | 1.10G | buf += buf_linesize; | 101 | 1.10G | } | 102 | 82.6M | } |
|