#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"
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]={
static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
{
VideoPicture *vp;
- int dst_pix_fmt;
#if CONFIG_AVFILTER
AVPicture pict_src;
+#else
+ int dst_pix_fmt = PIX_FMT_YUV420P;
#endif
/* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex);
/* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp);
- dst_pix_fmt = PIX_FMT_YUV420P;
memset(&pict,0,sizeof(AVPicture));
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
{
- int len1, 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) {
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, &ffsink, "out",
NULL, &ffsink_ctx, graph)) < 0)
- goto the_end;
+ return ret;
if(vfilters) {
AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
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, 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, 0);
+
/* 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 ||
- avcodec_open(avctx, codec) < 0)
+ 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;
- /* Set AVCodecContext options so they will be seen by av_find_stream_info() */
- for (i = 0; i < ic->nb_streams; i++) {
- AVCodecContext *dec = ic->streams[i]->codec;
- switch (dec->codec_type) {
- case AVMEDIA_TYPE_AUDIO:
- set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO],
- AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM,
- NULL);
- break;
- case AVMEDIA_TYPE_VIDEO:
- set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO],
- AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM,
- NULL);
- break;
- }
- }
+ opts = setup_find_stream_info_opts(ic);
+ orig_nb_streams = ic->nb_streams;
- err = av_find_stream_info(ic);
+ 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_ERROR,
+ "Option '%s' has been removed, use private format options instead\n", opt);
+ return AVERROR(EINVAL);
}
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_ERROR,
+ "Option '%s' has been removed, use private format options instead\n", opt);
+ return AVERROR(EINVAL);
}
static int opt_sync(const char *opt, const char *arg)