[vlc-commits] packetizer: h264: fill missing extradata on sets activation

Francois Cartegnie git at videolan.org
Tue Jan 16 21:55:30 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan 16 18:13:07 2018 +0100| [c64dd089dbf122e26bdd5c2f05d399a35ad71dc7] | committer: Francois Cartegnie

packetizer: h264: fill missing extradata on sets activation

avoids arbitratry configuration from annexb -> avc

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

 modules/packetizer/h264.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index df13711550..e92247fbd5 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -231,6 +231,35 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
                                       &p_dec->fmt_out.video.space,
                                       &p_dec->fmt_out.video.b_color_range_full );
         }
+
+        if( p_dec->fmt_out.i_extra == 0 && p_pps )
+        {
+            const block_t *p_spsblock = NULL;
+            const block_t *p_ppsblock = NULL;
+            for( size_t i=0; i<=H264_SPS_ID_MAX && !p_spsblock; i++ )
+                if( p_sps == p_sys->sps[i].p_sps )
+                    p_spsblock = p_sys->sps[i].p_block;
+
+            for( size_t i=0; i<=H264_PPS_ID_MAX && !p_ppsblock; i++ )
+                if( p_pps == p_sys->pps[i].p_pps )
+                    p_ppsblock = p_sys->pps[i].p_block;
+
+            if( p_spsblock && p_ppsblock )
+            {
+                size_t i_alloc = p_ppsblock->i_buffer + p_spsblock->i_buffer + 8;
+                p_dec->fmt_out.p_extra = malloc( i_alloc );
+                if( p_dec->fmt_out.p_extra )
+                {
+                    uint8_t*p_buf = p_dec->fmt_out.p_extra;
+                    p_dec->fmt_out.i_extra = i_alloc;
+                    memcpy( &p_buf[0], annexb_startcode4, 4 );
+                    memcpy( &p_buf[4], p_spsblock->p_buffer, p_spsblock->i_buffer );
+                    memcpy( &p_buf[4 + p_spsblock->i_buffer], annexb_startcode4, 4 );
+                    memcpy( &p_buf[8 + p_spsblock->i_buffer], p_ppsblock->p_buffer,
+                            p_ppsblock->i_buffer );
+                }
+            }
+        }
     }
 }
 



More information about the vlc-commits mailing list