| 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/frame.h" | ||
| 22 | #include "libavutil/macros.h" | ||
| 23 | #include "libavutil/mem.h" | ||
| 24 | #include "libavutil/stereo3d.h" | ||
| 25 | |||
| 26 | 1 | int main(void) | |
| 27 | { | ||
| 28 | AVStereo3D *s3d; | ||
| 29 | AVFrame *frame; | ||
| 30 | size_t size; | ||
| 31 | int ret; | ||
| 32 | |||
| 33 | /* av_stereo3d_alloc_size with size output */ | ||
| 34 | 1 | printf("Testing av_stereo3d_alloc_size()\n"); | |
| 35 | 1 | s3d = av_stereo3d_alloc_size(&size); | |
| 36 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | printf("alloc_size: %s, size>0: %s\n", |
| 37 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | s3d ? "OK" : "FAIL", size > 0 ? "yes" : "no"); |
| 38 | 1 | av_free(s3d); | |
| 39 | |||
| 40 | /* av_stereo3d_alloc (no size) */ | ||
| 41 | 1 | s3d = av_stereo3d_alloc(); | |
| 42 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | printf("alloc: %s\n", s3d ? "OK" : "FAIL"); |
| 43 | 1 | av_free(s3d); | |
| 44 | |||
| 45 | /* av_stereo3d_create_side_data */ | ||
| 46 | 1 | printf("\nTesting av_stereo3d_create_side_data()\n"); | |
| 47 | 1 | frame = av_frame_alloc(); | |
| 48 | 1 | s3d = av_stereo3d_create_side_data(frame); | |
| 49 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | printf("create_side_data: %s\n", s3d ? "OK" : "FAIL"); |
| 50 | 1 | av_frame_free(&frame); | |
| 51 | |||
| 52 | /* av_stereo3d_type_name - all valid types */ | ||
| 53 | 1 | printf("\nTesting av_stereo3d_type_name()\n"); | |
| 54 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
|
10 | for (int i = 0; i <= AV_STEREO3D_UNSPEC; i++) |
| 55 | 9 | printf("type %d: %s\n", i, av_stereo3d_type_name(i)); | |
| 56 | 1 | printf("out of range: %s\n", av_stereo3d_type_name(100)); | |
| 57 | |||
| 58 | /* av_stereo3d_from_name - all valid names and unknown */ | ||
| 59 | 1 | printf("\nTesting av_stereo3d_from_name()\n"); | |
| 60 | { | ||
| 61 | static const char * const names[] = { | ||
| 62 | "2D", "side by side", "top and bottom", "frame alternate", | ||
| 63 | "checkerboard", "side by side (quincunx subsampling)", | ||
| 64 | "interleaved lines", "interleaved columns", "unspecified", | ||
| 65 | }; | ||
| 66 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
|
10 | for (int i = 0; i < FF_ARRAY_ELEMS(names); i++) |
| 67 | 9 | printf("%s: %d\n", names[i], av_stereo3d_from_name(names[i])); | |
| 68 | } | ||
| 69 | 1 | ret = av_stereo3d_from_name("nonexistent"); | |
| 70 | 1 | printf("nonexistent: %d\n", ret); | |
| 71 | |||
| 72 | /* av_stereo3d_type_name / av_stereo3d_from_name round-trip */ | ||
| 73 | 1 | printf("\nTesting type name round-trip\n"); | |
| 74 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
|
10 | for (int i = 0; i <= AV_STEREO3D_UNSPEC; i++) { |
| 75 | 9 | const char *name = av_stereo3d_type_name(i); | |
| 76 | 9 | int rt = av_stereo3d_from_name(name); | |
| 77 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | printf("type roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL"); |
| 78 | } | ||
| 79 | |||
| 80 | /* av_stereo3d_view_name - all valid views */ | ||
| 81 | 1 | printf("\nTesting av_stereo3d_view_name()\n"); | |
| 82 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int i = 0; i <= AV_STEREO3D_VIEW_UNSPEC; i++) |
| 83 | 4 | printf("view %d: %s\n", i, av_stereo3d_view_name(i)); | |
| 84 | 1 | printf("out of range: %s\n", av_stereo3d_view_name(100)); | |
| 85 | |||
| 86 | /* av_stereo3d_view_name / av_stereo3d_view_from_name round-trip */ | ||
| 87 | 1 | printf("\nTesting view name round-trip\n"); | |
| 88 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int i = 0; i <= AV_STEREO3D_VIEW_UNSPEC; i++) { |
| 89 | 4 | const char *name = av_stereo3d_view_name(i); | |
| 90 | 4 | int rt = av_stereo3d_view_from_name(name); | |
| 91 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | printf("view roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL"); |
| 92 | } | ||
| 93 | |||
| 94 | /* av_stereo3d_view_from_name */ | ||
| 95 | 1 | printf("\nTesting av_stereo3d_view_from_name()\n"); | |
| 96 | 1 | printf("packed: %d\n", av_stereo3d_view_from_name("packed")); | |
| 97 | 1 | printf("left: %d\n", av_stereo3d_view_from_name("left")); | |
| 98 | 1 | printf("right: %d\n", av_stereo3d_view_from_name("right")); | |
| 99 | 1 | printf("unspecified: %d\n", av_stereo3d_view_from_name("unspecified")); | |
| 100 | 1 | ret = av_stereo3d_view_from_name("nonexistent"); | |
| 101 | 1 | printf("nonexistent: %d\n", ret); | |
| 102 | |||
| 103 | /* av_stereo3d_primary_eye_name - all valid values */ | ||
| 104 | 1 | printf("\nTesting av_stereo3d_primary_eye_name()\n"); | |
| 105 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | for (int i = 0; i <= AV_PRIMARY_EYE_RIGHT; i++) |
| 106 | 3 | printf("eye %d: %s\n", i, av_stereo3d_primary_eye_name(i)); | |
| 107 | 1 | printf("out of range: %s\n", av_stereo3d_primary_eye_name(100)); | |
| 108 | |||
| 109 | /* av_stereo3d_primary_eye_from_name */ | ||
| 110 | 1 | printf("\nTesting av_stereo3d_primary_eye_from_name()\n"); | |
| 111 | 1 | printf("none: %d\n", av_stereo3d_primary_eye_from_name("none")); | |
| 112 | 1 | printf("left: %d\n", av_stereo3d_primary_eye_from_name("left")); | |
| 113 | 1 | printf("right: %d\n", av_stereo3d_primary_eye_from_name("right")); | |
| 114 | 1 | ret = av_stereo3d_primary_eye_from_name("nonexistent"); | |
| 115 | 1 | printf("nonexistent: %d\n", ret); | |
| 116 | |||
| 117 | 1 | return 0; | |
| 118 | } | ||
| 119 |