[vlc-commits] demux: mp4: add sps/pps rbsp to AnnexB/avcC

Francois Cartegnie git at videolan.org
Thu Dec 3 17:34:57 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec  3 16:26:40 2015 +0100| [69cf32627e53b1623977f7010e240d95fdb6ca11] | committer: Francois Cartegnie

demux: mp4: add sps/pps rbsp to AnnexB/avcC

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

 modules/demux/mp4/avci.h |   55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/modules/demux/mp4/avci.h b/modules/demux/mp4/avci.h
index 5b17306..1f2ed98 100644
--- a/modules/demux/mp4/avci.h
+++ b/modules/demux/mp4/avci.h
@@ -148,4 +148,59 @@ static inline bool AVCi_lookup(uint16_t i_res, bool b_i,
 #undef AVCI_ENTRY
 #undef AVCI_ENTRIES
 
+#if 0
+static uint8_t * AVCi_create_avcC( uint16_t i_res, bool b_interlaced, int *pi_avcC )
+{
+    const uint8_t *p_pps, *p_sps;
+    uint8_t i_sps, i_pps;
+    uint8_t *p_data = NULL;
+    if( AVCi_lookup( i_res, b_interlaced,
+                     &p_sps, &i_sps, &p_pps, &i_pps ) )
+    {
+        int i_size = 5 + i_pps + i_sps + 2 + 2 * 3;
+        if( (p_data = (uint8_t *) malloc(i_size)) )
+        {
+            *pi_avcC = i_size;
+            /* Merge everything into avc decoder config record s4,1s,1p */
+            p_data[0] = 0x01;
+            memcpy(&p_data[1], p_sps, 3);
+            p_data[4] = 0xff;
+            p_data[5] = 0xe1; /* 1 sps */
+            p_data[6] = 0x00; p_data[7] = i_sps + 1; /* sps NAL size */
+            p_data[8] = 0x67; /* SPS_NAL Header */
+            memcpy(&p_data[9], p_sps, i_sps);
+            p_data[9 + i_sps] = 0x01; /* 1 sps */
+            p_data[10 + i_sps] = 0x00; p_data[11 + i_sps] = i_pps + 1; /* pps NAL size */
+            p_data[12 + i_sps] = 0x68; /* PPS_NAL Header */
+            memcpy(&p_data[13 + i_sps], p_pps, i_pps);
+        }
+    }
+    return p_data;
+}
+#endif
+
+static uint8_t * AVCi_create_AnnexB( uint16_t i_res, bool b_interlaced, int *pi_avcC )
+{
+    const uint8_t *p_pps, *p_sps;
+    uint8_t i_sps, i_pps;
+    uint8_t *p_data = NULL;
+    const uint8_t rgi_startcode[] = {0,0,0,1};
+    if( AVCi_lookup( i_res, b_interlaced,
+                     &p_sps, &i_sps, &p_pps, &i_pps ) )
+    {
+        int i_size = i_pps + i_sps + 2 * 5;
+        if( (p_data = (uint8_t *) malloc(i_size)) )
+        {
+            *pi_avcC = i_size;
+            memcpy(p_data, rgi_startcode, 4);
+            p_data[4] = 0x67; /* SPS_NAL Header */
+            memcpy(&p_data[5], p_sps, i_sps);
+            memcpy(&p_data[5 + i_sps], rgi_startcode, 4);
+            p_data[9 + i_sps] = 0x68; /* PPS_NAL Header */
+            memcpy(&p_data[10 + i_sps], p_pps, i_pps);
+        }
+    }
+    return p_data;
+}
+
 #endif



More information about the vlc-commits mailing list