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