FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/videodsp_template.c
Date: 2026-05-02 17:52:23
Exec Total Coverage
Lines: 42 43 97.7%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec 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 16930030 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 {
30 int x, y;
31 int start_y, start_x, end_y, end_x;
32
33 16930030 if (!w || !h)
34 return;
35
36 av_assert2(block_w * sizeof(pixel) <= FFABS(buf_linesize));
37
38 16930030 if (src_y >= h) {
39 230619 src -= src_y * src_linesize;
40 230619 src += (h - 1) * src_linesize;
41 230619 src_y = h - 1;
42 16699411 } else if (src_y <= -block_h) {
43 100952 src -= src_y * src_linesize;
44 100952 src += (1 - block_h) * src_linesize;
45 100952 src_y = 1 - block_h;
46 }
47 16930030 if (src_x >= w) {
48 // The subtracted expression has an unsigned type and must thus not be negative
49 250788 src -= (1 + src_x - w) * sizeof(pixel);
50 250788 src_x = w - 1;
51 16679242 } else if (src_x <= -block_w) {
52 104252 src += (1 - block_w - src_x) * sizeof(pixel);
53 104252 src_x = 1 - block_w;
54 }
55
56 16930030 start_y = FFMAX(0, -src_y);
57 16930030 start_x = FFMAX(0, -src_x);
58 16930030 end_y = FFMIN(block_h, h-src_y);
59 16930030 end_x = FFMIN(block_w, w-src_x);
60 av_assert2(start_y < end_y && block_h);
61 av_assert2(start_x < end_x && block_w);
62
63 16930030 w = end_x - start_x;
64 16930030 src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel);
65 16930030 buf += start_x * sizeof(pixel);
66
67 // top
68 25599458 for (y = 0; y < start_y; y++) {
69 8669428 memcpy(buf, src, w * sizeof(pixel));
70 8669428 buf += buf_linesize;
71 }
72
73 // copy existing part
74 232398487 for (; y < end_y; y++) {
75 215468457 memcpy(buf, src, w * sizeof(pixel));
76 215468457 src += src_linesize;
77 215468457 buf += buf_linesize;
78 }
79
80 // bottom
81 16930030 src -= src_linesize;
82 45458819 for (; y < block_h; y++) {
83 28528789 memcpy(buf, src, w * sizeof(pixel));
84 28528789 buf += buf_linesize;
85 }
86
87 16930030 buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel);
88 269596704 while (block_h--) {
89 252666674 pixel *bufp = (pixel *) buf;
90
91 // left
92 379747173 for(x = 0; x < start_x; x++) {
93 127080499 bufp[x] = bufp[start_x];
94 }
95
96 // right
97 530954128 for (x = end_x; x < block_w; x++) {
98 278287454 bufp[x] = bufp[end_x - 1];
99 }
100 252666674 buf += buf_linesize;
101 }
102 }
103