summaryrefslogtreecommitdiff
path: root/ext/openjpeg
diff options
context:
space:
mode:
authorAaron Boxer <boxerab@gmail.com>2016-06-21 12:41:46 -0400
committerSebastian Dröge <sebastian@centricular.com>2016-06-24 11:23:31 +0300
commite7e6a3579d7ec3b61c80040c679c48c216fb7065 (patch)
treeec228601c62ac75235d708b6f627d8f22630614d /ext/openjpeg
parent539c032345e3f063b5c166262aa7f7346a0d1e2f (diff)
jpeg2000parse: use enums for colorspace and sampling, rather than strings
Also, move gstjpeg2000sampling to codecparsers project https://bugzilla.gnome.org/show_bug.cgi?id=767908
Diffstat (limited to 'ext/openjpeg')
-rw-r--r--ext/openjpeg/Makefile.am1
-rw-r--r--ext/openjpeg/gstopenjpegdec.c70
-rw-r--r--ext/openjpeg/gstopenjpegdec.h3
-rw-r--r--ext/openjpeg/gstopenjpegenc.c32
4 files changed, 37 insertions, 69 deletions
diff --git a/ext/openjpeg/Makefile.am b/ext/openjpeg/Makefile.am
index c3376f177..40aa8b4fc 100644
--- a/ext/openjpeg/Makefile.am
+++ b/ext/openjpeg/Makefile.am
@@ -4,6 +4,7 @@ libgstopenjpeg_la_SOURCES = gstopenjpegdec.c gstopenjpegenc.c gstopenjpeg.c
libgstopenjpeg_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(OPENJPEG_CFLAGS)
libgstopenjpeg_la_LIBADD = \
+ $(top_builddir)/gst-libs/gst/codecparsers/libgstcodecparsers-$(GST_API_VERSION).la \
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
$(GST_LIBS) $(OPENJPEG_LIBS)
libgstopenjpeg_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/ext/openjpeg/gstopenjpegdec.c b/ext/openjpeg/gstopenjpegdec.c
index b83318217..075bd12f8 100644
--- a/ext/openjpeg/gstopenjpegdec.c
+++ b/ext/openjpeg/gstopenjpegdec.c
@@ -25,7 +25,7 @@
#endif
#include "gstopenjpegdec.h"
-#include "../../gst/videoparsers/gstjpeg2000sampling.h"
+
#include <string.h>
@@ -49,41 +49,13 @@ static gboolean gst_openjpeg_dec_decide_allocation (GstVideoDecoder * decoder,
#define YUV10 "Y444_10BE, I422_10BE, I420_10BE"
#endif
-
-/* convenience methods */
-static gboolean
-gst_openjpeg_dec_is_rgb (const gchar * sampling)
-{
- return (!g_strcmp0 (sampling, GST_RTP_J2K_RGB) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_RGBA) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_BGR) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_BGRA));
-}
-
-static gboolean
-gst_openjpeg_dec_is_yuv (const gchar * sampling)
-{
- return (!g_strcmp0 (sampling, GST_RTP_J2K_YBRA) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_YBR444) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_YBR422) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_YBR420) ||
- !g_strcmp0 (sampling, GST_RTP_J2K_YBR410));
-}
-
-static gboolean
-gst_openjpeg_dec_is_mono (const gchar * sampling)
-{
- return !g_strcmp0 (sampling, GST_RTP_J2K_GRAYSCALE);
-}
-
-
static GstStaticPadTemplate gst_openjpeg_dec_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("image/x-j2c, "
- GST_RTP_J2K_SAMPLING_LIST "; "
- "image/x-jpc, " GST_RTP_J2K_SAMPLING_LIST "; " "image/jp2")
+ GST_JPEG2000_SAMPLING_LIST "; "
+ "image/x-jpc, " GST_JPEG2000_SAMPLING_LIST "; " "image/jp2")
);
static GstStaticPadTemplate gst_openjpeg_dec_src_template =
@@ -144,7 +116,7 @@ gst_openjpeg_dec_init (GstOpenJPEGDec * self)
#ifdef HAVE_OPENJPEG_1
self->params.cp_limit_decoding = NO_LIMITATION;
#endif
- self->sampling = NULL;
+ self->sampling = GST_JPEG2000_SAMPLING_NONE;
}
static gboolean
@@ -174,11 +146,6 @@ gst_openjpeg_dec_stop (GstVideoDecoder * video_decoder)
self->input_state = NULL;
}
- if (self->sampling) {
- g_free (self->sampling);
- self->sampling = NULL;
- }
-
GST_DEBUG_OBJECT (self, "Stopped");
return TRUE;
@@ -210,18 +177,17 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
g_return_val_if_reached (FALSE);
}
- if (self->sampling)
- g_free (self->sampling);
- self->sampling = g_strdup (gst_structure_get_string (s, "sampling"));
- /* note: self->sampling may be NULL, for case of JP2 */
- if (self->sampling) {
- if (gst_openjpeg_dec_is_rgb (self->sampling))
- self->color_space = OPJ_CLRSPC_SRGB;
- else if (gst_openjpeg_dec_is_mono (self->sampling))
- self->color_space = OPJ_CLRSPC_GRAY;
- else if (gst_openjpeg_dec_is_yuv (self->sampling))
- self->color_space = OPJ_CLRSPC_SYCC;
- }
+
+ self->sampling =
+ gst_jpeg2000_sampling_from_string (gst_structure_get_string (s,
+ "sampling"));
+ if (gst_jpeg2000_sampling_is_rgb (self->sampling))
+ self->color_space = OPJ_CLRSPC_SRGB;
+ else if (gst_jpeg2000_sampling_is_mono (self->sampling))
+ self->color_space = OPJ_CLRSPC_GRAY;
+ else if (gst_jpeg2000_sampling_is_yuv (self->sampling))
+ self->color_space = OPJ_CLRSPC_SYCC;
+
self->ncomps = 0;
gst_structure_get_int (s, "num-components", &self->ncomps);
@@ -233,10 +199,10 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
}
static gboolean
-reverse_rgb_channels (const gchar * sampling)
+reverse_rgb_channels (GstJPEG2000Sampling sampling)
{
- return (!g_strcmp0 (sampling, GST_RTP_J2K_BGR)
- || !g_strcmp0 (sampling, GST_RTP_J2K_BGRA));
+ return sampling == GST_JPEG2000_SAMPLING_BGR
+ || sampling == GST_JPEG2000_SAMPLING_BGRA;
}
static void
diff --git a/ext/openjpeg/gstopenjpegdec.h b/ext/openjpeg/gstopenjpegdec.h
index bab3f1367..789c7e77b 100644
--- a/ext/openjpeg/gstopenjpegdec.h
+++ b/ext/openjpeg/gstopenjpegdec.h
@@ -24,6 +24,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
+#include <gst-libs/gst/codecparsers/gstjpeg2000sampling.h>
#include "gstopenjpeg.h"
@@ -54,7 +55,7 @@ struct _GstOpenJPEGDec
OPJ_CODEC_FORMAT codec_format;
gboolean is_jp2c;
OPJ_COLOR_SPACE color_space;
- gchar *sampling;
+ GstJPEG2000Sampling sampling;
gint ncomps;
void (*fill_frame) (GstVideoFrame *frame, opj_image_t * image);
diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c
index 5a771ca1e..54aa7d5bc 100644
--- a/ext/openjpeg/gstopenjpegenc.c
+++ b/ext/openjpeg/gstopenjpegenc.c
@@ -25,7 +25,7 @@
#endif
#include "gstopenjpegenc.h"
-#include "../../gst/videoparsers/gstjpeg2000sampling.h"
+#include <gst-libs/gst/codecparsers/gstjpeg2000sampling.h>
#include <string.h>
@@ -116,14 +116,14 @@ static GstStaticPadTemplate gst_openjpeg_enc_src_template =
"width = (int) [1, MAX], "
"height = (int) [1, MAX], "
"num-components = (int) [1, 4], "
- GST_RTP_J2K_SAMPLING_LIST ","
- "colorspace = (string) { sRGB, sYUV, GRAY }; "
+ GST_JPEG2000_SAMPLING_LIST ","
+ GST_JPEG2000_COLORSPACE_LIST "; "
"image/x-jpc, "
"width = (int) [1, MAX], "
"height = (int) [1, MAX], "
"num-components = (int) [1, 4], "
- GST_RTP_J2K_SAMPLING_LIST ","
- "colorspace = (string) { sRGB, sYUV, GRAY }; "
+ GST_JPEG2000_SAMPLING_LIST ","
+ GST_JPEG2000_COLORSPACE_LIST "; "
"image/jp2, " "width = (int) [1, MAX], " "height = (int) [1, MAX]")
);
@@ -561,7 +561,7 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
GstCaps *allowed_caps, *caps;
GstStructure *s;
const gchar *colorspace = NULL;
- const gchar *sampling = NULL;
+ GstJPEG2000Sampling sampling = GST_JPEG2000_SAMPLING_NONE;
gint ncomps;
GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps);
@@ -640,38 +640,38 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
switch (state->info.finfo->format) {
case GST_VIDEO_FORMAT_ARGB64:
case GST_VIDEO_FORMAT_ARGB:
- sampling = GST_RTP_J2K_RGBA;
+ sampling = GST_JPEG2000_SAMPLING_RGBA;
break;
case GST_VIDEO_FORMAT_AYUV64:
case GST_VIDEO_FORMAT_AYUV:
- sampling = GST_RTP_J2K_YBRA;
+ sampling = GST_JPEG2000_SAMPLING_YBRA4444_EXT;
break;
case GST_VIDEO_FORMAT_xRGB:
- sampling = GST_RTP_J2K_RGB;
+ sampling = GST_JPEG2000_COLORSPACE_RGB;
break;
case GST_VIDEO_FORMAT_Y444_10LE:
case GST_VIDEO_FORMAT_Y444_10BE:
case GST_VIDEO_FORMAT_Y444:
- sampling = GST_RTP_J2K_YBR444;
+ sampling = GST_JPEG2000_SAMPLING_YBR444;
break;
case GST_VIDEO_FORMAT_I422_10LE:
case GST_VIDEO_FORMAT_I422_10BE:
case GST_VIDEO_FORMAT_Y42B:
- sampling = GST_RTP_J2K_YBR422;
+ sampling = GST_JPEG2000_SAMPLING_YBR422;
break;
case GST_VIDEO_FORMAT_YUV9:
- sampling = GST_RTP_J2K_YBR410;
+ sampling = GST_JPEG2000_SAMPLING_YBR410;
break;
case GST_VIDEO_FORMAT_I420_10LE:
case GST_VIDEO_FORMAT_I420_10BE:
case GST_VIDEO_FORMAT_I420:
- sampling = GST_RTP_J2K_YBR420;
+ sampling = GST_JPEG2000_SAMPLING_YBR420;
break;
case GST_VIDEO_FORMAT_GRAY8:
case GST_VIDEO_FORMAT_GRAY16_LE:
case GST_VIDEO_FORMAT_GRAY16_BE:
- sampling = GST_RTP_J2K_GRAYSCALE;
+ sampling = GST_JPEG2000_SAMPLING_GRAYSCALE;
break;
default:
break;
@@ -688,10 +688,10 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
} else
g_return_val_if_reached (FALSE);
- if (sampling) {
+ if (sampling != GST_JPEG2000_SAMPLING_NONE) {
caps = gst_caps_new_simple (gst_structure_get_name (s),
"colorspace", G_TYPE_STRING, colorspace,
- "sampling", G_TYPE_STRING, sampling,
+ "sampling", G_TYPE_STRING, gst_jpeg2000_sampling_to_string (sampling),
"num-components", G_TYPE_INT, ncomps, NULL);
} else {
caps = gst_caps_new_simple (gst_structure_get_name (s),