| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "libavutil/mem.h" | ||
| 20 | #include "libavfilter/vf_nlmeans.c" | ||
| 21 | |||
| 22 | 98 | static void display_integral(const uint32_t *ii, int w, int h, int lz_32) | |
| 23 | { | ||
| 24 | int x, y; | ||
| 25 | |||
| 26 |
2/2✓ Branch 0 taken 1078 times.
✓ Branch 1 taken 98 times.
|
1176 | for (y = 0; y < h; y++) { |
| 27 |
2/2✓ Branch 0 taken 12936 times.
✓ Branch 1 taken 1078 times.
|
14014 | for (x = 0; x < w; x++) |
| 28 | 12936 | printf(" %7x", ii[y*lz_32 + x]); | |
| 29 | 1078 | printf("\n"); | |
| 30 | } | ||
| 31 | 98 | printf("---------------\n"); | |
| 32 | 98 | } | |
| 33 | |||
| 34 | 1 | int main(void) | |
| 35 | { | ||
| 36 | 1 | int ret = 0, xoff, yoff; | |
| 37 | uint32_t *ii_start; | ||
| 38 | uint32_t *ii_start2; | ||
| 39 | 1 | NLMeansDSPContext dsp = {0}; | |
| 40 | |||
| 41 | // arbitrary test source of size 6x5 and linesize=8 | ||
| 42 | 1 | const int w = 6, h = 5, lz = 8; | |
| 43 | static const uint8_t src[] = { | ||
| 44 | 0xb0, 0x71, 0xfb, 0xd8, 0x01, 0xd9, /***/ 0x01, 0x02, | ||
| 45 | 0x51, 0x8e, 0x41, 0x0f, 0x84, 0x58, /***/ 0x03, 0x04, | ||
| 46 | 0xc7, 0x8d, 0x07, 0x70, 0x5c, 0x47, /***/ 0x05, 0x06, | ||
| 47 | 0x09, 0x4e, 0xfc, 0x74, 0x8f, 0x9a, /***/ 0x07, 0x08, | ||
| 48 | 0x60, 0x8e, 0x20, 0xaa, 0x95, 0x7d, /***/ 0x09, 0x0a, | ||
| 49 | }; | ||
| 50 | |||
| 51 | 1 | const int e = 3; | |
| 52 | 1 | const int ii_w = w+e*2, ii_h = h+e*2; | |
| 53 | |||
| 54 | // align to 4 the linesize, "+1" is for the space of the left 0-column | ||
| 55 | 1 | const int ii_lz_32 = ((ii_w + 1) + 3) & ~3; | |
| 56 | |||
| 57 | // "+1" is for the space of the top 0-line | ||
| 58 | 1 | uint32_t *ii = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii)); | |
| 59 | 1 | uint32_t *ii2 = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii2)); | |
| 60 | |||
| 61 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (!ii || !ii2) |
| 62 | ✗ | return -1; | |
| 63 | |||
| 64 | 1 | ii_start = ii + ii_lz_32 + 1; // skip top 0-line and left 0-column | |
| 65 | 1 | ii_start2 = ii2 + ii_lz_32 + 1; // skip top 0-line and left 0-column | |
| 66 | |||
| 67 | 1 | ff_nlmeans_init(&dsp); | |
| 68 | |||
| 69 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
|
8 | for (yoff = -e; yoff <= e; yoff++) { |
| 70 |
2/2✓ Branch 0 taken 49 times.
✓ Branch 1 taken 7 times.
|
56 | for (xoff = -e; xoff <= e; xoff++) { |
| 71 | 49 | printf("xoff=%d yoff=%d\n", xoff, yoff); | |
| 72 | |||
| 73 | 49 | compute_ssd_integral_image(&dsp, ii_start, ii_lz_32, | |
| 74 | src, lz, xoff, yoff, e, w, h); | ||
| 75 | 49 | display_integral(ii_start, ii_w, ii_h, ii_lz_32); | |
| 76 | |||
| 77 | 49 | compute_unsafe_ssd_integral_image(ii_start2, ii_lz_32, | |
| 78 | 0, 0, | ||
| 79 | src, lz, | ||
| 80 | xoff, yoff, e, w, h, | ||
| 81 | ii_w, ii_h); | ||
| 82 | 49 | display_integral(ii_start2, ii_w, ii_h, ii_lz_32); | |
| 83 | |||
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
|
49 | if (memcmp(ii, ii2, (ii_h+1) * ii_lz_32 * sizeof(*ii))) { |
| 85 | ✗ | printf("Integral mismatch\n"); | |
| 86 | ✗ | ret = 1; | |
| 87 | ✗ | goto end; | |
| 88 | } | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | 1 | end: | |
| 93 | 1 | av_freep(&ii); | |
| 94 | 1 | av_freep(&ii2); | |
| 95 | 1 | return ret; | |
| 96 | } | ||
| 97 |