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:
@ -1145,6 +1145,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
||||
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
|
||||
current_acc_qp_ += qp;
|
||||
quality_scaler_.ReportQP(qp);
|
||||
image->qp_ = qp;
|
||||
}
|
||||
}
|
||||
// For H.264 search for start codes.
|
||||
|
||||
@ -384,18 +384,20 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
|
||||
// Encoder can skip frames to save bandwidth in which case
|
||||
// |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.
|
||||
CodecSpecificInfo codec_specific;
|
||||
codec_specific.codecType = kVideoCodecH264;
|
||||
encoded_image_callback_->OnEncodedImage(encoded_image_, &codec_specific,
|
||||
&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 {
|
||||
quality_scaler_.ReportDroppedFrame();
|
||||
}
|
||||
|
||||
@ -756,6 +756,7 @@ void H264VideoToolboxEncoder::OnEncodedFrame(
|
||||
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
|
||||
rtc::CritScope lock(&quality_scaler_crit_);
|
||||
quality_scaler_.ReportQP(qp);
|
||||
frame.qp_ = qp;
|
||||
}
|
||||
|
||||
EncodedImageCallback::Result result =
|
||||
|
||||
Reference in New Issue
Block a user