Bug 1075640 - Don't return 0-length frames for decoding; add comments about loss handling. r=ehugg, a=sledru
authorRandell Jesup <rjesup@jesup.org>
Wed, 15 Oct 2014 17:33:53 -0400
changeset 218098 be43cc1b2373
parent 218097 a7f2d0803533
child 218099 45dd53a5354b
push id539
push userryanvm@gmail.com
push date2014-10-21 20:12 +0000
treeherdermozilla-release@45dd53a5354b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehugg, sledru
bugs1075640
milestone33.0.1
Bug 1075640 - Don't return 0-length frames for decoding; add comments about loss handling. r=ehugg, a=sledru 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) {