[MPlayer-cvslog] r30405 - in trunk/libmpcodecs: vf_fspp.c vf_spp.c

reimar subversion at mplayerhq.hu
Sat Jan 23 15:57:43 CET 2010


Author: reimar
Date: Sat Jan 23 15:57:43 2010
New Revision: 30405

Log:
Make sure that a qstride of 0 (intentional or not) does not completely break
the code (crash if malloc(0) != NULL, otherwise wrong qscales used for B-frames).

Modified:
   trunk/libmpcodecs/vf_fspp.c
   trunk/libmpcodecs/vf_spp.c

Modified: trunk/libmpcodecs/vf_fspp.c
==============================================================================
--- trunk/libmpcodecs/vf_fspp.c	Sat Jan 23 13:27:13 2010	(r30404)
+++ trunk/libmpcodecs/vf_fspp.c	Sat Jan 23 15:57:43 2010	(r30405)
@@ -533,9 +533,15 @@ static int put_image(struct vf_instance_
 
     vf->priv->mpeg2= mpi->qscale_type;
     if(mpi->pict_type != 3 && mpi->qscale && !vf->priv->qp){
-	if(!vf->priv->non_b_qp)
-	    vf->priv->non_b_qp= malloc(mpi->qstride * ((mpi->h + 15) >> 4));
-	fast_memcpy(vf->priv->non_b_qp, mpi->qscale, mpi->qstride * ((mpi->h + 15) >> 4));
+        int w = mpi->qstride;
+        int h = (mpi->h + 15) >> 4;
+        if (!w) {
+            w = (mpi->w + 15) >> 4;
+            h = 1;
+        }
+        if(!vf->priv->non_b_qp)
+            vf->priv->non_b_qp= malloc(w*h);
+        fast_memcpy(vf->priv->non_b_qp, mpi->qscale, w*h);
     }
     if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){
 	char *qp_tab= vf->priv->non_b_qp;

Modified: trunk/libmpcodecs/vf_spp.c
==============================================================================
--- trunk/libmpcodecs/vf_spp.c	Sat Jan 23 13:27:13 2010	(r30404)
+++ trunk/libmpcodecs/vf_spp.c	Sat Jan 23 15:57:43 2010	(r30405)
@@ -480,9 +480,15 @@ static int put_image(struct vf_instance_
 
         vf->priv->mpeg2= mpi->qscale_type;
         if(mpi->pict_type != 3 && mpi->qscale && !vf->priv->qp){
+            int w = mpi->qstride;
+            int h = (mpi->h + 15) >> 4;
+            if (!w) {
+                w = (mpi->w + 15) >> 4;
+                h = 1;
+            }
             if(!vf->priv->non_b_qp)
-                vf->priv->non_b_qp= malloc(mpi->qstride * ((mpi->h + 15) >> 4));
-            fast_memcpy(vf->priv->non_b_qp, mpi->qscale, mpi->qstride * ((mpi->h + 15) >> 4));
+                vf->priv->non_b_qp= malloc(w*h);
+            fast_memcpy(vf->priv->non_b_qp, mpi->qscale, w*h);
         }
 	if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){
             char *qp_tab= vf->priv->non_b_qp;


More information about the MPlayer-cvslog mailing list