[vlc-devel] [PATCH 3/4] vlc_block: add BLOCK_FLAG_SINGLE_FIELD

Francois Cartegnie fcvlcdev at free.fr
Wed Apr 12 17:07:44 CEST 2017


---
 include/vlc_block.h            |  8 +++++---
 modules/access/v4l2/demux.c    |  2 ++
 modules/codec/rawvideo.c       |  2 +-
 modules/codec/videotoolbox.m   |  3 +--
 modules/demux/mp4/libmp4.c     |  6 +++++-
 modules/packetizer/h264.c      |  1 +
 modules/packetizer/mpegvideo.c | 15 ++++++++++++---
 7 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/include/vlc_block.h b/include/vlc_block.h
index 5c2633d..d8d543f 100644
--- a/include/vlc_block.h
+++ b/include/vlc_block.h
@@ -85,14 +85,16 @@
 #define BLOCK_FLAG_PREROLL       0x0800
 /** This block is corrupted and/or there is data loss  */
 #define BLOCK_FLAG_CORRUPTED     0x1000
-/** This block contains an interlaced picture with top field first */
+/** This block contains an interlaced picture with top field stored first */
 #define BLOCK_FLAG_TOP_FIELD_FIRST 0x2000
-/** This block contains an interlaced picture with bottom field first */
+/** This block contains an interlaced picture with bottom field stored first */
 #define BLOCK_FLAG_BOTTOM_FIELD_FIRST 0x4000
+/** This block contains a single field from interlaced picture. */
+#define BLOCK_FLAG_SINGLE_FIELD  0x8000
 
 /** This block contains an interlaced picture */
 #define BLOCK_FLAG_INTERLACED_MASK \
-    (BLOCK_FLAG_TOP_FIELD_FIRST|BLOCK_FLAG_BOTTOM_FIELD_FIRST)
+    (BLOCK_FLAG_TOP_FIELD_FIRST|BLOCK_FLAG_BOTTOM_FIELD_FIRST|BLOCK_FLAG_SINGLE_FIELD)
 
 #define BLOCK_FLAG_TYPE_MASK \
     (BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B|BLOCK_FLAG_TYPE_PB)
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index e56714c..6c1093b 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -351,9 +351,11 @@ static int InitVideo (demux_t *demux, int fd, uint32_t caps)
             break;
         case V4L2_FIELD_TOP:
             msg_Dbg (demux, "Interlacing setting: top field only");
+            sys->block_flags = BLOCK_FLAG_TOP_FIELD_FIRST|BLOCK_FLAG_SINGLE_FIELD;
             break;
         case V4L2_FIELD_BOTTOM:
             msg_Dbg (demux, "Interlacing setting: bottom field only");
+            sys->block_flags = BLOCK_FLAG_BOTTOM_FIELD_FIRST|BLOCK_FLAG_SINGLE_FIELD;
             break;
         case V4L2_FIELD_INTERLACED:
             msg_Dbg (demux, "Interlacing setting: interleaved");
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index 7500d7a..93d9fcd 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -249,7 +249,7 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
     if( p_block->i_flags & BLOCK_FLAG_INTERLACED_MASK )
     {
         p_pic->b_progressive = false;
-        p_pic->i_nb_fields = 2;
+        p_pic->i_nb_fields = (p_block->i_flags & BLOCK_FLAG_SINGLE_FIELD) ? 1 : 2;
         if( p_block->i_flags & BLOCK_FLAG_TOP_FIELD_FIRST )
             p_pic->b_top_field_first = true;
         else
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 7e2d0ff..d43686e 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1306,8 +1306,7 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_block)
         int i_ret = avcCFromAnnexBCreate(p_dec);
         if (i_ret == VLC_SUCCESS)
         {
-            if ((p_block->i_flags & BLOCK_FLAG_TOP_FIELD_FIRST
-             || p_block->i_flags & BLOCK_FLAG_BOTTOM_FIELD_FIRST)
+            if ((p_block->i_flags & BLOCK_FLAG_INTERLACED_MASK)
              && var_InheritBool(p_dec, "videotoolbox-temporal-deinterlacing"))
                 p_sys->b_enable_temporal_processing = true;
 
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index fe09925..25daa2e 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -2219,7 +2219,11 @@ static int MP4_ReadBox_fiel( stream_t *p_stream, MP4_Box_t *p_box )
     p_fiel = p_box->data.p_fiel;
     if(i_read < 2)
         MP4_READBOX_EXIT( 0 );
-    if(p_peek[0] == 2) /* Interlaced */
+    if(p_peek[0] == 1)
+    {
+        p_fiel->i_flags = BLOCK_FLAG_SINGLE_FIELD;
+    }
+    else if(p_peek[0] == 2) /* Interlaced */
     {
         /*
          * 0 – There is only one field.
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 8225c61..bfe324c 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -788,6 +788,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
         /* Top and Bottom field slices */
         case 1:
         case 2:
+            p_pic->i_flags |= BLOCK_FLAG_SINGLE_FIELD;
             p_pic->i_flags |= (!p_sys->slice.i_bottom_field_flag) ? BLOCK_FLAG_TOP_FIELD_FIRST
                                                                   : BLOCK_FLAG_BOTTOM_FIELD_FIRST;
             break;
diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c
index 39c94a4..a393a9b 100644
--- a/modules/packetizer/mpegvideo.c
+++ b/modules/packetizer/mpegvideo.c
@@ -465,10 +465,19 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
             break;
         }
 
-        if( p_sys->i_picture_structure == 0x03 && !p_sys->b_seq_progressive )
+        if( !p_sys->b_seq_progressive )
         {
-            p_pic->i_flags |= (p_sys->i_top_field_first) ? BLOCK_FLAG_TOP_FIELD_FIRST
-                                                         : BLOCK_FLAG_BOTTOM_FIELD_FIRST;
+            if( p_sys->i_picture_structure < 0x03 )
+            {
+                p_pic->i_flags |= BLOCK_FLAG_SINGLE_FIELD;
+                p_pic->i_flags |= (p_sys->i_picture_structure == 0x01) ? BLOCK_FLAG_TOP_FIELD_FIRST
+                                                                       : BLOCK_FLAG_BOTTOM_FIELD_FIRST;
+            }
+            else /* if( p_sys->i_picture_structure == 0x03 ) */
+            {
+                p_pic->i_flags |= (p_sys->i_top_field_first) ? BLOCK_FLAG_TOP_FIELD_FIRST
+                                                             : BLOCK_FLAG_BOTTOM_FIELD_FIRST;
+            }
         }
 
         /* Special case for DVR-MS where we need to fully build pts from scratch
-- 
2.9.3



More information about the vlc-devel mailing list