X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=129cd28871030550da3febc9c5c820341a097c87;hb=9ad7dfc110de1c7540d5050c1d4f075f57cb9f7a;hp=e84e290be703bd643530d70c50eda9e022b031ab;hpb=9b157b0ccd259f4b9f3f0066e75cb7b5e94ab525;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index e84e290be70..129cd288710 100644 --- a/ffplay.c +++ b/ffplay.c @@ -80,9 +80,7 @@ const int program_birth_year = 2003; /* NOTE: the size must be big enough to compensate the hardware audio buffersize size */ #define SAMPLE_ARRAY_SIZE (2*65536) -#if !CONFIG_AVFILTER static int sws_flags = SWS_BICUBIC; -#endif typedef struct PacketQueue { AVPacketList *first_pkt, *last_pkt; @@ -1567,7 +1565,7 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) AVFilterContext *ctx = codec->opaque; AVFilterPicRef *ref; int perms = AV_PERM_WRITE; - int w, h, stride[4]; + int i, w, h, stride[4]; unsigned edge; if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { @@ -1589,17 +1587,20 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) ref->w = codec->width; ref->h = codec->height; - for(int i = 0; i < 3; i ++) { + for(i = 0; i < 3; i ++) { unsigned hshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w; unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h; - ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); + if (ref->data[i]) { + ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); + } pic->data[i] = ref->data[i]; pic->linesize[i] = ref->linesize[i]; } pic->opaque = ref; pic->age = INT_MAX; pic->type = FF_BUFFER_TYPE_USER; + pic->reordered_opaque = codec->reordered_opaque; return 0; } @@ -1609,6 +1610,25 @@ static void input_release_buffer(AVCodecContext *codec, AVFrame *pic) avfilter_unref_pic(pic->opaque); } +static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) +{ + AVFilterPicRef *ref = pic->opaque; + + if (pic->data[0] == NULL) { + pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; + return codec->get_buffer(codec, pic); + } + + if ((codec->width != ref->w) || (codec->height != ref->h) || + (codec->pix_fmt != ref->pic->format)) { + av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n"); + return -1; + } + + pic->reordered_opaque = codec->reordered_opaque; + return 0; +} + static int input_init(AVFilterContext *ctx, const char *args, void *opaque) { FilterPriv *priv = ctx->priv; @@ -1622,6 +1642,7 @@ static int input_init(AVFilterContext *ctx, const char *args, void *opaque) priv->use_dr1 = 1; codec->get_buffer = input_get_buffer; codec->release_buffer = input_release_buffer; + codec->reget_buffer = input_reget_buffer; } priv->frame = avcodec_alloc_frame(); @@ -1766,9 +1787,11 @@ static int video_thread(void *arg) #if CONFIG_AVFILTER int64_t pos; + char sws_flags_str[128]; AVFilterContext *filt_src = NULL, *filt_out = NULL; AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); - graph->scale_sws_opts = av_strdup("sws_flags=bilinear"); + snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); + graph->scale_sws_opts = av_strdup(sws_flags_str); if(!(filt_src = avfilter_open(&input_filter, "src"))) goto the_end; if(!(filt_out = avfilter_open(&output_filter, "out"))) goto the_end; @@ -3045,7 +3068,7 @@ static const OptionDef options[] = { { "framedrop", OPT_BOOL | OPT_EXPERT, {(void*)&framedrop}, "drop frames when cpu is too slow", "" }, { "window_title", OPT_STRING | HAS_ARG, {(void*)&window_title}, "set window title", "window title" }, #if CONFIG_AVFILTER - { "vfilters", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" }, + { "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter list" }, #endif { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" }, { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },