v4l2videoenc: set GstVideoCodecFrame sync point flag
authorPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 25 Jun 2018 15:49:07 +0000 (17:49 +0200)
committerNicolas Dufresne <nicolas@ndufresne.ca>
Thu, 21 Mar 2019 18:05:51 +0000 (18:05 +0000)
The V4L2 elements already set the delta unit buffer flag when dequeueing
the buffer, but gst_video_encoder_finish_frame overwrites it from the
passed codec frame's sync point flag. Set the flag correctly.

sys/v4l2/gstv4l2videoenc.c

index c8a5389..c7943d7 100644 (file)
@@ -661,6 +661,15 @@ gst_v4l2_video_enc_loop (GstVideoEncoder * encoder)
   frame = gst_v4l2_video_enc_get_oldest_frame (encoder);
 
   if (frame) {
+    /* At this point, the delta unit buffer flag is already correctly set by
+     * gst_v4l2_buffer_pool_process. Since gst_video_encoder_finish_frame
+     * will overwrite it from GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT (frame),
+     * set that here.
+     */
+    if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT))
+      GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame);
+    else
+      GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
     frame->output_buffer = buffer;
     buffer = NULL;
     ret = gst_video_encoder_finish_frame (encoder, frame);