From 2be328f03fad60530a61cffd98e22d24d103e3b4 Mon Sep 17 00:00:00 2001
From: Boris Grozev <boris@jitsi.org>
Date: Fri, 25 Jan 2013 17:10:53 +0000
Subject: [PATCH] Fixes a problem with the VP8 Packetizer sometimes not sending
 the last chunk of a packet correctly. Changes the VP8 encoder and decoder
 used to the ones based on libvpx. Updates libjitsi.jar

---
 .../codec/FMJPlugInConfiguration.java         |  4 +--
 .../neomedia/codec/video/vp8/Packetizer.java  | 31 ++++++-------------
 2 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/org/jitsi/impl/neomedia/codec/FMJPlugInConfiguration.java b/src/org/jitsi/impl/neomedia/codec/FMJPlugInConfiguration.java
index 576f6d0a..a1b63eac 100644
--- a/src/org/jitsi/impl/neomedia/codec/FMJPlugInConfiguration.java
+++ b/src/org/jitsi/impl/neomedia/codec/FMJPlugInConfiguration.java
@@ -76,8 +76,8 @@ public class FMJPlugInConfiguration
                     "org.jitsi.impl.neomedia.codec.video.SwScaler",
                     "org.jitsi.impl.neomedia.codec.video.vp8.Packetizer",
                     "org.jitsi.impl.neomedia.codec.video.vp8.DePacketizer",
-                    "org.jitsi.impl.neomedia.codec.video.vp8.JNIEncoder",
-                    "org.jitsi.impl.neomedia.codec.video.vp8.JNIDecoder"
+                    "org.jitsi.impl.neomedia.codec.video.vp8.VPXEncoder",
+                    "org.jitsi.impl.neomedia.codec.video.vp8.VPXDecoder"
             };
 
     /**
diff --git a/src/org/jitsi/impl/neomedia/codec/video/vp8/Packetizer.java b/src/org/jitsi/impl/neomedia/codec/video/vp8/Packetizer.java
index fb4a4de5..3b9b3430 100644
--- a/src/org/jitsi/impl/neomedia/codec/video/vp8/Packetizer.java
+++ b/src/org/jitsi/impl/neomedia/codec/video/vp8/Packetizer.java
@@ -88,25 +88,14 @@ protected int doProcess(Buffer inputBuffer, Buffer outputBuffer)
         }
         byte[] output;
         int offset;
-        boolean haveToCopy = true;
         final int pdMaxLen = DePacketizer.VP8PayloadDescriptor.MAX_LENGTH;
 
         //The input will fit in a single packet
         if(inputBuffer.getLength() <= MAX_SIZE)
         {
-            //see if we can reuse the input buffer
-            if(inputBuffer.getOffset() >= pdMaxLen)
-            {
-                output = (byte[]) inputBuffer.getData();
-                offset = inputBuffer.getOffset();
-                haveToCopy = false;
-            }
-            else
-            {
-                output = validateByteArraySize(outputBuffer,
-                        inputBuffer.getLength() + pdMaxLen);
-                offset = pdMaxLen;
-            }
+            output = validateByteArraySize(outputBuffer,
+                                           inputBuffer.getLength() + pdMaxLen);
+            offset = pdMaxLen;
         }
         else
         {
@@ -117,14 +106,12 @@ protected int doProcess(Buffer inputBuffer, Buffer outputBuffer)
         int len = inputBuffer.getLength() <= MAX_SIZE
                     ? inputBuffer.getLength()
                     : MAX_SIZE;
-        if(haveToCopy)
-        {
-            System.arraycopy((byte[])inputBuffer.getData(),
-                                inputBuffer.getOffset(),
-                                output,
-                                offset,
-                                len);
-        }
+
+        System.arraycopy((byte[])inputBuffer.getData(),
+                         inputBuffer.getOffset(),
+                         output,
+                         offset,
+                         len);
 
         //get the payload descriptor and copy it to the output
         byte[] pd = DePacketizer.VP8PayloadDescriptor.create(firstPacket);
-- 
GitLab