New issue
Advanced search Search tips

Issue 865302 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Closed: Sep 19
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Feature



Sign in to add a comment

VideoEncodeAccelerator: check profile/level validity on parameter change request

Project Member Reported by johnylin@chromium.org, Jul 19

Issue description

The validity check basically is invloved with profile, level, video_size, bitrate and framerate.
In AVC encoding, each profile+level specifies the constraints of maximum video_size, framerate and bitrate that a decoder may use.
https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels

We need to add validity check in VideoEncodeAccelerator implementation on each parameter change request to avoid invalid setting for demanding profile+level.
 
Per offline discussion, the profile/level validity check should be taken place on H264Encoder::Initialize() [1] which would fail on initialization of VaapiVideoEncodeAccelerator if the parameter set violates the limit of requested profile/level [2].

As for V4L2, the check relies on driver itself while writing ext_controls into it about profile/level in InitControls() [3].

[1] https://cs.chromium.org/chromium/src/media/gpu/vaapi/h264_encoder.cc?type=cs&g=0&l=62
[2] https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
[3] https://cs.chromium.org/chromium/src/media/gpu/v4l2/v4l2_video_encode_accelerator.cc?type=cs&g=0&l=1192
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2d8542270aca3296d2308b0fd8133938a12d768e

commit 2d8542270aca3296d2308b0fd8133938a12d768e
Author: Pin-chih Lin <johnylin@chromium.org>
Date: Fri Sep 07 08:44:10 2018

media: configure h264 encode level and check initial params validity

Initial config has both profile and H264 level now, we then apply the
configuration by passing to H264 encoder class for VAVEA, and setting up
v4l2 controls for V4L2VEA, rather than using fixed profile and level in
the past.

According to H264 spec, there are limitations for
framerate/bitrate/framesize combinations as the requested level, and we
may want to fail initization for excessive configuration. For VAVEA, we
add the check on H264Encoder::Initialize(). For V4L2VEA, we will let
driver judge the legality on configuration.

In video_encode_accelerator_unittest, a new property requested_h264_level
is added to test_stream to specify requested level, and ForceH264Level
test for checking output level meets expectation.

BUG= 863327 
BUG= 865302 
TEST=build, deploy Chrome, and run video_encoder_accelerator_unittest on Eve
TEST=build, deploy Chrome, and run video_encoder_accelerator_unittest on Elm

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I003a4f5c1c8ef149ace3dd2ad18aebd84f60dd0c
Reviewed-on: https://chromium-review.googlesource.com/1209883
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589466}
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/h264_decoder.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/v4l2/v4l2_device.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/v4l2/v4l2_device.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/v4l2/v4l2_video_encode_accelerator.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/accelerated_video_encoder.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/h264_encoder.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/h264_encoder.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/vaapi_video_encode_accelerator.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/vp8_encoder.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/gpu/vaapi/vp8_encoder.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/BUILD.gn
[add] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/h264_level_limits.cc
[add] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/h264_level_limits.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/h264_parser.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/h264_parser.h
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/video_encode_accelerator.cc
[modify] https://crrev.com/2d8542270aca3296d2308b0fd8133938a12d768e/media/video/video_encode_accelerator.h

Status: Fixed (was: Started)

Sign in to add a comment