* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
#include <math.h>
#include <limits.h>
#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"
#endif
#undef exit
+#undef printf
+#undef fprintf
const char program_name[] = "FFplay";
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
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;
}
#endif
-
-
-#define SCALEBITS 10
-#define ONE_HALF (1 << (SCALEBITS - 1))
-#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
- FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> 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))
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;
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,
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);
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:
}
}
-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;
}
if (show_status) {
dump_format(ic, 0, is->filename, 0);
- dump_stream_info(ic);
}
/* open the streams */
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;
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:
}
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" },
{ 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",
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);
}