Commit 764fb8c8 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu: simplify Vp9ReferenceFrameVector

This CL cleans up the code in said class and applies Chromium style.
vp9_reference_frame_vector.h file:
- Removes a a prescriptive class comment, instead uses a
descriptive one.
- Removes closed TODO from class documentation.

vp9_reference_frame_vector.cc file:
- Uses =default for destructor instead of {}
- Uses a std::bitset<> instead of bit shifting and testing,
which is error prone and more verbose.
- Uses std::fill() instead of an explicit for loop.

Comments are supposed to be in descriptive style ("uses")
and not imperative ("use"):
> These comments should open with descriptive verbs in the indicative mood ("Opens the file") rather than verbs in the imperative ("Open the file").

https://google.github.io/styleguide/cppguide.html#Function_Comments

Also fixed orthographic and grammar mistakes where applicable.

Change-Id: Ie78e2fbad5f3317e2c291127ac678360ce96d625
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207749
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771134}
parent b205720e
......@@ -12,32 +12,26 @@ Vp9ReferenceFrameVector::Vp9ReferenceFrameVector() {
DETACH_FROM_SEQUENCE(sequence_checker_);
}
Vp9ReferenceFrameVector::~Vp9ReferenceFrameVector() {}
Vp9ReferenceFrameVector::~Vp9ReferenceFrameVector() = default;
// Refresh the reference frame buffer slots with current frame
// based on refresh_frame_flags set in the frame_hdr.
// Refreshes |reference_frames_| slots with the current |pic|s frame header.
void Vp9ReferenceFrameVector::Refresh(scoped_refptr<VP9Picture> pic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(pic);
const auto& frame_hdr = pic->frame_hdr;
const std::bitset<kVp9NumRefFrames> refresh_frame_flags(
pic->frame_hdr->refresh_frame_flags);
for (size_t i = 0, mask = frame_hdr->refresh_frame_flags; mask;
mask >>= 1, ++i) {
if (mask & 1)
for (size_t i = 0; i < kVp9NumRefFrames; ++i) {
if (refresh_frame_flags[i])
reference_frames_[i] = pic;
}
}
void Vp9ReferenceFrameVector::Clear() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
for (auto& f : reference_frames_)
f = nullptr;
reference_frames_.fill(nullptr);
}
// VP9 can maintains up to eight active reference frames and each
// frame can use up to three reference frames from this list.
// GetFrame will return the reference frame placed in reference_frames_[index]
scoped_refptr<VP9Picture> Vp9ReferenceFrameVector::GetFrame(
size_t index) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -15,9 +15,8 @@ namespace media {
class VP9Picture;
// class to share reference frame management code
// between encoder and decoder classes.
// TODO(crbug.com/924804): Add the support in Decoder class.
// This class encapsulates VP9-specific reference frame management code. This
// class is thread afine.
class Vp9ReferenceFrameVector {
public:
Vp9ReferenceFrameVector();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment