Commit e7e6a357 authored by Aaron Boxer's avatar Aaron Boxer Committed by Sebastian Dröge
Browse files

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
parent 539c0323
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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),
......
......@@ -6,6 +6,7 @@ libgstcodecparsers_@GST_API_VERSION@_la_SOURCES = \
parserutils.c nalutils.c dboolhuff.c vp8utils.c \
gstjpegparser.c \
gstmpegvideometa.c \
gstjpeg2000sampling.c \
gstvp9parser.c vp9utils.c
libgstcodecparsers_@GST_API_VERSION@includedir = \
......@@ -18,6 +19,7 @@ libgstcodecparsers_@GST_API_VERSION@include_HEADERS = \
gsth265parser.h gstvp8parser.h gstvp8rangedecoder.h \
gstjpegparser.h \
gstmpegvideometa.h \
gstjpeg2000sampling.h \
gstvp9parser.h
libgstcodecparsers_@GST_API_VERSION@_la_CFLAGS = \
......
/* GStreamer JPEG 2000 Sampling
* Copyright (C) <2016> Grok Image Compression Inc.
* @author Aaron Boxer <boxerab@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstjpeg2000sampling
* @short_description: Manage JPEG 2000 sampling and colorspace fields
*
*/
#include "gstjpeg2000sampling.h"
/* string values corresponding to GstJPEG2000Sampling enums */
static const gchar *gst_jpeg2000_sampling_strings[] = {
"RGB",
"BGR",
"RGBA",
"BGRA",
"YCbCr-4:4:4",
"YCbCr-4:2:2",
"YCbCr-4:2:0",
"YCbCr-4:1:0",
"GRAYSCALE",
"YCbCrA-4:4:4:4",
};
/* convert string to GstJPEG2000Sampling enum */
GstJPEG2000Sampling
gst_jpeg2000_sampling_from_string (const gchar * sampling_string)
{
GstJPEG2000Sampling i;
g_return_val_if_fail (sampling_string != NULL, GST_JPEG2000_SAMPLING_NONE);
for (i = 0; i < sizeof (gst_jpeg2000_sampling_strings); ++i) {
if (!g_strcmp0 (sampling_string, gst_jpeg2000_sampling_strings[i]))
return (i + 1);
}
return GST_JPEG2000_SAMPLING_NONE;
}
/* convert GstJPEG2000Sampling enum to string */
const gchar *
gst_jpeg2000_sampling_to_string (GstJPEG2000Sampling sampling)
{
g_return_val_if_fail (sampling > 0
&& sampling <= sizeof (gst_jpeg2000_sampling_strings), NULL);
return gst_jpeg2000_sampling_strings[sampling - 1];
}
/* check if @sampling is in RGB color space */
gboolean
gst_jpeg2000_sampling_is_rgb (GstJPEG2000Sampling sampling)
{
return sampling == GST_JPEG2000_SAMPLING_RGB ||
sampling == GST_JPEG2000_SAMPLING_RGBA ||
sampling == GST_JPEG2000_SAMPLING_BGR
|| sampling == GST_JPEG2000_SAMPLING_BGRA;
}
/* check if @sampling is in YUV color space */
gboolean
gst_jpeg2000_sampling_is_yuv (GstJPEG2000Sampling sampling)
{
return sampling = GST_JPEG2000_SAMPLING_YBRA4444_EXT ||
sampling == GST_JPEG2000_SAMPLING_YBR444 ||
sampling == GST_JPEG2000_SAMPLING_YBR422 ||
sampling == GST_JPEG2000_SAMPLING_YBR420
|| sampling == GST_JPEG2000_SAMPLING_YBR410;
}
/* check if @sampling is in GRAYSCALE color space */
gboolean
gst_jpeg2000_sampling_is_mono (GstJPEG2000Sampling sampling)
{
return sampling == GST_JPEG2000_SAMPLING_GRAYSCALE;
}
/* string values corresponding to GstJPEG2000Colorspace enums */
static const gchar *gst_jpeg2000_colorspace_strings[] = {
"sRGB",
"sYUV",
"GRAY",
};
/* convert GstJPEG2000Colorspace enum to string */
GstJPEG2000Colorspace
gst_jpeg2000_colorspace_from_string (const gchar * colorspace_string)
{
GstJPEG2000Colorspace i;
g_return_val_if_fail (colorspace_string != NULL,
GST_JPEG2000_COLORSPACE_NONE);
for (i = 0; i < sizeof (gst_jpeg2000_colorspace_strings); ++i) {
if (!g_strcmp0 (colorspace_string, gst_jpeg2000_colorspace_strings[i]))
return (i + 1);
}
return GST_JPEG2000_COLORSPACE_NONE;
}
/* convert string to GstJPEG2000Colorspace enum */
const gchar *
gst_jpeg2000_colorspace_to_string (GstJPEG2000Colorspace colorspace)
{
g_return_val_if_fail (colorspace >= 0
&& colorspace <= sizeof (gst_jpeg2000_colorspace_strings), NULL);
return gst_jpeg2000_colorspace_strings[colorspace - 1];
}
/* GStreamer JPEG 2000 Sampling
* Copyright (C) <2016> Grok Image Compression Inc.
* @author Aaron Boxer <boxerab@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_JPEG2000_SAMPLING_H__
#define __GST_JPEG2000_SAMPLING_H__
#include <gst/gst.h>
/**
* GstJPEG2000Sampling:
* Sampling values from RF 5371 for JPEG 2000 over RTP : https://datatracker.ietf.org/doc/rfc5371/C
* Note: sampling extensions that are not listed in the RFC are signified by an _EXT at the end of the enum
*
* @GST_JPEG2000_SAMPLING_NONE: no sampling
* @GST_JPEG2000_SAMPLING_RGB: standard Red, Green, Blue color space.
* @GST_JPEG2000_SAMPLING_BGR: standard Blue, Green, Red color space.
* @GST_JPEG2000_SAMPLING_RGBA: standard Red, Green, Blue, Alpha color space.
* @GST_JPEG2000_SAMPLING_BGRA: standard Blue, Green, Red, Alpha color space.
* @GST_JPEG2000_SAMPLING_YCbCr-4:4:4: standard YCbCr color space; no subsampling.
* @GST_JPEG2000_SAMPLING_YCbCr-4:2:2: standard YCbCr color space; Cb and Cr are subsampled horizontally by 1/2.
* @GST_JPEG2000_SAMPLING_YCbCr-4:2:0: standard YCbCr color space; Cb and Cr are subsampled horizontally and vertically by 1/2.
* @GST_JPEG2000_SAMPLING_YCbCr-4:1:1: standard YCbCr color space; Cb and Cr are subsampled vertically by 1/4.
* @GST_JPEG2000_SAMPLING_GRAYSCALE: basically, a single component image of just multilevels of grey.
* @GST_JPEG2000_SAMPLING_YBRA4444_EXT: standard YCbCr color space, alpha channel, no subsampling,
*/
typedef enum
{
GST_JPEG2000_SAMPLING_NONE,
GST_JPEG2000_SAMPLING_RGB,
GST_JPEG2000_SAMPLING_BGR,
GST_JPEG2000_SAMPLING_RGBA,
GST_JPEG2000_SAMPLING_BGRA,
GST_JPEG2000_SAMPLING_YBR444,
GST_JPEG2000_SAMPLING_YBR422,
GST_JPEG2000_SAMPLING_YBR420,
GST_JPEG2000_SAMPLING_YBR410,
GST_JPEG2000_SAMPLING_GRAYSCALE,
GST_JPEG2000_SAMPLING_YBRA4444_EXT
} GstJPEG2000Sampling;
/* GST_JPEG2000_SAMPLING_LIST: sampling strings in list form, for use in caps */
#define GST_JPEG2000_SAMPLING_LIST "sampling = (string) {\"RGB\", \"BGR\", \"RGBA\", \"BGRA\", \"YCbCr-4:4:4\", \"YCbCr-4:2:2\", \"YCbCr-4:2:0\", \"YCbCr-4:1:1\", \"GRAYSCALE\" , \"YCbCrA-4:4:4:4\"}"
const gchar *gst_jpeg2000_sampling_to_string (GstJPEG2000Sampling sampling);
GstJPEG2000Sampling gst_jpeg2000_sampling_from_string (const gchar *
sampling_string);
gboolean gst_jpeg2000_sampling_is_rgb (GstJPEG2000Sampling sampling);
gboolean gst_jpeg2000_sampling_is_yuv (GstJPEG2000Sampling sampling);
gboolean gst_jpeg2000_sampling_is_mono (GstJPEG2000Sampling sampling);
/**
* GstJPEG2000Colorspace:
* @GST_JPEG2000_COLORSPACE_NONE: no color space
* @GST_JPEG2000_COLORSPACE_RGB: standard RGB color space
* @GST_JPEG2000_COLORSPACE_YUV: standard YUV color space
* @GST_JPEG2000_COLORSPACE_GRAY: monochrome color space
*/
typedef enum
{
GST_JPEG2000_COLORSPACE_NONE,
GST_JPEG2000_COLORSPACE_RGB,
GST_JPEG2000_COLORSPACE_YUV,
GST_JPEG2000_COLORSPACE_GRAY
} GstJPEG2000Colorspace;
const gchar *gst_jpeg2000_colorspace_to_string (GstJPEG2000Colorspace
colorspace);
GstJPEG2000Colorspace gst_jpeg2000_colorspace_from_string (const gchar *
colorspace_string);
/* GST_JPEG2000_COLORSPACE_LIST: color space strings in list form, for use in caps */
#define GST_JPEG2000_COLORSPACE_LIST "colorspace = (string) { \"sRGB\", \"sYUV\", \"GRAY\" }"
#endif
......@@ -31,7 +31,6 @@ noinst_HEADERS = gsth263parse.h h263parse.h \
gsth264parse.h gstmpegvideoparse.h \
gstmpeg4videoparse.h \
gstjpeg2000parse.h \
gstjpeg2000sampling.h \
gstpngparse.h \
gstvc1parse.h \
gsth265parse.h
......@@ -26,44 +26,19 @@
#include <gst/base/base.h>
/* convenience methods */
static gboolean
gst_jpeg2000_parse_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_jpeg2000_parse_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_jpeg2000_parse_is_mono (const gchar * sampling)
{
return !g_strcmp0 (sampling, GST_RTP_J2K_GRAYSCALE);
}
static void
gst_jpeg2000_parse_get_subsampling (const gchar * sampling, guint8 * dx,
gst_jpeg2000_parse_get_subsampling (GstJPEG2000Sampling sampling, guint8 * dx,
guint8 * dy)
{
*dx = 1;
*dy = 1;
if (!g_strcmp0 (sampling, GST_RTP_J2K_YBR422)) {
if (sampling == GST_JPEG2000_SAMPLING_YBR422) {
*dx = 2;
} else if (!g_strcmp0 (sampling, GST_RTP_J2K_YBR420)) {
} else if (sampling == GST_JPEG2000_SAMPLING_YBR420) {
*dx = 2;
*dy = 2;
} else if (!g_strcmp0 (sampling, GST_RTP_J2K_YBR410)) {
} else if (sampling == GST_JPEG2000_SAMPLING_YBR410) {
*dx = 4;
*dy = 2;
}
......@@ -88,26 +63,25 @@ static GstStaticPadTemplate srctemplate =
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("image/x-jpc,"
" width = (int)[1, MAX], height = (int)[1, MAX],"
GST_RTP_J2K_SAMPLING_LIST ","
"colorspace = (string) { sRGB, sYUV, GRAY }, "
GST_JPEG2000_SAMPLING_LIST ","
GST_JPEG2000_COLORSPACE_LIST ","
" parsed = (boolean) true;"
"image/x-j2c,"
" width = (int)[1, MAX], height = (int)[1, MAX],"
GST_RTP_J2K_SAMPLING_LIST ","
"colorspace = (string) { sRGB, sYUV, GRAY }, "
" parsed = (boolean) true")
GST_JPEG2000_SAMPLING_LIST ","
GST_JPEG2000_COLORSPACE_LIST "," " parsed = (boolean) true")
);
static GstStaticPadTemplate sinktemplate =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("image/x-jpc,"
GST_RTP_J2K_SAMPLING_LIST ";"
GST_JPEG2000_SAMPLING_LIST ";"
"image/x-jpc, "
"colorspace = (string) { sRGB, sYUV, GRAY };"
GST_JPEG2000_COLORSPACE_LIST ";"
"image/x-j2c,"
GST_RTP_J2K_SAMPLING_LIST ";"
"image/x-j2c, " "colorspace = (string) { sRGB, sYUV, GRAY }")
GST_JPEG2000_SAMPLING_LIST ";"
"image/x-j2c, " GST_JPEG2000_COLORSPACE_LIST)
);
#define parent_class gst_jpeg2000_parse_parent_class
......@@ -155,8 +129,8 @@ gst_jpeg2000_parse_start (GstBaseParse * parse)
jpeg2000parse->width = 0;
jpeg2000parse->height = 0;
jpeg2000parse->sampling = NULL;
jpeg2000parse->colorspace = NULL;
jpeg2000parse->sampling = GST_JPEG2000_SAMPLING_NONE;
jpeg2000parse->colorspace = GST_JPEG2000_COLORSPACE_NONE;
jpeg2000parse->codec_format = GST_JPEG2000_PARSE_NO_CODEC;
return TRUE;
}
......@@ -212,16 +186,16 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
guint eoc_offset = 0;
GstCaps *current_caps = NULL;
GstStructure *current_caps_struct = NULL;
const gchar *colorspace = NULL;
GstJPEG2000Colorspace colorspace = GST_JPEG2000_COLORSPACE_NONE;
guint x0, y0, x1, y1;
guint width = 0, height = 0;
guint8 dx[GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS];
guint8 dy[GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS];
guint16 numcomps;
guint16 compno;
const char *parsed_sampling = NULL;
const char *sink_sampling = NULL;
const char *source_sampling = NULL;
GstJPEG2000Sampling parsed_sampling = GST_JPEG2000_SAMPLING_NONE;
GstJPEG2000Sampling sink_sampling = GST_JPEG2000_SAMPLING_NONE;
GstJPEG2000Sampling source_sampling = GST_JPEG2000_SAMPLING_NONE;
guint magic_offset = 0;
guint j2c_box_id_offset = 0;
guint num_prefix_bytes = 0; /* number of bytes to skip before actual code stream */
......@@ -367,8 +341,12 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
goto beach;
}
colorspace = gst_structure_get_string (current_caps_struct, "colorspace");
sink_sampling = gst_structure_get_string (current_caps_struct, "sampling");
colorspace =
gst_jpeg2000_colorspace_from_string (gst_structure_get_string
(current_caps_struct, "colorspace"));
sink_sampling =
gst_jpeg2000_sampling_from_string (gst_structure_get_string
(current_caps_struct, "sampling"));
for (compno = 0; compno < numcomps; ++compno) {
......@@ -396,30 +374,32 @@ gst_jpeg2000_parse_handle_frame (GstBaseParse * parse,
"Chroma channel sub-sampling factors are not equal");
}
for (compno = 0; compno < numcomps; ++compno) {
if (colorspace && g_strcmp0 (colorspace, "sYUV") && (dx[compno] > 1