diff --git a/webrtc/api/android/jni/androidmediaencoder_jni.cc b/webrtc/api/android/jni/androidmediaencoder_jni.cc index 9ee99f0495..ef3d4815ba 100644 --- a/webrtc/api/android/jni/androidmediaencoder_jni.cc +++ b/webrtc/api/android/jni/androidmediaencoder_jni.cc @@ -29,8 +29,8 @@ #include "webrtc/base/thread_checker.h" #include "webrtc/base/timeutils.h" #include "webrtc/common_types.h" -#include "webrtc/common_video/h264/h264_bitstream_parser.h" #include "webrtc/modules/video_coding/include/video_codec_interface.h" +#include "webrtc/modules/video_coding/utility/h264_bitstream_parser.h" #include "webrtc/modules/video_coding/utility/quality_scaler.h" #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" #include "webrtc/system_wrappers/include/field_trial.h" diff --git a/webrtc/common_video/BUILD.gn b/webrtc/common_video/BUILD.gn index 9830c8b942..5fbe1e875c 100644 --- a/webrtc/common_video/BUILD.gn +++ b/webrtc/common_video/BUILD.gn @@ -18,8 +18,6 @@ config("common_video_config") { rtc_static_library("common_video") { sources = [ "bitrate_adjuster.cc", - "h264/h264_bitstream_parser.cc", - "h264/h264_bitstream_parser.h", "h264/h264_common.cc", "h264/h264_common.h", "h264/pps_parser.cc", @@ -95,7 +93,6 @@ if (rtc_include_tests) { sources = [ "bitrate_adjuster_unittest.cc", - "h264/h264_bitstream_parser_unittest.cc", "h264/pps_parser_unittest.cc", "h264/sps_parser_unittest.cc", "h264/sps_vui_rewriter_unittest.cc", diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index cf6d8a8184..d983360d9b 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -490,6 +490,7 @@ if (rtc_include_tests) { "video_coding/test/stream_generator.h", "video_coding/timing_unittest.cc", "video_coding/utility/frame_dropper_unittest.cc", + "video_coding/utility/h264_bitstream_parser_unittest.cc", "video_coding/utility/ivf_file_writer_unittest.cc", "video_coding/utility/moving_average_unittest.cc", "video_coding/utility/quality_scaler_unittest.cc", diff --git a/webrtc/modules/video_coding/BUILD.gn b/webrtc/modules/video_coding/BUILD.gn index a21a79bbd9..4836207a9f 100644 --- a/webrtc/modules/video_coding/BUILD.gn +++ b/webrtc/modules/video_coding/BUILD.gn @@ -98,6 +98,8 @@ rtc_static_library("video_coding_utility") { sources = [ "utility/frame_dropper.cc", "utility/frame_dropper.h", + "utility/h264_bitstream_parser.cc", + "utility/h264_bitstream_parser.h", "utility/ivf_file_writer.cc", "utility/ivf_file_writer.h", "utility/moving_average.cc", diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h index 3713896a8b..c6014e6651 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h +++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h @@ -15,8 +15,8 @@ #include #include -#include "webrtc/common_video/h264/h264_bitstream_parser.h" #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" +#include "webrtc/modules/video_coding/utility/h264_bitstream_parser.h" #include "webrtc/modules/video_coding/utility/quality_scaler.h" #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h index 2def9f179e..cb7ca34e61 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h @@ -13,10 +13,10 @@ #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_ENCODER_H_ #include "webrtc/base/criticalsection.h" -#include "webrtc/common_video/h264/h264_bitstream_parser.h" #include "webrtc/common_video/include/bitrate_adjuster.h" #include "webrtc/common_video/rotation.h" #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" +#include "webrtc/modules/video_coding/utility/h264_bitstream_parser.h" #include "webrtc/modules/video_coding/utility/quality_scaler.h" #if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) diff --git a/webrtc/common_video/h264/h264_bitstream_parser.cc b/webrtc/modules/video_coding/utility/h264_bitstream_parser.cc similarity index 97% rename from webrtc/common_video/h264/h264_bitstream_parser.cc rename to webrtc/modules/video_coding/utility/h264_bitstream_parser.cc index b4f04f2efd..97cd003869 100644 --- a/webrtc/common_video/h264/h264_bitstream_parser.cc +++ b/webrtc/modules/video_coding/utility/h264_bitstream_parser.cc @@ -7,7 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/common_video/h264/h264_bitstream_parser.h" +#include "webrtc/modules/video_coding/utility/h264_bitstream_parser.h" #include #include @@ -240,11 +240,9 @@ bool H264BitstreamParser::ParseNonParameterSetNalu(const uint8_t* source, } } } - if (pps_->entropy_coding_mode_flag && - slice_type != H264::SliceType::kI && slice_type != H264::SliceType::kSi) { - // cabac_init_idc: ue(v) - RETURN_FALSE_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); - } + // cabac not supported: entropy_coding_mode_flag == 0 asserted above. + // if (entropy_coding_mode_flag && slice_type != I && slice_type != SI) + // cabac_init_idc int32_t last_slice_qp_delta; RETURN_FALSE_ON_FAIL( slice_reader.ReadSignedExponentialGolomb(&last_slice_qp_delta)); diff --git a/webrtc/common_video/h264/h264_bitstream_parser.h b/webrtc/modules/video_coding/utility/h264_bitstream_parser.h similarity index 89% rename from webrtc/common_video/h264/h264_bitstream_parser.h rename to webrtc/modules/video_coding/utility/h264_bitstream_parser.h index 0b84e40234..6a779e156b 100644 --- a/webrtc/common_video/h264/h264_bitstream_parser.h +++ b/webrtc/modules/video_coding/utility/h264_bitstream_parser.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_COMMON_VIDEO_H264_H264_BITSTREAM_PARSER_H_ -#define WEBRTC_COMMON_VIDEO_H264_H264_BITSTREAM_PARSER_H_ +#ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_H264_BITSTREAM_PARSER_H_ +#define WEBRTC_MODULES_VIDEO_CODING_UTILITY_H264_BITSTREAM_PARSER_H_ #include #include @@ -56,4 +56,4 @@ class H264BitstreamParser { } // namespace webrtc -#endif // WEBRTC_COMMON_VIDEO_H264_H264_BITSTREAM_PARSER_H_ +#endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_H264_BITSTREAM_PARSER_H_ diff --git a/webrtc/common_video/h264/h264_bitstream_parser_unittest.cc b/webrtc/modules/video_coding/utility/h264_bitstream_parser_unittest.cc similarity index 66% rename from webrtc/common_video/h264/h264_bitstream_parser_unittest.cc rename to webrtc/modules/video_coding/utility/h264_bitstream_parser_unittest.cc index c7ec21c65a..fbacd3b9ed 100644 --- a/webrtc/common_video/h264/h264_bitstream_parser_unittest.cc +++ b/webrtc/modules/video_coding/utility/h264_bitstream_parser_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/common_video/h264/h264_bitstream_parser.h" +#include "webrtc/modules/video_coding/utility/h264_bitstream_parser.h" #include "webrtc/test/gtest.h" @@ -32,18 +32,6 @@ uint8_t kH264BitstreamNextImageSliceChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x41, 0xe2, 0x01, 0x16, 0x0e, 0x3e, 0x2b, 0x86, }; -uint8_t kH264BitstreamChunkCabac[] = { - 0x00, 0x00, 0x00, 0x01, 0x27, 0x64, 0x00, 0x0d, 0xac, 0x52, 0x30, 0x50, - 0x7e, 0xc0, 0x5a, 0x81, 0x01, 0x01, 0x18, 0x56, 0xbd, 0xef, 0x80, 0x80, - 0x00, 0x00, 0x00, 0x01, 0x28, 0xfe, 0x09, 0x8b, -}; - -// Contains enough of the image slice to contain slice QP. -uint8_t kH264BitstreamNextImageSliceChunkCabac[] = { - 0x00, 0x00, 0x00, 0x01, 0x21, 0xe1, 0x05, 0x11, 0x3f, 0x9a, 0xae, 0x46, - 0x70, 0xbf, 0xc1, 0x4a, 0x16, 0x8f, 0x51, 0xf4, 0xca, 0xfb, 0xa3, 0x65, -}; - TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) { H264BitstreamParser h264_parser; int qp; @@ -71,18 +59,4 @@ TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) { EXPECT_EQ(37, qp); } -TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) { - H264BitstreamParser h264_parser; - h264_parser.ParseBitstream(kH264BitstreamChunkCabac, - sizeof(kH264BitstreamChunkCabac)); - int qp; - EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp)); - - // Parse an additional image slice. - h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac, - sizeof(kH264BitstreamNextImageSliceChunkCabac)); - ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp)); - EXPECT_EQ(24, qp); -} - } // namespace webrtc diff --git a/webrtc/modules/video_coding/utility/video_coding_utility.gyp b/webrtc/modules/video_coding/utility/video_coding_utility.gyp index b1158a2298..e4ed78f211 100644 --- a/webrtc/modules/video_coding/utility/video_coding_utility.gyp +++ b/webrtc/modules/video_coding/utility/video_coding_utility.gyp @@ -21,6 +21,8 @@ 'sources': [ 'frame_dropper.cc', 'frame_dropper.h', + 'h264_bitstream_parser.cc', + 'h264_bitstream_parser.h', 'ivf_file_writer.cc', 'ivf_file_writer.h', 'moving_average.cc',