mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-18 21:10:10 +01:00
fftools/ffmpeg: use new stream specifier API in opt_match_per_stream*()
Removes a lot of error checking code, as matching cannot fail.
This commit is contained in:
@@ -288,6 +288,14 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
sol->opt[sol->nb_opt - 1].specifier = str;
|
sol->opt[sol->nb_opt - 1].specifier = str;
|
||||||
|
|
||||||
|
if (po->flags & OPT_FLAG_PERSTREAM) {
|
||||||
|
ret = stream_specifier_parse(&sol->opt[sol->nb_opt - 1].stream_spec,
|
||||||
|
str, 0, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
dst = &sol->opt[sol->nb_opt - 1].u;
|
dst = &sol->opt[sol->nb_opt - 1].u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,11 @@ unsigned stream_specifier_match(const StreamSpecifier *ss,
|
|||||||
void stream_specifier_uninit(StreamSpecifier *ss);
|
void stream_specifier_uninit(StreamSpecifier *ss);
|
||||||
|
|
||||||
typedef struct SpecifierOpt {
|
typedef struct SpecifierOpt {
|
||||||
char *specifier; /**< stream/chapter/program/... specifier */
|
// original specifier or empty string
|
||||||
|
char *specifier;
|
||||||
|
// parsed specifier for OPT_FLAG_PERSTREAM options
|
||||||
|
StreamSpecifier stream_spec;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
uint8_t *str;
|
uint8_t *str;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -859,13 +859,13 @@ void update_benchmark(const char *fmt, ...);
|
|||||||
|
|
||||||
const char *opt_match_per_type_str(const SpecifierOptList *sol,
|
const char *opt_match_per_type_str(const SpecifierOptList *sol,
|
||||||
char mediatype);
|
char mediatype);
|
||||||
int opt_match_per_stream_str(void *logctx, const SpecifierOptList *sol,
|
void opt_match_per_stream_str(void *logctx, const SpecifierOptList *sol,
|
||||||
AVFormatContext *fc, AVStream *st, const char **out);
|
AVFormatContext *fc, AVStream *st, const char **out);
|
||||||
int opt_match_per_stream_int(void *logctx, const SpecifierOptList *sol,
|
void opt_match_per_stream_int(void *logctx, const SpecifierOptList *sol,
|
||||||
AVFormatContext *fc, AVStream *st, int *out);
|
AVFormatContext *fc, AVStream *st, int *out);
|
||||||
int opt_match_per_stream_int64(void *logctx, const SpecifierOptList *sol,
|
void opt_match_per_stream_int64(void *logctx, const SpecifierOptList *sol,
|
||||||
AVFormatContext *fc, AVStream *st, int64_t *out);
|
AVFormatContext *fc, AVStream *st, int64_t *out);
|
||||||
int opt_match_per_stream_dbl(void *logctx, const SpecifierOptList *sol,
|
void opt_match_per_stream_dbl(void *logctx, const SpecifierOptList *sol,
|
||||||
AVFormatContext *fc, AVStream *st, double *out);
|
AVFormatContext *fc, AVStream *st, double *out);
|
||||||
|
|
||||||
int muxer_thread(void *arg);
|
int muxer_thread(void *arg);
|
||||||
|
|||||||
@@ -1084,12 +1084,8 @@ static int choose_decoder(const OptionsContext *o, void *logctx,
|
|||||||
|
|
||||||
{
|
{
|
||||||
const char *codec_name = NULL;
|
const char *codec_name = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(logctx, &o->codec_names, s, st, &codec_name);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
opt_match_per_stream_str(logctx, &o->codec_names, s, st, &codec_name);
|
||||||
if (codec_name) {
|
if (codec_name) {
|
||||||
int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
|
int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -1153,18 +1149,11 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
|
|||||||
double rotation = DBL_MAX;
|
double rotation = DBL_MAX;
|
||||||
int hflip = -1, vflip = -1;
|
int hflip = -1, vflip = -1;
|
||||||
int hflip_set = 0, vflip_set = 0, rotation_set = 0;
|
int hflip_set = 0, vflip_set = 0, rotation_set = 0;
|
||||||
int ret;
|
|
||||||
int32_t *buf;
|
int32_t *buf;
|
||||||
|
|
||||||
ret = opt_match_per_stream_dbl(ist, &o->display_rotations, ctx, st, &rotation);
|
opt_match_per_stream_dbl(ist, &o->display_rotations, ctx, st, &rotation);
|
||||||
if (ret < 0)
|
opt_match_per_stream_int(ist, &o->display_hflips, ctx, st, &hflip);
|
||||||
return ret;
|
opt_match_per_stream_int(ist, &o->display_vflips, ctx, st, &vflip);
|
||||||
ret = opt_match_per_stream_int(ist, &o->display_hflips, ctx, st, &hflip);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
ret = opt_match_per_stream_int(ist, &o->display_vflips, ctx, st, &vflip);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
rotation_set = rotation != DBL_MAX;
|
rotation_set = rotation != DBL_MAX;
|
||||||
hflip_set = hflip != -1;
|
hflip_set = hflip != -1;
|
||||||
@@ -1262,19 +1251,13 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
ds->dec_opts.time_base = st->time_base;
|
ds->dec_opts.time_base = st->time_base;
|
||||||
|
|
||||||
ds->ts_scale = 1.0;
|
ds->ts_scale = 1.0;
|
||||||
ret = opt_match_per_stream_dbl(ist, &o->ts_scale, ic, st, &ds->ts_scale);
|
opt_match_per_stream_dbl(ist, &o->ts_scale, ic, st, &ds->ts_scale);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ds->autorotate = 1;
|
ds->autorotate = 1;
|
||||||
ret = opt_match_per_stream_int(ist, &o->autorotate, ic, st, &ds->autorotate);
|
opt_match_per_stream_int(ist, &o->autorotate, ic, st, &ds->autorotate);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ds->apply_cropping = CROP_ALL;
|
ds->apply_cropping = CROP_ALL;
|
||||||
ret = opt_match_per_stream_str(ist, &o->apply_cropping, ic, st, &apply_cropping);
|
opt_match_per_stream_str(ist, &o->apply_cropping, ic, st, &apply_cropping);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (apply_cropping) {
|
if (apply_cropping) {
|
||||||
const AVOption opts[] = {
|
const AVOption opts[] = {
|
||||||
{ "apply_cropping", NULL, 0, AV_OPT_TYPE_INT,
|
{ "apply_cropping", NULL, 0, AV_OPT_TYPE_INT,
|
||||||
@@ -1300,9 +1283,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->codec_tags, ic, st, &codec_tag);
|
opt_match_per_stream_str(ist, &o->codec_tags, ic, st, &codec_tag);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (codec_tag) {
|
if (codec_tag) {
|
||||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||||
if (*next) {
|
if (*next) {
|
||||||
@@ -1319,15 +1300,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->hwaccels, ic, st, &hwaccel);
|
opt_match_per_stream_str(ist, &o->hwaccels, ic, st, &hwaccel);
|
||||||
if (ret < 0)
|
opt_match_per_stream_str(ist, &o->hwaccel_output_formats, ic, st,
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->hwaccel_output_formats, ic, st,
|
|
||||||
&hwaccel_output_format);
|
&hwaccel_output_format);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
|
if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
|
||||||
av_log(ist, AV_LOG_WARNING,
|
av_log(ist, AV_LOG_WARNING,
|
||||||
"WARNING: defaulting hwaccel_output_format to cuda for compatibility "
|
"WARNING: defaulting hwaccel_output_format to cuda for compatibility "
|
||||||
@@ -1385,9 +1360,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->hwaccel_devices, ic, st, &hwaccel_device);
|
opt_match_per_stream_str(ist, &o->hwaccel_devices, ic, st, &hwaccel_device);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (hwaccel_device) {
|
if (hwaccel_device) {
|
||||||
ds->dec_opts.hwaccel_device = av_strdup(hwaccel_device);
|
ds->dec_opts.hwaccel_device = av_strdup(hwaccel_device);
|
||||||
if (!ds->dec_opts.hwaccel_device)
|
if (!ds->dec_opts.hwaccel_device)
|
||||||
@@ -1408,9 +1381,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
}
|
}
|
||||||
|
|
||||||
ds->reinit_filters = -1;
|
ds->reinit_filters = -1;
|
||||||
ret = opt_match_per_stream_int(ist, &o->reinit_filters, ic, st, &ds->reinit_filters);
|
opt_match_per_stream_int(ist, &o->reinit_filters, ic, st, &ds->reinit_filters);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ist->user_set_discard = AVDISCARD_NONE;
|
ist->user_set_discard = AVDISCARD_NONE;
|
||||||
|
|
||||||
@@ -1420,9 +1391,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
(o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA))
|
(o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA))
|
||||||
ist->user_set_discard = AVDISCARD_ALL;
|
ist->user_set_discard = AVDISCARD_ALL;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->discard, ic, st, &discard_str);
|
opt_match_per_stream_str(ist, &o->discard, ic, st, &discard_str);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (discard_str) {
|
if (discard_str) {
|
||||||
ret = av_opt_set(ist->st, "discard", discard_str, 0);
|
ret = av_opt_set(ist->st, "discard", discard_str, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -1444,9 +1413,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
|
|
||||||
switch (par->codec_type) {
|
switch (par->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
ret = opt_match_per_stream_str(ist, &o->frame_rates, ic, st, &framerate);
|
opt_match_per_stream_str(ist, &o->frame_rates, ic, st, &framerate);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (framerate) {
|
if (framerate) {
|
||||||
ret = av_parse_video_rate(&ist->framerate, framerate);
|
ret = av_parse_video_rate(&ist->framerate, framerate);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -1458,18 +1425,14 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
|
|
||||||
#if FFMPEG_OPT_TOP
|
#if FFMPEG_OPT_TOP
|
||||||
ist->top_field_first = -1;
|
ist->top_field_first = -1;
|
||||||
ret = opt_match_per_stream_int(ist, &o->top_field_first, ic, st, &ist->top_field_first);
|
opt_match_per_stream_int(ist, &o->top_field_first, ic, st, &ist->top_field_first);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO: {
|
case AVMEDIA_TYPE_AUDIO: {
|
||||||
const char *ch_layout_str = NULL;
|
const char *ch_layout_str = NULL;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->audio_ch_layouts, ic, st, &ch_layout_str);
|
opt_match_per_stream_str(ist, &o->audio_ch_layouts, ic, st, &ch_layout_str);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (ch_layout_str) {
|
if (ch_layout_str) {
|
||||||
AVChannelLayout ch_layout;
|
AVChannelLayout ch_layout;
|
||||||
ret = av_channel_layout_from_string(&ch_layout, ch_layout_str);
|
ret = av_channel_layout_from_string(&ch_layout, ch_layout_str);
|
||||||
@@ -1489,10 +1452,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int guess_layout_max = INT_MAX;
|
int guess_layout_max = INT_MAX;
|
||||||
ret = opt_match_per_stream_int(ist, &o->guess_layout_max, ic, st, &guess_layout_max);
|
opt_match_per_stream_int(ist, &o->guess_layout_max, ic, st, &guess_layout_max);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
guess_input_channel_layout(ist, par, guess_layout_max);
|
guess_input_channel_layout(ist, par, guess_layout_max);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1501,13 +1461,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
case AVMEDIA_TYPE_SUBTITLE: {
|
case AVMEDIA_TYPE_SUBTITLE: {
|
||||||
const char *canvas_size = NULL;
|
const char *canvas_size = NULL;
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ist, &o->fix_sub_duration, ic, st, &ist->fix_sub_duration);
|
opt_match_per_stream_int(ist, &o->fix_sub_duration, ic, st, &ist->fix_sub_duration);
|
||||||
if (ret < 0)
|
opt_match_per_stream_str(ist, &o->canvas_sizes, ic, st, &canvas_size);
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->canvas_sizes, ic, st, &canvas_size);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (canvas_size) {
|
if (canvas_size) {
|
||||||
ret = av_parse_video_size(&par->width, &par->height,
|
ret = av_parse_video_size(&par->width, &par->height,
|
||||||
canvas_size);
|
canvas_size);
|
||||||
@@ -1537,9 +1492,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
|
|||||||
if (ist->st->sample_aspect_ratio.num)
|
if (ist->st->sample_aspect_ratio.num)
|
||||||
ist->par->sample_aspect_ratio = ist->st->sample_aspect_ratio;
|
ist->par->sample_aspect_ratio = ist->st->sample_aspect_ratio;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ist, &o->bitstream_filters, ic, st, &bsfs);
|
opt_match_per_stream_str(ist, &o->bitstream_filters, ic, st, &bsfs);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (bsfs) {
|
if (bsfs) {
|
||||||
ret = av_bsf_list_parse_str(bsfs, &ds->bsf);
|
ret = av_bsf_list_parse_str(bsfs, &ds->bsf);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|||||||
@@ -71,13 +71,10 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s,
|
|||||||
{
|
{
|
||||||
enum AVMediaType type = ost->type;
|
enum AVMediaType type = ost->type;
|
||||||
const char *codec_name = NULL;
|
const char *codec_name = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
*enc = NULL;
|
*enc = NULL;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->codec_names, s, ost->st, &codec_name);
|
opt_match_per_stream_str(ost, &o->codec_names, s, ost->st, &codec_name);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (type != AVMEDIA_TYPE_VIDEO &&
|
if (type != AVMEDIA_TYPE_VIDEO &&
|
||||||
type != AVMEDIA_TYPE_AUDIO &&
|
type != AVMEDIA_TYPE_AUDIO &&
|
||||||
@@ -419,17 +416,12 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
|
|||||||
OutputStream *ost, char **dst)
|
OutputStream *ost, char **dst)
|
||||||
{
|
{
|
||||||
const char *filters = NULL;
|
const char *filters = NULL;
|
||||||
int ret;
|
|
||||||
#if FFMPEG_OPT_FILTER_SCRIPT
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
const char *filters_script = NULL;
|
const char *filters_script = NULL;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->filter_scripts, oc, ost->st, &filters_script);
|
opt_match_per_stream_str(ost, &o->filter_scripts, oc, ost->st, &filters_script);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
#endif
|
#endif
|
||||||
ret = opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
|
opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!ost->enc) {
|
if (!ost->enc) {
|
||||||
if (
|
if (
|
||||||
@@ -599,17 +591,13 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
|
|
||||||
st = ost->st;
|
st = ost->st;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate);
|
opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
|
if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
|
av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate);
|
opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
|
if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
|
av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
@@ -620,9 +608,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->frame_aspect_ratios, oc, st, &frame_aspect_ratio);
|
opt_match_per_stream_str(ost, &o->frame_aspect_ratios, oc, st, &frame_aspect_ratio);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (frame_aspect_ratio) {
|
if (frame_aspect_ratio) {
|
||||||
AVRational q;
|
AVRational q;
|
||||||
if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 ||
|
if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 ||
|
||||||
@@ -643,9 +629,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
int do_pass = 0;
|
int do_pass = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->frame_sizes, oc, st, &frame_size);
|
opt_match_per_stream_str(ost, &o->frame_sizes, oc, st, &frame_size);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (frame_size) {
|
if (frame_size) {
|
||||||
ret = av_parse_video_size(&video_enc->width, &video_enc->height, frame_size);
|
ret = av_parse_video_size(&video_enc->width, &video_enc->height, frame_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -654,9 +638,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->frame_pix_fmts, oc, st, &frame_pix_fmt);
|
opt_match_per_stream_str(ost, &o->frame_pix_fmts, oc, st, &frame_pix_fmt);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (frame_pix_fmt && *frame_pix_fmt == '+') {
|
if (frame_pix_fmt && *frame_pix_fmt == '+') {
|
||||||
*keep_pix_fmt = 1;
|
*keep_pix_fmt = 1;
|
||||||
if (!*++frame_pix_fmt)
|
if (!*++frame_pix_fmt)
|
||||||
@@ -668,9 +650,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->intra_matrices, oc, st, &intra_matrix);
|
opt_match_per_stream_str(ost, &o->intra_matrices, oc, st, &intra_matrix);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (intra_matrix) {
|
if (intra_matrix) {
|
||||||
if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64)))
|
if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -679,9 +659,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = opt_match_per_stream_str(ost, &o->chroma_intra_matrices, oc, st, &chroma_intra_matrix);
|
opt_match_per_stream_str(ost, &o->chroma_intra_matrices, oc, st, &chroma_intra_matrix);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (chroma_intra_matrix) {
|
if (chroma_intra_matrix) {
|
||||||
uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64);
|
uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64);
|
||||||
if (!p)
|
if (!p)
|
||||||
@@ -691,9 +669,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = opt_match_per_stream_str(ost, &o->inter_matrices, oc, st, &inter_matrix);
|
opt_match_per_stream_str(ost, &o->inter_matrices, oc, st, &inter_matrix);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (inter_matrix) {
|
if (inter_matrix) {
|
||||||
if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64)))
|
if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -702,9 +678,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->rc_overrides, oc, st, &p);
|
opt_match_per_stream_str(ost, &o->rc_overrides, oc, st, &p);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
for (i = 0; p; i++) {
|
for (i = 0; p; i++) {
|
||||||
int start, end, q;
|
int start, end, q;
|
||||||
int e = sscanf(p, "%d,%d,%d", &start, &end, &q);
|
int e = sscanf(p, "%d,%d,%d", &start, &end, &q);
|
||||||
@@ -735,9 +709,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
video_enc->rc_override_count = i;
|
video_enc->rc_override_count = i;
|
||||||
|
|
||||||
/* two pass mode */
|
/* two pass mode */
|
||||||
ret = opt_match_per_stream_int(ost, &o->pass, oc, st, &do_pass);
|
opt_match_per_stream_int(ost, &o->pass, oc, st, &do_pass);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (do_pass) {
|
if (do_pass) {
|
||||||
if (do_pass & 1)
|
if (do_pass & 1)
|
||||||
video_enc->flags |= AV_CODEC_FLAG_PASS1;
|
video_enc->flags |= AV_CODEC_FLAG_PASS1;
|
||||||
@@ -745,9 +717,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
video_enc->flags |= AV_CODEC_FLAG_PASS2;
|
video_enc->flags |= AV_CODEC_FLAG_PASS2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->passlogfiles, oc, st, &ost->logfile_prefix);
|
opt_match_per_stream_str(ost, &o->passlogfiles, oc, st, &ost->logfile_prefix);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (ost->logfile_prefix &&
|
if (ost->logfile_prefix &&
|
||||||
!(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
|
!(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -794,15 +764,11 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps);
|
opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
#if FFMPEG_OPT_TOP
|
#if FFMPEG_OPT_TOP
|
||||||
ost->top_field_first = -1;
|
ost->top_field_first = -1;
|
||||||
ret = opt_match_per_stream_int(ost, &o->top_field_first, oc, st, &ost->top_field_first);
|
opt_match_per_stream_int(ost, &o->top_field_first, oc, st, &ost->top_field_first);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (ost->top_field_first >= 0)
|
if (ost->top_field_first >= 0)
|
||||||
av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
|
av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -812,9 +778,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
|
|||||||
#else
|
#else
|
||||||
*vsync_method = VSYNC_AUTO;
|
*vsync_method = VSYNC_AUTO;
|
||||||
#endif
|
#endif
|
||||||
ret = opt_match_per_stream_str(ost, &o->fps_mode, oc, st, &fps_mode);
|
opt_match_per_stream_str(ost, &o->fps_mode, oc, st, &fps_mode);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (fps_mode) {
|
if (fps_mode) {
|
||||||
ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0);
|
ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -872,40 +836,28 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
|
|||||||
int channels = 0;
|
int channels = 0;
|
||||||
const char *layout = NULL;
|
const char *layout = NULL;
|
||||||
const char *sample_fmt = NULL;
|
const char *sample_fmt = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->audio_channels, oc, st, &channels);
|
opt_match_per_stream_int(ost, &o->audio_channels, oc, st, &channels);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (channels) {
|
if (channels) {
|
||||||
audio_enc->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
|
audio_enc->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
|
||||||
audio_enc->ch_layout.nb_channels = channels;
|
audio_enc->ch_layout.nb_channels = channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->audio_ch_layouts, oc, st, &layout);
|
opt_match_per_stream_str(ost, &o->audio_ch_layouts, oc, st, &layout);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (layout && av_channel_layout_from_string(&audio_enc->ch_layout, layout) < 0) {
|
if (layout && av_channel_layout_from_string(&audio_enc->ch_layout, layout) < 0) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout);
|
av_log(ost, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->sample_fmts, oc, st, &sample_fmt);
|
opt_match_per_stream_str(ost, &o->sample_fmts, oc, st, &sample_fmt);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (sample_fmt &&
|
if (sample_fmt &&
|
||||||
(audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) {
|
(audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) {
|
||||||
av_log(ost, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
|
av_log(ost, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->audio_sample_rate, oc, st, &audio_enc->sample_rate);
|
opt_match_per_stream_int(ost, &o->audio_sample_rate, oc, st, &audio_enc->sample_rate);
|
||||||
if (ret < 0)
|
opt_match_per_stream_str(ost, &o->apad, oc, st, &ms->apad);
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->apad, oc, st, &ms->apad);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -928,11 +880,8 @@ static int new_stream_subtitle(Muxer *mux, const OptionsContext *o,
|
|||||||
int input_props = 0, output_props = 0;
|
int input_props = 0, output_props = 0;
|
||||||
|
|
||||||
const char *frame_size = NULL;
|
const char *frame_size = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->frame_sizes, mux->fc, st, &frame_size);
|
opt_match_per_stream_str(ost, &o->frame_sizes, mux->fc, st, &frame_size);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (frame_size) {
|
if (frame_size) {
|
||||||
int ret = av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size);
|
int ret = av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -1211,13 +1160,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->presets, oc, st, &preset);
|
opt_match_per_stream_str(ost, &o->presets, oc, st, &preset);
|
||||||
if (ret < 0)
|
opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale);
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale);
|
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) {
|
if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) {
|
||||||
AVBPrint bprint;
|
AVBPrint bprint;
|
||||||
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||||
@@ -1248,14 +1192,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->enc_stats_pre, oc, st, &enc_stats_pre);
|
opt_match_per_stream_str(ost, &o->enc_stats_pre, oc, st, &enc_stats_pre);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (enc_stats_pre &&
|
if (enc_stats_pre &&
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
const char *format = "{fidx} {sidx} {n} {t}";
|
const char *format = "{fidx} {sidx} {n} {t}";
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->enc_stats_pre_fmt, oc, st, &format);
|
opt_match_per_stream_str(ost, &o->enc_stats_pre_fmt, oc, st, &format);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -1264,41 +1206,31 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->enc_stats_post, oc, st, &enc_stats_post);
|
opt_match_per_stream_str(ost, &o->enc_stats_post, oc, st, &enc_stats_post);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (enc_stats_post &&
|
if (enc_stats_post &&
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
const char *format = "{fidx} {sidx} {n} {t}";
|
const char *format = "{fidx} {sidx} {n} {t}";
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->enc_stats_post_fmt, oc, st, &format);
|
opt_match_per_stream_str(ost, &o->enc_stats_post_fmt, oc, st, &format);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = enc_stats_init(ost, &ost->enc_stats_post, 0, enc_stats_post, format);
|
ret = enc_stats_init(ost, &ost->enc_stats_post, 0, enc_stats_post, format);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->mux_stats, oc, st, &mux_stats);
|
opt_match_per_stream_str(ost, &o->mux_stats, oc, st, &mux_stats);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (mux_stats &&
|
if (mux_stats &&
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
const char *format = "{fidx} {sidx} {n} {t}";
|
const char *format = "{fidx} {sidx} {n} {t}";
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->mux_stats_fmt, oc, st, &format);
|
opt_match_per_stream_str(ost, &o->mux_stats_fmt, oc, st, &format);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = enc_stats_init(ost, &ms->stats, 0, mux_stats, format);
|
ret = enc_stats_init(ost, &ms->stats, 0, mux_stats, format);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->enc_time_bases, oc, st, &enc_time_base);
|
opt_match_per_stream_str(ost, &o->enc_time_bases, oc, st, &enc_time_base);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE)
|
if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE)
|
||||||
av_log(ost, AV_LOG_WARNING,
|
av_log(ost, AV_LOG_WARNING,
|
||||||
"-enc_time_base not supported for subtitles, ignoring\n");
|
"-enc_time_base not supported for subtitles, ignoring\n");
|
||||||
@@ -1361,9 +1293,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT);
|
ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->time_bases, oc, st, &time_base);
|
opt_match_per_stream_str(ost, &o->time_bases, oc, st, &time_base);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (time_base) {
|
if (time_base) {
|
||||||
AVRational q;
|
AVRational q;
|
||||||
if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 ||
|
if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 ||
|
||||||
@@ -1376,9 +1306,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ms->max_frames = INT64_MAX;
|
ms->max_frames = INT64_MAX;
|
||||||
ret = opt_match_per_stream_int64(ost, &o->max_frames, oc, st, &ms->max_frames);
|
opt_match_per_stream_int64(ost, &o->max_frames, oc, st, &ms->max_frames);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
for (int i = 0; i < o->max_frames.nb_opt; i++) {
|
for (int i = 0; i < o->max_frames.nb_opt; i++) {
|
||||||
char *p = o->max_frames.opt[i].specifier;
|
char *p = o->max_frames.opt[i].specifier;
|
||||||
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
|
if (!*p && type != AVMEDIA_TYPE_VIDEO) {
|
||||||
@@ -1388,13 +1316,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ms->copy_prior_start = -1;
|
ms->copy_prior_start = -1;
|
||||||
ret = opt_match_per_stream_int(ost, &o->copy_prior_start, oc, st, &ms->copy_prior_start);
|
opt_match_per_stream_int(ost, &o->copy_prior_start, oc, st, &ms->copy_prior_start);
|
||||||
if (ret < 0)
|
opt_match_per_stream_str(ost, &o->bitstream_filters, oc, st, &bsfs);
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->bitstream_filters, oc, st, &bsfs);
|
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (bsfs && *bsfs) {
|
if (bsfs && *bsfs) {
|
||||||
ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx);
|
ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -1403,9 +1326,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->codec_tags, oc, st, &codec_tag);
|
opt_match_per_stream_str(ost, &o->codec_tags, oc, st, &codec_tag);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
if (codec_tag) {
|
if (codec_tag) {
|
||||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||||
if (*next) {
|
if (*next) {
|
||||||
@@ -1419,9 +1340,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
ost->enc_ctx->codec_tag = tag;
|
ost->enc_ctx->codec_tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale);
|
opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (ost->enc_ctx && qscale >= 0) {
|
if (ost->enc_ctx && qscale >= 0) {
|
||||||
ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
|
ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
|
||||||
ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
|
ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
|
||||||
@@ -1431,38 +1350,26 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
|||||||
int max_muxing_queue_size = 128;
|
int max_muxing_queue_size = 128;
|
||||||
int muxing_queue_data_threshold = 50 * 1024 * 1024;
|
int muxing_queue_data_threshold = 50 * 1024 * 1024;
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->max_muxing_queue_size, oc, st,
|
opt_match_per_stream_int(ost, &o->max_muxing_queue_size, oc, st,
|
||||||
&max_muxing_queue_size);
|
&max_muxing_queue_size);
|
||||||
if (ret < 0)
|
opt_match_per_stream_int(ost, &o->muxing_queue_data_threshold,
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->muxing_queue_data_threshold,
|
|
||||||
oc, st, &muxing_queue_data_threshold);
|
oc, st, &muxing_queue_data_threshold);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
sch_mux_stream_buffering(mux->sch, mux->sch_idx, ms->sch_idx,
|
sch_mux_stream_buffering(mux->sch, mux->sch_idx, ms->sch_idx,
|
||||||
max_muxing_queue_size, muxing_queue_data_threshold);
|
max_muxing_queue_size, muxing_queue_data_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->bits_per_raw_sample, oc, st,
|
opt_match_per_stream_int(ost, &o->bits_per_raw_sample, oc, st,
|
||||||
&ost->bits_per_raw_sample);
|
&ost->bits_per_raw_sample);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat,
|
opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat,
|
||||||
oc, st, &ost->fix_sub_duration_heartbeat);
|
oc, st, &ost->fix_sub_duration_heartbeat);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx)
|
if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx)
|
||||||
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||||
|
|
||||||
ret = opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes,
|
opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes,
|
||||||
oc, st, &ms->copy_initial_nonkeyframes);
|
oc, st, &ms->copy_initial_nonkeyframes);
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt, &vsync_method); break;
|
case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt, &vsync_method); break;
|
||||||
case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break;
|
case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break;
|
||||||
@@ -3036,9 +2943,7 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o)
|
|||||||
|
|
||||||
nb_streams[ost->type + 1]++;
|
nb_streams[ost->type + 1]++;
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->disposition, ctx, ost->st, &dispositions[i]);
|
opt_match_per_stream_str(ost, &o->disposition, ctx, ost->st, &dispositions[i]);
|
||||||
if (ret < 0)
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
have_manual |= !!dispositions[i];
|
have_manual |= !!dispositions[i];
|
||||||
|
|
||||||
@@ -3183,12 +3088,9 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
|
|||||||
for (int i = 0; i < mux->of.nb_streams; i++) {
|
for (int i = 0; i < mux->of.nb_streams; i++) {
|
||||||
OutputStream *ost = mux->of.streams[i];
|
OutputStream *ost = mux->of.streams[i];
|
||||||
const char *forced_keyframes = NULL;
|
const char *forced_keyframes = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = opt_match_per_stream_str(ost, &o->forced_key_frames,
|
opt_match_per_stream_str(ost, &o->forced_key_frames,
|
||||||
mux->fc, ost->st, &forced_keyframes);
|
mux->fc, ost->st, &forced_keyframes);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!(ost->type == AVMEDIA_TYPE_VIDEO &&
|
if (!(ost->type == AVMEDIA_TYPE_VIDEO &&
|
||||||
ost->enc_ctx && forced_keyframes))
|
ost->enc_ctx && forced_keyframes))
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ static void uninit_options(OptionsContext *o)
|
|||||||
SpecifierOptList *so = dst;
|
SpecifierOptList *so = dst;
|
||||||
for (int i = 0; i < so->nb_opt; i++) {
|
for (int i = 0; i < so->nb_opt; i++) {
|
||||||
av_freep(&so->opt[i].specifier);
|
av_freep(&so->opt[i].specifier);
|
||||||
|
if (po->flags & OPT_FLAG_PERSTREAM)
|
||||||
|
stream_specifier_uninit(&so->opt[i].stream_spec);
|
||||||
if (po->type == OPT_TYPE_STRING)
|
if (po->type == OPT_TYPE_STRING)
|
||||||
av_freep(&so->opt[i].u.str);
|
av_freep(&so->opt[i].u.str);
|
||||||
}
|
}
|
||||||
@@ -164,7 +166,7 @@ const char *opt_match_per_type_str(const SpecifierOptList *sol,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int opt_match_per_stream(void *logctx, enum OptionType type,
|
static unsigned opt_match_per_stream(void *logctx, enum OptionType type,
|
||||||
const SpecifierOptList *sol,
|
const SpecifierOptList *sol,
|
||||||
AVFormatContext *fc, AVStream *st)
|
AVFormatContext *fc, AVStream *st)
|
||||||
{
|
{
|
||||||
@@ -173,13 +175,12 @@ static int opt_match_per_stream(void *logctx, enum OptionType type,
|
|||||||
av_assert0((type == sol->type) || !sol->nb_opt);
|
av_assert0((type == sol->type) || !sol->nb_opt);
|
||||||
|
|
||||||
for (int i = 0; i < sol->nb_opt; i++) {
|
for (int i = 0; i < sol->nb_opt; i++) {
|
||||||
const char *spec = sol->opt[i].specifier;
|
const StreamSpecifier *ss = &sol->opt[i].stream_spec;
|
||||||
int ret = check_stream_specifier(fc, st, spec);
|
|
||||||
if (ret > 0) {
|
if (stream_specifier_match(ss, fc, st, logctx)) {
|
||||||
match_idx = i;
|
match_idx = i;
|
||||||
matches++;
|
matches++;
|
||||||
} else if (ret < 0)
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches > 1 && sol->opt_canon) {
|
if (matches > 1 && sol->opt_canon) {
|
||||||
@@ -216,17 +217,12 @@ static int opt_match_per_stream(void *logctx, enum OptionType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define OPT_MATCH_PER_STREAM(name, type, opt_type, m) \
|
#define OPT_MATCH_PER_STREAM(name, type, opt_type, m) \
|
||||||
int opt_match_per_stream_ ## name(void *logctx, const SpecifierOptList *sol, \
|
void opt_match_per_stream_ ## name(void *logctx, const SpecifierOptList *sol, \
|
||||||
AVFormatContext *fc, AVStream *st, type *out) \
|
AVFormatContext *fc, AVStream *st, type *out) \
|
||||||
{ \
|
{ \
|
||||||
int ret = opt_match_per_stream(logctx, opt_type, sol, fc, st); \
|
unsigned ret = opt_match_per_stream(logctx, opt_type, sol, fc, st); \
|
||||||
\
|
if (ret > 0) \
|
||||||
if (ret <= 0) \
|
|
||||||
return ret; \
|
|
||||||
\
|
|
||||||
*out = sol->opt[ret - 1].u.m; \
|
*out = sol->opt[ret - 1].u.m; \
|
||||||
\
|
|
||||||
return 0; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OPT_MATCH_PER_STREAM(str, const char *, OPT_TYPE_STRING, str);
|
OPT_MATCH_PER_STREAM(str, const char *, OPT_TYPE_STRING, str);
|
||||||
|
|||||||
Reference in New Issue
Block a user