History

ffplay: factorize code from video_thread() into configure_video_filters()

Stefano Sabatini committed 15 years ago

Commit 8904a0f1 parent 01b75fa1 file · +32 −19Browse files

Unified · Split

ffplay.c+32−19
@@ -1782,30 +1782,20 @@ static AVFilter input_filter = · 1781 unmodified lines
17821782 { .name = NULL }},
17831783 };
17841784
1785−#endif /* CONFIG_AVFILTER */
1786−
1787−static int video_thread(void *arg)
1785+static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
17881786 {
1789− VideoState *is = arg;
1790− AVFrame *frame= avcodec_alloc_frame();
1791− int64_t pts_int;
1792− double pts;
1793− int ret;
1794−
1795−#if CONFIG_AVFILTER
1796− int64_t pos;
17971787 char sws_flags_str[128];
1788+ int ret;
17981789 FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P };
17991790 AVFilterContext *filt_src = NULL, *filt_out = NULL;
1800− AVFilterGraph *graph = avfilter_graph_alloc();
18011791 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
18021792 graph->scale_sws_opts = av_strdup(sws_flags_str);
18031793
1804− if (avfilter_graph_create_filter(&filt_src, &input_filter, "src",
1805− NULL, is, graph) < 0)
1794+ if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
1795+ NULL, is, graph)) < 0)
18061796 goto the_end;
1807− if (avfilter_graph_create_filter(&filt_out, &ffsink, "out",
1808− NULL, &ffsink_ctx, graph) < 0)
1797+ if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out",
1798+ NULL, &ffsink_ctx, graph)) < 0)
18091799 goto the_end;
18101800
18111801 if(vfilters) {
@@ -1822,17 +1812,40 @@ static int video_thread(void *arg) · 10 unmodified lines
18221812 inputs->pad_idx = 0;
18231813 inputs->next = NULL;
18241814
1825− if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0)
1815+ if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
18261816 goto the_end;
18271817 av_freep(&vfilters);
18281818 } else {
1829− if(avfilter_link(filt_src, 0, filt_out, 0) < 0) goto the_end;
1819+ if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
1820+ goto the_end;
18301821 }
18311822
1832− if (avfilter_graph_config(graph, NULL) < 0)
1823+ if ((ret = avfilter_graph_config(graph, NULL)) < 0)
18331824 goto the_end;
18341825
18351826 is->out_video_filter = filt_out;
1827+the_end:
1828+ return ret;
1829+}
1830+
1831+#endif /* CONFIG_AVFILTER */
1832+
1833+static int video_thread(void *arg)
1834+{
1835+ VideoState *is = arg;
1836+ AVFrame *frame= avcodec_alloc_frame();
1837+ int64_t pts_int;
1838+ double pts;
1839+ int ret;
1840+
1841+#if CONFIG_AVFILTER
1842+ AVFilterGraph *graph = avfilter_graph_alloc();
1843+ AVFilterContext *filt_out = NULL;
1844+ int64_t pos;
1845+
1846+ if ((ret = configure_video_filters(graph, is, vfilters)) < 0)
1847+ goto the_end;
1848+ filt_out = is->out_video_filter;
18361849 #endif
18371850
18381851 for(;;) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t