Bug 1075640: Don't return 0-length frames for decoding; add comments about loss handling r=ehugg
authorRandell Jesup <rjesup@jesup.org>
Wed, 15 Oct 2014 17:33:53 -0400
changeset 210627 8a1aa0399dcaf73a5a29f3aea184dd2cf6178e28
parent 210626 3352a380a448d21b0a32d8c99a93d0dfa550a732
child 210628 adde0b51f5b2c517b8b1d685b959b8d2b3817279
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersehugg
bugs1075640
milestone36.0a1
Bug 1075640: Don't return 0-length frames for decoding; add comments about loss handling r=ehugg Fixes OpenH264 crashes, especially under extreme packet loss
media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_buffer.cc
media/webrtc/trunk/webrtc/modules/video_coding/main/source/session_info.cc
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_buffer.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/jitter_buffer.cc
@@ -585,16 +585,21 @@ VCMEncodedFrame* VCMJitterBuffer::Extrac
 
   // We have a frame - update the last decoded state and nack list.
   last_decoded_state_.SetState(frame);
   DropPacketsFromNackList(last_decoded_state_.sequence_num());
 
   if ((*frame).IsSessionComplete())
     UpdateAveragePacketsPerFrame(frame->NumPackets());
 
+  if (frame->Length() == 0) {
+    // Normally only if MakeDecodable() on an incomplete frame threw it all away
+    ReleaseFrame(frame);
+    return NULL;
+  }
   return frame;
 }
 
 // Release frame when done with decoding. Should never be used to release
 // frames from within the jitter buffer.
 void VCMJitterBuffer::ReleaseFrame(VCMEncodedFrame* frame) {
   CriticalSectionScoped cs(crit_sect_);
   VCMFrameBuffer* frame_buffer = static_cast<VCMFrameBuffer*>(frame);
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/session_info.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/session_info.cc
@@ -543,16 +543,19 @@ int VCMSessionInfo::InsertPacket(const V
     }
   }
 
   // The insert operation invalidates the iterator |rit|.
   packet_list_it = packets_.insert(rit.base(), packet);
 
   int returnLength = InsertBuffer(frame_buffer, packet_list_it);
   UpdateCompleteSession();
+  // We call MakeDecodable() before decoding, which removes packets after a loss
+  // (and which means h.264 mode 1 frames with a loss in the first packet will be
+  // totally removed)
   if (decode_error_mode == kWithErrors)
     decodable_ = true;
   else if (decode_error_mode == kSelectiveErrors)
     UpdateDecodableSession(frame_data);
   return returnLength;
 }
 
 void VCMSessionInfo::InformOfEmptyPacket(uint16_t seq_num) {