From 49f574b3b33915405e03e02ca47472677ea4a448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 4 May 2020 13:47:28 +0200 Subject: [PATCH] Delete EncodedImage methods buffer(), set_buffer() and mutable_data() Bug: webrtc:9378 Change-Id: Iab21fe537f03a5cd130d8435cd94520952e693a9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168494 Commit-Queue: Niels Moller Reviewed-by: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#31164} --- api/video/encoded_image.h | 16 +--------------- .../codecs/h264/h264_decoder_impl.cc | 4 +++- .../multiplex/multiplex_encoded_image_packer.cc | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/api/video/encoded_image.h b/api/video/encoded_image.h index 25f83c7cf3..d89095f467 100644 --- a/api/video/encoded_image.h +++ b/api/video/encoded_image.h @@ -26,7 +26,7 @@ #include "api/video/video_frame_type.h" #include "api/video/video_rotation.h" #include "api/video/video_timing.h" -#include "common_types.h" // NOLINT(build/include) +#include "common_types.h" // NOLINT(build/include_directory) #include "rtc_base/checks.h" #include "rtc_base/deprecation.h" #include "rtc_base/ref_count.h" @@ -136,11 +136,6 @@ class RTC_EXPORT EncodedImage { return buffer_ ? capacity_ : (encoded_data_ ? encoded_data_->size() : 0); } - void set_buffer(uint8_t* buffer, size_t capacity) { - buffer_ = buffer; - capacity_ = capacity; - } - void SetEncodedData( rtc::scoped_refptr encoded_data) { encoded_data_ = encoded_data; @@ -169,15 +164,6 @@ class RTC_EXPORT EncodedImage { return buffer_ ? buffer_ : (encoded_data_ ? encoded_data_->data() : nullptr); } - // TODO(nisse): At some places, code accepts a const ref EncodedImage, but - // still writes to it, to clear padding at the end of the encoded data. - // Padding is required by ffmpeg; the best way to deal with that is likely to - // make this class ensure that buffers always have a few zero padding bytes. - uint8_t* mutable_data() const { return const_cast(data()); } - - // TODO(bugs.webrtc.org/9378): Delete. Used by code that wants to modify a - // buffer corresponding to a const EncodedImage. Requires an un-owned buffer. - uint8_t* buffer() const { return buffer_; } // Hack to workaround lack of ownership of the encoded data. If we don't // already own the underlying data, make an owned copy. diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc index 6725a3b7c7..33efa648ba 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -260,7 +260,9 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, AVPacket packet; av_init_packet(&packet); - packet.data = input_image.mutable_data(); + // packet.data has a non-const type, but isn't modified by + // avcodec_send_packet. + packet.data = const_cast(input_image.data()); if (input_image.size() > static_cast(std::numeric_limits::max())) { ReportError(); diff --git a/modules/video_coding/codecs/multiplex/multiplex_encoded_image_packer.cc b/modules/video_coding/codecs/multiplex/multiplex_encoded_image_packer.cc index 38f16d7f2f..6bc306dda8 100644 --- a/modules/video_coding/codecs/multiplex/multiplex_encoded_image_packer.cc +++ b/modules/video_coding/codecs/multiplex/multiplex_encoded_image_packer.cc @@ -193,7 +193,7 @@ EncodedImage MultiplexEncodedImagePacker::PackAndRelease( combined_image.SetEncodedData(buffer); // header - header_offset = PackHeader(combined_image.data(), header); + header_offset = PackHeader(buffer->data(), header); RTC_DCHECK_EQ(header.first_component_header_offset, kMultiplexImageHeaderSize);