video: Add flags for interlaced video along with convenience methods for interlaced caps.

These three flags allow all know combinations of interlaced formats. They should
only be used when the caps contain 'interlaced=True'.

Fixes #163577 (yes, it's a 4 year old bug).
This commit is contained in:
Edward Hervey 2009-01-26 10:30:53 +01:00
parent f187ffddce
commit c44b067817
3 changed files with 97 additions and 6 deletions

View file

@ -1552,12 +1552,16 @@ GST_VIDEO_RED_MASK_15_INT
GST_VIDEO_RED_MASK_16 GST_VIDEO_RED_MASK_16
GST_VIDEO_RED_MASK_16_INT GST_VIDEO_RED_MASK_16_INT
GST_VIDEO_SIZE_RANGE GST_VIDEO_SIZE_RANGE
GST_VIDEO_BUFFER_TFF
GST_VIDEO_BUFFER_RFF
GST_VIDEO_BUFFER_ONEFIELD
GstVideoFormat GstVideoFormat
gst_video_calculate_display_ratio gst_video_calculate_display_ratio
gst_video_frame_rate gst_video_frame_rate
gst_video_get_size gst_video_get_size
gst_video_format_convert gst_video_format_convert
gst_video_format_new_caps gst_video_format_new_caps
gst_video_format_new_caps_interlaced
gst_video_format_get_component_height gst_video_format_get_component_height
gst_video_format_get_component_offset gst_video_format_get_component_offset
gst_video_format_get_component_width gst_video_format_get_component_width
@ -1570,6 +1574,7 @@ gst_video_format_is_yuv
gst_video_format_to_fourcc gst_video_format_to_fourcc
gst_video_format_from_fourcc gst_video_format_from_fourcc
gst_video_format_parse_caps gst_video_format_parse_caps
gst_video_format_parse_caps_interlaced
gst_video_parse_caps_framerate gst_video_parse_caps_framerate
gst_video_parse_caps_pixel_aspect_ratio gst_video_parse_caps_pixel_aspect_ratio
</SECTION> </SECTION>

View file

@ -219,6 +219,36 @@ error_overflow:
return FALSE; return FALSE;
} }
/**
* gst_video_format_parse_caps_interlaced:
* @caps: the fixed #GstCaps to parse
* @interlaced: whether @caps represents interlaced video or not, may be NULL (output)
*
* Extracts whether the caps represents interlaced content or not and places it
* in @interlaced.
*
* Since: 0.10.22
*
* Returns: TRUE if @caps was parsed correctly.
*/
gboolean
gst_video_format_parse_caps_interlaced (GstCaps * caps, gboolean * interlaced)
{
GstStructure *structure;
if (!gst_caps_is_fixed (caps))
return FALSE;
structure = gst_caps_get_structure (caps, 0);
if (interlaced) {
if (!gst_structure_get_boolean (structure, "interlaced", interlaced))
*interlaced = FALSE;
}
return TRUE;
}
/** /**
* gst_video_format_parse_caps: * gst_video_format_parse_caps:
* @caps: the #GstCaps to parse * @caps: the #GstCaps to parse
@ -314,6 +344,7 @@ gst_video_format_parse_caps (GstCaps * caps, GstVideoFormat * format,
return ok; return ok;
} }
/** /**
* gst_video_parse_caps_framerate: * gst_video_parse_caps_framerate:
* @caps: pointer to a #GstCaps instance * @caps: pointer to a #GstCaps instance
@ -380,7 +411,7 @@ gst_video_parse_caps_pixel_aspect_ratio (GstCaps * caps, int *par_n, int *par_d)
} }
/** /**
* gst_video_format_new_caps: * gst_video_format_new_caps_interlaced:
* @format: the #GstVideoFormat describing the raw video format * @format: the #GstVideoFormat describing the raw video format
* @width: width of video * @width: width of video
* @height: height of video * @height: height of video
@ -388,16 +419,18 @@ gst_video_parse_caps_pixel_aspect_ratio (GstCaps * caps, int *par_n, int *par_d)
* @framerate_d: denominator of frame rate * @framerate_d: denominator of frame rate
* @par_n: numerator of pixel aspect ratio * @par_n: numerator of pixel aspect ratio
* @par_d: denominator of pixel aspect ratio * @par_d: denominator of pixel aspect ratio
* @interlaced: #TRUE if the format is interlaced
* *
* Creates a new #GstCaps object based on the parameters provided. * Creates a new #GstCaps object based on the parameters provided.
* *
* Since: 0.10.16 * Since: 0.10.22
* *
* Returns: a new #GstCaps object, or NULL if there was an error * Returns: a new #GstCaps object, or NULL if there was an error
*/ */
GstCaps * GstCaps *
gst_video_format_new_caps (GstVideoFormat format, int width, int height, gst_video_format_new_caps_interlaced (GstVideoFormat format, int width,
int framerate_n, int framerate_d, int par_n, int par_d) int height, int framerate_n, int framerate_d, int par_n, int par_d,
gboolean interlaced)
{ {
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL); g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
g_return_val_if_fail (width > 0 && height > 0, NULL); g_return_val_if_fail (width > 0 && height > 0, NULL);
@ -408,7 +441,8 @@ gst_video_format_new_caps (GstVideoFormat format, int width, int height,
"width", G_TYPE_INT, width, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, "height", G_TYPE_INT, height,
"framerate", GST_TYPE_FRACTION, framerate_n, framerate_d, "framerate", GST_TYPE_FRACTION, framerate_n, framerate_d,
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d,
"interlaced", G_TYPE_BOOLEAN, interlaced, NULL);
} }
if (gst_video_format_is_rgb (format)) { if (gst_video_format_is_rgb (format)) {
GstCaps *caps; GstCaps *caps;
@ -472,7 +506,8 @@ gst_video_format_new_caps (GstVideoFormat format, int width, int height,
"width", G_TYPE_INT, width, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, "height", G_TYPE_INT, height,
"framerate", GST_TYPE_FRACTION, framerate_n, framerate_d, "framerate", GST_TYPE_FRACTION, framerate_n, framerate_d,
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL); "pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d,
"interlaced", G_TYPE_BOOLEAN, interlaced, NULL);
if (have_alpha) { if (have_alpha) {
alpha_mask = alpha_mask =
mask >> (8 * gst_video_format_get_component_offset (format, 3, width, mask >> (8 * gst_video_format_get_component_offset (format, 3, width,
@ -484,6 +519,30 @@ gst_video_format_new_caps (GstVideoFormat format, int width, int height,
return NULL; return NULL;
} }
/**
* gst_video_format_new_caps:
* @format: the #GstVideoFormat describing the raw video format
* @width: width of video
* @height: height of video
* @framerate_n: numerator of frame rate
* @framerate_d: denominator of frame rate
* @par_n: numerator of pixel aspect ratio
* @par_d: denominator of pixel aspect ratio
*
* Creates a new #GstCaps object based on the parameters provided.
*
* Since: 0.10.16
*
* Returns: a new #GstCaps object, or NULL if there was an error
*/
GstCaps *
gst_video_format_new_caps (GstVideoFormat format, int width, int height,
int framerate_n, int framerate_d, int par_n, int par_d)
{
return gst_video_format_new_caps_interlaced (format, width, height,
framerate_n, framerate_d, par_n, par_d, FALSE);
}
/** /**
* gst_video_format_from_fourcc: * gst_video_format_from_fourcc:
* @fourcc: a FOURCC value representing raw YUV video * @fourcc: a FOURCC value representing raw YUV video

View file

@ -229,6 +229,29 @@ typedef enum {
"height = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE "framerate = " GST_VIDEO_FPS_RANGE
/* buffer flags */
/**
* GST_VIDEO_BUFFER_TFF:
* If the @GstBuffer is interlaced, then the first field in the video frame is
* the top field. If unset, the bottom field is first.
*/
#define GST_VIDEO_BUFFER_TFF GST_BUFFER_FLAG_MEDIA1
/**
* GST_VIDEO_BUFFER_RFF:
* If the @GstBuffer is interlaced, then the first field (as defined by the
* @GST_VIDEO_BUFFER_TFF flag setting) is repeated.
*/
#define GST_VIDEO_BUFFER_RFF GST_BUFFER_FLAG_MEDIA2
/**
* GST_VIDEO_BUFFER_ONEFIELD:
* If the #GstBuffer is interlaced, the only the first field (as defined by the
* @GST_VIDEO_BUFFER_TFF flag setting) is to be displayed.
*/
#define GST_VIDEO_BUFFER_ONEFIELD GST_BUFFER_FLAG_MEDIA3
/* functions */ /* functions */
const GValue *gst_video_frame_rate (GstPad *pad); const GValue *gst_video_frame_rate (GstPad *pad);
gboolean gst_video_get_size (GstPad *pad, gboolean gst_video_get_size (GstPad *pad,
@ -242,6 +265,7 @@ gboolean gst_video_calculate_display_ratio (guint *dar_n, guint *dar_d,
gboolean gst_video_format_parse_caps (GstCaps *caps, GstVideoFormat *format, gboolean gst_video_format_parse_caps (GstCaps *caps, GstVideoFormat *format,
int *width, int *height); int *width, int *height);
gboolean gst_video_format_parse_caps_interlaced (GstCaps *caps, gboolean *interlaced);
gboolean gst_video_parse_caps_framerate (GstCaps *caps, gboolean gst_video_parse_caps_framerate (GstCaps *caps,
int *fps_n, int *fps_d); int *fps_n, int *fps_d);
gboolean gst_video_parse_caps_pixel_aspect_ratio (GstCaps *caps, gboolean gst_video_parse_caps_pixel_aspect_ratio (GstCaps *caps,
@ -249,6 +273,9 @@ gboolean gst_video_parse_caps_pixel_aspect_ratio (GstCaps *caps,
GstCaps * gst_video_format_new_caps (GstVideoFormat format, GstCaps * gst_video_format_new_caps (GstVideoFormat format,
int width, int height, int framerate_n, int framerate_d, int width, int height, int framerate_n, int framerate_d,
int par_n, int par_d); int par_n, int par_d);
GstCaps * gst_video_format_new_caps_interlaced (GstVideoFormat format,
int width, int height, int framerate_n, int framerate_d,
int par_n, int par_d, gboolean interlaced);
GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc); GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc);
guint32 gst_video_format_to_fourcc (GstVideoFormat format); guint32 gst_video_format_to_fourcc (GstVideoFormat format);
gboolean gst_video_format_is_rgb (GstVideoFormat format); gboolean gst_video_format_is_rgb (GstVideoFormat format);