Make ff_parse_channel_layout() accept unknown layouts too.
(ret = ff_parse_sample_format(&aconvert->out_sample_fmt, aconvert->format_str, ctx)) < 0)
return ret;
if (aconvert->channel_layout_str && strcmp(aconvert->channel_layout_str, "auto"))
- return ff_parse_channel_layout(&aconvert->out_chlayout, aconvert->channel_layout_str, ctx);
+ return ff_parse_channel_layout(&aconvert->out_chlayout, NULL, aconvert->channel_layout_str, ctx);
return ret;
}
if (!args)
return AVERROR(ENOMEM);
arg = av_strtok(args, "|", &tokenizer);
- ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
+ ret = ff_parse_channel_layout(&pan->out_channel_layout, NULL, arg, ctx);
if (ret < 0)
goto fail;
pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
if (eval->chlayout_str) {
int n;
- ret = ff_parse_channel_layout(&eval->chlayout, eval->chlayout_str, ctx);
+ ret = ff_parse_channel_layout(&eval->chlayout, NULL, eval->chlayout_str, ctx);
if (ret < 0)
goto end;
null->sample_rate_str, ctx)) < 0)
return ret;
- if ((ret = ff_parse_channel_layout(&null->channel_layout,
+ if ((ret = ff_parse_channel_layout(&null->channel_layout, NULL,
null->channel_layout_str, ctx)) < 0)
return ret;
return 0;
}
-int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
+int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
+ void *log_ctx)
{
char *tail;
- int64_t chlayout = av_get_channel_layout(arg);
+ int64_t chlayout, count;
+
+ if (nret) {
+ count = strtol(arg, &tail, 10);
+ if (*tail == 'c' && !tail[1] && count > 0 && count < 63) {
+ *nret = count;
+ *ret = 0;
+ return 0;
+ }
+ }
+ chlayout = av_get_channel_layout(arg);
if (chlayout == 0) {
chlayout = strtol(arg, &tail, 10);
if (*tail || chlayout == 0) {
}
}
*ret = chlayout;
+ if (nret)
+ *nret = av_get_channel_layout_nb_channels(chlayout);
return 0;
}
* Parse a channel layout or a corresponding integer representation.
*
* @param ret 64bit integer pointer to where the value should be written.
+ * @param nret integer pointer to the number of channels;
+ * if not NULL, then unknown channel layouts are accepted
* @param arg string to parse
* @param log_ctx log context
* @return >= 0 in case of success, a negative AVERROR code on error
*/
-int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
+int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
+ void *log_ctx);
void ff_update_link_current_pts(AVFilterLink *link, int64_t pts);