From 56210579563244f1decea42d52528f27f109c437 Mon Sep 17 00:00:00 2001 From: "pwestin@webrtc.org" Date: Tue, 17 Jan 2012 12:45:47 +0000 Subject: [PATCH] Removing unused code. Review URL: https://webrtc-codereview.appspot.com/349008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1442 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/common_types.h | 41 - src/modules/interface/module_common_types.h | 11 - .../media_file/source/media_file_utility.cc | 51 +- src/modules/rtp_rtcp/interface/rtp_rtcp.h | 5 - src/modules/rtp_rtcp/source/Android.mk | 1 - .../rtp_rtcp/source/h263_information.cc | 1472 ----------------- .../rtp_rtcp/source/h263_information.h | 182 -- .../rtp_rtcp/source/rtp_receiver_video.cc | 193 +-- .../rtp_rtcp/source/rtp_receiver_video.h | 21 - src/modules/rtp_rtcp/source/rtp_rtcp.gypi | 2 - src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 9 - src/modules/rtp_rtcp/source/rtp_rtcp_impl.h | 2 - .../rtp_rtcp/source/rtp_sender_video.cc | 687 +------- .../rtp_rtcp/source/rtp_sender_video.h | 40 - src/modules/rtp_rtcp/source/rtp_utility.cc | 338 ---- src/modules/rtp_rtcp/source/rtp_utility.h | 43 - .../utility/source/file_player_impl.cc | 12 - src/modules/utility/source/video_coder.cc | 14 - src/modules/utility/source/video_coder.h | 7 - .../codecs/test/videoprocessor.cc | 6 - .../main/interface/video_coding.h | 15 - .../main/interface/video_coding_defines.h | 8 - .../main/source/codec_database.cc | 62 - .../video_coding/main/source/codec_database.h | 7 - .../video_coding/main/source/frame_buffer.cc | 6 - .../video_coding/main/source/packet.cc | 4 - src/modules/video_coding/main/source/packet.h | 17 +- .../video_coding/main/source/session_info.cc | 70 +- .../video_coding/main/source/session_info.h | 1 - .../main/source/session_info_unittest.cc | 71 +- .../main/source/video_coding_impl.cc | 26 - .../main/source/video_coding_impl.h | 5 - .../main/test/jitter_buffer_test.cc | 145 +- .../video_coding/main/test/normal_test.cc | 7 - .../video_coding/main/test/test_callbacks.cc | 4 - .../video_coding/main/test/test_util.cc | 8 - .../video_coding/main/test/tester_main.cc | 4 - src/video_engine/include/vie_codec.h | 4 - .../auto_test/primitives/codec_primitives.cc | 3 +- .../primitives/general_primitives.cc | 3 - .../test/auto_test/source/vie_autotest.cc | 3 - .../auto_test/source/vie_autotest_codec.cc | 3 +- src/video_engine/vie_base_impl.cc | 2 +- src/video_engine/vie_channel.cc | 4 - src/video_engine/vie_channel.h | 2 - src/video_engine/vie_codec_impl.cc | 40 +- src/video_engine/vie_codec_impl.h | 1 - 47 files changed, 25 insertions(+), 3637 deletions(-) delete mode 100644 src/modules/rtp_rtcp/source/h263_information.cc delete mode 100644 src/modules/rtp_rtcp/source/h263_information.h diff --git a/src/common_types.h b/src/common_types.h index 62eb3dbe75..33fcf1a02e 100644 --- a/src/common_types.h +++ b/src/common_types.h @@ -451,19 +451,6 @@ enum { kPayloadNameSize = 32}; enum { kMaxSimulcastStreams = 4}; enum { kMaxTemporalStreams = 4}; -// H.263 specific -struct VideoCodecH263 -{ - char quality; -}; - -// H.264 specific -enum H264Packetization -{ - kH264SingleMode = 0, - kH264NonInterleavedMode = 1 -}; - enum VideoCodecComplexity { kComplexityNormal = 0, @@ -489,20 +476,6 @@ enum VP8ResilienceMode { // within a frame. }; -struct VideoCodecH264 -{ - H264Packetization packetization; - VideoCodecComplexity complexity; - VideoCodecProfile profile; - char level; - char quality; - - bool useFMO; - - unsigned char configParameters[kConfigParameterSize]; - unsigned char configParametersSize; -}; - // VP8 specific struct VideoCodecVP8 { @@ -513,14 +486,6 @@ struct VideoCodecVP8 unsigned char numberOfTemporalLayers; }; -// MPEG-4 specific -struct VideoCodecMPEG4 -{ - unsigned char configParameters[kConfigParameterSize]; - unsigned char configParametersSize; - char level; -}; - // Unknown specific struct VideoCodecGeneric { @@ -529,10 +494,7 @@ struct VideoCodecGeneric // Video codec types enum VideoCodecType { - kVideoCodecH263, - kVideoCodecH264, kVideoCodecVP8, - kVideoCodecMPEG4, kVideoCodecI420, kVideoCodecRED, kVideoCodecULPFEC, @@ -541,10 +503,7 @@ enum VideoCodecType union VideoCodecUnion { - VideoCodecH263 H263; - VideoCodecH264 H264; VideoCodecVP8 VP8; - VideoCodecMPEG4 MPEG4; VideoCodecGeneric Generic; }; diff --git a/src/modules/interface/module_common_types.h b/src/modules/interface/module_common_types.h index 0319dfe2fa..22d68652f7 100644 --- a/src/modules/interface/module_common_types.h +++ b/src/modules/interface/module_common_types.h @@ -40,14 +40,6 @@ struct RTPAudioHeader WebRtc_UWord8 channel; // number of channels 2 = stereo }; -struct RTPVideoHeaderH263 -{ - void InitRTPVideoHeaderH263() {}; - bool independentlyDecodable; // H.263-1998 if no P bit it's not independently decodable - bool bits; // H.263 mode B, Xor the lasy byte of previus packet with the - // first byte of this packet -}; - enum {kNoPictureId = -1}; enum {kNoTl0PicIdx = -1}; enum {kNoTemporalIdx = -1}; @@ -87,15 +79,12 @@ struct RTPVideoHeaderVP8 }; union RTPVideoTypeHeader { - RTPVideoHeaderH263 H263; RTPVideoHeaderVP8 VP8; }; enum RTPVideoCodecTypes { kRTPVideoGeneric = 0, - kRTPVideoH263 = 1, - kRTPVideoMPEG4 = 5, kRTPVideoVP8 = 8, kRTPVideoNoVideo = 10, kRTPVideoFEC = 11, diff --git a/src/modules/media_file/source/media_file_utility.cc b/src/modules/media_file/source/media_file_utility.cc index 135b7051b8..5a68deb0e0 100644 --- a/src/modules/media_file/source/media_file_utility.cc +++ b/src/modules/media_file/source/media_file_utility.cc @@ -157,26 +157,13 @@ WebRtc_Word32 ModuleFileUtility::InitAviWriting( bitMapInfoHeader.biSizeImage = bitMapInfoHeader.biWidth * bitMapInfoHeader.biHeight * bitMapInfoHeader.biBitCount / 8; - if(videoCodecInst.codecType == kVideoCodecMPEG4) + if (_aviOutFile->CreateVideoStream( + videoStreamHeader, + bitMapInfoHeader, + NULL, + 0) != 0) { - if(_aviOutFile->CreateVideoStream( - videoStreamHeader, - bitMapInfoHeader, - videoCodecInst.codecSpecific.MPEG4.configParameters, - videoCodecInst.codecSpecific.MPEG4.configParametersSize) != 0) - { - return -1; - } - } else - { - if(_aviOutFile->CreateVideoStream( - videoStreamHeader, - bitMapInfoHeader, - NULL, - 0) != 0) - { - return -1; - } + return -1; } if(!videoOnly) @@ -349,35 +336,11 @@ WebRtc_Word32 ModuleFileUtility::InitAviReading(const WebRtc_Word8* filename, videoInStreamHeader.dwRate); const size_t plnameLen = sizeof(_videoCodec.plName) / sizeof(char); - if (bitmapInfo.biCompression == AviFile::MakeFourCc('M','4','S','2')) - { - strncpy(_videoCodec.plName, "MP4V-ES", plnameLen); - if (configLength > 0) - { - if (configLength < kConfigParameterSize) - { - _videoCodec.codecSpecific.MPEG4.configParametersSize = - (WebRtc_UWord8)configLength; - memcpy(_videoCodec.codecSpecific.MPEG4.configParameters, - &codecConfigParameters, - _videoCodec.codecSpecific.MPEG4.configParametersSize); - } - else - { - return -1; - } - } - } - else if (bitmapInfo.biCompression == AviFile::MakeFourCc('I','4','2','0')) + if (bitmapInfo.biCompression == AviFile::MakeFourCc('I','4','2','0')) { strncpy(_videoCodec.plName, "I420", plnameLen); _videoCodec.codecType = kVideoCodecI420; } - else if (bitmapInfo.biCompression == AviFile::MakeFourCc('H','2','6','3')) - { - strncpy(_videoCodec.plName, "H263", plnameLen); - _videoCodec.codecType = kVideoCodecH263; - } else if (bitmapInfo.biCompression == AviFile::MakeFourCc('V', 'P', '8', '0')) { diff --git a/src/modules/rtp_rtcp/interface/rtp_rtcp.h b/src/modules/rtp_rtcp/interface/rtp_rtcp.h index afb0b8412b..0032c4ba44 100644 --- a/src/modules/rtp_rtcp/interface/rtp_rtcp.h +++ b/src/modules/rtp_rtcp/interface/rtp_rtcp.h @@ -1073,11 +1073,6 @@ public: * return -1 on failure else 0 */ virtual WebRtc_Word32 RequestKeyFrame(const FrameType frameType = kVideoFrameKey) = 0; - - /* - * Only for H.263 to interop with bad endpoints - */ - virtual WebRtc_Word32 SetH263InverseLogic(const bool enable) = 0; }; } // namespace webrtc #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RTCP_H_ diff --git a/src/modules/rtp_rtcp/source/Android.mk b/src/modules/rtp_rtcp/source/Android.mk index 540c3fa373..00bd02a883 100644 --- a/src/modules/rtp_rtcp/source/Android.mk +++ b/src/modules/rtp_rtcp/source/Android.mk @@ -36,7 +36,6 @@ LOCAL_SRC_FILES := \ forward_error_correction.cc \ forward_error_correction_internal.cc \ overuse_detector.cc \ - h263_information.cc \ remote_rate_control.cc \ receiver_fec.cc \ rtp_receiver_video.cc \ diff --git a/src/modules/rtp_rtcp/source/h263_information.cc b/src/modules/rtp_rtcp/source/h263_information.cc deleted file mode 100644 index 75030679d7..0000000000 --- a/src/modules/rtp_rtcp/source/h263_information.cc +++ /dev/null @@ -1,1472 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include -#include "h263_information.h" - -namespace webrtc { -// MCBPC --- -static const WebRtc_Word32 MCBPC_I_MAX_CODE_LENGTH = 2; -static const WebRtc_Word32 MCBPC_I_TABLE_LENGTH = 9; -static const WebRtc_UWord8 MCBPC_I_CODE[9][2] = {{0x80,0x00}, //1 - {0x20,0x00}, //001 - {0x40,0x00}, //010 - {0x60,0x00}, //011 - {0x10,0x00}, //0001 - {0x04,0x00}, //0000 01 - {0x08,0x00}, //0000 10 - {0x0C,0x00}, //0000 11 - {0x00,0x80}}; //0000 0000 1 - -static const WebRtc_UWord8 MCBPC_I_MASK[9][2] = {{0x80,0x00}, //1 - {0xE0,0x00}, //001 - {0xE0,0x00}, //010 - {0xE0,0x00}, //011 - {0xF0,0x00}, //0001 - {0xFC,0x00}, //0000 01 - {0xFC,0x00}, //0000 10 - {0xFC,0x00}, //0000 11 - {0xFF,0x80}}; //0000 0000 1 - -static const WebRtc_Word32 MCBPC_I_MBTYPE[9] = {3,3,3,3,4,4,4,4,6}; -static const WebRtc_Word32 MCBPC_I_SIZE[9] = {1,3,3,3,4,6,6,6,9}; -static const char MCBPC_I_CBPC[9][2] = {{0,0},{0,1},{1,0},{1,1},{0,0},{0,1},{1,0},{1,1},{0,0}}; - -static const WebRtc_Word32 MCBPC_P_MAX_CODE_LENGTH = 2; -static const WebRtc_Word32 MCBPC_P_TABLE_LENGTH = 25; -static const WebRtc_UWord8 MCBPC_P_CODE[25][2] = {{0x80,0x00}, //1 - {0x30,0x00}, //0011 - {0x20,0x00}, //0010 - {0x14,0x00}, //0001 01 - {0x60,0x00}, //011 - {0x0E,0x00}, //0000 111 - {0x0C,0x00}, //0000 110 - {0x02,0x80}, //0000 0010 1 - {0x40,0x00}, //010 - {0x0A,0x00}, //0000 101 - {0x08,0x00}, //0000 100 - {0x05,0x00}, //0000 0101 - {0x18,0x00}, //0001 1 - {0x04,0x00}, //0000 0100 - {0x03,0x00}, //0000 0011 - {0x06,0x00}, //0000 011 - {0x10,0x00}, //0001 00 - {0x02,0x00}, //0000 0010 0 - {0x01,0x80}, //0000 0001 1 - {0x01,0x00}, //0000 0001 0 - {0x00,0x80}, //0000 0000 1 - {0x00,0x40}, //0000 0000 010 - {0x00,0x60}, //0000 0000 0110 0 - {0x00,0x70}, //0000 0000 0111 0 - {0x00,0x78}}; //0000 0000 0111 1 - -static const WebRtc_UWord8 MCBPC_P_MASK[25][2] = {{0x80,0x00}, //1 - {0xF0,0x00}, //0011 - {0xF0,0x00}, //0010 - {0xFC,0x00}, //0001 01 - {0xE0,0x00}, //011 - {0xFE,0x00}, //0000 111 - {0xFE,0x00}, //0000 110 - {0xFF,0x80}, //0000 0010 1 - {0xE0,0x00}, //010 - {0xFE,0x00}, //0000 101 - {0xFE,0x00}, //0000 100 - {0xFF,0x00}, //0000 0101 - {0xF8,0x00}, //0001 1 - {0xFF,0x00}, //0000 0100 - {0xFF,0x00}, //0000 0011 - {0xFE,0x00}, //0000 011 - {0xFC,0x00}, //0001 00 - {0xFF,0x80}, //0000 0010 0 - {0xFF,0x80}, //0000 0001 1 - {0xFF,0x80}, //0000 0001 0 - {0xFF,0x80}, //0000 0000 1 - {0xFF,0xE0}, //0000 0000 010 - {0xFF,0xF8}, //0000 0000 0110 0 - {0xFF,0xF8}, //0000 0000 0111 0 - {0xFF,0xF8}}; //0000 0000 0111 1 - -static const WebRtc_Word32 MCBPC_P_MBTYPE[25] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,6, 5, 5, 5, 5}; -static const WebRtc_Word32 MCBPC_P_SIZE[25] = {1,4,4,6,3,7,7,9,3,7,7,8,5,8,8,7,6,9,9,9,9,11,13,13,13}; -static const char MCBPC_P_CBPC[25][2] = {{0,0},{0,1},{1,0},{1,1}, - {0,0},{0,1},{1,0},{1,1}, - {0,0},{0,1},{1,0},{1,1}, - {0,0},{0,1},{1,0},{1,1}, - {0,0},{0,1},{1,0},{1,1}, - {0,0}, - {0,0},{0,1},{1,0},{1,1}}; - -// CBPY --- -static const WebRtc_Word32 CBPY_MAX_CODE_LENGTH = 1; -static const WebRtc_Word32 CBPY_TABLE_LENGTH = 16; -static const WebRtc_UWord8 CBPY_CODE[16][1] = {{0x30}, //0011 - {0x28}, //0010 1 - {0x20}, //0010 0 - {0x90}, //1001 - {0x18}, //0001 1 - {0x70}, //0111 - {0x08}, //0000 10 - {0xB0}, //1011 - {0x10}, //0001 0 - {0x0C}, //0000 11 - {0x50}, //0101 - {0xA0}, //1010 - {0x40}, //0100 - {0x80}, //1000 - {0x60}, //0110 - {0xC0}}; //11 - -static const WebRtc_UWord8 CBPY_MASK[16][1] = {{0xF0}, //0011 - {0xF8}, //0010 1 - {0xF8}, //0010 0 - {0xF0}, //1001 - {0xF8}, //0001 1 - {0xF0}, //0111 - {0xFC}, //0000 10 - {0xF0}, //1011 - {0xF8}, //0001 0 - {0xFC}, //0000 11 - {0xF0}, //0101 - {0xF0}, //1010 - {0xF0}, //0100 - {0xF0}, //1000 - {0xF0}, //0110 - {0xC0}}; //11 - -static const WebRtc_Word32 CBPY_SIZE[16] = {4,5,5,4,5,4,6,4,5,6,4,4,4,4,4,2}; -static const char CBPY_CBPY[16][4] = {{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}, - {0,1,0,0},{0,1,0,1},{0,1,1,0},{0,1,1,1}, - {1,0,0,0},{1,0,0,1},{1,0,1,0},{1,0,1,1}, - {1,1,0,0},{1,1,0,1},{1,1,1,0},{1,1,1,1}}; - -// MVD --- -static const WebRtc_Word32 MVD_MAX_CODE_LENGTH = 2; -static const WebRtc_Word32 MVD_TABLE_LENGTH = 64; -static const WebRtc_UWord8 MVD_CODE[64][2] = {{0x00,0x28}, //0000 0000 0010 1 - {0x00,0x38}, //0000 0000 0011 1 - {0x00,0x50}, //0000 0000 0101 - {0x00,0x70}, //0000 0000 0111 - {0x00,0x90}, //0000 0000 1001 - {0x00,0xB0}, //0000 0000 1011 - {0x00,0xD0}, //0000 0000 1101 - {0x00,0xF0}, //0000 0000 1111 - {0x01,0x20}, //0000 0001 001 - {0x01,0x60}, //0000 0001 011 - {0x01,0xA0}, //0000 0001 101 - {0x01,0xE0}, //0000 0001 111 - {0x02,0x20}, //0000 0010 001 - {0x02,0x60}, //0000 0010 011 - {0x02,0xA0}, //0000 0010 101 - {0x02,0xE0}, //0000 0010 111 - {0x03,0x20}, //0000 0011 001 - {0x03,0x60}, //0000 0011 011 - {0x03,0xA0}, //0000 0011 101 - {0x03,0xE0}, //0000 0011 111 - {0x04,0x20}, //0000 0100 001 - {0x04,0x60}, //0000 0100 011 - {0x04,0xC0}, //0000 0100 11 - {0x05,0x40}, //0000 0101 01 - {0x05,0xC0}, //0000 0101 11 - {0x07,0x00}, //0000 0111 - {0x09,0x00}, //0000 1001 - {0x0B,0x00}, //0000 1011 - {0x0E,0x00}, //0000 111 - {0x18,0x00}, //0001 1 - {0x30,0x00}, //0011 - {0x60,0x00}, //011 - {0x80,0x00}, //1 - {0x40,0x00}, //010 - {0x20,0x00}, //0010 - {0x10,0x00}, //0001 0 - {0x0C,0x00}, //0000 110 - {0x0A,0x00}, //0000 1010 - {0x08,0x00}, //0000 1000 - {0x06,0x00}, //0000 0110 - {0x05,0x80}, //0000 0101 10 - {0x05,0x00}, //0000 0101 00 - {0x04,0x80}, //0000 0100 10 - {0x04,0x40}, //0000 0100 010 - {0x04,0x00}, //0000 0100 000 - {0x03,0xC0}, //0000 0011 110 - {0x03,0x80}, //0000 0011 100 - {0x03,0x40}, //0000 0011 010 - {0x03,0x00}, //0000 0011 000 - {0x02,0xC0}, //0000 0010 110 - {0x02,0x80}, //0000 0010 100 - {0x02,0x40}, //0000 0010 010 - {0x02,0x00}, //0000 0010 000 - {0x01,0xC0}, //0000 0001 110 - {0x01,0x80}, //0000 0001 100 - {0x01,0x40}, //0000 0001 010 - {0x01,0x00}, //0000 0001 000 - {0x00,0xE0}, //0000 0000 1110 - {0x00,0xC0}, //0000 0000 1100 - {0x00,0xA0}, //0000 0000 1010 - {0x00,0x80}, //0000 0000 1000 - {0x00,0x60}, //0000 0000 0110 - {0x00,0x40}, //0000 0000 0100 - {0x00,0x30}}; //0000 0000 0011 0 - -static const WebRtc_UWord8 MVD_MASK[64][2] = {{0xFF,0xF8}, //0000 0000 0010 1 - {0xFF,0xF8}, //0000 0000 0011 1 - {0xFF,0xF0}, //0000 0000 0101 - {0xFF,0xF0}, //0000 0000 0111 - {0xFF,0xF0}, //0000 0000 1001 - {0xFF,0xF0}, //0000 0000 1011 - {0xFF,0xF0}, //0000 0000 1101 - {0xFF,0xF0}, //0000 0000 1111 - {0xFF,0xE0}, //0000 0001 001 - {0xFF,0xE0}, //0000 0001 011 - {0xFF,0xE0}, //0000 0001 101 - {0xFF,0xE0}, //0000 0001 111 - {0xFF,0xE0}, //0000 0010 001 - {0xFF,0xE0}, //0000 0010 011 - {0xFF,0xE0}, //0000 0010 101 - {0xFF,0xE0}, //0000 0010 111 - {0xFF,0xE0}, //0000 0011 001 - {0xFF,0xE0}, //0000 0011 011 - {0xFF,0xE0}, //0000 0011 101 - {0xFF,0xE0}, //0000 0011 111 - {0xFF,0xE0}, //0000 0100 001 - {0xFF,0xE0}, //0000 0100 011 - {0xFF,0xC0}, //0000 0100 11 - {0xFF,0xC0}, //0000 0101 01 - {0xFF,0xC0}, //0000 0101 11 - {0xFF,0x00}, //0000 0111 - {0xFF,0x00}, //0000 1001 - {0xFF,0x00}, //0000 1011 - {0xFE,0x00}, //0000 111 - {0xF8,0x00}, //0001 1 - {0xF0,0x00}, //0011 - {0xE0,0x00}, //011 - {0x80,0x00}, //1 - {0xE0,0x00}, //010 - {0xF0,0x00}, //0010 - {0xF8,0x00}, //0001 0 - {0xFE,0x00}, //0000 110 - {0xFF,0x00}, //0000 1010 - {0xFF,0x00}, //0000 1000 - {0xFF,0x00}, //0000 0110 - {0xFF,0xC0}, //0000 0101 10 - {0xFF,0xC0}, //0000 0101 00 - {0xFF,0xC0}, //0000 0100 10 - {0xFF,0xE0}, //0000 0100 010 - {0xFF,0xE0}, //0000 0100 000 - {0xFF,0xE0}, //0000 0011 110 - {0xFF,0xE0}, //0000 0011 100 - {0xFF,0xE0}, //0000 0011 010 - {0xFF,0xE0}, //0000 0011 000 - {0xFF,0xE0}, //0000 0010 110 - {0xFF,0xE0}, //0000 0010 100 - {0xFF,0xE0}, //0000 0010 010 - {0xFF,0xE0}, //0000 0010 000 - {0xFF,0xE0}, //0000 0001 110 - {0xFF,0xE0}, //0000 0001 100 - {0xFF,0xE0}, //0000 0001 010 - {0xFF,0xE0}, //0000 0001 000 - {0xFF,0xF0}, //0000 0000 1110 - {0xFF,0xF0}, //0000 0000 1100 - {0xFF,0xF0}, //0000 0000 1010 - {0xFF,0xF0}, //0000 0000 1000 - {0xFF,0xF0}, //0000 0000 0110 - {0xFF,0xF0}, //0000 0000 0100 - {0xFF,0xF8}}; //0000 0000 0011 0 - -static const WebRtc_Word32 MVD_SIZE[64] = {13,13,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,10,10,10, 8, 8, 8, 7, 5, 4, 3, 1, 3, 4, 5, 7, 8, 8, 8, - 10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12, - 12,12,12,13}; - -// TCOEF --- -static const WebRtc_Word32 TCOEF_MAX_CODE_LENGTH = 2; -static const WebRtc_Word32 TCOEF_TABLE_LENGTH = 103; -static const WebRtc_UWord8 TCOEF_CODE[103][2] = {{0x80,0x00}, //10s - {0xF0,0x00}, //1111s - {0x54,0x00}, //0101 01s - {0x2E,0x00}, //0010 111s - {0x1F,0x00}, //0001 1111s - {0x12,0x80}, //0001 0010 1s - {0x12,0x00}, //0001 0010 0s - {0x08,0x40}, //0000 1000 01s - {0x08,0x00}, //0000 1000 00s - {0x00,0xE0}, //0000 0000 111s - {0x00,0xC0}, //0000 0000 110s - {0x04,0x00}, //0000 0100 000s - {0xC0,0x00}, //110s - {0x50,0x00}, //0101 00s - {0x1E,0x00}, //0001 1110s - {0x03,0xC0}, //0000 0011 11s - {0x04,0x20}, //0000 0100 001s - {0x05,0x00}, //0000 0101 0000s - {0xE0,0x00}, //1110s - {0x1D,0x00}, //0001 1101s - {0x03,0x80}, //0000 0011 10s - {0x05,0x10}, //0000 0101 0001s - {0x68,0x00}, //0110 1s - {0x11,0x80}, //0001 0001 1s - {0x03,0x40}, //0000 0011 01s - {0x60,0x00}, //0110 0s - {0x11,0x00}, //0001 0001 0s - {0x05,0x20}, //0000 0101 0010s - {0x58,0x00}, //0101 1s - {0x03,0x00}, //0000 0011 00s - {0x05,0x30}, //0000 0101 0011s - {0x4C,0x00}, //0100 11s - {0x02,0xC0}, //0000 0010 11s - {0x05,0x40}, //0000 0101 0100s - {0x48,0x00}, //0100 10s - {0x02,0x80}, //0000 0010 10s - {0x44,0x00}, //0100 01s - {0x02,0x40}, //0000 0010 01s - {0x40,0x00}, //0100 00s - {0x02,0x00}, //0000 0010 00s - {0x2C,0x00}, //0010 110s - {0x05,0x50}, //0000 0101 0101s - {0x2A,0x00}, //0010 101s - {0x28,0x00}, //0010 100s - {0x1C,0x00}, //0001 1100s - {0x1B,0x00}, //0001 1011s - {0x10,0x80}, //0001 0000 1s - {0x10,0x00}, //0001 0000 0s - {0x0F,0x80}, //0000 1111 1s - {0x0F,0x00}, //0000 1111 0s - {0x0E,0x80}, //0000 1110 1s - {0x0E,0x00}, //0000 1110 0s - {0x0D,0x80}, //0000 1101 1s - {0x0D,0x00}, //0000 1101 0s - {0x04,0x40}, //0000 0100 010s - {0x04,0x60}, //0000 0100 011s - {0x05,0x60}, //0000 0101 0110s - {0x05,0x70}, //0000 0101 0111s - {0x70,0x00}, //0111s //last=1 --------------------- - {0x0C,0x80}, //0000 1100 1s - {0x00,0xA0}, //0000 0000 101s - {0x3C,0x00}, //0011 11s - {0x00,0x80}, //0000 0000 100s - {0x38,0x00}, //0011 10s - {0x34,0x00}, //0011 01s - {0x30,0x00}, //0011 00s - {0x26,0x00}, //0010 011s - {0x24,0x00}, //0010 010s - {0x22,0x00}, //0010 001s - {0x20,0x00}, //0010 000s - {0x1A,0x00}, //0001 1010s - {0x19,0x00}, //0001 1001s - {0x18,0x00}, //0001 1000s - {0x17,0x00}, //0001 0111s - {0x16,0x00}, //0001 0110s - {0x15,0x00}, //0001 0101s - {0x14,0x00}, //0001 0100s - {0x13,0x00}, //0001 0011s - {0x0C,0x00}, //0000 1100 0s - {0x0B,0x80}, //0000 1011 1s - {0x0B,0x00}, //0000 1011 0s - {0x0A,0x80}, //0000 1010 1s - {0x0A,0x00}, //0000 1010 0s - {0x09,0x80}, //0000 1001 1s - {0x09,0x00}, //0000 1001 0s - {0x08,0x80}, //0000 1000 1s - {0x01,0xC0}, //0000 0001 11s - {0x01,0x80}, //0000 0001 10s - {0x01,0x40}, //0000 0001 01s - {0x01,0x00}, //0000 0001 00s - {0x04,0x80}, //0000 0100 100s - {0x04,0xA0}, //0000 0100 101s - {0x04,0xC0}, //0000 0100 110s - {0x04,0xE0}, //0000 0100 111s - {0x05,0x80}, //0000 0101 1000s - {0x05,0x90}, //0000 0101 1001s - {0x05,0xA0}, //0000 0101 1010s - {0x05,0xB0}, //0000 0101 1011s - {0x05,0xC0}, //0000 0101 1100s - {0x05,0xD0}, //0000 0101 1101s - {0x05,0xE0}, //0000 0101 1110s - {0x05,0xF0}, //0000 0101 1111s - {0x06,0x00}}; //0000 011 (escape) - -static const WebRtc_UWord8 TCOEF_MASK[103][2] = {{0xC0,0x00}, //10s - {0xF0,0x00}, //1111s - {0xFC,0x00}, //0101 01s - {0xFE,0x00}, //0010 111s - {0xFF,0x00}, //0001 1111s - {0xFF,0x80}, //0001 0010 1s - {0xFF,0x80}, //0001 0010 0s - {0xFF,0xC0}, //0000 1000 01s - {0xFF,0xC0}, //0000 1000 00s - {0xFF,0xE0}, //0000 0000 111s - {0xFF,0xE0}, //0000 0000 110s - {0xFF,0xE0}, //0000 0100 000s - {0xE0,0x00}, //110s - {0xFC,0x00}, //0101 00s - {0xFF,0x00}, //0001 1110s - {0xFF,0xC0}, //0000 0011 11s - {0xFF,0xE0}, //0000 0100 001s - {0xFF,0xF0}, //0000 0101 0000s - {0xF0,0x00}, //1110s - {0xFF,0x00}, //0001 1101s - {0xFF,0xC0}, //0000 0011 10s - {0xFF,0xF0}, //0000 0101 0001s - {0xF8,0x00}, //0110 1s - {0xFF,0x80}, //0001 0001 1s - {0xFF,0xC0}, //0000 0011 01s - {0xF8,0x00}, //0110 0s - {0xFF,0x80}, //0001 0001 0s - {0xFF,0xF0}, //0000 0101 0010s - {0xF8,0x00}, //0101 1s - {0xFF,0xC0}, //0000 0011 00s - {0xFF,0xF0}, //0000 0101 0011s - {0xFC,0x00}, //0100 11s - {0xFF,0xC0}, //0000 0010 11s - {0xFF,0xF0}, //0000 0101 0100s - {0xFC,0x00}, //0100 10s - {0xFF,0xC0}, //0000 0010 10s - {0xFC,0x00}, //0100 01s - {0xFF,0xC0}, //0000 0010 01s - {0xFC,0x00}, //0100 00s - {0xFF,0xC0}, //0000 0010 00s - {0xFE,0x00}, //0010 110s - {0xFF,0xF0}, //0000 0101 0101s - {0xFE,0x00}, //0010 101s - {0xFE,0x00}, //0010 100s - {0xFF,0x00}, //0001 1100s - {0xFF,0x00}, //0001 1011s - {0xFF,0x80}, //0001 0000 1s - {0xFF,0x80}, //0001 0000 0s - {0xFF,0x80}, //0000 1111 1s - {0xFF,0x80}, //0000 1111 0s - {0xFF,0x80}, //0000 1110 1s - {0xFF,0x80}, //0000 1110 0s - {0xFF,0x80}, //0000 1101 1s - {0xFF,0x80}, //0000 1101 0s - {0xFF,0xE0}, //0000 0100 010s - {0xFF,0xE0}, //0000 0100 011s - {0xFF,0xF0}, //0000 0101 0110s - {0xFF,0xF0}, //0000 0101 0111s - {0xF0,0x00}, //0111s //last=1 ---- - {0xFF,0x80}, //0000 1100 1s - {0xFF,0xE0}, //0000 0000 101s - {0xFC,0x00}, //0011 11s - {0xFF,0xE0}, //0000 0000 100s - {0xFC,0x00}, //0011 10s - {0xFC,0x00}, //0011 01s - {0xFC,0x00}, //0011 00s - {0xFE,0x00}, //0010 011s - {0xFE,0x00}, //0010 010s - {0xFE,0x00}, //0010 001s - {0xFE,0x00}, //0010 000s - {0xFF,0x00}, //0001 1010s - {0xFF,0x00}, //0001 1001s - {0xFF,0x00}, //0001 1000s - {0xFF,0x00}, //0001 0111s - {0xFF,0x00}, //0001 0110s - {0xFF,0x00}, //0001 0101s - {0xFF,0x00}, //0001 0100s - {0xFF,0x00}, //0001 0011s - {0xFF,0x80}, //0000 1100 0s - {0xFF,0x80}, //0000 1011 1s - {0xFF,0x80}, //0000 1011 0s - {0xFF,0x80}, //0000 1010 1s - {0xFF,0x80}, //0000 1010 0s - {0xFF,0x80}, //0000 1001 1s - {0xFF,0x80}, //0000 1001 0s - {0xFF,0x80}, //0000 1000 1s - {0xFF,0xC0}, //0000 0001 11s - {0xFF,0xC0}, //0000 0001 10s - {0xFF,0xC0}, //0000 0001 01s - {0xFF,0xC0}, //0000 0001 00s - {0xFF,0xE0}, //0000 0100 100s - {0xFF,0xE0}, //0000 0100 101s - {0xFF,0xE0}, //0000 0100 110s - {0xFF,0xE0}, //0000 0100 111s - {0xFF,0xF0}, //0000 0101 1000s - {0xFF,0xF0}, //0000 0101 1001s - {0xFF,0xF0}, //0000 0101 1010s - {0xFF,0xF0}, //0000 0101 1011s - {0xFF,0xF0}, //0000 0101 1100s - {0xFF,0xF0}, //0000 0101 1101s - {0xFF,0xF0}, //0000 0101 1110s - {0xFF,0xF0}, //0000 0101 1111s - {0xFE,0x00}}; //0000 011 (escape) - -static const WebRtc_Word32 TCOEF_SIZE[103] = { 3, 5, 7, 8, 9,10,10,11,11,12,12,12, 4, 7, 9,11,12,13, 5, 9, - 11,13, 6,10,11, 6,10,13, 6,11,13, 7,11,13, 7,11, 7,11, 7,11, - 8,13, 8, 8, 9, 9,10,10,10,10,10,10,10,10,12,12,13,13, 5,10, - 12, 7,12, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,10,10, - 10,10,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,13,13, - 13,13, 8}; - -static const char TCOEF_LAST[103] = {0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1, 1,1,0}; - -// -------------------------------------- -// -------------------------------------- -// -------------------------------------- - -WebRtc_Word32 -H263Info::CalculateMBOffset(const WebRtc_UWord8 numOfGOB) const -{ - // calculate the number of MBs before this GOB - - // sanity - if( numOfGOBs < numOfGOB) - { - assert(false); - return -1; - } - WebRtc_Word32 numMBs = 0; - for(WebRtc_UWord8 GOB = 0; GOB< numOfGOB; GOB++) - { - numMBs += ptrNumOfMBs[GOB]; - } - return numMBs; -} - - -H263Information::H263Information() -{ -} - -H263Information::~H263Information() -{ - _infoMB.bufferSize = 0; - if (_infoMB.ptrBuffer) - { - delete [] _infoMB.ptrBuffer; - delete [] _infoMB.ptrBufferHMV; - delete [] _infoMB.ptrBufferVMV; - _infoMB.ptrBuffer = 0; - _infoMB.ptrBufferHMV = 0; - _infoMB.ptrBufferVMV = 0; - } -} - -void -H263Information::Reset() -{ - _info.uiH263PTypeFmt = 0; - _info.codecBits = 0; - _info.pQuant = 0; - _info.numOfGOBs = 0; - _info.cpmBit = 0; - _info.fType = 0; - - memset(_info.ptrGOBbuffer, 0, sizeof(_info.ptrGOBbuffer)); - memset(_info.ptrGOBbufferSBit, 0, sizeof(_info.ptrGOBbufferSBit)); - memset(_info.ptrGQuant, 0, sizeof(_info.ptrGQuant)); - memset(_info.ptrNumOfMBs, 0, sizeof(_info.ptrNumOfMBs)); - memset(_info.ptrGroupNum, 0, sizeof(_info.ptrGroupNum)); - - if (_infoMB.ptrBuffer) - { - memset(_infoMB.ptrBuffer, 0, sizeof(WebRtc_UWord32) * _infoMB.bufferSize); - memset(_infoMB.ptrBufferHMV, 0, sizeof(WebRtc_UWord8) * _infoMB.bufferSize); - memset(_infoMB.ptrBufferVMV, 0, sizeof(WebRtc_UWord8) * _infoMB.bufferSize); - } -} - -/******************************************************************************* - * WebRtc_Word32 GetInfo(const WebRtc_UWord8* ptrEncodedBuffer, - * const WebRtc_UWord32 length, - * const H263Info*& ptrInfo); - * - * Gets information from an encoded stream. - * - * Input: - * - ptrEncodedBuffer : Pointer to encoded stream. - * - length : Length in bytes of encoded stream. - * - * Output: - * - ptrInfo : Pointer to struct with H263 info. - * - * Return value: - * - 0 : ok - * - (-1) : Error - */ -WebRtc_Word32 -H263Information::GetInfo(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord32 length, - const H263Info*& ptrInfo) -{ - if (!ptrEncodedBuffer || length < 8) - { - return -1; - } - - if (!HasInfo(length)) - { - if (-1 == FindInfo(ptrEncodedBuffer, length)) - { - Reset(); - return -1; - } - } - - ptrInfo = &_info; - return 0; -} - -RtpVideoCodecTypes -H263Information::Type() -{ - return kRtpH263Video; -} - - -/******************************************************************************* - * WebRtc_Word32 GetMBInfo(const WebRtc_UWord8* ptrEncodedBuffer, - * const WebRtc_UWord32 length, - * WebRtc_Word32 numOfGOB, - * const H263MBInfo*& ptrInfoMB); - * - * Gets macroblock positions for a GOB. - * Also, the horizontal and vertical motion vector for each MB are returned. - * - * Input: - * - ptrEncodedBuffer : Pointer to encoded stream. - * - length : Length in bytes of encoded stream. - * - numOfGOB : Group number of current GOB. - * - * Output: - * - infoMB : Pointer to struct with MB positions in bits for a GOB. - * Horizontal and vertical motion vector for each MB. - * - * Return value: - * - 0 : ok - * - (-1) : Error - */ -WebRtc_Word32 -H263Information::GetMBInfo(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord32 length, - const WebRtc_UWord8 numOfGOB, - const H263MBInfo*& ptrInfoMB) -{ - if (!ptrEncodedBuffer || numOfGOB > _info.numOfGOBs - 1) - { - return -1; - } - if (-1 == VerifyAndAllocateMB()) - { - return -1; - } - if (length != _info.ptrGOBbuffer[_info.numOfGOBs]) - { - return -1; - } - if (!HasMBInfo(numOfGOB)) - { - if (-1 == FindMBs(ptrEncodedBuffer, numOfGOB, length)) - { - Reset(); - return -1; - } - } - ptrInfoMB = &_infoMB; - return 0; -} - -bool -H263Information::HasInfo(const WebRtc_UWord32 length) -{ - if (!_info.ptrGOBbuffer) - { - return false; - } - if (_info.ptrGOBbuffer[0] == 0) - { - return false; - } - - // has info, make sure current length matches info length - if (length != _info.ptrGOBbuffer[_info.numOfGOBs - 1]) - { - Reset(); - return false; - } - return true; -} - -WebRtc_Word32 -H263Information::FindInfo(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord32 length) -{ - _ptrData = ptrEncodedBuffer; - - if (!PictureStartCode()) - { - return -1; - } - - // Gets picture size - if (-1 == FindPTypeFMT()) - { - return -1; - } - - FindFType(); - FindCodecBits(); - FindPQUANT(); - FindCPMbit(); - - if (-1 == FindGOBs(length)) - { - return -1; - } - if (-1 == SetNumOfMBs()) - { - return -1; - } - return 0; -} - -WebRtc_Word32 -H263Information::SetNumOfMBs() -{ - // Source format: 000 - forbidden - // 001 - SQCIF 1 GOB - one macroblock row - // 010 - QCIF 1 GOB - one macroblock row - // 011 - CIF 1 GOB - one macroblock row - // 100 - 4CIF 1 GOB - two macroblock rows - // 101 - 16CIF 1 GOB - four macroblock rows - // 110 - reserved - // 111 - extended PTYPE - - WebRtc_UWord16 numOfMBsPerGOB = 0; - - switch (_info.uiH263PTypeFmt) - { - case 1: // SQCIF - numOfMBsPerGOB = 8; - _info.totalNumOfMBs = 8 * 6; //128x96 - break; - case 2: // QCIF - numOfMBsPerGOB = 11; - _info.totalNumOfMBs = 11 * 9; - break; - case 3: // CIF - numOfMBsPerGOB = 22; - _info.totalNumOfMBs = 22 * 18; - break; - case 4: // 4CIF - numOfMBsPerGOB = 88; - _info.totalNumOfMBs = 88 * 18; - break; - case 5: // 16CIF - numOfMBsPerGOB = 352; - _info.totalNumOfMBs = 352 * 18; - break; - default: - return -1; - } - - // loop through all GOBs - WebRtc_UWord16 numberOfMBs = 0; - for(WebRtc_UWord8 GOB = 0; GOB < (_info.numOfGOBs -1); GOB++) - { - _info.ptrNumOfMBs[GOB] = numOfMBsPerGOB * (_info.ptrGroupNum[GOB+1] - _info.ptrGroupNum[GOB]); - numberOfMBs += _info.ptrNumOfMBs[GOB]; - } - _info.ptrNumOfMBs[_info.numOfGOBs -1] = _info.totalNumOfMBs - numberOfMBs; - return 0; -} - -bool -H263Information::PictureStartCode() -{ - // Picture start code (PSC) (22 bits) - // ----0--------1-------2---- - // |00000000|00000000|100000xx| - // -------------------------- - - if ( _ptrData[0] == 0 && - _ptrData[1] == 0 && - (_ptrData[2] & 0x80) && - (_ptrData[2] & 0x7C) == 0) - { - return true; - } - return false; -} - -WebRtc_Word32 -H263Information::FindPTypeFMT() -{ - // Type Information (PTYPE) (Variable Length)(8/13 bits) - // ----3--------4--------5--- - // |xxxxxxPP|PPPPPPpp|pppxxxxx| - // -------------------------- - - // Source format (bits 6-8) - _info.uiH263PTypeFmt = (_ptrData[4] >> 2) & 0x07; - return 0; -} - -void -H263Information::FindFType() -{ - // Type Information (PTYPE) (13 bits, source format != 111, not extended PTYPE) - // ----3--------4--------5--- - // |xxxxxxPP|PPPPPPPP|PPPxxxxx| - // -------------------------- - - // Picture coding type (bit 9) - _info.fType = (_ptrData[4] & 0x02) >> 1; // 0 = I-frame, 1 = P-frame -} - -void -H263Information::FindCodecBits() -{ - // Type Information (PTYPE) (13 bits) - // ----3--------4--------5--- - // |xxxxxxPP|PPPPPPPP|PPPxxxxx| - // -------------------------- - - // Bits 9-12 // bit 10: Unrestricted Motion Vector mode (annex D) 0-off, 1-on - _info.codecBits = (_ptrData[4] & 0x03) << 2; // bit 11: Syntax-based Arithmetic Coding mode (annex E) - _info.codecBits += (_ptrData[5] & 0xC0) >> 6; // bit 12: Advanced Prediction mode (annex F) -} - -void -H263Information::FindPQUANT() -{ - // Quantizer Information (PQUANT) (5 bits) - // ----5--- - // |xxxQQQQQ| - // -------- - - _info.pQuant = _ptrData[5] & 0x1F; -} - -void -H263Information::FindCPMbit() -{ - // Continuous presence multipoWebRtc_Word32 and Video multiplex (CPM) (1 bit) - // ----6--- - // |Cxxxxxxx| - // -------- - - _info.cpmBit = IsBitOne(48); // 0-off, 1-on -} - -WebRtc_Word32 -H263Information::FindGOBs(const WebRtc_UWord32 length) -{ - // Group of block layer (GOB). - // GOB header followed by data for (one or more rows) of macroblocks. - - // Stuffing (GSTUF) (Variable length) consisting of less than 8 zero-bits. May be - // inserted by encoders so that the start of the GBSC is byte aligned. - // Group of block start code (GBSC) (17 bits). May be byte aligned. - // Group Number (GN) (5 bits). Group numbers 1-17 used for standard picture formats. - // 0 used in PSC. - // -------------------------------- - // |GSTUF|00000000|00000000|1GGGGGxx| - // -------------------------------- - - WebRtc_UWord8 numOfGOB = 0; - WebRtc_UWord8 groupNum = 0; - WebRtc_UWord8 sBit = 0; - - _info.ptrGroupNum[numOfGOB] = 0; - _info.ptrGOBbuffer[numOfGOB] = 0; - _info.ptrGOBbufferSBit[numOfGOB] = 0; - numOfGOB++; - - for (WebRtc_UWord32 i = 3; (i < length - 2); i++) - { - if (_ptrData[i] == 0) - { - if (_ptrData[i + 1] == 0) - { - if (_ptrData[i + 2] & 0x80) - { - // GBSC byte aligned - groupNum = (_ptrData[i + 2] >> 2) & 0x1f; - _info.ptrGroupNum[numOfGOB] = groupNum; - _info.ptrGOBbuffer[numOfGOB] = i; - _info.ptrGOBbufferSBit[numOfGOB] = 0; - numOfGOB++; - } - }else - { - // check for non byte aligned GBSC - if ((_ptrData[i - 1] & 0x7F) == 0 && (_ptrData[i + 1] & 0xC0) == 0x40) - { - // |x0000000|00000000|01GGGGGx| - sBit = 1; - groupNum = (_ptrData[i + 1] >> 1) & 0x1f; - } - else if ((_ptrData[i - 1] & 0x3F) == 0 && (_ptrData[i + 1] & 0xE0) == 0x20) - { - // |xx000000|00000000|001GGGGG| - sBit = 2; - groupNum = (_ptrData[i + 1]) & 0x1f; - } - else if ((_ptrData[i - 1] & 0x1F) == 0 && (_ptrData[i + 1] & 0xF0) == 0x10) - { - // |xxx00000|00000000|0001GGGG|G - sBit = 3; - groupNum = ((_ptrData[i + 1] & 0x0F) << 1) | ((_ptrData[i + 2] >> 7) & 0x01); - } - else if ((_ptrData[i - 1] & 0x0F) == 0 && (_ptrData[i + 1] & 0xF8) == 0x08) - { - // |xxxx0000|00000000|00001GGG|GG - sBit = 4; - groupNum = ((_ptrData[i + 1] & 0x07) << 2) | ((_ptrData[i + 2] >> 6) & 0x03); - } - else if ((_ptrData[i - 1] & 0x07) == 0 && (_ptrData[i + 1] & 0xFC) == 0x04) - { - // |xxxxx000|00000000|000001GG|GGG - sBit = 5; - groupNum = ((_ptrData[i + 1] & 0x03) << 3) | ((_ptrData[i + 2] >> 5) & 0x07); - } - else if ((_ptrData[i - 1] & 0x03) == 0 && (_ptrData[i + 1] & 0xFE) == 0x02) - { - // |xxxxxx00|00000000|0000001G|GGGG - sBit = 6; - groupNum = ((_ptrData[i + 1] & 0x01) << 4) | ((_ptrData[i + 2] >> 4) & 0x0F); - } - else if ((_ptrData[i - 1] & 0x01) == 0 && _ptrData[i + 1] == 0x01) - { - // |xxxxxxx0|00000000|00000001|GGGGG - sBit = 7; - groupNum = (_ptrData[i + 2] >> 3) & 0x1f; - } - else - { - sBit = 0; - groupNum = 0; - } - if (sBit) - { - _info.ptrGroupNum[numOfGOB] = groupNum; - _info.ptrGOBbuffer[numOfGOB] = i - 1; - _info.ptrGOBbufferSBit[numOfGOB] = sBit; - numOfGOB++; - } - } - if(numOfGOB >= MAX_NUMBER_OF_H263_GOB) - { - return -1; - } - } - } - _info.numOfGOBs = numOfGOB; - _info.ptrGOBbuffer[numOfGOB] = length; - _info.ptrGOBbufferSBit[numOfGOB] = 0; - return 0; -} - -WebRtc_Word32 -H263Information::VerifyAndAllocateMB() -{ - WebRtc_UWord32 minimumSize = _info.totalNumOfMBs; - if (minimumSize == 0) - { - return -1; - } - - if (minimumSize > _infoMB.bufferSize) - { - // make sure that our buffer is big enough - if (_infoMB.ptrBuffer) - { - delete [] _infoMB.ptrBuffer; - delete [] _infoMB.ptrBufferHMV; - delete [] _infoMB.ptrBufferVMV; - } - _infoMB.ptrBuffer = new WebRtc_UWord32[minimumSize]; - _infoMB.ptrBufferHMV = new WebRtc_UWord8[minimumSize]; - _infoMB.ptrBufferVMV = new WebRtc_UWord8[minimumSize]; - _infoMB.bufferSize = minimumSize; - - // reset memory - memset(_infoMB.ptrBuffer, 0, sizeof(WebRtc_UWord32) * _infoMB.bufferSize); - memset(_infoMB.ptrBufferHMV, 0, sizeof(WebRtc_UWord8) * _infoMB.bufferSize); - memset(_infoMB.ptrBufferVMV, 0, sizeof(WebRtc_UWord8) * _infoMB.bufferSize); - } - return 0; -} - -bool -H263Information::HasMBInfo(const WebRtc_UWord8 numOfGOB) -{ - if (!_infoMB.ptrBuffer) - { - return false; - } - - WebRtc_Word32 offset = _info.CalculateMBOffset(numOfGOB); - - if (_infoMB.ptrBuffer[offset] == 0) - { - return false; - } - return true; -} - -WebRtc_Word32 -H263Information::FindMBs(const WebRtc_UWord8 *ptrEncodedBuffer, - const WebRtc_UWord8 numOfGOB, - const WebRtc_UWord32 length) -{ - _bitCnt = 0; - WebRtc_Word32 bitCntOffset = 0; - _ptrData = ptrEncodedBuffer; - WebRtc_UWord32 payloadBytesToSend = length; - - if (numOfGOB > 0) - { - // Point at current GOB - _ptrData += _info.ptrGOBbuffer[numOfGOB ]; - payloadBytesToSend -= _info.ptrGOBbuffer[numOfGOB]; - // Start bits to ignore - _bitCnt += _info.ptrGOBbufferSBit[numOfGOB]; - // Byte with start bits has already been sent, start counting from next byte - if (_info.ptrGOBbufferSBit[numOfGOB]) - { - bitCntOffset = 8; - } - } - - WebRtc_Word32 offset = _info.CalculateMBOffset(numOfGOB); - WebRtc_UWord32 *sizeOfMBs = &_infoMB.ptrBuffer[offset]; - WebRtc_UWord8 *hmv1 = &_infoMB.ptrBufferHMV[offset]; - WebRtc_UWord8 *vmv1 = &_infoMB.ptrBufferVMV[offset]; - - // Header data - if (numOfGOB == 0) - { - // Picture layer - // ----------------------- - // | Picture header | GOBs | // For GOB number 0, empty GOB header - // ----------------------- - - _bitCnt = 49; - if (_info.cpmBit) - { - _bitCnt += 2; - } - - WebRtc_Word32 peiBit = IsBitOne(_bitCnt); - _bitCnt++; - if (peiBit) - { - _bitCnt += 8; - peiBit = IsBitOne(_bitCnt); - _bitCnt++; - if (peiBit) - { - _bitCnt += 9; - } - } - } - else if (numOfGOB < _info.numOfGOBs) - { - // Group of block layer (GOB). - // Group of block start code (GBSC) (17 bits). - // Group Number (GN) (5 bits). - // GOB Sub-Stream Indicator (GSBI) (2 bits). Only present if CPM = 1. - // GOB Frame ID (GFID) (2 bits). - // Quantizer Information (GQUANT) (5 bits). - // ---------------------------------------------------- - // | GBSC | GN | GSBI | GFID | GQUANT | Macroblock data | - // ---------------------------------------------------- - - _bitCnt += 24; - if (_info.cpmBit) - { - _bitCnt += 2; - } - - FindGQUANT(numOfGOB); - - _bitCnt += 5; - } - else - { - return -1; - } - - // Start of macroblock data - // ----------------------- - // | MB header | blockdata | - // ----------------------- - for (WebRtc_Word32 j = 0; j < _info.ptrNumOfMBs[numOfGOB]; j++) - { - // MB header - // ------------------------------------------------ - // | COD(inter) | MCBPC | CBPY | DQUANT |MVD(inter) | - // ------------------------------------------------ - WebRtc_Word32 codBit = 0; - if (_info.fType) - { - codBit = IsBitOne(_bitCnt); - _bitCnt++; - } - - if (codBit == 0) // if codBit == 1, no further info transmitted for this MB - { - WebRtc_Word32 mbType = 0; - char cbp[6]; - - // Get MB type & coded block pattern for chrominance (MCBPC) - WebRtc_Word32 size = FindMCBPC(mbType, cbp); - - _bitCnt += size; - - if (size == -1) - { - return -1; - } - - // Get coded block pattern for luminance (CBPY) - size = FindCBPY(mbType, cbp); - - _bitCnt += size; - - if (size == -1) - { - return -1; - } - - // Quantizer information (DQUANT), change in QUANT - if (mbType == 1 || mbType == 4) - { - _bitCnt += 2; - } - - // Get motion vector data (MVD) (inter-frames) - if (_info.fType && (mbType < 3 || mbType == 5)) - { - // Horizontal and vertical component - for (WebRtc_Word32 k = 0; k < 2; k++) - { - size = FindMVD(j, k, hmv1, vmv1); - - _bitCnt += size; - - if (size == -1) - { - return -1; - } - } - } - - // Block data. 1MB = 6 blocks (4 luminance blocks + 2 color blocks) - // ----------------- - // | intraDC | TCOEF | - // ----------------- - WebRtc_Word32 numOfBlocks = 6; - - WebRtc_Word32 WebRtc_Word32raDC = 0; - if (mbType == 3 || mbType == 4) - { - WebRtc_Word32raDC = 8; - } - - for (WebRtc_Word32 i = 0; i < numOfBlocks; i++) - { - // Get WebRtc_Word32raDC coefficient - _bitCnt += WebRtc_Word32raDC; - - // Get non-WebRtc_Word32RA dc coefficients - if (cbp[i]) // presence indicated by CBPY and CBPC - { - WebRtc_Word32 last = 0; - while (last == 0) - { - // Get transform coefficient (TCOEF) - size = FindTCOEF(last); - - _bitCnt += size; - - if (size == -1) - { - return -1; - } - } - } - } - // end of MB - sizeOfMBs[j] = _bitCnt - bitCntOffset; - } - else - { - // end of MB - sizeOfMBs[j] = _bitCnt - bitCntOffset; - } - } - // end of MBs - WebRtc_Word32 nextByte = _bitCnt >> 3; - WebRtc_Word32 nextByteRem = _bitCnt % 8; - if (nextByteRem) - { - nextByte++; - } - - // Check for next GOB/end of picture - if (numOfGOB < (_info.numOfGOBs - 1)) - { - // Test with GSTUF, GBSC (0000 0000 0000 0000 1) - if (_ptrData[nextByte] == 0 && - _ptrData[nextByte + 1] == 0 && - _ptrData[nextByte + 2] & 0x80) - { - sizeOfMBs[_info.ptrNumOfMBs[numOfGOB] - 1] = (nextByte << 3) - bitCntOffset; - return 1; // ok, next GOB - } - // ...without GSTUF - if (IsGBSC()) - { - return 1; // ok, next GOB - } - } - else if (numOfGOB == (_info.numOfGOBs - 1)) - { - // Picture end code may be included, (PSTUF (optional), EOS (22bits), ESTUF) - if (((WebRtc_UWord32) nextByte == payloadBytesToSend) || - ((WebRtc_UWord32)(nextByte + 2) == payloadBytesToSend) || - ((WebRtc_UWord32)(nextByte + 3) == payloadBytesToSend)) - { - sizeOfMBs[_info.ptrNumOfMBs[numOfGOB] - 1] = (payloadBytesToSend << 3) - bitCntOffset; - return 1; // ok, end of picture layer - } - } - else - { - return -1; - } - - return -1; -} - -WebRtc_Word32 -H263Information::FindMCBPC(WebRtc_Word32 &mbType, char *cbp) -{ - if (_info.fType == 0) // intra frame - { - ByteAlignData(MCBPC_I_MAX_CODE_LENGTH); - - WebRtc_Word32 i; - for (i = 0; i < MCBPC_I_TABLE_LENGTH - 1; i++) - { - if ((_dataShifted[0] & MCBPC_I_MASK[i][0]) == MCBPC_I_CODE[i][0]) - { - cbp[4] = MCBPC_I_CBPC[i][0]; - cbp[5] = MCBPC_I_CBPC[i][1]; - mbType = MCBPC_I_MBTYPE[i]; - - return MCBPC_I_SIZE[i]; - } - } - // last row - i = MCBPC_I_TABLE_LENGTH - 1; - if ((_dataShifted[0] & MCBPC_I_MASK[i][0]) == MCBPC_I_CODE[i][0] && - (_dataShifted[1] & MCBPC_I_MASK[i][1]) == MCBPC_I_CODE[i][1]) - { - cbp[4] = MCBPC_I_CBPC[i][0]; - cbp[5] = MCBPC_I_CBPC[i][1]; - mbType = MCBPC_I_MBTYPE[i]; - - return MCBPC_I_SIZE[i]; - } - - return -1; - } - else // inter frame - { - ByteAlignData(MCBPC_P_MAX_CODE_LENGTH); - - for (WebRtc_Word32 i = 0; i < MCBPC_P_TABLE_LENGTH; i++) - { - if ((_dataShifted[0] & MCBPC_P_MASK[i][0]) == MCBPC_P_CODE[i][0] && - (_dataShifted[1] & MCBPC_P_MASK[i][1]) == MCBPC_P_CODE[i][1]) - { - cbp[4] = MCBPC_P_CBPC[i][0]; - cbp[5] = MCBPC_P_CBPC[i][1]; - mbType = MCBPC_P_MBTYPE[i]; - - return MCBPC_P_SIZE[i]; - } - } - } - - return -1; -} - -WebRtc_Word32 -H263Information::FindCBPY(WebRtc_Word32 mbType, char *cbp) -{ - ByteAlignData(CBPY_MAX_CODE_LENGTH); - - for (WebRtc_Word32 i = 0; i < CBPY_TABLE_LENGTH; i++) - { - if ((_dataShifted[0] & CBPY_MASK[i][0]) == CBPY_CODE[i][0]) - { - cbp[0] = CBPY_CBPY[i][0]; - cbp[1] = CBPY_CBPY[i][1]; - cbp[2] = CBPY_CBPY[i][2]; - cbp[3] = CBPY_CBPY[i][3]; - - if (mbType == 0 || mbType == 1) - { - for (WebRtc_Word32 k = 0; k < 4; k++) - { - if (cbp[k]) - { - cbp[k] = 0; - } - else - { - cbp[k] = 1; - } - } - } - return CBPY_SIZE[i]; - } - } - - return -1; -} - -WebRtc_Word32 -H263Information::FindMVD(WebRtc_Word32 numOfMB, WebRtc_Word32 verORhor, WebRtc_UWord8 *hmv1, WebRtc_UWord8 *vmv1) -{ - ByteAlignData(MVD_MAX_CODE_LENGTH); - - for (WebRtc_Word32 i = 0; i < MVD_TABLE_LENGTH; i++) - { - if ((_dataShifted[0] & MVD_MASK[i][0]) == MVD_CODE[i][0] && - (_dataShifted[1] & MVD_MASK[i][1]) == MVD_CODE[i][1]) - { - // Store horizontal/vertical motion vector predictor (2's complement number) - WebRtc_Word32 index = i - 32; - if (index < 0) - { - index = ~ (-index-1); - } - - if (verORhor == 0) - { - hmv1[numOfMB] = static_cast(index); - - } else - { - vmv1[numOfMB] = static_cast(index); - } - - return MVD_SIZE[i]; - } - } - return -1; -} - -WebRtc_Word32 -H263Information::FindTCOEF(WebRtc_Word32 &last) -{ - ByteAlignData(TCOEF_MAX_CODE_LENGTH); - - for (WebRtc_Word32 i = 0; i < TCOEF_TABLE_LENGTH; i++) - { - if ((_dataShifted[0] & TCOEF_MASK[i][0]) == TCOEF_CODE[i][0] && - (_dataShifted[1] & TCOEF_MASK[i][1]) == TCOEF_CODE[i][1]) - { - last = TCOEF_LAST[i]; - if (i == (TCOEF_TABLE_LENGTH - 1)) - { - if (IsBitOne(_bitCnt + 7)) - { - last = 1; - } - return 22; - } - return TCOEF_SIZE[i]; - } - } - return -1; -} - -bool -H263Information::IsGBSC() -{ - // Group of block layer (GOB). - // Stuffing (GSTUF) (Variable length) consisting of less than 8 zero-bits. May be - // inserted by encoders so that the start of the GBSC is byte aligned. - // Group of block start code (GBSC) (17 bits). May be byte aligned. - // Group Number (GN) (5 bits). Group numbers 1-17 used for standard picture formats. - // -------------------------------- - // |GSTUF|00000000|00000000|1GGGGGxx| - // -------------------------------- - - ByteAlignData(3); - - if (_dataShifted[0] == 0 && _dataShifted[1] == 0 && (_dataShifted[2] & 0x80) == 0x80) - { - return true; - } - - return false; -} - -void -H263Information::FindGQUANT(WebRtc_Word32 numOfGOB) -{ - ByteAlignData(1); - - _info.ptrGQuant[numOfGOB] = (_dataShifted[0] >> 3) & 0x1F; -} - -WebRtc_UWord8 -H263Information::IsBitOne(const WebRtc_Word32 bitCnt) const -{ - WebRtc_Word32 curByte = bitCnt >> 3; - WebRtc_Word32 bit = bitCnt % 8; - - switch(bit) - { - case 0: - return _ptrData[curByte] & 0x80; - case 1: - return _ptrData[curByte] & 0x40; - case 2: - return _ptrData[curByte] & 0x20; - case 3: - return _ptrData[curByte] & 0x10; - case 4: - return _ptrData[curByte] & 0x08; - case 5: - return _ptrData[curByte] & 0x04; - case 6: - return _ptrData[curByte] & 0x02; - case 7: - return _ptrData[curByte] & 0x01; - default: - return 0; - } -} - -void -H263Information::ByteAlignData(WebRtc_Word32 numOfBytes) -{ - WebRtc_Word32 sByte = _bitCnt >> 3; - WebRtc_Word32 sBit = _bitCnt % 8; - - // Shift to byte align - WebRtc_Word32 i = 0; - do - { - _dataShifted[i] = _ptrData[sByte] << sBit; - _dataShifted[i++] += _ptrData[++sByte] >> (8 - sBit); - } while (i < numOfBytes); -} -} // namespace webrtc diff --git a/src/modules/rtp_rtcp/source/h263_information.h b/src/modules/rtp_rtcp/source/h263_information.h deleted file mode 100644 index 7839787632..0000000000 --- a/src/modules/rtp_rtcp/source/h263_information.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_H263_INFORMATION_H_ -#define WEBRTC_MODULES_RTP_RTCP_SOURCE_H263_INFORMATION_H_ - -#include "typedefs.h" - -#include "video_codec_information.h" - -#define MAX_NUMBER_OF_H263_GOB 32 // 5 bits - -namespace webrtc { -class H263Info -{ -public: - H263Info() - : - uiH263PTypeFmt(0), - codecBits(0), - pQuant(0), - numOfGOBs(0), - totalNumOfMBs(0), - cpmBit(0), - fType(0) - { - memset(ptrGOBbuffer, 0, sizeof(ptrGOBbuffer)); - memset(ptrGOBbufferSBit, 0, sizeof(ptrGOBbufferSBit)); - memset(ptrGQuant, 0, sizeof(ptrGQuant)); - memset(ptrNumOfMBs, 0, sizeof(ptrNumOfMBs)); - memset(ptrGroupNum, 0, sizeof(ptrGroupNum)); - } - - WebRtc_Word32 CalculateMBOffset(const WebRtc_UWord8 numOfGOB) const; - - WebRtc_UWord8 uiH263PTypeFmt; // Defines frame size - WebRtc_UWord8 codecBits; - WebRtc_UWord8 pQuant; - WebRtc_UWord8 numOfGOBs; // Total number of GOBs of current frame - - WebRtc_UWord16 totalNumOfMBs; - WebRtc_UWord8 cpmBit; - WebRtc_UWord8 fType; // 0 - intra frame, 1 - inter frame - - WebRtc_UWord16 ptrNumOfMBs[MAX_NUMBER_OF_H263_GOB]; // Total number of MBs of current GOB - WebRtc_UWord32 ptrGOBbuffer[MAX_NUMBER_OF_H263_GOB]; // GOB buffer (start byte of GOBs) - WebRtc_UWord8 ptrGroupNum[MAX_NUMBER_OF_H263_GOB]; - WebRtc_UWord8 ptrGOBbufferSBit[MAX_NUMBER_OF_H263_GOB]; // sBit buffer (number of start bits to ignore for corresponding GOB) - WebRtc_UWord8 ptrGQuant[MAX_NUMBER_OF_H263_GOB]; // quantizer information for GOBs -}; - -struct H263MBInfo -{ - H263MBInfo() - : - bufferSize(0), - ptrBuffer(0), - ptrBufferHMV(0), - ptrBufferVMV(0) - { - } - - WebRtc_UWord32 bufferSize; // Size of MB buffer - WebRtc_UWord32* ptrBuffer; // MB buffer - WebRtc_UWord8* ptrBufferHMV; // Horizontal motion vector for corresponding MB - WebRtc_UWord8* ptrBufferVMV; // Vertical motion vector for corresponding MB -}; - -class H263Information : public VideoCodecInformation -{ -public: - H263Information(); - ~H263Information(); - - /******************************************************************************* - * void Reset(); - * - * Resets the members to zero. - * - */ - virtual void Reset(); - - virtual RtpVideoCodecTypes Type(); - - /******************************************************************************* - * WebRtc_Word32 GetInfo(WebRtc_UWord8* ptrEncodedBuffer, - * WebRtc_UWord32 length, - * const H263Info*& ptrInfo); - * - * Gets information from an encoded stream. - * - * Input: - * - ptrEncodedBuffer : PoWebRtc_Word32er to encoded stream. - * - length : Length in bytes of encoded stream. - * - * Output: - * - ptrInfo : PoWebRtc_Word32er to struct with H263 info. - * - * Return value: - * - 0 : ok - * - (-1) : Error - */ - virtual WebRtc_Word32 GetInfo(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord32 length, - const H263Info*& ptrInfo); - - /******************************************************************************* - * WebRtc_Word32 GetMBInfo(const WebRtc_UWord8* ptrEncodedBuffer, - * WebRtc_UWord32 length, - * WebRtc_Word32 numOfGOB, - * const H263MBInfo*& ptrInfoMB); - * - * Gets macroblock positions for a GOB. - * Also, the horizontal and vertical motion vector for each MB are returned. - * - * Input: - * - ptrEncodedBuffer : Pointer to encoded stream. - * - length : Length in bytes of encoded stream. - * - numOfGOB : Group number of current GOB. - * - * Output: - * - ptrInfoMB : Pointer to struct with MB positions in bits for a GOB. - * Horizontal and vertical motion vector for each MB. - * - * Return value: - * - 0 : ok - * - (-1) : Error - */ - WebRtc_Word32 GetMBInfo(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord32 length, - const WebRtc_UWord8 numOfGOB, - const H263MBInfo*& ptrInfoMB); - -protected: - bool HasInfo(const WebRtc_UWord32 length); - WebRtc_Word32 FindInfo(const WebRtc_UWord8* ptrEncodedBuffer, const WebRtc_UWord32 length); - - bool PictureStartCode(); - WebRtc_Word32 FindPTypeFMT(); - void FindFType(); - void FindCodecBits(); - void FindPQUANT(); - void FindCPMbit(); - WebRtc_Word32 SetNumOfMBs(); - - WebRtc_Word32 FindGOBs(const WebRtc_UWord32 length); - - // MB info - WebRtc_Word32 VerifyAndAllocateMB(); - bool HasMBInfo(const WebRtc_UWord8 numOfGOB); - WebRtc_Word32 FindMBs(const WebRtc_UWord8* ptrEncodedBuffer, - const WebRtc_UWord8 numOfGOB, - const WebRtc_UWord32 length); - - void FindGQUANT(WebRtc_Word32 numOfGOB); - WebRtc_Word32 FindMCBPC(WebRtc_Word32 &mbType, char *cbp); - WebRtc_Word32 FindCBPY(WebRtc_Word32 mbType, char *cbp); - WebRtc_Word32 FindMVD(WebRtc_Word32 numOfMB, WebRtc_Word32 verORhor, WebRtc_UWord8 *hmv1, WebRtc_UWord8 *vmv1); - WebRtc_Word32 FindTCOEF(WebRtc_Word32 &last); - bool IsGBSC(); - WebRtc_UWord8 IsBitOne(const WebRtc_Word32 bitCnt) const; - void ByteAlignData(WebRtc_Word32 numOfBytes); - void OutputBits(WebRtc_Word32 length); - -private: - WebRtc_Word32 _bitCnt; - const WebRtc_UWord8* _ptrData; - WebRtc_UWord8 _dataShifted[5]; - - H263Info _info; - H263MBInfo _infoMB; -}; -} // namespace webrtc - -#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_H263_INFORMATION_H_ diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc index 4bf418a11c..4bc83bb3fa 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc +++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc @@ -39,7 +39,6 @@ RTPReceiverVideo::RTPReceiverVideo(const WebRtc_Word32 id, _estimatedBW(0), _currentFecFrameDecoded(false), _receiveFEC(NULL), - _h263InverseLogic(false), _overUseDetector(), _videoBitRate(), _lastBitRateChange(0), @@ -109,24 +108,9 @@ RTPReceiverVideo::RegisterReceiveVideoPayload(const WebRtc_Word8 payloadName[RTP if (ModuleRTPUtility::StringCompare(payloadName, "VP8",3)) { videoType = kRtpVp8Video; - - } else if ((ModuleRTPUtility::StringCompare(payloadName, "H263-1998", 9)) || - (ModuleRTPUtility::StringCompare(payloadName, "H263-2000", 9))) - { - videoType = kRtpH2631998Video; - - } else if (ModuleRTPUtility::StringCompare(payloadName, "H263", 4)) - { - videoType = kRtpH263Video; - - } else if (ModuleRTPUtility::StringCompare(payloadName, "MP4V-ES", 7)) - { - videoType = kRtpMpeg4Video; - } else if (ModuleRTPUtility::StringCompare(payloadName, "I420", 4)) { videoType = kRtpNoVideo; - } else if (ModuleRTPUtility::StringCompare(payloadName, "ULPFEC", 6)) { // store this @@ -136,7 +120,7 @@ RTPReceiverVideo::RegisterReceiveVideoPayload(const WebRtc_Word8 payloadName[RTP } _receiveFEC->SetPayloadTypeFEC(payloadType); videoType = kRtpFecVideo; - }else + } else { return NULL; } @@ -434,15 +418,6 @@ RTPReceiverVideo::SetCodecType(const RtpVideoCodecTypes videoType, case kRtpVp8Video: rtpHeader->type.Video.codec = kRTPVideoVP8; break; - case kRtpH263Video: - rtpHeader->type.Video.codec = kRTPVideoH263; - break; - case kRtpH2631998Video: - rtpHeader->type.Video.codec = kRTPVideoH263; - break; - case kRtpMpeg4Video: - rtpHeader->type.Video.codec = kRTPVideoMPEG4; - break; case kRtpFecVideo: rtpHeader->type.Video.codec = kRTPVideoFEC; break; @@ -475,15 +450,6 @@ RTPReceiverVideo::ParseVideoCodecSpecificSwitch(WebRtcRTPHeader* rtpHeader, case kRtpVp8Video: retVal = ReceiveVp8Codec(rtpHeader, payloadData, payloadDataLength); break; - case kRtpH263Video: - retVal = ReceiveH263Codec(rtpHeader, payloadData, payloadDataLength); - break; - case kRtpH2631998Video: - retVal = ReceiveH2631998Codec(rtpHeader,payloadData, payloadDataLength); - break; - case kRtpMpeg4Video: - retVal = ReceiveMPEG4Codec(rtpHeader,payloadData, payloadDataLength); - break; default: _criticalSectionReceiverVideo->Leave(); assert(((void)"ParseCodecSpecific videoType can not be unknown here!", false)); @@ -492,157 +458,6 @@ RTPReceiverVideo::ParseVideoCodecSpecificSwitch(WebRtcRTPHeader* rtpHeader, return retVal; } -WebRtc_Word32 -RTPReceiverVideo::ReceiveH263Codec(WebRtcRTPHeader* rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength) -{ - ModuleRTPUtility::RTPPayloadParser rtpPayloadParser(kRtpH263Video, - payloadData, - payloadDataLength, - _id); - ModuleRTPUtility::RTPPayload parsedPacket; - const bool success = rtpPayloadParser.Parse(parsedPacket); - - // from here down we only work on local data - _criticalSectionReceiverVideo->Leave(); - - if (!success) - { - return -1; - } - if (IP_PACKET_SIZE < parsedPacket.info.H263.dataLength + - (parsedPacket.info.H263.insert2byteStartCode ? 2 : 0)) - { - return -1; - } - return ReceiveH263CodecCommon(parsedPacket, rtpHeader); -} - -WebRtc_Word32 -RTPReceiverVideo::ReceiveH2631998Codec(WebRtcRTPHeader* rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength) -{ - ModuleRTPUtility::RTPPayloadParser rtpPayloadParser(kRtpH2631998Video, - payloadData, - payloadDataLength, - _id); - - ModuleRTPUtility::RTPPayload parsedPacket; - const bool success = rtpPayloadParser.Parse(parsedPacket); - if (!success) - { - _criticalSectionReceiverVideo->Leave(); - return -1; - } - if (IP_PACKET_SIZE < parsedPacket.info.H263.dataLength + - (parsedPacket.info.H263.insert2byteStartCode ? 2 : 0)) - { - _criticalSectionReceiverVideo->Leave(); - return -1; - } - // from here down we only work on local data - _criticalSectionReceiverVideo->Leave(); - - return ReceiveH263CodecCommon(parsedPacket, rtpHeader); -} - -WebRtc_Word32 -RTPReceiverVideo::ReceiveH263CodecCommon(ModuleRTPUtility::RTPPayload& parsedPacket, - WebRtcRTPHeader* rtpHeader) -{ - rtpHeader->frameType = (parsedPacket.frameType == ModuleRTPUtility::kIFrame) ? kVideoFrameKey : kVideoFrameDelta; - if (_h263InverseLogic) // Microsoft H263 bug - { - if (rtpHeader->frameType == kVideoFrameKey) - rtpHeader->frameType = kVideoFrameDelta; - else - rtpHeader->frameType = kVideoFrameKey; - } - rtpHeader->type.Video.isFirstPacket = parsedPacket.info.H263.hasPictureStartCode; - - // if p == 0 - // it's a follow-on packet, hence it's not independently decodable - rtpHeader->type.Video.codecHeader.H263.independentlyDecodable = parsedPacket.info.H263.hasPbit; - - if (parsedPacket.info.H263.hasPictureStartCode) - { - rtpHeader->type.Video.width = parsedPacket.info.H263.frameWidth; - rtpHeader->type.Video.height = parsedPacket.info.H263.frameHeight; - } else - { - rtpHeader->type.Video.width = 0; - rtpHeader->type.Video.height = 0; - } - rtpHeader->type.Video.codecHeader.H263.bits = (parsedPacket.info.H263.startBits > 0)?true:false; - - // copy to a local buffer - WebRtc_UWord8 dataBuffer[IP_PACKET_SIZE]; - WebRtc_UWord16 dataLength = 0; - - // we need to copy since we modify the first byte - if(parsedPacket.info.H263.insert2byteStartCode) - { - dataBuffer[0] = 0; - dataBuffer[1] = 0; - memcpy(dataBuffer+2, parsedPacket.info.H263.data, parsedPacket.info.H263.dataLength); - dataLength = 2 + parsedPacket.info.H263.dataLength; - } else - { - memcpy(dataBuffer, parsedPacket.info.H263.data, parsedPacket.info.H263.dataLength); - dataLength = parsedPacket.info.H263.dataLength; - } - - if(parsedPacket.info.H263.dataLength > 0) - { - if(parsedPacket.info.H263.startBits > 0) - { - // make sure that the ignored start bits are zero - dataBuffer[0] &= (0xff >> parsedPacket.info.H263.startBits); - } - if(parsedPacket.info.H263.endBits > 0) - { - // make sure that the ignored end bits are zero - dataBuffer[parsedPacket.info.H263.dataLength -1] &= ((0xff << parsedPacket.info.H263.endBits) & 0xff); - } - } - - return CallbackOfReceivedPayloadData(dataBuffer, dataLength, rtpHeader); -} - -WebRtc_Word32 -RTPReceiverVideo::ReceiveMPEG4Codec(WebRtcRTPHeader* rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength) -{ - ModuleRTPUtility::RTPPayloadParser rtpPayloadParser(kRtpMpeg4Video, - payloadData, - payloadDataLength, - _id); - - ModuleRTPUtility::RTPPayload parsedPacket; - const bool success = rtpPayloadParser.Parse(parsedPacket); - if (!success) - { - _criticalSectionReceiverVideo->Leave(); - return -1; - } - // from here down we only work on local data - _criticalSectionReceiverVideo->Leave(); - - rtpHeader->frameType = (parsedPacket.frameType == ModuleRTPUtility::kIFrame) ? kVideoFrameKey : kVideoFrameDelta; - rtpHeader->type.Video.isFirstPacket = parsedPacket.info.MPEG4.isFirstPacket; - - if(CallbackOfReceivedPayloadData(parsedPacket.info.MPEG4.data, - parsedPacket.info.MPEG4.dataLength, - rtpHeader) != 0) - { - return -1; - } - return 0; - } - WebRtc_Word32 RTPReceiverVideo::ReceiveVp8Codec(WebRtcRTPHeader* rtpHeader, const WebRtc_UWord8* payloadData, @@ -738,12 +553,6 @@ RTPReceiverVideo::ReceiveGenericCodec(WebRtcRTPHeader* rtpHeader, return 0; } -WebRtc_Word32 RTPReceiverVideo::SetH263InverseLogic(const bool enable) -{ - _h263InverseLogic = enable; - return 0; -} - void RTPReceiverVideo::SetPacketOverHead(WebRtc_UWord16 packetOverHead) { _packetOverHead = packetOverHead; diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.h b/src/modules/rtp_rtcp/source/rtp_receiver_video.h index 78934267ba..d2c7c5e014 100644 --- a/src/modules/rtp_rtcp/source/rtp_receiver_video.h +++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.h @@ -60,8 +60,6 @@ public: const WebRtc_UWord16 incomingRtpPacketSize, const WebRtc_Word64 nowMS); - WebRtc_Word32 SetH263InverseLogic(const bool enable); - WebRtc_Word32 ReceiveRecoveredPacketCallback( WebRtcRTPHeader* rtpHeader, const WebRtc_UWord8* payloadData, @@ -105,22 +103,6 @@ protected: const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadDataLength); - WebRtc_Word32 ReceiveH263Codec(WebRtcRTPHeader *rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength); - - WebRtc_Word32 ReceiveH2631998Codec(WebRtcRTPHeader *rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength); - - WebRtc_Word32 ReceiveH263CodecCommon( - ModuleRTPUtility::RTPPayload& parsedPacket, - WebRtcRTPHeader* rtpHeader); - - WebRtc_Word32 ReceiveMPEG4Codec(WebRtcRTPHeader *rtpHeader, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadDataLength); - WebRtc_Word32 ReceiveVp8Codec(WebRtcRTPHeader *rtpHeader, const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadDataLength); @@ -147,9 +129,6 @@ private: bool _currentFecFrameDecoded; ReceiverFEC* _receiveFEC; - // H263 - bool _h263InverseLogic; - // BWE OverUseDetector _overUseDetector; BitRateStats _videoBitRate; diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp.gypi b/src/modules/rtp_rtcp/source/rtp_rtcp.gypi index 381779c13b..5bd67d7fb9 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp.gypi +++ b/src/modules/rtp_rtcp/source/rtp_rtcp.gypi @@ -71,8 +71,6 @@ 'forward_error_correction_internal.h', 'overuse_detector.cc', 'overuse_detector.h', - 'h263_information.cc', - 'h263_information.h', 'remote_rate_control.cc', 'remote_rate_control.h', 'rtp_packet_history.cc', diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 93d088dcf2..4fc675d020 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -3121,15 +3121,6 @@ WebRtc_Word32 ModuleRtpRtcpImpl::BoundingSet(bool &tmmbrOwner, boundingSet); } -WebRtc_Word32 ModuleRtpRtcpImpl::SetH263InverseLogic(const bool enable) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "SetH263InverseLogic(%s)", - enable ? "true":"false"); - return _rtpReceiver.SetH263InverseLogic(enable); -} - void ModuleRtpRtcpImpl::SendKeyFrame() { WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, _id, "SendKeyFrame()"); OnReceivedIntraFrameRequest(0); diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 4351ab1e7d..d5f6948440 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -486,8 +486,6 @@ public: virtual WebRtc_Word32 SetFECUepProtection(const bool keyUseUepProtection, const bool deltaUseUepProtection); - virtual WebRtc_Word32 SetH263InverseLogic(const bool enable); - virtual WebRtc_Word32 LastReceivedNTP(WebRtc_UWord32& NTPsecs, WebRtc_UWord32& NTPfrac, WebRtc_UWord32& remoteSR); diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.cc b/src/modules/rtp_rtcp/source/rtp_sender_video.cc index bbbae187d3..51326980b3 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -19,7 +19,6 @@ #include // assert #include // srand -#include "h263_information.h" #include "rtp_format_vp8.h" namespace webrtc { @@ -50,12 +49,7 @@ RTPSenderVideo::RTPSenderVideo(const WebRtc_Word32 id, _fecUseUepProtection(false), _numberFirstPartition(0), _fecOverheadRate(clock), - _videoBitrate(clock), - - // H263 - _savedByte(0), - _eBit(0) -{ + _videoBitrate(clock) { } RTPSenderVideo::~RTPSenderVideo() @@ -119,19 +113,6 @@ RTPSenderVideo::RegisterVideoPayload( if (ModuleRTPUtility::StringCompare(payloadName, "VP8",3)) { videoType = kRtpVp8Video; - } - else if ((ModuleRTPUtility::StringCompare(payloadName, "H263-1998", 9)) || - (ModuleRTPUtility::StringCompare(payloadName, "H263-2000", 9))) - { - videoType = kRtpH2631998Video; - } - else if (ModuleRTPUtility::StringCompare(payloadName, "H263", 4)) - { - videoType = kRtpH263Video; - } - else if (ModuleRTPUtility::StringCompare(payloadName, "MP4V-ES", 7)) - { - videoType = kRtpMpeg4Video; } else if (ModuleRTPUtility::StringCompare(payloadName, "I420", 4)) { videoType = kRtpNoVideo; @@ -461,18 +442,6 @@ RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, retVal = SendGeneric(payloadType,captureTimeStamp, payloadData, payloadSize); break; - case kRtpH263Video: - retVal = SendH263(frameType,payloadType, captureTimeStamp, payloadData, - payloadSize, codecInfo); - break; - case kRtpH2631998Video: //RFC 4629 - retVal = SendH2631998(frameType,payloadType, captureTimeStamp, - payloadData, payloadSize, codecInfo); - break; - case kRtpMpeg4Video: // RFC 3016 - retVal = SendMPEG4(frameType,payloadType, captureTimeStamp, - payloadData, payloadSize); - break; case kRtpVp8Video: retVal = SendVP8(frameType, payloadType, captureTimeStamp, payloadData, payloadSize, fragmentation, rtpTypeHdr); @@ -549,114 +518,6 @@ RTPSenderVideo::SendGeneric(const WebRtc_Word8 payloadType, return 0; } -WebRtc_Word32 -RTPSenderVideo::SendMPEG4(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize) -{ - WebRtc_Word32 payloadBytesToSend = payloadSize; - WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength(); - WebRtc_UWord16 maxLength = _rtpSender.MaxPayloadLength() - - FECPacketOverhead() - rtpHeaderLength; - WebRtc_UWord8 dataBuffer[IP_PACKET_SIZE]; - - // Fragment packet of max MaxPayloadLength bytes payload. - const WebRtc_UWord8* data = payloadData; - - while (payloadBytesToSend > 0) - { - WebRtc_UWord16 payloadBytes = 0; - WebRtc_Word32 dataOffset = rtpHeaderLength; - - do - { - WebRtc_Word32 size = 0; - bool markerBit = false; - if(payloadBytesToSend > maxLength) - { - size = FindMPEG4NALU(data, maxLength); - }else - { - // Last in frame - markerBit = true; - size = payloadBytesToSend; - } - if(size <= 0) - { - return -1; - } - if(size > maxLength) - { - // We need to fragment NALU - return -1; - } - - if(payloadBytes == 0) - { - // Build RTP header - if(_rtpSender.BuildRTPheader( - dataBuffer, - payloadType, - markerBit, - captureTimeStamp) != rtpHeaderLength) - { - return -1; - } - } - - if( size + payloadBytes <= maxLength) - { - // Put payload in packet - memcpy(&dataBuffer[dataOffset], data, size); - dataOffset += size; //advance frame ptr - data += size; //advance packet ptr - payloadBytes += (WebRtc_UWord16)size; - payloadBytesToSend -= size; - } else - { - // Send packet - break; - } - }while(payloadBytesToSend); - - if (-1 == SendVideoPacket(frameType, dataBuffer, payloadBytes, - rtpHeaderLength, kAllowRetransmission)) - { - return -1; - } - } - return 0; -} - -WebRtc_Word32 -RTPSenderVideo::FindMPEG4NALU(const WebRtc_UWord8* inData, - WebRtc_Word32 maxLength) -{ - WebRtc_Word32 size = 0; - for (WebRtc_Word32 i = maxLength; i > 4; i-=2) // Find NAL - { - // Scan down - if (inData[i] == 0) - { - if (inData[i-1] == 0) - { - // i point at the last zero - size = i-1; - }else if(inData[i+1] == 0) - { - size = i; - } - if(size > 0) - { - return size; - } - } - } - return 0; -} - VideoCodecInformation* RTPSenderVideo::CodecInformationVideo() { @@ -675,552 +536,6 @@ RTPSenderVideo::MaxConfiguredBitrateVideo() const return _maxBitrate; } -WebRtc_Word32 -RTPSenderVideo::SendH263(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize, - VideoCodecInformation* codecInfo) -{ - bool modeA = true; - WebRtc_UWord16 h263HeaderLength = 4; - WebRtc_UWord16 payloadBytesInPacket = 0; - WebRtc_Word32 payloadBytesToSend = payloadSize; - WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength(); - - // -2: one byte is possible old ebit -> sBit, - // one byte is new ebit if next GOB header is not byte aligned - // (eventual sBit, eBit) - WebRtc_UWord16 maxPayloadLengthH263 = _rtpSender.MaxPayloadLength() - - FECPacketOverhead() - rtpHeaderLength - h263HeaderLength - 2; - - // Fragment packet into packets of max MaxPayloadLength bytes payload. - WebRtc_UWord8 numOfGOB = 0; - WebRtc_UWord16 prevOK = 0; - WebRtc_UWord32 payloadBytesSent = 0; - WebRtc_UWord8 sbit = 0; - _eBit = 0; - - H263Information* h263Information = NULL; - if(codecInfo) - { - // Another channel have already parsed this data - h263Information = static_cast(codecInfo); - - } else - { - if(_videoCodecInformation) - { - if(_videoCodecInformation->Type() != kRtpH263Video) - { - // Wrong codec - delete _videoCodecInformation; - _videoCodecInformation = new H263Information(); - } else - { - _videoCodecInformation->Reset(); - } - } else - { - _videoCodecInformation = new H263Information(); - } - h263Information = static_cast(_videoCodecInformation); - } - - WebRtc_UWord8 dataBuffer[IP_PACKET_SIZE]; - const WebRtc_UWord8* data = payloadData; - const H263Info* ptrH263Info = NULL; - - if (h263Information->GetInfo(payloadData,payloadSize, ptrH263Info) == -1) - { - return -1; - } - - while (payloadBytesToSend > 0) - { - prevOK = 0; - modeA = true; - - if (payloadBytesToSend > maxPayloadLengthH263) - { - // Fragment packet at GOB boundary - for (; numOfGOB < ptrH263Info->numOfGOBs; numOfGOB++) - { - // Fit one or more GOBs into packet - if (WebRtc_Word32(ptrH263Info->ptrGOBbuffer[numOfGOB+1] - - payloadBytesSent) < maxPayloadLengthH263) - { - prevOK = static_cast( - ptrH263Info->ptrGOBbuffer[numOfGOB+1] - - payloadBytesSent); - }else - { - break; - } - } - if (!prevOK) - { - // GOB larger than max MaxPayloadLength bytes => Mode B required - // Fragment stream at MB boundaries - modeA = false; - - // Get MB positions within GOB - const H263MBInfo* ptrInfoMB = NULL; - if (-1 == h263Information->GetMBInfo(payloadData, payloadSize, - numOfGOB, ptrInfoMB)) - { - return -1; - } - WebRtc_Word32 offset = ptrH263Info-> - CalculateMBOffset(numOfGOB); - if(offset < 0) - { - return -1; - } - // Send packets fragmented at MB boundaries - if (-1 == SendH263MBs(frameType, payloadType, captureTimeStamp, - dataBuffer, data, rtpHeaderLength, - numOfGOB, *ptrH263Info,*ptrInfoMB, offset)) - { - return -1; - } - offset = ptrH263Info->CalculateMBOffset(numOfGOB+1); - if(offset < 0) - { - return -1; - } - WebRtc_Word32 numBytes = ptrInfoMB->ptrBuffer[offset-1] / 8; - WebRtc_Word32 numBytesRem = ptrInfoMB->ptrBuffer[offset-1] % 8; - if (numBytesRem) - { - // In case our GOB is not byte alligned - numBytes++; - } - payloadBytesToSend -= numBytes; - data += numBytes; - payloadBytesSent += numBytes; - numOfGOB++; - } - } - if (modeA) - { - h263HeaderLength = 4; - WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength(); - - // H.263 payload header (4 bytes) - // First bit 0 == mode A, (00 000 000) - dataBuffer[rtpHeaderLength] = 0; - dataBuffer[rtpHeaderLength+1] = ptrH263Info->uiH263PTypeFmt << 5; - // Last bit 0 - dataBuffer[rtpHeaderLength + 1] += ptrH263Info->codecBits << 1; - // First 3 bits 0 - dataBuffer[rtpHeaderLength + 2] = 0; - // No pb frame - dataBuffer[rtpHeaderLength + 3] = 0; - - // Last packet eBit -> current packet sBit - sbit = (8 - _eBit) % 8; - - if (payloadBytesToSend > maxPayloadLengthH263) - { - if (numOfGOB > 0) - { - // Check if GOB header is byte aligned - if(ptrH263Info->ptrGOBbufferSBit) - { - _eBit = (8 - - ptrH263Info->ptrGOBbufferSBit[numOfGOB - 1]) % 8; - } else - { - _eBit = 0; - } - } - if (_eBit) - { - // Next GOB header is not byte aligned, - // include this byte in packet - // Send the byte with eBits - prevOK++; - } - } - - if (payloadBytesToSend > maxPayloadLengthH263) - { - payloadBytesInPacket = prevOK; - payloadBytesToSend -= payloadBytesInPacket; - _rtpSender.BuildRTPheader(dataBuffer, payloadType, - false, captureTimeStamp); - - } else - { - payloadBytesInPacket = (WebRtc_UWord16)payloadBytesToSend; - payloadBytesToSend = 0; - _rtpSender.BuildRTPheader(dataBuffer, payloadType, - true, captureTimeStamp); - _eBit = 0; - } - - if (sbit) - { - // Add last sent byte and put payload in packet - // Set sBit - dataBuffer[rtpHeaderLength] = dataBuffer[rtpHeaderLength] | - ((sbit & 0x7) << 3); - memcpy(&dataBuffer[rtpHeaderLength + h263HeaderLength], - &_savedByte, 1); - memcpy(&dataBuffer[rtpHeaderLength + h263HeaderLength + 1], - data, payloadBytesInPacket); - h263HeaderLength++; - - }else - { - // Put payload in packet - memcpy(&dataBuffer[rtpHeaderLength + h263HeaderLength], data, - payloadBytesInPacket); - } - if (_eBit) - { - // Save last byte to paste in next packet - // Set eBit - dataBuffer[rtpHeaderLength] |= (_eBit & 0x7); - _savedByte = dataBuffer[payloadBytesInPacket + - h263HeaderLength + rtpHeaderLength-1]; - } - if (-1 == SendVideoPacket(frameType, - dataBuffer, - payloadBytesInPacket + h263HeaderLength, - rtpHeaderLength, kAllowRetransmission)) - { - return -1; - } - payloadBytesSent += payloadBytesInPacket; - data += payloadBytesInPacket; - } - } - return 0; -} - -WebRtc_Word32 -RTPSenderVideo::SendH2631998(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize, - VideoCodecInformation* codecInfo) -{ - const WebRtc_UWord16 h2631998HeaderLength = 2; - // No extra header included - const WebRtc_UWord8 pLen = 0; - const WebRtc_UWord8 peBit = 0; - bool fragment = false; - WebRtc_UWord16 payloadBytesInPacket = 0; - WebRtc_Word32 payloadBytesToSend = payloadSize; - WebRtc_UWord16 numPayloadBytesToSend = 0; - WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength(); - - // P is not set in all packets, - // only packets that has a PictureStart or a GOB header - WebRtc_UWord8 p = 2; - - H263Information* h263Information = NULL; - if(codecInfo) - { - // Another channel have already parsed this data - h263Information = static_cast(codecInfo); - - } else - { - if(_videoCodecInformation) - { - if(_videoCodecInformation->Type() != kRtpH263Video) - { - // Wrong codec - delete _videoCodecInformation; - _videoCodecInformation = new H263Information(); - } else - { - _videoCodecInformation->Reset(); - } - } else - { - _videoCodecInformation = new H263Information(); - } - h263Information = static_cast(_videoCodecInformation); - } - const H263Info* ptrH263Info = NULL; - if (h263Information->GetInfo(payloadData,payloadSize, ptrH263Info) == -1) - { - return -1; - } - - WebRtc_UWord8 dataBuffer[IP_PACKET_SIZE]; - const WebRtc_UWord16 maxPayloadLengthH2631998 = - _rtpSender.MaxPayloadLength() - FECPacketOverhead() - rtpHeaderLength - - h2631998HeaderLength; - const WebRtc_UWord8* data = payloadData; - WebRtc_UWord8 numOfGOB = 0; - WebRtc_UWord32 payloadBytesSent = 0; - - while(payloadBytesToSend > 0) - { - WebRtc_Word32 prevOK = 0; - - // Fragment packets at GOB boundaries - for (; numOfGOB < ptrH263Info->numOfGOBs; numOfGOB++) - { - // Fit one or more GOBs into packet - if (static_cast( - ptrH263Info->ptrGOBbuffer[numOfGOB+1] - - payloadBytesSent) <= - (maxPayloadLengthH2631998 + p)) - { - prevOK = static_cast( - ptrH263Info->ptrGOBbuffer[numOfGOB+1] - - payloadBytesSent); - if(fragment) - { - // This is a fragment, send it - break; - } - }else - { - break; - } - } - if(!prevOK) - { - // GOB larger than MaxPayloadLength bytes - fragment = true; - numPayloadBytesToSend = maxPayloadLengthH2631998; - } else - { - fragment = false; - numPayloadBytesToSend = WebRtc_UWord16(prevOK - p); - } - dataBuffer[rtpHeaderLength] = (p << 1) + ((pLen >> 5) & 0x01); - dataBuffer[rtpHeaderLength+1] = ((pLen & 0x1F) << 3) + peBit; - - if(p == 2) - { - // Increment data ptr - // (do not send first two bytes of picture or GOB start code) - data += 2; - payloadBytesToSend -= 2; - } - - if(payloadBytesToSend > maxPayloadLengthH2631998) - { - payloadBytesInPacket = numPayloadBytesToSend; - payloadBytesToSend -= payloadBytesInPacket; - - _rtpSender.BuildRTPheader(dataBuffer, payloadType, - false, captureTimeStamp); - }else - { - payloadBytesInPacket = (WebRtc_UWord16)payloadBytesToSend; - payloadBytesToSend = 0; - // MarkerBit is 1 - _rtpSender.BuildRTPheader(dataBuffer, payloadType, - true, captureTimeStamp); - } - // Put payload in packet - memcpy(&dataBuffer[rtpHeaderLength + h2631998HeaderLength], - data, payloadBytesInPacket); - - if(-1 == SendVideoPacket(frameType, - dataBuffer, - payloadBytesInPacket + h2631998HeaderLength, - rtpHeaderLength, - kAllowRetransmission)) - { - return -1; - } - data += payloadBytesInPacket; - payloadBytesSent += payloadBytesInPacket + p; - if(fragment) - { - p = 0; - }else - { - p = 2; - } - } - return 0; -} - -WebRtc_Word32 -RTPSenderVideo::SendH263MBs(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - WebRtc_UWord8* dataBuffer, - const WebRtc_UWord8 *data, - const WebRtc_UWord16 rtpHeaderLength, - const WebRtc_UWord8 numOfGOB, - const H263Info& info, - const H263MBInfo& infoMB, - const WebRtc_Word32 offset) -{ - // Mode B - WebRtc_UWord32 *sizeOfMBs = &infoMB.ptrBuffer[offset]; - WebRtc_UWord8 *hmv1 = &infoMB.ptrBufferHMV[offset]; - WebRtc_UWord8 *vmv1 = &infoMB.ptrBufferVMV[offset]; - - WebRtc_UWord16 h263HeaderLength = 8; - WebRtc_UWord16 payloadBytesInPacket = 0; - WebRtc_Word32 payloadBytesToSend = - sizeOfMBs[info.ptrNumOfMBs[numOfGOB]-1] / 8; - WebRtc_UWord8 eBitLastByte = (WebRtc_UWord8)((8 - - (sizeOfMBs[info.ptrNumOfMBs[numOfGOB]-1] % 8)) % 8); - WebRtc_Word32 sBit = 0; - WebRtc_Word32 firstMB = 0; - WebRtc_UWord32 bitsRem = 0; - WebRtc_UWord32 payloadBytesSent = 0; - WebRtc_Word32 numOfMB = 0; - WebRtc_Word32 prevOK = 0; - - // (Eventual sBit, eBit) - WebRtc_UWord16 maxPayloadLengthH263MB = _rtpSender.MaxPayloadLength() - - FECPacketOverhead() - rtpHeaderLength - h263HeaderLength - 2; - if (eBitLastByte) - { - payloadBytesToSend++; - } - - // Fragment packet into packets of max MaxPayloadLength bytes payload. - while (payloadBytesToSend > 0) - { - prevOK = 0; - firstMB = numOfMB; - if (payloadBytesToSend > maxPayloadLengthH263MB) - { - // Fragment packet at MB boundary - for (; numOfMB < info.ptrNumOfMBs[numOfGOB]; numOfMB++) - { - // Fit one or more MBs into packet - if (WebRtc_Word32(sizeOfMBs[numOfMB] / 8 - payloadBytesSent) < - maxPayloadLengthH263MB) - { - prevOK = sizeOfMBs[numOfMB] / 8 - payloadBytesSent; - bitsRem = sizeOfMBs[numOfMB] % 8; - if (bitsRem) - { - prevOK++; - } - }else - { - break; - } - } - - if (!prevOK) - { - // MB does not fit in packet - return -1; - } - } - - - // H.263 payload header (8 bytes) - h263HeaderLength = 8; - // First bit 1 == mode B, 10 000 000 - dataBuffer[rtpHeaderLength] = (WebRtc_UWord8)0x80; - // Source format - dataBuffer[rtpHeaderLength + 1] = (info.uiH263PTypeFmt) << 5; - if (numOfGOB == 0) - { - // Quantization value for first MB in packet - dataBuffer[rtpHeaderLength + 1] += info.pQuant; - } - if (numOfGOB > 0 && firstMB > 0) - { - // Quantization value for first MB in packet - // (0 if packet begins w/ a GOB header) - dataBuffer[rtpHeaderLength + 1] += info.ptrGQuant[numOfGOB]; - } - // GOB # - dataBuffer[rtpHeaderLength + 2] = numOfGOB << 3; - // First MB in the packet - dataBuffer[rtpHeaderLength + 2] += (WebRtc_UWord8)((firstMB >> 6)& 0x7); - dataBuffer[rtpHeaderLength + 3] = (WebRtc_UWord8)(firstMB << 2); - dataBuffer[rtpHeaderLength + 4] = (info.codecBits) << 4; - // Horizontal motion vector - dataBuffer[rtpHeaderLength + 4] += (hmv1[firstMB] & 0x7F) >> 3; - dataBuffer[rtpHeaderLength + 5] = hmv1[firstMB] << 5; - // Vertical motion vector - dataBuffer[rtpHeaderLength + 5] += (vmv1[firstMB] & 0x7F) >> 2; - dataBuffer[rtpHeaderLength + 6] = vmv1[firstMB] << 6; - dataBuffer[rtpHeaderLength + 7] = 0; - - sBit = (8 - _eBit) % 8; - - if (payloadBytesToSend > maxPayloadLengthH263MB) - { - payloadBytesInPacket = (WebRtc_UWord16)prevOK; - payloadBytesToSend -= payloadBytesInPacket; - - _rtpSender.BuildRTPheader(dataBuffer, payloadType, false, - captureTimeStamp); - - _eBit = (WebRtc_UWord8)((8 - bitsRem) % 8); - } - else - { - payloadBytesInPacket = (WebRtc_UWord16)payloadBytesToSend; - payloadBytesToSend = 0; - - if (numOfGOB == (info.numOfGOBs - 1)) - { - _rtpSender.BuildRTPheader(dataBuffer, payloadType, true, - captureTimeStamp); - _eBit = 0; - } - else - { - _rtpSender.BuildRTPheader(dataBuffer, payloadType, false, - captureTimeStamp); - _eBit = eBitLastByte; - } - } - - - if (sBit) - { - // Add last sent byte and put payload in packet - dataBuffer[rtpHeaderLength] |= ((sBit & 0x7) << 3); - dataBuffer[rtpHeaderLength + h263HeaderLength] = _savedByte; - memcpy(&dataBuffer[rtpHeaderLength + h263HeaderLength + 1], - data, payloadBytesInPacket); - h263HeaderLength++; - } else - { - // Put payload in packet - memcpy(&dataBuffer[rtpHeaderLength + h263HeaderLength], - data, payloadBytesInPacket); - } - if (_eBit) - { - // Save last byte to paste in next packet - dataBuffer[rtpHeaderLength] |= (_eBit & 0x7); - _savedByte = dataBuffer[rtpHeaderLength + - h263HeaderLength + - payloadBytesInPacket - 1]; - } - if (-1 == SendVideoPacket(frameType, - dataBuffer, - payloadBytesInPacket + h263HeaderLength, - rtpHeaderLength, - kAllowRetransmission)) - { - return -1; - } - - data += payloadBytesInPacket; - payloadBytesSent += payloadBytesInPacket; - } - return 0; -} - WebRtc_Word32 RTPSenderVideo::SendVP8(const FrameType frameType, const WebRtc_Word8 payloadType, diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.h b/src/modules/rtp_rtcp/source/rtp_sender_video.h index 92eb4fa873..107e05a7bb 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_video.h +++ b/src/modules/rtp_rtcp/source/rtp_sender_video.h @@ -20,7 +20,6 @@ #include "list_wrapper.h" #include "video_codec_information.h" -#include "h263_information.h" #include "forward_error_correction.h" #include "Bitrate.h" @@ -104,26 +103,6 @@ private: const WebRtc_UWord8* payloadData, const WebRtc_UWord32 payloadSize); - WebRtc_Word32 SendH263(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize, - VideoCodecInformation* codecInfo); - - WebRtc_Word32 SendH2631998(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize, - VideoCodecInformation* codecInfo); - - WebRtc_Word32 SendMPEG4(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord32 payloadSize); - WebRtc_Word32 SendVP8(const FrameType frameType, const WebRtc_Word8 payloadType, const WebRtc_UWord32 captureTimeStamp, @@ -132,21 +111,6 @@ private: const RTPFragmentationHeader* fragmentation, const RTPVideoTypeHeader* rtpTypeHdr); - // MPEG 4 - WebRtc_Word32 FindMPEG4NALU(const WebRtc_UWord8* inData ,WebRtc_Word32 MaxPayloadLength); - - // H263 - WebRtc_Word32 SendH263MBs(const FrameType frameType, - const WebRtc_Word8 payloadType, - const WebRtc_UWord32 captureTimeStamp, - WebRtc_UWord8* dataBuffer, - const WebRtc_UWord8 *data, - const WebRtc_UWord16 rtpHeaderLength, - const WebRtc_UWord8 numOfGOB, - const H263Info& info, - const H263MBInfo& infoMB, - const WebRtc_Word32 offset); - private: WebRtc_Word32 _id; RTPSenderInterface& _rtpSender; @@ -176,10 +140,6 @@ private: Bitrate _fecOverheadRate; // Bitrate used for video payload and RTP headers Bitrate _videoBitrate; - - // H263 - WebRtc_UWord8 _savedByte; - WebRtc_UWord8 _eBit; }; } // namespace webrtc diff --git a/src/modules/rtp_rtcp/source/rtp_utility.cc b/src/modules/rtp_rtcp/source/rtp_utility.cc index f008849152..228de49ec1 100644 --- a/src/modules/rtp_rtcp/source/rtp_utility.cc +++ b/src/modules/rtp_rtcp/source/rtp_utility.cc @@ -427,27 +427,6 @@ ModuleRTPUtility::RTPPayload::SetType(RtpVideoCodecTypes videoType) { case kRtpNoVideo: break; - case kRtpH263Video: - case kRtpH2631998Video: - { - info.H263.hasPictureStartCode = false; - info.H263.insert2byteStartCode = false; - info.H263.hasPbit = false; - info.H263.frameWidth = 0; - info.H263.frameHeight = 0; - info.H263.startBits = 0; - info.H263.endBits = 0; - info.H263.data = 0; - info.H263.dataLength = 0; - break; - } - case kRtpMpeg4Video: - { - info.MPEG4.isFirstPacket = false; - info.MPEG4.data = 0; - info.MPEG4.dataLength = 0; - break; - } case kRtpVp8Video: { info.VP8.nonReferenceFrame = false; @@ -793,12 +772,6 @@ ModuleRTPUtility::RTPPayloadParser::Parse( RTPPayload& parsedPacket) const { case kRtpNoVideo: return ParseGeneric(parsedPacket); - case kRtpH263Video: - return ParseH263(parsedPacket); - case kRtpH2631998Video: - return ParseH2631998(parsedPacket); - case kRtpMpeg4Video: - return ParseMPEG4(parsedPacket); case kRtpVp8Video: return ParseVP8(parsedPacket); default: @@ -812,177 +785,6 @@ ModuleRTPUtility::RTPPayloadParser::ParseGeneric(RTPPayload& /*parsedPacket*/) c return false; } -bool -ModuleRTPUtility::RTPPayloadParser::ParseH263(RTPPayload& parsedPacket) const -{ - if(_dataLength <= 2) - { - // data length sanity check. - return false; - } - - const WebRtc_UWord8 header1 = _dataPtr[0]; - const WebRtc_UWord8 header2 = _dataPtr[1]; - - parsedPacket.frameType = ((header2 & 0x10) == 0) ? kIFrame : kPFrame; - - unsigned int h263HeaderLength = 0; - if ((header1 & 0x80) == 0) - { - // Mode A - h263HeaderLength = 4; - } - else - { - // In Mode B and Mode C, I bit is in 5th byte of header - const WebRtc_UWord8 header5 = _dataPtr[4]; - parsedPacket.frameType = ((header5 & 0x80) == 0) ? kIFrame : kPFrame; - - if((header1 & 0x40) == 0) - { - // Mode B - // IMPROVEMENT use the information in the H263 header? - // GQuant of the first MB - h263HeaderLength = 8; - }else - { - // Mode C - h263HeaderLength = 12; - } - } - - if (_dataLength < h263HeaderLength) - { - // Received empty H263 packet - return false; - } - - // Get SBIT and EBIT - WebRtc_UWord8 sbit = 0; - WebRtc_UWord8 ebit = 0; - const WebRtc_UWord8 seBit = header1 & 0x3f; - if (seBit) - { - // We got SBIT or EBIT - sbit = (seBit >> 3) & 0x07; - ebit = seBit & 0x07; - } - - const bool isH263PictureStartCode = H263PictureStartCode(_dataPtr + h263HeaderLength); - if (isH263PictureStartCode) - { - // parse out real size and inform the decoder - WebRtc_UWord16 width = 0; - WebRtc_UWord16 height = 0; - - GetH263FrameSize(_dataPtr + h263HeaderLength, width, height); - - parsedPacket.info.H263.hasPictureStartCode = true; - parsedPacket.info.H263.frameWidth = width; - parsedPacket.info.H263.frameHeight = height; - } - parsedPacket.info.H263.startBits = sbit; - parsedPacket.info.H263.endBits = ebit; - parsedPacket.info.H263.data = _dataPtr + h263HeaderLength; - parsedPacket.info.H263.dataLength = _dataLength - h263HeaderLength; - parsedPacket.info.H263.insert2byteStartCode = false; // not used in this mode - parsedPacket.info.H263.hasPbit = true; // not used in this mode - return true; -} - -bool -ModuleRTPUtility::RTPPayloadParser::ParseH2631998( RTPPayload& parsedPacket) const -{ - unsigned int h2631998HeaderLength = 2; - if(_dataLength <= h2631998HeaderLength) - { - // Received empty H263 (1998) packet - return false; - } - - const WebRtc_UWord8 header1 = _dataPtr[0]; - const WebRtc_UWord8 header2 = _dataPtr[1]; - - parsedPacket.frameType = kPFrame; - - WebRtc_UWord8 p = (header1 >> 2) & 0x01; // picture start or a picture segment - WebRtc_UWord8 vrc = header1 & 0x02; // Video Redundancy Coding (VRC) - WebRtc_UWord8 pLen = ((header1 & 0x01) << 5) + ((header2 >> 3) & 0x1f); // Length, in bytes, of the extra picture header - //WebRtc_UWord8 peBit = (header2 & 0x07); // number of bits that shall be ignored in the last byte of the extra picture header - - if (vrc) - { - return false; - } - if (pLen > 0) - { - h2631998HeaderLength += pLen; - //get extra header - - // IMPROVEMENT we don't use the redundant picture header - } - - if (_dataLength <= h2631998HeaderLength) - { - // Received empty H263 (1998) packet - return false; - } - // if p == 0 - // it's a follow-on packet, hence it's not independently decodable - - const bool isH263PictureStartCode = H263PictureStartCode(_dataPtr + h2631998HeaderLength, (p>0)?true:false); - if (isH263PictureStartCode) - { - // parse out real size and inform the decoder - WebRtc_UWord16 width = 0; - WebRtc_UWord16 height = 0; - - if(p) - { - parsedPacket.frameType = GetH263FrameType(_dataPtr + h2631998HeaderLength - 2); - GetH263FrameSize(_dataPtr + h2631998HeaderLength - 2, width, height); - } - - parsedPacket.info.H263.hasPictureStartCode = true; - parsedPacket.info.H263.frameWidth = width; - parsedPacket.info.H263.frameHeight = height; - - } - parsedPacket.info.H263.hasPbit = (p>0)?true:false; - parsedPacket.info.H263.insert2byteStartCode = (p>0)?true:false; - parsedPacket.info.H263.data = _dataPtr + h2631998HeaderLength; - parsedPacket.info.H263.dataLength = _dataLength - h2631998HeaderLength; - return true; -} - -bool -ModuleRTPUtility::RTPPayloadParser::ParseMPEG4( - RTPPayload& parsedPacket) const -{ - if (_dataLength <= 5) - { - // Received empty MPEG4 packet - return false; - } - - parsedPacket.frameType = kPFrame; - - if (_dataPtr[0] == 0 && _dataPtr[1] == 0 && _dataPtr[2] == 1) - { - parsedPacket.info.MPEG4.isFirstPacket = true; - if (!(_dataPtr[4] & 0x40)) - { - parsedPacket.frameType = kIFrame; - } - } - - parsedPacket.info.MPEG4.data = _dataPtr; - parsedPacket.info.MPEG4.dataLength = _dataLength; - - return true; -} - - // // VP8 format: // @@ -1183,144 +985,4 @@ int ModuleRTPUtility::RTPPayloadParser::ParseVP8TIDAndKeyIdx( (*dataLength)--; return 0; } - -bool -ModuleRTPUtility::RTPPayloadParser::H263PictureStartCode(const WebRtc_UWord8* data, const bool skipFirst2bytes) const -{ - // data is at least 3 bytes! - - if(skipFirst2bytes) - { - const WebRtc_UWord8 h3 = *(data); - if((h3 & 0x7C) == 0 && (h3 & 0x80)) - { - return true; - } - }else - { - // first part of the frame - const WebRtc_UWord8 h1 = *(data); - const WebRtc_UWord8 h2 = *(data+1); - const WebRtc_UWord8 h3 = *(data+2); - if(h1 == 0 && h2 == 0 && (h3 & 0x7C) == 0 && (h3 & 0x80)) - { - return true; - } - } - - return false; -} - -void -ModuleRTPUtility::RTPPayloadParser::GetH263FrameSize(const WebRtc_UWord8* inputVideoBuffer, - WebRtc_UWord16& width, - WebRtc_UWord16& height) const -{ - WebRtc_UWord8 uiH263PTypeFmt = (inputVideoBuffer[4] >> 2) & 0x07; - if (uiH263PTypeFmt == 7) //extended PTYPE (for QQVGA, QVGA, VGA) - { - const WebRtc_UWord8 uiH263PlusPTypeUFEP = ((inputVideoBuffer[4] & 0x03) << 1) + ((inputVideoBuffer[5] >> 7) & 0x01); - if (uiH263PlusPTypeUFEP == 1) //optional part included - { - WebRtc_UWord8 uiH263PlusPTypeFmt = (inputVideoBuffer[5] >> 4) & 0x07; - if(uiH263PlusPTypeFmt == 6) //custom picture format - { - const WebRtc_UWord16 uiH263PlusPTypeCPFmt_PWI = ((inputVideoBuffer[9] & 0x7F) << 2) + ((inputVideoBuffer[10] >> 6) & 0x03); - const WebRtc_UWord16 uiH263PlusPTypeCPFmt_PHI = ((inputVideoBuffer[10] & 0x1F) << 4) + ((inputVideoBuffer[11] >> 4) & 0x0F); - width = (uiH263PlusPTypeCPFmt_PWI + 1)*4; - width = uiH263PlusPTypeCPFmt_PHI*4; - } - else - { - switch (uiH263PlusPTypeFmt) - { - case 1: // SQCIF - width = 128; - height = 96; - break; - case 2: // QCIF - width = 176; - height = 144; - break; - case 3: // CIF - width = 352; - height = 288; - break; - case 4: // 4CIF - width = 704; - height = 576; - break; - case 5: // 16CIF - width = 1408; - height = 1152; - break; - default: - assert(false); - break; - } - } - } - } - else - { - switch (uiH263PTypeFmt) - { - case 1: // SQCIF - width = 128; - height = 96; - break; - case 2: // QCIF - width = 176; - height = 144; - break; - case 3: // CIF - width = 352; - height = 288; - break; - case 4: // 4CIF - width = 704; - height = 576; - break; - case 5: // 16CIF - width = 1408; - height = 1152; - break; - default: - assert(false); - break; - } - } -} - -ModuleRTPUtility::FrameTypes -ModuleRTPUtility::RTPPayloadParser::GetH263FrameType( - const WebRtc_UWord8* inputVideoBuffer) const -{ - FrameTypes frameType = kPFrame; - const WebRtc_UWord8 uiH263PTypeFmt = (inputVideoBuffer[4] >> 2) & 0x07; - WebRtc_UWord8 pType = 1; - if (uiH263PTypeFmt != 7) - { - pType = (inputVideoBuffer[4] >> 1) & 0x01; - } - else - { - const WebRtc_UWord8 uiH263PlusPTypeUFEP = ((inputVideoBuffer[4] & 0x03) << 1) + ((inputVideoBuffer[5] >> 7) & 0x01); - if (uiH263PlusPTypeUFEP == 1) - { - pType = ((inputVideoBuffer[7] >> 2) & 0x07); - } - else if (uiH263PlusPTypeUFEP == 0) - { - pType = ((inputVideoBuffer[5] >> 4) & 0x07); - } - } - - if (pType == 0) - { - frameType = kIFrame; - } - - return frameType; -} } // namespace webrtc diff --git a/src/modules/rtp_rtcp/source/rtp_utility.h b/src/modules/rtp_rtcp/source/rtp_utility.h index 39ce9ae3f2..a0eee1d899 100644 --- a/src/modules/rtp_rtcp/source/rtp_utility.h +++ b/src/modules/rtp_rtcp/source/rtp_utility.h @@ -22,9 +22,6 @@ namespace webrtc { enum RtpVideoCodecTypes { kRtpNoVideo = 0, - kRtpH263Video = 1, - kRtpH2631998Video = 2, - kRtpMpeg4Video = 5, kRtpFecVideo = 10, kRtpVp8Video = 11 }; @@ -153,29 +150,6 @@ namespace ModuleRTPUtility kPFrame // Delta frame }; - struct RTPPayloadH263 - { - // H.263 and H.263+ - bool hasPictureStartCode; - bool insert2byteStartCode; - bool hasPbit; - WebRtc_UWord16 frameWidth; - WebRtc_UWord16 frameHeight; - - WebRtc_UWord8 endBits; // ignore last end bits - WebRtc_UWord8 startBits; // ignore first bits - - const WebRtc_UWord8* data; - WebRtc_UWord16 dataLength; - }; - - struct RTPPayloadMPEG4 - { - // MPEG4 - bool isFirstPacket; - const WebRtc_UWord8* data; - WebRtc_UWord16 dataLength; - }; struct RTPPayloadVP8 { bool nonReferenceFrame; @@ -199,8 +173,6 @@ namespace ModuleRTPUtility union RTPPayloadUnion { - RTPPayloadH263 H263; - RTPPayloadMPEG4 MPEG4; RTPPayloadVP8 VP8; }; @@ -229,11 +201,6 @@ namespace ModuleRTPUtility private: bool ParseGeneric(RTPPayload& parsedPacket) const; - bool ParseH263(RTPPayload& parsedPacket) const; - bool ParseH2631998(RTPPayload& parsedPacket) const; - - bool ParseMPEG4(RTPPayload& parsedPacket) const; - bool ParseVP8(RTPPayload& parsedPacket) const; int ParseVP8Extension(RTPPayloadVP8 *vp8, @@ -259,16 +226,6 @@ namespace ModuleRTPUtility const WebRtc_UWord8 *dataPtr, int dataLength) const; - // H.263 - bool H263PictureStartCode(const WebRtc_UWord8* data, - const bool skipFirst2bytes = false) const; - - void GetH263FrameSize(const WebRtc_UWord8* inputVideoBuffer, - WebRtc_UWord16& width, - WebRtc_UWord16& height) const; - - FrameTypes GetH263FrameType(const WebRtc_UWord8* inputVideoBuffer) const; - private: WebRtc_Word32 _id; const WebRtc_UWord8* _dataPtr; diff --git a/src/modules/utility/source/file_player_impl.cc b/src/modules/utility/source/file_player_impl.cc index f5eb9b8577..fb673cb959 100644 --- a/src/modules/utility/source/file_player_impl.cc +++ b/src/modules/utility/source/file_player_impl.cc @@ -696,18 +696,6 @@ WebRtc_Word32 VideoFilePlayerImpl::SetUpVideoDecoder() return -1; } - if(strncmp(video_codec_info_.plName, "MP4V-ES", 8) == 0) - { - if(_videoDecoder.SetCodecConfigParameters( - video_codec_info_.plType, - video_codec_info_.codecSpecific.MPEG4.configParameters, - video_codec_info_.codecSpecific.MPEG4.configParametersSize) != - 0) - { - return -1; - } - } - _frameLengthMS = 1000/video_codec_info_.maxFramerate; // Size of unencoded data (I420) should be the largest possible frame size diff --git a/src/modules/utility/source/video_coder.cc b/src/modules/utility/source/video_coder.cc index 6edcebb4c0..470e6b2f08 100644 --- a/src/modules/utility/source/video_coder.cc +++ b/src/modules/utility/source/video_coder.cc @@ -76,20 +76,6 @@ WebRtc_Word32 VideoCoder::SetDecodeCodec(VideoCodec& videoCodecInst, return 0; } - -WebRtc_Word32 VideoCoder::CodecConfigParameters(WebRtc_UWord8* buffer, - WebRtc_Word32 size) -{ - return _vcm->CodecConfigParameters(buffer, size); -} - -WebRtc_Word32 VideoCoder::SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length) -{ - return _vcm->SetCodecConfigParameters(payloadType, buffer, length); -} - WebRtc_Word32 VideoCoder::Decode(VideoFrame& decodedVideo, const EncodedVideoData& encodedData) { diff --git a/src/modules/utility/source/video_coder.h b/src/modules/utility/source/video_coder.h index 2b061b3dc6..049793b711 100644 --- a/src/modules/utility/source/video_coder.h +++ b/src/modules/utility/source/video_coder.h @@ -35,13 +35,6 @@ public: WebRtc_Word32 SetDecodeCodec(VideoCodec& videoCodecInst, WebRtc_Word32 numberOfCores); - WebRtc_Word32 CodecConfigParameters(WebRtc_UWord8* buffer, - WebRtc_Word32 size); - - WebRtc_Word32 SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length); - WebRtc_Word32 Decode(VideoFrame& decodedVideo, const EncodedVideoData& encodedData); diff --git a/src/modules/video_coding/codecs/test/videoprocessor.cc b/src/modules/video_coding/codecs/test/videoprocessor.cc index cf0869b2b3..8b1351300e 100644 --- a/src/modules/video_coding/codecs/test/videoprocessor.cc +++ b/src/modules/video_coding/codecs/test/videoprocessor.cc @@ -251,14 +251,8 @@ const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) { const char* VideoCodecTypeToStr(webrtc::VideoCodecType e) { switch (e) { - case kVideoCodecH263: - return "H263"; - case kVideoCodecH264: - return "H264"; case kVideoCodecVP8: return "VP8"; - case kVideoCodecMPEG4: - return "MPEG4"; case kVideoCodecI420: return "I420"; case kVideoCodecRED: diff --git a/src/modules/video_coding/main/interface/video_coding.h b/src/modules/video_coding/main/interface/video_coding.h index 5840b0e457..87d04fb9ed 100644 --- a/src/modules/video_coding/main/interface/video_coding.h +++ b/src/modules/video_coding/main/interface/video_coding.h @@ -463,21 +463,6 @@ public: WebRtc_UWord32 payloadLength, const WebRtcRTPHeader& rtpInfo) = 0; - // Sets codec config parameters received out-of-band to the currently - // selected receive codec. - // - // Input: - // - payloadType : Payload type which specifies which codec to set these - // parameters to. - // - buffer : Codec config parameters. - // - length : Length of the parameter data. - // - // Return value : VCM_OK, on success. - // < 0, on error. - virtual WebRtc_Word32 SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length) = 0; - // Minimum playout delay (Used for lip-sync). This is the minimum delay required // to sync with audio. Not included in VideoCodingModule::Delay() // Defaults to 0 ms. diff --git a/src/modules/video_coding/main/interface/video_coding_defines.h b/src/modules/video_coding/main/interface/video_coding_defines.h index deddb9dc65..592835fd19 100644 --- a/src/modules/video_coding/main/interface/video_coding_defines.h +++ b/src/modules/video_coding/main/interface/video_coding_defines.h @@ -36,10 +36,8 @@ namespace webrtc #define VCM_ERROR_REQUEST_SLI -12 #define VCM_NOT_IMPLEMENTED -20 -#define VCM_H263_PAYLOAD_TYPE 34 #define VCM_RED_PAYLOAD_TYPE 96 #define VCM_ULPFEC_PAYLOAD_TYPE 97 -#define VCM_H263_1998_PAYLOAD_TYPE 121 #define VCM_VP8_PAYLOAD_TYPE 120 #define VCM_I420_PAYLOAD_TYPE 124 @@ -48,12 +46,6 @@ enum VCMNackProperties kNackHistoryLength = 450 }; -enum VCMH263FrameDrop -{ - kDecodePFrames, - kDropPFrames -}; - enum VCMVideoProtection { kProtectionNack, // Both send-side and receive-side diff --git a/src/modules/video_coding/main/source/codec_database.cc b/src/modules/video_coding/main/source/codec_database.cc index 0635b42bf3..53595ccd9b 100644 --- a/src/modules/video_coding/main/source/codec_database.cc +++ b/src/modules/video_coding/main/source/codec_database.cc @@ -274,11 +274,6 @@ VCMCodecDataBase::RegisterSendCodec(const VideoCodec* sendCodec, { return VCM_PARAMETER_ERROR; } - if (strcmp(sendCodec->plName, "H263") == 0 && - (sendCodec->plType != 34)) - { - return VCM_PARAMETER_ERROR; - } if (sendCodec->plType <= 0) { return VCM_PARAMETER_ERROR; @@ -656,9 +651,6 @@ VCMCodecDataBase::CreateAndInitDecoder(WebRtc_UWord8 payloadType, ReleaseDecoder(ptrDecoder); return NULL; } - - SetCodecConfigParameters(*ptrDecoder, *decoderItem->_settings); - memcpy(&newCodec, decoderItem->_settings, sizeof(VideoCodec)); return ptrDecoder; } @@ -721,36 +713,6 @@ VCMCodecDataBase::ReleaseDecoder(VCMGenericDecoder* decoder) const } } -WebRtc_Word32 -VCMCodecDataBase::SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length) -{ - VCMDecoderMapItem* decItem = FindDecoderItem(payloadType); - if (decItem == NULL) - { - return VCM_PARAMETER_ERROR; - } - switch (decItem->_settings->codecType) - { - case kVideoCodecMPEG4: - { - memcpy(decItem->_settings->codecSpecific.MPEG4.configParameters, buffer, length); - decItem->_settings->codecSpecific.MPEG4.configParametersSize = - static_cast(length); - break; - } - default: - // This codec doesn't have codec config parameters - return VCM_GENERAL_ERROR; - } - if (_ptrDecoder != NULL && _receiveCodec.plType == decItem->_settings->plType) - { - return _ptrDecoder->SetCodecConfigParameters(buffer, length); - } - return VCM_OK; -} - VCMDecoderMapItem* VCMCodecDataBase::FindDecoderItem(WebRtc_UWord8 payloadType) const { @@ -790,28 +752,4 @@ VCMCodecDataBase::CreateDecoder(VideoCodecType type) const return NULL; } } - -void -VCMCodecDataBase::SetCodecConfigParameters(VCMGenericDecoder& decoder, - const VideoCodec& settings) -{ - switch (settings.codecType) - { - case kVideoCodecMPEG4: - { - if (settings.codecSpecific.MPEG4.configParametersSize > 0) - { - decoder.SetCodecConfigParameters( - settings.codecSpecific.MPEG4.configParameters, - settings.codecSpecific.MPEG4.configParametersSize); - } - break; - } - default: - // No codec config parameters for this codec - return; - } - return; -} - } diff --git a/src/modules/video_coding/main/source/codec_database.h b/src/modules/video_coding/main/source/codec_database.h index 87123a2b93..d5aab554c0 100644 --- a/src/modules/video_coding/main/source/codec_database.h +++ b/src/modules/video_coding/main/source/codec_database.h @@ -174,10 +174,6 @@ public: bool RenderTiming() const; - WebRtc_Word32 SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length); - protected: /** * Create an internal Encoder given a codec type @@ -190,9 +186,6 @@ protected: */ VCMGenericDecoder* CreateDecoder(VideoCodecType type) const; - static void SetCodecConfigParameters(VCMGenericDecoder& decoder, - const VideoCodec& settings); - VCMDecoderMapItem* FindDecoderItem(WebRtc_UWord8 payloadType) const; VCMExtDecoderMapItem* FindExternalDecoderItem(WebRtc_UWord8 payloadType) const; diff --git a/src/modules/video_coding/main/source/frame_buffer.cc b/src/modules/video_coding/main/source/frame_buffer.cc index dfded86643..b96187d166 100644 --- a/src/modules/video_coding/main/source/frame_buffer.cc +++ b/src/modules/video_coding/main/source/frame_buffer.cc @@ -414,12 +414,6 @@ VCMFrameBuffer::PrepareForDecode() _sessionInfo.BuildVP8FragmentationHeader(_buffer, _length, &_fragmentation); } - else - { - _length = _sessionInfo.PrepareForDecode(_buffer); - } -#else - _length = _sessionInfo.PrepareForDecode(_buffer); #endif } diff --git a/src/modules/video_coding/main/source/packet.cc b/src/modules/video_coding/main/source/packet.cc index 7c21c50310..e52cbdd8bf 100644 --- a/src/modules/video_coding/main/source/packet.cc +++ b/src/modules/video_coding/main/source/packet.cc @@ -28,7 +28,6 @@ VCMPacket::VCMPacket() isFirstPacket(false), completeNALU(kNaluUnset), insertStartCode(false), - bits(false), codecSpecificHeader() { } @@ -47,7 +46,6 @@ VCMPacket::VCMPacket(const WebRtc_UWord8* ptr, isFirstPacket(rtpHeader.type.Video.isFirstPacket), completeNALU(kNaluComplete), insertStartCode(false), - bits(false), codecSpecificHeader(rtpHeader.type.Video) { CopyCodecSpecifics(rtpHeader.type.Video); @@ -66,7 +64,6 @@ VCMPacket::VCMPacket(const WebRtc_UWord8* ptr, WebRtc_UWord32 size, WebRtc_UWord isFirstPacket(false), completeNALU(kNaluComplete), insertStartCode(false), - bits(false), codecSpecificHeader() {} @@ -82,7 +79,6 @@ void VCMPacket::Reset() { isFirstPacket = false; completeNALU = kNaluUnset; insertStartCode = false; - bits = false; memset(&codecSpecificHeader, 0, sizeof(RTPVideoHeader)); } diff --git a/src/modules/video_coding/main/source/packet.h b/src/modules/video_coding/main/source/packet.h index c27c055ac5..2035653e90 100644 --- a/src/modules/video_coding/main/source/packet.h +++ b/src/modules/video_coding/main/source/packet.h @@ -23,13 +23,13 @@ class VCMPacket public: VCMPacket(); VCMPacket(const WebRtc_UWord8* ptr, - const WebRtc_UWord32 size, - const WebRtcRTPHeader& rtpHeader); + const WebRtc_UWord32 size, + const WebRtcRTPHeader& rtpHeader); VCMPacket(const WebRtc_UWord8* ptr, - WebRtc_UWord32 size, - WebRtc_UWord16 seqNum, - WebRtc_UWord32 timestamp, - bool markerBit); + WebRtc_UWord32 size, + WebRtc_UWord16 seqNum, + WebRtc_UWord32 timestamp, + bool markerBit); void Reset(); @@ -47,10 +47,6 @@ public: VCMNaluCompleteness completeNALU; // Default is kNaluIncomplete. bool insertStartCode; // True if a start code should be inserted before this // packet. - bool bits; // The first bits of this packets are zero and the - // first - // byte should be ORed with the last packet of the - // previous frame. RTPVideoHeader codecSpecificHeader; protected: @@ -58,5 +54,4 @@ protected: }; } // namespace webrtc - #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_H_ diff --git a/src/modules/video_coding/main/source/session_info.cc b/src/modules/video_coding/main/source/session_info.cc index 4a5d16948f..9a6cd94eee 100644 --- a/src/modules/video_coding/main/source/session_info.cc +++ b/src/modules/video_coding/main/source/session_info.cc @@ -108,8 +108,7 @@ int VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer, PacketIterator it; int packet_size = packet.sizeBytes; - if (!packet.bits) - packet_size += (packet.insertStartCode ? kH264StartCodeLengthBytes : 0); + packet_size += (packet.insertStartCode ? kH264StartCodeLengthBytes : 0); // Calculate the offset into the frame buffer for this packet. int offset = 0; @@ -529,7 +528,6 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet, uint8_t* frame_buffer, bool enable_decodable_state, int rtt_ms) { - assert(!packet.insertStartCode || !packet.bits); // Check if this is first packet (only valid for some codecs) if (packet.isFirstPacket) { // The first packet in a frame signals the frame type. @@ -584,72 +582,6 @@ void VCMSessionInfo::InformOfEmptyPacket(uint16_t seq_num) { empty_seq_num_low_ = seq_num; } -int VCMSessionInfo::PrepareForDecode(uint8_t* frame_buffer) { - int length = SessionLength(); - int real_data_bytes = 0; - if (length == 0) - return length; - PacketIterator it = packets_.begin(); - PacketIterator prev_it = it; - for (; it != packets_.end(); ++it) { - bool packet_loss = ((*prev_it).sizeBytes == 0 || - !InSequence(it, prev_it)); - if ((*it).bits) { - if (prev_it != it) { // Not the first packet. - uint8_t* ptr_first_byte = - const_cast((*it).dataPtr); - - if (packet_loss) { - // It is be better to throw away this packet if we are - // missing the previous packet. - memset(ptr_first_byte, 0, (*it).sizeBytes); - ++packets_not_decodable_; - } else if ((*it).sizeBytes > 0) { - // Glue with previous byte. - // Move everything from [this packet start + 1, end of buffer] one - // byte to the left. - uint8_t* ptr_prev_byte = - const_cast((*prev_it).dataPtr) + - (*prev_it).sizeBytes - 1; - *ptr_prev_byte = (*ptr_prev_byte) | (*ptr_first_byte); - memmove(const_cast((*it).dataPtr), - (*it).dataPtr + 1, (*it).sizeBytes - 1); - ShiftSubsequentPackets(it, -1); - (*it).sizeBytes--; - length--; - real_data_bytes += (*it).sizeBytes; - } - } else { - memset(const_cast((*it).dataPtr), 0, - (*it).sizeBytes); - ++packets_not_decodable_; - } - } else if (packet_loss && - (*it).codecSpecificHeader.codec == kRTPVideoH263) { - // Pad H.263 packet losses with 10 zeros to make it easier - // for the decoder. - const int kPaddingLength = 10; - WebRtc_UWord8 padding_data[kPaddingLength] = {0}; - // Make a copy of the previous packet. - VCMPacket padding_packet(*it); - ++padding_packet.seqNum; - padding_packet.dataPtr = padding_data; - padding_packet.sizeBytes = kPaddingLength; - length += InsertPacket(padding_packet, frame_buffer, false, 0); - } else { - real_data_bytes += (*it).sizeBytes; - } - prev_it = it; - } - if (real_data_bytes == 0) { - // Drop the frame since all it contains are zeros. - for (it = packets_.begin(); it != packets_.end(); ++it) - (*it).sizeBytes = 0; - length = 0; - } - return length; -} - int VCMSessionInfo::packets_not_decodable() const { return packets_not_decodable_; } diff --git a/src/modules/video_coding/main/source/session_info.h b/src/modules/video_coding/main/source/session_info.h index fd4ae88fa2..27533cee0a 100644 --- a/src/modules/video_coding/main/source/session_info.h +++ b/src/modules/video_coding/main/source/session_info.h @@ -69,7 +69,6 @@ class VCMSessionInfo { bool LayerSync() const; int Tl0PicId() const; bool NonReference() const; - int PrepareForDecode(uint8_t* frame_buffer); void SetPreviousFrameLoss() { previous_frame_loss_ = true; } bool PreviousFrameLoss() const { return previous_frame_loss_; } diff --git a/src/modules/video_coding/main/source/session_info_unittest.cc b/src/modules/video_coding/main/source/session_info_unittest.cc index b72d61c98a..285cf9ce2d 100644 --- a/src/modules/video_coding/main/source/session_info_unittest.cc +++ b/src/modules/video_coding/main/source/session_info_unittest.cc @@ -32,7 +32,6 @@ class TestSessionInfo : public ::testing::Test { packet_.dataPtr = packet_buffer_; packet_.seqNum = 0; packet_.timestamp = 0; - packet_.bits = false; } void FillPacket(uint8_t start_value) { @@ -89,7 +88,7 @@ class TestNalUnits : public TestSessionInfo { protected: virtual void SetUp() { TestSessionInfo::SetUp(); - packet_.codec = kVideoCodecH264; + packet_.codec = kVideoCodecVP8; } bool VerifyNalu(int offset, int packets_expected, int start_value) { @@ -915,72 +914,4 @@ TEST_F(TestNackList, LostAllButEmptyPackets) { EXPECT_EQ(-2, seq_num_list_[3]); EXPECT_EQ(4, seq_num_list_[4]); } - -TEST_F(TestSessionInfo, PacketPriorBitsPacketLost) { - packet_.seqNum = 0; - packet_.codecSpecificHeader.codec = kRTPVideoH263; - packet_.bits = true; - packet_.isFirstPacket = false; - packet_.markerBit = true; - FillPacket(1); - ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), - kPacketBufferSize); - - EXPECT_EQ(0, session_.PrepareForDecode(frame_buffer_)); - EXPECT_EQ(0, session_.SessionLength()); - EXPECT_EQ(1, session_.packets_not_decodable()); -} - -TEST_F(TestSessionInfo, MiddlePacketPriorBitsPacketLost) { - packet_.codecSpecificHeader.codec = kRTPVideoH263; - packet_.bits = false; - packet_.isFirstPacket = true; - packet_.seqNum = 0; - packet_.markerBit = false; - FillPacket(2); - ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), - kPacketBufferSize); - - packet_.bits = true; - packet_.isFirstPacket = false; - packet_.seqNum += 2; - packet_.markerBit = true; - FillPacket(2); - ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), - kPacketBufferSize); - - EXPECT_EQ(2 * kPacketBufferSize, session_.PrepareForDecode(frame_buffer_)); - EXPECT_EQ(2 * kPacketBufferSize, session_.SessionLength()); - EXPECT_EQ(1, session_.packets_not_decodable()); -} - -TEST_F(TestSessionInfo, ORingReorderedBitsPackets) { - const uint8_t kEndByte = 0x07; - const uint8_t kStartByte = 0xF8; - packet_.codecSpecificHeader.codec = kRTPVideoH263; - packet_.bits = true; - packet_.isFirstPacket = false; - packet_.seqNum = 1; - packet_.markerBit = true; - FillPacket(2); - packet_buffer_[0] = kStartByte; - ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), - kPacketBufferSize); - - packet_.bits = false; - packet_.isFirstPacket = true; - packet_.seqNum = 0; - packet_.markerBit = false; - FillPacket(1); - packet_buffer_[kPacketBufferSize - 1] = kEndByte; - ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), - kPacketBufferSize); - - EXPECT_EQ(2 * kPacketBufferSize - 1, - session_.PrepareForDecode(frame_buffer_)); - EXPECT_EQ(2 * kPacketBufferSize - 1, session_.SessionLength()); - EXPECT_EQ(kStartByte | kEndByte, frame_buffer_[kPacketBufferSize - 1]); - EXPECT_EQ(0, session_.packets_not_decodable()); -} - } // namespace webrtc diff --git a/src/modules/video_coding/main/source/video_coding_impl.cc b/src/modules/video_coding/main/source/video_coding_impl.cc index bf5c2e6100..31addc8246 100644 --- a/src/modules/video_coding/main/source/video_coding_impl.cc +++ b/src/modules/video_coding/main/source/video_coding_impl.cc @@ -1405,32 +1405,6 @@ VideoCodingModuleImpl::IncomingPacket(const WebRtc_UWord8* incomingPayload, return VCM_OK; } -// Set codec config parameters -WebRtc_Word32 -VideoCodingModuleImpl::SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length) -{ - WEBRTC_TRACE(webrtc::kTraceModuleCall, - webrtc::kTraceVideoCoding, - VCMId(_id), - "SetCodecConfigParameters()"); - CriticalSectionScoped cs(_receiveCritSect); - - WebRtc_Word32 ret = _codecDataBase.SetCodecConfigParameters(payloadType, - buffer, - length); - if (ret < 0) - { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceVideoCoding, - VCMId(_id), - "SetCodecConfigParameters() failed, %d", ret); - return ret; - } - return VCM_OK; -} - // Minimum playout delay (used for lip-sync). This is the minimum delay required // to sync with audio. Not included in VideoCodingModule::Delay() // Defaults to 0 ms. diff --git a/src/modules/video_coding/main/source/video_coding_impl.h b/src/modules/video_coding/main/source/video_coding_impl.h index 8276179bfd..4e21fa0e8b 100644 --- a/src/modules/video_coding/main/source/video_coding_impl.h +++ b/src/modules/video_coding/main/source/video_coding_impl.h @@ -228,11 +228,6 @@ public: virtual WebRtc_Word32 DecodeFromStorage( const EncodedVideoData& frameFromStorage); - // Set codec config parameters - virtual WebRtc_Word32 SetCodecConfigParameters(WebRtc_UWord8 payloadType, - const WebRtc_UWord8* buffer, - WebRtc_Word32 length); - // Minimum playout delay (Used for lip-sync). This is the minimum delay // required to sync with audio. Not included in VideoCodingModule::Delay() // Defaults to 0 ms. diff --git a/src/modules/video_coding/main/test/jitter_buffer_test.cc b/src/modules/video_coding/main/test/jitter_buffer_test.cc index e75e9cea92..75e6aec7cf 100644 --- a/src/modules/video_coding/main/test/jitter_buffer_test.cc +++ b/src/modules/video_coding/main/test/jitter_buffer_test.cc @@ -627,73 +627,9 @@ int JitterBufferTest(CmdArgs& args) seqNum += 2; //printf("DONE frame re-ordering 2 frames 2 packets\n"); - // - // TEST H.263 bits - // - // ----------------- - // | 1541 | 1542 | - // ----------------- - // sBits - - seqNum++; - timeStamp += 2*33*90; - packet.frameType = kVideoFrameDelta; - packet.isFirstPacket = true; - packet.markerBit = false; - packet.seqNum = seqNum; - packet.timestamp = timeStamp; - packet.bits = false; - packet.codec = kVideoCodecH263; - - frameIn = jb.GetFrame(packet); - TEST(frameIn != 0); - - // Insert a packet into a frame - TEST(kFirstPacket == jb.InsertPacket(frameIn, packet)); - - // get packet notification - TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs)); - - // check incoming frame type - TEST(incomingFrameType == kVideoFrameDelta); - - // get the frame - frameOut = jb.GetCompleteFrameForDecoding(10); - - // it should not be complete - TEST(frameOut == 0); - - seqNum++; - packet.isFirstPacket = false; - packet.markerBit = true; - packet.seqNum = seqNum; - packet.bits = true; - packet.dataPtr = &(data[9]); - - frameIn = jb.GetFrame(packet); - TEST(frameIn != 0); - - // Insert a packet into a frame - TEST(kCompleteSession == jb.InsertPacket(frameIn, packet)); - - TEST(timeStamp == jb.GetNextTimeStamp(10, incomingFrameType, renderTimeMs)); - - // get the frame - frameOut = jb.GetCompleteFrameForDecoding(10); - - TEST(CheckOutFrame(frameOut, (size*2)-1, false) == 0); - - // check the frame type - TEST(frameOut->FrameType() == kVideoFrameDelta); - - // Release frame (when done with decoding) - jb.ReleaseFrame(frameOut); - // restore packet.dataPtr = data; - packet.bits = false; packet.codec = kVideoCodecUnknown; - //printf("DONE H.263 frame 2 packets with bits\n"); // // TEST duplicate packets @@ -703,8 +639,8 @@ int JitterBufferTest(CmdArgs& args) // ----------------- // - seqNum++; - timeStamp += 33*90; + seqNum++; + timeStamp += 2*33*90; packet.frameType = kVideoFrameDelta; packet.isFirstPacket = true; packet.markerBit = false; @@ -824,7 +760,7 @@ int JitterBufferTest(CmdArgs& args) WebRtc_UWord32 numKeyFrames = 0; TEST(jb.GetFrameStatistics(numDeltaFrames, numKeyFrames) == 0); - TEST(numDeltaFrames == 9); + TEST(numDeltaFrames == 8); TEST(numKeyFrames == 1); WebRtc_UWord32 frameRate; @@ -1983,86 +1919,11 @@ int JitterBufferTest(CmdArgs& args) jb.Flush(); - // Three reordered H263 packets with bits. - - packet.codec = kVideoCodecH263; - packet.frameType = kVideoFrameDelta; - packet.isFirstPacket = false; - packet.markerBit = false; - packet.bits = true; - packet.seqNum += 1; - WebRtc_UWord8 oldData1 = data[0]; - WebRtc_UWord8 oldData2 = data[packet.sizeBytes - 1]; - unsigned char startByte = 0x07; - unsigned char endByte = 0xF8; - data[0] = startByte; - TEST(frameIn = jb.GetFrame(packet)); - TEST(kFirstPacket == jb.InsertPacket(frameIn, packet)); - frameOut = jb.GetFrameForDecoding(); - TEST(frameOut == NULL); - - packet.seqNum -= 1; - packet.isFirstPacket = true; - packet.bits = false; - data[0] = oldData1; - data[packet.sizeBytes - 1] = endByte; - TEST(frameIn = jb.GetFrame(packet)); - TEST(kIncomplete == jb.InsertPacket(frameIn, packet)); - frameOut = jb.GetFrameForDecoding(); - TEST(frameOut == NULL); - - packet.seqNum += 2; - packet.isFirstPacket = false; - packet.markerBit = true; - data[packet.sizeBytes - 1] = oldData2; - TEST(frameIn = jb.GetFrame(packet)); - TEST(kCompleteSession == jb.InsertPacket(frameIn, packet)); - - frameOut = jb.GetCompleteFrameForDecoding(0); - TEST(frameOut != NULL); - const WebRtc_UWord8* buf = frameOut->Buffer(); - TEST(buf[packet.sizeBytes - 1] == (startByte | endByte)); - jb.ReleaseFrame(frameOut); - // First packet lost, second packet with bits. - - // The JB only outputs frame if the next one arrives: - // Adding dummy timestamp value so won't interfere with the test. - packet.seqNum = 1; - packet.timestamp = timeStamp + 33 * 90 * 5; - packet.frameType = kVideoFrameDelta; - packet.isFirstPacket = false; - packet.completeNALU = kNaluStart; - packet.markerBit = false; - frameIn = jb.GetFrame(packet); - TEST(kFirstPacket == jb.InsertPacket(frameIn, packet)); - - packet.frameType = kVideoFrameDelta; - packet.isFirstPacket = false; - packet.markerBit = true; - packet.bits = true; - packet.seqNum += 2; - packet.timestamp = timeStamp + 33 * 90; - data[0] = 0x07; - data[packet.sizeBytes - 1] = 0xF8; - TEST(frameIn = jb.GetFrame(packet)); - TEST(kFirstPacket == jb.InsertPacket(frameIn, packet)); - frameOut = jb.GetFrameForDecoding(); - TEST(frameOut != NULL); - TEST(frameOut->Length() == 0); - jb.ReleaseFrame(frameOut); - - data[0] = oldData1; - data[packet.sizeBytes - 1] = oldData2; - packet.codec = kVideoCodecUnknown; - - jb.Flush(); - // Test that a we cannot get incomplete frames from the JB if we haven't // received the marker bit, unless we have received a packet from a later // timestamp. packet.seqNum += 2; - packet.bits = false; packet.frameType = kVideoFrameDelta; packet.isFirstPacket = false; packet.markerBit = false; diff --git a/src/modules/video_coding/main/test/normal_test.cc b/src/modules/video_coding/main/test/normal_test.cc index 80a14c1e66..923d64962b 100644 --- a/src/modules/video_coding/main/test/normal_test.cc +++ b/src/modules/video_coding/main/test/normal_test.cc @@ -92,13 +92,6 @@ VCMNTEncodeCompleteCallback::SendData( rtpInfo.type.Video.height = 0; switch (_test.VideoType()) { - case kVideoCodecH263: - rtpInfo.type.Video.codec = kRTPVideoH263; - rtpInfo.type.Video.codecHeader.H263.bits = false; - rtpInfo.type.Video.codecHeader.H263.independentlyDecodable = false; - rtpInfo.type.Video.height = (WebRtc_UWord16)_test.Height(); - rtpInfo.type.Video.width = (WebRtc_UWord16)_test.Width(); - break; case kVideoCodecVP8: rtpInfo.type.Video.codec = kRTPVideoVP8; rtpInfo.type.Video.codecHeader.VP8.InitRTPVideoHeaderVP8(); diff --git a/src/modules/video_coding/main/test/test_callbacks.cc b/src/modules/video_coding/main/test/test_callbacks.cc index 57e4ab0ac0..2070abe678 100644 --- a/src/modules/video_coding/main/test/test_callbacks.cc +++ b/src/modules/video_coding/main/test/test_callbacks.cc @@ -68,10 +68,6 @@ VCMEncodeCompleteCallback::SendData( rtpInfo.type.Video.width = (WebRtc_UWord16)_width; switch (_codecType) { - case webrtc::kRTPVideoH263: - rtpInfo.type.Video.codecHeader.H263.bits = false; - rtpInfo.type.Video.codecHeader.H263.independentlyDecodable = false; - break; case webrtc::kRTPVideoVP8: rtpInfo.type.Video.codecHeader.VP8.InitRTPVideoHeaderVP8(); rtpInfo.type.Video.codecHeader.VP8.nonReference = diff --git a/src/modules/video_coding/main/test/test_util.cc b/src/modules/video_coding/main/test/test_util.cc index be9f352aeb..1f8916839c 100644 --- a/src/modules/video_coding/main/test/test_util.cc +++ b/src/modules/video_coding/main/test/test_util.cc @@ -34,14 +34,6 @@ ConvertCodecType(const char* plname) { return kRTPVideoVP8; } - else if (strncmp(plname,"H263" , 5) == 0) - { - return kRTPVideoH263; - } - else if (strncmp(plname, "H263-1998",10) == 0) - { - return kRTPVideoH263; - } else if (strncmp(plname,"I420" , 5) == 0) { return kRTPVideoI420; diff --git a/src/modules/video_coding/main/test/tester_main.cc b/src/modules/video_coding/main/test/tester_main.cc index ef5c9debe3..e5d7cd37ea 100644 --- a/src/modules/video_coding/main/test/tester_main.cc +++ b/src/modules/video_coding/main/test/tester_main.cc @@ -90,10 +90,6 @@ int ParseArguments(int argc, char **argv, CmdArgs& args) { args.codecType = kVideoCodecI420; } - else if (strncmp(argv[i+1], "H263", 4) == 0) - { - args.codecType = kVideoCodecH263; - } else return -1; diff --git a/src/video_engine/include/vie_codec.h b/src/video_engine/include/vie_codec.h index 1344848f97..08d1cc56bc 100644 --- a/src/video_engine/include/vie_codec.h +++ b/src/video_engine/include/vie_codec.h @@ -162,10 +162,6 @@ class WEBRTC_DLLEXPORT ViECodec { virtual int WaitForFirstKeyFrame(const int video_channel, const bool wait) = 0; - // This function makes VideoEngine decode all incoming H.263 key frames as - // delta frames and all incoming delta frames as key frames. - virtual int SetInverseH263Logic(int video_channel, bool enable) = 0; - protected: ViECodec() {} virtual ~ViECodec() {} diff --git a/src/video_engine/test/auto_test/primitives/codec_primitives.cc b/src/video_engine/test/auto_test/primitives/codec_primitives.cc index eef2cb4d00..2d434404c6 100644 --- a/src/video_engine/test/auto_test/primitives/codec_primitives.cc +++ b/src/video_engine/test/auto_test/primitives/codec_primitives.cc @@ -136,8 +136,7 @@ void TestCodecs(const TbInterfaces& interfaces, for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecMPEG4 || - video_codec.codecType == webrtc::kVideoCodecRED || + if (video_codec.codecType == webrtc::kVideoCodecRED || video_codec.codecType == webrtc::kVideoCodecULPFEC) { ViETest::Log("\t %d. %s not tested", i, video_codec.plName); } else { diff --git a/src/video_engine/test/auto_test/primitives/general_primitives.cc b/src/video_engine/test/auto_test/primitives/general_primitives.cc index 84ce8acf9e..6198a64970 100644 --- a/src/video_engine/test/auto_test/primitives/general_primitives.cc +++ b/src/video_engine/test/auto_test/primitives/general_primitives.cc @@ -122,9 +122,6 @@ void SetSuitableResolution(webrtc::VideoCodec* video_codec, // I420 is very bandwidth heavy, so limit it here. video_codec->width = 176; video_codec->height = 144; - } else if (video_codec->codecType == webrtc::kVideoCodecH263) { - video_codec->width = 352; - video_codec->height = 288; } else { // Otherwise go with 640x480. video_codec->width = 640; diff --git a/src/video_engine/test/auto_test/source/vie_autotest.cc b/src/video_engine/test/auto_test/source/vie_autotest.cc index f71284fa2a..2eaa0e37c1 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest.cc @@ -100,9 +100,6 @@ void ViEAutoTest::PrintVideoCodec(const webrtc::VideoCodec videoCodec) switch (videoCodec.codecType) { - case webrtc::kVideoCodecH263: - ViETest::Log("\tcodecType: H263"); - break; case webrtc::kVideoCodecVP8: ViETest::Log("\tcodecType: VP8"); break; diff --git a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc index 1fbc1cdf0f..580d0a4dab 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc @@ -100,8 +100,7 @@ void ViEAutoTest::ViECodecExtendedTest() { EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec)); - if (videoCodec.codecType != webrtc::kVideoCodecH263 - && videoCodec.codecType != webrtc::kVideoCodecI420) + if (videoCodec.codecType != webrtc::kVideoCodecI420) { videoCodec.width = 640; videoCodec.height = 480; diff --git a/src/video_engine/vie_base_impl.cc b/src/video_engine/vie_base_impl.cc index 9d62a49ac6..92d4e26aa8 100644 --- a/src/video_engine/vie_base_impl.cc +++ b/src/video_engine/vie_base_impl.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include "critical_section_wrapper.h" #include "engine_configurations.h" #include "rtp_rtcp.h" -#include "stdio.h" #include "trace.h" #include "video_coding.h" #include "video_processing.h" diff --git a/src/video_engine/vie_channel.cc b/src/video_engine/vie_channel.cc index d37b828912..a2ae0961da 100644 --- a/src/video_engine/vie_channel.cc +++ b/src/video_engine/vie_channel.cc @@ -2527,8 +2527,4 @@ void ViEChannel::OnIncomingCSRCChanged(const WebRtc_Word32 id, } } -WebRtc_Word32 ViEChannel::SetInverseH263Logic(const bool enable) { - return rtp_rtcp_.SetH263InverseLogic(enable); -} - } // namespace webrtc diff --git a/src/video_engine/vie_channel.h b/src/video_engine/vie_channel.h index 6bcddeb35a..62f42a6599 100644 --- a/src/video_engine/vie_channel.h +++ b/src/video_engine/vie_channel.h @@ -334,8 +334,6 @@ class ViEChannel WebRtc_Word32 RegisterEffectFilter(ViEEffectFilter* effect_filter); - WebRtc_Word32 SetInverseH263Logic(const bool enable); - ViEFileRecorder& GetIncomingFileRecorder(); void ReleaseIncomingFileRecorder(); diff --git a/src/video_engine/vie_codec_impl.cc b/src/video_engine/vie_codec_impl.cc index bdfb4ad41b..4c8f169479 100644 --- a/src/video_engine/vie_codec_impl.cc +++ b/src/video_engine/vie_codec_impl.cc @@ -613,25 +613,6 @@ int ViECodecImpl::WaitForFirstKeyFrame(const int video_channel, return 0; } -int ViECodecImpl::SetInverseH263Logic(int video_channel, bool enable) { - WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), - "%s(video_channel: %d)", __FUNCTION__, video_channel); - - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), - "%s: No channel %d", __FUNCTION__, video_channel); - SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->SetInverseH263Logic(enable) != 0) { - SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - bool ViECodecImpl::CodecValid(const VideoCodec& video_codec) { // Check pl_name matches codec_type. if (video_codec.codecType == kVideoCodecRED) { @@ -658,16 +639,10 @@ bool ViECodecImpl::CodecValid(const VideoCodec& video_codec) { WEBRTC_TRACE(kTraceError, kTraceVideo, -1, "Codec type doesn't match pl_name", video_codec.plType); return false; - } else if ((video_codec.codecType == kVideoCodecH263 && - strncmp(video_codec.plName, "H263", 4) == 0) || - (video_codec.codecType == kVideoCodecH263 && - strncmp(video_codec.plName, "H263-1998", 9) == 0) || - (video_codec.codecType == kVideoCodecVP8 && + } else if ((video_codec.codecType == kVideoCodecVP8 && strncmp(video_codec.plName, "VP8", 4) == 0) || (video_codec.codecType == kVideoCodecI420 && - strncmp(video_codec.plName, "I420", 4) == 0) || - (video_codec.codecType == kVideoCodecH264 && - strncmp(video_codec.plName, "H264", 4) == 0)) { + strncmp(video_codec.plName, "I420", 4) == 0)) { // OK. } else { WEBRTC_TRACE(kTraceError, kTraceVideo, -1, @@ -703,17 +678,6 @@ bool ViECodecImpl::CodecValid(const VideoCodec& video_codec) { "Number of Simulcast streams can not be 1"); return false; } - if (video_codec.codecType == kVideoCodecH263) { - if ((video_codec.width == 704 && video_codec.height == 576) || - (video_codec.width == 352 && video_codec.height == 288) || - (video_codec.width == 176 && video_codec.height == 144) || - (video_codec.width == 128 && video_codec.height == 96)) { - // OK. - } else { - WEBRTC_TRACE(kTraceError, kTraceVideo, -1, "Invalid size for H.263"); - return false; - } - } return true; } diff --git a/src/video_engine/vie_codec_impl.h b/src/video_engine/vie_codec_impl.h index a2fa8b2e80..43ccf81842 100644 --- a/src/video_engine/vie_codec_impl.h +++ b/src/video_engine/vie_codec_impl.h @@ -63,7 +63,6 @@ class ViECodecImpl virtual int DeregisterDecoderObserver(const int video_channel); virtual int SendKeyFrame(const int video_channel); virtual int WaitForFirstKeyFrame(const int video_channel, const bool wait); - virtual int SetInverseH263Logic(int video_channel, bool enable); protected: ViECodecImpl();