[Sumover-dev] [svn commit] r4160 - in vic/branches/mpeg4: codec rtp

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Sat May 24 22:11:28 BST 2008


Author: piers
Date: Sat May 24 22:11:28 2008
New Revision: 4160

Modified:
   vic/branches/mpeg4/codec/decoder-h264.cpp
   vic/branches/mpeg4/codec/rtp_h264_depayloader.cpp
   vic/branches/mpeg4/codec/rtp_h264_depayloader.h
   vic/branches/mpeg4/rtp/rtp.h
   vic/branches/mpeg4/tcl/cf-main.tcl

Log:
Added decoding of IOCOM's IG2 H.264 non-standard H.264 streams - payload type 107 - identified as H264_IOCOM. 
Note: VIC will decode IOCOM's 'standard H.264' [RFC3984] (the checkbox in the video properties of IG2 needs to be checked) with latest ffmpeg library (when patched to allow for use of one reference frame - when num_ref_frames=0 in SPS). IOCOM will decode VIC's H.264 streams.


Modified: vic/branches/mpeg4/codec/decoder-h264.cpp
==============================================================================
--- vic/branches/mpeg4/codec/decoder-h264.cpp	(original)
+++ vic/branches/mpeg4/codec/decoder-h264.cpp	Sat May 24 22:11:28 2008
@@ -71,7 +71,8 @@
     }
     TclObject *match(const char *id)
     {
-	if (strcasecmp(id, "h264") == 0)
+	if ((strcasecmp(id, "h264") == 0 ) || 
+	    (strcasecmp(id, "h264_IOCOM") == 0))
 	    return (new H264Decoder());
 	return (0);
     }
@@ -227,7 +228,7 @@
     //stream->write(pktIdx, cc, (char *) bp);
     //fprintf(stderr, "H264_RTP: -------------------------------- seq = %d, m=%d, ts=%d, cc=%d\n", seq, mbit, ts, cc);
     //fprintf(stderr, "H264_RTP: pktIdx = %d\n", pktIdx);
-    int yo = h264depayloader->h264_handle_packet(h264depayloader->h264_extradata, pktIdx, stream, /*ts,*/ bp, cc);
+    int yo = h264depayloader->h264_handle_packet(h264depayloader->h264_extradata, pktIdx, stream, /*ts,*/ bp, cc, mbit);
     //fprintf(stderr, "H264_RTP: h264_handle_packet = %d\n", yo);
 
 

Modified: vic/branches/mpeg4/codec/rtp_h264_depayloader.cpp
==============================================================================
--- vic/branches/mpeg4/codec/rtp_h264_depayloader.cpp	(original)
+++ vic/branches/mpeg4/codec/rtp_h264_depayloader.cpp	Sat May 24 22:11:28 2008
@@ -54,6 +54,7 @@
 
 #include "rtp_h264_depayloader.h"
 #include "packetbuffer.h"
+#include "rtp.h"
 
 //using namespace std;
 
@@ -187,6 +188,7 @@
 {
     h264_extradata = (h264_rtp_extra_data *) h264_new_extradata();
     //fprintf(stderr, "H264_RTP: H264Depayloader Constructor done.\n");
+    aggregate_pkt = 0;
 }
 
 H264Depayloader::~H264Depayloader()
@@ -291,7 +293,7 @@
                               /*AVPacket * pkt,*/ int pktIdx, PacketBuffer *pb,
                               /*uint32_t * timestamp,*/ 
                               const uint8_t * buf,
-                              int len)
+                              int len, int mbit)
 {
     //h264_rtp_extra_data *data = s->dynamic_protocol_context;
     uint8_t nal = buf[0];
@@ -304,7 +306,12 @@
     assert(data->cookie == MAGIC_COOKIE);
     assert(buf);
 
-    if (type >= 1 && type <= 23)
+    //fprintf(stderr, /*NULL, AV_LOG_ERROR,*/ "H264_RTP: Single NAL type (%d, equiv. to >=1 or <=23), len=%4d\n", type, len);
+
+    if (buf[0]==0x02 && buf[1]==0x5d && buf[2]==0x47){
+      type=99; // IOCOM's non-standard H.264 packet format
+      //fprintf(stderr,"found IOCOM pkt\n");
+    } else if (type >= 1 && type <= 23)
         type = 1;              // simplify the case. (these are all the nal types used internally by the h264 codec)
     switch (type) {
     case 0:                    // undefined;
@@ -313,7 +320,6 @@
         break;
 
     case 1:
-	//fprintf(stderr, /*NULL, AV_LOG_ERROR,*/ "H264_RTP: Single NAL type (%d, equiv. to >=1 or <=23), len=%4d\n", type, len);
 
         //av_new_packet(pkt, len+sizeof(start_sequence));
         //memcpy(pkt->data, start_sequence, sizeof(start_sequence));
@@ -329,9 +335,8 @@
 	pb->write(pktIdx, sslen+len, temp); //SV: XXX
 */	
 
-	pb->writeAppend(pktIdx, sslen, start_sequence); //PO: XXX
-	pb->writeAppend(pktIdx, len, (char *)buf); //PO: XXX
-	
+	  pb->writeAppend(pktIdx, sslen, start_sequence); //PO: XXX
+	  pb->writeAppend(pktIdx, len, (char *)buf); //PO: XXX
 
 #ifdef DEBUG
         data->packet_types_received[nal & 0x1f]++;
@@ -427,7 +432,7 @@
             uint8_t fu_indicator = nal;
             uint8_t fu_header = *buf;   // read the fu_header.
             uint8_t start_bit = (fu_header & 0x80) >> 7;
-            uint8_t end_bit = (fu_header & 0x40) >> 6;
+            // non used uint8_t end_bit = (fu_header & 0x40) >> 6;
             uint8_t nal_type = (fu_header & 0x1f);
             uint8_t reconstructed_nal;
 
@@ -480,6 +485,25 @@
         }
         break;
 
+    case 99:                   // IOCOM's non-standard H.264
+
+	//fprintf(stderr,"IOCOM pkt\n");
+	if (mbit) {
+          if (aggregate_pkt)
+            pb->writeAppend(pktIdx, len-20, (char *)buf+20);
+          else
+            pb->writeAppend(pktIdx, len-21, (char *)buf+21);
+          aggregate_pkt = 0;
+	}  else {
+	  if (aggregate_pkt)
+	    //stream->writeAppend(pktIdx,cc-bit_pos+1, (char *)bp+bit_pos-1);
+	    pb->writeAppend(pktIdx, len-20, (char *)buf+20);
+	  else
+	    pb->writeAppend(pktIdx, len-21, (char *)buf+21);
+	  aggregate_pkt = 1;
+	}
+        break;
+
     case 30:                   // undefined
     case 31:                   // undefined
     default:

Modified: vic/branches/mpeg4/codec/rtp_h264_depayloader.h
==============================================================================
--- vic/branches/mpeg4/codec/rtp_h264_depayloader.h	(original)
+++ vic/branches/mpeg4/codec/rtp_h264_depayloader.h	Sat May 24 22:11:28 2008
@@ -80,12 +80,14 @@
     h264_rtp_extra_data *h264_extradata;
 
     int parse_h264_sdp_line(AVCodecContext *codec, /*AVStream * stream,*/ void *data, const char *line);
-    int h264_handle_packet(h264_rtp_extra_data *data, /*AVPacket * pkt*/ int pktIdx, PacketBuffer *pb, /*uint32_t * timestamp,*/ const uint8_t * buf, int len);
+    int h264_handle_packet(h264_rtp_extra_data *data, /*AVPacket * pkt*/ int pktIdx, PacketBuffer *pb, /*uint32_t * timestamp,*/ const uint8_t * buf, int len, int mbit);
 
 /**
     RTP/H264 specific private data.
 */
   private:
+    int aggregate_pkt; // Count of mbits for decoding IOCOM H.264 
+
     void h264_free_extradata(void *d);
     void *h264_new_extradata();
     void sdp_parse_fmtp_config_h264(AVCodecContext *codec, /*AVStream * stream,*/

Modified: vic/branches/mpeg4/rtp/rtp.h
==============================================================================
--- vic/branches/mpeg4/rtp/rtp.h	(original)
+++ vic/branches/mpeg4/rtp/rtp.h	Sat May 24 22:11:28 2008
@@ -61,7 +61,8 @@
 #define RTP_PT_H263		34 	/* ITU H.263 */
 #define RTP_PT_DV               123     /* DV */
 #define RTP_PT_MPEG4		45
-#define RTP_PT_H264		96
+#define RTP_PT_H264		96	/* RFC3984 compliant H.264 */
+#define RTP_PT_H264_IOCOM	107	/* IOCOM.com's IG2 proprietary H.264*/
 
 /* backward compat hack for decoding RTPv1 ivs streams */
 #define RTP_PT_H261_COMPAT 127

Modified: vic/branches/mpeg4/tcl/cf-main.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/cf-main.tcl	(original)
+++ vic/branches/mpeg4/tcl/cf-main.tcl	Sat May 24 22:11:28 2008
@@ -49,7 +49,10 @@
 set rtp_type(77) h261as
 set rtp_type(123) dv
 set rtp_type(45) mpeg4
-set rtp_type(96) h264
+# RFC3984 compliant H.264
+set rtp_type(96) h264  
+# IOCOM's IG2 H.264 format
+set rtp_type(107) h264_IOCOM
 
 
 proc vic_main {} {



More information about the Sumover-dev mailing list