2017-05-24 10:00:16 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
2017-05-24 10:00:16 -07:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/bit_buffer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/logging.h"
|
2017-06-06 23:41:44 -07:00
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
#define RETURN_FALSE_IF_ERROR(x) \
|
|
|
|
|
if (!(x)) { \
|
|
|
|
|
return false; \
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
namespace vp9 {
|
|
|
|
|
namespace {
|
|
|
|
|
const size_t kVp9NumRefsPerFrame = 3;
|
|
|
|
|
const size_t kVp9MaxRefLFDeltas = 4;
|
|
|
|
|
const size_t kVp9MaxModeLFDeltas = 2;
|
|
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
bool Vp9ReadProfile(rtc::BitBuffer* br, uint8_t* profile) {
|
|
|
|
|
uint32_t high_bit;
|
|
|
|
|
uint32_t low_bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&low_bit, 1));
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&high_bit, 1));
|
|
|
|
|
*profile = (high_bit << 1) + low_bit;
|
|
|
|
|
if (*profile > 2) {
|
|
|
|
|
uint32_t reserved_bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&reserved_bit, 1));
|
|
|
|
|
if (reserved_bit) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. Unsupported bitstream profile.";
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Vp9ReadSyncCode(rtc::BitBuffer* br) {
|
|
|
|
|
uint32_t sync_code;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&sync_code, 24));
|
|
|
|
|
if (sync_code != 0x498342) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. Invalid sync code.";
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
bool Vp9ReadColorConfig(rtc::BitBuffer* br, uint8_t profile) {
|
|
|
|
|
if (profile == 2 || profile == 3) {
|
|
|
|
|
// Bitdepth.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(1));
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t color_space;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&color_space, 3));
|
2017-05-24 10:00:16 -07:00
|
|
|
|
|
|
|
|
// SRGB is 7.
|
|
|
|
|
if (color_space != 7) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
// YUV range flag.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(1));
|
2017-05-24 10:00:16 -07:00
|
|
|
if (profile == 1 || profile == 3) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
// 1 bit: subsampling x.
|
|
|
|
|
// 1 bit: subsampling y.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(2));
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t reserved_bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&reserved_bit, 1));
|
|
|
|
|
if (reserved_bit) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. Reserved bit set.";
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (profile == 1 || profile == 3) {
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t reserved_bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&reserved_bit, 1));
|
|
|
|
|
if (reserved_bit) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. Reserved bit set.";
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. 4:4:4 color not supported in "
|
|
|
|
|
"profile 0 or 2.";
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
bool Vp9ReadFrameSize(rtc::BitBuffer* br) {
|
|
|
|
|
// 2 bytes: frame width.
|
|
|
|
|
// 2 bytes: frame height.
|
|
|
|
|
return br->ConsumeBytes(4);
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
bool Vp9ReadRenderSize(rtc::BitBuffer* br) {
|
|
|
|
|
uint32_t bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&bit, 1));
|
|
|
|
|
if (bit) {
|
|
|
|
|
// 2 bytes: render width.
|
|
|
|
|
// 2 bytes: render height.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBytes(4));
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
2017-06-06 23:41:44 -07:00
|
|
|
return true;
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
bool Vp9ReadFrameSizeFromRefs(rtc::BitBuffer* br) {
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t found_ref = 0;
|
2017-05-24 10:00:16 -07:00
|
|
|
for (size_t i = 0; i < kVp9NumRefsPerFrame; i++) {
|
|
|
|
|
// Size in refs.
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&found_ref, 1));
|
2017-05-24 10:00:16 -07:00
|
|
|
if (found_ref)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
if (!found_ref) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadFrameSize(br)) {
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
return Vp9ReadRenderSize(br);
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
bool Vp9ReadInterpolationFilter(rtc::BitBuffer* br) {
|
|
|
|
|
uint32_t bit;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&bit, 1));
|
|
|
|
|
if (bit)
|
|
|
|
|
return true;
|
2017-05-24 10:00:16 -07:00
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
return br->ConsumeBits(2);
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
bool Vp9ReadLoopfilter(rtc::BitBuffer* br) {
|
|
|
|
|
// 6 bits: filter level.
|
|
|
|
|
// 3 bits: sharpness level.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(9));
|
|
|
|
|
|
|
|
|
|
uint32_t mode_ref_delta_enabled;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&mode_ref_delta_enabled, 1));
|
2017-05-24 10:00:16 -07:00
|
|
|
if (mode_ref_delta_enabled) {
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t mode_ref_delta_update;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&mode_ref_delta_update, 1));
|
2017-05-24 10:00:16 -07:00
|
|
|
if (mode_ref_delta_update) {
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t bit;
|
2017-05-24 10:00:16 -07:00
|
|
|
for (size_t i = 0; i < kVp9MaxRefLFDeltas; i++) {
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&bit, 1));
|
|
|
|
|
if (bit) {
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(7));
|
|
|
|
|
}
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
for (size_t i = 0; i < kVp9MaxModeLFDeltas; i++) {
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br->ReadBits(&bit, 1));
|
|
|
|
|
if (bit) {
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br->ConsumeBits(7));
|
|
|
|
|
}
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-06 23:41:44 -07:00
|
|
|
return true;
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
2017-06-06 23:41:44 -07:00
|
|
|
} // namespace
|
2017-05-24 10:00:16 -07:00
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
bool GetQp(const uint8_t* buf, size_t length, int* qp) {
|
2017-06-06 23:41:44 -07:00
|
|
|
rtc::BitBuffer br(buf, length);
|
2017-05-24 10:00:16 -07:00
|
|
|
|
|
|
|
|
// Frame marker.
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t frame_marker;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&frame_marker, 2));
|
|
|
|
|
if (frame_marker != 0x2) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to get QP. Frame marker should be 2.";
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Profile.
|
2017-06-06 23:41:44 -07:00
|
|
|
uint8_t profile;
|
|
|
|
|
if (!Vp9ReadProfile(&br, &profile))
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Show existing frame.
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t show_existing_frame;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&show_existing_frame, 1));
|
|
|
|
|
if (show_existing_frame)
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Frame type: KEY_FRAME(0), INTER_FRAME(1).
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t frame_type;
|
|
|
|
|
uint32_t show_frame;
|
|
|
|
|
uint32_t error_resilient;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&frame_type, 1));
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&show_frame, 1));
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&error_resilient, 1));
|
2017-05-24 10:00:16 -07:00
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!frame_type) {
|
2017-06-06 23:41:44 -07:00
|
|
|
if (!Vp9ReadSyncCode(&br))
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadColorConfig(&br, profile))
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadFrameSize(&br))
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadRenderSize(&br))
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
} else {
|
2017-06-06 23:41:44 -07:00
|
|
|
uint32_t intra_only = 0;
|
2017-05-24 10:00:16 -07:00
|
|
|
if (!show_frame)
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadBits(&intra_only, 1));
|
2017-05-24 10:00:16 -07:00
|
|
|
if (!error_resilient)
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(2)); // Reset frame context.
|
2017-05-24 10:00:16 -07:00
|
|
|
|
|
|
|
|
if (intra_only) {
|
2017-06-06 23:41:44 -07:00
|
|
|
if (!Vp9ReadSyncCode(&br))
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
2017-06-06 23:41:44 -07:00
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
if (profile > 0) {
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadColorConfig(&br, profile))
|
2017-05-24 10:00:16 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Refresh frame flags.
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(8));
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadFrameSize(&br))
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadRenderSize(&br))
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
2017-05-24 10:00:16 -07:00
|
|
|
} else {
|
|
|
|
|
// Refresh frame flags.
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(8));
|
2017-05-24 10:00:16 -07:00
|
|
|
|
|
|
|
|
for (size_t i = 0; i < kVp9NumRefsPerFrame; i++) {
|
2017-06-06 23:41:44 -07:00
|
|
|
// 3 bits: Ref frame index.
|
|
|
|
|
// 1 bit: Ref frame sign biases.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(4));
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
if (!Vp9ReadFrameSizeFromRefs(&br))
|
2017-06-06 23:41:44 -07:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
// Allow high precision mv.
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(1));
|
2017-05-24 10:00:16 -07:00
|
|
|
// Interpolation filter.
|
2017-06-06 23:41:44 -07:00
|
|
|
if (!Vp9ReadInterpolationFilter(&br))
|
|
|
|
|
return false;
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!error_resilient) {
|
2017-06-06 23:41:44 -07:00
|
|
|
// 1 bit: Refresh frame context.
|
|
|
|
|
// 1 bit: Frame parallel decoding mode.
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(2));
|
2017-05-24 10:00:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Frame context index.
|
2017-06-06 23:41:44 -07:00
|
|
|
RETURN_FALSE_IF_ERROR(br.ConsumeBits(2));
|
2017-05-24 10:00:16 -07:00
|
|
|
|
2017-06-06 23:41:44 -07:00
|
|
|
if (!Vp9ReadLoopfilter(&br))
|
|
|
|
|
return false;
|
2017-05-24 10:00:16 -07:00
|
|
|
|
|
|
|
|
// Base QP.
|
2017-06-06 23:41:44 -07:00
|
|
|
uint8_t base_q0;
|
|
|
|
|
RETURN_FALSE_IF_ERROR(br.ReadUInt8(&base_q0));
|
2017-05-24 10:00:16 -07:00
|
|
|
*qp = base_q0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
VP9 decoder: Sets thread count based on resolution, reinit on change.
Previously, number of decoder threads for VP9 were always set to 8 but
with a cap at number of cores. This was done since we "can't know" the
resolution that will be used.
With this change, we now intialize the number of threads based on
resolution given in InitDecode(). If a resolution change happens in
flight, it requires a keyframe. We therefore parse the header from
any key frame and if it has a new resolution, we re-initialize the
decoder.
The number of threads used is based on pixel count. We set one thread
as target for 1280x720, and scale up lineraly from there. The 8-thread
cap is gone, but still limit it core count.
This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
Bug: webrtc:11551
Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31507}
2020-06-11 18:24:22 +02:00
|
|
|
} // namespace vp9
|
Revert "VP9 decoder: Sets thread count based on resolution, reinit on change."
This reverts commit d5925756980f6e82a55f57532c8d855e954459fb.
Reason for revert: May cause crashes.
Original change's description:
> VP9 decoder: Sets thread count based on resolution, reinit on change.
>
> Previously, number of decoder threads for VP9 were always set to 8 but
> with a cap at number of cores. This was done since we "can't know" the
> resolution that will be used.
>
> With this change, we now intialize the number of threads based on
> resolution given in InitDecode(). If a resolution change happens in
> flight, it requires a keyframe. We therefore parse the header from
> any key frame and if it has a new resolution, we re-initialize the
> decoder.
>
> The number of threads used is based on pixel count. We set one thread
> as target for 1280x720, and scale up lineraly from there. The 8-thread
> cap is gone, but still limit it core count.
>
> This means for instance: 1 <= 720p, 2 for 1080p, 4 for 1440p, 9 for 4K.
>
> Bug: webrtc:11551
> Change-Id: I14c169a6c651c50bd1b870c4b22bc4495c8448fd
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174460
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31507}
TBR=ilnik@webrtc.org,sprang@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11551
Change-Id: Id235c8ded83b3e1fc1d132c8f56c9f20001f6f22
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177242
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31521}
2020-06-15 08:43:22 +00:00
|
|
|
|
2017-05-24 10:00:16 -07:00
|
|
|
} // namespace webrtc
|