Skip to content

Commit 2d60e53

Browse files
Hnoo112233Commit bot
authored and
Commit bot
committed
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}
1 parent e60f020 commit 2d60e53

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

webrtc/api/android/jni/androidmediaencoder_jni.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
11451145
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
11461146
current_acc_qp_ += qp;
11471147
quality_scaler_.ReportQP(qp);
1148+
image->qp_ = qp;
11481149
}
11491150
}
11501151
// For H.264 search for start codes.

webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,20 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
384384
// Encoder can skip frames to save bandwidth in which case
385385
// |encoded_image_._length| == 0.
386386
if (encoded_image_._length > 0) {
387-
// Deliver encoded image.
388-
CodecSpecificInfo codec_specific;
389-
codec_specific.codecType = kVideoCodecH264;
390-
encoded_image_callback_->OnEncodedImage(encoded_image_, &codec_specific,
391-
&frag_header);
392-
393387
// Parse and report QP.
394388
h264_bitstream_parser_.ParseBitstream(encoded_image_._buffer,
395389
encoded_image_._length);
396390
int qp = -1;
397-
if (h264_bitstream_parser_.GetLastSliceQp(&qp))
391+
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
398392
quality_scaler_.ReportQP(qp);
393+
encoded_image_.qp_ = qp;
394+
}
395+
396+
// Deliver encoded image.
397+
CodecSpecificInfo codec_specific;
398+
codec_specific.codecType = kVideoCodecH264;
399+
encoded_image_callback_->OnEncodedImage(encoded_image_, &codec_specific,
400+
&frag_header);
399401
} else {
400402
quality_scaler_.ReportDroppedFrame();
401403
}

webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.mm

+1
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ CFStringRef ExtractProfile(const cricket::VideoCodec& codec) {
756756
if (h264_bitstream_parser_.GetLastSliceQp(&qp)) {
757757
rtc::CritScope lock(&quality_scaler_crit_);
758758
quality_scaler_.ReportQP(qp);
759+
frame.qp_ = qp;
759760
}
760761

761762
EncodedImageCallback::Result result =

0 commit comments

Comments
 (0)