Skip to content

Commit

Permalink
media/gpu/v4l2: rename V4L2H264Accelerator to V4L2ChromiumH264Acceler…
Browse files Browse the repository at this point in the history
…ator

The H.264 kernel ABI we were using so far has been designed for Chromium
and did not correspond to anything official upstream. Now that the
official H.264 interface has landed and we are going to support it,
rename our own implementation so the official ABI can take its name.

BUG=b:149437087
TEST=Chromium builds and decodes accelerated H.264 on Kukui.

Change-Id: I3955b82c704fa4465f093c89ae702cd9abbe3ee9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2717275
Reviewed-by: Fritz Koenig <frkoenig@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#857535}
  • Loading branch information
Gnurou authored and Chromium LUCI CQ committed Feb 25, 2021
1 parent e17adab commit 2ff000c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions media/gpu/v4l2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ source_set("v4l2") {
"v4l2_device.h",
"v4l2_device_poller.cc",
"v4l2_device_poller.h",
"v4l2_h264_accelerator.cc",
"v4l2_h264_accelerator.h",
"v4l2_h264_accelerator_chromium.cc",
"v4l2_h264_accelerator_chromium.h",
"v4l2_h264_accelerator_legacy.cc",
"v4l2_h264_accelerator_legacy.h",
"v4l2_image_processor_backend.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/gpu/v4l2/v4l2_h264_accelerator.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator_chromium.h"

// TODO(987856): prevent legacy headers being included from videodev2.h until
// v4.14
Expand Down Expand Up @@ -49,7 +49,7 @@ class V4L2H264Picture : public H264Picture {
DISALLOW_COPY_AND_ASSIGN(V4L2H264Picture);
};

V4L2H264Accelerator::V4L2H264Accelerator(
V4L2ChromiumH264Accelerator::V4L2ChromiumH264Accelerator(
V4L2DecodeSurfaceHandler* surface_handler,
V4L2Device* device)
: num_slices_(0),
Expand All @@ -59,9 +59,9 @@ V4L2H264Accelerator::V4L2H264Accelerator(
DCHECK(surface_handler_);
}

V4L2H264Accelerator::~V4L2H264Accelerator() {}
V4L2ChromiumH264Accelerator::~V4L2ChromiumH264Accelerator() {}

scoped_refptr<H264Picture> V4L2H264Accelerator::CreateH264Picture() {
scoped_refptr<H264Picture> V4L2ChromiumH264Accelerator::CreateH264Picture() {
scoped_refptr<V4L2DecodeSurface> dec_surface =
surface_handler_->CreateSurface();
if (!dec_surface)
Expand All @@ -70,7 +70,7 @@ scoped_refptr<H264Picture> V4L2H264Accelerator::CreateH264Picture() {
return new V4L2H264Picture(dec_surface);
}

void V4L2H264Accelerator::H264PictureListToDPBIndicesList(
void V4L2ChromiumH264Accelerator::H264PictureListToDPBIndicesList(
const H264Picture::Vector& src_pic_list,
uint8_t dst_list[kDPBIndicesListSize]) {
size_t i;
Expand All @@ -83,7 +83,7 @@ void V4L2H264Accelerator::H264PictureListToDPBIndicesList(
dst_list[i++] = VIDEO_MAX_FRAME;
}

void V4L2H264Accelerator::H264DPBToV4L2DPB(
void V4L2ChromiumH264Accelerator::H264DPBToV4L2DPB(
const H264DPB& dpb,
std::vector<scoped_refptr<V4L2DecodeSurface>>* ref_surfaces) {
memset(priv_->v4l2_decode_param.dpb, 0, sizeof(priv_->v4l2_decode_param.dpb));
Expand Down Expand Up @@ -113,7 +113,7 @@ void V4L2H264Accelerator::H264DPBToV4L2DPB(
}
}

H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitFrameMetadata(
H264Decoder::H264Accelerator::Status V4L2ChromiumH264Accelerator::SubmitFrameMetadata(
const H264SPS* sps,
const H264PPS* pps,
const H264DPB& dpb,
Expand Down Expand Up @@ -298,7 +298,7 @@ H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitFrameMetadata(
return Status::kOk;
}

H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitSlice(
H264Decoder::H264Accelerator::Status V4L2ChromiumH264Accelerator::SubmitSlice(
const H264PPS* pps,
const H264SliceHeader* slice_hdr,
const H264Picture::Vector& ref_pic_list0,
Expand Down Expand Up @@ -423,7 +423,7 @@ H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitSlice(
: Status::kFail;
}

H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitDecode(
H264Decoder::H264Accelerator::Status V4L2ChromiumH264Accelerator::SubmitDecode(
scoped_refptr<H264Picture> pic) {
scoped_refptr<V4L2DecodeSurface> dec_surface =
H264PictureToV4L2DecodeSurface(pic.get());
Expand Down Expand Up @@ -467,22 +467,22 @@ H264Decoder::H264Accelerator::Status V4L2H264Accelerator::SubmitDecode(
return Status::kOk;
}

bool V4L2H264Accelerator::OutputPicture(scoped_refptr<H264Picture> pic) {
bool V4L2ChromiumH264Accelerator::OutputPicture(scoped_refptr<H264Picture> pic) {
// TODO(crbug.com/647725): Insert correct color space.
surface_handler_->SurfaceReady(H264PictureToV4L2DecodeSurface(pic.get()),
pic->bitstream_id(), pic->visible_rect(),
VideoColorSpace());
return true;
}

void V4L2H264Accelerator::Reset() {
void V4L2ChromiumH264Accelerator::Reset() {
num_slices_ = 0;
memset(&priv_->v4l2_decode_param, 0, sizeof(priv_->v4l2_decode_param));
memset(&priv_->v4l2_slice_params, 0, sizeof(priv_->v4l2_slice_params));
}

scoped_refptr<V4L2DecodeSurface>
V4L2H264Accelerator::H264PictureToV4L2DecodeSurface(H264Picture* pic) {
V4L2ChromiumH264Accelerator::H264PictureToV4L2DecodeSurface(H264Picture* pic) {
V4L2H264Picture* v4l2_pic = pic->AsV4L2H264Picture();
CHECK(v4l2_pic);
return v4l2_pic->dec_surface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_H_
#define MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_H_
#ifndef MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_CHROMIUM_H_
#define MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_CHROMIUM_H_

#include <memory>
#include <vector>
Expand All @@ -20,13 +20,14 @@ class V4L2DecodeSurface;
class V4L2DecodeSurfaceHandler;
struct V4L2H264AcceleratorPrivate;

class V4L2H264Accelerator : public H264Decoder::H264Accelerator {
// H.264 accelerator supported the old Chromium-only ABI with the kernel.
class V4L2ChromiumH264Accelerator : public H264Decoder::H264Accelerator {
public:
using Status = H264Decoder::H264Accelerator::Status;

explicit V4L2H264Accelerator(V4L2DecodeSurfaceHandler* surface_handler,
explicit V4L2ChromiumH264Accelerator(V4L2DecodeSurfaceHandler* surface_handler,
V4L2Device* device);
~V4L2H264Accelerator() override;
~V4L2ChromiumH264Accelerator() override;

// H264Decoder::H264Accelerator implementation.
scoped_refptr<H264Picture> CreateH264Picture() override;
Expand Down Expand Up @@ -69,9 +70,9 @@ class V4L2H264Accelerator : public H264Decoder::H264Accelerator {
// outside of the compilation unit.
const std::unique_ptr<V4L2H264AcceleratorPrivate> priv_;

DISALLOW_COPY_AND_ASSIGN(V4L2H264Accelerator);
DISALLOW_COPY_AND_ASSIGN(V4L2ChromiumH264Accelerator);
};

} // namespace media

#endif // MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_H_
#endif // MEDIA_GPU_V4L2_V4L2_H264_ACCELERATOR_CHROMIUM_H_
4 changes: 2 additions & 2 deletions media/gpu/v4l2/v4l2_slice_video_decode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "media/gpu/chromeos/platform_video_frame_utils.h"
#include "media/gpu/macros.h"
#include "media/gpu/v4l2/v4l2_decode_surface.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator_chromium.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator_legacy.h"
#include "media/gpu/v4l2/v4l2_image_processor_backend.h"
#include "media/gpu/v4l2/v4l2_vda_helpers.h"
Expand Down Expand Up @@ -295,7 +295,7 @@ bool V4L2SliceVideoDecodeAccelerator::Initialize(const Config& config,
if (video_profile_ >= H264PROFILE_MIN && video_profile_ <= H264PROFILE_MAX) {
if (supports_requests_) {
decoder_ = std::make_unique<H264Decoder>(
std::make_unique<V4L2H264Accelerator>(this, device_.get()),
std::make_unique<V4L2ChromiumH264Accelerator>(this, device_.get()),
video_profile_);
} else {
decoder_ = std::make_unique<H264Decoder>(
Expand Down
4 changes: 2 additions & 2 deletions media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
#include "media/gpu/macros.h"
#include "media/gpu/v4l2/v4l2_device.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator_chromium.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator_legacy.h"
#include "media/gpu/v4l2/v4l2_vp8_accelerator.h"
#include "media/gpu/v4l2/v4l2_vp8_accelerator_legacy.h"
Expand Down Expand Up @@ -646,7 +646,7 @@ bool V4L2StatelessVideoDecoderBackend::CreateAvd() {
if (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) {
if (input_queue_->SupportsRequests()) {
avd_ = std::make_unique<H264Decoder>(
std::make_unique<V4L2H264Accelerator>(this, device_.get()), profile_);
std::make_unique<V4L2ChromiumH264Accelerator>(this, device_.get()), profile_);
} else {
avd_ = std::make_unique<H264Decoder>(
std::make_unique<V4L2LegacyH264Accelerator>(this, device_.get()),
Expand Down

0 comments on commit 2ff000c

Please sign in to comment.