#include <limits.h>
#include "libavutil/avstring.h"
#include "libavutil/colorspace.h"
+#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
typedef struct VideoPicture {
double pts; ///<presentation time stamp for this picture
double target_clock; ///<av_gettime() time at which this should be displayed ideally
+ double duration; ///<expected duration of the frame
int64_t pos; ///<byte position in file
SDL_Overlay *bmp;
int width, height; /* source height & width */
static int fs_screen_height;
static int screen_width = 0;
static int screen_height = 0;
-static int frame_width = 0;
-static int frame_height = 0;
-static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
static int audio_disable;
static int video_disable;
static int wanted_stream[AVMEDIA_TYPE_NB]={
assert(nextvp->target_clock >= vp->target_clock);
next_target= nextvp->target_clock;
}else{
- next_target= vp->target_clock + is->video_clock - vp->pts; //FIXME pass durations cleanly
+ next_target= vp->target_clock + vp->duration;
}
if((framedrop>0 || (framedrop && is->audio_st)) && time > next_target){
is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR;
vp = &is->pictq[is->pictq_windex];
+ vp->duration = frame_delay;
+
/* alloc or resize hardware picture buffer */
if (!vp->bmp ||
#if CONFIG_AVFILTER
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
{
- int len1 av_unused, got_picture, i;
+ int got_picture, i;
if (packet_queue_get(&is->videoq, pkt, 1) < 0)
return -1;
return 0;
}
- len1 = avcodec_decode_video2(is->video_st->codec,
- frame, &got_picture,
- pkt);
+ avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt);
if (got_picture) {
if (decoder_reorder_pts == -1) {
link->w = c->width;
link->h = c->height;
+ link->sample_aspect_ratio = priv->is->video_st->sample_aspect_ratio;
link->time_base = priv->is->video_st->time_base;
return 0;
if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
NULL, is, graph)) < 0)
- goto the_end;
+ return ret;
if ((ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
NULL, pix_fmts, graph)) < 0)
- goto the_end;
+ return ret;
if(vfilters) {
AVFilterInOut *outputs = avfilter_inout_alloc();
inputs->next = NULL;
if ((ret = avfilter_graph_parse(graph, vfilters, &inputs, &outputs, NULL)) < 0)
- goto the_end;
+ return ret;
av_freep(&vfilters);
} else {
if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
- goto the_end;
+ return ret;
}
if ((ret = avfilter_graph_config(graph, NULL)) < 0)
- goto the_end;
+ return ret;
is->out_video_filter = filt_out;
-the_end:
+
return ret;
}
VideoState *is = arg;
SubPicture *sp;
AVPacket pkt1, *pkt = &pkt1;
- int len1 av_unused, got_subtitle;
+ int got_subtitle;
double pts;
int i, j;
int r, g, b, y, u, v, a;
SDL_UnlockMutex(is->subpq_mutex);
if (is->subtitleq.abort_request)
- goto the_end;
+ return 0;
sp = &is->subpq[is->subpq_windex];
if (pkt->pts != AV_NOPTS_VALUE)
pts = av_q2d(is->subtitle_st->time_base)*pkt->pts;
- len1 = avcodec_decode_subtitle2(is->subtitle_st->codec,
- &sp->sub, &got_subtitle,
- pkt);
+ avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub,
+ &got_subtitle, pkt);
+
if (got_subtitle && sp->sub.format == 0) {
sp->pts = pts;
}
av_free_packet(pkt);
}
- the_end:
return 0;
}
AVCodecContext *avctx;
AVCodec *codec;
SDL_AudioSpec wanted_spec, spec;
+ AVDictionary *opts;
+ AVDictionaryEntry *t = NULL;
if (stream_index < 0 || stream_index >= ic->nb_streams)
return -1;
avctx = ic->streams[stream_index]->codec;
+ opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index]);
+
/* prepare audio output */
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
if (avctx->channels > 0) {
avctx->error_concealment= error_concealment;
avctx->thread_count= thread_count;
- set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec);
-
if(codec->capabilities & CODEC_CAP_DR1)
avctx->flags |= CODEC_FLAG_EMU_EDGE;
- if (avcodec_open(avctx, codec) < 0)
+ if (!codec ||
+ avcodec_open2(avctx, codec, &opts) < 0)
return -1;
+ if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+ av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
+ return AVERROR_OPTION_NOT_FOUND;
+ }
/* prepare audio output */
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
int eof=0;
int pkt_in_play_range = 0;
AVDictionaryEntry *t;
+ AVDictionary **opts;
+ int orig_nb_streams;
memset(st_index, -1, sizeof(st_index));
is->video_stream = -1;
if(genpts)
ic->flags |= AVFMT_FLAG_GENPTS;
- err = av_find_stream_info(ic);
+ opts = setup_find_stream_info_opts(ic, codec_opts);
+ orig_nb_streams = ic->nb_streams;
+
+ err = avformat_find_stream_info(ic, opts);
if (err < 0) {
fprintf(stderr, "%s: could not find codec parameters\n", is->filename);
ret = -1;
goto fail;
}
+ for (i = 0; i < orig_nb_streams; i++)
+ av_dict_free(&opts[i]);
+ av_freep(&opts);
+
if(ic->pb)
ic->pb->eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end
static int opt_frame_size(const char *opt, const char *arg)
{
- if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
- fprintf(stderr, "Incorrect frame size\n");
- return AVERROR(EINVAL);
- }
- if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
- fprintf(stderr, "Frame size must be a multiple of 2\n");
- return AVERROR(EINVAL);
- }
- return 0;
+ av_log(NULL, AV_LOG_WARNING, "Option -s is deprecated, use -video_size.\n");
+ return opt_default("video_size", arg);
}
static int opt_width(const char *opt, const char *arg)
static int opt_frame_pix_fmt(const char *opt, const char *arg)
{
- frame_pix_fmt = av_get_pix_fmt(arg);
- return 0;
+ av_log(NULL, AV_LOG_WARNING, "Option -pix_fmt is deprecated, use -pixel_format.\n");
+ return opt_default("pixel_format", arg);
}
static int opt_sync(const char *opt, const char *arg)
static void show_usage(void)
{
printf("Simple media player\n");
- printf("usage: ffplay [options] input_file\n");
+ printf("usage: %s [options] input_file\n", program_name);
printf("\n");
}
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");
+ fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'\n", program_name);
exit(1);
}
#endif
if (SDL_Init (flags)) {
fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
+ fprintf(stderr, "(Did you set the DISPLAY variable?)\n");
exit(1);
}