From 99bc1da79b3c4d7ee82afeef53b9dbb54a9c0584 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 15 Oct 2010 11:30:21 -0700 Subject: [PATCH] If the PES packet size exceeds 16-bit range, use a packet size of 0 instead. This is valid for video content according to the specs. Change-Id: I686320d9d4cd826f43c0813c6ba1dc4949d1115f --- media/libstagefright/MPEG2TSWriter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/media/libstagefright/MPEG2TSWriter.cpp b/media/libstagefright/MPEG2TSWriter.cpp index b3daf67f892de..81a2b0d6c339e 100644 --- a/media/libstagefright/MPEG2TSWriter.cpp +++ b/media/libstagefright/MPEG2TSWriter.cpp @@ -725,6 +725,14 @@ void MPEG2TSWriter::writeAccessUnit( size_t PES_packet_length = accessUnit->size() + 8; + if (PES_packet_length >= 65536) { + // This really should only happen for video. + CHECK_EQ(stream_id, 0xe0u); + + // It's valid to set this to 0 for video according to the specs. + PES_packet_length = 0; + } + uint8_t *ptr = buffer->data(); *ptr++ = 0x47; *ptr++ = 0x40 | (PID >> 8);