| 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 <limits.h> | ||
| 20 | #include <stdio.h> | ||
| 21 | |||
| 22 | #include "libavutil/frame.h" | ||
| 23 | #include "libavutil/hdr_dynamic_vivid_metadata.h" | ||
| 24 | #include "libavutil/mem.h" | ||
| 25 | |||
| 26 | 1 | int main(void) | |
| 27 | { | ||
| 28 | AVDynamicHDRVivid *vivid; | ||
| 29 | AVFrame *frame; | ||
| 30 | size_t size; | ||
| 31 | |||
| 32 | /* av_dynamic_hdr_vivid_alloc */ | ||
| 33 | 1 | printf("Testing av_dynamic_hdr_vivid_alloc()\n"); | |
| 34 | 1 | vivid = av_dynamic_hdr_vivid_alloc(&size); | |
| 35 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (vivid) { |
| 36 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | printf("alloc: OK, size>0=%s\n", size > 0 ? "yes" : "no"); |
| 37 | 1 | printf("defaults: system_start_code=%u, num_windows=%u\n", | |
| 38 | 1 | vivid->system_start_code, vivid->num_windows); | |
| 39 | |||
| 40 | /* write and read back */ | ||
| 41 | 1 | vivid->system_start_code = 0x01; | |
| 42 | 1 | vivid->num_windows = 1; | |
| 43 | 1 | vivid->params[0].minimum_maxrgb = (AVRational){ 100, 1 }; | |
| 44 | 1 | vivid->params[0].average_maxrgb = (AVRational){ 500, 1 }; | |
| 45 | 1 | vivid->params[0].variance_maxrgb = (AVRational){ 200, 1 }; | |
| 46 | 1 | vivid->params[0].maximum_maxrgb = (AVRational){ 1000, 1 }; | |
| 47 | 1 | printf("write: system_start_code=%u, num_windows=%u\n", | |
| 48 | 1 | vivid->system_start_code, vivid->num_windows); | |
| 49 | 1 | printf("params[0]: min=%d/%d avg=%d/%d var=%d/%d max=%d/%d\n", | |
| 50 | vivid->params[0].minimum_maxrgb.num, | ||
| 51 | vivid->params[0].minimum_maxrgb.den, | ||
| 52 | vivid->params[0].average_maxrgb.num, | ||
| 53 | vivid->params[0].average_maxrgb.den, | ||
| 54 | vivid->params[0].variance_maxrgb.num, | ||
| 55 | vivid->params[0].variance_maxrgb.den, | ||
| 56 | vivid->params[0].maximum_maxrgb.num, | ||
| 57 | vivid->params[0].maximum_maxrgb.den); | ||
| 58 | 1 | av_free(vivid); | |
| 59 | } | ||
| 60 | |||
| 61 | /* alloc with NULL size */ | ||
| 62 | 1 | vivid = av_dynamic_hdr_vivid_alloc(NULL); | |
| 63 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | printf("alloc (no size): %s\n", vivid ? "OK" : "FAIL"); |
| 64 | 1 | av_free(vivid); | |
| 65 | |||
| 66 | /* av_dynamic_hdr_vivid_create_side_data */ | ||
| 67 | 1 | printf("\nTesting av_dynamic_hdr_vivid_create_side_data()\n"); | |
| 68 | 1 | frame = av_frame_alloc(); | |
| 69 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (frame) { |
| 70 | 1 | vivid = av_dynamic_hdr_vivid_create_side_data(frame); | |
| 71 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (vivid) { |
| 72 | 1 | printf("side_data: OK\n"); | |
| 73 | 1 | vivid->system_start_code = 0x02; | |
| 74 | 1 | printf("side_data write: system_start_code=%u\n", | |
| 75 | 1 | vivid->system_start_code); | |
| 76 | } else { | ||
| 77 | ✗ | printf("side_data: FAIL\n"); | |
| 78 | } | ||
| 79 | 1 | av_frame_free(&frame); | |
| 80 | } | ||
| 81 | |||
| 82 | /* OOM paths via av_max_alloc */ | ||
| 83 | 1 | printf("\nTesting OOM paths\n"); | |
| 84 | 1 | av_max_alloc(1); | |
| 85 | 1 | vivid = av_dynamic_hdr_vivid_alloc(&size); | |
| 86 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | printf("alloc OOM: %s\n", vivid ? "FAIL" : "OK"); |
| 87 | 1 | av_free(vivid); | |
| 88 | 1 | av_max_alloc(INT_MAX); | |
| 89 | |||
| 90 | 1 | frame = av_frame_alloc(); | |
| 91 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (frame) { |
| 92 | 1 | av_max_alloc(1); | |
| 93 | 1 | vivid = av_dynamic_hdr_vivid_create_side_data(frame); | |
| 94 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | printf("side_data OOM: %s\n", vivid ? "FAIL" : "OK"); |
| 95 | 1 | av_max_alloc(INT_MAX); | |
| 96 | 1 | av_frame_free(&frame); | |
| 97 | } | ||
| 98 | |||
| 99 | 1 | return 0; | |
| 100 | } | ||
| 101 |