]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
The fail test needs to be outside of the GPL test, it's referenced elsewhere.
[ffmpeg] / ffplay.c
index 8cffa8f704e6ad34191a109f15fdab200fdd4dcb..46638bdc5c25f2a3aa7f9cfe69d90af328474c74 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
  */
 #define HAVE_AV_CONFIG_H
 #include "avformat.h"
+#include "swscale.h"
 
+#include "version.h"
 #include "cmdutils.h"
 
 #include <SDL.h>
 #include <SDL_thread.h>
 
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
 #undef main /* We don't want SDL to override our main() */
 #endif
 
@@ -69,6 +71,8 @@
 /* NOTE: the size must be big enough to compensate the hardware audio buffersize size */
 #define SAMPLE_ARRAY_SIZE (2*65536)
 
+static int sws_flags = SWS_BICUBIC;
+
 typedef struct PacketQueue {
     AVPacketList *first_pkt, *last_pkt;
     int nb_packets;
@@ -1142,6 +1146,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts)
     VideoPicture *vp;
     int dst_pix_fmt;
     AVPicture pict;
+    static struct SwsContext *img_convert_ctx;
 
     /* wait until we have space to put a new picture */
     SDL_LockMutex(is->pictq_mutex);
@@ -1194,9 +1199,18 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts)
         pict.linesize[0] = vp->bmp->pitches[0];
         pict.linesize[1] = vp->bmp->pitches[2];
         pict.linesize[2] = vp->bmp->pitches[1];
-        img_convert(&pict, dst_pix_fmt,
-                    (AVPicture *)src_frame, is->video_st->codec->pix_fmt,
-                    is->video_st->codec->width, is->video_st->codec->height);
+        if (img_convert_ctx == NULL) {
+            img_convert_ctx = sws_getContext(is->video_st->codec->width,
+                    is->video_st->codec->height, is->video_st->codec->pix_fmt,
+                    is->video_st->codec->width, is->video_st->codec->height,
+                    dst_pix_fmt, sws_flags, NULL, NULL, NULL);
+            if (img_convert_ctx == NULL) {
+                fprintf(stderr, "Cannot initialize the conversion context\n");
+                exit(1);
+            }
+        }
+        sws_scale(img_convert_ctx, src_frame->data, src_frame->linesize,
+                  0, is->video_st->codec->height, pict.data, pict.linesize);
         /* update the bitmap content */
         SDL_UnlockYUVOverlay(vp->bmp);
 
@@ -1605,8 +1619,6 @@ static int stream_component_open(VideoState *is, int stream_index)
     codec = avcodec_find_decoder(enc->codec_id);
     enc->debug_mv = debug_mv;
     enc->debug = debug;
-    if(debug)
-        av_log_set_level(AV_LOG_DEBUG);
     enc->workaround_bugs = workaround_bugs;
     enc->lowres = lowres;
     if(lowres) enc->flags |= CODEC_FLAG_EMU_EDGE;
@@ -1791,7 +1803,7 @@ static int decode_thread(void *arg)
     }
     is->ic = ic;
 #ifdef CONFIG_NETWORK
-    use_play = (ic->iformat == &rtsp_demux);
+    use_play = (ic->iformat == &rtsp_demuxer);
 #else
     use_play = 0;
 #endif
@@ -1885,7 +1897,7 @@ static int decode_thread(void *arg)
             else
                 av_read_play(ic);
         }
-        if (is->paused && ic->iformat == &rtsp_demux) {
+        if (is->paused && ic->iformat == &rtsp_demuxer) {
             /* wait 10 ms to avoid trying to get another packet */
             /* XXX: horrible */
             SDL_Delay(10);
@@ -2318,6 +2330,7 @@ void opt_seek(const char *arg)
 
 static void opt_debug(const char *arg)
 {
+    av_log_set_level(99);
     debug = atoi(arg);
 }
 
@@ -2423,7 +2436,7 @@ int main(int argc, char **argv)
         video_disable = 1;
     }
     flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
-#if !defined(CONFIG_WIN32) && !defined(CONFIG_DARWIN)
+#if !defined(__MINGW32__) && !defined(CONFIG_DARWIN)
     flags |= SDL_INIT_EVENTTHREAD; /* Not supported on win32 or darwin */
 #endif
     if (SDL_Init (flags)) {