]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
Move *_static to bitstream.c which is the only file left which needs
[ffmpeg] / ffplay.c
index 1cfb54d9766f610e3207bcf4800cc90a7532383d..e6c2e7fe5c99b693cb624e1c509e65f41bbe5c4f 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
 
 #include <math.h>
 #include <limits.h>
-#include "avformat.h"
-#include "avdevice.h"
-#include "rtsp.h"
-#include "swscale.h"
-#include "avstring.h"
+#include "libavutil/avstring.h"
+#include "libavformat/avformat.h"
+#include "libavformat/rtsp.h"
+#include "libavdevice/avdevice.h"
+#include "libswscale/swscale.h"
 
-#include "version.h"
 #include "cmdutils.h"
 
 #include <SDL.h>
@@ -39,8 +38,8 @@
 
 #undef exit
 
-static const char program_name[] = "FFplay";
-static const int program_birth_year = 2003;
+const char program_name[] = "FFplay";
+const int program_birth_year = 2003;
 
 //#define DEBUG_SYNC
 
@@ -169,7 +168,7 @@ typedef struct VideoState {
     int width, height, xleft, ytop;
 } VideoState;
 
-void show_help(void);
+static void show_help(void);
 static int audio_write_get_buf_size(VideoState *is);
 
 /* options specified by the user */
@@ -657,7 +656,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;
@@ -1645,7 +1644,7 @@ static int audio_write_get_buf_size(VideoState *is)
 
 
 /* prepare a new audio buffer */
-void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
+static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
 {
     VideoState *is = opaque;
     int audio_size, len1;
@@ -2364,22 +2363,16 @@ static void opt_frame_size(const char *arg)
     }
 }
 
-static void opt_width(const char *arg)
+static int opt_width(const char *opt, const char *arg)
 {
-    screen_width = atoi(arg);
-    if(screen_width<=0){
-        fprintf(stderr, "invalid width\n");
-        exit(1);
-    }
+    screen_width = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX);
+    return 0;
 }
 
-static void opt_height(const char *arg)
+static int opt_height(const char *opt, const char *arg)
 {
-    screen_height = atoi(arg);
-    if(screen_height<=0){
-        fprintf(stderr, "invalid height\n");
-        exit(1);
-    }
+    screen_height = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX);
+    return 0;
 }
 
 static void opt_format(const char *arg)
@@ -2410,59 +2403,56 @@ static void opt_sync(const char *arg)
     }
 }
 
-static void opt_seek(const char *arg)
+static int opt_seek(const char *opt, const char *arg)
 {
-    start_time = parse_date(arg, 1);
-    if (start_time == INT64_MIN) {
-        fprintf(stderr, "Invalid duration specification: %s\n", arg);
-        exit(1);
-    }
+    start_time = parse_time_or_die(opt, arg, 1);
+    return 0;
 }
 
-static void opt_debug(const char *arg)
+static int opt_debug(const char *opt, const char *arg)
 {
     av_log_set_level(99);
-    debug = atoi(arg);
+    debug = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
+    return 0;
 }
 
-static void opt_vismv(const char *arg)
+static int opt_vismv(const char *opt, const char *arg)
 {
-    debug_mv = atoi(arg);
+    debug_mv = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
+    return 0;
 }
 
-static void opt_thread_count(const char *arg)
+static int opt_thread_count(const char *opt, const char *arg)
 {
-    thread_count= atoi(arg);
+    thread_count= parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
 #if !defined(HAVE_THREADS)
     fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
 #endif
+    return 0;
 }
 
-static void opt_show_help(void)
-{
-    show_help();
-    exit(0);
-}
-
-const OptionDef options[] = {
-    { "h", 0, {(void*)opt_show_help}, "show help" },
-    { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
-    { "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
+static const OptionDef options[] = {
+    { "h", OPT_EXIT, {(void*)show_help}, "show help" },
+    { "version", OPT_EXIT, {(void*)show_version}, "show version" },
+    { "L", OPT_EXIT, {(void*)show_license}, "show license" },
+    { "formats", OPT_EXIT, {(void*)show_formats}, "show available formats, codecs, protocols, ..." },
+    { "x", HAS_ARG | OPT_FUNC2, {(void*)opt_width}, "force displayed width", "width" },
+    { "y", HAS_ARG | OPT_FUNC2, {(void*)opt_height}, "force displayed height", "height" },
     { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
     { "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
     { "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
     { "vn", OPT_BOOL, {(void*)&video_disable}, "disable video" },
     { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_audio_stream}, "", "" },
     { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_video_stream}, "", "" },
-    { "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
+    { "ss", HAS_ARG | OPT_FUNC2, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
     { "bytes", OPT_BOOL, {(void*)&seek_by_bytes}, "seek by bytes" },
     { "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
     { "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
     { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
     { "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
-    { "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
+    { "debug", HAS_ARG | OPT_FUNC2 | 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", "" },
+    { "vismv", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
     { "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
     { "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
     { "drp", OPT_BOOL |OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts", ""},
@@ -2474,11 +2464,11 @@ const OptionDef options[] = {
     { "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" },
     { "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" },
+    { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
     { NULL, },
 };
 
-void show_help(void)
+static void show_help(void)
 {
     printf("usage: ffplay [options] input_file\n"
            "Simple media player\n");
@@ -2501,7 +2491,7 @@ void show_help(void)
            );
 }
 
-void opt_input_file(const char *filename)
+static void opt_input_file(const char *filename)
 {
     if (!strcmp(filename, "-"))
         filename = "pipe:";
@@ -2518,7 +2508,7 @@ int main(int argc, char **argv)
     avdevice_register_all();
     av_register_all();
 
-    show_banner(program_name, program_birth_year);
+    show_banner();
 
     parse_options(argc, argv, options, opt_input_file);