| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Filter layer - format negotiation | ||
| 3 | * Copyright (c) 2007 Bobby Bingham | ||
| 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 "libavutil/avassert.h" | ||
| 23 | #include "libavutil/bprint.h" | ||
| 24 | #include "libavutil/channel_layout.h" | ||
| 25 | #include "libavutil/common.h" | ||
| 26 | #include "libavutil/mem.h" | ||
| 27 | #include "libavutil/pixdesc.h" | ||
| 28 | #include "avfilter.h" | ||
| 29 | #include "filters.h" | ||
| 30 | #include "formats.h" | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Add all refs from a to ret and destroy a. | ||
| 34 | */ | ||
| 35 | #define MERGE_REF(ret, a, fmts, type, fail_statement) \ | ||
| 36 | do { \ | ||
| 37 | type ***tmp; \ | ||
| 38 | int i; \ | ||
| 39 | \ | ||
| 40 | if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \ | ||
| 41 | sizeof(*tmp)))) \ | ||
| 42 | { fail_statement } \ | ||
| 43 | ret->refs = tmp; \ | ||
| 44 | \ | ||
| 45 | for (i = 0; i < a->refcount; i ++) { \ | ||
| 46 | ret->refs[ret->refcount] = a->refs[i]; \ | ||
| 47 | *ret->refs[ret->refcount++] = ret; \ | ||
| 48 | } \ | ||
| 49 | \ | ||
| 50 | av_freep(&a->refs); \ | ||
| 51 | av_freep(&a->fmts); \ | ||
| 52 | av_freep(&a); \ | ||
| 53 | } while (0) | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Add all formats common to a and b to a, add b's refs to a and destroy b. | ||
| 57 | * If check is set, nothing is modified and it is only checked whether | ||
| 58 | * the formats are compatible. | ||
| 59 | * If empty_allowed is set and one of a,b->nb is zero, the lists are | ||
| 60 | * merged; otherwise, 0 (for nonmergeability) is returned. | ||
| 61 | */ | ||
| 62 | #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed) \ | ||
| 63 | do { \ | ||
| 64 | int i, j, k = 0, skip = 0; \ | ||
| 65 | \ | ||
| 66 | if (empty_allowed) { \ | ||
| 67 | if (!a->nb || !b->nb) { \ | ||
| 68 | if (check) \ | ||
| 69 | return 1; \ | ||
| 70 | if (!a->nb) \ | ||
| 71 | FFSWAP(type *, a, b); \ | ||
| 72 | skip = 1; \ | ||
| 73 | } \ | ||
| 74 | } \ | ||
| 75 | if (!skip) { \ | ||
| 76 | for (i = 0; i < a->nb; i++) \ | ||
| 77 | for (j = 0; j < b->nb; j++) \ | ||
| 78 | if (a->fmts[i] == b->fmts[j]) { \ | ||
| 79 | if (check) \ | ||
| 80 | return 1; \ | ||
| 81 | a->fmts[k++] = a->fmts[i]; \ | ||
| 82 | break; \ | ||
| 83 | } \ | ||
| 84 | /* Check that there was at least one common format. \ | ||
| 85 | * Notice that both a and b are unchanged if not. */ \ | ||
| 86 | if (!k) \ | ||
| 87 | return 0; \ | ||
| 88 | av_assert2(!check); \ | ||
| 89 | a->nb = k; \ | ||
| 90 | } \ | ||
| 91 | \ | ||
| 92 | MERGE_REF(a, b, fmts, type, return AVERROR(ENOMEM);); \ | ||
| 93 | } while (0) | ||
| 94 | |||
| 95 | 72830 | static int merge_formats_internal(AVFilterFormats *a, AVFilterFormats *b, | |
| 96 | enum AVMediaType type, int check) | ||
| 97 | { | ||
| 98 | int i, j; | ||
| 99 | 72830 | int alpha1=0, alpha2=0; | |
| 100 | 72830 | int chroma1=0, chroma2=0; | |
| 101 | |||
| 102 | av_assert2(check || (a->refcount && b->refcount)); | ||
| 103 | |||
| 104 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 72830 times.
|
72830 | if (a == b) |
| 105 | ✗ | return 1; | |
| 106 | |||
| 107 | /* Do not lose chroma or alpha in merging. | ||
| 108 | It happens if both lists have formats with chroma (resp. alpha), but | ||
| 109 | the only formats in common do not have it (e.g. YUV+gray vs. | ||
| 110 | RGB+gray): in that case, the merging would select the gray format, | ||
| 111 | possibly causing a lossy conversion elsewhere in the graph. | ||
| 112 | To avoid that, pretend that there are no common formats to force the | ||
| 113 | insertion of a conversion filter. */ | ||
| 114 |
2/2✓ Branch 0 taken 61340 times.
✓ Branch 1 taken 11490 times.
|
72830 | if (type == AVMEDIA_TYPE_VIDEO) |
| 115 |
2/2✓ Branch 0 taken 3390500 times.
✓ Branch 1 taken 61340 times.
|
3451840 | for (i = 0; i < a->nb_formats; i++) { |
| 116 | 3390500 | const AVPixFmtDescriptor *const adesc = av_pix_fmt_desc_get(a->formats[i]); | |
| 117 |
2/2✓ Branch 0 taken 198210847 times.
✓ Branch 1 taken 3390500 times.
|
201601347 | for (j = 0; j < b->nb_formats; j++) { |
| 118 | 198210847 | const AVPixFmtDescriptor *bdesc = av_pix_fmt_desc_get(b->formats[j]); | |
| 119 | 198210847 | alpha2 |= adesc->flags & bdesc->flags & AV_PIX_FMT_FLAG_ALPHA; | |
| 120 |
4/4✓ Branch 0 taken 172980090 times.
✓ Branch 1 taken 25230757 times.
✓ Branch 2 taken 150147053 times.
✓ Branch 3 taken 22833037 times.
|
198210847 | chroma2|= adesc->nb_components > 1 && bdesc->nb_components > 1; |
| 121 |
2/2✓ Branch 0 taken 759167 times.
✓ Branch 1 taken 197451680 times.
|
198210847 | if (a->formats[i] == b->formats[j]) { |
| 122 | 759167 | alpha1 |= adesc->flags & AV_PIX_FMT_FLAG_ALPHA; | |
| 123 | 759167 | chroma1|= adesc->nb_components > 1; | |
| 124 | } | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | // If chroma or alpha can be lost through merging then do not merge | ||
| 129 |
4/4✓ Branch 0 taken 72807 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 72250 times.
|
72830 | if (alpha2 > alpha1 || chroma2 > chroma1) |
| 130 | 580 | return 0; | |
| 131 | |||
| 132 |
14/16✓ Branch 0 taken 72250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424531 times.
✓ Branch 3 taken 50330510 times.
✓ Branch 4 taken 34498 times.
✓ Branch 5 taken 390033 times.
✓ Branch 6 taken 50755041 times.
✓ Branch 7 taken 1957226 times.
✓ Branch 8 taken 2381757 times.
✓ Branch 9 taken 37752 times.
✓ Branch 10 taken 698 times.
✓ Branch 11 taken 37054 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 37054 times.
✓ Branch 15 taken 82404 times.
✓ Branch 16 taken 37054 times.
|
52832423 | MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, check, 0); |
| 133 | |||
| 134 | 37054 | return 1; | |
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | /** | ||
| 139 | * Check the formats lists for compatibility for merging without actually | ||
| 140 | * merging. | ||
| 141 | * | ||
| 142 | * @return 1 if they are compatible, 0 if not. | ||
| 143 | */ | ||
| 144 | 30355 | static int can_merge_pix_fmts(const void *a, const void *b) | |
| 145 | { | ||
| 146 | 30355 | return merge_formats_internal((AVFilterFormats *)a, | |
| 147 | (AVFilterFormats *)b, AVMEDIA_TYPE_VIDEO, 1); | ||
| 148 | } | ||
| 149 | |||
| 150 | /** | ||
| 151 | * Merge the formats lists if they are compatible and update all the | ||
| 152 | * references of a and b to point to the combined list and free the old | ||
| 153 | * lists as needed. The combined list usually contains the intersection of | ||
| 154 | * the lists of a and b. | ||
| 155 | * | ||
| 156 | * Both a and b must have owners (i.e. refcount > 0) for these functions. | ||
| 157 | * | ||
| 158 | * @return 1 if merging succeeded, 0 if a and b are incompatible | ||
| 159 | * and negative AVERROR code on failure. | ||
| 160 | * a and b are unmodified if 0 is returned. | ||
| 161 | */ | ||
| 162 | 30985 | static int merge_pix_fmts(void *a, void *b) | |
| 163 | { | ||
| 164 | 30985 | return merge_formats_internal(a, b, AVMEDIA_TYPE_VIDEO, 0); | |
| 165 | } | ||
| 166 | |||
| 167 | /** | ||
| 168 | * See can_merge_pix_fmts(). | ||
| 169 | */ | ||
| 170 | 5421 | static int can_merge_sample_fmts(const void *a, const void *b) | |
| 171 | { | ||
| 172 | 5421 | return merge_formats_internal((AVFilterFormats *)a, | |
| 173 | (AVFilterFormats *)b, AVMEDIA_TYPE_AUDIO, 1); | ||
| 174 | } | ||
| 175 | |||
| 176 | /** | ||
| 177 | * See merge_pix_fmts(). | ||
| 178 | */ | ||
| 179 | 6069 | static int merge_sample_fmts(void *a, void *b) | |
| 180 | { | ||
| 181 | 6069 | return merge_formats_internal(a, b, AVMEDIA_TYPE_AUDIO, 0); | |
| 182 | } | ||
| 183 | |||
| 184 | 11490 | static int merge_samplerates_internal(AVFilterFormats *a, | |
| 185 | AVFilterFormats *b, int check) | ||
| 186 | { | ||
| 187 | av_assert2(check || (a->refcount && b->refcount)); | ||
| 188 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11490 times.
|
11490 | if (a == b) return 1; |
| 189 | |||
| 190 |
23/24✓ Branch 0 taken 7292 times.
✓ Branch 1 taken 4198 times.
✓ Branch 2 taken 7118 times.
✓ Branch 3 taken 174 times.
✓ Branch 4 taken 5318 times.
✓ Branch 5 taken 5998 times.
✓ Branch 6 taken 2423 times.
✓ Branch 7 taken 3575 times.
✓ Branch 8 taken 174 times.
✓ Branch 9 taken 5998 times.
✓ Branch 10 taken 168 times.
✓ Branch 11 taken 90 times.
✓ Branch 12 taken 97 times.
✓ Branch 13 taken 71 times.
✓ Branch 14 taken 258 times.
✓ Branch 15 taken 6 times.
✓ Branch 16 taken 174 times.
✓ Branch 17 taken 77 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 71 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 6069 times.
✓ Branch 23 taken 26756 times.
✓ Branch 24 taken 6069 times.
|
38413 | MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, check, 1); |
| 191 | 6069 | return 1; | |
| 192 | } | ||
| 193 | |||
| 194 | /** | ||
| 195 | * See can_merge_pix_fmts(). | ||
| 196 | */ | ||
| 197 | 5421 | static int can_merge_samplerates(const void *a, const void *b) | |
| 198 | { | ||
| 199 | 5421 | return merge_samplerates_internal((AVFilterFormats *)a, (AVFilterFormats *)b, 1); | |
| 200 | } | ||
| 201 | |||
| 202 | /** | ||
| 203 | * See merge_pix_fmts(). | ||
| 204 | */ | ||
| 205 | 6069 | static int merge_samplerates(void *a, void *b) | |
| 206 | { | ||
| 207 | 6069 | return merge_samplerates_internal(a, b, 0); | |
| 208 | } | ||
| 209 | |||
| 210 | /** | ||
| 211 | * See merge_pix_fmts(). | ||
| 212 | */ | ||
| 213 | 6804 | static int merge_channel_layouts_internal(AVFilterChannelLayouts *a, | |
| 214 | AVFilterChannelLayouts *b, int check) | ||
| 215 | { | ||
| 216 | 6804 | AVChannelLayout *channel_layouts = NULL; | |
| 217 | 6804 | unsigned a_all = a->all_layouts + a->all_counts; | |
| 218 | 6804 | unsigned b_all = b->all_layouts + b->all_counts; | |
| 219 | 6804 | int ret_max, ret_nb = 0, i, j, round; | |
| 220 | |||
| 221 | av_assert2(a->refcount && b->refcount); | ||
| 222 | |||
| 223 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6804 times.
|
6804 | if (a == b) return 1; |
| 224 | |||
| 225 | /* Put the most generic set in a, to avoid doing everything twice */ | ||
| 226 |
2/2✓ Branch 0 taken 3427 times.
✓ Branch 1 taken 3377 times.
|
6804 | if (a_all < b_all) { |
| 227 | 3427 | FFSWAP(AVFilterChannelLayouts *, a, b); | |
| 228 | 3427 | FFSWAP(unsigned, a_all, b_all); | |
| 229 | } | ||
| 230 |
2/2✓ Branch 0 taken 6578 times.
✓ Branch 1 taken 226 times.
|
6804 | if (a_all) { |
| 231 |
3/4✓ Branch 0 taken 70 times.
✓ Branch 1 taken 6508 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
|
6578 | if (a_all == 1 && !b_all) { |
| 232 | /* keep only known layouts in b; works also for b_all = 1 */ | ||
| 233 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 70 times.
|
140 | for (i = j = 0; i < b->nb_channel_layouts; i++) |
| 234 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
|
70 | if (KNOWN(&b->channel_layouts[i]) && i != j++) { |
| 235 | ✗ | if (check) | |
| 236 | ✗ | return 1; | |
| 237 | ✗ | av_channel_layout_copy(&b->channel_layouts[j], &b->channel_layouts[i]); | |
| 238 | } | ||
| 239 | /* Not optimal: the unknown layouts of b may become known after | ||
| 240 | another merge. */ | ||
| 241 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
|
70 | if (!j) |
| 242 | ✗ | return 0; | |
| 243 | 70 | b->nb_channel_layouts = j; | |
| 244 | } | ||
| 245 |
3/4✗ Branch 1 not taken.
✓ Branch 2 taken 6578 times.
✓ Branch 3 taken 11373 times.
✓ Branch 4 taken 6578 times.
|
17951 | MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, return AVERROR(ENOMEM);); |
| 246 | 6578 | return 1; | |
| 247 | } | ||
| 248 | |||
| 249 | 226 | ret_max = a->nb_channel_layouts + b->nb_channel_layouts; | |
| 250 |
3/4✓ Branch 0 taken 87 times.
✓ Branch 1 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87 times.
|
226 | if (!check && !(channel_layouts = av_calloc(ret_max, sizeof(*channel_layouts)))) |
| 251 | ✗ | return AVERROR(ENOMEM); | |
| 252 | |||
| 253 | /* a[known] intersect b[known] */ | ||
| 254 |
2/2✓ Branch 0 taken 226 times.
✓ Branch 1 taken 96 times.
|
322 | for (i = 0; i < a->nb_channel_layouts; i++) { |
| 255 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
226 | if (!KNOWN(&a->channel_layouts[i])) |
| 256 | 3 | continue; | |
| 257 |
2/2✓ Branch 0 taken 379 times.
✓ Branch 1 taken 7 times.
|
386 | for (j = 0; j < b->nb_channel_layouts; j++) { |
| 258 |
2/2✓ Branch 1 taken 216 times.
✓ Branch 2 taken 163 times.
|
379 | if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j])) { |
| 259 |
2/2✓ Branch 0 taken 130 times.
✓ Branch 1 taken 86 times.
|
216 | if (check) |
| 260 | 130 | return 1; | |
| 261 | 86 | av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]); | |
| 262 | 86 | av_channel_layout_uninit(&a->channel_layouts[i]); | |
| 263 | 86 | av_channel_layout_uninit(&b->channel_layouts[j]); | |
| 264 | 86 | break; | |
| 265 | } | ||
| 266 | } | ||
| 267 | } | ||
| 268 | /* 1st round: a[known] intersect b[generic] | ||
| 269 | 2nd round: a[generic] intersect b[known] */ | ||
| 270 |
2/2✓ Branch 0 taken 192 times.
✓ Branch 1 taken 95 times.
|
287 | for (round = 0; round < 2; round++) { |
| 271 |
2/2✓ Branch 0 taken 340 times.
✓ Branch 1 taken 191 times.
|
531 | for (i = 0; i < a->nb_channel_layouts; i++) { |
| 272 | 340 | AVChannelLayout *fmt = &a->channel_layouts[i], bfmt = { 0 }; | |
| 273 |
5/6✓ Branch 1 taken 168 times.
✓ Branch 2 taken 172 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 163 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
|
340 | if (!av_channel_layout_check(fmt) || !KNOWN(fmt)) |
| 274 | 177 | continue; | |
| 275 | 163 | bfmt = FF_COUNT2LAYOUT(fmt->nb_channels); | |
| 276 |
2/2✓ Branch 0 taken 163 times.
✓ Branch 1 taken 162 times.
|
325 | for (j = 0; j < b->nb_channel_layouts; j++) |
| 277 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 162 times.
|
163 | if (!av_channel_layout_compare(&b->channel_layouts[j], &bfmt)) { |
| 278 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (check) |
| 279 | 1 | return 1; | |
| 280 | ✗ | av_channel_layout_copy(&channel_layouts[ret_nb++], fmt); | |
| 281 | } | ||
| 282 | } | ||
| 283 | /* 1st round: swap to prepare 2nd round; 2nd round: put it back */ | ||
| 284 | 191 | FFSWAP(AVFilterChannelLayouts *, a, b); | |
| 285 | } | ||
| 286 | /* a[generic] intersect b[generic] */ | ||
| 287 |
2/2✓ Branch 0 taken 95 times.
✓ Branch 1 taken 94 times.
|
189 | for (i = 0; i < a->nb_channel_layouts; i++) { |
| 288 |
4/4✓ Branch 0 taken 88 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 2 times.
|
95 | if (KNOWN(&a->channel_layouts[i])) |
| 289 | 93 | continue; | |
| 290 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (j = 0; j < b->nb_channel_layouts; j++) |
| 291 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j])) { |
| 292 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (check) |
| 293 | 1 | return 1; | |
| 294 | 1 | av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]); | |
| 295 | } | ||
| 296 | } | ||
| 297 | |||
| 298 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 87 times.
|
94 | if (!ret_nb) { |
| 299 | 7 | av_free(channel_layouts); | |
| 300 | 7 | return 0; | |
| 301 | } | ||
| 302 | |||
| 303 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 66 times.
|
87 | if (a->refcount > b->refcount) |
| 304 | 21 | FFSWAP(AVFilterChannelLayouts *, a, b); | |
| 305 | |||
| 306 |
3/4✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 4 taken 171 times.
✓ Branch 5 taken 87 times.
|
258 | MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, |
| 307 | { av_free(channel_layouts); return AVERROR(ENOMEM); }); | ||
| 308 | 87 | av_freep(&b->channel_layouts); | |
| 309 | 87 | b->channel_layouts = channel_layouts; | |
| 310 | 87 | b->nb_channel_layouts = ret_nb; | |
| 311 | 87 | return 1; | |
| 312 | } | ||
| 313 | |||
| 314 | 5421 | static int can_merge_channel_layouts(const void *a, const void *b) | |
| 315 | { | ||
| 316 | 5421 | return merge_channel_layouts_internal((AVFilterChannelLayouts *)a, | |
| 317 | (AVFilterChannelLayouts *)b, 1); | ||
| 318 | } | ||
| 319 | |||
| 320 | 1383 | static int merge_channel_layouts(void *a, void *b) | |
| 321 | { | ||
| 322 | 1383 | return merge_channel_layouts_internal(a, b, 0); | |
| 323 | } | ||
| 324 | |||
| 325 | 185239 | static int merge_generic_internal(AVFilterFormats *a, | |
| 326 | AVFilterFormats *b, int check) | ||
| 327 | { | ||
| 328 | av_assert2(check || (a->refcount && b->refcount)); | ||
| 329 | |||
| 330 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 185239 times.
|
185239 | if (a == b) |
| 331 | ✗ | return 1; | |
| 332 | |||
| 333 |
14/16✓ Branch 0 taken 185239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521491 times.
✓ Branch 3 taken 1804030 times.
✓ Branch 4 taken 92237 times.
✓ Branch 5 taken 429254 times.
✓ Branch 6 taken 2325521 times.
✓ Branch 7 taken 19828 times.
✓ Branch 8 taken 541319 times.
✓ Branch 9 taken 93002 times.
✓ Branch 10 taken 65 times.
✓ Branch 11 taken 92937 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 92937 times.
✓ Branch 15 taken 174407 times.
✓ Branch 16 taken 92937 times.
|
2612758 | MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, check, 0); |
| 334 | |||
| 335 | 92937 | return 1; | |
| 336 | } | ||
| 337 | |||
| 338 | 92302 | static int can_merge_generic(const void *a, const void *b) | |
| 339 | { | ||
| 340 | 92302 | return merge_generic_internal((AVFilterFormats *)a, | |
| 341 | (AVFilterFormats *)b, 1); | ||
| 342 | } | ||
| 343 | |||
| 344 | 92937 | static int merge_generic(void *a, void *b) | |
| 345 | { | ||
| 346 | 92937 | return merge_generic_internal(a, b, 0); | |
| 347 | } | ||
| 348 | |||
| 349 | #define PRINT_NAME(type, type_name) \ | ||
| 350 | static void print_##type_name(AVBPrint *bp, const void *fmtsp) \ | ||
| 351 | { \ | ||
| 352 | const AVFilterFormats *fmts = fmtsp; \ | ||
| 353 | for (int i = 0; i < fmts->nb_formats; i++) { \ | ||
| 354 | const char *name = av_##type_name(fmts->formats[i]); \ | ||
| 355 | av_bprint_chars(bp, ' ', i ? 1 : 0); \ | ||
| 356 | av_bprint_append_data(bp, name, name ? strlen(name) : 0); \ | ||
| 357 | } \ | ||
| 358 | } | ||
| 359 | |||
| 360 | ✗ | PRINT_NAME(enum AVSampleFormat, get_sample_fmt_name) | |
| 361 | ✗ | PRINT_NAME(enum AVPixelFormat, get_pix_fmt_name) | |
| 362 | ✗ | PRINT_NAME(enum AVColorSpace, color_space_name) | |
| 363 | ✗ | PRINT_NAME(enum AVColorRange, color_range_name) | |
| 364 | ✗ | PRINT_NAME(enum AVAlphaMode, alpha_mode_name) | |
| 365 | |||
| 366 | ✗ | static void print_channel_layout_desc(AVBPrint *bp, const void *layoutsp) | |
| 367 | { | ||
| 368 | ✗ | const AVFilterChannelLayouts *layouts = layoutsp; | |
| 369 | ✗ | for (int i = 0; i < layouts->nb_channel_layouts; i++) { | |
| 370 | ✗ | av_bprint_chars(bp, ' ', i ? 1 : 0); | |
| 371 | ✗ | av_channel_layout_describe_bprint(&layouts->channel_layouts[i], bp); | |
| 372 | } | ||
| 373 | ✗ | } | |
| 374 | |||
| 375 | ✗ | static void print_sample_rate(AVBPrint *bp, const void *ratesp) | |
| 376 | { | ||
| 377 | ✗ | const AVFilterFormats *rates = ratesp; | |
| 378 | ✗ | for (int i = 0; i < rates->nb_formats; i++) | |
| 379 | ✗ | av_bprintf(bp, "%s%d", i ? " " : "", rates->formats[i]); | |
| 380 | ✗ | } | |
| 381 | |||
| 382 | #define CONVERSION_FILTER_SWSCALE \ | ||
| 383 | .conversion_filter = "scale", \ | ||
| 384 | .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts), | ||
| 385 | |||
| 386 | #define CONVERSION_FILTER_ARESAMPLE \ | ||
| 387 | .conversion_filter = "aresample", \ | ||
| 388 | .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts), | ||
| 389 | |||
| 390 | static const AVFilterFormatsMerger mergers_video[] = { | ||
| 391 | { | ||
| 392 | .name = "Pixel formats", | ||
| 393 | .offset = offsetof(AVFilterFormatsConfig, formats), | ||
| 394 | .merge = merge_pix_fmts, | ||
| 395 | .can_merge = can_merge_pix_fmts, | ||
| 396 | .print_list = print_get_pix_fmt_name, | ||
| 397 | CONVERSION_FILTER_SWSCALE | ||
| 398 | }, | ||
| 399 | { | ||
| 400 | .name = "Color spaces", | ||
| 401 | .offset = offsetof(AVFilterFormatsConfig, color_spaces), | ||
| 402 | .merge = merge_generic, | ||
| 403 | .can_merge = can_merge_generic, | ||
| 404 | .print_list = print_color_space_name, | ||
| 405 | CONVERSION_FILTER_SWSCALE | ||
| 406 | }, | ||
| 407 | { | ||
| 408 | .name = "Color ranges", | ||
| 409 | .offset = offsetof(AVFilterFormatsConfig, color_ranges), | ||
| 410 | .merge = merge_generic, | ||
| 411 | .can_merge = can_merge_generic, | ||
| 412 | .print_list = print_color_range_name, | ||
| 413 | CONVERSION_FILTER_SWSCALE | ||
| 414 | }, | ||
| 415 | { | ||
| 416 | .name = "Alpha modes", | ||
| 417 | .offset = offsetof(AVFilterFormatsConfig, alpha_modes), | ||
| 418 | .merge = merge_generic, | ||
| 419 | .can_merge = can_merge_generic, | ||
| 420 | .print_list = print_alpha_mode_name, | ||
| 421 | .conversion_filter = "premultiply_dynamic", | ||
| 422 | }, | ||
| 423 | }; | ||
| 424 | |||
| 425 | static const AVFilterFormatsMerger mergers_audio[] = { | ||
| 426 | { | ||
| 427 | .name = "Channel layouts", | ||
| 428 | .offset = offsetof(AVFilterFormatsConfig, channel_layouts), | ||
| 429 | .merge = merge_channel_layouts, | ||
| 430 | .can_merge = can_merge_channel_layouts, | ||
| 431 | .print_list = print_channel_layout_desc, | ||
| 432 | CONVERSION_FILTER_ARESAMPLE | ||
| 433 | }, | ||
| 434 | { | ||
| 435 | .name = "Sample rates", | ||
| 436 | .offset = offsetof(AVFilterFormatsConfig, samplerates), | ||
| 437 | .merge = merge_samplerates, | ||
| 438 | .can_merge = can_merge_samplerates, | ||
| 439 | .print_list = print_sample_rate, | ||
| 440 | CONVERSION_FILTER_ARESAMPLE | ||
| 441 | }, | ||
| 442 | { | ||
| 443 | .name = "Sample formats", | ||
| 444 | .offset = offsetof(AVFilterFormatsConfig, formats), | ||
| 445 | .merge = merge_sample_fmts, | ||
| 446 | .can_merge = can_merge_sample_fmts, | ||
| 447 | .print_list = print_get_sample_fmt_name, | ||
| 448 | CONVERSION_FILTER_ARESAMPLE | ||
| 449 | }, | ||
| 450 | }; | ||
| 451 | |||
| 452 | static const AVFilterNegotiation negotiate_video = { | ||
| 453 | .nb_mergers = FF_ARRAY_ELEMS(mergers_video), | ||
| 454 | .mergers = mergers_video, | ||
| 455 | }; | ||
| 456 | |||
| 457 | static const AVFilterNegotiation negotiate_audio = { | ||
| 458 | .nb_mergers = FF_ARRAY_ELEMS(mergers_audio), | ||
| 459 | .mergers = mergers_audio, | ||
| 460 | }; | ||
| 461 | |||
| 462 | 52560 | const AVFilterNegotiation *ff_filter_get_negotiation(const AVFilterLink *link) | |
| 463 | { | ||
| 464 |
2/3✓ Branch 0 taken 32956 times.
✓ Branch 1 taken 19604 times.
✗ Branch 2 not taken.
|
52560 | switch (link->type) { |
| 465 | 32956 | case AVMEDIA_TYPE_VIDEO: return &negotiate_video; | |
| 466 | 19604 | case AVMEDIA_TYPE_AUDIO: return &negotiate_audio; | |
| 467 | ✗ | default: return NULL; | |
| 468 | } | ||
| 469 | } | ||
| 470 | |||
| 471 | 194 | int ff_pixfmt_is_in(enum AVPixelFormat fmt, const enum AVPixelFormat *fmts) | |
| 472 | { | ||
| 473 |
2/2✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 107 times.
|
2292 | for (; *fmts != AV_PIX_FMT_NONE; ++fmts) { |
| 474 |
2/2✓ Branch 0 taken 87 times.
✓ Branch 1 taken 2098 times.
|
2185 | if (fmt == *fmts) |
| 475 | 87 | return 1; | |
| 476 | } | ||
| 477 | 107 | return 0; | |
| 478 | } | ||
| 479 | |||
| 480 | #define MAKE_FORMAT_LIST(type, field, count_field) \ | ||
| 481 | type *formats; \ | ||
| 482 | int count = 0; \ | ||
| 483 | if (fmts) \ | ||
| 484 | for (count = 0; fmts[count] != -1; count++) \ | ||
| 485 | ; \ | ||
| 486 | formats = av_mallocz(sizeof(*formats)); \ | ||
| 487 | if (!formats) \ | ||
| 488 | return NULL; \ | ||
| 489 | formats->count_field = count; \ | ||
| 490 | if (count) { \ | ||
| 491 | formats->field = av_malloc_array(count, sizeof(*formats->field)); \ | ||
| 492 | if (!formats->field) { \ | ||
| 493 | av_freep(&formats); \ | ||
| 494 | return NULL; \ | ||
| 495 | } \ | ||
| 496 | } | ||
| 497 | |||
| 498 | #define MAKE_FORMAT_LIST_TYPE(name, type) \ | ||
| 499 | AVFilterFormats *ff_make_ ## name ## _list(const type* fmts) \ | ||
| 500 | { \ | ||
| 501 | MAKE_FORMAT_LIST(AVFilterFormats, formats, nb_formats); \ | ||
| 502 | while (count--) \ | ||
| 503 | formats->formats[count] = (int)fmts[count]; \ | ||
| 504 | return formats; \ | ||
| 505 | } | ||
| 506 | |||
| 507 |
8/12✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1352 times.
✓ Branch 3 taken 960 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 960 times.
✓ Branch 7 taken 960 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 960 times.
✓ Branch 13 taken 1352 times.
✓ Branch 14 taken 960 times.
|
3664 | MAKE_FORMAT_LIST_TYPE(format, int) |
| 508 |
8/12✓ Branch 0 taken 1884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2276 times.
✓ Branch 3 taken 1884 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1884 times.
✓ Branch 7 taken 1884 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1884 times.
✓ Branch 13 taken 2276 times.
✓ Branch 14 taken 1884 times.
|
6436 | MAKE_FORMAT_LIST_TYPE(sample_format, enum AVSampleFormat) |
| 509 |
8/12✓ Branch 0 taken 1663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46205 times.
✓ Branch 3 taken 1663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1663 times.
✓ Branch 7 taken 1663 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1663 times.
✓ Branch 13 taken 46205 times.
✓ Branch 14 taken 1663 times.
|
94073 | MAKE_FORMAT_LIST_TYPE(pixel_format, enum AVPixelFormat) |
| 510 | |||
| 511 | 230 | AVFilterChannelLayouts *ff_make_channel_layout_list(const AVChannelLayout *fmts) | |
| 512 | { | ||
| 513 | AVFilterChannelLayouts *ch_layouts; | ||
| 514 | 230 | int count = 0; | |
| 515 |
1/2✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
|
230 | if (fmts) |
| 516 |
2/2✓ Branch 0 taken 617 times.
✓ Branch 1 taken 230 times.
|
847 | for (count = 0; fmts[count].nb_channels; count++) |
| 517 | ; | ||
| 518 | 230 | ch_layouts = av_mallocz(sizeof(*ch_layouts)); | |
| 519 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 230 times.
|
230 | if (!ch_layouts) |
| 520 | ✗ | return NULL; | |
| 521 | 230 | ch_layouts->nb_channel_layouts = count; | |
| 522 |
1/2✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
|
230 | if (count) { |
| 523 | 460 | ch_layouts->channel_layouts = | |
| 524 | 230 | av_calloc(count, sizeof(*ch_layouts->channel_layouts)); | |
| 525 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 230 times.
|
230 | if (!ch_layouts->channel_layouts) { |
| 526 | ✗ | av_freep(&ch_layouts); | |
| 527 | ✗ | return NULL; | |
| 528 | } | ||
| 529 |
2/2✓ Branch 0 taken 617 times.
✓ Branch 1 taken 230 times.
|
847 | for (int i = 0; i < count; i++) { |
| 530 | 617 | int ret = av_channel_layout_copy(&ch_layouts->channel_layouts[i], &fmts[i]); | |
| 531 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 617 times.
|
617 | if (ret < 0) |
| 532 | ✗ | goto fail; | |
| 533 | } | ||
| 534 | } | ||
| 535 | |||
| 536 | 230 | return ch_layouts; | |
| 537 | |||
| 538 | ✗ | fail: | |
| 539 | ✗ | for (int i = 0; i < count; i++) | |
| 540 | ✗ | av_channel_layout_uninit(&ch_layouts->channel_layouts[i]); | |
| 541 | ✗ | av_free(ch_layouts->channel_layouts); | |
| 542 | ✗ | av_freep(&ch_layouts); | |
| 543 | |||
| 544 | ✗ | return NULL; | |
| 545 | } | ||
| 546 | |||
| 547 | #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \ | ||
| 548 | do { \ | ||
| 549 | type *fmts; \ | ||
| 550 | \ | ||
| 551 | if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \ | ||
| 552 | return AVERROR(ENOMEM); \ | ||
| 553 | } \ | ||
| 554 | \ | ||
| 555 | fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \ | ||
| 556 | sizeof(*(*f)->list)); \ | ||
| 557 | if (!fmts) { \ | ||
| 558 | unref_fn(f); \ | ||
| 559 | return AVERROR(ENOMEM); \ | ||
| 560 | } \ | ||
| 561 | \ | ||
| 562 | (*f)->list = fmts; \ | ||
| 563 | ASSIGN_FMT(f, fmt, list, nb); \ | ||
| 564 | } while (0) | ||
| 565 | |||
| 566 | #define ASSIGN_FMT(f, fmt, list, nb) \ | ||
| 567 | do { \ | ||
| 568 | (*f)->list[(*f)->nb++] = fmt; \ | ||
| 569 | } while (0) | ||
| 570 | |||
| 571 | 4522369 | int ff_add_format(AVFilterFormats **avff, int64_t fmt) | |
| 572 | { | ||
| 573 |
4/6✓ Branch 0 taken 223997 times.
✓ Branch 1 taken 4298372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 223997 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4522369 times.
|
4522369 | ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats); |
| 574 | 4522369 | return 0; | |
| 575 | } | ||
| 576 | |||
| 577 | #undef ASSIGN_FMT | ||
| 578 | #define ASSIGN_FMT(f, fmt, list, nb) \ | ||
| 579 | do { \ | ||
| 580 | int ret; \ | ||
| 581 | memset((*f)->list + (*f)->nb, 0, sizeof(*(*f)->list)); \ | ||
| 582 | ret = av_channel_layout_copy(&(*f)->list[(*f)->nb], fmt); \ | ||
| 583 | if (ret < 0) \ | ||
| 584 | return ret; \ | ||
| 585 | (*f)->nb++; \ | ||
| 586 | } while (0) | ||
| 587 | |||
| 588 | 2327 | int ff_add_channel_layout(AVFilterChannelLayouts **l, | |
| 589 | const AVChannelLayout *channel_layout) | ||
| 590 | { | ||
| 591 | av_assert1(!(*l && (*l)->all_layouts)); | ||
| 592 |
5/8✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1483 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2327 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2327 times.
|
2327 | ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, AVChannelLayout, channel_layouts, nb_channel_layouts); |
| 593 | 2327 | return 0; | |
| 594 | } | ||
| 595 | |||
| 596 | 72 | AVFilterFormats *ff_make_formats_list_singleton(int fmt) | |
| 597 | { | ||
| 598 | 72 | int fmts[2] = { fmt, -1 }; | |
| 599 | 72 | return ff_make_format_list(fmts); | |
| 600 | } | ||
| 601 | |||
| 602 | 46819 | AVFilterFormats *ff_all_formats(enum AVMediaType type) | |
| 603 | { | ||
| 604 | 46819 | AVFilterFormats *ret = NULL; | |
| 605 | |||
| 606 |
2/2✓ Branch 0 taken 36444 times.
✓ Branch 1 taken 10375 times.
|
46819 | if (type == AVMEDIA_TYPE_VIDEO) { |
| 607 | 36444 | return ff_formats_pixdesc_filter(0, 0); | |
| 608 |
1/2✓ Branch 0 taken 10375 times.
✗ Branch 1 not taken.
|
10375 | } else if (type == AVMEDIA_TYPE_AUDIO) { |
| 609 | 10375 | enum AVSampleFormat fmt = 0; | |
| 610 |
2/2✓ Branch 1 taken 124500 times.
✓ Branch 2 taken 10375 times.
|
134875 | while (av_get_sample_fmt_name(fmt)) { |
| 611 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 124500 times.
|
124500 | if (ff_add_format(&ret, fmt) < 0) |
| 612 | ✗ | return NULL; | |
| 613 | 124500 | fmt++; | |
| 614 | } | ||
| 615 | } | ||
| 616 | |||
| 617 | 10375 | return ret; | |
| 618 | } | ||
| 619 | |||
| 620 | 37095 | AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej) | |
| 621 | { | ||
| 622 | unsigned nb_formats, fmt, flags; | ||
| 623 | 37095 | AVFilterFormats *formats = NULL; | |
| 624 | |||
| 625 | while (1) { | ||
| 626 | 74190 | nb_formats = 0; | |
| 627 | 19882920 | for (fmt = 0;; fmt++) { | |
| 628 | 19882920 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); | |
| 629 |
2/2✓ Branch 0 taken 74190 times.
✓ Branch 1 taken 19808730 times.
|
19882920 | if (!desc) |
| 630 | 74190 | break; | |
| 631 | 19808730 | flags = desc->flags; | |
| 632 |
2/2✓ Branch 0 taken 18621690 times.
✓ Branch 1 taken 1187040 times.
|
19808730 | if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) && |
| 633 |
2/2✓ Branch 0 taken 8754420 times.
✓ Branch 1 taken 9867270 times.
|
18621690 | !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) && |
| 634 |
3/4✓ Branch 0 taken 8012520 times.
✓ Branch 1 taken 741900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8012520 times.
|
8754420 | (desc->log2_chroma_w || desc->log2_chroma_h)) |
| 635 | 741900 | flags |= FF_PIX_FMT_FLAG_SW_FLAT_SUB; | |
| 636 |
2/2✓ Branch 0 taken 21640 times.
✓ Branch 1 taken 19787090 times.
|
19808730 | if ((flags & (want | rej)) != want) |
| 637 | 21640 | continue; | |
| 638 |
2/2✓ Branch 0 taken 9893545 times.
✓ Branch 1 taken 9893545 times.
|
19787090 | if (formats) |
| 639 | 9893545 | formats->formats[nb_formats] = fmt; | |
| 640 | 19787090 | nb_formats++; | |
| 641 | } | ||
| 642 |
2/2✓ Branch 0 taken 37095 times.
✓ Branch 1 taken 37095 times.
|
74190 | if (formats) { |
| 643 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 37095 times.
|
37095 | av_assert0(formats->nb_formats == nb_formats); |
| 644 | 37095 | return formats; | |
| 645 | } | ||
| 646 | 37095 | formats = av_mallocz(sizeof(*formats)); | |
| 647 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 37095 times.
|
37095 | if (!formats) |
| 648 | ✗ | return NULL; | |
| 649 | 37095 | formats->nb_formats = nb_formats; | |
| 650 |
1/2✓ Branch 0 taken 37095 times.
✗ Branch 1 not taken.
|
37095 | if (nb_formats) { |
| 651 | 37095 | formats->formats = av_malloc_array(nb_formats, sizeof(*formats->formats)); | |
| 652 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 37095 times.
|
37095 | if (!formats->formats) { |
| 653 | ✗ | av_freep(&formats); | |
| 654 | ✗ | return NULL; | |
| 655 | } | ||
| 656 | } | ||
| 657 | } | ||
| 658 | } | ||
| 659 | |||
| 660 | 65 | AVFilterFormats *ff_planar_sample_fmts(void) | |
| 661 | { | ||
| 662 | 65 | AVFilterFormats *ret = NULL; | |
| 663 | int fmt; | ||
| 664 | |||
| 665 |
2/2✓ Branch 1 taken 780 times.
✓ Branch 2 taken 65 times.
|
845 | for (fmt = 0; av_get_bytes_per_sample(fmt)>0; fmt++) |
| 666 |
2/2✓ Branch 1 taken 390 times.
✓ Branch 2 taken 390 times.
|
780 | if (av_sample_fmt_is_planar(fmt)) |
| 667 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
|
390 | if (ff_add_format(&ret, fmt) < 0) |
| 668 | ✗ | return NULL; | |
| 669 | |||
| 670 | 65 | return ret; | |
| 671 | } | ||
| 672 | |||
| 673 | 46213 | AVFilterFormats *ff_all_samplerates(void) | |
| 674 | { | ||
| 675 | 46213 | AVFilterFormats *ret = av_mallocz(sizeof(*ret)); | |
| 676 | 46213 | return ret; | |
| 677 | } | ||
| 678 | |||
| 679 | 70 | AVFilterChannelLayouts *ff_all_channel_layouts(void) | |
| 680 | { | ||
| 681 | 70 | AVFilterChannelLayouts *ret = av_mallocz(sizeof(*ret)); | |
| 682 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
|
70 | if (!ret) |
| 683 | ✗ | return NULL; | |
| 684 | 70 | ret->all_layouts = 1; | |
| 685 | 70 | return ret; | |
| 686 | } | ||
| 687 | |||
| 688 | 46873 | AVFilterChannelLayouts *ff_all_channel_counts(void) | |
| 689 | { | ||
| 690 | 46873 | AVFilterChannelLayouts *ret = av_mallocz(sizeof(*ret)); | |
| 691 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46873 times.
|
46873 | if (!ret) |
| 692 | ✗ | return NULL; | |
| 693 | 46873 | ret->all_layouts = ret->all_counts = 1; | |
| 694 | 46873 | return ret; | |
| 695 | } | ||
| 696 | |||
| 697 | 58618 | AVFilterFormats *ff_all_color_spaces(void) | |
| 698 | { | ||
| 699 | 58618 | AVFilterFormats *ret = NULL; | |
| 700 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 58618 times.
|
58618 | if (ff_add_format(&ret, AVCOL_SPC_UNSPECIFIED) < 0) |
| 701 | ✗ | return NULL; | |
| 702 |
2/2✓ Branch 0 taken 1055124 times.
✓ Branch 1 taken 58618 times.
|
1113742 | for (int csp = 0; csp < AVCOL_SPC_NB; csp++) { |
| 703 |
4/4✓ Branch 0 taken 996506 times.
✓ Branch 1 taken 58618 times.
✓ Branch 2 taken 58618 times.
✓ Branch 3 taken 937888 times.
|
1055124 | if (csp == AVCOL_SPC_RESERVED || |
| 704 | csp == AVCOL_SPC_UNSPECIFIED) | ||
| 705 | 117236 | continue; | |
| 706 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 937888 times.
|
937888 | if (ff_add_format(&ret, csp) < 0) |
| 707 | ✗ | return NULL; | |
| 708 | } | ||
| 709 | |||
| 710 | 58618 | return ret; | |
| 711 | } | ||
| 712 | |||
| 713 | 58618 | AVFilterFormats *ff_all_color_ranges(void) | |
| 714 | { | ||
| 715 | 58618 | AVFilterFormats *ret = NULL; | |
| 716 |
2/2✓ Branch 0 taken 175854 times.
✓ Branch 1 taken 58618 times.
|
234472 | for (int range = 0; range < AVCOL_RANGE_NB; range++) { |
| 717 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 175854 times.
|
175854 | if (ff_add_format(&ret, range) < 0) |
| 718 | ✗ | return NULL; | |
| 719 | } | ||
| 720 | |||
| 721 | 58618 | return ret; | |
| 722 | } | ||
| 723 | |||
| 724 | 45296 | AVFilterFormats *ff_all_alpha_modes(void) | |
| 725 | { | ||
| 726 | 45296 | AVFilterFormats *ret = NULL; | |
| 727 |
2/2✓ Branch 0 taken 135888 times.
✓ Branch 1 taken 45296 times.
|
181184 | for (int range = 0; range < AVALPHA_MODE_NB; range++) { |
| 728 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 135888 times.
|
135888 | if (ff_add_format(&ret, range) < 0) |
| 729 | ✗ | return NULL; | |
| 730 | } | ||
| 731 | |||
| 732 | 45296 | return ret; | |
| 733 | } | ||
| 734 | |||
| 735 | #define FORMATS_REF(f, ref, unref_fn) \ | ||
| 736 | void *tmp; \ | ||
| 737 | \ | ||
| 738 | if (!f) \ | ||
| 739 | return AVERROR(ENOMEM); \ | ||
| 740 | \ | ||
| 741 | tmp = av_realloc_array(f->refs, f->refcount + 1, sizeof(*f->refs)); \ | ||
| 742 | if (!tmp) { \ | ||
| 743 | unref_fn(&f); \ | ||
| 744 | return AVERROR(ENOMEM); \ | ||
| 745 | } \ | ||
| 746 | f->refs = tmp; \ | ||
| 747 | f->refs[f->refcount++] = ref; \ | ||
| 748 | *ref = f; \ | ||
| 749 | return 0 | ||
| 750 | |||
| 751 | 12138 | int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref) | |
| 752 | { | ||
| 753 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 12138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12138 times.
|
12138 | FORMATS_REF(f, ref, ff_channel_layouts_unref); |
| 754 | } | ||
| 755 | |||
| 756 | 290683 | int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) | |
| 757 | { | ||
| 758 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 290683 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 290683 times.
|
290683 | FORMATS_REF(f, ref, ff_formats_unref); |
| 759 | } | ||
| 760 | |||
| 761 | #define FIND_REF_INDEX(ref, idx) \ | ||
| 762 | do { \ | ||
| 763 | int i; \ | ||
| 764 | for (i = 0; i < (*ref)->refcount; i ++) \ | ||
| 765 | if((*ref)->refs[i] == ref) { \ | ||
| 766 | idx = i; \ | ||
| 767 | break; \ | ||
| 768 | } \ | ||
| 769 | } while (0) | ||
| 770 | |||
| 771 | #define FORMATS_UNREF(ref, list) \ | ||
| 772 | do { \ | ||
| 773 | int idx = -1; \ | ||
| 774 | \ | ||
| 775 | if (!*ref) \ | ||
| 776 | return; \ | ||
| 777 | \ | ||
| 778 | FIND_REF_INDEX(ref, idx); \ | ||
| 779 | \ | ||
| 780 | if (idx >= 0) { \ | ||
| 781 | memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \ | ||
| 782 | sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \ | ||
| 783 | --(*ref)->refcount; \ | ||
| 784 | } \ | ||
| 785 | if (!(*ref)->refcount) { \ | ||
| 786 | FREE_LIST(ref, list); \ | ||
| 787 | av_free((*ref)->list); \ | ||
| 788 | av_free((*ref)->refs); \ | ||
| 789 | av_free(*ref); \ | ||
| 790 | } \ | ||
| 791 | *ref = NULL; \ | ||
| 792 | } while (0) | ||
| 793 | |||
| 794 | #define FREE_LIST(ref, list) do { } while(0) | ||
| 795 | 1026437 | void ff_formats_unref(AVFilterFormats **ref) | |
| 796 | { | ||
| 797 |
10/10✓ Branch 0 taken 618741 times.
✓ Branch 1 taken 407696 times.
✓ Branch 2 taken 290683 times.
✓ Branch 3 taken 148955 times.
✓ Branch 4 taken 439638 times.
✓ Branch 5 taken 117013 times.
✓ Branch 6 taken 290683 times.
✓ Branch 7 taken 117013 times.
✓ Branch 8 taken 175752 times.
✓ Branch 9 taken 231944 times.
|
1175392 | FORMATS_UNREF(ref, formats); |
| 798 | } | ||
| 799 | |||
| 800 | #undef FREE_LIST | ||
| 801 | #define FREE_LIST(ref, list) \ | ||
| 802 | do { \ | ||
| 803 | for (int i = 0; i < (*ref)->nb_channel_layouts; i++) \ | ||
| 804 | av_channel_layout_uninit(&(*ref)->list[i]); \ | ||
| 805 | } while(0) | ||
| 806 | |||
| 807 | 208717 | void ff_channel_layouts_unref(AVFilterChannelLayouts **ref) | |
| 808 | { | ||
| 809 |
12/12✓ Branch 0 taken 157058 times.
✓ Branch 1 taken 51659 times.
✓ Branch 2 taken 12138 times.
✓ Branch 3 taken 9138 times.
✓ Branch 4 taken 21276 times.
✓ Branch 5 taken 39521 times.
✓ Branch 6 taken 12138 times.
✓ Branch 7 taken 39521 times.
✓ Branch 8 taken 41991 times.
✓ Branch 9 taken 9668 times.
✓ Branch 11 taken 2470 times.
✓ Branch 12 taken 41991 times.
|
220325 | FORMATS_UNREF(ref, channel_layouts); |
| 810 | } | ||
| 811 | |||
| 812 | #define FORMATS_CHANGEREF(oldref, newref) \ | ||
| 813 | do { \ | ||
| 814 | int idx = -1; \ | ||
| 815 | \ | ||
| 816 | FIND_REF_INDEX(oldref, idx); \ | ||
| 817 | \ | ||
| 818 | if (idx >= 0) { \ | ||
| 819 | (*oldref)->refs[idx] = newref; \ | ||
| 820 | *newref = *oldref; \ | ||
| 821 | *oldref = NULL; \ | ||
| 822 | } \ | ||
| 823 | } while (0) | ||
| 824 | |||
| 825 | 648 | void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, | |
| 826 | AVFilterChannelLayouts **newref) | ||
| 827 | { | ||
| 828 |
4/6✓ Branch 0 taken 648 times.
✓ Branch 1 taken 1678 times.
✓ Branch 2 taken 2326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 648 times.
✗ Branch 5 not taken.
|
2326 | FORMATS_CHANGEREF(oldref, newref); |
| 829 | 648 | } | |
| 830 | |||
| 831 | 3824 | void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) | |
| 832 | { | ||
| 833 |
4/6✓ Branch 0 taken 3824 times.
✓ Branch 1 taken 8108 times.
✓ Branch 2 taken 11932 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3824 times.
✗ Branch 5 not taken.
|
11932 | FORMATS_CHANGEREF(oldref, newref); |
| 834 | 3824 | } | |
| 835 | |||
| 836 | #define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn) \ | ||
| 837 | int i; \ | ||
| 838 | \ | ||
| 839 | if (!fmts) \ | ||
| 840 | return AVERROR(ENOMEM); \ | ||
| 841 | \ | ||
| 842 | for (i = 0; i < ctx->nb_inputs; i++) { \ | ||
| 843 | AVFilterLink *const link = ctx->inputs[i]; \ | ||
| 844 | if (link && !link->outcfg.fmts && \ | ||
| 845 | (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \ | ||
| 846 | int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \ | ||
| 847 | if (ret < 0) { \ | ||
| 848 | return ret; \ | ||
| 849 | } \ | ||
| 850 | } \ | ||
| 851 | } \ | ||
| 852 | for (i = 0; i < ctx->nb_outputs; i++) { \ | ||
| 853 | AVFilterLink *const link = ctx->outputs[i]; \ | ||
| 854 | if (link && !link->incfg.fmts && \ | ||
| 855 | (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \ | ||
| 856 | int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \ | ||
| 857 | if (ret < 0) { \ | ||
| 858 | return ret; \ | ||
| 859 | } \ | ||
| 860 | } \ | ||
| 861 | } \ | ||
| 862 | \ | ||
| 863 | if (!fmts->refcount) \ | ||
| 864 | unref_fn(&fmts); \ | ||
| 865 | \ | ||
| 866 | return 0; | ||
| 867 | |||
| 868 | 43832 | int ff_set_common_channel_layouts(AVFilterContext *ctx, | |
| 869 | AVFilterChannelLayouts *channel_layouts) | ||
| 870 | { | ||
| 871 |
19/24✗ Branch 0 not taken.
✓ Branch 1 taken 43832 times.
✓ Branch 2 taken 36705 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34956 times.
✓ Branch 5 taken 1749 times.
✓ Branch 6 taken 4320 times.
✓ Branch 7 taken 30636 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4320 times.
✓ Branch 11 taken 36705 times.
✓ Branch 12 taken 43832 times.
✓ Branch 13 taken 35575 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 32365 times.
✓ Branch 16 taken 3210 times.
✓ Branch 17 taken 2859 times.
✓ Branch 18 taken 29506 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 2859 times.
✓ Branch 22 taken 35575 times.
✓ Branch 23 taken 43832 times.
✓ Branch 24 taken 39521 times.
✓ Branch 25 taken 4311 times.
|
116112 | SET_COMMON_FORMATS(ctx, channel_layouts, AVMEDIA_TYPE_AUDIO, |
| 872 | ff_channel_layouts_ref, ff_channel_layouts_unref); | ||
| 873 | } | ||
| 874 | |||
| 875 | ✗ | int ff_set_common_channel_layouts_from_list(AVFilterContext *ctx, | |
| 876 | const AVChannelLayout *fmts) | ||
| 877 | { | ||
| 878 | ✗ | return ff_set_common_channel_layouts(ctx, ff_make_channel_layout_list(fmts)); | |
| 879 | } | ||
| 880 | |||
| 881 | 43832 | int ff_set_common_all_channel_counts(AVFilterContext *ctx) | |
| 882 | { | ||
| 883 | 43832 | return ff_set_common_channel_layouts(ctx, ff_all_channel_counts()); | |
| 884 | } | ||
| 885 | |||
| 886 | 43836 | int ff_set_common_samplerates(AVFilterContext *ctx, | |
| 887 | AVFilterFormats *samplerates) | ||
| 888 | { | ||
| 889 |
19/24✗ Branch 0 not taken.
✓ Branch 1 taken 43836 times.
✓ Branch 2 taken 36715 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35087 times.
✓ Branch 5 taken 1628 times.
✓ Branch 6 taken 4451 times.
✓ Branch 7 taken 30636 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4451 times.
✓ Branch 11 taken 36715 times.
✓ Branch 12 taken 43836 times.
✓ Branch 13 taken 35579 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 32551 times.
✓ Branch 16 taken 3028 times.
✓ Branch 17 taken 3045 times.
✓ Branch 18 taken 29506 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3045 times.
✓ Branch 22 taken 35579 times.
✓ Branch 23 taken 43836 times.
✓ Branch 24 taken 39466 times.
✓ Branch 25 taken 4370 times.
|
116130 | SET_COMMON_FORMATS(ctx, samplerates, AVMEDIA_TYPE_AUDIO, |
| 890 | ff_formats_ref, ff_formats_unref); | ||
| 891 | } | ||
| 892 | |||
| 893 | ✗ | int ff_set_common_samplerates_from_list(AVFilterContext *ctx, | |
| 894 | const int *samplerates) | ||
| 895 | { | ||
| 896 | ✗ | return ff_set_common_samplerates(ctx, ff_make_format_list(samplerates)); | |
| 897 | } | ||
| 898 | |||
| 899 | 43836 | int ff_set_common_all_samplerates(AVFilterContext *ctx) | |
| 900 | { | ||
| 901 | 43836 | return ff_set_common_samplerates(ctx, ff_all_samplerates()); | |
| 902 | } | ||
| 903 | |||
| 904 | 45294 | int ff_set_common_color_spaces(AVFilterContext *ctx, | |
| 905 | AVFilterFormats *color_spaces) | ||
| 906 | { | ||
| 907 |
19/24✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
✓ Branch 2 taken 37028 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30390 times.
✓ Branch 5 taken 6638 times.
✓ Branch 6 taken 24363 times.
✓ Branch 7 taken 6027 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24363 times.
✓ Branch 11 taken 37028 times.
✓ Branch 12 taken 45294 times.
✓ Branch 13 taken 37037 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 25325 times.
✓ Branch 16 taken 11712 times.
✓ Branch 17 taken 19289 times.
✓ Branch 18 taken 6036 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 19289 times.
✓ Branch 22 taken 37037 times.
✓ Branch 23 taken 45294 times.
✓ Branch 24 taken 19070 times.
✓ Branch 25 taken 26224 times.
|
119359 | SET_COMMON_FORMATS(ctx, color_spaces, AVMEDIA_TYPE_VIDEO, |
| 908 | ff_formats_ref, ff_formats_unref); | ||
| 909 | } | ||
| 910 | |||
| 911 | ✗ | int ff_set_common_color_spaces_from_list(AVFilterContext *ctx, | |
| 912 | const int *color_spaces) | ||
| 913 | { | ||
| 914 | ✗ | return ff_set_common_color_spaces(ctx, ff_make_format_list(color_spaces)); | |
| 915 | } | ||
| 916 | |||
| 917 | 45294 | int ff_set_common_all_color_spaces(AVFilterContext *ctx) | |
| 918 | { | ||
| 919 | 45294 | return ff_set_common_color_spaces(ctx, ff_all_color_spaces()); | |
| 920 | } | ||
| 921 | |||
| 922 | 45294 | int ff_set_common_color_ranges(AVFilterContext *ctx, | |
| 923 | AVFilterFormats *color_ranges) | ||
| 924 | { | ||
| 925 |
19/24✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
✓ Branch 2 taken 37028 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28221 times.
✓ Branch 5 taken 8807 times.
✓ Branch 6 taken 22194 times.
✓ Branch 7 taken 6027 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 22194 times.
✓ Branch 11 taken 37028 times.
✓ Branch 12 taken 45294 times.
✓ Branch 13 taken 37037 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 23156 times.
✓ Branch 16 taken 13881 times.
✓ Branch 17 taken 17120 times.
✓ Branch 18 taken 6036 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 17120 times.
✓ Branch 22 taken 37037 times.
✓ Branch 23 taken 45294 times.
✓ Branch 24 taken 21239 times.
✓ Branch 25 taken 24055 times.
|
119359 | SET_COMMON_FORMATS(ctx, color_ranges, AVMEDIA_TYPE_VIDEO, |
| 926 | ff_formats_ref, ff_formats_unref); | ||
| 927 | } | ||
| 928 | |||
| 929 | ✗ | int ff_set_common_color_ranges_from_list(AVFilterContext *ctx, | |
| 930 | const int *color_ranges) | ||
| 931 | { | ||
| 932 | ✗ | return ff_set_common_color_ranges(ctx, ff_make_format_list(color_ranges)); | |
| 933 | } | ||
| 934 | |||
| 935 | 45294 | int ff_set_common_all_color_ranges(AVFilterContext *ctx) | |
| 936 | { | ||
| 937 | 45294 | return ff_set_common_color_ranges(ctx, ff_all_color_ranges()); | |
| 938 | } | ||
| 939 | |||
| 940 | 45294 | int ff_set_common_alpha_modes(AVFilterContext *ctx, | |
| 941 | AVFilterFormats *alpha_modes) | ||
| 942 | { | ||
| 943 |
19/24✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
✓ Branch 2 taken 37028 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36987 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 30960 times.
✓ Branch 7 taken 6027 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 30960 times.
✓ Branch 11 taken 37028 times.
✓ Branch 12 taken 45294 times.
✓ Branch 13 taken 37037 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 36682 times.
✓ Branch 16 taken 355 times.
✓ Branch 17 taken 30646 times.
✓ Branch 18 taken 6036 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 30646 times.
✓ Branch 22 taken 37037 times.
✓ Branch 23 taken 45294 times.
✓ Branch 24 taken 7709 times.
✓ Branch 25 taken 37585 times.
|
119359 | SET_COMMON_FORMATS(ctx, alpha_modes, AVMEDIA_TYPE_VIDEO, |
| 944 | ff_formats_ref, ff_formats_unref); | ||
| 945 | } | ||
| 946 | |||
| 947 | ✗ | int ff_set_common_alpha_modes_from_list(AVFilterContext *ctx, | |
| 948 | const int *alpha_modes) | ||
| 949 | { | ||
| 950 | ✗ | return ff_set_common_alpha_modes(ctx, ff_make_format_list(alpha_modes)); | |
| 951 | } | ||
| 952 | |||
| 953 | 45294 | int ff_set_common_all_alpha_modes(AVFilterContext *ctx) | |
| 954 | { | ||
| 955 | 45294 | return ff_set_common_alpha_modes(ctx, ff_all_alpha_modes()); | |
| 956 | } | ||
| 957 | |||
| 958 | /** | ||
| 959 | * A helper for query_formats() which sets all links to the same list of | ||
| 960 | * formats. If there are no links hooked to this filter, the list of formats is | ||
| 961 | * freed. | ||
| 962 | */ | ||
| 963 | 45331 | int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) | |
| 964 | { | ||
| 965 |
15/20✗ Branch 0 not taken.
✓ Branch 1 taken 45331 times.
✓ Branch 2 taken 37080 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14686 times.
✓ Branch 5 taken 22394 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14686 times.
✓ Branch 9 taken 37080 times.
✓ Branch 10 taken 45331 times.
✓ Branch 11 taken 37074 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7501 times.
✓ Branch 14 taken 29573 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 7501 times.
✓ Branch 18 taken 37074 times.
✓ Branch 19 taken 45331 times.
✓ Branch 20 taken 29529 times.
✓ Branch 21 taken 15802 times.
|
119485 | SET_COMMON_FORMATS(ctx, formats, AVMEDIA_TYPE_UNKNOWN, |
| 966 | ff_formats_ref, ff_formats_unref); | ||
| 967 | } | ||
| 968 | |||
| 969 | ✗ | int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts) | |
| 970 | { | ||
| 971 | ✗ | return ff_set_common_formats(ctx, ff_make_format_list(fmts)); | |
| 972 | } | ||
| 973 | |||
| 974 | 4 | int ff_set_sample_formats_from_list(AVFilterContext *ctx, const enum AVSampleFormat *fmts) | |
| 975 | { | ||
| 976 | 4 | return ff_set_common_formats(ctx, ff_make_sample_format_list(fmts)); | |
| 977 | } | ||
| 978 | |||
| 979 | ✗ | int ff_set_pixel_formats_from_list(AVFilterContext *ctx, const enum AVPixelFormat *fmts) | |
| 980 | { | ||
| 981 | ✗ | return ff_set_common_formats(ctx, ff_make_pixel_format_list(fmts)); | |
| 982 | } | ||
| 983 | |||
| 984 | #define SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, fmts, media_type, \ | ||
| 985 | ref_fn, unref_fn) \ | ||
| 986 | if (!fmts) \ | ||
| 987 | return AVERROR(ENOMEM); \ | ||
| 988 | \ | ||
| 989 | for (unsigned i = 0; i < ctx->nb_inputs; i++) { \ | ||
| 990 | const AVFilterLink *const link = ctx->inputs[i]; \ | ||
| 991 | if (!cfg_in[i]->fmts && \ | ||
| 992 | (media_type == AVMEDIA_TYPE_UNKNOWN || \ | ||
| 993 | link->type == media_type)) { \ | ||
| 994 | int ret = ref_fn(fmts, &cfg_in[i]->fmts); \ | ||
| 995 | if (ret < 0) { \ | ||
| 996 | return ret; \ | ||
| 997 | } \ | ||
| 998 | } \ | ||
| 999 | } \ | ||
| 1000 | for (unsigned i = 0; i < ctx->nb_outputs; i++) { \ | ||
| 1001 | const AVFilterLink *const link = ctx->outputs[i]; \ | ||
| 1002 | if (!cfg_out[i]->fmts && \ | ||
| 1003 | (media_type == AVMEDIA_TYPE_UNKNOWN || \ | ||
| 1004 | link->type == media_type)) { \ | ||
| 1005 | int ret = ref_fn(fmts, &cfg_out[i]->fmts); \ | ||
| 1006 | if (ret < 0) { \ | ||
| 1007 | return ret; \ | ||
| 1008 | } \ | ||
| 1009 | } \ | ||
| 1010 | } \ | ||
| 1011 | \ | ||
| 1012 | if (!fmts->refcount) \ | ||
| 1013 | unref_fn(&fmts); \ | ||
| 1014 | \ | ||
| 1015 | return 0; | ||
| 1016 | |||
| 1017 | 1536 | int ff_set_common_channel_layouts2(const AVFilterContext *ctx, | |
| 1018 | AVFilterFormatsConfig **cfg_in, | ||
| 1019 | AVFilterFormatsConfig **cfg_out, | ||
| 1020 | AVFilterChannelLayouts *channel_layouts) | ||
| 1021 | { | ||
| 1022 |
12/20✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 1536 times.
✓ Branch 11 taken 1536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1536 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1536 times.
✓ Branch 18 taken 1536 times.
✓ Branch 19 taken 1536 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 1536 times.
|
3201 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, channel_layouts, AVMEDIA_TYPE_AUDIO, |
| 1023 | ff_channel_layouts_ref, ff_channel_layouts_unref); | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | 227 | int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, | |
| 1027 | AVFilterFormatsConfig **cfg_in, | ||
| 1028 | AVFilterFormatsConfig **cfg_out, | ||
| 1029 | const AVChannelLayout *fmts) | ||
| 1030 | { | ||
| 1031 | 227 | return ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, ff_make_channel_layout_list(fmts)); | |
| 1032 | } | ||
| 1033 | |||
| 1034 | ✗ | int ff_set_common_all_channel_counts2(const AVFilterContext *ctx, | |
| 1035 | AVFilterFormatsConfig **cfg_in, | ||
| 1036 | AVFilterFormatsConfig **cfg_out) | ||
| 1037 | { | ||
| 1038 | ✗ | return ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, ff_all_channel_counts()); | |
| 1039 | } | ||
| 1040 | |||
| 1041 | 1511 | int ff_set_common_samplerates2(const AVFilterContext *ctx, | |
| 1042 | AVFilterFormatsConfig **cfg_in, | ||
| 1043 | AVFilterFormatsConfig **cfg_out, | ||
| 1044 | AVFilterFormats *samplerates) | ||
| 1045 | { | ||
| 1046 |
12/20✗ Branch 0 not taken.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 104 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 104 times.
✓ Branch 9 taken 104 times.
✓ Branch 10 taken 1511 times.
✓ Branch 11 taken 1511 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1511 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1511 times.
✓ Branch 18 taken 1511 times.
✓ Branch 19 taken 1511 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 1511 times.
|
3126 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, samplerates, AVMEDIA_TYPE_AUDIO, |
| 1047 | ff_formats_ref, ff_formats_unref); | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | 202 | int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, | |
| 1051 | AVFilterFormatsConfig **cfg_in, | ||
| 1052 | AVFilterFormatsConfig **cfg_out, | ||
| 1053 | const int *samplerates) | ||
| 1054 | { | ||
| 1055 | 202 | return ff_set_common_samplerates2(ctx, cfg_in, cfg_out, ff_make_format_list(samplerates)); | |
| 1056 | } | ||
| 1057 | |||
| 1058 | ✗ | int ff_set_common_all_samplerates2(const AVFilterContext *ctx, | |
| 1059 | AVFilterFormatsConfig **cfg_in, | ||
| 1060 | AVFilterFormatsConfig **cfg_out) | ||
| 1061 | { | ||
| 1062 | ✗ | return ff_set_common_samplerates2(ctx, cfg_in, cfg_out, ff_all_samplerates()); | |
| 1063 | } | ||
| 1064 | |||
| 1065 | 5081 | int ff_set_common_color_spaces2(const AVFilterContext *ctx, | |
| 1066 | AVFilterFormatsConfig **cfg_in, | ||
| 1067 | AVFilterFormatsConfig **cfg_out, | ||
| 1068 | AVFilterFormats *color_spaces) | ||
| 1069 | { | ||
| 1070 |
12/20✗ Branch 0 not taken.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 5081 times.
✓ Branch 11 taken 5081 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 5081 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 5081 times.
✓ Branch 18 taken 5081 times.
✓ Branch 19 taken 5081 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 5081 times.
|
10182 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, color_spaces, AVMEDIA_TYPE_VIDEO, |
| 1071 | ff_formats_ref, ff_formats_unref); | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | ✗ | int ff_set_common_color_spaces_from_list2(const AVFilterContext *ctx, | |
| 1075 | AVFilterFormatsConfig **cfg_in, | ||
| 1076 | AVFilterFormatsConfig **cfg_out, | ||
| 1077 | const int *color_spaces) | ||
| 1078 | { | ||
| 1079 | ✗ | return ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, ff_make_format_list(color_spaces)); | |
| 1080 | } | ||
| 1081 | |||
| 1082 | ✗ | int ff_set_common_all_color_spaces2(const AVFilterContext *ctx, | |
| 1083 | AVFilterFormatsConfig **cfg_in, | ||
| 1084 | AVFilterFormatsConfig **cfg_out) | ||
| 1085 | { | ||
| 1086 | ✗ | return ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, ff_all_color_spaces()); | |
| 1087 | } | ||
| 1088 | |||
| 1089 | 7250 | int ff_set_common_color_ranges2(const AVFilterContext *ctx, | |
| 1090 | AVFilterFormatsConfig **cfg_in, | ||
| 1091 | AVFilterFormatsConfig **cfg_out, | ||
| 1092 | AVFilterFormats *color_ranges) | ||
| 1093 | { | ||
| 1094 |
12/20✗ Branch 0 not taken.
✓ Branch 1 taken 7250 times.
✓ Branch 2 taken 2189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2189 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2189 times.
✓ Branch 9 taken 2189 times.
✓ Branch 10 taken 7250 times.
✓ Branch 11 taken 7250 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7250 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 7250 times.
✓ Branch 18 taken 7250 times.
✓ Branch 19 taken 7250 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 7250 times.
|
16689 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, color_ranges, AVMEDIA_TYPE_VIDEO, |
| 1095 | ff_formats_ref, ff_formats_unref); | ||
| 1096 | } | ||
| 1097 | |||
| 1098 | ✗ | int ff_set_common_color_ranges_from_list2(const AVFilterContext *ctx, | |
| 1099 | AVFilterFormatsConfig **cfg_in, | ||
| 1100 | AVFilterFormatsConfig **cfg_out, | ||
| 1101 | const int *color_ranges) | ||
| 1102 | { | ||
| 1103 | ✗ | return ff_set_common_color_ranges2(ctx, cfg_in, cfg_out, ff_make_format_list(color_ranges)); | |
| 1104 | } | ||
| 1105 | |||
| 1106 | ✗ | int ff_set_common_all_color_ranges2(const AVFilterContext *ctx, | |
| 1107 | AVFilterFormatsConfig **cfg_in, | ||
| 1108 | AVFilterFormatsConfig **cfg_out) | ||
| 1109 | { | ||
| 1110 | ✗ | return ff_set_common_color_ranges2(ctx, cfg_in, cfg_out, ff_all_color_ranges()); | |
| 1111 | } | ||
| 1112 | |||
| 1113 | 349 | int ff_set_common_alpha_modes2(const AVFilterContext *ctx, | |
| 1114 | AVFilterFormatsConfig **cfg_in, | ||
| 1115 | AVFilterFormatsConfig **cfg_out, | ||
| 1116 | AVFilterFormats *alpha_modes) | ||
| 1117 | { | ||
| 1118 |
12/20✗ Branch 0 not taken.
✓ Branch 1 taken 349 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 38 times.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 349 times.
✓ Branch 11 taken 349 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 349 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 349 times.
✓ Branch 18 taken 349 times.
✓ Branch 19 taken 349 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 349 times.
|
736 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, alpha_modes, AVMEDIA_TYPE_VIDEO, |
| 1119 | ff_formats_ref, ff_formats_unref); | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | ✗ | int ff_set_common_alpha_modes_from_list2(const AVFilterContext *ctx, | |
| 1123 | AVFilterFormatsConfig **cfg_in, | ||
| 1124 | AVFilterFormatsConfig **cfg_out, | ||
| 1125 | const int *alpha_modes) | ||
| 1126 | { | ||
| 1127 | ✗ | return ff_set_common_alpha_modes2(ctx, cfg_in, cfg_out, ff_make_format_list(alpha_modes)); | |
| 1128 | } | ||
| 1129 | |||
| 1130 | ✗ | int ff_set_common_all_alpha_modes2(const AVFilterContext *ctx, | |
| 1131 | AVFilterFormatsConfig **cfg_in, | ||
| 1132 | AVFilterFormatsConfig **cfg_out) | ||
| 1133 | { | ||
| 1134 | ✗ | return ff_set_common_alpha_modes2(ctx, cfg_in, cfg_out, ff_all_alpha_modes()); | |
| 1135 | } | ||
| 1136 | |||
| 1137 | 21326 | int ff_set_common_formats2(const AVFilterContext *ctx, | |
| 1138 | AVFilterFormatsConfig **cfg_in, | ||
| 1139 | AVFilterFormatsConfig **cfg_out, | ||
| 1140 | AVFilterFormats *formats) | ||
| 1141 | { | ||
| 1142 |
11/16✗ Branch 0 not taken.
✓ Branch 1 taken 21326 times.
✓ Branch 2 taken 14157 times.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14157 times.
✓ Branch 7 taken 14161 times.
✓ Branch 8 taken 21326 times.
✓ Branch 9 taken 21367 times.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 21367 times.
✓ Branch 14 taken 21367 times.
✓ Branch 15 taken 21326 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21326 times.
|
56854 | SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, formats, AVMEDIA_TYPE_UNKNOWN, |
| 1143 | ff_formats_ref, ff_formats_unref); | ||
| 1144 | } | ||
| 1145 | |||
| 1146 | ✗ | int ff_set_common_formats_from_list2(const AVFilterContext *ctx, | |
| 1147 | AVFilterFormatsConfig **cfg_in, | ||
| 1148 | AVFilterFormatsConfig **cfg_out, | ||
| 1149 | const int *fmts) | ||
| 1150 | { | ||
| 1151 | ✗ | return ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_make_format_list(fmts)); | |
| 1152 | } | ||
| 1153 | |||
| 1154 | 1821 | int ff_set_sample_formats_from_list2(const AVFilterContext *ctx, | |
| 1155 | AVFilterFormatsConfig **cfg_in, | ||
| 1156 | AVFilterFormatsConfig **cfg_out, | ||
| 1157 | const enum AVSampleFormat *fmts) | ||
| 1158 | { | ||
| 1159 | 1821 | return ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_make_sample_format_list(fmts)); | |
| 1160 | } | ||
| 1161 | |||
| 1162 | 99 | int ff_set_pixel_formats_from_list2(const AVFilterContext *ctx, | |
| 1163 | AVFilterFormatsConfig **cfg_in, | ||
| 1164 | AVFilterFormatsConfig **cfg_out, | ||
| 1165 | const enum AVPixelFormat *fmts) | ||
| 1166 | { | ||
| 1167 | 99 | return ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_make_pixel_format_list(fmts)); | |
| 1168 | } | ||
| 1169 | |||
| 1170 | 45327 | int ff_default_query_formats(AVFilterContext *ctx) | |
| 1171 | { | ||
| 1172 | 45327 | const FFFilter *const f = fffilter(ctx->filter); | |
| 1173 | AVFilterFormats *formats; | ||
| 1174 | enum AVMediaType type; | ||
| 1175 | int ret; | ||
| 1176 | |||
| 1177 |
5/5✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 43799 times.
|
45327 | switch (f->formats_state) { |
| 1178 | 1463 | case FF_FILTER_FORMATS_PIXFMT_LIST: | |
| 1179 | 1463 | type = AVMEDIA_TYPE_VIDEO; | |
| 1180 | 1463 | formats = ff_make_pixel_format_list(f->formats.pixels_list); | |
| 1181 | 1463 | break; | |
| 1182 | 20 | case FF_FILTER_FORMATS_SAMPLEFMTS_LIST: | |
| 1183 | 20 | type = AVMEDIA_TYPE_AUDIO; | |
| 1184 | 20 | formats = ff_make_sample_format_list(f->formats.samples_list); | |
| 1185 | 20 | break; | |
| 1186 | 32 | case FF_FILTER_FORMATS_SINGLE_PIXFMT: | |
| 1187 | 32 | type = AVMEDIA_TYPE_VIDEO; | |
| 1188 | 32 | formats = ff_make_formats_list_singleton(f->formats.pix_fmt); | |
| 1189 | 32 | break; | |
| 1190 | 13 | case FF_FILTER_FORMATS_SINGLE_SAMPLEFMT: | |
| 1191 | 13 | type = AVMEDIA_TYPE_AUDIO; | |
| 1192 | 13 | formats = ff_make_formats_list_singleton(f->formats.sample_fmt); | |
| 1193 | 13 | break; | |
| 1194 | 43799 | default: | |
| 1195 | av_assert2(!"Unreachable"); | ||
| 1196 | /* Intended fallthrough */ | ||
| 1197 | case FF_FILTER_FORMATS_PASSTHROUGH: | ||
| 1198 | case FF_FILTER_FORMATS_QUERY_FUNC: | ||
| 1199 | case FF_FILTER_FORMATS_QUERY_FUNC2: | ||
| 1200 | 43799 | type = AVMEDIA_TYPE_UNKNOWN; | |
| 1201 |
2/2✓ Branch 0 taken 36533 times.
✓ Branch 1 taken 7266 times.
|
51065 | formats = ff_all_formats(ctx->nb_inputs ? ctx->inputs [0]->type : |
| 1202 |
1/2✓ Branch 0 taken 7266 times.
✗ Branch 1 not taken.
|
7266 | ctx->nb_outputs ? ctx->outputs[0]->type : |
| 1203 | AVMEDIA_TYPE_VIDEO); | ||
| 1204 | 43799 | break; | |
| 1205 | } | ||
| 1206 | |||
| 1207 | 45327 | ret = ff_set_common_formats(ctx, formats); | |
| 1208 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45327 times.
|
45327 | if (ret < 0) |
| 1209 | ✗ | return ret; | |
| 1210 |
2/2✓ Branch 0 taken 45294 times.
✓ Branch 1 taken 33 times.
|
45327 | if (type != AVMEDIA_TYPE_AUDIO) { |
| 1211 | 45294 | ret = ff_set_common_all_color_spaces(ctx); | |
| 1212 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
|
45294 | if (ret < 0) |
| 1213 | ✗ | return ret; | |
| 1214 | 45294 | ret = ff_set_common_all_color_ranges(ctx); | |
| 1215 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
|
45294 | if (ret < 0) |
| 1216 | ✗ | return ret; | |
| 1217 | 45294 | ret = ff_set_common_all_alpha_modes(ctx); | |
| 1218 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45294 times.
|
45294 | if (ret < 0) |
| 1219 | ✗ | return ret; | |
| 1220 | } | ||
| 1221 |
2/2✓ Branch 0 taken 43832 times.
✓ Branch 1 taken 1495 times.
|
45327 | if (type != AVMEDIA_TYPE_VIDEO) { |
| 1222 | 43832 | ret = ff_set_common_all_channel_counts(ctx); | |
| 1223 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43832 times.
|
43832 | if (ret < 0) |
| 1224 | ✗ | return ret; | |
| 1225 | 43832 | ret = ff_set_common_all_samplerates(ctx); | |
| 1226 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43832 times.
|
43832 | if (ret < 0) |
| 1227 | ✗ | return ret; | |
| 1228 | } | ||
| 1229 | |||
| 1230 | 45327 | return 0; | |
| 1231 | } | ||
| 1232 | |||
| 1233 | 214934 | static int check_list(void *log, const char *name, const AVFilterFormats *fmts) | |
| 1234 | { | ||
| 1235 | unsigned i, j; | ||
| 1236 | |||
| 1237 |
2/2✓ Branch 0 taken 119274 times.
✓ Branch 1 taken 95660 times.
|
214934 | if (!fmts) |
| 1238 | 119274 | return 0; | |
| 1239 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 95660 times.
|
95660 | if (!fmts->nb_formats) { |
| 1240 | ✗ | av_log(log, AV_LOG_ERROR, "Empty %s list\n", name); | |
| 1241 | ✗ | return AVERROR(EINVAL); | |
| 1242 | } | ||
| 1243 |
2/2✓ Branch 0 taken 3736687 times.
✓ Branch 1 taken 95660 times.
|
3832347 | for (i = 0; i < fmts->nb_formats; i++) { |
| 1244 |
2/2✓ Branch 0 taken 383987338 times.
✓ Branch 1 taken 3736687 times.
|
387724025 | for (j = i + 1; j < fmts->nb_formats; j++) { |
| 1245 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 383987338 times.
|
383987338 | if (fmts->formats[i] == fmts->formats[j]) { |
| 1246 | ✗ | av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name); | |
| 1247 | ✗ | return AVERROR(EINVAL); | |
| 1248 | } | ||
| 1249 | } | ||
| 1250 | } | ||
| 1251 | 95660 | return 0; | |
| 1252 | } | ||
| 1253 | |||
| 1254 | 50769 | int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts) | |
| 1255 | { | ||
| 1256 | 50769 | return check_list(log, "pixel format", fmts); | |
| 1257 | } | ||
| 1258 | |||
| 1259 | 9599 | int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts) | |
| 1260 | { | ||
| 1261 | 9599 | return check_list(log, "sample format", fmts); | |
| 1262 | } | ||
| 1263 | |||
| 1264 | 9599 | int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts) | |
| 1265 | { | ||
| 1266 |
4/4✓ Branch 0 taken 4656 times.
✓ Branch 1 taken 4943 times.
✓ Branch 2 taken 2397 times.
✓ Branch 3 taken 2259 times.
|
9599 | if (!fmts || !fmts->nb_formats) |
| 1267 | 7340 | return 0; | |
| 1268 | 2259 | return check_list(log, "sample rate", fmts); | |
| 1269 | } | ||
| 1270 | |||
| 1271 | 50769 | int ff_formats_check_color_spaces(void *log, const AVFilterFormats *fmts) | |
| 1272 | { | ||
| 1273 |
4/4✓ Branch 0 taken 129338 times.
✓ Branch 1 taken 32419 times.
✓ Branch 2 taken 110988 times.
✓ Branch 3 taken 18350 times.
|
161757 | for (int i = 0; fmts && i < fmts->nb_formats; i++) { |
| 1274 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 110988 times.
|
110988 | if (fmts->formats[i] == AVCOL_SPC_RESERVED) { |
| 1275 | ✗ | av_log(log, AV_LOG_ERROR, "Invalid color space\n"); | |
| 1276 | ✗ | return AVERROR(EINVAL); | |
| 1277 | } | ||
| 1278 | } | ||
| 1279 | 50769 | return check_list(log, "color space", fmts); | |
| 1280 | } | ||
| 1281 | |||
| 1282 | 50769 | int ff_formats_check_color_ranges(void *log, const AVFilterFormats *fmts) | |
| 1283 | { | ||
| 1284 | 50769 | return check_list(log, "color range", fmts); | |
| 1285 | } | ||
| 1286 | |||
| 1287 | 50769 | int ff_formats_check_alpha_modes(void *log, const AVFilterFormats *fmts) | |
| 1288 | { | ||
| 1289 | 50769 | return check_list(log, "alpha mode", fmts); | |
| 1290 | } | ||
| 1291 | |||
| 1292 | 3978 | static int layouts_compatible(const AVChannelLayout *a, const AVChannelLayout *b) | |
| 1293 | { | ||
| 1294 | 3978 | return !av_channel_layout_compare(a, b) || | |
| 1295 |
3/12✓ Branch 0 taken 3978 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3978 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3978 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
7956 | (KNOWN(a) && !KNOWN(b) && a->nb_channels == b->nb_channels) || |
| 1296 |
2/10✗ Branch 0 not taken.
✓ Branch 1 taken 3978 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3978 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
3978 | (KNOWN(b) && !KNOWN(a) && b->nb_channels == a->nb_channels); |
| 1297 | } | ||
| 1298 | |||
| 1299 | 9599 | int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts) | |
| 1300 | { | ||
| 1301 | unsigned i, j; | ||
| 1302 | |||
| 1303 |
2/2✓ Branch 0 taken 4640 times.
✓ Branch 1 taken 4959 times.
|
9599 | if (!fmts) |
| 1304 | 4640 | return 0; | |
| 1305 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4959 times.
|
4959 | if (fmts->all_layouts < fmts->all_counts) { |
| 1306 | ✗ | av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); | |
| 1307 | ✗ | return AVERROR(EINVAL); | |
| 1308 | } | ||
| 1309 |
3/4✓ Branch 0 taken 1842 times.
✓ Branch 1 taken 3117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1842 times.
|
4959 | if (!fmts->all_layouts && !fmts->nb_channel_layouts) { |
| 1310 | ✗ | av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); | |
| 1311 | ✗ | return AVERROR(EINVAL); | |
| 1312 | } | ||
| 1313 |
2/2✓ Branch 0 taken 2616 times.
✓ Branch 1 taken 4959 times.
|
7575 | for (i = 0; i < fmts->nb_channel_layouts; i++) { |
| 1314 |
2/2✓ Branch 0 taken 3978 times.
✓ Branch 1 taken 2616 times.
|
6594 | for (j = i + 1; j < fmts->nb_channel_layouts; j++) { |
| 1315 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3978 times.
|
3978 | if (layouts_compatible(&fmts->channel_layouts[i], &fmts->channel_layouts[j])) { |
| 1316 | ✗ | av_log(log, AV_LOG_ERROR, "Duplicated or redundant channel layout\n"); | |
| 1317 | ✗ | return AVERROR(EINVAL); | |
| 1318 | } | ||
| 1319 | } | ||
| 1320 | } | ||
| 1321 | 4959 | return 0; | |
| 1322 | } | ||
| 1323 |