mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 14:11:15 +00:00
vp9decoder: Port to GstCodecPicture struct
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5285>
This commit is contained in:
parent
4571fac946
commit
a73c6d7fb6
8 changed files with 52 additions and 89 deletions
|
@ -492,11 +492,11 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
|
||||||
goto unmap_and_error;
|
goto unmap_and_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
picture->system_frame_number = pic_to_dup->system_frame_number;
|
GST_CODEC_PICTURE_COPY_FRAME_NUMBER (picture, pic_to_dup);
|
||||||
} else {
|
} else {
|
||||||
picture = gst_vp9_picture_new ();
|
picture = gst_vp9_picture_new ();
|
||||||
picture->frame_hdr = frame_hdr;
|
picture->frame_hdr = frame_hdr;
|
||||||
picture->system_frame_number = frame->system_frame_number;
|
GST_CODEC_PICTURE_FRAME_NUMBER (picture) = frame->system_frame_number;
|
||||||
picture->data = map.data;
|
picture->data = map.data;
|
||||||
picture->size = map.size;
|
picture->size = map.size;
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
|
||||||
/* If subclass didn't update output state at this point,
|
/* If subclass didn't update output state at this point,
|
||||||
* marking this picture as a discont and stores current input state */
|
* marking this picture as a discont and stores current input state */
|
||||||
if (priv->input_state_changed) {
|
if (priv->input_state_changed) {
|
||||||
picture->discont_state = gst_video_codec_state_ref (self->input_state);
|
gst_vp9_picture_set_discont_state (picture, self->input_state);
|
||||||
priv->input_state_changed = FALSE;
|
priv->input_state_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ struct _GstVp9DecoderClass
|
||||||
*
|
*
|
||||||
* Optional. Called whenever new #GstVp9Picture is created.
|
* Optional. Called whenever new #GstVp9Picture is created.
|
||||||
* Subclass can set implementation specific user data on the #GstVp9Picture
|
* Subclass can set implementation specific user data on the #GstVp9Picture
|
||||||
* via gst_vp9_picture_set_user_data()
|
* via gst_vp9_picture_set_user_data
|
||||||
*
|
*
|
||||||
* Since: 1.18
|
* Since: 1.18
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,26 +22,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gstvp9picture.h"
|
#include "gstvp9picture.h"
|
||||||
|
#include "gstcodecpicture-private.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_EXTERN (gst_vp9_decoder_debug);
|
GST_DEBUG_CATEGORY_EXTERN (gst_vp9_decoder_debug);
|
||||||
#define GST_CAT_DEFAULT gst_vp9_decoder_debug
|
#define GST_CAT_DEFAULT gst_vp9_decoder_debug
|
||||||
|
|
||||||
GST_DEFINE_MINI_OBJECT_TYPE (GstVp9Picture, gst_vp9_picture);
|
GST_DEFINE_MINI_OBJECT_TYPE (GstVp9Picture, gst_vp9_picture);
|
||||||
|
|
||||||
static void
|
|
||||||
_gst_vp9_picture_free (GstVp9Picture * picture)
|
|
||||||
{
|
|
||||||
GST_TRACE ("Free picture %p", 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_vp9_picture_new:
|
* gst_vp9_picture_new:
|
||||||
*
|
*
|
||||||
|
@ -58,53 +45,13 @@ gst_vp9_picture_new (void)
|
||||||
|
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
|
||||||
GST_TYPE_VP9_PICTURE, NULL, NULL,
|
GST_TYPE_VP9_PICTURE, NULL, NULL,
|
||||||
(GstMiniObjectFreeFunction) _gst_vp9_picture_free);
|
(GstMiniObjectFreeFunction) gst_codec_picture_free);
|
||||||
|
|
||||||
GST_TRACE ("New picture %p", pic);
|
GST_TRACE ("New picture %p", pic);
|
||||||
|
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vp9_picture_set_user_data:
|
|
||||||
* @picture: a #GstVp9Picture
|
|
||||||
* @user_data: 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.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gst_vp9_picture_set_user_data (GstVp9Picture * picture, gpointer user_data,
|
|
||||||
GDestroyNotify notify)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GST_IS_VP9_PICTURE (picture));
|
|
||||||
|
|
||||||
if (picture->notify)
|
|
||||||
picture->notify (picture->user_data);
|
|
||||||
|
|
||||||
picture->user_data = user_data;
|
|
||||||
picture->notify = notify;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vp9_picture_get_user_data:
|
|
||||||
* @picture: a #GstVp9Picture
|
|
||||||
*
|
|
||||||
* Gets private data set on the picture via
|
|
||||||
* gst_vp9_picture_set_user_data() previously.
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): The previously set user_data
|
|
||||||
*/
|
|
||||||
gpointer
|
|
||||||
gst_vp9_picture_get_user_data (GstVp9Picture * picture)
|
|
||||||
{
|
|
||||||
return picture->user_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vp9_dpb_new: (skip)
|
* gst_vp9_dpb_new: (skip)
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define __GST_VP9_PICTURE_H__
|
#define __GST_VP9_PICTURE_H__
|
||||||
|
|
||||||
#include <gst/codecs/codecs-prelude.h>
|
#include <gst/codecs/codecs-prelude.h>
|
||||||
|
#include <gst/codecs/gstcodecpicture.h>
|
||||||
#include <gst/codecs/gstvp9statefulparser.h>
|
#include <gst/codecs/gstvp9statefulparser.h>
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
|
@ -36,22 +37,13 @@ typedef struct _GstVp9Picture GstVp9Picture;
|
||||||
struct _GstVp9Picture
|
struct _GstVp9Picture
|
||||||
{
|
{
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstMiniObject parent;
|
GstCodecPicture parent;
|
||||||
|
|
||||||
/* From GstVideoCodecFrame */
|
|
||||||
guint32 system_frame_number;
|
|
||||||
|
|
||||||
GstVp9FrameHeader frame_hdr;
|
GstVp9FrameHeader frame_hdr;
|
||||||
|
|
||||||
/* raw data and size (does not have ownership) */
|
/* raw data and size (does not have ownership) */
|
||||||
const guint8 * data;
|
const guint8 * data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
/* decoder input state if this picture is discont point */
|
|
||||||
GstVideoCodecState *discont_state;
|
|
||||||
|
|
||||||
gpointer user_data;
|
|
||||||
GDestroyNotify notify;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_CODECS_API
|
GST_CODECS_API
|
||||||
|
@ -89,13 +81,27 @@ gst_clear_vp9_picture (GstVp9Picture ** picture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_CODECS_API
|
static inline void
|
||||||
void gst_vp9_picture_set_user_data (GstVp9Picture * picture,
|
gst_vp9_picture_set_user_data (GstVp9Picture * picture, gpointer user_data,
|
||||||
gpointer user_data,
|
GDestroyNotify notify)
|
||||||
GDestroyNotify notify);
|
{
|
||||||
|
gst_codec_picture_set_user_data (GST_CODEC_PICTURE (picture),
|
||||||
|
user_data, notify);
|
||||||
|
}
|
||||||
|
|
||||||
GST_CODECS_API
|
static inline gpointer
|
||||||
gpointer gst_vp9_picture_get_user_data (GstVp9Picture * picture);
|
gst_vp9_picture_get_user_data (GstVp9Picture * picture)
|
||||||
|
{
|
||||||
|
return gst_codec_picture_get_user_data (GST_CODEC_PICTURE (picture));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
gst_vp9_picture_set_discont_state (GstVp9Picture * picture,
|
||||||
|
GstVideoCodecState * discont_state)
|
||||||
|
{
|
||||||
|
gst_codec_picture_set_discont_state (GST_CODEC_PICTURE (picture),
|
||||||
|
discont_state);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* GstVp9Dpb *
|
* GstVp9Dpb *
|
||||||
|
|
|
@ -781,7 +781,7 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec,
|
if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec,
|
||||||
picture->discont_state, picture->frame_hdr.width,
|
GST_CODEC_PICTURE (picture)->discont_state, picture->frame_hdr.width,
|
||||||
picture->frame_hdr.height, view_buffer, &frame->output_buffer)) {
|
picture->frame_hdr.height, view_buffer, &frame->output_buffer)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to copy buffer");
|
GST_ERROR_OBJECT (self, "Failed to copy buffer");
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -744,7 +744,8 @@ gst_nv_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_nv_decoder_finish_surface (self->decoder,
|
ret = gst_nv_decoder_finish_surface (self->decoder,
|
||||||
vdec, picture->discont_state, surface, &frame->output_buffer);
|
vdec, GST_CODEC_PICTURE (picture)->discont_state, surface,
|
||||||
|
&frame->output_buffer);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
|
@ -273,17 +273,20 @@ gst_v4l2_codecs_vp9_dec_fill_refs (GstV4l2CodecVp9Dec * self,
|
||||||
|
|
||||||
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[0]]) {
|
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[0]]) {
|
||||||
ref_pic = reference_frames->pic_list[h->ref_frame_idx[0]];
|
ref_pic = reference_frames->pic_list[h->ref_frame_idx[0]];
|
||||||
self->v4l2_vp9_frame.last_frame_ts = ref_pic->system_frame_number * 1000;
|
self->v4l2_vp9_frame.last_frame_ts =
|
||||||
|
GST_CODEC_PICTURE_FRAME_NUMBER (ref_pic) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[1]]) {
|
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[1]]) {
|
||||||
ref_pic = reference_frames->pic_list[h->ref_frame_idx[1]];
|
ref_pic = reference_frames->pic_list[h->ref_frame_idx[1]];
|
||||||
self->v4l2_vp9_frame.golden_frame_ts = ref_pic->system_frame_number * 1000;
|
self->v4l2_vp9_frame.golden_frame_ts =
|
||||||
|
GST_CODEC_PICTURE_FRAME_NUMBER (ref_pic) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[2]]) {
|
if (reference_frames && reference_frames->pic_list[h->ref_frame_idx[2]]) {
|
||||||
ref_pic = reference_frames->pic_list[h->ref_frame_idx[2]];
|
ref_pic = reference_frames->pic_list[h->ref_frame_idx[2]];
|
||||||
self->v4l2_vp9_frame.alt_frame_ts = ref_pic->system_frame_number * 1000;
|
self->v4l2_vp9_frame.alt_frame_ts =
|
||||||
|
GST_CODEC_PICTURE_FRAME_NUMBER (ref_pic) * 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +799,7 @@ gst_v4l2_codec_vp9_dec_end_picture (GstVp9Decoder * decoder,
|
||||||
gst_memory_resize (self->bitstream, 0, bytesused);
|
gst_memory_resize (self->bitstream, 0, bytesused);
|
||||||
|
|
||||||
frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self),
|
frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self),
|
||||||
picture->system_frame_number);
|
GST_CODEC_PICTURE_FRAME_NUMBER (picture));
|
||||||
g_return_val_if_fail (frame, FALSE);
|
g_return_val_if_fail (frame, FALSE);
|
||||||
|
|
||||||
flow_ret = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL (self->src_pool),
|
flow_ret = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL (self->src_pool),
|
||||||
|
@ -811,7 +814,8 @@ gst_v4l2_codec_vp9_dec_end_picture (GstVp9Decoder * decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
request = gst_v4l2_decoder_alloc_request (self->decoder,
|
request = gst_v4l2_decoder_alloc_request (self->decoder,
|
||||||
picture->system_frame_number, self->bitstream, frame->output_buffer);
|
GST_CODEC_PICTURE_FRAME_NUMBER (picture), self->bitstream,
|
||||||
|
frame->output_buffer);
|
||||||
|
|
||||||
gst_video_codec_frame_unref (frame);
|
gst_video_codec_frame_unref (frame);
|
||||||
|
|
||||||
|
@ -903,11 +907,11 @@ gst_v4l2_codec_vp9_dec_duplicate_picture (GstVp9Decoder * decoder,
|
||||||
GstVp9Picture *new_picture;
|
GstVp9Picture *new_picture;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (decoder, "Duplicate picture %u",
|
GST_DEBUG_OBJECT (decoder, "Duplicate picture %u",
|
||||||
picture->system_frame_number);
|
GST_CODEC_PICTURE_FRAME_NUMBER (picture));
|
||||||
|
|
||||||
new_picture = gst_vp9_picture_new ();
|
new_picture = gst_vp9_picture_new ();
|
||||||
new_picture->frame_hdr = picture->frame_hdr;
|
new_picture->frame_hdr = picture->frame_hdr;
|
||||||
new_picture->system_frame_number = frame->system_frame_number;
|
GST_CODEC_PICTURE_FRAME_NUMBER (new_picture) = frame->system_frame_number;
|
||||||
|
|
||||||
if (GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER)) {
|
if (GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER)) {
|
||||||
GstBuffer *output_buffer = gst_vp9_picture_get_user_data (picture);
|
GstBuffer *output_buffer = gst_vp9_picture_get_user_data (picture);
|
||||||
|
@ -942,16 +946,18 @@ gst_v4l2_codec_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
GstV4l2CodecVp9Dec *self = GST_V4L2_CODEC_VP9_DEC (decoder);
|
GstV4l2CodecVp9Dec *self = GST_V4L2_CODEC_VP9_DEC (decoder);
|
||||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||||
GstV4l2Request *request = NULL;
|
GstV4l2Request *request = NULL;
|
||||||
|
GstCodecPicture *codec_picture = GST_CODEC_PICTURE (picture);
|
||||||
gint ret;
|
gint ret;
|
||||||
|
|
||||||
if (picture->discont_state) {
|
if (codec_picture->discont_state) {
|
||||||
if (!gst_video_decoder_negotiate (vdec)) {
|
if (!gst_video_decoder_negotiate (vdec)) {
|
||||||
GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
|
GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
|
GST_DEBUG_OBJECT (self, "Output picture %u",
|
||||||
|
codec_picture->system_frame_number);
|
||||||
|
|
||||||
if (!GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER))
|
if (!GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER))
|
||||||
request = gst_vp9_picture_get_user_data (picture);
|
request = gst_vp9_picture_get_user_data (picture);
|
||||||
|
@ -971,7 +977,8 @@ gst_v4l2_codec_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
|
|
||||||
if (gst_v4l2_request_failed (request)) {
|
if (gst_v4l2_request_failed (request)) {
|
||||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||||
("Failed to decode frame %u", picture->system_frame_number), (NULL));
|
("Failed to decode frame %u", codec_picture->system_frame_number),
|
||||||
|
(NULL));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +993,8 @@ gst_v4l2_codec_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
/* This may happen if we duplicate a picture witch failed to decode */
|
/* This may happen if we duplicate a picture witch failed to decode */
|
||||||
if (!frame->output_buffer) {
|
if (!frame->output_buffer) {
|
||||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||||
("Failed to decode frame %u", picture->system_frame_number), (NULL));
|
("Failed to decode frame %u", codec_picture->system_frame_number),
|
||||||
|
(NULL));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,8 @@ gst_va_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
||||||
|
|
||||||
GST_LOG_OBJECT (self, "Outputting picture %p", picture);
|
GST_LOG_OBJECT (self, "Outputting picture %p", picture);
|
||||||
|
|
||||||
ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
|
ret = gst_va_base_dec_process_output (base,
|
||||||
|
frame, GST_CODEC_PICTURE (picture)->discont_state, 0);
|
||||||
gst_vp9_picture_unref (picture);
|
gst_vp9_picture_unref (picture);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Reference in a new issue