diff options
Diffstat (limited to 'gst/pnm/gstpnmenc.c')
-rw-r--r-- | gst/pnm/gstpnmenc.c | 17 |
1 files changed, 13 insertions, 4 deletions
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); |