vtenc: Don't call drop_frame() when flushing

Slipped through with earlier changes to use drop/release_frame() explicitly.
We should only drop when something goes wrong in the encoder, and just release otherwise.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7475>
This commit is contained in:
Piotr Brzeziński 2024-09-09 15:53:25 +02:00 committed by GStreamer Marge Bot
parent 95ca7014c8
commit 9a232f7983

View file

@ -1976,7 +1976,6 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstVideoCodecFrame * frame)
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
CFDictionaryRef frame_props = NULL; CFDictionaryRef frame_props = NULL;
GstTaskState task_state; GstTaskState task_state;
gboolean is_flushing;
/* If this condition changes later while we're still in this function, /* If this condition changes later while we're still in this function,
* it'll just fail on next frame encode or in _finish() */ * it'll just fail on next frame encode or in _finish() */
@ -1984,28 +1983,30 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstVideoCodecFrame * frame)
if (task_state == GST_TASK_STOPPED || task_state == GST_TASK_PAUSED) { if (task_state == GST_TASK_STOPPED || task_state == GST_TASK_PAUSED) {
/* Abort if our loop failed to push frames downstream... */ /* Abort if our loop failed to push frames downstream... */
if (self->downstream_ret != GST_FLOW_OK) { if (self->downstream_ret != GST_FLOW_OK) {
if (self->downstream_ret == GST_FLOW_FLUSHING) ret = self->downstream_ret;
if (ret == GST_FLOW_FLUSHING) {
GST_DEBUG_OBJECT (self, GST_DEBUG_OBJECT (self,
"Output loop stopped because of flushing, ignoring frame"); "Output loop stopped because of flushing, ignoring frame");
else goto release;
} else {
GST_WARNING_OBJECT (self, GST_WARNING_OBJECT (self,
"Output loop stopped with error (%s), leaving", "Output loop stopped with error (%s), leaving",
gst_flow_get_name (self->downstream_ret)); gst_flow_get_name (ret));
goto drop;
ret = self->downstream_ret; }
goto drop;
} }
/* ...or if it stopped because of the flushing flag while the queue /* ...or if it stopped because of the flushing flag while the queue
* was empty, in which case we didn't get GST_FLOW_FLUSHING... */ * was empty, in which case we didn't get GST_FLOW_FLUSHING... */
g_mutex_lock (&self->queue_mutex); g_mutex_lock (&self->queue_mutex);
is_flushing = self->is_flushing; if (self->is_flushing) {
g_mutex_unlock (&self->queue_mutex); g_mutex_unlock (&self->queue_mutex);
if (is_flushing) {
GST_DEBUG_OBJECT (self, "Flushing flag set, ignoring frame"); GST_DEBUG_OBJECT (self, "Flushing flag set, ignoring frame");
ret = GST_FLOW_FLUSHING; ret = GST_FLOW_FLUSHING;
goto drop; goto release;
} }
g_mutex_unlock (&self->queue_mutex);
/* .. or if it refuses to resume - e.g. it was stopped instead of paused */ /* .. or if it refuses to resume - e.g. it was stopped instead of paused */
if (!gst_vtenc_ensure_output_loop (self)) { if (!gst_vtenc_ensure_output_loop (self)) {
@ -2225,17 +2226,16 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstVideoCodecFrame * frame)
return ret; return ret;
drop:
{
gst_video_encoder_drop_frame (GST_VIDEO_ENCODER_CAST (self), frame);
return ret;
}
cv_error: cv_error:
{ ret = GST_FLOW_ERROR;
gst_video_encoder_drop_frame (GST_VIDEO_ENCODER_CAST (self), frame);
return GST_FLOW_ERROR; drop:
} gst_video_encoder_drop_frame (GST_VIDEO_ENCODER_CAST (self), frame);
return ret;
release:
gst_video_encoder_release_frame (GST_VIDEO_ENCODER_CAST (self), frame);
return ret;
} }
static void static void