omxvideo: add debug infos to find_nearest_frame()

Those debug infos have proved to be very helpful when debugging
timestamp issues. They are often linked to gst-omx picking the wrong
frame when trying to map from OMX.
This commit is contained in:
Guillaume Desmottes 2019-06-14 10:57:29 +05:30
parent a7ecda85b6
commit cfeeb15b1e
4 changed files with 12 additions and 4 deletions

View file

@ -181,7 +181,8 @@ gst_omx_video_negotiation_map_free (GstOMXVideoNegotiationMap * m)
} }
GstVideoCodecFrame * GstVideoCodecFrame *
gst_omx_video_find_nearest_frame (GstOMXBuffer * buf, GList * frames) gst_omx_video_find_nearest_frame (GstElement * element, GstOMXBuffer * buf,
GList * frames)
{ {
GstVideoCodecFrame *best = NULL; GstVideoCodecFrame *best = NULL;
GstClockTimeDiff best_diff = G_MAXINT64; GstClockTimeDiff best_diff = G_MAXINT64;
@ -192,10 +193,17 @@ gst_omx_video_find_nearest_frame (GstOMXBuffer * buf, GList * frames)
gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp), gst_util_uint64_scale (GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp),
GST_SECOND, OMX_TICKS_PER_SECOND); GST_SECOND, OMX_TICKS_PER_SECOND);
GST_LOG_OBJECT (element, "look for ts %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
for (l = frames; l; l = l->next) { for (l = frames; l; l = l->next) {
GstVideoCodecFrame *tmp = l->data; GstVideoCodecFrame *tmp = l->data;
GstClockTimeDiff diff = ABS (GST_CLOCK_DIFF (timestamp, tmp->pts)); GstClockTimeDiff diff = ABS (GST_CLOCK_DIFF (timestamp, tmp->pts));
GST_LOG_OBJECT (element,
" frame %u diff %" G_GINT64_FORMAT " ts %" GST_TIME_FORMAT,
tmp->system_frame_number, diff, GST_TIME_ARGS (tmp->pts));
if (diff < best_diff) { if (diff < best_diff) {
best = tmp; best = tmp;
best_diff = diff; best_diff = diff;

View file

@ -57,7 +57,7 @@ void
gst_omx_video_negotiation_map_free (GstOMXVideoNegotiationMap * m); gst_omx_video_negotiation_map_free (GstOMXVideoNegotiationMap * m);
GstVideoCodecFrame * GstVideoCodecFrame *
gst_omx_video_find_nearest_frame (GstOMXBuffer * buf, GList * frames); gst_omx_video_find_nearest_frame (GstElement * element, GstOMXBuffer * buf, GList * frames);
OMX_U32 gst_omx_video_calculate_framerate_q16 (GstVideoInfo * info); OMX_U32 gst_omx_video_calculate_framerate_q16 (GstVideoInfo * info);

View file

@ -1716,7 +1716,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
gst_omx_buffer_flags_to_string (buf->omx_buf->nFlags), gst_omx_buffer_flags_to_string (buf->omx_buf->nFlags),
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp)); (guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
frame = gst_omx_video_find_nearest_frame (buf, frame = gst_omx_video_find_nearest_frame (GST_ELEMENT_CAST (self), buf,
gst_video_decoder_get_frames (GST_VIDEO_DECODER (self))); gst_video_decoder_get_frames (GST_VIDEO_DECODER (self)));
/* So we have a timestamped OMX buffer and get, or not, corresponding frame. /* So we have a timestamped OMX buffer and get, or not, corresponding frame.

View file

@ -1543,7 +1543,7 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
gst_omx_buffer_flags_to_string (buf->omx_buf->nFlags), gst_omx_buffer_flags_to_string (buf->omx_buf->nFlags),
(guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp)); (guint64) GST_OMX_GET_TICKS (buf->omx_buf->nTimeStamp));
frame = gst_omx_video_find_nearest_frame (buf, frame = gst_omx_video_find_nearest_frame (GST_ELEMENT_CAST (self), buf,
gst_video_encoder_get_frames (GST_VIDEO_ENCODER (self))); gst_video_encoder_get_frames (GST_VIDEO_ENCODER (self)));
g_assert (klass->handle_output_frame); g_assert (klass->handle_output_frame);