[MPlayer-dev-eng] [PATCH][RFC] video size change (realvideo)

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Nov 22 19:08:05 CET 2006


Hello,
On Wed, Nov 22, 2006 at 12:32:37AM +0100, Roberto Togni wrote:
> But I'm not sure about the vf.c vf_get_image() part. While is true that
> there is no need to reallocate the memory buffer when the new mpi image
> is smaller than the old one, there are a lot of other stuff that get
> skipped with the reallocation (stride, alignement, and some vf() calls).
> Does big->small resize works for other demuxers/codecs? Does anybody
> knows how that mpi allocation code works and what are the minimal
> things that have to be done on resize?
> My simple solution is to always reallocate the buffer.

I think your problems are because of two things in vd_realvid, both of
which I consider a bug
1) It does not set mpi->stride. IMO it should _always_ do that because
with dr the vo might set an aligned stride in the mpi it returns. Though
I admit that in the normal case this might not be needed because the vd
does not set MP_IMGFLAG_ACCEPT_STRIDE in mpcodecs_get_image.
2) The code assumes that mpi->planes[1] is directly behind
mpi->planes[0]. IIRC the documentation explicitly states that this
should not be assumed.

Attached hack works for me, but might have all kinds of weird effects,
esp. with -dr (changing ->planes[] is not allowed).

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vd_realvid.c
===================================================================
--- libmpcodecs/vd_realvid.c	(revision 21170)
+++ libmpcodecs/vd_realvid.c	(working copy)
@@ -366,6 +366,16 @@
 	    free(buffer);
 	    inited=1;
 	} 
+	if(transform_out[0] &&
+	   (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4])){
+	    mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo: image resize (%dx%d -> %dx%d)\n",sh->disp_w,sh->disp_h,transform_out[3],transform_out[4]);
+	    if (!mpcodecs_config_vo(sh,transform_out[3],transform_out[4],IMGFMT_I420)) return 0;
+	}
+	mpi->stride[0] = sh->disp_w;
+	mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * sh->disp_h;
+	mpi->stride[1] = sh->disp_w / 2;
+	mpi->planes[2] = mpi->planes[1] + mpi->stride[1] * sh->disp_h / 2;
+	mpi->stride[2] = sh->disp_w / 2;
 
 	return (result?NULL:mpi);
 }


More information about the MPlayer-dev-eng mailing list