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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc

Issue 2656603002: Add QP for libvpx VP8 decoder. (Closed)
Patch Set: Rebase. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 if (vpx_codec_decode(decoder_, buffer, input_image._length, 0, 1138 if (vpx_codec_decode(decoder_, buffer, input_image._length, 0,
1139 VPX_DL_REALTIME)) { 1139 VPX_DL_REALTIME)) {
1140 // Reset to avoid requesting key frames too often. 1140 // Reset to avoid requesting key frames too often.
1141 if (propagation_cnt_ > 0) { 1141 if (propagation_cnt_ > 0) {
1142 propagation_cnt_ = 0; 1142 propagation_cnt_ = 0;
1143 } 1143 }
1144 return WEBRTC_VIDEO_CODEC_ERROR; 1144 return WEBRTC_VIDEO_CODEC_ERROR;
1145 } 1145 }
1146 1146
1147 img = vpx_codec_get_frame(decoder_, &iter); 1147 img = vpx_codec_get_frame(decoder_, &iter);
1148 ret = ReturnFrame(img, input_image._timeStamp, input_image.ntp_time_ms_); 1148 int qp;
1149 vpx_codec_err_t vpx_ret =
1150 vpx_codec_control(decoder_, VPXD_GET_LAST_QUANTIZER, &qp);
1151 RTC_DCHECK_EQ(vpx_ret, VPX_CODEC_OK);
1152 ret = ReturnFrame(img, input_image._timeStamp, input_image.ntp_time_ms_, qp);
1149 if (ret != 0) { 1153 if (ret != 0) {
1150 // Reset to avoid requesting key frames too often. 1154 // Reset to avoid requesting key frames too often.
1151 if (ret < 0 && propagation_cnt_ > 0) 1155 if (ret < 0 && propagation_cnt_ > 0)
1152 propagation_cnt_ = 0; 1156 propagation_cnt_ = 0;
1153 return ret; 1157 return ret;
1154 } 1158 }
1155 if (feedback_mode_) { 1159 if (feedback_mode_) {
1156 // Whenever we receive an incomplete key frame all reference buffers will 1160 // Whenever we receive an incomplete key frame all reference buffers will
1157 // be corrupt. If that happens we must request new key frames until we 1161 // be corrupt. If that happens we must request new key frames until we
1158 // decode a complete key frame. 1162 // decode a complete key frame.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 if (propagation_cnt_ > kVp8ErrorPropagationTh) { 1202 if (propagation_cnt_ > kVp8ErrorPropagationTh) {
1199 // Reset to avoid requesting key frames too often. 1203 // Reset to avoid requesting key frames too often.
1200 propagation_cnt_ = 0; 1204 propagation_cnt_ = 0;
1201 return WEBRTC_VIDEO_CODEC_ERROR; 1205 return WEBRTC_VIDEO_CODEC_ERROR;
1202 } 1206 }
1203 return WEBRTC_VIDEO_CODEC_OK; 1207 return WEBRTC_VIDEO_CODEC_OK;
1204 } 1208 }
1205 1209
1206 int VP8DecoderImpl::ReturnFrame(const vpx_image_t* img, 1210 int VP8DecoderImpl::ReturnFrame(const vpx_image_t* img,
1207 uint32_t timestamp, 1211 uint32_t timestamp,
1208 int64_t ntp_time_ms) { 1212 int64_t ntp_time_ms,
1213 int qp) {
1209 if (img == NULL) { 1214 if (img == NULL) {
1210 // Decoder OK and NULL image => No show frame 1215 // Decoder OK and NULL image => No show frame
1211 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; 1216 return WEBRTC_VIDEO_CODEC_NO_OUTPUT;
1212 } 1217 }
1213 last_frame_width_ = img->d_w; 1218 last_frame_width_ = img->d_w;
1214 last_frame_height_ = img->d_h; 1219 last_frame_height_ = img->d_h;
1215 // Allocate memory for decoded image. 1220 // Allocate memory for decoded image.
1216 rtc::scoped_refptr<I420Buffer> buffer = 1221 rtc::scoped_refptr<I420Buffer> buffer =
1217 buffer_pool_.CreateBuffer(img->d_w, img->d_h); 1222 buffer_pool_.CreateBuffer(img->d_w, img->d_h);
1218 if (!buffer.get()) { 1223 if (!buffer.get()) {
1219 // Pool has too many pending frames. 1224 // Pool has too many pending frames.
1220 RTC_HISTOGRAM_BOOLEAN("WebRTC.Video.VP8DecoderImpl.TooManyPendingFrames", 1225 RTC_HISTOGRAM_BOOLEAN("WebRTC.Video.VP8DecoderImpl.TooManyPendingFrames",
1221 1); 1226 1);
1222 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; 1227 return WEBRTC_VIDEO_CODEC_NO_OUTPUT;
1223 } 1228 }
1224 1229
1225 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], 1230 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y],
1226 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], 1231 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U],
1227 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], 1232 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V],
1228 buffer->MutableDataY(), buffer->StrideY(), 1233 buffer->MutableDataY(), buffer->StrideY(),
1229 buffer->MutableDataU(), buffer->StrideU(), 1234 buffer->MutableDataU(), buffer->StrideU(),
1230 buffer->MutableDataV(), buffer->StrideV(), 1235 buffer->MutableDataV(), buffer->StrideV(),
1231 img->d_w, img->d_h); 1236 img->d_w, img->d_h);
1232 1237
1233 VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0); 1238 VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0);
1234 decoded_image.set_ntp_time_ms(ntp_time_ms); 1239 decoded_image.set_ntp_time_ms(ntp_time_ms);
1235 int ret = decode_complete_callback_->Decoded(decoded_image); 1240 decode_complete_callback_->Decoded(decoded_image, rtc::Optional<int32_t>(),
1236 if (ret != 0) 1241 rtc::Optional<uint8_t>(qp));
1237 return ret;
1238 1242
1239 // Remember image format for later 1243 // Remember image format for later
1240 image_format_ = img->fmt; 1244 image_format_ = img->fmt;
1241 return WEBRTC_VIDEO_CODEC_OK; 1245 return WEBRTC_VIDEO_CODEC_OK;
1242 } 1246 }
1243 1247
1244 int VP8DecoderImpl::RegisterDecodeCompleteCallback( 1248 int VP8DecoderImpl::RegisterDecodeCompleteCallback(
1245 DecodedImageCallback* callback) { 1249 DecodedImageCallback* callback) {
1246 decode_complete_callback_ = callback; 1250 decode_complete_callback_ = callback;
1247 return WEBRTC_VIDEO_CODEC_OK; 1251 return WEBRTC_VIDEO_CODEC_OK;
(...skipping 29 matching lines...) Expand all
1277 return -1; 1281 return -1;
1278 } 1282 }
1279 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != 1283 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) !=
1280 VPX_CODEC_OK) { 1284 VPX_CODEC_OK) {
1281 return -1; 1285 return -1;
1282 } 1286 }
1283 return 0; 1287 return 0;
1284 } 1288 }
1285 1289
1286 } // namespace webrtc 1290 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/vp8_impl.h ('k') | webrtc/pc/rtcstats_integrationtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698