mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
pnm: Use correct rowstride for 8 bit grayscale too
This commit is contained in:
parent
f09b1adf70
commit
5b5ff07c28
2 changed files with 28 additions and 11 deletions
|
@ -62,15 +62,23 @@ static GstFlowReturn
|
||||||
gst_pnmdec_push (GstPnmdec * s, GstPad * src, GstBuffer * buf)
|
gst_pnmdec_push (GstPnmdec * s, GstPad * src, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
/* Need to convert from PNM rowstride to GStreamer rowstride */
|
/* Need to convert from PNM rowstride to GStreamer rowstride */
|
||||||
if ((s->mngr.info.type == GST_PNM_TYPE_PIXMAP_ASCII ||
|
if (s->mngr.info.width % 4 != 0) {
|
||||||
s->mngr.info.type == GST_PNM_TYPE_PIXMAP_RAW)
|
guint i_rowstride;
|
||||||
&& s->mngr.info.width % 4 != 0) {
|
guint o_rowstride;
|
||||||
guint i_rowstride = 3 * s->mngr.info.width;
|
GstBuffer *obuf;
|
||||||
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);
|
|
||||||
guint i;
|
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);
|
gst_buffer_copy_metadata (obuf, buf, GST_BUFFER_COPY_ALL);
|
||||||
|
|
||||||
for (i = 0; i < s->mngr.info.height; i++)
|
for (i = 0; i < s->mngr.info.height; i++)
|
||||||
|
|
|
@ -80,12 +80,21 @@ gst_pnmenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Need to convert from GStreamer rowstride to PNM rowstride */
|
/* Need to convert from GStreamer rowstride to PNM rowstride */
|
||||||
if (s->info.type == GST_PNM_TYPE_PIXMAP_RAW && s->info.width % 4 != 0) {
|
if (s->info.width % 4 != 0) {
|
||||||
guint i_rowstride = GST_ROUND_UP_4 (s->info.width * 3);
|
guint i_rowstride;
|
||||||
guint o_rowstride = s->info.width * 3;
|
guint o_rowstride;
|
||||||
GstBuffer *obuf = gst_buffer_new_and_alloc (o_rowstride * s->info.height);
|
GstBuffer *obuf;
|
||||||
guint i;
|
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++)
|
for (i = 0; i < s->info.height; i++)
|
||||||
memcpy (GST_BUFFER_DATA (obuf) + o_rowstride * i,
|
memcpy (GST_BUFFER_DATA (obuf) + o_rowstride * i,
|
||||||
GST_BUFFER_DATA (buf) + i_rowstride * i, o_rowstride);
|
GST_BUFFER_DATA (buf) + i_rowstride * i, o_rowstride);
|
||||||
|
|
Loading…
Reference in a new issue