[vlc-devel] [PATCH 2/9] video_format: set the number of fields per picture in the video format

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 16 13:44:13 CET 2020


Force 2 fields on codecs explicitly outputting deinterlaced pictures.
---
 modules/codec/mft.c              |  2 ++
 modules/codec/omxil/mediacodec.c |  2 ++
 modules/hw/mmal/codec.c          | 14 +++++++++++++-
 modules/hw/mmal/deinterlace.c    |  2 ++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index 46e03bdcab0..22148ea60f4 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -725,6 +725,8 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id)
 
         if (p_dec->fmt_in.i_cat == VIDEO_ES)
         {
+            p_dec->fmt_out.video.i_num_fields = 2;
+
             if (decoder_UpdateVideoFormat(p_dec))
                 return VLC_SUCCESS;
             picture = decoder_NewPicture(p_dec);
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index b5680e57de5..b57107dfec6 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1198,6 +1198,8 @@ static int Video_ProcessOutput(decoder_t *p_dec, mc_api_out *p_out,
                 p_sys->video.i_mpeg_dar_den * p_dec->fmt_out.video.i_width;
         }
 
+        p_dec->fmt_out.video.i_num_fields = 2;
+
         /* If MediaCodec can handle the rotation, reset the orientation to
          * Normal in order to ask the vout not to rotate. */
         if (p_sys->video.i_angle != 0)
diff --git a/modules/hw/mmal/codec.c b/modules/hw/mmal/codec.c
index e3bdeffc16b..cdd291f87d8 100644
--- a/modules/hw/mmal/codec.c
+++ b/modules/hw/mmal/codec.c
@@ -363,7 +363,19 @@ apply_fmt:
         msg_Warn(dec, "Failed to query interlace type from decoder output port (status=%"PRIx32" %s)",
                 status, mmal_status_to_string(status));
     } else {
-        sys->b_progressive = (interlace_type.eMode == MMAL_InterlaceProgressive);
+        switch (interlace_type.eMode)
+        {
+            case MMAL_InterlaceProgressive:
+                dec->fmt_out.video.i_num_fields = 2;
+                break;
+            case MMAL_InterlaceFieldSingleUpperFirst:
+            case MMAL_InterlaceFieldSingleLowerFirst:
+                dec->fmt_out.video.i_num_fields = 1;
+                break;
+            default:
+                dec->fmt_out.video.i_num_fields = 2;
+                break;
+        }
     }
 
     // Tell the rest of the world we have changed format
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index 70814303bb6..2d43ed35437 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -536,6 +536,8 @@ static int OpenMmalDeinterlace(filter_t *filter)
         }
     }
 
+    filter->fmt_out.video.i_num_fields = 2;
+
     sys->component->control->userdata = (struct MMAL_PORT_USERDATA_T *)filter;
     status = mmal_port_enable(sys->component->control, control_port_cb);
     if (status != MMAL_SUCCESS) {
-- 
2.26.2



More information about the vlc-devel mailing list