mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
av1decoder: Port to GstCodecPicture struct
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5285>
This commit is contained in:
parent
a73c6d7fb6
commit
97fc02cfe3
8 changed files with 53 additions and 95 deletions
|
@ -491,7 +491,7 @@ gst_av1_decoder_decode_frame_header (GstAV1Decoder * self,
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
picture->system_frame_number = ref_picture->system_frame_number;
|
||||
GST_CODEC_PICTURE_COPY_FRAME_NUMBER (picture, ref_picture);
|
||||
picture->frame_hdr = *frame_header;
|
||||
priv->current_picture = picture;
|
||||
} else {
|
||||
|
@ -501,7 +501,8 @@ gst_av1_decoder_decode_frame_header (GstAV1Decoder * self,
|
|||
picture->show_frame = frame_header->show_frame;
|
||||
picture->showable_frame = frame_header->showable_frame;
|
||||
picture->apply_grain = frame_header->film_grain_params.apply_grain;
|
||||
picture->system_frame_number = priv->current_frame->system_frame_number;
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (picture) =
|
||||
priv->current_frame->system_frame_number;
|
||||
picture->temporal_id = obu->header.obu_temporal_id;
|
||||
picture->spatial_id = obu->header.obu_spatial_id;
|
||||
|
||||
|
@ -761,8 +762,8 @@ out:
|
|||
/* If subclass didn't update output state at this point,
|
||||
* marking this picture as a discont and stores current input state */
|
||||
if (priv->input_state_changed) {
|
||||
priv->current_picture->discont_state =
|
||||
gst_video_codec_state_ref (self->input_state);
|
||||
gst_av1_picture_set_discont_state (priv->current_picture,
|
||||
self->input_state);
|
||||
priv->input_state_changed = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ struct _GstAV1DecoderClass
|
|||
*
|
||||
* Optional. Called whenever new #GstAV1Picture is created.
|
||||
* Subclass can set implementation specific user data
|
||||
* on the #GstAV1Picture via gst_av1_picture_set_user_data()
|
||||
* on the #GstAV1Picture via gst_av1_picture_set_user_data
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
|
|
|
@ -22,26 +22,13 @@
|
|||
#endif
|
||||
|
||||
#include "gstav1picture.h"
|
||||
#include "gstcodecpicture-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_av1_decoder_debug);
|
||||
#define GST_CAT_DEFAULT gst_av1_decoder_debug
|
||||
|
||||
GST_DEFINE_MINI_OBJECT_TYPE (GstAV1Picture, gst_av1_picture);
|
||||
|
||||
static void
|
||||
_gst_av1_picture_free (GstAV1Picture * 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_av1_picture_new:
|
||||
*
|
||||
|
@ -60,57 +47,13 @@ gst_av1_picture_new (void)
|
|||
|
||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
|
||||
GST_TYPE_AV1_PICTURE, NULL, NULL,
|
||||
(GstMiniObjectFreeFunction) _gst_av1_picture_free);
|
||||
(GstMiniObjectFreeFunction) gst_codec_picture_free);
|
||||
|
||||
GST_TRACE ("New picture %p", pic);
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_av1_picture_set_user_data:
|
||||
* @picture: a #GstAV1Picture
|
||||
* @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.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
void
|
||||
gst_av1_picture_set_user_data (GstAV1Picture * picture, gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
g_return_if_fail (GST_IS_AV1_PICTURE (picture));
|
||||
|
||||
if (picture->notify)
|
||||
picture->notify (picture->user_data);
|
||||
|
||||
picture->user_data = user_data;
|
||||
picture->notify = notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_av1_picture_get_user_data:
|
||||
* @picture: a #GstAV1Picture
|
||||
*
|
||||
* Gets private data set on the picture via
|
||||
* gst_av1_picture_set_user_data() previously.
|
||||
*
|
||||
* Returns: (transfer none): The previously set user_data
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
gpointer
|
||||
gst_av1_picture_get_user_data (GstAV1Picture * picture)
|
||||
{
|
||||
return picture->user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_av1_dpb_new: (skip)
|
||||
*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define __GST_AV1_PICTURE_H__
|
||||
|
||||
#include <gst/codecs/codecs-prelude.h>
|
||||
#include <gst/codecs/gstcodecpicture.h>
|
||||
#include <gst/codecparsers/gstav1parser.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
|
@ -68,10 +69,7 @@ struct _GstAV1Tile
|
|||
struct _GstAV1Picture
|
||||
{
|
||||
/*< private >*/
|
||||
GstMiniObject parent;
|
||||
|
||||
/* From GstVideoCodecFrame */
|
||||
guint32 system_frame_number;
|
||||
GstCodecPicture parent;
|
||||
|
||||
GstAV1FrameHeaderOBU frame_hdr;
|
||||
|
||||
|
@ -84,12 +82,6 @@ struct _GstAV1Picture
|
|||
gboolean show_frame;
|
||||
gboolean showable_frame;
|
||||
gboolean apply_grain;
|
||||
|
||||
/* decoder input state if this picture is discont point */
|
||||
GstVideoCodecState *discont_state;
|
||||
|
||||
gpointer user_data;
|
||||
GDestroyNotify notify;
|
||||
};
|
||||
|
||||
GST_CODECS_API
|
||||
|
@ -127,13 +119,27 @@ gst_clear_av1_picture (GstAV1Picture ** picture)
|
|||
}
|
||||
}
|
||||
|
||||
GST_CODECS_API
|
||||
void gst_av1_picture_set_user_data (GstAV1Picture * picture,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
static inline void
|
||||
gst_av1_picture_set_user_data (GstAV1Picture * picture, gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
gst_codec_picture_set_user_data (GST_CODEC_PICTURE (picture),
|
||||
user_data, notify);
|
||||
}
|
||||
|
||||
GST_CODECS_API
|
||||
gpointer gst_av1_picture_get_user_data (GstAV1Picture * picture);
|
||||
static inline gpointer
|
||||
gst_av1_picture_get_user_data (GstAV1Picture * picture)
|
||||
{
|
||||
return gst_codec_picture_get_user_data (GST_CODEC_PICTURE (picture));
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_av1_picture_set_discont_state (GstAV1Picture * picture,
|
||||
GstVideoCodecState * discont_state)
|
||||
{
|
||||
gst_codec_picture_set_discont_state (GST_CODEC_PICTURE (picture),
|
||||
discont_state);
|
||||
}
|
||||
|
||||
/*******************
|
||||
* GstAV1Dpb *
|
||||
|
|
|
@ -1225,9 +1225,9 @@ gst_d3d11_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
}
|
||||
|
||||
if (!gst_d3d11_decoder_process_output (inner->d3d11_decoder, vdec,
|
||||
picture->discont_state, picture->frame_hdr.render_width,
|
||||
picture->frame_hdr.render_height, view_buffer,
|
||||
&frame->output_buffer)) {
|
||||
GST_CODEC_PICTURE (picture)->discont_state,
|
||||
picture->frame_hdr.render_width, picture->frame_hdr.render_height,
|
||||
view_buffer, &frame->output_buffer)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to copy buffer");
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -1032,7 +1032,8 @@ gst_nv_av1_dec_output_picture (GstAV1Decoder * 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)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ gst_v4l2_codec_av1_fill_refs (GstV4l2CodecAV1Dec * self,
|
|||
|
||||
/* the decoder might not have filled all slots in the first few frames */
|
||||
self->v4l2_frame.reference_frame_ts[i] =
|
||||
ref_pic ? ref_pic->system_frame_number * 1000 : 0;
|
||||
ref_pic ? GST_CODEC_PICTURE_FRAME_NUMBER (ref_pic) * 1000 : 0;
|
||||
}
|
||||
|
||||
memcpy (self->v4l2_frame.ref_frame_idx, frame_hdr->ref_frame_idx,
|
||||
|
@ -1133,11 +1133,11 @@ gst_v4l2_codec_av1_dec_duplicate_picture (GstAV1Decoder * decoder,
|
|||
GstAV1Picture *new_picture;
|
||||
|
||||
GST_DEBUG_OBJECT (decoder, "Duplicate picture %u",
|
||||
picture->system_frame_number);
|
||||
GST_CODEC_PICTURE_FRAME_NUMBER (picture));
|
||||
|
||||
new_picture = gst_av1_picture_new ();
|
||||
new_picture->frame_hdr = picture->frame_hdr;
|
||||
new_picture->system_frame_number = picture->system_frame_number;
|
||||
GST_CODEC_PICTURE_COPY_FRAME_NUMBER (new_picture, picture);
|
||||
|
||||
if (GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER)) {
|
||||
GstBuffer *output_buffer = gst_av1_picture_get_user_data (picture);
|
||||
|
@ -1286,7 +1286,7 @@ gst_v4l2_codec_av1_dec_end_picture (GstAV1Decoder * decoder,
|
|||
gst_memory_resize (self->bitstream, 0, bytesused);
|
||||
|
||||
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);
|
||||
|
||||
flow_ret = gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL (self->src_pool),
|
||||
|
@ -1301,7 +1301,8 @@ gst_v4l2_codec_av1_dec_end_picture (GstAV1Decoder * 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);
|
||||
|
||||
|
@ -1389,9 +1390,11 @@ gst_v4l2_codec_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
GstV4l2CodecAV1Dec *self = GST_V4L2_CODEC_AV1_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstV4l2Request *request = NULL;
|
||||
GstCodecPicture *codec_picture = GST_CODEC_PICTURE (picture);
|
||||
gint ret;
|
||||
|
||||
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))
|
||||
request = gst_av1_picture_get_user_data (picture);
|
||||
|
@ -1410,7 +1413,8 @@ gst_v4l2_codec_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
|
||||
if (gst_v4l2_request_failed (request)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1425,7 +1429,8 @@ gst_v4l2_codec_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
/* This may happen if we duplicate a picture witch failed to decode */
|
||||
if (!frame->output_buffer) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -923,7 +923,7 @@ gst_va_av1_dec_end_picture (GstAV1Decoder * decoder, GstAV1Picture * picture)
|
|||
GstVaDecodePicture *va_pic;
|
||||
|
||||
GST_LOG_OBJECT (self, "end picture %p, (system_frame_number %d)",
|
||||
picture, picture->system_frame_number);
|
||||
picture, GST_CODEC_PICTURE_FRAME_NUMBER (picture));
|
||||
|
||||
va_pic = gst_av1_picture_get_user_data (picture);
|
||||
|
||||
|
@ -942,6 +942,7 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
GstVaAV1Dec *self = GST_VA_AV1_DEC (decoder);
|
||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
||||
GstCodecPicture *codec_picture = GST_CODEC_PICTURE (picture);
|
||||
gboolean ret;
|
||||
|
||||
g_assert (picture->frame_hdr.show_frame ||
|
||||
|
@ -949,7 +950,7 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
|
||||
GST_LOG_OBJECT (self,
|
||||
"Outputting picture %p (system_frame_number %d)",
|
||||
picture, picture->system_frame_number);
|
||||
picture, codec_picture->system_frame_number);
|
||||
|
||||
if (picture->frame_hdr.show_existing_frame) {
|
||||
GstVaDecodePicture *pic;
|
||||
|
@ -959,7 +960,8 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
|
|||
frame->output_buffer = gst_buffer_ref (pic->gstbuffer);
|
||||
}
|
||||
|
||||
ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
|
||||
ret = gst_va_base_dec_process_output (base,
|
||||
frame, codec_picture->discont_state, 0);
|
||||
gst_av1_picture_unref (picture);
|
||||
|
||||
if (ret)
|
||||
|
|
Loading…
Reference in a new issue