Browse code

ffplay: only configure video filters after we got the first frame

Otherwise the codec width, height and pixel format values may not be set.

Signed-off-by: Marton Balint <cus@passwd.hu>

Marton Balint authored on 2012/06/08 07:16:49
Showing 1 changed files
... ...
@@ -1625,13 +1625,6 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
1625 1625
     is->in_video_filter  = filt_src;
1626 1626
     is->out_video_filter = filt_out;
1627 1627
 
1628
-    if (codec->codec->capabilities & CODEC_CAP_DR1) {
1629
-        is->use_dr1 = 1;
1630
-        codec->get_buffer     = codec_get_buffer;
1631
-        codec->release_buffer = codec_release_buffer;
1632
-        codec->opaque         = &is->buffer_pool;
1633
-    }
1634
-
1635 1628
     return ret;
1636 1629
 }
1637 1630
 
... ...
@@ -1646,28 +1639,26 @@ static int video_thread(void *arg)
1646 1646
     int ret;
1647 1647
 
1648 1648
 #if CONFIG_AVFILTER
1649
+    AVCodecContext *codec = is->video_st->codec;
1649 1650
     AVFilterGraph *graph = avfilter_graph_alloc();
1650 1651
     AVFilterContext *filt_out = NULL, *filt_in = NULL;
1651
-    int last_w = is->video_st->codec->width;
1652
-    int last_h = is->video_st->codec->height;
1653
-    enum PixelFormat last_format = is->video_st->codec->pix_fmt;
1652
+    int last_w = 0;
1653
+    int last_h = 0;
1654
+    enum PixelFormat last_format = -2;
1654 1655
 
1655
-    if ((ret = configure_video_filters(graph, is, vfilters)) < 0) {
1656
-        SDL_Event event;
1657
-        event.type = FF_QUIT_EVENT;
1658
-        event.user.data1 = is;
1659
-        SDL_PushEvent(&event);
1660
-        goto the_end;
1656
+    if (codec->codec->capabilities & CODEC_CAP_DR1) {
1657
+        is->use_dr1 = 1;
1658
+        codec->get_buffer     = codec_get_buffer;
1659
+        codec->release_buffer = codec_release_buffer;
1660
+        codec->opaque         = &is->buffer_pool;
1661 1661
     }
1662
-    filt_in  = is->in_video_filter;
1663
-    filt_out = is->out_video_filter;
1664 1662
 #endif
1665 1663
 
1666 1664
     for (;;) {
1667 1665
         AVPacket pkt;
1668 1666
 #if CONFIG_AVFILTER
1669 1667
         AVFilterBufferRef *picref;
1670
-        AVRational tb = filt_out->inputs[0]->time_base;
1668
+        AVRational tb;
1671 1669
 #endif
1672 1670
         while (is->paused && !is->videoq.abort_request)
1673 1671
             SDL_Delay(10);
... ...
@@ -1691,6 +1682,10 @@ static int video_thread(void *arg)
1691 1691
             avfilter_graph_free(&graph);
1692 1692
             graph = avfilter_graph_alloc();
1693 1693
             if ((ret = configure_video_filters(graph, is, vfilters)) < 0) {
1694
+                SDL_Event event;
1695
+                event.type = FF_QUIT_EVENT;
1696
+                event.user.data1 = is;
1697
+                SDL_PushEvent(&event);
1694 1698
                 av_free_packet(&pkt);
1695 1699
                 goto the_end;
1696 1700
             }