vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Tue Sep 20 
18:41:18 2016 +0200| [f856d4b066276a9ab3a94a1574c2690bd0e32415] | committer: 
Francois Cartegnie

vt: simplify h264/annexb start

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

 modules/codec/videotoolbox.m | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index a3eeb77..51ac7a5 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -382,19 +382,24 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t 
*p_block)
         uint8_t *p_alloc_buf = NULL;
         int i_ret = 0;
 
-        if (p_block == NULL) {
-            /* we need to convert the SPS and PPS units we received from the
-             * demuxer's avvC atom so we can process them further */
-            if(h264_isavcC(p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra))
+        /* we need to convert the SPS and PPS units we received from the
+         * demuxer's avvC atom so we can process them further */
+        p_sys->b_is_avcc = h264_isavcC(p_dec->fmt_in.p_extra, 
p_dec->fmt_in.i_extra);
+        if(p_sys->b_is_avcc)
+        {
+            p_alloc_buf = h264_avcC_to_AnnexB_NAL(p_dec->fmt_in.p_extra,
+                                                  p_dec->fmt_in.i_extra,
+                                                  &i_buf,
+                                                  &p_sys->i_nal_length_size);
+            p_buf = p_alloc_buf;
+            if(!p_alloc_buf)
             {
-                p_alloc_buf = h264_avcC_to_AnnexB_NAL(p_dec->fmt_in.p_extra,
-                                                      p_dec->fmt_in.i_extra,
-                                                      &i_buf,
-                                                      
&p_sys->i_nal_length_size);
-                p_buf = p_alloc_buf;
-                p_sys->b_is_avcc = !!p_buf;
+                msg_Warn(p_dec, "invalid avc decoder configuration record");
+                return VLC_EGENERIC;
             }
-        } else {
+        }
+        else if(p_block)
+        {
             /* we are mid-stream, let's have the h264_get helper see if it
              * can find a NAL unit */
             i_buf = p_block->i_buffer;
@@ -402,16 +407,16 @@ static int StartVideoToolbox(decoder_t *p_dec, block_t 
*p_block)
             p_sys->i_nal_length_size = 4; /* default to 4 bytes */
             i_ret = VLC_SUCCESS;
         }
-
-        uint8_t *p_sps_ab = NULL, *p_pps_ab = NULL, *p_ext_ab = NULL;
-        size_t i_sps_absize = 0, i_pps_absize = 0, i_ext_absize = 0;
-        if (!p_buf) {
-            msg_Warn(p_dec, "no valid extradata or conversion failed");
+        else
+        {
+            assert_unreachable();
             return VLC_EGENERIC;
         }
 
         /* get the SPS and PPS units from the NAL unit which is either
          * part of the demuxer's avvC atom or the mid stream data block */
+        uint8_t *p_sps_ab = NULL, *p_pps_ab = NULL, *p_ext_ab = NULL;
+        size_t i_sps_absize = 0, i_pps_absize = 0, i_ext_absize = 0;
         i_ret = h264_get_spspps(p_buf, i_buf,
                                 &p_sps_ab, &i_sps_absize,
                                 &p_pps_ab, &i_pps_absize,

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to