Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: source/patched-ffmpeg-mt/ffplay.c

Issue 4533003: patched ffmpeg nov 2 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * FFplay : Simple Media Player based on the FFmpeg libraries 2 * FFplay : Simple Media Player based on the FFmpeg libraries
3 * Copyright (c) 2003 Fabrice Bellard 3 * Copyright (c) 2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 return 0; 1748 return 0;
1749 } 1749 }
1750 1750
1751 static int input_config_props(AVFilterLink *link) 1751 static int input_config_props(AVFilterLink *link)
1752 { 1752 {
1753 FilterPriv *priv = link->src->priv; 1753 FilterPriv *priv = link->src->priv;
1754 AVCodecContext *c = priv->is->video_st->codec; 1754 AVCodecContext *c = priv->is->video_st->codec;
1755 1755
1756 link->w = c->width; 1756 link->w = c->width;
1757 link->h = c->height; 1757 link->h = c->height;
1758 link->time_base = priv->is->video_st->time_base;
1758 1759
1759 return 0; 1760 return 0;
1760 } 1761 }
1761 1762
1762 static AVFilter input_filter = 1763 static AVFilter input_filter =
1763 { 1764 {
1764 .name = "ffplay_input", 1765 .name = "ffplay_input",
1765 1766
1766 .priv_size = sizeof(FilterPriv), 1767 .priv_size = sizeof(FilterPriv),
1767 1768
1768 .init = input_init, 1769 .init = input_init,
1769 .uninit = input_uninit, 1770 .uninit = input_uninit,
1770 1771
1771 .query_formats = input_query_formats, 1772 .query_formats = input_query_formats,
1772 1773
1773 .inputs = (AVFilterPad[]) {{ .name = NULL }}, 1774 .inputs = (AVFilterPad[]) {{ .name = NULL }},
1774 .outputs = (AVFilterPad[]) {{ .name = "default", 1775 .outputs = (AVFilterPad[]) {{ .name = "default",
1775 .type = AVMEDIA_TYPE_VIDEO, 1776 .type = AVMEDIA_TYPE_VIDEO,
1776 .request_frame = input_request_frame, 1777 .request_frame = input_request_frame,
1777 .config_props = input_config_props, }, 1778 .config_props = input_config_props, },
1778 { .name = NULL }}, 1779 { .name = NULL }},
1779 }; 1780 };
1780 1781
1781 static void output_end_frame(AVFilterLink *link)
1782 {
1783 }
1784
1785 static int output_query_formats(AVFilterContext *ctx)
1786 {
1787 enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
1788
1789 avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
1790 return 0;
1791 }
1792
1793 static int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
1794 int64_t *pts, int64_t *pos)
1795 {
1796 AVFilterBufferRef *pic;
1797
1798 if(avfilter_request_frame(ctx->inputs[0]))
1799 return -1;
1800 if(!(pic = ctx->inputs[0]->cur_buf))
1801 return -1;
1802 ctx->inputs[0]->cur_buf = NULL;
1803
1804 frame->opaque = pic;
1805 *pts = pic->pts;
1806 *pos = pic->pos;
1807
1808 memcpy(frame->data, pic->data, sizeof(frame->data));
1809 memcpy(frame->linesize, pic->linesize, sizeof(frame->linesize));
1810
1811 return 1;
1812 }
1813
1814 static AVFilter output_filter =
1815 {
1816 .name = "ffplay_output",
1817
1818 .query_formats = output_query_formats,
1819
1820 .inputs = (AVFilterPad[]) {{ .name = "default",
1821 .type = AVMEDIA_TYPE_VIDEO,
1822 .end_frame = output_end_frame,
1823 .min_perms = AV_PERM_READ, },
1824 { .name = NULL }},
1825 .outputs = (AVFilterPad[]) {{ .name = NULL }},
1826 };
1827 #endif /* CONFIG_AVFILTER */ 1782 #endif /* CONFIG_AVFILTER */
1828 1783
1829 static int video_thread(void *arg) 1784 static int video_thread(void *arg)
1830 { 1785 {
1831 VideoState *is = arg; 1786 VideoState *is = arg;
1832 AVFrame *frame= avcodec_alloc_frame(); 1787 AVFrame *frame= avcodec_alloc_frame();
1833 int64_t pts_int; 1788 int64_t pts_int;
1834 double pts; 1789 double pts;
1835 int ret; 1790 int ret;
1836 1791
1837 #if CONFIG_AVFILTER 1792 #if CONFIG_AVFILTER
1838 int64_t pos; 1793 int64_t pos;
1839 char sws_flags_str[128]; 1794 char sws_flags_str[128];
1795 FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P };
1840 AVFilterContext *filt_src = NULL, *filt_out = NULL; 1796 AVFilterContext *filt_src = NULL, *filt_out = NULL;
1841 AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); 1797 AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph));
1842 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); 1798 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
1843 graph->scale_sws_opts = av_strdup(sws_flags_str); 1799 graph->scale_sws_opts = av_strdup(sws_flags_str);
1844 1800
1845 if (avfilter_open(&filt_src, &input_filter, "src") < 0) goto the_end; 1801 if (avfilter_open(&filt_src, &input_filter, "src") < 0) goto the_end;
1846 if (avfilter_open(&filt_out, &output_filter, "out") < 0) goto the_end; 1802 if (avfilter_open(&filt_out, &ffsink , "out") < 0) goto the_end;
1847 1803
1848 if(avfilter_init_filter(filt_src, NULL, is)) goto the_end; 1804 if(avfilter_init_filter(filt_src, NULL, is)) goto the_end;
1849 if(avfilter_init_filter(filt_out, NULL, frame)) goto the_end; 1805 if(avfilter_init_filter(filt_out, NULL, &ffsink_ctx)) goto the_end;
1850 1806
1851 1807
1852 if(vfilters) { 1808 if(vfilters) {
1853 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); 1809 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
1854 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); 1810 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));
1855 1811
1856 outputs->name = av_strdup("in"); 1812 outputs->name = av_strdup("in");
1857 outputs->filter = filt_src; 1813 outputs->filter = filt_src;
1858 outputs->pad_idx = 0; 1814 outputs->pad_idx = 0;
1859 outputs->next = NULL; 1815 outputs->next = NULL;
1860 1816
1861 inputs->name = av_strdup("out"); 1817 inputs->name = av_strdup("out");
1862 inputs->filter = filt_out; 1818 inputs->filter = filt_out;
1863 inputs->pad_idx = 0; 1819 inputs->pad_idx = 0;
1864 inputs->next = NULL; 1820 inputs->next = NULL;
1865 1821
1866 if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0) 1822 if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0)
1867 goto the_end; 1823 goto the_end;
1868 av_freep(&vfilters); 1824 av_freep(&vfilters);
1869 } else { 1825 } else {
1870 if(avfilter_link(filt_src, 0, filt_out, 0) < 0) goto the_end; 1826 if(avfilter_link(filt_src, 0, filt_out, 0) < 0) goto the_end;
1871 } 1827 }
1872 avfilter_graph_add_filter(graph, filt_src); 1828 avfilter_graph_add_filter(graph, filt_src);
1873 avfilter_graph_add_filter(graph, filt_out); 1829 avfilter_graph_add_filter(graph, filt_out);
1874 1830
1875 if(avfilter_graph_check_validity(graph, NULL)) goto the_end; 1831 if (avfilter_graph_config(graph, NULL) < 0)
1876 if(avfilter_graph_config_formats(graph, NULL)) goto the_end; 1832 goto the_end;
1877 if(avfilter_graph_config_links(graph, NULL)) goto the_end;
1878 1833
1879 is->out_video_filter = filt_out; 1834 is->out_video_filter = filt_out;
1880 #endif 1835 #endif
1881 1836
1882 for(;;) { 1837 for(;;) {
1883 #if !CONFIG_AVFILTER 1838 #if !CONFIG_AVFILTER
1884 AVPacket pkt; 1839 AVPacket pkt;
1840 #else
1841 AVFilterBufferRef *picref;
1842 AVRational tb;
1885 #endif 1843 #endif
1886 while (is->paused && !is->videoq.abort_request) 1844 while (is->paused && !is->videoq.abort_request)
1887 SDL_Delay(10); 1845 SDL_Delay(10);
1888 #if CONFIG_AVFILTER 1846 #if CONFIG_AVFILTER
1889 ret = get_filtered_video_frame(filt_out, frame, &pts_int, &pos); 1847 ret = get_filtered_video_frame(filt_out, frame, &picref, &tb);
1848 if (picref) {
1849 pts_int = picref->pts;
1850 pos = picref->pos;
1851 frame->opaque = picref;
1852 }
1853
1854 if (av_cmp_q(tb, is->video_st->time_base)) {
1855 int64_t pts1 = pts_int;
1856 pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base);
1857 av_log(NULL, AV_LOG_DEBUG, "video_thread(): "
1858 "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
1859 tb.num, tb.den, pts1,
1860 is->video_st->time_base.num, is->video_st->time_base.den, pts _int);
1861 }
1890 #else 1862 #else
1891 ret = get_video_frame(is, frame, &pts_int, &pkt); 1863 ret = get_video_frame(is, frame, &pts_int, &pkt);
1892 #endif 1864 #endif
1893 1865
1894 if (ret < 0) goto the_end; 1866 if (ret < 0) goto the_end;
1895 1867
1896 if (!ret) 1868 if (!ret)
1897 continue; 1869 continue;
1898 1870
1899 pts = pts_int*av_q2d(is->video_st->time_base); 1871 pts = pts_int*av_q2d(is->video_st->time_base);
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 flush_pkt.data= "FLUSH"; 3163 flush_pkt.data= "FLUSH";
3192 3164
3193 cur_stream = stream_open(input_filename, file_iformat); 3165 cur_stream = stream_open(input_filename, file_iformat);
3194 3166
3195 event_loop(); 3167 event_loop();
3196 3168
3197 /* never returns */ 3169 /* never returns */
3198 3170
3199 return 0; 3171 return 0;
3200 } 3172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698