MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

tools/target_sws_fuzzer.c:89–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
90 int srcW= 48, srcH = 48;
91 int dstW= 48, dstH = 48;
92 int srcHShift, srcVShift;
93 int dstHShift, dstVShift;
94 unsigned flags = 1;
95 int srcStride[AV_VIDEO_MAX_PLANES] = {0};
96 int dstStride[AV_VIDEO_MAX_PLANES] = {0};
97 int ret;
98 const uint8_t *end = data + size;
99 enum AVPixelFormat srcFormat = AV_PIX_FMT_YUV420P;
100 enum AVPixelFormat dstFormat = AV_PIX_FMT_YUV420P;
101 uint8_t *src[AV_VIDEO_MAX_PLANES] = { 0 };
102 uint8_t *dst[AV_VIDEO_MAX_PLANES] = { 0 };
103 struct SwsContext *sws = NULL;
104 const AVPixFmtDescriptor *desc_src, *desc_dst;
105
106 if (size > 128) {
107 GetByteContext gbc;
108 int64_t flags64;
109
110 size -= 128;
111 bytestream2_init(&gbc, data + size, 128);
112 srcW = bytestream2_get_le32(&gbc);
113 srcH = bytestream2_get_le32(&gbc);
114 dstW = bytestream2_get_le32(&gbc);
115 dstH = bytestream2_get_le32(&gbc);
116
117 mapres(&srcW, &srcH);
118 mapres(&dstW, &dstH);
119
120 flags = bytestream2_get_le32(&gbc);
121
122 unsigned mask = flags & (SWS_POINT |
123 SWS_AREA |
124 SWS_BILINEAR |
125 SWS_FAST_BILINEAR |
126 SWS_BICUBIC |
127 SWS_X |
128 SWS_GAUSS |
129 SWS_LANCZOS |
130 SWS_SINC |
131 SWS_SPLINE |
132 SWS_BICUBLIN);
133 mask &= flags;
134 if (mask && (mask & (mask -1)))
135 return 0; // multiple scalers are set, not possible
136
137 srcFormat = bytestream2_get_le32(&gbc) % AV_PIX_FMT_NB;
138 dstFormat = bytestream2_get_le32(&gbc) % AV_PIX_FMT_NB;
139
140 flags64 = bytestream2_get_le64(&gbc);
141 if (flags64 & 0x10)
142 av_force_cpu_flags(0);
143
144 if (av_image_check_size(srcW, srcH, srcFormat, NULL) < 0)
145 srcW = srcH = 23;
146 if (av_image_check_size(dstW, dstH, dstFormat, NULL) < 0)

Callers

nothing calls this directly

Calls 14

bytestream2_initFunction · 0.85
mapresFunction · 0.85
av_force_cpu_flagsFunction · 0.85
av_image_check_sizeFunction · 0.85
av_pix_fmt_desc_getFunction · 0.85
alloc_planeFunction · 0.85
sws_alloc_contextFunction · 0.85
av_opt_set_intFunction · 0.85
av_opt_setFunction · 0.85
sws_init_contextFunction · 0.85
sws_scaleFunction · 0.85
sws_freeContextFunction · 0.85

Tested by

no test coverage detected