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

Unified Diff: webrtc/common_video/h264/sps_vui_rewriter.cc

Issue 2728093002: Optimize ParseRbsp method in H264 bitstream parser. (Closed)
Patch Set: return vector to avoid copy Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/common_video/h264/sps_vui_rewriter.cc
diff --git a/webrtc/common_video/h264/sps_vui_rewriter.cc b/webrtc/common_video/h264/sps_vui_rewriter.cc
index c5b9b706dff3e6dc66a047da1330c4999b8e2efc..2e118d5233b147b1f48f0268553534f8c044335b 100644
--- a/webrtc/common_video/h264/sps_vui_rewriter.cc
+++ b/webrtc/common_video/h264/sps_vui_rewriter.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include <memory>
+#include <vector>
#include "webrtc/base/bitbuffer.h"
#include "webrtc/base/checks.h"
@@ -74,8 +75,8 @@ SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps(
rtc::Buffer* destination) {
// Create temporary RBSP decoded buffer of the payload (exlcuding the
// leading nalu type header byte (the SpsParser uses only the payload).
- std::unique_ptr<rtc::Buffer> rbsp_buffer = H264::ParseRbsp(buffer, length);
- rtc::BitBuffer source_buffer(rbsp_buffer->data(), rbsp_buffer->size());
+ std::vector<uint8_t> rbsp_buffer = H264::ParseRbsp(buffer, length);
+ rtc::BitBuffer source_buffer(rbsp_buffer.data(), rbsp_buffer.size());
rtc::Optional<SpsParser::SpsState> sps_state =
SpsParser::ParseSpsUpToVui(&source_buffer);
if (!sps_state)
@@ -97,7 +98,7 @@ SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps(
size_t byte_offset;
size_t bit_offset;
source_buffer.GetCurrentOffset(&byte_offset, &bit_offset);
- memcpy(out_buffer.data(), rbsp_buffer->data(),
+ memcpy(out_buffer.data(), rbsp_buffer.data(),
byte_offset + (bit_offset > 0 ? 1 : 0)); // OK to copy the last bits.
// SpsParser will have read the vui_params_present flag, which we want to
« webrtc/common_video/h264/sps_parser.cc ('K') | « webrtc/common_video/h264/sps_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698