Commit 3b3ea346 authored by Anton Khirnov's avatar Anton Khirnov

Remove all uses of deprecated AVOptions API.

parent 8c5dcaad
......@@ -224,7 +224,7 @@ typedef struct OutputStream {
AVFilterGraph *graph;
#endif
int sws_flags;
int64_t sws_flags;
AVDictionary *opts;
int is_past_recording_time;
} OutputStream;
......@@ -421,7 +421,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
snprintf(args, 255, "%d:%d:flags=0x%X",
codec->width,
codec->height,
ost->sws_flags);
(unsigned)ost->sws_flags);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
NULL, args, NULL, ost->graph)) < 0)
return ret;
......@@ -430,7 +430,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
last_filter = filter;
}
snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags);
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
ost->graph->scale_sws_opts = av_strdup(args);
if (ost->avfilter) {
......@@ -3033,7 +3033,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags);
return ost;
}
......
......@@ -3938,7 +3938,7 @@ static int avserver_opt_default(const char *opt, const char *arg,
int ret = 0;
const AVOption *o = av_opt_find(avctx, opt, NULL, type, 0);
if(o)
ret = av_set_string3(avctx, opt, arg, 1, NULL);
ret = av_opt_set(avctx, opt, arg, 0);
return ret;
}
......
......@@ -361,7 +361,7 @@ int opt_default(const char *opt, const char *arg)
av_dict_set(&format_opts, opt, arg, FLAGS);
else if ((o = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
// XXX we only support sws_flags, not arbitrary sws options
int ret = av_set_string3(sws_opts, opt, arg, 1, NULL);
int ret = av_opt_set(sws_opts, opt, arg, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
return ret;
......
......@@ -350,8 +350,8 @@ static int open_input(struct variant *var)
snprintf(url, sizeof(url), "crypto:%s", seg->url);
if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ)) < 0)
return ret;
av_set_string3(var->input->priv_data, "key", key, 0, NULL);
av_set_string3(var->input->priv_data, "iv", iv, 0, NULL);
av_opt_set(var->input->priv_data, "key", key, 0);
av_opt_set(var->input->priv_data, "iv", iv, 0);
if ((ret = ffurl_connect(var->input)) < 0) {
ffurl_close(var->input);
var->input = NULL;
......
......@@ -97,9 +97,9 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
/* Was the payload type already specified for the RTP muxer? */
if (ofmt && ofmt->priv_class) {
int payload_type = av_get_int(fmt->priv_data, "payload_type", NULL);
if (payload_type >= 0)
return payload_type;
int64_t payload_type;
if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0)
return (int)payload_type;
}
/* static payload type */
......
......@@ -31,6 +31,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
AVFormatContext *rtpctx;
int ret;
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
uint8_t *rtpflags;
AVDictionary *opts = NULL;
if (!rtp_format)
return NULL;
......@@ -50,12 +52,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
/* Copy other stream parameters. */
rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio;
av_set_parameters(rtpctx, NULL);
/* Copy the rtpflags values straight through */
if (s->oformat->priv_class &&
av_find_opt(s->priv_data, "rtpflags", NULL, 0, 0))
av_set_int(rtpctx->priv_data, "rtpflags",
av_get_int(s->priv_data, "rtpflags", NULL));
if (av_opt_get(s, "rtpflags", AV_OPT_SEARCH_CHILDREN, &rtpflags) >= 0)
av_dict_set(&opts, "rtpflags", rtpflags, AV_DICT_DONT_STRDUP_VAL);
/* Set the synchronized start time. */
rtpctx->start_time_realtime = s->start_time_realtime;
......@@ -66,7 +64,8 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
ffio_fdopen(&rtpctx->pb, handle);
} else
ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size);
ret = avformat_write_header(rtpctx, NULL);
ret = avformat_write_header(rtpctx, &opts);
av_dict_free(&opts);
if (ret) {
if (handle) {
......
......@@ -500,12 +500,14 @@ int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
{
const AVOption *field = av_find_opt(obj, field_name, NULL, 0, 0);
const AVOption *flag = av_find_opt(obj, flag_name, NULL, 0, 0);
const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
const AVOption *flag = av_opt_find(obj, flag_name, NULL, 0, 0);
int64_t res;
if (!field || !flag || flag->type != FF_OPT_TYPE_CONST)
if (!field || !flag || flag->type != FF_OPT_TYPE_CONST ||
av_opt_get_int(obj, field_name, 0, &res) < 0)
return 0;
return av_get_int(obj, field_name, NULL) & (int) flag->default_val.dbl;
return res & (int) flag->default_val.dbl;
}
static void opt_list(void *obj, void *av_log_obj, const char *unit,
......@@ -513,7 +515,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
{
const AVOption *opt=NULL;
while ((opt= av_next_option(obj, opt))) {
while ((opt = av_opt_next(obj, opt))) {
if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
continue;
......@@ -599,7 +601,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
{
#endif
const AVOption *opt = NULL;
while ((opt = av_next_option(s, opt)) != NULL) {
while ((opt = av_opt_next(s, opt)) != NULL) {
#if FF_API_OLD_AVOPTIONS
if ((opt->flags & mask) != flags)
continue;
......@@ -612,29 +614,29 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
case FF_OPT_TYPE_INT: {
int val;
val = opt->default_val.dbl;
av_set_int(s, opt->name, val);
av_opt_set_int(s, opt->name, val, 0);
}
break;
case FF_OPT_TYPE_INT64:
if ((double)(opt->default_val.dbl+0.6) == opt->default_val.dbl)
av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name);
av_set_int(s, opt->name, opt->default_val.dbl);
av_opt_set_int(s, opt->name, opt->default_val.dbl, 0);
break;
case FF_OPT_TYPE_DOUBLE:
case FF_OPT_TYPE_FLOAT: {
double val;
val = opt->default_val.dbl;
av_set_double(s, opt->name, val);
av_opt_set_double(s, opt->name, val, 0);
}
break;
case FF_OPT_TYPE_RATIONAL: {
AVRational val;
val = av_d2q(opt->default_val.dbl, INT_MAX);
av_set_q(s, opt->name, val);
av_opt_set_q(s, opt->name, val, 0);
}
break;
case FF_OPT_TYPE_STRING:
av_set_string3(s, opt->name, opt->default_val.str, 1, NULL);
av_opt_set(s, opt->name, opt->default_val.str, 0);
break;
case FF_OPT_TYPE_BINARY:
/* Cannot set default for binary */
......@@ -659,7 +661,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
* set, or a negative value corresponding to an AVERROR code in case
* of error:
* AVERROR(EINVAL) if the key/value pair cannot be parsed,
* the error code issued by av_set_string3() if the key/value pair
* the error code issued by av_opt_set() if the key/value pair
* cannot be set
*/
static int parse_key_value_pair(void *ctx, const char **buf,
......@@ -680,7 +682,7 @@ static int parse_key_value_pair(void *ctx, const char **buf,
av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key);
ret = av_set_string3(ctx, key, val, 1, NULL);
ret = av_opt_set(ctx, key, val, 0);
if (ret == AVERROR_OPTION_NOT_FOUND)
av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key);
......@@ -709,7 +711,7 @@ int av_set_options_string(void *ctx, const char *opts,
void av_opt_free(void *obj)
{
const AVOption *o = NULL;
while ((o = av_next_option(obj, o)))
while ((o = av_opt_next(obj, o)))
if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY)
av_freep((uint8_t *)obj + o->offset);
}
......@@ -721,7 +723,7 @@ int av_opt_set_dict(void *obj, AVDictionary **options)
int ret = 0;
while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {
ret = av_set_string3(obj, t->key, t->value, 1, NULL);
ret = av_opt_set(obj, t->key, t->value, 0);
if (ret == AVERROR_OPTION_NOT_FOUND)
av_dict_set(&tmp, t->key, t->value, 0);
else if (ret < 0) {
......@@ -761,7 +763,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
}
}
while (o = av_next_option(obj, o)) {
while (o = av_opt_next(obj, o)) {
if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags &&
((!unit && o->type != FF_OPT_TYPE_CONST) ||
(unit && o->unit && !strcmp(o->unit, unit)))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment