gstvideo

gstvideo — Support library for video operations

Synopsis

#include <gst/video/video.h>

#define             GST_VIDEO_FPS_RANGE
#define             GST_VIDEO_SIZE_RANGE
#define             GST_VIDEO_BUFFER_TFF
#define             GST_VIDEO_BUFFER_RFF
#define             GST_VIDEO_BUFFER_ONEFIELD
enum                GstVideoFormat;
gboolean            gst_video_calculate_display_ratio   (guint *dar_n,
                                                         guint *dar_d,
                                                         guint video_width,
                                                         guint video_height,
                                                         guint video_par_n,
                                                         guint video_par_d,
                                                         guint display_par_n,
                                                         guint display_par_d);
guint32             gst_video_format_to_fourcc          (GstVideoFormat format);
GstVideoFormat      gst_video_format_from_fourcc        (guint32 fourcc);
gboolean            gst_video_parse_caps_framerate      (GstCaps *caps,
                                                         int *fps_n,
                                                         int *fps_d);
GstBuffer *         gst_video_parse_caps_palette        (GstCaps *caps);
void                (*GstVideoConvertFrameCallback)     (GstBuffer *buf,
                                                         GError *error,
                                                         gpointer user_data);
GstBuffer *         gst_video_convert_frame             (GstBuffer *buf,
                                                         GstCaps *from_caps,
                                                         const GstCaps *to_caps,
                                                         GstClockTime timeout,
                                                         GError **error);
void                gst_video_convert_frame_async       (GstBuffer *buf,
                                                         GstCaps *from_caps,
                                                         const GstCaps *to_caps,
                                                         GstClockTime timeout,
                                                         GstVideoConvertFrameCallback callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy_notify);
GstEvent *          gst_video_event_new_still_frame     (gboolean in_still);
gboolean            gst_video_event_parse_still_frame   (GstEvent *event,
                                                         gboolean *in_still);

Description

This library contains some helper functions and includes the videosink and videofilter base classes.

Details

GST_VIDEO_FPS_RANGE

#define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]"

GST_VIDEO_SIZE_RANGE

#define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]"

GST_VIDEO_BUFFER_TFF

#define GST_VIDEO_BUFFER_TFF GST_BUFFER_FLAG_MEDIA1

If the GstBuffer is interlaced, then the first field in the video frame is the top field. If unset, the bottom field is first.

Since 0.10.23


GST_VIDEO_BUFFER_RFF

#define GST_VIDEO_BUFFER_RFF GST_BUFFER_FLAG_MEDIA2

If the GstBuffer is interlaced, then the first field (as defined by the GST_VIDEO_BUFFER_TFF flag setting) is repeated.

Since 0.10.23


GST_VIDEO_BUFFER_ONEFIELD

#define GST_VIDEO_BUFFER_ONEFIELD GST_BUFFER_FLAG_MEDIA3

If the GstBuffer is interlaced, then only the first field (as defined by the GST_VIDEO_BUFFER_TFF flag setting) is to be displayed.

Since 0.10.23


enum GstVideoFormat

typedef enum {
  GST_VIDEO_FORMAT_UNKNOWN,
  GST_VIDEO_FORMAT_I420,
  GST_VIDEO_FORMAT_YV12,
  GST_VIDEO_FORMAT_YUY2,
  GST_VIDEO_FORMAT_UYVY,
  GST_VIDEO_FORMAT_AYUV,
  GST_VIDEO_FORMAT_RGBx,
  GST_VIDEO_FORMAT_BGRx,
  GST_VIDEO_FORMAT_xRGB,
  GST_VIDEO_FORMAT_xBGR,
  GST_VIDEO_FORMAT_RGBA,
  GST_VIDEO_FORMAT_BGRA,
  GST_VIDEO_FORMAT_ARGB,
  GST_VIDEO_FORMAT_ABGR,
  GST_VIDEO_FORMAT_RGB,
  GST_VIDEO_FORMAT_BGR,
  GST_VIDEO_FORMAT_Y41B,
  GST_VIDEO_FORMAT_Y42B,
  GST_VIDEO_FORMAT_YVYU,
  GST_VIDEO_FORMAT_Y444,
  GST_VIDEO_FORMAT_v210,
  GST_VIDEO_FORMAT_v216,
  GST_VIDEO_FORMAT_NV12,
  GST_VIDEO_FORMAT_NV21,
  GST_VIDEO_FORMAT_GRAY8,
  GST_VIDEO_FORMAT_GRAY16_BE,
  GST_VIDEO_FORMAT_GRAY16_LE,
  GST_VIDEO_FORMAT_v308,
  GST_VIDEO_FORMAT_Y800,
  GST_VIDEO_FORMAT_Y16,
  GST_VIDEO_FORMAT_RGB16,
  GST_VIDEO_FORMAT_BGR16,
  GST_VIDEO_FORMAT_RGB15,
  GST_VIDEO_FORMAT_BGR15,
  GST_VIDEO_FORMAT_UYVP,
  GST_VIDEO_FORMAT_A420,
  GST_VIDEO_FORMAT_RGB8_PALETTED,
  GST_VIDEO_FORMAT_YUV9,
  GST_VIDEO_FORMAT_YVU9,
  GST_VIDEO_FORMAT_IYU1,
  GST_VIDEO_FORMAT_ARGB64,
  GST_VIDEO_FORMAT_AYUV64,
  GST_VIDEO_FORMAT_r210
} GstVideoFormat;

Enum value describing the most common video formats.

GST_VIDEO_FORMAT_UNKNOWN

Unknown or unset video format id

GST_VIDEO_FORMAT_I420

planar 4:2:0 YUV

GST_VIDEO_FORMAT_YV12

planar 4:2:0 YVU (like I420 but UV planes swapped)

GST_VIDEO_FORMAT_YUY2

packed 4:2:2 YUV (Y0-U0-Y1-V0 Y2-U2-Y3-V2 Y4 ...)

GST_VIDEO_FORMAT_UYVY

packed 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)

GST_VIDEO_FORMAT_AYUV

packed 4:4:4 YUV with alpha channel (A0-Y0-U0-V0 ...)

GST_VIDEO_FORMAT_RGBx

sparse rgb packed into 32 bit, space last

GST_VIDEO_FORMAT_BGRx

sparse reverse rgb packed into 32 bit, space last

GST_VIDEO_FORMAT_xRGB

sparse rgb packed into 32 bit, space first

GST_VIDEO_FORMAT_xBGR

sparse reverse rgb packed into 32 bit, space first

GST_VIDEO_FORMAT_RGBA

rgb with alpha channel last

GST_VIDEO_FORMAT_BGRA

reverse rgb with alpha channel last

GST_VIDEO_FORMAT_ARGB

rgb with alpha channel first

GST_VIDEO_FORMAT_ABGR

reverse rgb with alpha channel first

GST_VIDEO_FORMAT_RGB

rgb

GST_VIDEO_FORMAT_BGR

reverse rgb

GST_VIDEO_FORMAT_Y41B

planar 4:1:1 YUV (Since: 0.10.18)

GST_VIDEO_FORMAT_Y42B

planar 4:2:2 YUV (Since: 0.10.18)

GST_VIDEO_FORMAT_YVYU

packed 4:2:2 YUV (Y0-V0-Y1-U0 Y2-V2-Y3-U2 Y4 ...) (Since: 0.10.23)

GST_VIDEO_FORMAT_Y444

planar 4:4:4 YUV (Since: 0.10.24)

GST_VIDEO_FORMAT_v210

packed 4:2:2 10-bit YUV, complex format (Since: 0.10.24)

GST_VIDEO_FORMAT_v216

packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order (Since: 0.10.24)

GST_VIDEO_FORMAT_NV12

planar 4:2:0 YUV with interleaved UV plane (Since: 0.10.26)

GST_VIDEO_FORMAT_NV21

planar 4:2:0 YUV with interleaved VU plane (Since: 0.10.26)

GST_VIDEO_FORMAT_GRAY8

8-bit grayscale (Since: 0.10.29)

GST_VIDEO_FORMAT_GRAY16_BE

16-bit grayscale, most significant byte first (Since: 0.10.29)

GST_VIDEO_FORMAT_GRAY16_LE

16-bit grayscale, least significant byte first (Since: 0.10.29)

GST_VIDEO_FORMAT_v308

packed 4:4:4 YUV (Since: 0.10.29)

GST_VIDEO_FORMAT_Y800

same as GST_VIDEO_FORMAT_GRAY8 (Since: 0.10.30)

GST_VIDEO_FORMAT_Y16

same as GST_VIDEO_FORMAT_GRAY16_LE (Since: 0.10.30)

GST_VIDEO_FORMAT_RGB16

rgb 5-6-5 bits per component (Since: 0.10.30)

GST_VIDEO_FORMAT_BGR16

reverse rgb 5-6-5 bits per component (Since: 0.10.30)

GST_VIDEO_FORMAT_RGB15

rgb 5-5-5 bits per component (Since: 0.10.30)

GST_VIDEO_FORMAT_BGR15

reverse rgb 5-5-5 bits per component (Since: 0.10.30)

GST_VIDEO_FORMAT_UYVP

packed 10-bit 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...) (Since: 0.10.31)

GST_VIDEO_FORMAT_A420

planar 4:4:2:0 AYUV (Since: 0.10.31)

GST_VIDEO_FORMAT_RGB8_PALETTED

8-bit paletted RGB (Since: 0.10.32)

GST_VIDEO_FORMAT_YUV9

planar 4:1:0 YUV (Since: 0.10.32)

GST_VIDEO_FORMAT_YVU9

planar 4:1:0 YUV (like YUV9 but UV planes swapped) (Since: 0.10.32)

GST_VIDEO_FORMAT_IYU1

packed 4:1:1 YUV (Cb-Y0-Y1-Cr-Y2-Y3 ...) (Since: 0.10.32)

GST_VIDEO_FORMAT_ARGB64

rgb with alpha channel first, 16 bits per channel (Since: 0.10.33)

GST_VIDEO_FORMAT_AYUV64

packed 4:4:4 YUV with alpha channel, 16 bits per channel (A0-Y0-U0-V0 ...) (Since: 0.10.33)

GST_VIDEO_FORMAT_r210

packed 4:4:4 RGB, 10 bits per channel (Since: 0.10.33)

gst_video_calculate_display_ratio ()

gboolean            gst_video_calculate_display_ratio   (guint *dar_n,
                                                         guint *dar_d,
                                                         guint video_width,
                                                         guint video_height,
                                                         guint video_par_n,
                                                         guint video_par_d,
                                                         guint display_par_n,
                                                         guint display_par_d);

Given the Pixel Aspect Ratio and size of an input video frame, and the pixel aspect ratio of the intended display device, calculates the actual display ratio the video will be rendered with.

dar_n :

Numerator of the calculated display_ratio

dar_d :

Denominator of the calculated display_ratio

video_width :

Width of the video frame in pixels

video_height :

Height of the video frame in pixels

video_par_n :

Numerator of the pixel aspect ratio of the input video.

video_par_d :

Denominator of the pixel aspect ratio of the input video.

display_par_n :

Numerator of the pixel aspect ratio of the display device

display_par_d :

Denominator of the pixel aspect ratio of the display device

Returns :

A boolean indicating success and a calculated Display Ratio in the dar_n and dar_d parameters. The return value is FALSE in the case of integer overflow or other error.

Since 0.10.7


gst_video_format_to_fourcc ()

guint32             gst_video_format_to_fourcc          (GstVideoFormat format);

Converts a GstVideoFormat value into the corresponding FOURCC. Only a few YUV formats have corresponding FOURCC values. If format has no corresponding FOURCC value, 0 is returned.

format :

a GstVideoFormat video format

Returns :

the FOURCC corresponding to format

Since 0.10.16


gst_video_format_from_fourcc ()

GstVideoFormat      gst_video_format_from_fourcc        (guint32 fourcc);

Converts a FOURCC value into the corresponding GstVideoFormat. If the FOURCC cannot be represented by GstVideoFormat, GST_VIDEO_FORMAT_UNKNOWN is returned.

fourcc :

a FOURCC value representing raw YUV video

Returns :

the GstVideoFormat describing the FOURCC value

Since 0.10.16


gst_video_parse_caps_framerate ()

gboolean            gst_video_parse_caps_framerate      (GstCaps *caps,
                                                         int *fps_n,
                                                         int *fps_d);

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.

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)

Returns :

TRUE if caps was parsed correctly.

Since 0.10.16


gst_video_parse_caps_palette ()

GstBuffer *         gst_video_parse_caps_palette        (GstCaps *caps);

Returns the palette data from the caps as a GstBuffer. For GST_VIDEO_FORMAT_RGB8_PALETTED this is containing 256 guint32 values, each containing ARGB colors in native endianness.

caps :

GstCaps to parse

Returns :

a GstBuffer containing the palette data. Unref after usage.

Since 0.10.32


GstVideoConvertFrameCallback ()

void                (*GstVideoConvertFrameCallback)     (GstBuffer *buf,
                                                         GError *error,
                                                         gpointer user_data);

gst_video_convert_frame ()

GstBuffer *         gst_video_convert_frame             (GstBuffer *buf,
                                                         GstCaps *from_caps,
                                                         const GstCaps *to_caps,
                                                         GstClockTime timeout,
                                                         GError **error);

Converts a raw video buffer into the specified output caps.

The output caps can be any raw video formats or any image formats (jpeg, png, ...).

The width, height and pixel-aspect-ratio can also be specified in the output caps.

buf :

a GstBuffer

from_caps :

the GstCaps to convert from

to_caps :

the GstCaps to convert to

timeout :

the maximum amount of time allowed for the processing.

error :

pointer to a GError. Can be NULL.

Returns :

The converted GstBuffer, or NULL if an error happened (in which case err will point to the GError).

Since 0.10.31


gst_video_convert_frame_async ()

void                gst_video_convert_frame_async       (GstBuffer *buf,
                                                         GstCaps *from_caps,
                                                         const GstCaps *to_caps,
                                                         GstClockTime timeout,
                                                         GstVideoConvertFrameCallback callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy_notify);

Converts a raw video buffer into the specified output caps.

The output caps can be any raw video formats or any image formats (jpeg, png, ...).

The width, height and pixel-aspect-ratio can also be specified in the output caps.

callback will be called after conversion, when an error occured or if conversion didn't finish after timeout. callback will always be called from the thread default GMainContext, see g_main_context_get_thread_default(). If GLib before 2.22 is used, this will always be the global default main context.

destroy_notify will be called after the callback was called and user_data is not needed anymore.

buf :

a GstBuffer

to_caps :

the GstCaps to convert to

timeout :

the maximum amount of time allowed for the processing.

callback :

GstVideoConvertFrameCallback that will be called after conversion.

user_data :

extra data that will be passed to the callback

destroy_notify :

GDestroyNotify to be called after user_data is not needed anymore

Since 0.10.31


gst_video_event_new_still_frame ()

GstEvent *          gst_video_event_new_still_frame     (gboolean in_still);

Creates a new Still Frame event. If in_still is TRUE, then the event represents the start of a still frame sequence. If it is FALSE, then the event ends a still frame sequence.

To parse an event created by gst_video_event_new_still_frame() use gst_video_event_parse_still_frame().

in_still :

boolean value for the still-frame state of the event.

Returns :

The new GstEvent

Since 0.10.26


gst_video_event_parse_still_frame ()

gboolean            gst_video_event_parse_still_frame   (GstEvent *event,
                                                         gboolean *in_still);

Parse a GstEvent, identify if it is a Still Frame event, and return the still-frame state from the event if it is. If the event represents the start of a still frame, the in_still variable will be set to TRUE, otherwise FALSE. It is OK to pass NULL for the in_still variable order to just check whether the event is a valid still-frame event.

Create a still frame event using gst_video_event_new_still_frame()

event :

A GstEvent to parse

in_still :

A boolean to receive the still-frame status from the event, or NULL

Returns :

TRUE if the event is a valid still-frame event. FALSE if not

Since 0.10.26