avfilter/vf_mp: preserve pixel format when possible

Fixes Ticket2577

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-06-28 03:27:39 +02:00
parent 86190afbda
commit ef90639004

View File

@ -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)));