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

Function opt_match_per_stream

fftools/ffmpeg_opt.c:181–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181static unsigned opt_match_per_stream(void *logctx, enum OptionType type,
182 const SpecifierOptList *sol,
183 AVFormatContext *fc, AVStream *st)
184{
185 int matches = 0, match_idx = -1;
186
187 av_assert0((type == sol->type) || !sol->nb_opt);
188
189 for (int i = 0; i < sol->nb_opt; i++) {
190 const StreamSpecifier *ss = &sol->opt[i].stream_spec;
191
192 if (stream_specifier_match(ss, fc, st, logctx)) {
193 match_idx = i;
194 matches++;
195 }
196 }
197
198 if (matches > 1 && sol->opt_canon) {
199 const SpecifierOpt *so = &sol->opt[match_idx];
200 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";
201
202 char namestr[128] = "";
203 char optval_buf[32];
204 const char *optval = optval_buf;
205
206 snprintf(namestr, sizeof(namestr), "-%s", sol->opt_canon->name);
207 if (sol->opt_canon->flags & OPT_HAS_ALT) {
208 const char * const *names_alt = sol->opt_canon->u1.names_alt;
209 for (int i = 0; names_alt[i]; i++)
210 av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[i]);
211 }
212
213 switch (sol->type) {
214 case OPT_TYPE_STRING: optval = so->u.str; break;
215 case OPT_TYPE_INT: snprintf(optval_buf, sizeof(optval_buf), "%d", so->u.i); break;
216 case OPT_TYPE_INT64: snprintf(optval_buf, sizeof(optval_buf), "%"PRId64, so->u.i64); break;
217 case OPT_TYPE_FLOAT: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.f); break;
218 case OPT_TYPE_DOUBLE: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.dbl); break;
219 default: av_assert0(0);
220 }
221
222 av_log(logctx, AV_LOG_WARNING, "Multiple %s options specified for "
223 "stream %d, only the last option '-%s%s%s %s' will be used.\n",
224 namestr, st->index, sol->opt_canon->name, spec[0] ? ":" : "",
225 spec, optval);
226 }
227
228 return match_idx + 1;
229}
230
231#define OPT_MATCH_PER_STREAM(name, type, opt_type, m) \
232void opt_match_per_stream_ ## name(void *logctx, const SpecifierOptList *sol, \

Callers

nothing calls this directly

Calls 3

stream_specifier_matchFunction · 0.85
av_strlcatfFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected