diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-01-23 14:57:43 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-01-23 14:57:43 +0000 |
commit | 7725c6d73b3bf2f20ee7c5aac18c76eb8397c7ef (patch) | |
tree | 844b78e79f88ede9854c210c68e57c47be5adba7 /libmpcodecs | |
parent | 570f1f5dec2f92f46a9628df2ff9b0f5620532a8 (diff) |
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).
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30405 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/vf_fspp.c | 12 | ||||
-rw-r--r-- | libmpcodecs/vf_spp.c | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c index 44bafb61bf..a813396058 100644 --- a/libmpcodecs/vf_fspp.c +++ b/libmpcodecs/vf_fspp.c @@ -533,9 +533,15 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) 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; diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c index 5a6ed294e3..476d2103c7 100644 --- a/libmpcodecs/vf_spp.c +++ b/libmpcodecs/vf_spp.c @@ -480,9 +480,15 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ 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; |