linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] patch for h263Oldenc


From: joakim
Subject: [Linphone-developers] patch for h263Oldenc
Date: Wed, 30 Dec 2009 03:34:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

We have experienced issues with mediastreamers h263oldEnc and an ffmpeg
based h263 decoder for Java Media Framework, JMF.

The problem seems to be that the JMF decoder is more stringent than
other ffmpeg decoders and is sensitive to what we believe is an encoding
error in videostreamer. When we wireshark h263 sessions we notice that the
difference between working and non-working streams is that packets in
the working stream begins at GOB or PSC boundaries, whereas packets in the non
working mediastreamer encoded stream often doesn't begin at these
boundaries. The visual result in the receiving end is something that
looks like severe packet loss.

The attached patch solve these issues for us. It is a replacement for
get_gbsc(). It works a little differently but has the same intent as
get_gbsc(), finding the GBSC and PSC boundaries in a ffmpeg encoded
stream. For simplicity is assumes the stream is byte aligned, which the
original doesnt. This assumptions seems safe to us but if there are
objections we can rework the patch. Furthermore it searches from the end
of the packet size backwards for markers. This isn't really an
optimization, we just found it easier to think this way.

To summarize, we believe this patch improves compatibility with old
stringent h263 decoders. We are also happy to rework the patch to the
standards needed for inclusion in the mediastreamer codebase.




Index: videoenc.c
===================================================================
--- videoenc.c  (revision 780)
+++ videoenc.c  (working copy)
@@ -371,12 +371,33 @@
        return k;
 }
 
+
+static int get_gbsc_bytealigned(uint8_t *begin, uint8_t *end)
+{
+  int i;
+  int len = end - begin;
+  for (i = len - 2;  //len + length of scan window
+       i > 2 + 2; //length of scan window + 2 avoidance of 1st gob or psc
+       i--){
+    if(*(begin + i) == 0 &&
+       *(begin + i+1) == 0 &&
+       (*(begin + i+2) & 0x80) == 0x80){
+      //ms_message("JV psc/gob found! %2x %2x %2x", *(begin + i), *(begin + 
i+1), *(begin + i + 2));
+      return i;
+    }
+  }
+  //ms_message("JV no psc or gob found!");
+  return len;
+  
+}
+
 static void rfc2190_generate_packets(MSFilter *f, EncState *s, mblk_t *frame, 
uint32_t timestamp){
        mblk_t *packet=NULL;
        
        while (frame->b_rptr<frame->b_wptr){
                packet=dupb(frame);
-               
frame->b_rptr=packet->b_wptr=packet->b_rptr+get_gbsc(packet->b_rptr, 
MIN(packet->b_rptr+s->mtu,frame->b_wptr));
+               frame->b_rptr = packet->b_wptr =
+                  packet->b_rptr + get_gbsc_bytealigned(packet->b_rptr, 
MIN(packet->b_rptr+s->mtu,frame->b_wptr));
                add_rfc2190_header(&packet, &s->av_context);
                mblk_set_timestamp_info(packet,timestamp);
                ms_queue_put(f->outputs[0],packet);
-- 
Joakim Verona




reply via email to

[Prev in Thread] Current Thread [Next in Thread]