2019-12-26 05:24:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_H264_PICTURE_H__
|
|
|
|
#define __GST_H264_PICTURE_H__
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
#include <gst/codecs/codecs-prelude.h>
|
2019-12-26 05:24:46 +00:00
|
|
|
#include <gst/codecparsers/gsth264parser.h>
|
2020-11-09 16:28:03 +00:00
|
|
|
#include <gst/video/video.h>
|
2019-12-26 05:24:46 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GST_TYPE_H264_PICTURE (gst_h264_picture_get_type())
|
|
|
|
#define GST_IS_H264_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_H264_PICTURE))
|
|
|
|
#define GST_H264_PICTURE(obj) ((GstH264Picture *)obj)
|
|
|
|
#define GST_H264_PICTURE_CAST(obj) (GST_H264_PICTURE(obj))
|
|
|
|
|
|
|
|
typedef struct _GstH264Slice GstH264Slice;
|
|
|
|
typedef struct _GstH264Picture GstH264Picture;
|
|
|
|
|
2020-04-06 19:06:01 +00:00
|
|
|
/* As specified in A.3.1 h) and A.3.2 f) */
|
|
|
|
#define GST_H264_DPB_MAX_SIZE 16
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-11-05 16:45:36 +00:00
|
|
|
/**
|
|
|
|
* GST_H264_PICTURE_IS_REF:
|
|
|
|
* @picture: a #GstH264Picture
|
|
|
|
*
|
|
|
|
* Check whether @picture is used for short-term or long-term reference
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
#define GST_H264_PICTURE_IS_REF(picture) \
|
|
|
|
((picture)->ref != GST_H264_PICTURE_REF_NONE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_H264_PICTURE_IS_SHORT_TERM_REF:
|
|
|
|
* @picture: a #GstH264Picture
|
|
|
|
*
|
|
|
|
* Check whether @picture is used for short-term reference
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
#define GST_H264_PICTURE_IS_SHORT_TERM_REF(picture) \
|
|
|
|
((picture)->ref == GST_H264_PICTURE_REF_SHORT_TERM)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GST_H264_PICTURE_IS_LONG_TERM_REF:
|
|
|
|
* @picture: a #GstH264Picture
|
|
|
|
*
|
|
|
|
* Check whether @picture is used for long-term reference
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
#define GST_H264_PICTURE_IS_LONG_TERM_REF(picture) \
|
|
|
|
((picture)->ref == GST_H264_PICTURE_REF_LONG_TERM)
|
|
|
|
|
2020-11-15 15:27:28 +00:00
|
|
|
/**
|
|
|
|
* GST_H264_PICTURE_IS_FRAME:
|
|
|
|
* @picture: a #GstH264Picture
|
|
|
|
*
|
|
|
|
* Check whether @picture is a frame (not a field picture)
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
#define GST_H264_PICTURE_IS_FRAME(picture) \
|
|
|
|
((picture)->field == GST_H264_PICTURE_FIELD_FRAME)
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
struct _GstH264Slice
|
|
|
|
{
|
|
|
|
GstH264SliceHdr header;
|
|
|
|
|
|
|
|
/* parsed nal unit (doesn't take ownership of raw data) */
|
|
|
|
GstH264NalUnit nalu;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_H264_PICTURE_FIELD_FRAME,
|
2020-04-19 16:37:58 +00:00
|
|
|
GST_H264_PICTURE_FIELD_TOP_FIELD,
|
2019-12-26 05:24:46 +00:00
|
|
|
GST_H264_PICTURE_FIELD_BOTTOM_FIELD,
|
|
|
|
} GstH264PictureField;
|
|
|
|
|
2020-11-05 16:45:36 +00:00
|
|
|
/**
|
|
|
|
* GstH264PictureReference:
|
|
|
|
* @GST_H264_PICTURE_REF_NONE: Not used for reference picture
|
|
|
|
* @GST_H264_PICTURE_REF_SHORT_TERM: Used for short-term reference picture
|
|
|
|
* @GST_H264_PICTURE_REF_LONG_TERM: Used for long-term reference picture
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_H264_PICTURE_REF_NONE = 0,
|
|
|
|
GST_H264_PICTURE_REF_SHORT_TERM,
|
|
|
|
GST_H264_PICTURE_REF_LONG_TERM,
|
|
|
|
} GstH264PictureReference;
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
struct _GstH264Picture
|
|
|
|
{
|
2020-11-01 15:08:04 +00:00
|
|
|
/*< private >*/
|
2019-12-26 05:24:46 +00:00
|
|
|
GstMiniObject parent;
|
|
|
|
|
|
|
|
GstH264SliceType type;
|
|
|
|
|
2020-02-15 02:50:15 +00:00
|
|
|
/* From GstVideoCodecFrame */
|
|
|
|
guint32 system_frame_number;
|
2019-12-26 05:24:46 +00:00
|
|
|
|
|
|
|
guint8 pic_order_cnt_type; /* SPS */
|
|
|
|
gint32 top_field_order_cnt;
|
|
|
|
gint32 bottom_field_order_cnt;
|
|
|
|
|
|
|
|
gint pic_order_cnt;
|
|
|
|
gint pic_order_cnt_msb;
|
|
|
|
gint pic_order_cnt_lsb;
|
|
|
|
gint delta_pic_order_cnt_bottom;
|
|
|
|
gint delta_pic_order_cnt0;
|
|
|
|
gint delta_pic_order_cnt1;
|
|
|
|
|
|
|
|
gint pic_num;
|
|
|
|
gint long_term_pic_num;
|
|
|
|
gint frame_num;
|
|
|
|
gint frame_num_offset;
|
|
|
|
gint frame_num_wrap;
|
|
|
|
gint long_term_frame_idx;
|
|
|
|
|
|
|
|
gint nal_ref_idc;
|
|
|
|
gboolean idr;
|
|
|
|
gint idr_pic_id;
|
2021-12-21 15:52:32 +00:00
|
|
|
gboolean field_pic_flag;
|
2020-11-05 16:45:36 +00:00
|
|
|
GstH264PictureReference ref;
|
2021-07-20 15:36:38 +00:00
|
|
|
/* Whether a reference picture. */
|
|
|
|
gboolean ref_pic;
|
2020-11-01 15:08:04 +00:00
|
|
|
gboolean needed_for_output;
|
2019-12-26 05:24:46 +00:00
|
|
|
gboolean mem_mgmt_5;
|
|
|
|
|
|
|
|
gboolean nonexisting;
|
|
|
|
|
|
|
|
GstH264PictureField field;
|
|
|
|
|
|
|
|
GstH264DecRefPicMarking dec_ref_pic_marking;
|
|
|
|
|
2020-11-09 16:28:03 +00:00
|
|
|
/* For interlaced decoding */
|
|
|
|
gboolean second_field;
|
|
|
|
GstH264Picture * other_field;
|
|
|
|
|
|
|
|
GstVideoBufferFlags buffer_flags;
|
|
|
|
|
2022-11-04 16:07:02 +00:00
|
|
|
/* decoder input state if this picture is discont point */
|
|
|
|
GstVideoCodecState *discont_state;
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify notify;
|
|
|
|
};
|
|
|
|
|
2021-07-28 14:48:21 +00:00
|
|
|
/**
|
|
|
|
* GstH264DpbBumpMode:
|
|
|
|
* @GST_H264_DPB_BUMP_NORMAL_LATENCY: No latency requirement for DBP bumping.
|
|
|
|
* @GST_H264_DPB_BUMP_LOW_LATENCY: Low-latency requirement for DBP bumping.
|
|
|
|
* @GST_H264_DPB_BUMP_VERY_LOW_LATENCY: Very low-latency requirement for DBP bumping.
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_H264_DPB_BUMP_NORMAL_LATENCY,
|
|
|
|
GST_H264_DPB_BUMP_LOW_LATENCY,
|
|
|
|
GST_H264_DPB_BUMP_VERY_LOW_LATENCY
|
|
|
|
} GstH264DpbBumpMode;
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GType gst_h264_picture_get_type (void);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GstH264Picture * gst_h264_picture_new (void);
|
|
|
|
|
|
|
|
static inline GstH264Picture *
|
|
|
|
gst_h264_picture_ref (GstH264Picture * picture)
|
|
|
|
{
|
|
|
|
return (GstH264Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
gst_h264_picture_unref (GstH264Picture * picture)
|
|
|
|
{
|
|
|
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
gst_h264_picture_replace (GstH264Picture ** old_picture,
|
|
|
|
GstH264Picture * new_picture)
|
|
|
|
{
|
|
|
|
return gst_mini_object_replace ((GstMiniObject **) old_picture,
|
|
|
|
(GstMiniObject *) new_picture);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2022-03-08 18:45:18 +00:00
|
|
|
gst_clear_h264_picture (GstH264Picture ** picture)
|
2019-12-26 05:24:46 +00:00
|
|
|
{
|
|
|
|
if (picture && *picture) {
|
|
|
|
gst_h264_picture_unref (*picture);
|
|
|
|
*picture = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_picture_set_user_data (GstH264Picture * picture,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
gpointer gst_h264_picture_get_user_data (GstH264Picture * picture);
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
* GstH264Dpb *
|
|
|
|
*******************/
|
|
|
|
typedef struct _GstH264Dpb GstH264Dpb;
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GstH264Dpb * gst_h264_dpb_new (void);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2020-11-04 19:16:54 +00:00
|
|
|
void gst_h264_dpb_set_max_num_frames (GstH264Dpb * dpb,
|
|
|
|
gint max_num_frames);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2020-11-04 19:16:54 +00:00
|
|
|
gint gst_h264_dpb_get_max_num_frames (GstH264Dpb * dpb);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-11-09 16:28:03 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
void gst_h264_dpb_set_interlaced (GstH264Dpb * dpb,
|
|
|
|
gboolean interlaced);
|
|
|
|
|
2021-07-20 15:49:12 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
void gst_h264_dpb_set_max_num_reorder_frames (GstH264Dpb * dpb,
|
|
|
|
guint32 max_num_reorder_frames);
|
|
|
|
|
2023-04-06 11:48:17 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
guint32 gst_h264_dpb_get_max_num_reorder_frames (GstH264Dpb * dpb);
|
|
|
|
|
2021-07-20 16:04:18 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
gboolean gst_h264_dpb_get_interlaced (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_free (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_clear (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_add (GstH264Dpb * dpb,
|
|
|
|
GstH264Picture * picture);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_delete_unused (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2020-11-04 19:16:54 +00:00
|
|
|
gint gst_h264_dpb_num_ref_frames (GstH264Dpb * dpb);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_mark_all_non_ref (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GstH264Picture * gst_h264_dpb_get_short_ref_by_pic_num (GstH264Dpb * dpb,
|
|
|
|
gint pic_num);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2020-11-05 09:42:37 +00:00
|
|
|
GstH264Picture * gst_h264_dpb_get_long_ref_by_long_term_pic_num (GstH264Dpb * dpb,
|
|
|
|
gint long_term_pic_num);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GstH264Picture * gst_h264_dpb_get_lowest_frame_num_short_ref (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_get_pictures_short_term_ref (GstH264Dpb * dpb,
|
2020-11-17 09:39:56 +00:00
|
|
|
gboolean include_non_existing,
|
|
|
|
gboolean include_second_field,
|
2020-05-15 18:56:27 +00:00
|
|
|
GArray * out);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
void gst_h264_dpb_get_pictures_long_term_ref (GstH264Dpb * dpb,
|
2020-11-17 09:39:56 +00:00
|
|
|
gboolean include_second_field,
|
2020-05-15 18:56:27 +00:00
|
|
|
GArray * out);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
GArray * gst_h264_dpb_get_pictures_all (GstH264Dpb * dpb);
|
|
|
|
|
2020-07-20 20:48:32 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
GstH264Picture * gst_h264_dpb_get_picture (GstH264Dpb * dpb,
|
|
|
|
guint32 system_frame_number);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2019-12-26 05:24:46 +00:00
|
|
|
gint gst_h264_dpb_get_size (GstH264Dpb * dpb);
|
|
|
|
|
2021-07-11 16:01:58 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
gboolean gst_h264_dpb_has_empty_frame_buffer (GstH264Dpb * dpb);
|
|
|
|
|
2020-01-31 22:54:57 +00:00
|
|
|
GST_CODECS_API
|
2020-11-01 15:08:04 +00:00
|
|
|
gboolean gst_h264_dpb_needs_bump (GstH264Dpb * dpb,
|
2021-07-11 16:06:49 +00:00
|
|
|
GstH264Picture * to_insert,
|
2021-07-28 14:48:21 +00:00
|
|
|
GstH264DpbBumpMode latency_mode);
|
2020-11-01 15:08:04 +00:00
|
|
|
|
|
|
|
GST_CODECS_API
|
|
|
|
GstH264Picture * gst_h264_dpb_bump (GstH264Dpb * dpb,
|
|
|
|
gboolean drain);
|
|
|
|
|
2021-07-20 16:04:18 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
void gst_h264_dpb_set_last_output (GstH264Dpb * dpb,
|
|
|
|
GstH264Picture * picture);
|
|
|
|
|
2020-11-01 15:08:04 +00:00
|
|
|
GST_CODECS_API
|
|
|
|
gboolean gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
|
|
|
|
GstH264RefPicMarking *ref_pic_marking,
|
|
|
|
GstH264Picture * picture);
|
2019-12-26 05:24:46 +00:00
|
|
|
|
2020-02-09 16:20:16 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstH264Picture, gst_h264_picture_unref)
|
|
|
|
|
2019-12-26 05:24:46 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_H264_PICTURE_H__ */
|