@@ -1861,7 +1861,6 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
{
enum AVPixelFormat pix_fmts[FF_ARRAY_ELEMS(sdl_texture_format_map)];
char sws_flags_str[512] = "";
- char buffersrc_args[256];
int ret;
AVFilterContext *filt_src = NULL, *filt_out = NULL, *last_filter = NULL;
AVCodecParameters *codecpar = is->video_st->codecpar;
@@ -1895,38 +1894,48 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
graph->scale_sws_opts = av_strdup(sws_flags_str);
- snprintf(buffersrc_args, sizeof(buffersrc_args),
- "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d:"
- "colorspace=%d:range=%d",
- frame->width, frame->height, frame->format,
- is->video_st->time_base.num, is->video_st->time_base.den,
- codecpar->sample_aspect_ratio.num, FFMAX(codecpar->sample_aspect_ratio.den, 1),
- frame->colorspace, frame->color_range);
- if (fr.num && fr.den)
- av_strlcatf(buffersrc_args, sizeof(buffersrc_args), ":frame_rate=%d/%d", fr.num, fr.den);
- if ((ret = avfilter_graph_create_filter(&filt_src,
- avfilter_get_by_name("buffer"),
- "ffplay_buffer", buffersrc_args, NULL,
- graph)) < 0)
+ filt_src = avfilter_graph_alloc_filter(graph, avfilter_get_by_name("buffer"),
+ "ffplay_buffer");
+ if (!filt_src) {
+ ret = AVERROR(ENOMEM);
goto fail;
+ }
+
+ par->format = frame->format;
+ par->time_base = is->video_st->time_base;
+ par->width = frame->width;
+ par->height = frame->height;
+ par->sample_aspect_ratio = codecpar->sample_aspect_ratio;
+ par->color_space = frame->colorspace;
+ par->color_range = frame->color_range;
+ par->frame_rate = fr;
par->hw_frames_ctx = frame->hw_frames_ctx;
ret = av_buffersrc_parameters_set(filt_src, par);
if (ret < 0)
goto fail;
- ret = avfilter_graph_create_filter(&filt_out,
- avfilter_get_by_name("buffersink"),
- "ffplay_buffersink", NULL, NULL, graph);
+ ret = avfilter_init_dict(filt_src, NULL);
if (ret < 0)
goto fail;
+ filt_out = avfilter_graph_alloc_filter(graph, avfilter_get_by_name("buffersink"),
+ "ffplay_buffersink");
+ if (!filt_out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0)
goto fail;
if (!vk_renderer &&
(ret = av_opt_set_int_list(filt_out, "color_spaces", sdl_supported_color_spaces, AVCOL_SPC_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0)
goto fail;
+ ret = avfilter_init_dict(filt_out, NULL);
+ if (ret < 0)
+ goto fail;
+
last_filter = filt_out;
/* Note: this macro adds a filter before the lastly added filter, so the
@@ -2029,12 +2038,12 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for
if (ret < 0)
goto end;
-
- ret = avfilter_graph_create_filter(&filt_asink,
- avfilter_get_by_name("abuffersink"), "ffplay_abuffersink",
- NULL, NULL, is->agraph);
- if (ret < 0)
+ filt_asink = avfilter_graph_alloc_filter(is->agraph, avfilter_get_by_name("abuffersink"),
+ "ffplay_abuffersink");
+ if (!filt_asink) {
+ ret = AVERROR(ENOMEM);
goto end;
+ }
if ((ret = av_opt_set_int_list(filt_asink, "sample_fmts", sample_fmts, AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0)
goto end;
@@ -2053,6 +2062,9 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for
goto end;
}
+ ret = avfilter_init_dict(filt_asink, NULL);
+ if (ret < 0)
+ goto end;
if ((ret = configure_filtergraph(is->agraph, afilters, filt_asrc, filt_asink)) < 0)
goto end;