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

Unified Diff: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc

Issue 1616843004: Small cleanup in VP9EncoderImpl::GetEncodedLayerFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index 6dbc23956ed975281730edd1f481252371c54583..70a903cd05c462322e2598b0c9592bc7f0784d19 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -245,9 +245,9 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
- int retVal = Release();
- if (retVal < 0) {
- return retVal;
+ int ret_val = Release();
+ if (ret_val < 0) {
+ return ret_val;
}
if (encoder_ == NULL) {
encoder_ = new vpx_codec_ctx_t;
@@ -650,30 +650,25 @@ void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
}
int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
- encoded_image_._length = 0;
- encoded_image_._frameType = kVideoFrameDelta;
- RTPFragmentationHeader frag_info;
- // Note: no data partitioning in VP9, so 1 partition only. We keep this
- // fragmentation data for now, until VP9 packetizer is implemented.
- frag_info.VerifyAndAllocateFragmentationHeader(1);
- int part_idx = 0;
- CodecSpecificInfo codec_specific;
+ RTC_DCHECK_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT);
if (pkt->data.frame.sz > encoded_image_._size) {
delete[] encoded_image_._buffer;
encoded_image_._size = pkt->data.frame.sz;
encoded_image_._buffer = new uint8_t[encoded_image_._size];
}
+ memcpy(encoded_image_._buffer, pkt->data.frame.buf, pkt->data.frame.sz);
+ encoded_image_._length = pkt->data.frame.sz;
- assert(pkt->kind == VPX_CODEC_CX_FRAME_PKT);
- memcpy(&encoded_image_._buffer[encoded_image_._length], pkt->data.frame.buf,
- pkt->data.frame.sz);
- frag_info.fragmentationOffset[part_idx] = encoded_image_._length;
- frag_info.fragmentationLength[part_idx] =
- static_cast<uint32_t>(pkt->data.frame.sz);
+ // Note: no data partitioning in VP9, so 1 partition only. We keep this
+ // fragmentation data for now, until VP9 packetizer is implemented.
stefan-webrtc 2016/01/25 13:57:38 It is already implemented, right? Is this comment
åsapersson 2016/01/26 07:55:32 Updated comment.
+ int part_idx = 0;
+ RTPFragmentationHeader frag_info;
+ frag_info.VerifyAndAllocateFragmentationHeader(1);
+ frag_info.fragmentationOffset[part_idx] = 0;
+ frag_info.fragmentationLength[part_idx] = pkt->data.frame.sz;
frag_info.fragmentationPlType[part_idx] = 0;
frag_info.fragmentationTimeDiff[part_idx] = 0;
- encoded_image_._length += static_cast<uint32_t>(pkt->data.frame.sz);
vpx_svc_layer_id_t layer_id = {0};
vpx_codec_control(encoder_, VP9E_GET_SVC_LAYER_ID, &layer_id);
@@ -682,13 +677,15 @@ int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
static_cast<unsigned int>(encoded_image_._length),
layer_id.spatial_layer_id);
- assert(encoded_image_._length <= encoded_image_._size);
-
// End of frame.
// Check if encoded frame is a key frame.
+ encoded_image_._frameType = kVideoFrameDelta;
if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
encoded_image_._frameType = kVideoFrameKey;
}
+ RTC_DCHECK_LE(encoded_image_._length, encoded_image_._size);
+
+ CodecSpecificInfo codec_specific;
PopulateCodecSpecific(&codec_specific, *pkt, input_image_->timestamp());
if (encoded_image_._length > 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698