[vlc-commits] [Git][videolan/vlc][master] 2 commits: vlc_es: add a way to log differences between ES/video formats

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Nov 18 10:52:56 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
fe85a32a by Steve Lhomme at 2023-11-18T10:23:50+00:00
vlc_es: add a way to log differences between ES/video formats

When es_format_IsSimilar and video_format_IsSimilar report a format
is not similar, it can be useful to know the reason.

These logging functions match the tests done in thos functions.

- - - - -
bf87e846 by Steve Lhomme at 2023-11-18T10:23:50+00:00
decoder: log why the packetizer restarts the decoder

- - - - -


4 changed files:

- include/vlc_es.h
- src/input/decoder.c
- src/libvlccore.sym
- src/misc/es_format.c


Changes:

=====================================
include/vlc_es.h
=====================================
@@ -701,6 +701,21 @@ VLC_API void es_format_Clean( es_format_t *fmt );
  */
 VLC_API bool es_format_IsSimilar( const es_format_t *, const es_format_t * );
 
+/**
+ * Log differences between 2 ES format.
+ * The difference checks the same fields as \ref es_format_IsSimilar
+ */
+VLC_API void es_format_LogDifferences(struct vlc_logger *,
+                                      const char *name_a, const es_format_t *a,
+                                      const char *name_b, const es_format_t *b);
+/**
+ * Log differences between 2 video format.
+ * The difference checks the same fields as \ref video_format_IsSimilar
+ */
+VLC_API void video_format_LogDifferences(struct vlc_logger *log,
+                                         const char *name_a, const video_format_t *a,
+                                         const char *name_b, const video_format_t *b);
+
 /**
  * Changes ES format to another category
  * Format must have been properly initialized


=====================================
src/input/decoder.c
=====================================
@@ -1692,6 +1692,9 @@ static void DecoderThread_ProcessInput( vlc_input_decoder_t *p_owner, vlc_frame_
             if( !es_format_IsSimilar( p_dec->fmt_in, &p_packetizer->fmt_out ) )
             {
                 msg_Dbg( p_dec, "restarting module due to input format change");
+                es_format_LogDifferences( vlc_object_logger(p_dec),
+                                          "decoder in", p_dec->fmt_in,
+                                          "packetizer out", &p_packetizer->fmt_out );
 
                 /* Drain the decoder module */
                 DecoderThread_DecodeBlock( p_owner, NULL );


=====================================
src/libvlccore.sym
=====================================
@@ -112,6 +112,7 @@ es_format_Copy
 es_format_Init
 es_format_InitFromVideo
 es_format_IsSimilar
+es_format_LogDifferences
 filter_AddProxyCallbacks
 filter_DelProxyCallbacks
 filter_Blend
@@ -512,6 +513,7 @@ video_format_TransformBy
 video_format_TransformTo
 video_format_GetTransform
 video_format_IsSimilar
+video_format_LogDifferences
 video_format_IsSameChroma
 video_format_Setup
 video_format_Print


=====================================
src/misc/es_format.c
=====================================
@@ -239,6 +239,35 @@ bool video_format_IsSimilar( const video_format_t *f1,
     return true;
 }
 
+void video_format_LogDifferences(struct vlc_logger *log,
+                                 const char *name_a, const video_format_t *a,
+                                 const char *name_b, const video_format_t *b)
+{
+    if (a->i_chroma != b->i_chroma)
+        vlc_debug(log, "'%s/%s' category %4.4s / %4.4s", name_a, name_b, (char*)&a->i_chroma, (char*)&b->i_chroma);
+    if( a->i_width != b->i_width )
+        vlc_debug(log, "'%s/%s' i_width %u / %u", name_a, name_b, a->i_width, b->i_width);
+    if( a->i_height != b->i_height )
+        vlc_debug(log, "'%s/%s' i_height %u / %u", name_a, name_b, a->i_height, b->i_height);
+    if( a->i_visible_width != b->i_visible_width )
+        vlc_debug(log, "'%s/%s' i_visible_width %u / %u", name_a, name_b, a->i_visible_width, b->i_visible_width);
+    if( a->i_visible_height != b->i_visible_height )
+        vlc_debug(log, "'%s/%s' i_visible_height %u / %u", name_a, name_b, a->i_visible_height, b->i_visible_height);
+    if( a->i_x_offset != b->i_x_offset )
+        vlc_debug(log, "'%s/%s' i_x_offset %u / %u", name_a, name_b, a->i_x_offset, b->i_x_offset);
+    if( a->i_y_offset != b->i_y_offset )
+        vlc_debug(log, "'%s/%s' i_y_offset %u / %u", name_a, name_b, a->i_y_offset, b->i_y_offset);
+    if( (int64_t)a->i_sar_num * b->i_sar_den !=
+        (int64_t)b->i_sar_num * a->i_sar_den )
+        vlc_debug(log, "'%s/%s' SAR %u/%u / %u/%u", name_a, name_b, a->i_sar_den, a->i_sar_num, b->i_sar_den, b->i_sar_num);
+
+    if( a->orientation != b->orientation)
+        vlc_debug(log, "'%s/%s' orientation %d / %d", name_a, name_b, a->orientation, b->orientation);
+
+    if( a->multiview_mode!= b->multiview_mode )
+        vlc_debug(log, "'%s/%s' orientation %d / %d", name_a, name_b, a->multiview_mode, b->multiview_mode);
+}
+
 static const char *orient_to_string[] =
 {
     [ORIENT_NORMAL]             = "normal",
@@ -437,3 +466,60 @@ bool es_format_IsSimilar( const es_format_t *p_fmt1, const es_format_t *p_fmt2 )
         return true;
     }
 }
+
+
+void es_format_LogDifferences(struct vlc_logger *log,
+                              const char *name_a, const es_format_t *a,
+                              const char *name_b, const es_format_t *b)
+{
+    if (a->i_cat != b->i_cat)
+        vlc_debug(log, "'%s/%s' category %d / %d", name_a, name_b, a->i_cat, b->i_cat);
+    if (a->i_codec != b->i_codec)
+    {
+        vlc_fourcc_t a_codec = vlc_fourcc_GetCodec(a->i_cat, a->i_codec);
+        vlc_fourcc_t b_codec = vlc_fourcc_GetCodec(a->i_cat, a->i_codec);
+        vlc_debug(log, "'%s/%s' codec %4.4s(%4.4s) / %4.4s(%4.4s)",
+                  name_a, name_b, (char*)&a_codec, (char*)&a->i_codec, (char*)&b_codec, (char*)&b->i_codec);
+    }
+    switch (a->i_cat)
+    {
+    case AUDIO_ES:
+    {
+        audio_format_t aa = a->audio;
+        audio_format_t ab = b->audio;
+
+        if( aa.i_format && ab.i_format && aa.i_format != ab.i_format )
+            vlc_debug(log, "'%s/%s' format %d / %d", name_a, name_b, aa.i_format, ab.i_format);
+        if( aa.channel_type != ab.channel_type)
+            vlc_debug(log, "'%s/%s' channel_type %d / %d",
+                      name_a, name_b, aa.channel_type, ab.channel_type);
+        if( aa.i_rate != ab.i_rate)
+            vlc_debug(log, "'%s/%s' i_rate %u / %u", name_a, name_b, aa.i_rate, ab.i_rate);
+        if( aa.i_channels != ab.i_channels)
+            vlc_debug(log, "'%s/%s' i_channels %" PRIu8 " / %" PRIu8 ,
+                      name_a, name_b, aa.i_channels, ab.i_channels);
+        if( aa.i_physical_channels != ab.i_physical_channels)
+            vlc_debug(log, "'%s/%s' i_physical_channels %" PRIu16 " / %" PRIu16 ,
+                      name_a, name_b, aa.i_physical_channels, ab.i_physical_channels);
+        if( aa.i_chan_mode != ab.i_chan_mode)
+            vlc_debug(log, "'%s/%s' i_chan_mode %" PRIu16 " / %" PRIu16 ,
+                      name_a, name_b, aa.i_chan_mode, ab.i_chan_mode);
+        if (a->i_profile != b->i_profile)
+            vlc_debug(log, "'%s/%s' profile %d / %d", name_a, name_b, a->i_profile, b->i_profile);
+        break;
+    }
+    case VIDEO_ES:
+        if (a->i_profile != b->i_profile)
+            vlc_debug(log, "'%s/%s' profile %d / %d", name_a, name_b, a->i_profile, b->i_profile);
+        video_format_t va = a->video;
+        video_format_t vb = b->video;
+        if( !va.i_chroma )
+            va.i_chroma = vlc_fourcc_GetCodec(a->i_cat, a->i_codec);
+        if( !vb.i_chroma )
+            vb.i_chroma = vlc_fourcc_GetCodec(b->i_cat, b->i_codec);
+        video_format_LogDifferences(log, name_a, &va, name_b, &vb);
+        break;
+    default:
+        break;
+    }
+}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c828db69e7230c076ea215ee2f19fda7700250c5...bf87e8465546bec8c3678aca139df1da039f348c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c828db69e7230c076ea215ee2f19fda7700250c5...bf87e8465546bec8c3678aca139df1da039f348c
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list