Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1772)

Side by Side Diff: webrtc/base/bitbuffer.cc

Issue 1979443004: Add H264 bitstream rewriting to limit frame reordering marker in header (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/bitbuffer.h ('k') | webrtc/base/buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return false; 286 return false;
287 } 287 }
288 uint64_t val_to_encode = static_cast<uint64_t>(val) + 1; 288 uint64_t val_to_encode = static_cast<uint64_t>(val) + 1;
289 289
290 // We need to write CountBits(val+1) 0s and then val+1. Since val (as a 290 // We need to write CountBits(val+1) 0s and then val+1. Since val (as a
291 // uint64_t) has leading zeros, we can just write the total golomb encoded 291 // uint64_t) has leading zeros, we can just write the total golomb encoded
292 // size worth of bits, knowing the value will appear last. 292 // size worth of bits, knowing the value will appear last.
293 return WriteBits(val_to_encode, CountBits(val_to_encode) * 2 - 1); 293 return WriteBits(val_to_encode, CountBits(val_to_encode) * 2 - 1);
294 } 294 }
295 295
296 bool BitBufferWriter::WriteSignedExponentialGolomb(int32_t val) {
297 if (val == 0) {
298 return WriteExponentialGolomb(0);
299 } else if (val > 0) {
300 uint32_t signed_val = val;
301 return WriteExponentialGolomb((signed_val * 2) - 1);
302 } else {
303 if (val == std::numeric_limits<int32_t>::min())
304 return false; // Not supported, would cause overflow.
305 uint32_t signed_val = -val;
306 return WriteExponentialGolomb(signed_val * 2);
307 }
308 }
309
296 } // namespace rtc 310 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/bitbuffer.h ('k') | webrtc/base/buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698