| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.GstVideo.Structs.VideoFrame
Description
A video frame obtained from videoFrameMap
Synopsis
- newtype VideoFrame = VideoFrame (ManagedPtr VideoFrame)
- newZeroVideoFrame :: MonadIO m => m VideoFrame
- videoFrameCopy :: (HasCallStack, MonadIO m) => VideoFrame -> VideoFrame -> m Bool
- videoFrameCopyPlane :: (HasCallStack, MonadIO m) => VideoFrame -> VideoFrame -> Word32 -> m Bool
- videoFrameMap :: (HasCallStack, MonadIO m) => VideoInfo -> Buffer -> [MapFlags] -> m (Bool, VideoFrame)
- videoFrameMapId :: (HasCallStack, MonadIO m) => VideoInfo -> Buffer -> Int32 -> [MapFlags] -> m (Bool, VideoFrame)
- videoFrameUnmap :: (HasCallStack, MonadIO m) => VideoFrame -> m ()
- clearVideoFrameBuffer :: MonadIO m => VideoFrame -> m ()
- getVideoFrameBuffer :: MonadIO m => VideoFrame -> m (Maybe Buffer)
- setVideoFrameBuffer :: MonadIO m => VideoFrame -> Ptr Buffer -> m ()
- getVideoFrameFlags :: MonadIO m => VideoFrame -> m [VideoFrameFlags]
- setVideoFrameFlags :: MonadIO m => VideoFrame -> [VideoFrameFlags] -> m ()
- getVideoFrameId :: MonadIO m => VideoFrame -> m Int32
- setVideoFrameId :: MonadIO m => VideoFrame -> Int32 -> m ()
- getVideoFrameInfo :: MonadIO m => VideoFrame -> m VideoInfo
- clearVideoFrameMeta :: MonadIO m => VideoFrame -> m ()
- getVideoFrameMeta :: MonadIO m => VideoFrame -> m (Ptr ())
- setVideoFrameMeta :: MonadIO m => VideoFrame -> Ptr () -> m ()
Exported types
newtype VideoFrame Source #
Memory-managed wrapper type.
Constructors
| VideoFrame (ManagedPtr VideoFrame) |
Instances
| Eq VideoFrame Source # | |
Defined in GI.GstVideo.Structs.VideoFrame | |
| BoxedPtr VideoFrame Source # | |
Defined in GI.GstVideo.Structs.VideoFrame | |
| CallocPtr VideoFrame Source # | |
Defined in GI.GstVideo.Structs.VideoFrame Methods boxedPtrCalloc :: IO (Ptr VideoFrame) | |
| ManagedPtrNewtype VideoFrame Source # | |
Defined in GI.GstVideo.Structs.VideoFrame Methods toManagedPtr :: VideoFrame -> ManagedPtr VideoFrame | |
| tag ~ 'AttrSet => Constructible VideoFrame tag Source # | |
Defined in GI.GstVideo.Structs.VideoFrame Methods new :: MonadIO m => (ManagedPtr VideoFrame -> VideoFrame) -> [AttrOp VideoFrame tag] -> m VideoFrame | |
newZeroVideoFrame :: MonadIO m => m VideoFrame Source #
Construct a VideoFrame struct initialized to zero.
Methods
Click to display all available methods, including inherited ones
copy
Arguments
| :: (HasCallStack, MonadIO m) | |
| => VideoFrame |
|
| -> VideoFrame |
|
| -> m Bool | Returns: TRUE if the contents could be copied. |
Copy the contents from src to dest.
Note: Since: 1.18, dest dimensions are allowed to be
smaller than src dimensions.
copyPlane
Arguments
| :: (HasCallStack, MonadIO m) | |
| => VideoFrame |
|
| -> VideoFrame |
|
| -> Word32 |
|
| -> m Bool | Returns: TRUE if the contents could be copied. |
Copy the plane with index plane from src to dest.
Note: Since: 1.18, dest dimensions are allowed to be
smaller than src dimensions.
map
Arguments
| :: (HasCallStack, MonadIO m) | |
| => VideoInfo |
|
| -> Buffer |
|
| -> [MapFlags] |
|
| -> m (Bool, VideoFrame) | Returns: |
Use info and buffer to fill in the values of frame. frame is usually
allocated on the stack, and you will pass the address to the VideoFrame
structure allocated on the stack; videoFrameMap will then fill in
the structures with the various video-specific information you need to access
the pixels of the video buffer. You can then use accessor macros such as
GST_VIDEO_FRAME_COMP_DATA(), GST_VIDEO_FRAME_PLANE_DATA(),
GST_VIDEO_FRAME_COMP_STRIDE(), GST_VIDEO_FRAME_PLANE_STRIDE() etc.
to get to the pixels.
C code
GstVideoFrame vframe;
...
// set RGB pixels to black one at a time
if (gst_video_frame_map (&vframe, video_info, video_buffer, GST_MAP_WRITE)) {
guint8 *pixels = GST_VIDEO_FRAME_PLANE_DATA (vframe, 0);
guint stride = GST_VIDEO_FRAME_PLANE_STRIDE (vframe, 0);
guint pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (vframe, 0);
for (h = 0; h < height; ++h) {
for (w = 0; w < width; ++w) {
guint8 *pixel = pixels + h * stride + w * pixel_stride;
memset (pixel, 0, pixel_stride);
}
}
gst_video_frame_unmap (&vframe);
}
...All video planes of buffer will be mapped and the pointers will be set in
frame->data.
The purpose of this function is to make it easy for you to get to the video
pixels in a generic way, without you having to worry too much about details
such as whether the video data is allocated in one contiguous memory chunk
or multiple memory chunks (e.g. one for each plane); or if custom strides
and custom plane offsets are used or not (as signalled by GstVideoMeta on
each buffer). This function will just fill the VideoFrame structure
with the right values and if you use the accessor macros everything will
just work and you can access the data easily. It also maps the underlying
memory chunks for you.
mapId
Arguments
| :: (HasCallStack, MonadIO m) | |
| => VideoInfo |
|
| -> Buffer |
|
| -> Int32 |
|
| -> [MapFlags] |
|
| -> m (Bool, VideoFrame) | Returns: |
Use info and buffer to fill in the values of frame with the video frame
information of frame id.
When id is -1, the default frame is mapped. When id != -1, this function
will return False when there is no GstVideoMeta with that id.
All video planes of buffer will be mapped and the pointers will be set in
frame->data.
unmap
Arguments
| :: (HasCallStack, MonadIO m) | |
| => VideoFrame |
|
| -> m () |
Unmap the memory previously mapped with gst_video_frame_map.
Properties
buffer
the mapped buffer
clearVideoFrameBuffer :: MonadIO m => VideoFrame -> m () Source #
Set the value of the “buffer” field to Nothing.
When overloading is enabled, this is equivalent to
clear #buffer
getVideoFrameBuffer :: MonadIO m => VideoFrame -> m (Maybe Buffer) Source #
Get the value of the “buffer” field.
When overloading is enabled, this is equivalent to
get videoFrame #buffer
setVideoFrameBuffer :: MonadIO m => VideoFrame -> Ptr Buffer -> m () Source #
Set the value of the “buffer” field.
When overloading is enabled, this is equivalent to
setvideoFrame [ #buffer:=value ]
flags
VideoFrameFlags for the frame
getVideoFrameFlags :: MonadIO m => VideoFrame -> m [VideoFrameFlags] Source #
Get the value of the “flags” field.
When overloading is enabled, this is equivalent to
get videoFrame #flags
setVideoFrameFlags :: MonadIO m => VideoFrame -> [VideoFrameFlags] -> m () Source #
Set the value of the “flags” field.
When overloading is enabled, this is equivalent to
setvideoFrame [ #flags:=value ]
id
id of the mapped frame. the id can for example be used to identify the frame in case of multiview video.
getVideoFrameId :: MonadIO m => VideoFrame -> m Int32 Source #
Get the value of the “id” field.
When overloading is enabled, this is equivalent to
get videoFrame #id
setVideoFrameId :: MonadIO m => VideoFrame -> Int32 -> m () Source #
Set the value of the “id” field.
When overloading is enabled, this is equivalent to
setvideoFrame [ #id:=value ]
info
the VideoInfo
getVideoFrameInfo :: MonadIO m => VideoFrame -> m VideoInfo Source #
Get the value of the “info” field.
When overloading is enabled, this is equivalent to
get videoFrame #info
meta
pointer to metadata if any
clearVideoFrameMeta :: MonadIO m => VideoFrame -> m () Source #
Set the value of the “meta” field to Nothing.
When overloading is enabled, this is equivalent to
clear #meta
getVideoFrameMeta :: MonadIO m => VideoFrame -> m (Ptr ()) Source #
Get the value of the “meta” field.
When overloading is enabled, this is equivalent to
get videoFrame #meta
setVideoFrameMeta :: MonadIO m => VideoFrame -> Ptr () -> m () Source #
Set the value of the “meta” field.
When overloading is enabled, this is equivalent to
setvideoFrame [ #meta:=value ]