mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
vaav1dec: Use gst_va_base_dec_prepare_output_frame().
And simplify a bit the code flow. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3480>
This commit is contained in:
parent
4a8ecc2dba
commit
31c63a6e6c
1 changed files with 33 additions and 26 deletions
|
@ -369,6 +369,35 @@ gst_va_av1_dec_new_sequence (GstAV1Decoder * decoder,
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline GstFlowReturn
|
||||||
|
_acquire_internal_buffer (GstVaAV1Dec * self, GstVideoCodecFrame * frame)
|
||||||
|
{
|
||||||
|
GstVaBaseDec *base = GST_VA_BASE_DEC (self);
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
|
if (!self->internal_pool) {
|
||||||
|
self->internal_pool =
|
||||||
|
_create_internal_pool (self, self->max_width, self->max_height);
|
||||||
|
if (!self->internal_pool)
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base->need_negotiation) {
|
||||||
|
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self)))
|
||||||
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gst_buffer_pool_acquire_buffer (self->internal_pool,
|
||||||
|
&frame->output_buffer, NULL);
|
||||||
|
if (ret != GST_FLOW_OK) {
|
||||||
|
GST_WARNING_OBJECT (self,
|
||||||
|
"Failed to allocated output buffer from internal pool, return %s",
|
||||||
|
gst_flow_get_name (ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_va_av1_dec_new_picture (GstAV1Decoder * decoder,
|
gst_va_av1_dec_new_picture (GstAV1Decoder * decoder,
|
||||||
GstVideoCodecFrame * frame, GstAV1Picture * picture)
|
GstVideoCodecFrame * frame, GstAV1Picture * picture)
|
||||||
|
@ -376,19 +405,15 @@ gst_va_av1_dec_new_picture (GstAV1Decoder * decoder,
|
||||||
GstVaAV1Dec *self = GST_VA_AV1_DEC (decoder);
|
GstVaAV1Dec *self = GST_VA_AV1_DEC (decoder);
|
||||||
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
|
||||||
GstVaDecodePicture *pic;
|
GstVaDecodePicture *pic;
|
||||||
GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
|
|
||||||
GstAV1FrameHeaderOBU *frame_hdr = &picture->frame_hdr;
|
GstAV1FrameHeaderOBU *frame_hdr = &picture->frame_hdr;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
/* Only output the highest spatial layer. For non output pictures,
|
/* Only output the highest spatial layer. For non output pictures,
|
||||||
we just use internal pool, then no negotiation needed. */
|
we just use internal pool, then no negotiation needed. */
|
||||||
if (picture->spatial_id < decoder->highest_spatial_layer) {
|
if (picture->spatial_id < decoder->highest_spatial_layer) {
|
||||||
if (!self->internal_pool) {
|
ret = _acquire_internal_buffer (self, frame);
|
||||||
self->internal_pool =
|
if (ret != GST_FLOW_OK)
|
||||||
_create_internal_pool (self, self->max_width, self->max_height);
|
return ret;
|
||||||
if (!self->internal_pool)
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (frame_hdr->upscaled_width != base->width
|
if (frame_hdr->upscaled_width != base->width
|
||||||
|| frame_hdr->frame_height != base->height) {
|
|| frame_hdr->frame_height != base->height) {
|
||||||
|
@ -407,26 +432,8 @@ gst_va_av1_dec_new_picture (GstAV1Decoder * decoder,
|
||||||
|
|
||||||
base->need_negotiation = TRUE;
|
base->need_negotiation = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (base->need_negotiation) {
|
ret = gst_va_base_dec_prepare_output_frame (base, frame);
|
||||||
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
|
|
||||||
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
|
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (picture->spatial_id < decoder->highest_spatial_layer) {
|
|
||||||
ret = gst_buffer_pool_acquire_buffer (self->internal_pool,
|
|
||||||
&frame->output_buffer, NULL);
|
|
||||||
if (ret != GST_FLOW_OK) {
|
|
||||||
GST_WARNING_OBJECT (self,
|
|
||||||
"Failed to allocated output buffer from internal pool, return %s",
|
|
||||||
gst_flow_get_name (ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = gst_video_decoder_allocate_output_frame (vdec, frame);
|
|
||||||
if (ret != GST_FLOW_OK) {
|
if (ret != GST_FLOW_OK) {
|
||||||
GST_WARNING_OBJECT (self, "Failed to allocated output buffer, return %s",
|
GST_WARNING_OBJECT (self, "Failed to allocated output buffer, return %s",
|
||||||
gst_flow_get_name (ret));
|
gst_flow_get_name (ret));
|
||||||
|
|
Loading…
Reference in a new issue