| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |    2  *  Copyright (c) 2016 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  */ | 
|   11  |   11  | 
|   12 #include "webrtc/common_video/h264/sps_vui_rewriter.h" |   12 #include "webrtc/common_video/h264/sps_vui_rewriter.h" | 
|   13  |   13  | 
|   14 #include <algorithm> |   14 #include <algorithm> | 
|   15 #include <memory> |   15 #include <memory> | 
|   16 #include <vector> |   16 #include <vector> | 
|   17  |   17  | 
|   18 #include "webrtc/base/bitbuffer.h" |   18 #include "webrtc/base/bitbuffer.h" | 
|   19 #include "webrtc/base/checks.h" |   19 #include "webrtc/base/checks.h" | 
|   20 #include "webrtc/base/logging.h" |   20 #include "webrtc/base/logging.h" | 
 |   21 #include "webrtc/base/safe_minmax.h" | 
|   21  |   22  | 
|   22 #include "webrtc/common_video/h264/h264_common.h" |   23 #include "webrtc/common_video/h264/h264_common.h" | 
|   23 #include "webrtc/common_video/h264/sps_parser.h" |   24 #include "webrtc/common_video/h264/sps_parser.h" | 
|   24  |   25  | 
|   25 namespace webrtc { |   26 namespace webrtc { | 
|   26  |   27  | 
|   27 // The maximum expected growth from adding a VUI to the SPS. It's actually |   28 // The maximum expected growth from adding a VUI to the SPS. It's actually | 
|   28 // closer to 24 or so, but better safe than sorry. |   29 // closer to 24 or so, but better safe than sorry. | 
|   29 const size_t kMaxVuiSpsIncrease = 64; |   30 const size_t kMaxVuiSpsIncrease = 64; | 
|   30  |   31  | 
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  344  |  345  | 
|  345 bool CopyRemainingBits(rtc::BitBuffer* source, |  346 bool CopyRemainingBits(rtc::BitBuffer* source, | 
|  346                        rtc::BitBufferWriter* destination) { |  347                        rtc::BitBufferWriter* destination) { | 
|  347   uint32_t bits_tmp; |  348   uint32_t bits_tmp; | 
|  348   // Try to get at least the destination aligned. |  349   // Try to get at least the destination aligned. | 
|  349   if (source->RemainingBitCount() > 0 && source->RemainingBitCount() % 8 != 0) { |  350   if (source->RemainingBitCount() > 0 && source->RemainingBitCount() % 8 != 0) { | 
|  350     size_t misaligned_bits = source->RemainingBitCount() % 8; |  351     size_t misaligned_bits = source->RemainingBitCount() % 8; | 
|  351     COPY_BITS(source, destination, bits_tmp, misaligned_bits); |  352     COPY_BITS(source, destination, bits_tmp, misaligned_bits); | 
|  352   } |  353   } | 
|  353   while (source->RemainingBitCount() > 0) { |  354   while (source->RemainingBitCount() > 0) { | 
|  354     size_t count = std::min(static_cast<size_t>(32u), |  355     auto count = rtc::SafeMin<size_t>(32u, source->RemainingBitCount()); | 
|  355                             static_cast<size_t>(source->RemainingBitCount())); |  | 
|  356     COPY_BITS(source, destination, bits_tmp, count); |  356     COPY_BITS(source, destination, bits_tmp, count); | 
|  357   } |  357   } | 
|  358   // TODO(noahric): The last byte could be all zeroes now, which we should just |  358   // TODO(noahric): The last byte could be all zeroes now, which we should just | 
|  359   // strip. |  359   // strip. | 
|  360   return true; |  360   return true; | 
|  361 } |  361 } | 
|  362  |  362  | 
|  363 }  // namespace webrtc |  363 }  // namespace webrtc | 
| OLD | NEW |