X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=dc8303166182d3ddb1521615bc23710de827222a;hb=fdf4662211fb8e50854e795f47a59753378f2a10;hp=092a08824009ff5733bb04bc8b712b68b0a7f82d;hpb=3ac56e28b0a3fc84ccac9ac7e359f0f29567f8a0;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index 092a0882400..dc830316618 100644 --- a/ffplay.c +++ b/ffplay.c @@ -19,14 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include #include #include "libavutil/avstring.h" #include "libavformat/avformat.h" -#include "libavformat/rtsp.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavcodec/audioconvert.h" +#include "libavcodec/colorspace.h" #include "libavcodec/opt.h" #include "cmdutils.h" @@ -39,6 +40,8 @@ #endif #undef exit +#undef printf +#undef fprintf const char program_name[] = "FFplay"; const int program_birth_year = 2003; @@ -46,7 +49,7 @@ const int program_birth_year = 2003; //#define DEBUG_SYNC #define MAX_VIDEOQ_SIZE (5 * 256 * 1024) -#define MAX_AUDIOQ_SIZE (5 * 16 * 1024) +#define MAX_AUDIOQ_SIZE (20 * 16 * 1024) #define MAX_SUBTITLEQ_SIZE (5 * 16 * 1024) /* SDL audio buffer size, in samples. Should be small to have precise @@ -195,7 +198,7 @@ static int wanted_video_stream= 0; static int wanted_subtitle_stream= -1; static int seek_by_bytes; static int display_disable; -static int show_status; +static int show_status = 1; static int av_sync_type = AV_SYNC_AUDIO_MASTER; static int64_t start_time = AV_NOPTS_VALUE; static int debug = 0; @@ -387,24 +390,6 @@ void fill_border(VideoState *s, int x, int y, int w, int h, int color) } #endif - - -#define SCALEBITS 10 -#define ONE_HALF (1 << (SCALEBITS - 1)) -#define FIX(x) ((int) ((x) * (1<> SCALEBITS) - -#define RGB_TO_U_CCIR(r1, g1, b1, shift)\ -(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \ - FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) - -#define RGB_TO_V_CCIR(r1, g1, b1, shift)\ -(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \ - FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) - #define ALPHA_BLEND(a, oldp, newp, s)\ ((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s)) @@ -1156,7 +1141,7 @@ static void video_refresh_timer(void *opaque) double av_diff; cur_time = av_gettime(); - if (!last_time || (cur_time - last_time) >= 500 * 1000) { + if (!last_time || (cur_time - last_time) >= 30000) { aqsize = 0; vqsize = 0; sqsize = 0; @@ -1189,23 +1174,6 @@ static void alloc_picture(void *opaque) if (vp->bmp) SDL_FreeYUVOverlay(vp->bmp); -#if 0 - /* XXX: use generic function */ - /* XXX: disable overlay if no hardware acceleration or if RGB format */ - switch(is->video_st->codec->pix_fmt) { - case PIX_FMT_YUV420P: - case PIX_FMT_YUV422P: - case PIX_FMT_YUV444P: - case PIX_FMT_YUYV422: - case PIX_FMT_YUV410P: - case PIX_FMT_YUV411P: - is_yuv = 1; - break; - default: - is_yuv = 0; - break; - } -#endif vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width, is->video_st->codec->height, SDL_YV12_OVERLAY, @@ -1754,6 +1722,8 @@ static int stream_component_open(VideoState *is, int stream_index) enc->skip_loop_filter= skip_loop_filter; enc->error_recognition= error_recognition; enc->error_concealment= error_concealment; + if (thread_count > 1) + avcodec_thread_init(enc, thread_count); set_context_opts(enc, avcodec_opts[enc->codec_type], 0); @@ -1778,9 +1748,6 @@ static int stream_component_open(VideoState *is, int stream_index) is->audio_src_fmt= SAMPLE_FMT_S16; } - if(thread_count>1) - avcodec_thread_init(enc, thread_count); - enc->thread_count= thread_count; ic->streams[stream_index]->discard = AVDISCARD_DEFAULT; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: @@ -1895,13 +1862,6 @@ static void stream_component_close(VideoState *is, int stream_index) } } -static void dump_stream_info(const AVFormatContext *s) -{ - AVMetadataTag *tag = NULL; - while ((tag=av_metadata_get(s->metadata,"",tag,AV_METADATA_IGNORE_SUFFIX))) - fprintf(stderr, "%s: %s\n", tag->key, tag->value); -} - /* since we have only one decoding thread, we can use a global variable instead of a thread local variable */ static VideoState *global_video_state; @@ -1995,7 +1955,6 @@ static int decode_thread(void *arg) } if (show_status) { dump_format(ic, 0, is->filename, 0); - dump_stream_info(ic); } /* open the streams */ @@ -2368,6 +2327,7 @@ static void event_loop(void) break; case SDL_MOUSEBUTTONDOWN: if (cur_stream) { + int64_t ts; int ns, hh, mm, ss; int tns, thh, tmm, tss; tns = cur_stream->ic->duration/1000000LL; @@ -2381,7 +2341,10 @@ static void event_loop(void) ss = (ns%60); fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100, hh, mm, ss, thh, tmm, tss); - stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration), 0); + ts = frac*cur_stream->ic->duration; + if (cur_stream->ic->start_time != AV_NOPTS_VALUE) + ts += cur_stream->ic->start_time; + stream_seek(cur_stream, ts, 0); } break; case SDL_VIDEORESIZE: @@ -2491,10 +2454,7 @@ static int opt_thread_count(const char *opt, const char *arg) } 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, ..." }, +#include "cmdutils_common_opts.h" { "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" }, @@ -2529,11 +2489,16 @@ static const OptionDef options[] = { { NULL, }, }; -static void show_help(void) +static void show_usage(void) { - printf("usage: ffplay [options] input_file\n" - "Simple media player\n"); + printf("Simple media player\n"); + printf("usage: ffplay [options] input_file\n"); printf("\n"); +} + +static void show_help(void) +{ + show_usage(); show_help_options(options, "Main options:\n", OPT_EXPERT, 0); show_help_options(options, "\nAdvanced options:\n", @@ -2580,7 +2545,9 @@ int main(int argc, char **argv) parse_options(argc, argv, options, opt_input_file); if (!input_filename) { + show_usage(); fprintf(stderr, "An input file must be specified\n"); + fprintf(stderr, "Use -h to get full help or, even better, run 'man ffplay'\n"); exit(1); }