H264 encoder: Include QP information in encoded images

Set the |qp_| field in EncodedImage before calling OnEncodedImage.

BUG=webrtc:6541

Review-Url: https://codereview.webrtc.org/2499003002
Cr-Commit-Position: refs/heads/master@{#15199}
This commit is contained in:
magjed
2016-11-22 08:42:06 -08:00
committed by Commit bot
parent e60f020456
commit 2d60e53ad5
3 changed files with 11 additions and 7 deletions

View File

@ -1145,6 +1145,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) { if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
current_acc_qp_ += qp; current_acc_qp_ += qp;
quality_scaler_.ReportQP(qp); quality_scaler_.ReportQP(qp);
image->qp_ = qp;
} }
} }
// For H.264 search for start codes. // For H.264 search for start codes.

View File

@ -384,18 +384,20 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
// Encoder can skip frames to save bandwidth in which case // Encoder can skip frames to save bandwidth in which case
// |encoded_image_._length| == 0. // |encoded_image_._length| == 0.
if (encoded_image_._length > 0) { if (encoded_image_._length > 0) {
// Parse and report QP.
h264_bitstream_parser_.ParseBitstream(encoded_image_._buffer,
encoded_image_._length);
int qp = -1;
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
quality_scaler_.ReportQP(qp);
encoded_image_.qp_ = qp;
}
// Deliver encoded image. // Deliver encoded image.
CodecSpecificInfo codec_specific; CodecSpecificInfo codec_specific;
codec_specific.codecType = kVideoCodecH264; codec_specific.codecType = kVideoCodecH264;
encoded_image_callback_->OnEncodedImage(encoded_image_, &codec_specific, encoded_image_callback_->OnEncodedImage(encoded_image_, &codec_specific,
&frag_header); &frag_header);
// Parse and report QP.
h264_bitstream_parser_.ParseBitstream(encoded_image_._buffer,
encoded_image_._length);
int qp = -1;
if (h264_bitstream_parser_.GetLastSliceQp(&qp))
quality_scaler_.ReportQP(qp);
} else { } else {
quality_scaler_.ReportDroppedFrame(); quality_scaler_.ReportDroppedFrame();
} }

View File

@ -756,6 +756,7 @@ void H264VideoToolboxEncoder::OnEncodedFrame(
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) { if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
rtc::CritScope lock(&quality_scaler_crit_); rtc::CritScope lock(&quality_scaler_crit_);
quality_scaler_.ReportQP(qp); quality_scaler_.ReportQP(qp);
frame.qp_ = qp;
} }
EncodedImageCallback::Result result = EncodedImageCallback::Result result =