mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
codecs: Define common codec picture struct
Adding parent class of codec picture struct Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5285>
This commit is contained in:
parent
1bfd8a9fb1
commit
d69bacb954
4 changed files with 242 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/codecs/gstcodecpicture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gst_codec_picture_free (GstCodecPicture * picture);
|
||||
|
||||
G_END_DECLS
|
|
@ -0,0 +1,104 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "gstcodecpicture.h"
|
||||
#include "gstcodecpicture-private.h"
|
||||
|
||||
void
|
||||
gst_codec_picture_free (GstCodecPicture * picture)
|
||||
{
|
||||
if (picture->notify)
|
||||
picture->notify (picture->user_data);
|
||||
|
||||
if (picture->discont_state)
|
||||
gst_video_codec_state_unref (picture->discont_state);
|
||||
|
||||
g_free (picture);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_codec_picture_set_user_data:
|
||||
* @picture: a #GstCodecPicture
|
||||
* @user_data: (nullable): private data
|
||||
* @notify: (closure user_data): a #GDestroyNotify
|
||||
*
|
||||
* Sets @user_data on the picture and the #GDestroyNotify that will be called when
|
||||
* the picture is freed.
|
||||
*
|
||||
* If a @user_data was previously set, then the previous set @notify will be called
|
||||
* before the @user_data is replaced.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
void
|
||||
gst_codec_picture_set_user_data (GstCodecPicture * picture, gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
g_return_if_fail (picture);
|
||||
|
||||
if (picture->notify)
|
||||
picture->notify (picture->user_data);
|
||||
|
||||
picture->notify = notify;
|
||||
picture->user_data = user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_codec_picture_get_user_data:
|
||||
* @picture: a #GstCodecPicture
|
||||
*
|
||||
* Gets private data set on the picture via
|
||||
* gst_codec_picture_set_user_data() previously.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The previously set user_data
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gpointer
|
||||
gst_codec_picture_get_user_data (GstCodecPicture * picture)
|
||||
{
|
||||
g_return_val_if_fail (picture, NULL);
|
||||
|
||||
return picture->user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_codec_picture_set_discont_state:
|
||||
* @picture: a #GstCodecPicture
|
||||
* @discont_state: (transfer none) (allow-none): a #GstVideoCodecState
|
||||
*
|
||||
* Sets @discont_state to @picture
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
void
|
||||
gst_codec_picture_set_discont_state (GstCodecPicture * picture,
|
||||
GstVideoCodecState * discont_state)
|
||||
{
|
||||
g_return_if_fail (picture);
|
||||
|
||||
g_clear_pointer (&picture->discont_state, gst_video_codec_state_unref);
|
||||
|
||||
if (discont_state)
|
||||
picture->discont_state = gst_video_codec_state_ref (discont_state);
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2023 Seungha Yang <seungha@centricular.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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/codecs/codecs-prelude.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstCodecPicture GstCodecPicture;
|
||||
#define GST_CODEC_PICTURE(p) ((GstCodecPicture *) p)
|
||||
|
||||
/**
|
||||
* GST_CODEC_PICTURE_FRAME_NUMBER:
|
||||
* @picture: a #GstCodecPicture
|
||||
*
|
||||
* Gets access to the system_frame_number field of @picture
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
#define GST_CODEC_PICTURE_FRAME_NUMBER(picture) \
|
||||
GST_CODEC_PICTURE(picture)->system_frame_number
|
||||
|
||||
/**
|
||||
* GST_CODEC_PICTURE_COPY_FRAME_NUMBER:
|
||||
* @dst: a #GstCodecPicture
|
||||
* @src: a #GstCodecPicture
|
||||
*
|
||||
* Copy system_frame_number of @src to @dst
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
#define GST_CODEC_PICTURE_COPY_FRAME_NUMBER(dst,src) G_STMT_START { \
|
||||
GST_CODEC_PICTURE(dst)->system_frame_number = \
|
||||
GST_CODEC_PICTURE(src)->system_frame_number; \
|
||||
} G_STMT_END
|
||||
|
||||
/**
|
||||
* GstCodecPicture:
|
||||
*
|
||||
* Base struct for coded picture representation
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
struct _GstCodecPicture
|
||||
{
|
||||
/*< private >*/
|
||||
GstMiniObject parent;
|
||||
|
||||
guint32 system_frame_number;
|
||||
GstVideoCodecState *discont_state;
|
||||
|
||||
gpointer user_data;
|
||||
GDestroyNotify notify;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GST_CODECS_API
|
||||
void gst_codec_picture_set_user_data (GstCodecPicture * picture,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
GST_CODECS_API
|
||||
gpointer gst_codec_picture_get_user_data (GstCodecPicture * picture);
|
||||
|
||||
GST_CODECS_API
|
||||
void gst_codec_picture_set_discont_state (GstCodecPicture * picture,
|
||||
GstVideoCodecState * discont_state);
|
||||
|
||||
static inline GstCodecPicture *
|
||||
gst_codec_picture_ref (GstCodecPicture * picture)
|
||||
{
|
||||
return (GstCodecPicture *) gst_mini_object_ref ((GstMiniObject *) picture);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_codec_picture_unref (GstCodecPicture * picture)
|
||||
{
|
||||
gst_mini_object_unref ((GstMiniObject *) picture);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_clear_codec_picture (GstCodecPicture ** picture)
|
||||
{
|
||||
gst_clear_mini_object ((GstMiniObject **) picture);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
|
@ -12,6 +12,7 @@ codecs_sources = files(
|
|||
'gstav1decoder.c',
|
||||
'gstav1picture.c',
|
||||
'gstvp9statefulparser.c',
|
||||
'gstcodecpicture.c',
|
||||
)
|
||||
|
||||
codecs_headers = files(
|
||||
|
@ -28,6 +29,7 @@ codecs_headers = files(
|
|||
'gstav1decoder.h',
|
||||
'gstav1picture.h',
|
||||
'gstvp9statefulparser.h',
|
||||
'gstcodecpicture.h',
|
||||
)
|
||||
|
||||
cp_args = [
|
||||
|
|
Loading…
Reference in a new issue