]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
Remove redundant swScaler: output from places where av_log()
[ffmpeg] / ffplay.c
index 37282d3277320dc6cdea2cd42d20d4eaea20a397..acb729a22e5aed09ebb7c91674241d10bc2118e3 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
@@ -22,6 +22,7 @@
 #include <math.h>
 #include <limits.h>
 #include "avformat.h"
+#include "avdevice.h"
 #include "rtsp.h"
 #include "swscale.h"
 #include "avstring.h"
@@ -656,7 +657,7 @@ static void video_image_display(VideoState *is)
             aspect_ratio = 0;
         else
             aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio)
-                * is->video_st->codec->width / is->video_st->codec->height;;
+                * is->video_st->codec->width / is->video_st->codec->height;
         if (aspect_ratio <= 0.0)
             aspect_ratio = (float)is->video_st->codec->width /
                 (float)is->video_st->codec->height;
@@ -1692,21 +1693,11 @@ static int stream_component_open(VideoState *is, int stream_index)
 
     /* prepare audio output */
     if (enc->codec_type == CODEC_TYPE_AUDIO) {
-        wanted_spec.freq = enc->sample_rate;
-        wanted_spec.format = AUDIO_S16SYS;
-        /* hack for AC3. XXX: suppress that */
-        if (enc->channels > 2)
-            enc->channels = 2;
-        wanted_spec.channels = enc->channels;
-        wanted_spec.silence = 0;
-        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
-        wanted_spec.callback = sdl_audio_callback;
-        wanted_spec.userdata = is;
-        if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
-            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
-            return -1;
+        if (enc->channels > 0) {
+            enc->request_channels = FFMIN(2, enc->channels);
+        } else {
+            enc->request_channels = 2;
         }
-        is->audio_hw_buf_size = spec.size;
     }
 
     codec = avcodec_find_decoder(enc->codec_id);
@@ -1725,6 +1716,23 @@ static int stream_component_open(VideoState *is, int stream_index)
     if (!codec ||
         avcodec_open(enc, codec) < 0)
         return -1;
+
+    /* prepare audio output */
+    if (enc->codec_type == CODEC_TYPE_AUDIO) {
+        wanted_spec.freq = enc->sample_rate;
+        wanted_spec.format = AUDIO_S16SYS;
+        wanted_spec.channels = enc->channels;
+        wanted_spec.silence = 0;
+        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
+        wanted_spec.callback = sdl_audio_callback;
+        wanted_spec.userdata = is;
+        if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
+            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
+            return -1;
+        }
+        is->audio_hw_buf_size = spec.size;
+    }
+
     if(thread_count>1)
         avcodec_thread_init(enc, thread_count);
     enc->thread_count= thread_count;
@@ -2358,20 +2366,12 @@ static void opt_frame_size(const char *arg)
 
 static void opt_width(const char *arg)
 {
-    screen_width = atoi(arg);
-    if(screen_width<=0){
-        fprintf(stderr, "invalid width\n");
-        exit(1);
-    }
+    screen_width = parse_number_or_die("x", arg, OPT_INT64, 1, INT_MAX);
 }
 
 static void opt_height(const char *arg)
 {
-    screen_height = atoi(arg);
-    if(screen_height<=0){
-        fprintf(stderr, "invalid height\n");
-        exit(1);
-    }
+    screen_height = parse_number_or_die("y", arg, OPT_INT64, 1, INT_MAX);
 }
 
 static void opt_format(const char *arg)
@@ -2388,14 +2388,6 @@ static void opt_frame_pix_fmt(const char *arg)
     frame_pix_fmt = avcodec_get_pix_fmt(arg);
 }
 
-#ifdef CONFIG_RTSP_DEMUXER
-static void opt_rtp_tcp(void)
-{
-    /* only tcp protocol */
-    rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_TCP);
-}
-#endif
-
 static void opt_sync(const char *arg)
 {
     if (!strcmp(arg, "audio"))
@@ -2421,18 +2413,18 @@ static void opt_seek(const char *arg)
 
 static void opt_debug(const char *arg)
 {
-    av_log_level = 99;
-    debug = atoi(arg);
+    av_log_set_level(99);
+    debug = parse_number_or_die("debug", arg, OPT_INT64, 0, INT_MAX);
 }
 
 static void opt_vismv(const char *arg)
 {
-    debug_mv = atoi(arg);
+    debug_mv = parse_number_or_die("vismv", arg, OPT_INT64, INT_MIN, INT_MAX);
 }
 
 static void opt_thread_count(const char *arg)
 {
-    thread_count= atoi(arg);
+    thread_count= parse_number_or_die("threads", arg, OPT_INT64, 0, INT_MAX);
 #if !defined(HAVE_THREADS)
     fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
 #endif
@@ -2473,9 +2465,6 @@ const OptionDef options[] = {
     { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&idct}, "set idct algo",  "algo" },
     { "er", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_resilience}, "set error detection threshold (0-4)",  "threshold" },
     { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_concealment}, "set error concealment options",  "bit_mask" },
-#ifdef CONFIG_RTSP_DEMUXER
-    { "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" },
     { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
     { NULL, },
@@ -2517,6 +2506,8 @@ int main(int argc, char **argv)
     int flags;
 
     /* register all codecs, demux and protocols */
+    avcodec_register_all();
+    avdevice_register_all();
     av_register_all();
 
     show_banner(program_name, program_birth_year);