[vlc-devel] [PATCH 2/4] mux/mpeg/pes: Add support for unbounded VIDEO_ES

davidf+nntp at woaf.net davidf+nntp at woaf.net
Thu Nov 13 17:19:57 CET 2008


From: David Flynn <davidf at rd.bbc.co.uk>

For some stream_id's in a transport stream, the PES packet may be
unbounded in length; add support for this.

Signed-off-by: David Flynn <davidf at rd.bbc.co.uk>
---
 modules/mux/mpeg/pes.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/modules/mux/mpeg/pes.c b/modules/mux/mpeg/pes.c
index 851cf6f..49d21b8 100644
--- a/modules/mux/mpeg/pes.c
+++ b/modules/mux/mpeg/pes.c
@@ -116,8 +116,19 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
                     if ( !i_header_size ) i_header_size = 0x0;
                 }
 
-                bits_write( &bits, 16, i_es_size + i_extra + 3
-                             + i_header_size ); // size
+                /* there are two ways to handle unbounded PES packets:
+                 *   Unbounded streams are only allowed in certain environments
+                 *   eg, MPEG* Video ES or a dirac stream.
+                 *   - Test for FOURCC
+                 *   - Test for es_size > SIZE_MAX, and hope the caller won't
+                 *     try something stupid.
+                 *     NB, the upstream caller already has to sort this out.
+                 */
+                if( p_fmt->i_cat == VIDEO_ES && i_es_size > PES_PAYLOAD_SIZE_MAX )
+                    bits_write( &bits, 16, 0 ); // size unbounded
+                else
+                    bits_write( &bits, 16, i_es_size + i_extra + 3
+                                 + i_header_size ); // size
                 bits_write( &bits, 2, 0x02 ); // mpeg2 id
                 bits_write( &bits, 2, 0x00 ); // pes scrambling control
                 bits_write( &bits, 1, 0x00 ); // pes priority
-- 
1.5.6.5




More information about the vlc-devel mailing list