[vlc-commits] [Git][videolan/vlc][master] 2 commits: decklink: don't return a whole es_format_t

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Oct 8 05:59:12 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
3164c897 by Steve Lhomme at 2023-10-08T05:41:50+00:00
decklink: don't return a whole es_format_t

And return an error when we can't use a format. We shouldn't pretend
everything is OK.

- - - - -
a642f638 by Steve Lhomme at 2023-10-08T05:41:50+00:00
decklink: split the code to log field dominance and map to block flags

- - - - -


1 changed file:

- modules/access/decklink.cpp


Changes:

=====================================
modules/access/decklink.cpp
=====================================
@@ -176,7 +176,7 @@ struct demux_sys_t
 
 } // namespace
 
-static const char *GetFieldDominance(BMDFieldDominance dom, uint32_t *flags)
+static const char *FieldDominanceStr(BMDFieldDominance dom)
 {
     switch(dom)
     {
@@ -185,10 +185,8 @@ static const char *GetFieldDominance(BMDFieldDominance dom, uint32_t *flags)
         case bmdProgressiveSegmentedFrame:
             return ", segmented";
         case bmdLowerFieldFirst:
-            *flags = BLOCK_FLAG_BOTTOM_FIELD_FIRST;
             return ", interlaced [BFF]";
         case bmdUpperFieldFirst:
-            *flags = BLOCK_FLAG_TOP_FIELD_FIRST;
             return ", interlaced [TFF]";
         case bmdUnknownFieldDominance:
         default:
@@ -196,12 +194,26 @@ static const char *GetFieldDominance(BMDFieldDominance dom, uint32_t *flags)
     }
 }
 
-static es_format_t GetModeSettings(demux_t *demux, IDeckLinkDisplayMode *m,
+static uint32_t FieldDominanceBlockFlag(BMDFieldDominance dom)
+{
+    switch(dom)
+    {
+        case bmdLowerFieldFirst:
+            return BLOCK_FLAG_BOTTOM_FIELD_FIRST;
+        case bmdUpperFieldFirst:
+            return BLOCK_FLAG_TOP_FIELD_FIRST;
+        case bmdProgressiveFrame:
+        case bmdProgressiveSegmentedFrame:
+        case bmdUnknownFieldDominance:
+        default:
+            return 0;
+    }
+}
+
+static int GetModeSettings(demux_t *demux, IDeckLinkDisplayMode *m,
         BMDDetectedVideoInputFormatFlags fmt_flags)
 {
     demux_sys_t *sys = (demux_sys_t *)demux->p_sys;
-    uint32_t flags = 0;
-    (void)GetFieldDominance(m->GetFieldDominance(), &flags);
 
     BMDTimeValue frame_duration, time_scale;
     if (m->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
@@ -209,7 +221,6 @@ static es_format_t GetModeSettings(demux_t *demux, IDeckLinkDisplayMode *m,
         frame_duration = 1;
     }
 
-    es_format_t video_fmt;
     vlc_fourcc_t chroma = 0;
     switch (fmt_flags) {
         case bmdDetectedVideoInputYCbCr422:
@@ -220,29 +231,28 @@ static es_format_t GetModeSettings(demux_t *demux, IDeckLinkDisplayMode *m,
             break;
         default:
             msg_Err(demux, "Unsupported input format");
-            break;
+            return VLC_ENOTSUP;
     }
-    es_format_Init(&video_fmt, VIDEO_ES, chroma);
+    es_format_Init(&sys->video_fmt, VIDEO_ES, chroma);
 
-    video_fmt.video.i_chroma = chroma;
-    video_fmt.video.i_width = m->GetWidth();
-    video_fmt.video.i_height = m->GetHeight();
-    video_fmt.video.i_sar_num = 1;
-    video_fmt.video.i_sar_den = 1;
-    video_fmt.video.i_frame_rate = time_scale;
-    video_fmt.video.i_frame_rate_base = frame_duration;
-    video_fmt.i_bitrate = video_fmt.video.i_width * video_fmt.video.i_height * video_fmt.video.i_frame_rate * 2 * 8;
+    sys->video_fmt.video.i_chroma = chroma;
+    sys->video_fmt.video.i_width = m->GetWidth();
+    sys->video_fmt.video.i_height = m->GetHeight();
+    sys->video_fmt.video.i_sar_num = 1;
+    sys->video_fmt.video.i_sar_den = 1;
+    sys->video_fmt.video.i_frame_rate = time_scale;
+    sys->video_fmt.video.i_frame_rate_base = frame_duration;
+    sys->video_fmt.i_bitrate = sys->video_fmt.video.i_width * sys->video_fmt.video.i_height * sys->video_fmt.video.i_frame_rate * 2 * 8;
 
     unsigned aspect_num, aspect_den;
     if (!var_InheritURational(demux, &aspect_num, &aspect_den, "decklink-aspect-ratio") &&
          aspect_num > 0 && aspect_den > 0) {
-        video_fmt.video.i_sar_num = aspect_num * video_fmt.video.i_height;
-        video_fmt.video.i_sar_den = aspect_den * video_fmt.video.i_width;
+        sys->video_fmt.video.i_sar_num = aspect_num * sys->video_fmt.video.i_height;
+        sys->video_fmt.video.i_sar_den = aspect_den * sys->video_fmt.video.i_width;
     }
 
-    sys->dominance_flags = flags;
-
-    return video_fmt;
+    sys->dominance_flags = FieldDominanceBlockFlag(m->GetFieldDominance());
+    return VLC_SUCCESS;
 }
 namespace {
 
@@ -309,7 +319,9 @@ public:
         }
 
         es_out_Del(demux_->out, sys->video_es);
-        sys->video_fmt = GetModeSettings(demux_, mode, flags);
+        sys->video_es = NULL;
+        if (GetModeSettings(demux_, mode, flags) != VLC_SUCCESS)
+            return E_NOTIMPL;
         sys->video_es = es_out_Add(demux_->out, &sys->video_fmt);
 
         sys->input->PauseStreams();
@@ -666,8 +678,6 @@ static int Open(vlc_object_t *p_this)
 
         const char *mode_name;
         BMDTimeValue frame_duration, time_scale;
-        uint32_t field_flags;
-        const char *field = GetFieldDominance(m->GetFieldDominance(), &field_flags);
         union {
             BMDDisplayMode id;
             char str[4];
@@ -688,10 +698,11 @@ static int Open(vlc_object_t *p_this)
         msg_Dbg(demux, "Found mode '%4.4s': %s (%dx%d, %.3f fps%s)",
                  mode.str, mode_name,
                  (int)m->GetWidth(), (int)m->GetHeight(),
-                 double(time_scale) / frame_duration, field);
+                 double(time_scale) / frame_duration,
+                 FieldDominanceStr(m->GetFieldDominance()));
 
         if (u_id == mode.id) {
-            sys->video_fmt = GetModeSettings(demux, m, bmdDetectedVideoInputYCbCr422);
+            GetModeSettings(demux, m, bmdDetectedVideoInputYCbCr422);
             msg_Dbg(demux, "Using that mode");
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8d7695e6cf1cc44ead47e4ae03faa5c0f6db8b17...a642f638e87c0a3523f09bc52b176e70f7805b65

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8d7695e6cf1cc44ead47e4ae03faa5c0f6db8b17...a642f638e87c0a3523f09bc52b176e70f7805b65
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