]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
10l fixes by ("Debabrata Banerjee" <davatar at comcast dot net>)
[ffmpeg] / ffplay.c
index 6fbb91e1583e47d1a4c939d011b5827dd7f2975c..9035c51ecbba08abc137c17e174c5bbbea0344e2 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
@@ -168,6 +168,8 @@ static int64_t start_time = AV_NOPTS_VALUE;
 static int debug = 0;
 static int debug_mv = 0;
 static int step = 0;
+static int thread_count = 1;
+static int workaround_bugs = 1;
 
 /* current context */
 static int is_full_screen;
@@ -913,8 +915,8 @@ static int video_thread(void *arg)
             len1 = avcodec_decode_video(&is->video_st->codec, 
                                         frame, &got_picture, 
                                         pkt->data, pkt->size);
-            if (len1 < 0)
-                break;
+//            if (len1 < 0)
+//                break;
             if (got_picture) {
                 if (output_picture2(is, frame, pts) < 0)
                     goto the_end;
@@ -1166,9 +1168,17 @@ 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;
+    enc->workaround_bugs = workaround_bugs;
     if (!codec ||
         avcodec_open(enc, codec) < 0)
         return -1;
+#if defined(HAVE_PTHREADS) || defined(HAVE_W32THREADS)
+    if(thread_count>1)
+        avcodec_thread_init(enc, thread_count);
+#endif
+    enc->thread_count= thread_count;
     switch(enc->codec_type) {
     case CODEC_TYPE_AUDIO:
         is->audio_stream = stream_index;
@@ -1197,8 +1207,6 @@ static int stream_component_open(VideoState *is, int stream_index)
 
         packet_queue_init(&is->videoq);
         is->video_tid = SDL_CreateThread(video_thread, is);
-        enc->debug = debug;
-        enc->debug_mv = debug_mv;
         break;
     default:
         break;
@@ -1415,6 +1423,7 @@ static int decode_thread(void *arg)
                 }
                 if (is->video_stream >= 0) {
                     packet_queue_flush(&is->videoq);
+                    avcodec_flush_buffers(&ic->streams[video_index]->codec);
                 }
             }
             is->seek_req = 0;
@@ -1422,7 +1431,8 @@ static int decode_thread(void *arg)
 
         /* if the queue are full, no need to read more */
         if (is->audioq.size > MAX_AUDIOQ_SIZE ||
-            is->videoq.size > MAX_VIDEOQ_SIZE) {
+            is->videoq.size > MAX_VIDEOQ_SIZE || 
+            url_feof(&ic->pb)) {
             /* wait 10 ms */
             SDL_Delay(10);
             continue;
@@ -1791,6 +1801,14 @@ static void opt_vismv(const char *arg)
 {
     debug_mv = atoi(arg);
 }
+
+static void opt_thread_count(const char *arg)
+{
+    thread_count= atoi(arg);
+#if !defined(HAVE_PTHREADS) && !defined(HAVE_W32THREADS)
+    fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
+#endif
+}
     
 const OptionDef options[] = {
     { "h", 0, {(void*)show_help}, "show help" },    
@@ -1808,11 +1826,13 @@ const OptionDef options[] = {
     { "img", HAS_ARG, {(void*)opt_image_format}, "force image format", "img_fmt" },
     { "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
     { "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
+    { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
     { "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
 #ifdef CONFIG_NETWORK
     { "rtp_tcp", OPT_EXPERT, {(void*)&opt_rtp_tcp}, "force RTP/TCP protocol usage", "" },
 #endif
-    { "sync", HAS_ARG | OPT_EXPERT, {(void*)&opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
+    { "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
+    { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
     { NULL, },
 };