Initialize packetization mode in VideoToolbox

This fixes a recently introduced bug where we would read uninitialized
memory as the packetization_mode member in codec_specific_info was not
being properly initialized.

BUG=webrtc:6858

Review-Url: https://codereview.webrtc.org/2577043003
Cr-Commit-Position: refs/heads/master@{#15646}
This commit is contained in:
kthelgason
2016-12-16 02:10:20 -08:00
committed by Commit bot
parent 9a272059c2
commit 05d6e260f5
2 changed files with 7 additions and 2 deletions

View File

@ -80,6 +80,7 @@ class H264VideoToolboxEncoder : public H264Encoder {
EncodedImageCallback* callback_;
VTCompressionSessionRef compression_session_;
BitrateAdjuster bitrate_adjuster_;
H264PacketizationMode packetization_mode_;
uint32_t target_bitrate_bps_;
uint32_t encoder_bitrate_bps_;
int32_t width_;

View File

@ -342,13 +342,14 @@ namespace webrtc {
// drastically reduced bitrate, so we want to avoid that. In steady state
// conditions, 0.95 seems to give us better overall bitrate over long periods
// of time.
H264VideoToolboxEncoder::H264VideoToolboxEncoder(
const cricket::VideoCodec& codec)
H264VideoToolboxEncoder::H264VideoToolboxEncoder(const cricket::VideoCodec& codec)
: callback_(nullptr),
compression_session_(nullptr),
bitrate_adjuster_(Clock::GetRealTimeClock(), .5, .95),
packetization_mode_(H264PacketizationMode::NonInterleaved),
profile_(internal::ExtractProfile(codec)) {
LOG(LS_INFO) << "Using profile " << internal::CFStringToString(profile_);
RTC_CHECK(cricket::CodecNamesEq(codec.name, cricket::kH264CodecName));
}
H264VideoToolboxEncoder::~H264VideoToolboxEncoder() {
@ -470,6 +471,9 @@ int H264VideoToolboxEncoder::Encode(
this, codec_specific_info, width_, height_, frame.render_time_ms(),
frame.timestamp(), frame.rotation()));
encode_params->codec_specific_info.codecSpecific.H264.packetization_mode =
packetization_mode_;
// Update the bitrate if needed.
SetBitrateBps(bitrate_adjuster_.GetAdjustedBitrateBps());