summaryrefslogtreecommitdiffstats
path: root/ext/jp2k
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2008-11-13 21:31:14 +0000
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2008-11-13 21:31:14 +0000
commitde900d75f4568dc81d9b270a09ad891966f227cd (patch)
treeb115c4ca28fd3c4b02a135e7be76a9dde864aba4 /ext/jp2k
parent411a21bafb4a005fb5c80e641a24950a67e24f5d (diff)
downloadgst-plugins-bad-de900d75f4568dc81d9b270a09ad891966f227cd.tar.gz
gst-plugins-bad-de900d75f4568dc81d9b270a09ad891966f227cd.tar.bz2
gst-plugins-bad-de900d75f4568dc81d9b270a09ad891966f227cd.zip
ext/jp2k/gstjasperdec.*: Make pad template caps reflect the supported formats.
Original commit message from CVS: * ext/jp2k/gstjasperdec.c: (gst_jasper_dec_init), (gst_jasper_dec_reset), (gst_jasper_dec_negotiate), (gst_jasper_dec_get_picture): * ext/jp2k/gstjasperdec.h: Make pad template caps reflect the supported formats. Add or modify some debug statements, and slightly simplify image passing to encoding library.
Diffstat (limited to 'ext/jp2k')
-rw-r--r--ext/jp2k/gstjasperdec.c34
-rw-r--r--ext/jp2k/gstjasperdec.h7
2 files changed, 21 insertions, 20 deletions
diff --git a/ext/jp2k/gstjasperdec.c b/ext/jp2k/gstjasperdec.c
index 326a111c..267bb5dc 100644
--- a/ext/jp2k/gstjasperdec.c
+++ b/ext/jp2k/gstjasperdec.c
@@ -62,11 +62,9 @@ static GstStaticPadTemplate gst_jasper_dec_src_template =
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGBA "; " GST_VIDEO_CAPS_ARGB "; "
- GST_VIDEO_CAPS_BGRA "; " GST_VIDEO_CAPS_ABGR "; "
GST_VIDEO_CAPS_RGBx "; " GST_VIDEO_CAPS_xRGB "; "
GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV, Y41B, Y42B }"))
+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, Y41B, Y42B }"))
);
static void gst_jasper_dec_base_init (gpointer g_class);
@@ -140,7 +138,7 @@ gst_jasper_dec_init (GstJasperDec * dec, GstJasperDecClass * klass)
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
dec->codec_data = NULL;
- dec->mat = NULL;
+ dec->buf = NULL;
gst_jasper_dec_reset (dec);
}
@@ -150,9 +148,9 @@ gst_jasper_dec_reset (GstJasperDec * dec)
if (dec->codec_data)
gst_buffer_unref (dec->codec_data);
dec->codec_data = NULL;
- if (dec->mat)
- jas_matrix_destroy (dec->mat);
- dec->mat = NULL;
+ if (dec->buf)
+ g_free (dec->buf);
+ dec->buf = NULL;
dec->fmt = -1;
dec->clrspc = JAS_CLRSPC_UNKNOWN;
dec->format = GST_VIDEO_FORMAT_UNKNOWN;
@@ -252,6 +250,8 @@ gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image)
height = jas_image_height (image);
channels = jas_image_numcmpts (image);
+ GST_LOG_OBJECT (dec, "%d x %d, %d components", width, height, channels);
+
/* jp2c bitstream has no real colour space info (kept in container),
* so decoder may only pretend to know, where it really does not */
if (!jas_clrspc_isunknown (dec->clrspc)) {
@@ -391,14 +391,9 @@ gst_jasper_dec_negotiate (GstJasperDec * dec, jas_image_t * image)
dec->image_size = gst_video_format_get_size (dec->format, width, height);
dec->alpha = gst_video_format_has_alpha (dec->format);
- if (dec->mat)
- jas_matrix_destroy (dec->mat);
- dec->mat = jas_matrix_create (1, dec->width);
- if (!dec->mat) {
- dec->format = GST_VIDEO_FORMAT_UNKNOWN;
- GST_DEBUG_OBJECT (dec, "failed to create helper buffer");
- goto fail_image;
- }
+ if (dec->buf)
+ g_free (dec->buf);
+ dec->buf = g_new0 (glong, dec->width);
caps = gst_video_format_new_caps (dec->format, dec->width, dec->height,
dec->framerate_numerator, dec->framerate_denominator, 1, 1);
@@ -462,6 +457,7 @@ gst_jasper_dec_get_picture (GstJasperDec * dec, guint8 * data,
for (i = 0; i < dec->channels; ++i) {
gint x, y, cwidth, cheight, inc, stride, cmpt;
guint8 *row_pix, *out_pix;
+ glong *tb;
inc = dec->inc[i];
stride = dec->stride[i];
@@ -469,7 +465,7 @@ gst_jasper_dec_get_picture (GstJasperDec * dec, guint8 * data,
cheight = dec->cheight[cmpt];
cwidth = dec->cwidth[cmpt];
- GST_DEBUG_OBJECT (dec,
+ GST_LOG_OBJECT (dec,
"retrieve component %d<=%d, size %dx%d, offset %d, inc %d, stride %d",
i, cmpt, cwidth, cheight, dec->offset[i], inc, stride);
@@ -477,10 +473,12 @@ gst_jasper_dec_get_picture (GstJasperDec * dec, guint8 * data,
for (y = 0; y < cheight; y++) {
row_pix = out_pix;
- if (jas_image_readcmpt (image, i, 0, y, cwidth, 1, dec->mat))
+ tb = dec->buf;
+ if (jas_image_readcmpt2 (image, i, 0, y, cwidth, 1, dec->buf))
goto fail_image;
for (x = 0; x < cwidth; x++) {
- *out_pix = (guint8) jas_matrix_get (dec->mat, 0, x);
+ *out_pix = *tb;
+ tb++;
out_pix += inc;
}
out_pix = row_pix + stride;
diff --git a/ext/jp2k/gstjasperdec.h b/ext/jp2k/gstjasperdec.h
index 962ca772..84a82929 100644
--- a/ext/jp2k/gstjasperdec.h
+++ b/ext/jp2k/gstjasperdec.h
@@ -21,6 +21,9 @@
#define __GST_JASPER_DEC_H__
#include <gst/gst.h>
+#include <gst/video/video.h>
+
+#include <jasper/jasper.h>
G_BEGIN_DECLS
@@ -64,7 +67,7 @@ struct _GstJasperDec
gint offset[GST_JASPER_DEC_MAX_COMPONENT];
gint inc[GST_JASPER_DEC_MAX_COMPONENT];
gboolean alpha;
- jas_matrix_t *mat;
+ glong *buf;
/* image cmpt indexed */
gint cwidth[GST_JASPER_DEC_MAX_COMPONENT];
@@ -81,7 +84,7 @@ struct _GstJasperDecClass
GstElementClass parent_class;
};
-static GType gst_jasper_dec_get_type (void);
+GType gst_jasper_dec_get_type (void);
G_END_DECLS