[vlc-commits] vlc_block: add BLOCK_FLAG_SINGLE_FIELD

Francois Cartegnie git at videolan.org
Thu Apr 27 16:32:43 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 12 17:07:44 2017 +0200| [8431be31b9c22f454aadb0b0a19a623231c272b4] | committer: Francois Cartegnie

vlc_block: add BLOCK_FLAG_SINGLE_FIELD

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8431be31b9c22f454aadb0b0a19a623231c272b4
---

 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 5c2633d353..d8d543f24c 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 e56714cc7a..6c1093bffa 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 7500d7afb4..93d9fcd3c2 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 edc4c5b65f..965262ebd9 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1310,8 +1310,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 fe099254bd..25daa2ea8c 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 fa10e70118..8a91adbf72 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -803,6 +803,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 9a82310c4e..58acfb7ba1 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



More information about the vlc-commits mailing list