From f7053318069c66b907a74ebf77ebec372076bc7c Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 27 Sep 2019 13:18:58 +0200 Subject: [PATCH] RTP video dec.: zero buffer where missing data Zero parts of the framebuffer for compressed streams. This should be safer for decoder when trying to decompress an incomplete frame. --- src/rtp/video_decoders.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 2c43d8cff..a8f1815a5 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -1785,6 +1785,25 @@ next_packet: frame_size += frame->tiles[i].data_len; } + /// Zero missing parts of framebuffer for compressed video + /// @todo this can be done also for FEC but not here + if ((pt == PT_VIDEO || pt == PT_ENCRYPT_VIDEO) && decoder->decoder_type != LINE_DECODER) { + for(int i = 0; i < max_substreams; ++i) { + unsigned int last_end = 0; + for (auto const & packets : pckt_list[i]) { + unsigned int start = packets.first; + unsigned int len = packets.second; + if (last_end < start) { + memset(frame->tiles[i].data + last_end, 0, start - last_end); + } + last_end = start + len; + } + if (last_end < frame->tiles[0].data_len) { + memset(frame->tiles[i].data + last_end, 0, frame->tiles[0].data_len - last_end); + } + } + } + // format message { unique_ptr fec_msg (new frame_msg(decoder->control, decoder->stats));