From ef906390043010cde8844ec30da79926f2f8b846 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 28 Jun 2013 03:27:39 +0200 Subject: [PATCH] avfilter/vf_mp: preserve pixel format when possible Fixes Ticket2577 Signed-off-by: Michael Niedermayer --- libavfilter/vf_mp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 3cf22f8bab..9414c7a9fb 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -249,6 +249,7 @@ typedef struct { AVFilterContext *avfctx; int frame_returned; char *filter; + enum AVPixelFormat in_pix_fmt; } MPContext; #define OFFSET(x) offsetof(MPContext, x) @@ -543,6 +544,10 @@ int ff_vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts){ for(i=0; conversion_map[i].fmt && mpi->imgfmt != conversion_map[i].fmt; i++); picref->format = conversion_map[i].pix_fmt; + for(i=0; conversion_map[i].fmt && m->in_pix_fmt != conversion_map[i].pix_fmt; i++); + if (mpi->imgfmt == conversion_map[i].fmt) + picref->format = conversion_map[i].pix_fmt; + memcpy(picref->linesize, mpi->stride, FFMIN(sizeof(picref->linesize), sizeof(mpi->stride))); for(i=0; i<4 && mpi->stride[i]; i++){ @@ -796,6 +801,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) for(i=0; conversion_map[i].fmt && conversion_map[i].pix_fmt != inlink->format; i++); ff_mp_image_setfmt(mpi,conversion_map[i].fmt); + m->in_pix_fmt = inlink->format; memcpy(mpi->planes, inpic->data, FFMIN(sizeof(inpic->data) , sizeof(mpi->planes))); memcpy(mpi->stride, inpic->linesize, FFMIN(sizeof(inpic->linesize), sizeof(mpi->stride)));