/* TODO: We assume that a decoded and resampled frame fits into this buffer */
#define SAMPLE_ARRAY_SIZE (8 * 65536)
-static int sws_flags = SWS_BICUBIC;
+static int64_t sws_flags = SWS_BICUBIC;
typedef struct MyAVPacketList {
AVPacket pkt;
double video_current_pts; // current displayed pts (different from video_clock if frame fifos are used)
double video_current_pts_drift; // video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
int64_t video_current_pos; // current displayed file pos
+ double max_frame_duration; // maximum duration of a frame - above this, we consider the jump a timestamp discontinuity
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex;
/* compute nominal last_duration */
last_duration = vp->pts - is->frame_last_pts;
- if (last_duration > 0 && last_duration < 10.0) {
+ if (last_duration > 0 && last_duration < is->max_frame_duration) {
/* if duration of the last frame was sane, update last_duration in video state */
is->frame_last_duration = last_duration;
}
av_picture_copy(&pict, (AVPicture *)src_frame,
src_frame->format, vp->width, vp->height);
#else
- sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
+ av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, src_frame->format, vp->width, vp->height,
AV_PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
if (!buffersink_params)
return AVERROR(ENOMEM);
- snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
+ snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%"PRId64, sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
snprintf(buffersrc_args, sizeof(buffersrc_args),
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
AVCodec *codec;
+ const char *forced_codec_name = NULL;
AVDictionary *opts;
AVDictionaryEntry *t = NULL;
codec = avcodec_find_decoder(avctx->codec_id);
switch(avctx->codec_type){
- case AVMEDIA_TYPE_AUDIO : is->last_audio_stream = stream_index; if(audio_codec_name ) codec= avcodec_find_decoder_by_name( audio_codec_name); break;
- case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; if(subtitle_codec_name) codec= avcodec_find_decoder_by_name(subtitle_codec_name); break;
- case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; if(video_codec_name ) codec= avcodec_find_decoder_by_name( video_codec_name); break;
- }
- if (!codec)
+ case AVMEDIA_TYPE_AUDIO : is->last_audio_stream = stream_index; forced_codec_name = audio_codec_name; break;
+ case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break;
+ case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break;
+ }
+ if (forced_codec_name)
+ codec = avcodec_find_decoder_by_name(forced_codec_name);
+ if (!codec) {
+ if (forced_codec_name) fprintf(stderr, "No codec could be found with name '%s'\n", forced_codec_name);
+ else fprintf(stderr, "No codec could be found with id %d\n", avctx->codec_id);
return -1;
+ }
+ avctx->codec_id = codec->id;
avctx->workaround_bugs = workaround_bugs;
avctx->lowres = lowres;
if(avctx->lowres > codec->max_lowres){
if (seek_by_bytes < 0)
seek_by_bytes = !!(ic->iformat->flags & AVFMT_TS_DISCONT);
+ is->max_frame_duration = (ic->iformat->flags & AVFMT_TS_DISCONT) ? 10.0 : 3600.0;
+
/* if seeking requested, we execute it */
if (start_time != AV_NOPTS_VALUE) {
int64_t timestamp;
packet_queue_flush(&is->videoq);
packet_queue_put(&is->videoq, &flush_pkt);
}
+ if (is->seek_flags & AVSEEK_FLAG_BYTE) {
+ //FIXME: use a cleaner way to signal obsolete external clock...
+ update_external_clock_pts(is, (double)AV_NOPTS_VALUE);
+ } else {
+ update_external_clock_pts(is, seek_target / (double)AV_TIME_BASE);
+ }
}
- update_external_clock_pts(is, (seek_target + ic->start_time) / (double)AV_TIME_BASE);
is->seek_req = 0;
eof = 0;
}
} else {
pos = get_master_clock(cur_stream);
pos += incr;
+ if (cur_stream->ic->start_time != AV_NOPTS_VALUE && pos < cur_stream->ic->start_time / (double)AV_TIME_BASE)
+ pos = cur_stream->ic->start_time / (double)AV_TIME_BASE;
stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);
}
break;
input_filename = filename;
}
-static int opt_codec(void *o, const char *opt, const char *arg)
+static int opt_codec(void *optctx, const char *opt, const char *arg)
{
- switch(opt[strlen(opt)-1]){
- case 'a' : audio_codec_name = arg; break;
- case 's' : subtitle_codec_name = arg; break;
- case 'v' : video_codec_name = arg; break;
- }
- return 0;
+ const char *spec = strchr(opt, ':');
+ if (!spec) {
+ fprintf(stderr, "No media specifier was specified in '%s' in option '%s'\n",
+ arg, opt);
+ return AVERROR(EINVAL);
+ }
+ spec++;
+ switch (spec[0]) {
+ case 'a' : audio_codec_name = arg; break;
+ case 's' : subtitle_codec_name = arg; break;
+ case 'v' : video_codec_name = arg; break;
+ default:
+ fprintf(stderr, "Invalid media specifier '%s' in option '%s'\n", spec, opt);
+ return AVERROR(EINVAL);
+ }
+ return 0;
}
static int dummy;
{ "showmode", HAS_ARG, { .func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { .func_arg = opt_default }, "generic catch all option", "" },
{ "i", OPT_BOOL, { &dummy}, "read specified file", "input_file"},
- { "codec", HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder" },
+ { "codec", HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
+ { "acodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &audio_codec_name }, "force audio decoder", "decoder_name" },
+ { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
+ { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &video_codec_name }, "force video decoder", "decoder_name" },
{ NULL, },
};