video: add colorimetry info

Make enums for the chroma siting for easier use in the videoinfo.
Make enums for the color range, color matrix, transfer function and the
color primaries. Add these values to the video info structure in a Colorimetry
structure. These values define the exact colors and are needed to perform
correct colorspace conversion. Use a couple of predefined colorimetry specs
because in practice only a few combinations are in use.
Add view_id to the video frames to identify the view this frame represents in
multiview video.
Remove old gst_video_parse_caps_framerate, use the videoinfo for this.
Port elements to new colorimetry info.
Remove deprecated colorspace property from videotestsrc.
This commit is contained in:
Wim Taymans 2011-08-23 18:57:35 +02:00
parent 2ce5c8b8be
commit 9ad89374a3
8 changed files with 355 additions and 155 deletions

View file

@ -955,8 +955,24 @@ theora_handle_type_packet (GstTheoraDec * dec, ogg_packet * packet)
dec->vinfo.fps_d = dec->info.fps_denominator; dec->vinfo.fps_d = dec->info.fps_denominator;
dec->vinfo.par_n = par_num; dec->vinfo.par_n = par_num;
dec->vinfo.par_d = par_den; dec->vinfo.par_d = par_den;
dec->vinfo.chroma_site = "jpeg";
dec->vinfo.color_matrix = "sdtv"; /* these values are for all versions of the colorspace specified in the
* theora info */
dec->vinfo.chroma_site = GST_VIDEO_CHROMA_JPEG;
dec->vinfo.colorimetry.range = GST_VIDEO_COLOR_RANGE_16_235;
dec->vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
dec->vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
switch (dec->info.colorspace) {
case TH_CS_ITU_REC_470M:
dec->vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470M;
break;
case TH_CS_ITU_REC_470BG:
dec->vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470BG;
break;
default:
dec->vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
break;
}
caps = gst_video_info_to_caps (&dec->vinfo); caps = gst_video_info_to_caps (&dec->vinfo);
gst_pad_set_caps (dec->srcpad, caps); gst_pad_set_caps (dec->srcpad, caps);

View file

@ -608,6 +608,145 @@ gst_video_info_set_format (GstVideoInfo * info, GstVideoFormat format,
fill_planes (info); fill_planes (info);
} }
static GstVideoChromaSite
gst_video_chroma_from_string (const gchar * s)
{
GstVideoChromaSite res;
if (g_str_equal (s, "jpeg")) {
res = GST_VIDEO_CHROMA_JPEG;
} else if (g_str_equal (s, "mpeg2")) {
res = GST_VIDEO_CHROMA_MPEG2;
} else if (g_str_equal (s, "dv")) {
res = GST_VIDEO_CHROMA_DV;
} else {
res = GST_VIDEO_CHROMA_NONE;
}
return res;
}
static const gchar *
gst_video_chroma_to_string (GstVideoChromaSite site)
{
const gchar *res;
switch (site) {
case GST_VIDEO_CHROMA_JPEG:
res = "jpeg";
break;
case GST_VIDEO_CHROMA_MPEG2:
res = "mpeg2";
break;
case GST_VIDEO_CHROMA_DV:
res = "dv";
break;
default:
res = NULL;
break;
}
return res;
}
typedef struct
{
const gchar *name;
GstVideoColorimetry color;
} ColorimetryInfo;
#define MAKE_COLORIMETRY(n,r,m,t,p) { GST_VIDEO_COLORIMETRY_ ##n, \
{ GST_VIDEO_COLOR_RANGE_ ##r, GST_VIDEO_COLOR_MATRIX_ ##m, \
GST_VIDEO_TRANSFER_ ##t, GST_VIDEO_COLOR_PRIMARIES_ ##p } }
static const ColorimetryInfo colorimetry[] = {
MAKE_COLORIMETRY (BT601, 16 _235, BT601, BT709, BT470M),
MAKE_COLORIMETRY (BT709, 16 _235, BT709, BT709, BT709),
MAKE_COLORIMETRY (SMPTE240M, 16 _235, SMPTE240M, SMPTE240M, SMPTE240M),
{NULL,}
};
static const ColorimetryInfo *
gst_video_get_colorimetry (const gchar * s)
{
gint i;
for (i = 0; colorimetry[i].name; i++) {
if (g_str_equal (colorimetry[i].name, s))
return &colorimetry[i];
}
return NULL;
}
#define IS_EQUAL(ci,i) (((ci)->color.range == (i)->range) && \
((ci)->color.matrix == (i)->matrix) && \
((ci)->color.transfer == (i)->transfer) && \
((ci)->color.primaries == (i)->primaries))
/**
* gst_video_colorimetry_from_string
* @cinfo: a #GstVideoColorimetry
* @color: a colorimetry string
*
* Parse the colorimetry string and update @cinfo with the parsed
* values.
*
* Returns: #TRUE if @color points to valid colorimetry info.
*/
gboolean
gst_video_colorimetry_from_string (GstVideoColorimetry * cinfo,
const gchar * color)
{
const ColorimetryInfo *ci;
if ((ci = gst_video_get_colorimetry (color))) {
*cinfo = ci->color;
} else {
/* FIXME, split and parse */
cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT601;
cinfo->transfer = GST_VIDEO_TRANSFER_BT709;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
}
return TRUE;
}
static void
gst_video_caps_set_colorimetry (GstCaps * caps, GstVideoColorimetry * cinfo)
{
gint i;
for (i = 0; colorimetry[i].name; i++) {
if (IS_EQUAL (&colorimetry[i], cinfo)) {
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING,
colorimetry[i].name, NULL);
return;
}
}
/* FIXME, construct colorimetry */
}
/**
* gst_video_colorimetry_matches:
* @info: a #GstVideoInfo
* @color: a colorimetry string
*
* Check if the colorimetry information in @info matches that of the
* string @color.
*
* Returns: #TRUE if @color conveys the same colorimetry info as the color
* information in @info.
*/
gboolean
gst_video_colorimetry_matches (GstVideoColorimetry * cinfo, const gchar * color)
{
const ColorimetryInfo *ci;
if ((ci = gst_video_get_colorimetry (color)))
return IS_EQUAL (ci, cinfo);
return FALSE;
}
/** /**
* gst_video_info_from_caps: * gst_video_info_from_caps:
* @info: a #GstVideoInfo * @info: a #GstVideoInfo
@ -673,17 +812,11 @@ gst_video_info_from_caps (GstVideoInfo * info, const GstCaps * caps)
else else
info->views = 1; info->views = 1;
s = gst_structure_get_string (structure, "color-matrix"); if ((s = gst_structure_get_string (structure, "chroma-site")))
if (s) info->chroma_site = gst_video_chroma_from_string (s);
info->color_matrix = s;
else
info->color_matrix = "sdtv";
s = gst_structure_get_string (structure, "chroma-site"); if ((s = gst_structure_get_string (structure, "colorimetry")))
if (s) gst_video_colorimetry_from_string (&info->colorimetry, s);
info->chroma_site = s;
else
info->chroma_site = "mpeg2";
if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", if (gst_structure_get_fraction (structure, "pixel-aspect-ratio",
&par_n, &par_d)) { &par_n, &par_d)) {
@ -750,14 +883,16 @@ gst_video_info_to_caps (GstVideoInfo * info)
"height", G_TYPE_INT, info->height, "height", G_TYPE_INT, info->height,
"framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d, "framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d,
"pixel-aspect-ratio", GST_TYPE_FRACTION, info->par_n, info->par_d, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, info->par_n, info->par_d, NULL);
if (info->flags & GST_VIDEO_FLAG_INTERLACED) if (info->flags & GST_VIDEO_FLAG_INTERLACED)
gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, TRUE, NULL); gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, TRUE, NULL);
if (info->color_matrix)
gst_caps_set_simple (caps, "color-matrix", G_TYPE_STRING, if (info->chroma_site != GST_VIDEO_CHROMA_UNKNOWN)
info->color_matrix, NULL); gst_caps_set_simple (caps, "chroma-site", G_TYPE_STRING,
if (info->chroma_site) gst_video_chroma_to_string (info->chroma_site), NULL);
gst_caps_set_simple (caps, "chroma-site", G_TYPE_STRING, info->chroma_site,
NULL); gst_video_caps_set_colorimetry (caps, &info->colorimetry);
if (info->views > 1) if (info->views > 1)
gst_caps_set_simple (caps, "views", G_TYPE_INT, info->views, NULL); gst_caps_set_simple (caps, "views", G_TYPE_INT, info->views, NULL);
@ -1299,36 +1434,6 @@ gst_video_event_parse_still_frame (GstEvent * event, gboolean * in_still)
return TRUE; return TRUE;
} }
/**
* gst_video_parse_caps_framerate:
* @caps: pointer to a #GstCaps instance
* @fps_n: pointer to integer to hold numerator of frame rate (output)
* @fps_d: pointer to integer to hold denominator of frame rate (output)
*
* Extracts the frame rate from @caps and places the values in the locations
* pointed to by @fps_n and @fps_d. Returns TRUE if the values could be
* parsed correctly, FALSE if not.
*
* This function can be used with #GstCaps that have any media type; it
* is not limited to formats handled by #GstVideoFormat.
*
* Since: 0.10.16
*
* Returns: TRUE if @caps was parsed correctly.
*/
gboolean
gst_video_parse_caps_framerate (GstCaps * caps, int *fps_n, int *fps_d)
{
GstStructure *structure;
if (!gst_caps_is_fixed (caps))
return FALSE;
structure = gst_caps_get_structure (caps, 0);
return gst_structure_get_fraction (structure, "framerate", fps_n, fps_d);
}
/** /**
* gst_video_parse_caps_palette: * gst_video_parse_caps_palette:
* @caps: #GstCaps to parse * @caps: #GstCaps to parse
@ -1356,7 +1461,7 @@ gst_video_parse_caps_palette (GstCaps * caps)
if (!p_v || !GST_VALUE_HOLDS_BUFFER (p_v)) if (!p_v || !GST_VALUE_HOLDS_BUFFER (p_v))
return NULL; return NULL;
p = gst_buffer_ref (gst_value_get_buffer (p_v)); p = g_value_dup_boxed (p_v);
return p; return p;
} }

View file

@ -323,6 +323,146 @@ typedef enum {
GST_VIDEO_FLAG_PROGRESSIVE = (1 << 5) GST_VIDEO_FLAG_PROGRESSIVE = (1 << 5)
} GstVideoFlags; } GstVideoFlags;
/**
* GstVideoChroma:
* @GST_VIDEO_CHROMA_UNKNOWN: unknown cositing
* @GST_VIDEO_CHROMA_NONE: no cositing
* @GST_VIDEO_CHROMA_H_COSITED: chroma is horizontally cosited
* @GST_VIDEO_CHROMA_V_COSITED: chroma is vertically cosited
* @GST_VIDEO_CHROMA_ALT_LINE: choma samples are sited on alternate lines
* @GST_VIDEO_CHROMA_COSITED: chroma samples cosited with luma samples
* @GST_VIDEO_CHROMA_JPEG: jpeg style cositing, also for mpeg1 and mjpeg
* @GST_VIDEO_CHROMA_MPEG2: mpeg2 style cositing
* @GST_VIDEO_CHROMA_DV: DV style cositing
*
* Various Chroma sitings.
*/
typedef enum {
GST_VIDEO_CHROMA_UNKNOWN = 0,
GST_VIDEO_CHROMA_NONE = (1 << 0),
GST_VIDEO_CHROMA_H_COSITED = (1 << 1),
GST_VIDEO_CHROMA_V_COSITED = (1 << 2),
GST_VIDEO_CHROMA_ALT_LINE = (1 << 3),
/* some common chroma cositing */
GST_VIDEO_CHROMA_COSITED = (GST_VIDEO_CHROMA_H_COSITED | GST_VIDEO_CHROMA_V_COSITED),
GST_VIDEO_CHROMA_JPEG = (GST_VIDEO_CHROMA_NONE),
GST_VIDEO_CHROMA_MPEG2 = (GST_VIDEO_CHROMA_H_COSITED),
GST_VIDEO_CHROMA_DV = (GST_VIDEO_CHROMA_COSITED | GST_VIDEO_CHROMA_ALT_LINE),
} GstVideoChromaSite;
/**
* GstVideoColorRange:
* @GST_VIDEO_COLOR_RANGE_UNKNOWN: unknown range
* @GST_VIDEO_COLOR_RANGE_0_255: [0..255] for 8 bit components
* @GST_VIDEO_COLOR_RANGE_16_235: [16..235] for 8 bit components. Chroma has
* [16..240] range.
*
* Possible color range values. These constants are defined for 8 bit color
* values and can be scaled for other bit depths.
*/
typedef enum {
GST_VIDEO_COLOR_RANGE_UNKNOWN = 0,
GST_VIDEO_COLOR_RANGE_0_255,
GST_VIDEO_COLOR_RANGE_16_235
} GstVideoColorRange;
/**
* GstVideoColorMatrix:
* @GST_VIDEO_COLOR_MATRIX_UNKNOWN: unknown matrix
* @GST_VIDEO_COLOR_MATRIX_RGB: identity matrix
* @GST_VIDEO_COLOR_MATRIX_BT709: ITU-R BT.709 transfer matrix
* @GST_VIDEO_COLOR_MATRIX_BT601: ITU-R BT.601 transfer matrix
* @GST_VIDEO_COLOR_MATRIX_SMPTE240M: SMPTE 240M transfer matrix
*
* The color matrix is used to convert between Y'PbPr and
* non-linear RGB (R'G'B')
*/
typedef enum {
GST_VIDEO_COLOR_MATRIX_UNKNOWN = 0,
GST_VIDEO_COLOR_MATRIX_RGB,
GST_VIDEO_COLOR_MATRIX_BT709,
GST_VIDEO_COLOR_MATRIX_BT601,
GST_VIDEO_COLOR_MATRIX_SMPTE240M
} GstVideoColorMatrix;
/**
* GstVideoTransferFunction:
* GST_VIDEO_TRANSFER_UNKNOWN: unknown transfer function
* GST_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve
* GST_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve
* GST_VIDEO_TRANSFER_GAMMA20: Gamma 2.0 curve
* GST_VIDEO_TRANSFER_GAMMA22: Gamma 2.2 curve
* GST_VIDEO_TRANSFER_BT709: Gamma 2.2 curve with a linear segment in the lower
* range
* GST_VIDEO_TRANSFER_SMPTE240M: Gamma 2.2 curve with a linear segment in the
* lower range
* GST_VIDEO_TRANSFER_SRGB: Gamma 2.4 curve with a linear segment in the lower
* range
* GST_VIDEO_TRANSFER_GAMMA28: Gamma 2.8 curve
*
* The video transfer function defines the formula for converting between
* non-linear RGB (R'G'B') and linear RGB
*/
typedef enum {
GST_VIDEO_TRANSFER_UNKNOWN = 0,
GST_VIDEO_TRANSFER_GAMMA10,
GST_VIDEO_TRANSFER_GAMMA18,
GST_VIDEO_TRANSFER_GAMMA20,
GST_VIDEO_TRANSFER_GAMMA22,
GST_VIDEO_TRANSFER_BT709,
GST_VIDEO_TRANSFER_SMPTE240M,
GST_VIDEO_TRANSFER_SRGB,
GST_VIDEO_TRANSFER_GAMMA28
} GstVideoTransferFunction;
/**
* GstVideoColorPrimaries:
* @GST_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries
* @GST_VIDEO_COLOR_PRIMARIES_BT601:
* @GST_VIDEO_COLOR_PRIMARIES_BT470M:
* @GST_VIDEO_COLOR_PRIMARIES_BT470BG:
* @GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
* @GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
*
* The color primaries define the how to transform linear RGB values to and from
* the CIE XYZ colorspace.
*/
typedef enum {
GST_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,
GST_VIDEO_COLOR_PRIMARIES_BT709,
GST_VIDEO_COLOR_PRIMARIES_BT470M,
GST_VIDEO_COLOR_PRIMARIES_BT470BG,
GST_VIDEO_COLOR_PRIMARIES_SMPTE170M,
GST_VIDEO_COLOR_PRIMARIES_SMPTE240M
} GstVideoColorPrimaries;
/**
* GstVideoColorimetry:
* @range: the color range. This is the valid range for the samples.
* It is used to convert the samples to Y'PbPr values.
* @matrix: the color matrix. Used to convert between Y'PbPr and
* non-linear RGB (R'G'B')
* @transfer: the transfer function. used to convert between R'G'B' and RGB
* @primaries: color primaries. used to convert between R'G'B' and CIE XYZ
*
* Structure describing the color info.
*/
typedef struct {
GstVideoColorRange range;
GstVideoColorMatrix matrix;
GstVideoTransferFunction transfer;
GstVideoColorPrimaries primaries;
} GstVideoColorimetry;
/* predefined colorimetry */
#define GST_VIDEO_COLORIMETRY_BT601 "bt601"
#define GST_VIDEO_COLORIMETRY_BT709 "bt709"
#define GST_VIDEO_COLORIMETRY_SMPTE240M "smpte240m"
gboolean gst_video_colorimetry_matches (GstVideoColorimetry *cinfo, const gchar *color);
gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
gchar * gst_video_colorimetry_to_string (GstVideoColorimetry *cinfo);
/** /**
* GstVideoInfo: * GstVideoInfo:
* @finfo: the format info of the video * @finfo: the format info of the video
@ -331,15 +471,11 @@ typedef enum {
* @height: the height of the video * @height: the height of the video
* @views: the number of views for multiview video * @views: the number of views for multiview video
* @size: the default size of one frame * @size: the default size of one frame
* @color_matrix: the color matrix. Possible values are * @chroma_site: a #GstVideoChromaSite.
* "sdtv" for the standard definition color matrix (as specified in * @color_range: the color range. This is the valid range for the samples.
* Rec. ITU-R BT.470-6) or "hdtv" for the high definition color * @color_matrix: the color matrix. Used to transform to non-linear RGB (R'G'B')
* matrix (as specified in Rec. ITU-R BT.709) * @transfer_function: the transfer function. used to convert betwen R'G'B' and RGB
* @chroma_site: the chroma siting. Possible values are * @color_primaries: color primaries. used to convert to CIE XYZ
* "mpeg2" for MPEG-2 style chroma siting (co-sited horizontally,
* halfway-sited vertically), "jpeg" for JPEG and Theora style
* chroma siting (halfway-sited both horizontally and vertically).
* Other chroma site values are possible, but uncommon.
* @palette: a buffer with palette data * @palette: a buffer with palette data
* @par_n: the pixel-aspect-ratio numerator * @par_n: the pixel-aspect-ratio numerator
* @par_d: the pixel-aspect-ratio demnominator * @par_d: the pixel-aspect-ratio demnominator
@ -363,8 +499,9 @@ struct _GstVideoInfo {
gsize size; gsize size;
gint views; gint views;
const gchar *color_matrix; GstVideoChromaSite chroma_site;
const gchar *chroma_site; GstVideoColorimetry colorimetry;
GstBuffer *palette; GstBuffer *palette;
gint par_n; gint par_n;
@ -429,6 +566,7 @@ gboolean gst_video_info_convert (GstVideoInfo *info,
* @info: the #GstVideoInfo * @info: the #GstVideoInfo
* @buffer: the mapped buffer * @buffer: the mapped buffer
* @meta: pointer to metadata if any * @meta: pointer to metadata if any
* @view_id: id of the view in multiview
* @data: pointers to the plane data * @data: pointers to the plane data
* *
* A video frame obtained from gst_video_frame_map() * A video frame obtained from gst_video_frame_map()
@ -438,6 +576,7 @@ struct _GstVideoFrame {
GstBuffer *buffer; GstBuffer *buffer;
gpointer meta; gpointer meta;
gint view_id;
gpointer data[GST_VIDEO_MAX_PLANES]; gpointer data[GST_VIDEO_MAX_PLANES];
}; };
@ -545,7 +684,6 @@ gboolean gst_video_calculate_display_ratio (guint * dar_n,
guint display_par_n, guint display_par_n,
guint display_par_d); guint display_par_d);
gboolean gst_video_parse_caps_framerate (GstCaps * caps, int *fps_n, int *fps_d);
GstBuffer * gst_video_parse_caps_palette (GstCaps * caps); GstBuffer * gst_video_parse_caps_palette (GstCaps * caps);
/* video still frame event creation and parsing */ /* video still frame event creation and parsing */

View file

@ -868,7 +868,6 @@ _pad_blocked_cb (GstPad * pad, GstProbeType type, gpointer type_data,
video_peer = gst_pad_get_peer (self->video_sinkpad); video_peer = gst_pad_get_peer (self->video_sinkpad);
if (video_peer) { if (video_peer) {
GstCaps *video_caps; GstCaps *video_caps;
gint fps_n, fps_d;
video_caps = gst_pad_get_current_caps (video_peer); video_caps = gst_pad_get_current_caps (video_peer);
if (!video_caps) { if (!video_caps) {
@ -879,12 +878,16 @@ _pad_blocked_cb (GstPad * pad, GstProbeType type, gpointer type_data,
} }
} }
if (video_caps if (video_caps) {
&& gst_video_parse_caps_framerate (video_caps, &fps_n, &fps_d)) { GstVideoInfo info;
if (self->fps_n != fps_n || self->fps_d != fps_d) {
GST_DEBUG_OBJECT (self, "New video fps: %d/%d", fps_n, fps_d); if (gst_video_info_from_caps (&info, video_caps)) {
self->fps_n = fps_n; if (self->fps_n != info.fps_n || self->fps_d != info.fps_d) {
self->fps_d = fps_d; GST_DEBUG_OBJECT (self, "New video fps: %d/%d", info.fps_n,
info.fps_d);
self->fps_n = info.fps_n;
self->fps_d = info.fps_d;
}
} }
} }
@ -1604,21 +1607,21 @@ gst_subtitle_overlay_video_sink_setcaps (GstSubtitleOverlay * self,
GstCaps * caps) GstCaps * caps)
{ {
gboolean ret = TRUE; gboolean ret = TRUE;
gint fps_n, fps_d; GstVideoInfo info;
GST_DEBUG_OBJECT (self, "Setting caps: %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (self, "Setting caps: %" GST_PTR_FORMAT, caps);
if (!gst_video_parse_caps_framerate (caps, &fps_n, &fps_d)) { if (!gst_video_info_from_caps (&info, caps)) {
GST_ERROR_OBJECT (self, "Failed to parse framerate from caps"); GST_ERROR_OBJECT (self, "Failed to parse caps");
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
GST_SUBTITLE_OVERLAY_LOCK (self); GST_SUBTITLE_OVERLAY_LOCK (self);
if (self->fps_n != fps_n || self->fps_d != fps_d) { if (self->fps_n != info.fps_n || self->fps_d != info.fps_d) {
GST_DEBUG_OBJECT (self, "New video fps: %d/%d", fps_n, fps_d); GST_DEBUG_OBJECT (self, "New video fps: %d/%d", info.fps_n, info.fps_d);
self->fps_n = fps_n; self->fps_n = info.fps_n;
self->fps_d = fps_d; self->fps_d = info.fps_d;
gst_subtitle_overlay_set_fps (self); gst_subtitle_overlay_set_fps (self);
} }
GST_SUBTITLE_OVERLAY_UNLOCK (self); GST_SUBTITLE_OVERLAY_UNLOCK (self);

View file

@ -123,7 +123,7 @@ gst_video_convert_caps_remove_format_info (GstCaps * caps)
st = gst_structure_copy (st); st = gst_structure_copy (st);
gst_structure_remove_fields (st, "format", "palette_data", gst_structure_remove_fields (st, "format", "palette_data",
"color-matrix", "chroma-site", NULL); "colorimetry", "chroma-site", NULL);
gst_caps_append_structure (res, st); gst_caps_append_structure (res, st);
} }
@ -203,7 +203,7 @@ gst_video_convert_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
if (in_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_RGB) { if (in_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_RGB) {
in_spec = COLOR_SPEC_RGB; in_spec = COLOR_SPEC_RGB;
} else if (in_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_YUV) { } else if (in_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_YUV) {
if (in_info.color_matrix && g_str_equal (in_info.color_matrix, "hdtv")) if (in_info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT709)
in_spec = COLOR_SPEC_YUV_BT709; in_spec = COLOR_SPEC_YUV_BT709;
else else
in_spec = COLOR_SPEC_YUV_BT470_6; in_spec = COLOR_SPEC_YUV_BT470_6;
@ -218,7 +218,7 @@ gst_video_convert_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
if (out_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_RGB) { if (out_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_RGB) {
out_spec = COLOR_SPEC_RGB; out_spec = COLOR_SPEC_RGB;
} else if (out_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_YUV) { } else if (out_info.finfo->flags & GST_VIDEO_FORMAT_FLAG_YUV) {
if (out_info.color_matrix && g_str_equal (out_info.color_matrix, "hdtv")) if (out_info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT709)
out_spec = COLOR_SPEC_YUV_BT709; out_spec = COLOR_SPEC_YUV_BT709;
else else
out_spec = COLOR_SPEC_YUV_BT470_6; out_spec = COLOR_SPEC_YUV_BT470_6;

View file

@ -60,7 +60,6 @@ enum
PROP_PATTERN, PROP_PATTERN,
PROP_TIMESTAMP_OFFSET, PROP_TIMESTAMP_OFFSET,
PROP_IS_LIVE, PROP_IS_LIVE,
PROP_COLOR_SPEC,
PROP_K0, PROP_K0,
PROP_KX, PROP_KX,
PROP_KY, PROP_KY,
@ -147,24 +146,6 @@ gst_video_test_src_pattern_get_type (void)
return video_test_src_pattern_type; return video_test_src_pattern_type;
} }
#define GST_TYPE_VIDEO_TEST_SRC_COLOR_SPEC (gst_video_test_src_color_spec_get_type ())
static GType
gst_video_test_src_color_spec_get_type (void)
{
static GType video_test_src_color_spec_type = 0;
static const GEnumValue color_spec_types[] = {
{GST_VIDEO_TEST_SRC_BT601, "ITU-R Rec. BT.601", "bt601"},
{GST_VIDEO_TEST_SRC_BT709, "ITU-R Rec. BT.709", "bt709"},
{0, NULL, NULL}
};
if (!video_test_src_color_spec_type) {
video_test_src_color_spec_type =
g_enum_register_static ("GstVideoTestSrcColorSpec", color_spec_types);
}
return video_test_src_color_spec_type;
}
static void static void
gst_video_test_src_class_init (GstVideoTestSrcClass * klass) gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
{ {
@ -194,13 +175,6 @@ gst_video_test_src_class_init (GstVideoTestSrcClass * klass)
g_param_spec_boolean ("is-live", "Is Live", g_param_spec_boolean ("is-live", "Is Live",
"Whether to act as a live source", DEFAULT_IS_LIVE, "Whether to act as a live source", DEFAULT_IS_LIVE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_COLOR_SPEC,
g_param_spec_enum ("colorspec", "Color Specification",
"Generate video in the given color specification (Deprecated: "
"use a caps filter with video/x-raw-yuv,color-matrix=\"sdtv\" or "
"\"hdtv\" instead)",
GST_TYPE_VIDEO_TEST_SRC_COLOR_SPEC,
DEFAULT_COLOR_SPEC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_K0, g_object_class_install_property (gobject_class, PROP_K0,
g_param_spec_int ("k0", "Zoneplate zero order phase", g_param_spec_int ("k0", "Zoneplate zero order phase",
"Zoneplate zero order phase, for generating plain fields or phase offsets", "Zoneplate zero order phase, for generating plain fields or phase offsets",
@ -340,8 +314,8 @@ gst_video_test_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
if (gst_structure_has_field (structure, "pixel-aspect-ratio")) if (gst_structure_has_field (structure, "pixel-aspect-ratio"))
gst_structure_fixate_field_nearest_fraction (structure, gst_structure_fixate_field_nearest_fraction (structure,
"pixel-aspect-ratio", 1, 1); "pixel-aspect-ratio", 1, 1);
if (gst_structure_has_field (structure, "color-matrix")) if (gst_structure_has_field (structure, "colorimetry"))
gst_structure_fixate_field_string (structure, "color-matrix", "sdtv"); gst_structure_fixate_field_string (structure, "colorimetry", "bt601");
if (gst_structure_has_field (structure, "chroma-site")) if (gst_structure_has_field (structure, "chroma-site"))
gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2"); gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2");
@ -444,8 +418,6 @@ gst_video_test_src_set_property (GObject * object, guint prop_id,
case PROP_IS_LIVE: case PROP_IS_LIVE:
gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value)); gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
break; break;
case PROP_COLOR_SPEC:
break;
case PROP_K0: case PROP_K0:
src->k0 = g_value_get_int (value); src->k0 = g_value_get_int (value);
break; break;
@ -511,8 +483,6 @@ gst_video_test_src_get_property (GObject * object, guint prop_id,
case PROP_IS_LIVE: case PROP_IS_LIVE:
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src))); g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
break; break;
case PROP_COLOR_SPEC:
break;
case PROP_K0: case PROP_K0:
g_value_set_int (value, src->k0); g_value_set_int (value, src->k0);
break; break;
@ -564,23 +534,6 @@ gst_video_test_src_get_property (GObject * object, guint prop_id,
} }
} }
static GstVideoTestSrcColorSpec
to_color_spec (const gchar * csp)
{
if (csp) {
if (strcmp (csp, "sdtv") == 0) {
return GST_VIDEO_TEST_SRC_BT601;
} else if (strcmp (csp, "hdtv") == 0) {
return GST_VIDEO_TEST_SRC_BT709;
} else {
GST_DEBUG ("unknown color-matrix");
return GST_VIDEO_TEST_SRC_UNKNOWN;
}
} else {
return GST_VIDEO_TEST_SRC_BT601;
}
}
/* threadsafe because this gets called as the plugin is loaded */ /* threadsafe because this gets called as the plugin is loaded */
static GstCaps * static GstCaps *
gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
@ -614,11 +567,12 @@ gst_video_test_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
static gboolean static gboolean
gst_video_test_src_parse_caps (const GstCaps * caps, gst_video_test_src_parse_caps (const GstCaps * caps,
gint * width, gint * height, gint * fps_n, gint * fps_d, gint * width, gint * height, gint * fps_n, gint * fps_d,
const gchar ** color_matrix) GstVideoColorimetry * colorimetry)
{ {
const GstStructure *structure; const GstStructure *structure;
GstPadLinkReturn ret; GstPadLinkReturn ret;
const GValue *framerate; const GValue *framerate;
const gchar *csp;
GST_DEBUG ("parsing caps"); GST_DEBUG ("parsing caps");
@ -634,7 +588,8 @@ gst_video_test_src_parse_caps (const GstCaps * caps,
} else } else
goto no_framerate; goto no_framerate;
*color_matrix = gst_structure_get_string (structure, "color-matrix"); if ((csp = gst_structure_get_string (structure, "colorimetry")))
gst_video_colorimetry_from_string (colorimetry, csp);
return ret; return ret;
@ -693,7 +648,7 @@ gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
} else if (gst_structure_has_name (structure, "video/x-raw-bayer")) { } else if (gst_structure_has_name (structure, "video/x-raw-bayer")) {
if (!gst_video_test_src_parse_caps (caps, &info.width, &info.height, if (!gst_video_test_src_parse_caps (caps, &info.width, &info.height,
&info.fps_n, &info.fps_d, &info.color_matrix)) &info.fps_n, &info.fps_d, &info.colorimetry))
goto parse_failed; goto parse_failed;
info.size = info.size =
@ -704,7 +659,6 @@ gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
goto unknown_format; goto unknown_format;
/* looks ok here */ /* looks ok here */
videotestsrc->color_spec = to_color_spec (info.color_matrix);
videotestsrc->format = format; videotestsrc->format = format;
videotestsrc->info = info; videotestsrc->info = info;

View file

@ -106,19 +106,6 @@ typedef enum {
GST_VIDEO_TEST_SRC_BAR GST_VIDEO_TEST_SRC_BAR
} GstVideoTestSrcPattern; } GstVideoTestSrcPattern;
/**
* GstVideoTestSrcColorSpec:
* @GST_VIDEO_TEST_SRC_BT601: ITU-R Rec. BT.601/BT.470 (SD)
* @GST_VIDEO_TEST_SRC_BT709: ITU-R Rec. BT.709 (HD)
*
* The color specification to use.
*/
typedef enum {
GST_VIDEO_TEST_SRC_UNKNOWN,
GST_VIDEO_TEST_SRC_BT601,
GST_VIDEO_TEST_SRC_BT709
} GstVideoTestSrcColorSpec;
typedef struct _GstVideoTestSrc GstVideoTestSrc; typedef struct _GstVideoTestSrc GstVideoTestSrc;
typedef struct _GstVideoTestSrcClass GstVideoTestSrcClass; typedef struct _GstVideoTestSrcClass GstVideoTestSrcClass;
@ -135,9 +122,6 @@ struct _GstVideoTestSrc {
/* type of output */ /* type of output */
GstVideoTestSrcPattern pattern_type; GstVideoTestSrcPattern pattern_type;
/* Color spec of output */
GstVideoTestSrcColorSpec color_spec;
/* video state */ /* video state */
GstVideoInfo info; GstVideoInfo info;

View file

@ -407,13 +407,13 @@ paint_get_structure (struct format_list_struct * format)
g_value_init (&value_list, GST_TYPE_LIST); g_value_init (&value_list, GST_TYPE_LIST);
g_value_init (&value, G_TYPE_STRING); g_value_init (&value, G_TYPE_STRING);
g_value_set_static_string (&value, "sdtv"); g_value_set_static_string (&value, "bt601");
gst_value_list_append_value (&value_list, &value); gst_value_list_append_value (&value_list, &value);
g_value_set_static_string (&value, "hdtv"); g_value_set_static_string (&value, "bt709");
gst_value_list_append_value (&value_list, &value); gst_value_list_append_value (&value_list, &value);
gst_structure_set_value (structure, "color-matrix", &value_list); gst_structure_set_value (structure, "colorimetry", &value_list);
g_value_reset (&value_list); g_value_reset (&value_list);
if (strcmp (format->format, "AYUV") && if (strcmp (format->format, "AYUV") &&
@ -430,8 +430,8 @@ paint_get_structure (struct format_list_struct * format)
} }
g_value_unset (&value_list); g_value_unset (&value_list);
} }
}
break; break;
}
case VTS_BAYER: case VTS_BAYER:
structure = gst_structure_new ("video/x-raw-bayer", structure = gst_structure_new ("video/x-raw-bayer",
"format", G_TYPE_STRING, format->format, NULL); "format", G_TYPE_STRING, format->format, NULL);
@ -508,7 +508,7 @@ videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
{ {
int a, r, g, b; int a, r, g, b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { if (v->info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT601) {
p->colors = vts_colors_bt601_ycbcr_100; p->colors = vts_colors_bt601_ycbcr_100;
} else { } else {
p->colors = vts_colors_bt709_ycbcr_100; p->colors = vts_colors_bt709_ycbcr_100;
@ -537,7 +537,7 @@ videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
p->foreground_color.R = r; p->foreground_color.R = r;
p->foreground_color.G = g; p->foreground_color.G = g;
p->foreground_color.B = b; p->foreground_color.B = b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { if (v->info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT601) {
p->foreground_color.Y = RGB_TO_Y_CCIR (r, g, b); p->foreground_color.Y = RGB_TO_Y_CCIR (r, g, b);
p->foreground_color.U = RGB_TO_U_CCIR (r, g, b, 0); p->foreground_color.U = RGB_TO_U_CCIR (r, g, b, 0);
p->foreground_color.V = RGB_TO_V_CCIR (r, g, b, 0); p->foreground_color.V = RGB_TO_V_CCIR (r, g, b, 0);
@ -556,7 +556,7 @@ videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
p->background_color.R = r; p->background_color.R = r;
p->background_color.G = g; p->background_color.G = g;
p->background_color.B = b; p->background_color.B = b;
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { if (v->info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT601) {
p->background_color.Y = RGB_TO_Y_CCIR (r, g, b); p->background_color.Y = RGB_TO_Y_CCIR (r, g, b);
p->background_color.U = RGB_TO_U_CCIR (r, g, b, 0); p->background_color.U = RGB_TO_U_CCIR (r, g, b, 0);
p->background_color.V = RGB_TO_V_CCIR (r, g, b, 0); p->background_color.V = RGB_TO_V_CCIR (r, g, b, 0);
@ -751,7 +751,7 @@ gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstVideoFrame * frame)
int w = frame->info.width, h = frame->info.height; int w = frame->info.width, h = frame->info.height;
videotestsrc_setup_paintinfo (v, p, w, h); videotestsrc_setup_paintinfo (v, p, w, h);
if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) { if (v->info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT601) {
p->colors = vts_colors_bt601_ycbcr_75; p->colors = vts_colors_bt601_ycbcr_75;
} else { } else {
p->colors = vts_colors_bt709_ycbcr_75; p->colors = vts_colors_bt709_ycbcr_75;