diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-09-13 19:39:59 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-09-13 19:39:59 +0200 |
commit | 5b5ff07c2810d0668ce12a52826a260b39c0c1fd (patch) | |
tree | feb7ca680b49f86d05d323c22b68ab9055e9d999 /gst/pnm | |
parent | f09b1adf707747e96e95b5cc0ff69178a3dab738 (diff) | |
download | gstreamer-plugins-bad-5b5ff07c2810d0668ce12a52826a260b39c0c1fd.tar.gz |
pnm: Use correct rowstride for 8 bit grayscale too
Diffstat (limited to 'gst/pnm')
-rw-r--r-- | gst/pnm/gstpnmdec.c | 22 | ||||
-rw-r--r-- | gst/pnm/gstpnmenc.c | 17 |
2 files changed, 28 insertions, 11 deletions
diff --git a/gst/pnm/gstpnmdec.c b/gst/pnm/gstpnmdec.c index 0d2dd5a14..4b6b15f04 100644 --- a/gst/pnm/gstpnmdec.c +++ b/gst/pnm/gstpnmdec.c @@ -62,15 +62,23 @@ static GstFlowReturn gst_pnmdec_push (GstPnmdec * s, GstPad * src, GstBuffer * buf) { /* Need to convert from PNM rowstride to GStreamer rowstride */ - if ((s->mngr.info.type == GST_PNM_TYPE_PIXMAP_ASCII || - s->mngr.info.type == GST_PNM_TYPE_PIXMAP_RAW) - && s->mngr.info.width % 4 != 0) { - guint i_rowstride = 3 * s->mngr.info.width; - guint o_rowstride = GST_ROUND_UP_4 (3 * s->mngr.info.width); - GstBuffer *obuf = - gst_buffer_new_and_alloc (o_rowstride * s->mngr.info.height); + if (s->mngr.info.width % 4 != 0) { + guint i_rowstride; + guint o_rowstride; + GstBuffer *obuf; guint i; + if (s->mngr.info.type == GST_PNM_TYPE_PIXMAP_RAW || + s->mngr.info.type == GST_PNM_TYPE_PIXMAP_ASCII) { + i_rowstride = 3 * s->mngr.info.width; + o_rowstride = GST_ROUND_UP_4 (i_rowstride); + } else { + i_rowstride = s->mngr.info.width; + o_rowstride = GST_ROUND_UP_4 (i_rowstride); + } + + obuf = gst_buffer_new_and_alloc (o_rowstride * s->mngr.info.height); + gst_buffer_copy_metadata (obuf, buf, GST_BUFFER_COPY_ALL); for (i = 0; i < s->mngr.info.height; i++) diff --git a/gst/pnm/gstpnmenc.c b/gst/pnm/gstpnmenc.c index c94ed17f3..3a9a98a84 100644 --- a/gst/pnm/gstpnmenc.c +++ b/gst/pnm/gstpnmenc.c @@ -80,12 +80,21 @@ gst_pnmenc_chain (GstPad * pad, GstBuffer * buf) goto out; /* Need to convert from GStreamer rowstride to PNM rowstride */ - if (s->info.type == GST_PNM_TYPE_PIXMAP_RAW && s->info.width % 4 != 0) { - guint i_rowstride = GST_ROUND_UP_4 (s->info.width * 3); - guint o_rowstride = s->info.width * 3; - GstBuffer *obuf = gst_buffer_new_and_alloc (o_rowstride * s->info.height); + if (s->info.width % 4 != 0) { + guint i_rowstride; + guint o_rowstride; + GstBuffer *obuf; guint i; + if (s->info.type == GST_PNM_TYPE_PIXMAP_RAW) { + o_rowstride = 3 * s->info.width; + i_rowstride = GST_ROUND_UP_4 (o_rowstride); + } else { + o_rowstride = s->info.width; + i_rowstride = GST_ROUND_UP_4 (o_rowstride); + } + + obuf = gst_buffer_new_and_alloc (o_rowstride * s->info.height); for (i = 0; i < s->info.height; i++) memcpy (GST_BUFFER_DATA (obuf) + o_rowstride * i, GST_BUFFER_DATA (buf) + i_rowstride * i, o_rowstride); |