Unified · Split
| @@ -1782,30 +1782,20 @@ static AVFilter input_filter = · 1781 unmodified lines | |||
| 1782 | { .name = NULL }}, | 1782 | { .name = NULL }}, |
| 1783 | }; | 1783 | }; |
| 1784 | 1784 | ||
| 1785 | #endif /* CONFIG_AVFILTER */ | 1785 | static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters) |
| 1786 | |||
| 1787 | static int video_thread(void *arg) | ||
| 1788 | { | 1786 | { |
| 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; | ||
| 1797 | char sws_flags_str[128]; | 1787 | char sws_flags_str[128]; |
| 1788 | int ret; | ||
| 1798 | FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P }; | 1789 | FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P }; |
| 1799 | AVFilterContext *filt_src = NULL, *filt_out = NULL; | 1790 | AVFilterContext *filt_src = NULL, *filt_out = NULL; |
| 1800 | AVFilterGraph *graph = avfilter_graph_alloc(); | ||
| 1801 | snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); | 1791 | snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); |
| 1802 | graph->scale_sws_opts = av_strdup(sws_flags_str); | 1792 | graph->scale_sws_opts = av_strdup(sws_flags_str); |
| 1803 | 1793 | ||
| 1804 | if (avfilter_graph_create_filter(&filt_src, &input_filter, "src", | 1794 | if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src", |
| 1805 | NULL, is, graph) < 0) | 1795 | NULL, is, graph)) < 0) |
| 1806 | goto the_end; | 1796 | goto the_end; |
| 1807 | if (avfilter_graph_create_filter(&filt_out, &ffsink, "out", | 1797 | if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out", |
| 1808 | NULL, &ffsink_ctx, graph) < 0) | 1798 | NULL, &ffsink_ctx, graph)) < 0) |
| 1809 | goto the_end; | 1799 | goto the_end; |
| 1810 | 1800 | ||
| 1811 | if(vfilters) { | 1801 | if(vfilters) { |
| @@ -1822,17 +1812,40 @@ static int video_thread(void *arg) · 10 unmodified lines | |||
| 1822 | inputs->pad_idx = 0; | 1812 | inputs->pad_idx = 0; |
| 1823 | inputs->next = NULL; | 1813 | inputs->next = NULL; |
| 1824 | 1814 | ||
| 1825 | if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0) | 1815 | if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0) |
| 1826 | goto the_end; | 1816 | goto the_end; |
| 1827 | av_freep(&vfilters); | 1817 | av_freep(&vfilters); |
| 1828 | } else { | 1818 | } 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; | ||
| 1830 | } | 1821 | } |
| 1831 | 1822 | ||
| 1832 | if (avfilter_graph_config(graph, NULL) < 0) | 1823 | if ((ret = avfilter_graph_config(graph, NULL)) < 0) |
| 1833 | goto the_end; | 1824 | goto the_end; |
| 1834 | 1825 | ||
| 1835 | is->out_video_filter = filt_out; | 1826 | 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; | ||
| 1836 | #endif | 1849 | #endif |
| 1837 | 1850 | ||
| 1838 | for(;;) { | 1851 | for(;;) { |