pnm: Use correct rowstride for 8 bit grayscale too

This commit is contained in:
Sebastian Dröge 2009-09-13 19:39:59 +02:00
parent f09b1adf70
commit 5b5ff07c28
2 changed files with 28 additions and 11 deletions

View file

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

View file

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