omx: Improve debug output
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 20 Dec 2012 11:20:31 +0000 (12:20 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 20 Dec 2012 11:20:31 +0000 (12:20 +0100)
omx/gstomxaudioenc.c
omx/gstomxvideodec.c
omx/gstomxvideoenc.c

index d6160fe..185ad5a 100644 (file)
@@ -292,6 +292,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
       goto caps_failed;
     }
 
+    GST_DEBUG_OBJECT (self, "Setting output caps: %" GST_PTR_FORMAT, caps);
+
     if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (self), caps)) {
       gst_caps_unref (caps);
       if (buf)
@@ -333,6 +335,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
       GstBuffer *codec_data;
       GstMapInfo map = GST_MAP_INFO_INIT;
 
+      GST_DEBUG_OBJECT (self, "Handling codec data");
       caps =
           gst_caps_copy (gst_pad_get_current_caps (GST_AUDIO_ENCODER_SRC_PAD
               (self)));
@@ -359,6 +362,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
       GstBuffer *outbuf;
       guint n_samples;
 
+      GST_DEBUG_OBJECT (self, "Handling output data");
+
       n_samples =
           klass->get_num_samples (self, self->out_port,
           gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (self)), buf);
@@ -391,6 +396,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
           outbuf, n_samples);
     }
 
+    GST_DEBUG_OBJECT (self, "Handled output data");
+
     if (is_eos || flow_ret == GST_FLOW_EOS) {
       g_mutex_lock (&self->drain_lock);
       if (self->draining) {
@@ -565,17 +572,23 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
    * format change happened we can just exit here.
    */
   if (needs_disable) {
+    GST_DEBUG_OBJECT (self, "Need to disable and drain encoder");
     gst_omx_audio_enc_drain (self);
 
     if (gst_omx_port_manual_reconfigure (self->in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
     if (gst_omx_port_set_enabled (self->in_port, FALSE) != OMX_ErrorNone)
       return FALSE;
+
+    GST_DEBUG_OBJECT (self, "Encoder drained and disabled");
   }
 
   port_def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
+  GST_DEBUG_OBJECT (self, "Setting inport port definition");
   if (!gst_omx_port_update_port_definition (self->in_port, &port_def))
     return FALSE;
+
+  GST_DEBUG_OBJECT (self, "Setting outport port definition");
   if (!gst_omx_port_update_port_definition (self->out_port, NULL))
     return FALSE;
 
@@ -632,6 +645,7 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
     pcm_param.eChannelMapping[i] = pos;
   }
 
+  GST_DEBUG_OBJECT (self, "Setting PCM parameters");
   err =
       gst_omx_component_set_parameter (self->component, OMX_IndexParamAudioPcm,
       &pcm_param);
@@ -648,6 +662,7 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
     }
   }
 
+  GST_DEBUG_OBJECT (self, "Enabling component");
   if (needs_disable) {
     if (gst_omx_port_set_enabled (self->in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
@@ -689,6 +704,7 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
   }
 
   /* Start the srcpad loop again */
+  GST_DEBUG_OBJECT (self, "Starting task again");
   self->downstream_flow_ret = GST_FLOW_OK;
   gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
       (GstTaskFunction) gst_omx_audio_enc_loop, encoder, NULL);
@@ -797,6 +813,8 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf)
       goto full_buffer;
     }
 
+    GST_DEBUG_OBJECT (self, "Handling frame at offset %d", offset);
+
     /* Copy the buffer content in chunks of size as requested
      * by the port */
     buf->omx_buf->nFilledLen =
@@ -828,6 +846,8 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf)
     gst_omx_port_release_buffer (self->in_port, buf);
   }
 
+  GST_DEBUG_OBJECT (self, "Passed frame to component");
+
   return self->downstream_flow_ret;
 
 full_buffer:
index b61da54..2af42a4 100644 (file)
@@ -552,9 +552,13 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
     switch (port_def.format.video.eColorFormat) {
       case OMX_COLOR_FormatYUV420Planar:
       case OMX_COLOR_FormatYUV420PackedPlanar:
+        GST_DEBUG_OBJECT (self, "Output is I420 (%d)",
+            port_def.format.video.eColorFormat);
         format = GST_VIDEO_FORMAT_I420;
         break;
       case OMX_COLOR_FormatYUV420SemiPlanar:
+        GST_DEBUG_OBJECT (self, "Output is NV12 (%d)",
+            port_def.format.video.eColorFormat);
         format = GST_VIDEO_FORMAT_NV12;
         break;
       default:
@@ -567,6 +571,11 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
         break;
     }
 
+    GST_DEBUG_OBJECT (self,
+        "Setting output state: format %s, width %d, height %d",
+        gst_video_format_to_string (format), port_def.format.video.nFrameWidth,
+        port_def.format.video.nFrameHeight);
+
     state = gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
         format, port_def.format.video.nFrameWidth,
         port_def.format.video.nFrameHeight, self->input_state);
@@ -659,6 +668,8 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
           gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
     }
 
+    GST_DEBUG_OBJECT (self, "Read frame from component");
+
     if (is_eos || flow_ret == GST_FLOW_EOS) {
       g_mutex_lock (&self->drain_lock);
       if (self->draining) {
@@ -853,8 +864,13 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
   GstStructure *s;
   const gchar *format_str;
 
+  GST_DEBUG_OBJECT (self, "Trying to negotiate a video format with downstream");
+
   intersection = gst_pad_get_allowed_caps (GST_VIDEO_DECODER_SRC_PAD (self));
 
+  GST_DEBUG_OBJECT (self, "Allowed downstream caps: %" GST_PTR_FORMAT,
+      intersection);
+
   GST_OMX_INIT_STRUCT (&param);
   param.nPortIndex = port->index;
   param.nIndex = 0;
@@ -890,6 +906,8 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
           gst_caps_append_structure (comp_supported_caps,
               gst_structure_new ("video/x-raw",
                   "format", G_TYPE_STRING, "I420", NULL));
+          GST_DEBUG_OBJECT (self, "Component supports I420 (%d) at index %d",
+              param.eColorFormat, param.nIndex);
           break;
         case OMX_COLOR_FormatYUV420SemiPlanar:
           m = g_slice_new0 (VideoNegotiationMap);
@@ -899,6 +917,8 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
           gst_caps_append_structure (comp_supported_caps,
               gst_structure_new ("video/x-raw",
                   "format", G_TYPE_STRING, "NV12", NULL));
+          GST_DEBUG_OBJECT (self, "Component supports NV12 (%d) at index %d",
+              param.eColorFormat, param.nIndex);
           break;
         default:
           break;
@@ -949,6 +969,9 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
     }
   }
 
+  GST_DEBUG_OBJECT (self, "Negotiating color format %s (%d)", format_str,
+      param.eColorFormat);
+
   /* We must find something here */
   g_assert (l != NULL);
   g_list_free_full (negotiation_map,
@@ -1016,6 +1039,8 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
   }
 
   if (needs_disable && is_format_change) {
+    GST_DEBUG_OBJECT (self, "Need to disable and drain decoder");
+
     gst_omx_video_dec_drain (self, FALSE);
 
     if (klass->cdata.hacks & GST_OMX_HACK_NO_COMPONENT_RECONFIGURE) {
@@ -1039,6 +1064,8 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
     if (self->input_state)
       gst_video_codec_state_unref (self->input_state);
     self->input_state = NULL;
+
+    GST_DEBUG_OBJECT (self, "Decoder drained and disabled");
   }
 
   port_def.format.video.nFrameWidth = info->width;
@@ -1048,8 +1075,12 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
   else
     port_def.format.video.xFramerate = (info->fps_n << 16) / (info->fps_d);
 
+  GST_DEBUG_OBJECT (self, "Setting inport port definition");
+
   if (!gst_omx_port_update_port_definition (self->in_port, &port_def))
     return FALSE;
+
+  GST_DEBUG_OBJECT (self, "Setting outport port definition");
   if (!gst_omx_port_update_port_definition (self->out_port, NULL))
     return FALSE;
 
@@ -1067,6 +1098,8 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
     GST_LOG_OBJECT (self, "Negotiation failed, will get output format later");
   }
 
+  GST_DEBUG_OBJECT (self, "Enabling component");
+
   if (needs_disable) {
     if (gst_omx_port_set_enabled (self->in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
@@ -1108,6 +1141,8 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
   }
 
   /* Start the srcpad loop again */
+  GST_DEBUG_OBJECT (self, "Starting task again");
+
   self->downstream_flow_ret = GST_FLOW_OK;
   gst_pad_start_task (GST_VIDEO_DECODER_SRC_PAD (self),
       (GstTaskFunction) gst_omx_video_dec_loop, decoder, NULL);
@@ -1233,6 +1268,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
     }
 
     if (self->codec_data) {
+      GST_DEBUG_OBJECT (self, "Passing codec data to the component");
+
       codec_data = self->codec_data;
 
       if (buf->omx_buf->nAllocLen - buf->omx_buf->nOffset <
@@ -1255,6 +1292,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
     }
 
     /* Now handle the frame */
+    GST_DEBUG_OBJECT (self, "Passing frame offset %d to the component", offset);
 
     /* Copy the buffer content in chunks of size as requested
      * by the port */
@@ -1305,6 +1343,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
     gst_omx_port_release_buffer (self->in_port, buf);
   }
 
+  GST_DEBUG_OBJECT (self, "Passed frame to component");
+
   return self->downstream_flow_ret;
 
 full_buffer:
index 4e64466..32e4f97 100644 (file)
@@ -618,6 +618,8 @@ gst_omx_video_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port,
     GstMapInfo map = GST_MAP_INFO_INIT;
     GstCaps *caps;
 
+    GST_DEBUG_OBJECT (self, "Handling codec data");
+
     caps = klass->get_caps (self, self->out_port, self->input_state);
     codec_data = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen);
 
@@ -637,6 +639,8 @@ gst_omx_video_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port,
     GstBuffer *outbuf;
     GstMapInfo map = GST_MAP_INFO_INIT;
 
+    GST_DEBUG_OBJECT (self, "Handling output data");
+
     if (buf->omx_buf->nFilledLen > 0) {
       outbuf = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen);
 
@@ -726,6 +730,9 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
       GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
       goto caps_failed;
     }
+
+    GST_DEBUG_OBJECT (self, "Setting output state: %" GST_PTR_FORMAT, caps);
+
     state =
         gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self), caps,
         self->input_state);
@@ -795,6 +802,8 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
     flow_ret = GST_FLOW_EOS;
   }
 
+  GST_DEBUG_OBJECT (self, "Read frame from component");
+
   if (flow_ret != GST_FLOW_OK)
     goto flow_error;
 
@@ -942,12 +951,15 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
    * format change happened we can just exit here.
    */
   if (needs_disable) {
+    GST_DEBUG_OBJECT (self, "Need to disable and drain encoder");
     gst_omx_video_enc_drain (self, FALSE);
 
     if (gst_omx_port_manual_reconfigure (self->in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
     if (gst_omx_port_set_enabled (self->in_port, FALSE) != OMX_ErrorNone)
       return FALSE;
+
+    GST_DEBUG_OBJECT (self, "Encoder drained and disabled");
   }
 
   switch (info->finfo->format) {
@@ -974,8 +986,11 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
       port_def.format.video.xFramerate = (info->fps_n) / (info->fps_d);
   }
 
+  GST_DEBUG_OBJECT (self, "Setting inport port definition");
   if (!gst_omx_port_update_port_definition (self->in_port, &port_def))
     return FALSE;
+
+  GST_DEBUG_OBJECT (self, "Setting outport port definition");
   if (!gst_omx_port_update_port_definition (self->out_port, NULL))
     return FALSE;
 
@@ -986,6 +1001,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
     }
   }
 
+  GST_DEBUG_OBJECT (self, "Enabling component");
   if (needs_disable) {
     if (gst_omx_port_set_enabled (self->in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
@@ -1031,6 +1047,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
   self->input_state = gst_video_codec_state_ref (self->input_state);
 
   /* Start the srcpad loop again */
+  GST_DEBUG_OBJECT (self, "Starting task again");
   self->downstream_flow_ret = GST_FLOW_OK;
   gst_pad_start_task (GST_VIDEO_ENCODER_SRC_PAD (self),
       (GstTaskFunction) gst_omx_video_enc_loop, encoder, NULL);
@@ -1299,6 +1316,8 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
     }
 
     /* Now handle the frame */
+    GST_DEBUG_OBJECT (self, "Handling frame");
+
     if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (frame)) {
       OMX_ERRORTYPE err;
       OMX_CONFIG_INTRAREFRESHVOPTYPE config;
@@ -1307,6 +1326,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
       config.nPortIndex = self->out_port->index;
       config.IntraRefreshVOP = OMX_TRUE;
 
+      GST_DEBUG_OBJECT (self, "Forcing a keyframe");
       err =
           gst_omx_component_set_config (self->component,
           OMX_IndexConfigVideoIntraVOPRefresh, &config);
@@ -1344,6 +1364,8 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
 
     self->started = TRUE;
     gst_omx_port_release_buffer (self->in_port, buf);
+
+    GST_DEBUG_OBJECT (self, "Passed frame to component");
   }
 
   return self->downstream_flow_ret;;