mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
pngenc: output one frame only in snapshot mode
In snapshot mode pngenc should output exactly one frame and then return FLOW_EOS to upstream. If upstream sends more input frames before shutting down, it should keep returning FLOW_EOS but not output any more encoded frames. After a flushing seek it should output frames again though. Fixes #3069. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5546>
This commit is contained in:
parent
7fd7917c78
commit
d69885e0f7
2 changed files with 19 additions and 1 deletions
|
@ -86,6 +86,7 @@ static GstFlowReturn gst_pngenc_handle_frame (GstVideoEncoder * encoder,
|
||||||
GstVideoCodecFrame * frame);
|
GstVideoCodecFrame * frame);
|
||||||
static gboolean gst_pngenc_set_format (GstVideoEncoder * encoder,
|
static gboolean gst_pngenc_set_format (GstVideoEncoder * encoder,
|
||||||
GstVideoCodecState * state);
|
GstVideoCodecState * state);
|
||||||
|
static gboolean gst_pngenc_flush (GstVideoEncoder * encoder);
|
||||||
static gboolean gst_pngenc_propose_allocation (GstVideoEncoder * encoder,
|
static gboolean gst_pngenc_propose_allocation (GstVideoEncoder * encoder,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
|
||||||
|
@ -143,6 +144,7 @@ gst_pngenc_class_init (GstPngEncClass * klass)
|
||||||
venc_class->set_format = gst_pngenc_set_format;
|
venc_class->set_format = gst_pngenc_set_format;
|
||||||
venc_class->handle_frame = gst_pngenc_handle_frame;
|
venc_class->handle_frame = gst_pngenc_handle_frame;
|
||||||
venc_class->propose_allocation = gst_pngenc_propose_allocation;
|
venc_class->propose_allocation = gst_pngenc_propose_allocation;
|
||||||
|
venc_class->flush = gst_pngenc_flush;
|
||||||
gobject_class->finalize = gst_pngenc_finalize;
|
gobject_class->finalize = gst_pngenc_finalize;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (pngenc_debug, "pngenc", 0, "PNG image encoder");
|
GST_DEBUG_CATEGORY_INIT (pngenc_debug, "pngenc", 0, "PNG image encoder");
|
||||||
|
@ -310,6 +312,16 @@ user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||||
pngenc->output_mem_pos += length;
|
pngenc->output_mem_pos += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_pngenc_flush (GstVideoEncoder * encoder)
|
||||||
|
{
|
||||||
|
GstPngEnc *pngenc = GST_PNGENC (encoder);
|
||||||
|
|
||||||
|
pngenc->frame_count = 0;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
|
gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
|
||||||
{
|
{
|
||||||
|
@ -323,6 +335,10 @@ gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
pngenc = GST_PNGENC (encoder);
|
pngenc = GST_PNGENC (encoder);
|
||||||
|
|
||||||
|
if (pngenc->snapshot && pngenc->frame_count > 0)
|
||||||
|
return GST_FLOW_EOS;
|
||||||
|
|
||||||
info = &pngenc->input_state->info;
|
info = &pngenc->input_state->info;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (pngenc, "BEGINNING");
|
GST_DEBUG_OBJECT (pngenc, "BEGINNING");
|
||||||
|
@ -408,6 +424,8 @@ gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
|
||||||
if ((ret = gst_video_encoder_finish_frame (encoder, frame)) != GST_FLOW_OK)
|
if ((ret = gst_video_encoder_finish_frame (encoder, frame)) != GST_FLOW_OK)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
++pngenc->frame_count;
|
||||||
|
|
||||||
if (pngenc->snapshot)
|
if (pngenc->snapshot)
|
||||||
ret = GST_FLOW_EOS;
|
ret = GST_FLOW_EOS;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct _GstPngEnc
|
||||||
guint compression_level;
|
guint compression_level;
|
||||||
|
|
||||||
gboolean snapshot;
|
gboolean snapshot;
|
||||||
gboolean newmedia;
|
guint frame_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
GST_ELEMENT_REGISTER_DECLARE (pngenc);
|
GST_ELEMENT_REGISTER_DECLARE (pngenc);
|
||||||
|
|
Loading…
Reference in a new issue