[vlc-commits] packetizer: mpegvideo: move colorspace checking to correct place

Ilkka Ollakka git at videolan.org
Fri Sep 30 11:50:37 CEST 2016


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Sep 30 12:48:47 2016 +0300| [d9ea89a9227f1e40cb4444e60a3898737ff10bfb] | committer: Ilkka Ollakka

packetizer: mpegvideo: move colorspace checking to correct place

This way we will parse sequence extensions and picture extensions also if they
happen to be in same fragment.

fixes #17212

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

 modules/packetizer/mpegvideo.c | 120 ++++++++++++++++++++---------------------
 1 file changed, 60 insertions(+), 60 deletions(-)

diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c
index 67fb67c..22f6e86 100644
--- a/modules/packetizer/mpegvideo.c
+++ b/modules/packetizer/mpegvideo.c
@@ -538,66 +538,6 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
             p_sys->i_seq_old = 0;
         }
     }
-    else if( p_frag->p_buffer[3] == 0xb5 && p_frag->i_buffer >= 10 )
-    {
-        /* Sequence display extension */
-        bool contains_color_description = (p_frag->p_buffer[4] & 0x01);
-        //uint8_t video_format = (p_frag->p_buffer[4] & 0x0f) >> 1;
-
-        if( contains_color_description )
-        {
-            uint8_t color_primaries = p_frag->p_buffer[5];
-            uint8_t color_transfer  = p_frag->p_buffer[6];
-            uint8_t color_matrix    = p_frag->p_buffer[7];
-            switch( color_primaries )
-            {
-                case 1:
-                    p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT709;
-                    break;
-                case 4: /* BT.470M    */
-                case 5: /* BT.470BG   */
-                    p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_625;
-                    break;
-                case 6: /* SMPTE 170M */
-                case 7: /* SMPTE 240M */
-                    p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_525;
-                    break;
-                default:
-                    break;
-            }
-            switch( color_transfer )
-            {
-                case 1:
-                    p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT709;
-                    break;
-                case 4: /* BT.470M assumed gamma 2.2  */
-                    p_dec->fmt_out.video.transfer = TRANSFER_FUNC_SRGB;
-                    break;
-                case 5: /* BT.470BG */
-                case 6: /* SMPTE 170M */
-                    p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT2020;
-                    break;
-                case 8: /* Linear */
-                    p_dec->fmt_out.video.transfer = TRANSFER_FUNC_LINEAR;
-                    break;
-                default:
-                    break;
-            }
-            switch( color_matrix )
-            {
-                case 1:
-                    p_dec->fmt_out.video.space = COLOR_SPACE_BT709;
-                    break;
-                case 5: /* BT.470BG */
-                case 6: /* SMPTE 170 M */
-                    p_dec->fmt_out.video.space = COLOR_SPACE_BT601;
-                    break;
-                default:
-                    break;
-            }
-        }
-
-    }
     else if( p_frag->p_buffer[3] == 0xb3 && p_frag->i_buffer >= 8 )
     {
         /* Sequence header code */
@@ -699,6 +639,66 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
             p_sys->i_repeat_first_field= (p_frag->p_buffer[7]>>1)&0x01;
             p_sys->i_progressive_frame = p_frag->p_buffer[8] >> 7;
         }
+        if( p_frag->i_buffer >= 10 )
+        {
+            /* Sequence display extension */
+            bool contains_color_description = (p_frag->p_buffer[4] & 0x01);
+            //uint8_t video_format = (p_frag->p_buffer[4] & 0x0f) >> 1;
+
+            if( contains_color_description )
+            {
+                uint8_t color_primaries = p_frag->p_buffer[5];
+                uint8_t color_transfer  = p_frag->p_buffer[6];
+                uint8_t color_matrix    = p_frag->p_buffer[7];
+                switch( color_primaries )
+                {
+                    case 1:
+                        p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT709;
+                        break;
+                    case 4: /* BT.470M    */
+                    case 5: /* BT.470BG   */
+                        p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_625;
+                        break;
+                    case 6: /* SMPTE 170M */
+                    case 7: /* SMPTE 240M */
+                        p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_525;
+                        break;
+                    default:
+                        break;
+                }
+                switch( color_transfer )
+                {
+                    case 1:
+                        p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT709;
+                        break;
+                    case 4: /* BT.470M assumed gamma 2.2  */
+                        p_dec->fmt_out.video.transfer = TRANSFER_FUNC_SRGB;
+                        break;
+                    case 5: /* BT.470BG */
+                    case 6: /* SMPTE 170M */
+                        p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT2020;
+                        break;
+                    case 8: /* Linear */
+                        p_dec->fmt_out.video.transfer = TRANSFER_FUNC_LINEAR;
+                        break;
+                    default:
+                        break;
+                }
+                switch( color_matrix )
+                {
+                    case 1:
+                        p_dec->fmt_out.video.space = COLOR_SPACE_BT709;
+                        break;
+                    case 5: /* BT.470BG */
+                    case 6: /* SMPTE 170 M */
+                        p_dec->fmt_out.video.space = COLOR_SPACE_BT601;
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+        }
     }
     else if( p_frag->p_buffer[3] == 0xb2 && p_frag->i_buffer > 4 )
     {



More information about the vlc-commits mailing list