av1decoder: Sync duplicate_picture with VP9 one

Pass the current frame to the duplicate_picture callback. This makes it easier
to set the frame's output_buffer if we already have one available. Also
documented that unlike VP9, it is not optional to implement this as the
picture will populate the DPB if it is a key-frame. To ensure this, remove the
default implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1992>
This commit is contained in:
Daniel Almeida 2022-02-02 10:05:16 -03:00 committed by GStreamer Marge Bot
parent a7ceac50b2
commit 9a364464f0
5 changed files with 13 additions and 26 deletions

View file

@ -74,9 +74,6 @@ static GstFlowReturn gst_av1_decoder_drain (GstVideoDecoder * decoder);
static GstFlowReturn gst_av1_decoder_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static GstAV1Picture *gst_av1_decoder_duplicate_picture_default (GstAV1Decoder *
decoder, GstAV1Picture * picture);
static void
gst_av1_decoder_class_init (GstAV1DecoderClass * klass)
{
@ -90,9 +87,6 @@ gst_av1_decoder_class_init (GstAV1DecoderClass * klass)
decoder_class->drain = GST_DEBUG_FUNCPTR (gst_av1_decoder_drain);
decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_av1_decoder_handle_frame);
klass->duplicate_picture =
GST_DEBUG_FUNCPTR (gst_av1_decoder_duplicate_picture_default);
}
static void
@ -199,17 +193,6 @@ gst_av1_decoder_drain (GstVideoDecoder * decoder)
return GST_FLOW_OK;
}
static GstAV1Picture *
gst_av1_decoder_duplicate_picture_default (GstAV1Decoder * decoder,
GstAV1Picture * picture)
{
GstAV1Picture *new_picture;
new_picture = gst_av1_picture_new ();
return new_picture;
}
static const gchar *
get_obu_name (GstAV1OBUType type)
{
@ -363,10 +346,10 @@ gst_av1_decoder_decode_frame_header (GstAV1Decoder * self,
return GST_FLOW_ERROR;
}
/* FIXME: duplicate picture might be optional feature like that of VP9
* decoder baseclass */
/* The duplicated picture, if a key frame, will be placed in the DPB and
* for this reason is not optional. */
g_assert (klass->duplicate_picture);
picture = klass->duplicate_picture (self, ref_picture);
picture = klass->duplicate_picture (self, priv->current_frame, ref_picture);
if (!picture) {
GST_ERROR_OBJECT (self, "subclass didn't provide duplicated picture");
return GST_FLOW_ERROR;

View file

@ -96,13 +96,16 @@ struct _GstAV1DecoderClass
* GstAV1DecoderClass::duplicate_picture:
* @decoder: a #GstAV1Decoder
* @picture: (transfer none): a #GstAV1Picture
* @frame: (transfer none): the current #GstVideoCodecFrame
*
* Optional. Called when need to duplicate an existing
* #GstAV1Picture.
* Called when need to duplicate an existing #GstAV1Picture. As
* duplicated key-frame will populate the DPB, this virtual
* function is not optional.
*
* Since: 1.20
* Since: 1.22
*/
GstAV1Picture * (*duplicate_picture) (GstAV1Decoder * decoder,
GstVideoCodecFrame * frame,
GstAV1Picture * picture);
/**
* GstAV1DecoderClass::start_picture:

View file

@ -459,6 +459,7 @@ gst_vp9_decoder_handle_frame (GstVideoDecoder * decoder,
GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY (frame);
gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
return GST_FLOW_OK;
}
pic_to_dup = priv->dpb->pic_list[frame_hdr.frame_to_show_map_idx];

View file

@ -427,7 +427,7 @@ static GstFlowReturn gst_d3d11_av1_dec_new_sequence (GstAV1Decoder * decoder,
static GstFlowReturn gst_d3d11_av1_dec_new_picture (GstAV1Decoder * decoder,
GstVideoCodecFrame * frame, GstAV1Picture * picture);
static GstAV1Picture *gst_d3d11_av1_dec_duplicate_picture (GstAV1Decoder *
decoder, GstAV1Picture * picture);
decoder, GstVideoCodecFrame * frame, GstAV1Picture * picture);
static GstFlowReturn gst_d3d11_av1_dec_start_picture (GstAV1Decoder * decoder,
GstAV1Picture * picture, GstAV1Dpb * dpb);
static GstFlowReturn gst_d3d11_av1_dec_decode_tile (GstAV1Decoder * decoder,
@ -728,7 +728,7 @@ gst_d3d11_av1_dec_new_picture (GstAV1Decoder * decoder,
static GstAV1Picture *
gst_d3d11_av1_dec_duplicate_picture (GstAV1Decoder * decoder,
GstAV1Picture * picture)
GstVideoCodecFrame * frame, GstAV1Picture * picture)
{
GstD3D11AV1Dec *self = GST_D3D11_AV1_DEC (decoder);
GstBuffer *view_buffer;

View file

@ -357,7 +357,7 @@ gst_va_av1_dec_new_picture (GstAV1Decoder * decoder,
static GstAV1Picture *
gst_va_av1_dec_duplicate_picture (GstAV1Decoder * decoder,
GstAV1Picture * picture)
GstVideoCodecFrame * frame, GstAV1Picture * picture)
{
GstVaAV1Dec *self = GST_VA_AV1_DEC (decoder);
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);