Use software bitrate control for D3D12 H26x video encoder [chromium/src : main]

0 views
Skip to first unread message

Pohsiang Hsu (Gerrit)

unread,
Mar 17, 2025, 2:00:48 PMMar 17
to Zhibo Wang, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
Attention needed from Eugene Zemtsov and Zhibo Wang

Pohsiang Hsu added 3 comments

File media/gpu/windows/d3d12_video_encode_h265_delegate.cc
Line 189, Patchset 29 (Latest): pic_params_.PictureOrderCountNumber = -1;
Pohsiang Hsu . unresolved

Just curious, this seems to suggest we insert a keyframe when frame_rate exceeds frame_rate_max. Is that the case?

Line 191, Patchset 29 (Latest): software_rate_controller_->temporal_layers(0).SetBufferParameters(
Pohsiang Hsu . unresolved

Just wondering, I see that if framerate changed and is higher than frame_rate_max, then we update gop_max_duration and frame_rate. But what about when framerate changes to be lower than frame_rate_max, we don't need to update gop_max_duration and frame_rate? most like this is by design, but I'd just wanted to ask just in case.

Line 316, Patchset 29 (Latest): (config.gop_length.value() + config.framerate - 1) / config.framerate);
Pohsiang Hsu . unresolved

wondering if there is any check for config.framerate > 0 in the caller of InitializeVideoEncoder? if not, perhaps would be good to add a check for safety (framerate > 0)?

Open in Gerrit

Related details

Attention is currently required from:
  • Eugene Zemtsov
  • Zhibo Wang
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
Gerrit-Change-Number: 6073677
Gerrit-PatchSet: 29
Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Comment-Date: Mon, 17 Mar 2025 18:00:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Zhibo Wang (Gerrit)

unread,
Mar 20, 2025, 5:00:22 AMMar 20
to Pohsiang Hsu, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
Attention needed from Eugene Zemtsov and Pohsiang Hsu

Zhibo Wang added 3 comments

File media/gpu/windows/d3d12_video_encode_h265_delegate.cc
Line 189, Patchset 29: pic_params_.PictureOrderCountNumber = -1;
Pohsiang Hsu . resolved

Just curious, this seems to suggest we insert a keyframe when frame_rate exceeds frame_rate_max. Is that the case?

Zhibo Wang

It was. Thanks to your comment, I think this is unnecessary. It is removed now.

Line 191, Patchset 29: software_rate_controller_->temporal_layers(0).SetBufferParameters(
Pohsiang Hsu . resolved

Just wondering, I see that if framerate changed and is higher than frame_rate_max, then we update gop_max_duration and frame_rate. But what about when framerate changes to be lower than frame_rate_max, we don't need to update gop_max_duration and frame_rate? most like this is by design, but I'd just wanted to ask just in case.

Zhibo Wang

It was my design, when it don't exceed the maximum we won't use up the bitrate budget, so it is ok we don't reset it. But I feel it kind of wierd now. I have updated the logic to as long as the frame rate changes, the controller is reset, so it can provide precise estimation according to the new frame rate.

Line 316, Patchset 29: (config.gop_length.value() + config.framerate - 1) / config.framerate);
Pohsiang Hsu . resolved

wondering if there is any check for config.framerate > 0 in the caller of InitializeVideoEncoder? if not, perhaps would be good to add a check for safety (framerate > 0)?

Zhibo Wang

It will be by default 30 or what we explicitly set. Adding a check will be safer. Done.

Open in Gerrit

Related details

Attention is currently required from:
  • Eugene Zemtsov
  • Pohsiang Hsu
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
Gerrit-Change-Number: 6073677
Gerrit-PatchSet: 30
Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Attention: Pohsiang Hsu <poh...@microsoft.com>
Gerrit-Comment-Date: Thu, 20 Mar 2025 08:59:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Pohsiang Hsu <poh...@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Pohsiang Hsu (Gerrit)

unread,
Mar 20, 2025, 12:10:28 PMMar 20
to Zhibo Wang, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
Attention needed from Eugene Zemtsov and Zhibo Wang

Pohsiang Hsu added 1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Eugene Zemtsov
  • Zhibo Wang
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
Gerrit-Change-Number: 6073677
Gerrit-PatchSet: 33
Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Comment-Date: Thu, 20 Mar 2025 16:10:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Zhibo Wang (Gerrit)

unread,
Mar 21, 2025, 1:34:29 AMMar 21
to Pohsiang Hsu, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
Attention needed from Eugene Zemtsov and Rafael Cintron

Zhibo Wang added 1 comment

Patchset-level comments
Zhibo Wang . resolved
Open in Gerrit

Related details

Attention is currently required from:
  • Eugene Zemtsov
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
Gerrit-Change-Number: 6073677
Gerrit-PatchSet: 33
Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Fri, 21 Mar 2025 05:34:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Rafael Cintron (Gerrit)

unread,
Mar 21, 2025, 4:43:19 PMMar 21
to Zhibo Wang, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
Attention needed from Eugene Zemtsov and Zhibo Wang

Rafael Cintron added 1 comment

File media/gpu/windows/d3d12_video_encode_h265_delegate.h
Line 98, Patchset 33 (Latest): base::TimeDelta rate_controller_timestamp_;
Rafael Cintron . unresolved

Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

Open in Gerrit

Related details

Attention is currently required from:
  • Eugene Zemtsov
  • Zhibo Wang
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
    Gerrit-Change-Number: 6073677
    Gerrit-PatchSet: 33
    Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
    Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
    Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
    Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
    Gerrit-Comment-Date: Fri, 21 Mar 2025 20:43:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Zhibo Wang (Gerrit)

    unread,
    Mar 24, 2025, 4:33:20 AMMar 24
    to Pohsiang Hsu, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
    Attention needed from Eugene Zemtsov and Rafael Cintron

    Zhibo Wang added 1 comment

    File media/gpu/windows/d3d12_video_encode_h265_delegate.h
    Line 98, Patchset 33: base::TimeDelta rate_controller_timestamp_;
    Rafael Cintron . resolved

    Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

    Zhibo Wang

    Done. This refers to the timestamp of a frame in the video, which start with 0.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Eugene Zemtsov
    • Rafael Cintron
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
    Gerrit-Change-Number: 6073677
    Gerrit-PatchSet: 34
    Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
    Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
    Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
    Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Comment-Date: Mon, 24 Mar 2025 08:33:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Rafael Cintron (Gerrit)

    unread,
    Mar 25, 2025, 2:03:47 PMMar 25
    to Zhibo Wang, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
    Attention needed from Eugene Zemtsov and Zhibo Wang

    Rafael Cintron added 1 comment

    File media/gpu/windows/d3d12_video_encode_h265_delegate.h
    Line 98, Patchset 33: base::TimeDelta rate_controller_timestamp_;
    Rafael Cintron . unresolved

    Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

    Zhibo Wang

    Done. This refers to the timestamp of a frame in the video, which start with 0.

    Rafael Cintron

    To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure. From the looks of the code, we increment the time delta by the framerate, but only in `D3D12VideoEncodeH265Delegate::ReadbackBitstream`. Is there significance of doing so here and not elsewhere? Is ReadbackBitsstream meant to be a heartbeat of encoding?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Eugene Zemtsov
    • Zhibo Wang
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
      Gerrit-Change-Number: 6073677
      Gerrit-PatchSet: 34
      Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
      Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Comment-Date: Tue, 25 Mar 2025 18:03:25 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Zhibo Wang <zhibo...@intel.com>
      Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Zhibo Wang (Gerrit)

      unread,
      Mar 26, 2025, 3:00:25 AMMar 26
      to Pohsiang Hsu, Eugene Zemtsov, Rafael Cintron, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
      Attention needed from Eugene Zemtsov and Rafael Cintron

      Zhibo Wang added 1 comment

      File media/gpu/windows/d3d12_video_encode_h265_delegate.h
      Line 98, Patchset 33: base::TimeDelta rate_controller_timestamp_;
      Rafael Cintron . unresolved

      Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

      Zhibo Wang

      Done. This refers to the timestamp of a frame in the video, which start with 0.

      Rafael Cintron

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure. From the looks of the code, we increment the time delta by the framerate, but only in `D3D12VideoEncodeH265Delegate::ReadbackBitstream`. Is there significance of doing so here and not elsewhere? Is ReadbackBitsstream meant to be a heartbeat of encoding?

      Zhibo Wang

      To make it simple, all we are doing in this CL is to use a software (previously it is done by hardware) rate controller in our encoding procedure, which takes the encoded stream byte size and the timestamp (the one we are talking about) of the current frame as input, and produces the QP value for next frame.

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure.

      It makes sense in general coding area, but here we are in media domain, where `timestamp` may be like a term that has special meaning. It stands for the time offset since the start of the video that a frame should be presented at. So the `TimeDelta` means delta to the start of the video, which makes sense to me, while `TimeTicks` is real world time, which don't fit our definition.

      Also, this variable is for `H264RateController`, who accepts a `base::TimeDelta` object which is named as timestamp.
      https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/h264_rate_controller.h;l=502;drc=3ddadc368c8043783e32a3b50c64158cfb8aa42a

      Is ReadbackBitsstream meant to be a heartbeat of encoding?

      `ReadbackBitsstream()` will be called once a frame is encoded. So it may be yes but we don't utilize the real world time when it is called, in this CL. We are updating the rate controller to let it calculate the remaining bandwidth and the proper QP value for next frame. We do the update in `ReadbackBitsstream()` is only because we had to wait until this time to know the size of encoded stream.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Eugene Zemtsov
      • Rafael Cintron
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
      Gerrit-Change-Number: 6073677
      Gerrit-PatchSet: 34
      Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
      Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Comment-Date: Wed, 26 Mar 2025 07:00:01 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Rafael Cintron (Gerrit)

      unread,
      Mar 27, 2025, 5:19:03 PMMar 27
      to Zhibo Wang, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
      Attention needed from Eugene Zemtsov and Zhibo Wang

      Rafael Cintron voted and added 1 comment

      Votes added by Rafael Cintron

      Code-Review+1

      1 comment

      File media/gpu/windows/d3d12_video_encode_h265_delegate.h
      Line 98, Patchset 33: base::TimeDelta rate_controller_timestamp_;
      Rafael Cintron . unresolved

      Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

      Zhibo Wang

      Done. This refers to the timestamp of a frame in the video, which start with 0.

      Rafael Cintron

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure. From the looks of the code, we increment the time delta by the framerate, but only in `D3D12VideoEncodeH265Delegate::ReadbackBitstream`. Is there significance of doing so here and not elsewhere? Is ReadbackBitsstream meant to be a heartbeat of encoding?

      Zhibo Wang

      To make it simple, all we are doing in this CL is to use a software (previously it is done by hardware) rate controller in our encoding procedure, which takes the encoded stream byte size and the timestamp (the one we are talking about) of the current frame as input, and produces the QP value for next frame.

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure.

      It makes sense in general coding area, but here we are in media domain, where `timestamp` may be like a term that has special meaning. It stands for the time offset since the start of the video that a frame should be presented at. So the `TimeDelta` means delta to the start of the video, which makes sense to me, while `TimeTicks` is real world time, which don't fit our definition.

      Also, this variable is for `H264RateController`, who accepts a `base::TimeDelta` object which is named as timestamp.
      https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/h264_rate_controller.h;l=502;drc=3ddadc368c8043783e32a3b50c64158cfb8aa42a

      Is ReadbackBitsstream meant to be a heartbeat of encoding?

      `ReadbackBitsstream()` will be called once a frame is encoded. So it may be yes but we don't utilize the real world time when it is called, in this CL. We are updating the rate controller to let it calculate the remaining bandwidth and the proper QP value for next frame. We do the update in `ReadbackBitsstream()` is only because we had to wait until this time to know the size of encoded stream.

      Rafael Cintron

      Thank you for this detailed explanation. Please include a summary of the explanation in either the comment for the member or in the place where you increment it.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Eugene Zemtsov
      • Zhibo Wang
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
      Gerrit-Change-Number: 6073677
      Gerrit-PatchSet: 34
      Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
      Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Comment-Date: Thu, 27 Mar 2025 21:18:43 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Zhibo Wang (Gerrit)

      unread,
      Mar 31, 2025, 3:09:11 AMMar 31
      to Rafael Cintron, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
      Attention needed from Eugene Zemtsov and Rafael Cintron

      Zhibo Wang added 1 comment

      File media/gpu/windows/d3d12_video_encode_h265_delegate.h
      Line 98, Patchset 33: base::TimeDelta rate_controller_timestamp_;
      Rafael Cintron . resolved

      Can you please write a comment detailing what this "timestamp" is used for and how it is calculated? To me, it looks more like a time delta than a "stamp" like base::TimeTicks is.

      Zhibo Wang

      Done. This refers to the timestamp of a frame in the video, which start with 0.

      Rafael Cintron

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure. From the looks of the code, we increment the time delta by the framerate, but only in `D3D12VideoEncodeH265Delegate::ReadbackBitstream`. Is there significance of doing so here and not elsewhere? Is ReadbackBitsstream meant to be a heartbeat of encoding?

      Zhibo Wang

      To make it simple, all we are doing in this CL is to use a software (previously it is done by hardware) rate controller in our encoding procedure, which takes the encoded stream byte size and the timestamp (the one we are talking about) of the current frame as input, and produces the QP value for next frame.

      To me, a timestamp would use the base.TimeTicks data structure, not the base.TimeDelta data structure.

      It makes sense in general coding area, but here we are in media domain, where `timestamp` may be like a term that has special meaning. It stands for the time offset since the start of the video that a frame should be presented at. So the `TimeDelta` means delta to the start of the video, which makes sense to me, while `TimeTicks` is real world time, which don't fit our definition.

      Also, this variable is for `H264RateController`, who accepts a `base::TimeDelta` object which is named as timestamp.
      https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/h264_rate_controller.h;l=502;drc=3ddadc368c8043783e32a3b50c64158cfb8aa42a

      Is ReadbackBitsstream meant to be a heartbeat of encoding?

      `ReadbackBitsstream()` will be called once a frame is encoded. So it may be yes but we don't utilize the real world time when it is called, in this CL. We are updating the rate controller to let it calculate the remaining bandwidth and the proper QP value for next frame. We do the update in `ReadbackBitsstream()` is only because we had to wait until this time to know the size of encoded stream.

      Rafael Cintron

      Thank you for this detailed explanation. Please include a summary of the explanation in either the comment for the member or in the place where you increment it.

      Zhibo Wang

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Eugene Zemtsov
      • Rafael Cintron
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
      Gerrit-Change-Number: 6073677
      Gerrit-PatchSet: 35
      Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
      Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Comment-Date: Mon, 31 Mar 2025 07:09:04 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Rafael Cintron (Gerrit)

      unread,
      Mar 31, 2025, 6:51:58 PMMar 31
      to Zhibo Wang, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
      Attention needed from Eugene Zemtsov and Zhibo Wang

      Rafael Cintron voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Eugene Zemtsov
      • Zhibo Wang
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
      Gerrit-Change-Number: 6073677
      Gerrit-PatchSet: 35
      Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
      Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
      Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
      Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
      Gerrit-Comment-Date: Mon, 31 Mar 2025 22:51:48 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Eugene Zemtsov (Gerrit)

      unread,
      Mar 31, 2025, 10:53:40 PMMar 31
      to Zhibo Wang, Rafael Cintron, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
      Attention needed from Zhibo Wang

      Eugene Zemtsov added 1 comment

      File media/gpu/windows/d3d12_video_encode_h264_delegate.cc
      Line 193, Patchset 35 (Latest): layer_settings.peak_bitrate = bitrate.peak_bps();
      Eugene Zemtsov . unresolved

      peak_bps() isn't supposed to be called with CBR. same in the h265 encoder

      https://source.chromium.org/chromium/chromium/src/+/main:media/base/bitrate.cc;l=33

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Zhibo Wang
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Gerrit-Change-Number: 6073677
        Gerrit-PatchSet: 35
        Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
        Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Comment-Date: Tue, 01 Apr 2025 02:53:30 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Zhibo Wang (Gerrit)

        unread,
        Apr 1, 2025, 4:01:15 AMApr 1
        to Rafael Cintron, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
        Attention needed from Eugene Zemtsov and Rafael Cintron

        Zhibo Wang added 1 comment

        File media/gpu/windows/d3d12_video_encode_h264_delegate.cc
        Line 193, Patchset 35: layer_settings.peak_bitrate = bitrate.peak_bps();
        Eugene Zemtsov . resolved

        peak_bps() isn't supposed to be called with CBR. same in the h265 encoder

        https://source.chromium.org/chromium/chromium/src/+/main:media/base/bitrate.cc;l=33

        Zhibo Wang

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Eugene Zemtsov
        • Rafael Cintron
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Gerrit-Change-Number: 6073677
        Gerrit-PatchSet: 36
        Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
        Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Comment-Date: Tue, 01 Apr 2025 08:01:08 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Eugene Zemtsov <eug...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Rafael Cintron (Gerrit)

        unread,
        Apr 1, 2025, 4:30:59 PMApr 1
        to Zhibo Wang, Chromium LUCI CQ, Pohsiang Hsu, Eugene Zemtsov, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
        Attention needed from Eugene Zemtsov and Zhibo Wang

        Rafael Cintron voted Code-Review+1

        Code-Review+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Eugene Zemtsov
        • Zhibo Wang
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Gerrit-Change-Number: 6073677
        Gerrit-PatchSet: 36
        Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
        Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Reviewer: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Attention: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Comment-Date: Tue, 01 Apr 2025 20:30:48 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Eugene Zemtsov (Gerrit)

        unread,
        Apr 1, 2025, 5:10:05 PMApr 1
        to Zhibo Wang, Eugene Zemtsov, Rafael Cintron, Chromium LUCI CQ, Pohsiang Hsu, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org
        Attention needed from Zhibo Wang

        Eugene Zemtsov voted Code-Review+1

        Code-Review+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Zhibo Wang
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Review
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Gerrit-Change-Number: 6073677
        Gerrit-PatchSet: 36
        Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
        Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Reviewer: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Attention: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Comment-Date: Tue, 01 Apr 2025 21:09:56 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        Apr 2, 2025, 2:45:39 AMApr 2
        to Zhibo Wang, Eugene Zemtsov, Rafael Cintron, Pohsiang Hsu, chromium...@chromium.org, chromeos-gfx-...@google.com, feature-me...@chromium.org, media-cro...@chromium.org, media-wi...@chromium.org

        Chromium LUCI CQ submitted the change

        Change information

        Commit message:
        Use software bitrate control for D3D12 H26x video encoder

        Add support of software bitrate control by calculating per-frame QP
        values using H264RateController and setting CQP in D3D12.
        Bug: 40275246
        Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Reviewed-by: Rafael Cintron <rafael....@microsoft.com>
        Commit-Queue: Zhibo Wang <zhibo...@intel.com>
        Reviewed-by: Eugene Zemtsov <eug...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1441365}
        Files:
        • M media/gpu/windows/d3d12_video_encode_accelerator.cc
        • M media/gpu/windows/d3d12_video_encode_delegate.cc
        • M media/gpu/windows/d3d12_video_encode_delegate.h
        • M media/gpu/windows/d3d12_video_encode_h264_delegate.cc
        • M media/gpu/windows/d3d12_video_encode_h264_delegate.h
        • M media/gpu/windows/d3d12_video_encode_h264_delegate_unittest.cc
        • M media/gpu/windows/d3d12_video_encode_h265_delegate.cc
        • M media/gpu/windows/d3d12_video_encode_h265_delegate.h
        • M media/gpu/windows/d3d12_video_encode_h265_delegate_unittest.cc
        Change size: L
        Delta: 9 files changed, 328 insertions(+), 25 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Rafael Cintron, +1 by Eugene Zemtsov
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I28535abf86eff9cf243baa998cd05dd28812cd65
        Gerrit-Change-Number: 6073677
        Gerrit-PatchSet: 37
        Gerrit-Owner: Zhibo Wang <zhibo...@intel.com>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Eugene Zemtsov <eug...@chromium.org>
        Gerrit-Reviewer: Pohsiang Hsu <poh...@microsoft.com>
        Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
        Gerrit-Reviewer: Zhibo Wang <zhibo...@intel.com>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages