| 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 <stdio.h> | ||
| 20 | |||
| 21 | #include "libavutil/pixdesc.h" | ||
| 22 | #include "libavfilter/drawutils.h" | ||
| 23 | |||
| 24 | 1 | int main(void) | |
| 25 | { | ||
| 26 | enum AVPixelFormat f; | ||
| 27 | const AVPixFmtDescriptor *desc; | ||
| 28 | FFDrawContext draw; | ||
| 29 | FFDrawColor color; | ||
| 30 | int r, i; | ||
| 31 | |||
| 32 |
2/2✓ Branch 1 taken 268 times.
✓ Branch 2 taken 1 times.
|
269 | for (f = 0; av_pix_fmt_desc_get(f); f++) { |
| 33 | 268 | desc = av_pix_fmt_desc_get(f); | |
| 34 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
|
268 | if (!desc->name) |
| 35 | 171 | continue; | |
| 36 | 268 | printf("Testing %s...%*s", desc->name, | |
| 37 | 268 | (int)(16 - strlen(desc->name)), ""); | |
| 38 | 268 | r = ff_draw_init(&draw, f, 0); | |
| 39 |
2/2✓ Branch 0 taken 171 times.
✓ Branch 1 taken 97 times.
|
268 | if (r < 0) { |
| 40 | 171 | printf("no: %s\n", av_err2str(r)); | |
| 41 | 171 | continue; | |
| 42 | } | ||
| 43 | 97 | ff_draw_color(&draw, &color, (uint8_t[]) { 1, 0, 0, 1 }); | |
| 44 |
1/2✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
|
97 | for (i = 0; i < sizeof(color); i++) |
| 45 |
1/2✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
|
97 | if (((uint8_t *)&color)[i] != 128) |
| 46 | 97 | break; | |
| 47 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
|
97 | if (i == sizeof(color)) { |
| 48 | ✗ | printf("fallback color\n"); | |
| 49 | ✗ | continue; | |
| 50 | } | ||
| 51 | 97 | printf("ok\n"); | |
| 52 | } | ||
| 53 | |||
| 54 | 1 | ff_draw_init(&draw, AV_PIX_FMT_RGBA, FF_DRAW_PROCESS_ALPHA); | |
| 55 | 1 | ff_draw_color(&draw, &color, (uint8_t[]) { 255, 0, 0, 128 }); | |
| 56 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (int pass = 0; pass < 2; pass++) { |
| 57 | 2 | uint8_t pixel[4] = { 0 }; | |
| 58 | 2 | uint8_t *dst[4] = { pixel }, mask = 0xFF; | |
| 59 | 2 | int linesize[4] = { 4 }; | |
| 60 | |||
| 61 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (pass) |
| 62 | 1 | ff_blend_rectangle(&draw, &color, dst, linesize, 1, 1, 0, 0, 1, 1); | |
| 63 | else | ||
| 64 | 1 | ff_blend_mask(&draw, &color, dst, linesize, 1, 1, &mask, 1, 1, 1, 3, 0, 0, 0); | |
| 65 | 2 | printf("half transparent red over transparent rgba by %s: %d %d %d %d\n", | |
| 66 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | pass ? "rectangle" : "mask", pixel[0], pixel[1], pixel[2], pixel[3]); |
| 67 | } | ||
| 68 | 1 | return 0; | |
| 69 | } | ||
| 70 |