changeset 22278:ac8ac9e3761d

insert extradata in sh_video->bih+1 instead of pushing it to demuxer->video as separate packet; patch by C.E.Hoyos
author nicodvb
date Tue, 20 Feb 2007 20:21:15 +0000
parents de3ca43ae51e
children 856feaa9cb61
files libmpdemux/demux_rtp_codec.cpp
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rtp_codec.cpp	Tue Feb 20 20:09:29 2007 +0000
+++ b/libmpdemux/demux_rtp_codec.cpp	Tue Feb 20 20:21:15 2007 +0000
@@ -17,6 +17,21 @@
 parseQTState_audio(QuickTimeGenericRTPSource::QTState const& qtState,
 		   unsigned& fourcc, unsigned& numChannels); // forward
 		       
+static BITMAPINFOHEADER * insertVideoExtradata(BITMAPINFOHEADER *bih,
+                                               unsigned char * extraData,
+                                               unsigned size)
+{
+    BITMAPINFOHEADER * original = bih;
+    if (!size || size > INT_MAX - sizeof(BITMAPINFOHEADER))
+        return bih;
+    bih = (BITMAPINFOHEADER*)realloc(bih, sizeof(BITMAPINFOHEADER) + size);
+    if (!bih)
+        return original;
+    bih->biSize = sizeof(BITMAPINFOHEADER) + size;
+    memcpy(bih+1, extraData, size);
+    return bih;
+}
+
 void rtpCodecInitialize_video(demuxer_t* demuxer,
 			      MediaSubsession* subsession,
 			      unsigned& flags) {
@@ -67,7 +82,7 @@
     unsigned configLen;
     unsigned char* configData
       = parseGeneralConfigStr(subsession->fmtp_config(), configLen);
-    insertRTPData(demuxer, demuxer->video, configData, configLen);
+    sh_video->bih = bih = insertVideoExtradata(bih, configData, configLen);
     needVideoFrameRate(demuxer, subsession);
   } else if (strcmp(subsession->codecName(), "X-QT") == 0 ||
 	     strcmp(subsession->codecName(), "X-QUICKTIME") == 0) {
@@ -103,11 +118,9 @@
         if ((!memcmp(pos+4, "avcC", 4) || 
              !memcmp(pos+4, "esds", 4) || 
              !memcmp(pos+4, "SMI ", 4)) &&
-            atomLength > 8 &&
-            atomLength <= INT_MAX-sizeof(BITMAPINFOHEADER)) {
-          bih->biSize = sizeof(BITMAPINFOHEADER)+atomLength-8;
-          sh_video->bih = bih = (BITMAPINFOHEADER*)realloc(bih, bih->biSize);
-          memcpy(bih+1, pos+8, atomLength-8);
+            atomLength > 8) {
+          sh_video->bih = bih = 
+              insertVideoExtradata(bih, pos+8, atomLength-8);
           break;
         }
         pos += atomLength;