Keep slice data partition NALs in clear
CENCv3 recommends only encrypting video data in slice NALs. Slice data partition NALs should not be encrypted. In the code, differentiate is_vcl and is_video_slice. They are the same for H265; for H264, vcl NALs include slice data partition NALs but video_slice NALs do not. Change-Id: I91f4bdd76d25f0eac50e39aed350ebce3f667121
This commit is contained in:
parent
5c07ff6b1c
commit
c223bc9144
|
@ -79,10 +79,11 @@ bool Nalu::InitializeFromH264(const uint8_t* data, uint64_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_aud_ = type_ == H264_AUD;
|
is_aud_ = type_ == H264_AUD;
|
||||||
is_video_slice_ = (type_ >= Nalu::H264_NonIDRSlice &&
|
is_vcl_ = (type_ >= Nalu::H264_NonIDRSlice && type_ <= Nalu::H264_IDRSlice);
|
||||||
type_ <= Nalu::H264_IDRSlice);
|
is_video_slice_ =
|
||||||
|
(type_ == Nalu::H264_NonIDRSlice || type_ == Nalu::H264_IDRSlice);
|
||||||
can_start_access_unit_ =
|
can_start_access_unit_ =
|
||||||
(is_video_slice_ || type_ == Nalu::H264_AUD || type_ == Nalu::H264_SPS ||
|
(is_vcl_ || type_ == Nalu::H264_AUD || type_ == Nalu::H264_SPS ||
|
||||||
type_ == Nalu::H264_PPS || type_ == Nalu::H264_SEIMessage ||
|
type_ == Nalu::H264_PPS || type_ == Nalu::H264_SEIMessage ||
|
||||||
(type_ >= Nalu::H264_PrefixNALUnit && type_ <= Nalu::H264_Reserved18));
|
(type_ >= Nalu::H264_PrefixNALUnit && type_ <= Nalu::H264_Reserved18));
|
||||||
return true;
|
return true;
|
||||||
|
@ -147,10 +148,11 @@ bool Nalu::InitializeFromH265(const uint8_t* data, uint64_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_aud_ = type_ == H265_AUD;
|
is_aud_ = type_ == H265_AUD;
|
||||||
is_video_slice_ = type_ >= Nalu::H265_TRAIL_N && type_ <= Nalu::H265_CRA_NUT;
|
is_vcl_ = type_ >= Nalu::H265_TRAIL_N && type_ <= Nalu::H265_CRA_NUT;
|
||||||
|
is_video_slice_ = is_vcl_;
|
||||||
can_start_access_unit_ =
|
can_start_access_unit_ =
|
||||||
nuh_layer_id_ == 0 &&
|
nuh_layer_id_ == 0 &&
|
||||||
(is_video_slice_ || type_ == Nalu::H265_AUD || type_ == Nalu::H265_VPS ||
|
(is_vcl_ || type_ == Nalu::H265_AUD || type_ == Nalu::H265_VPS ||
|
||||||
type_ == Nalu::H265_SPS || type_ == Nalu::H265_PPS ||
|
type_ == Nalu::H265_SPS || type_ == Nalu::H265_PPS ||
|
||||||
type_ == Nalu::H265_PREFIX_SEI ||
|
type_ == Nalu::H265_PREFIX_SEI ||
|
||||||
(type_ >= Nalu::H265_RSV_NVCL41 && type_ <= Nalu::H265_RSV_NVCL44) ||
|
(type_ >= Nalu::H265_RSV_NVCL41 && type_ <= Nalu::H265_RSV_NVCL44) ||
|
||||||
|
|
|
@ -111,6 +111,8 @@ class Nalu {
|
||||||
/// return value.
|
/// return value.
|
||||||
int type() const { return type_; }
|
int type() const { return type_; }
|
||||||
bool is_aud() const { return is_aud_; }
|
bool is_aud() const { return is_aud_; }
|
||||||
|
bool is_vcl() const { return is_vcl_; }
|
||||||
|
/// Slice data partition NALs are not considered as slice NALs.
|
||||||
bool is_video_slice() const { return is_video_slice_; }
|
bool is_video_slice() const { return is_video_slice_; }
|
||||||
bool can_start_access_unit() const { return can_start_access_unit_; }
|
bool can_start_access_unit() const { return can_start_access_unit_; }
|
||||||
|
|
||||||
|
@ -132,6 +134,7 @@ class Nalu {
|
||||||
int nuh_temporal_id_ = 0;
|
int nuh_temporal_id_ = 0;
|
||||||
int type_ = 0;
|
int type_ = 0;
|
||||||
bool is_aud_ = false;
|
bool is_aud_ = false;
|
||||||
|
bool is_vcl_ = false;
|
||||||
bool is_video_slice_ = false;
|
bool is_video_slice_ = false;
|
||||||
bool can_start_access_unit_ = false;
|
bool can_start_access_unit_ = false;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool EsParserH265::ProcessNalu(const Nalu& nalu,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if (nalu.is_video_slice() && nalu.nuh_layer_id() == 0) {
|
if (nalu.is_vcl() && nalu.nuh_layer_id() == 0) {
|
||||||
const bool is_key_frame = nalu.type() == Nalu::H265_IDR_W_RADL ||
|
const bool is_key_frame = nalu.type() == Nalu::H265_IDR_W_RADL ||
|
||||||
nalu.type() == Nalu::H265_IDR_N_LP;
|
nalu.type() == Nalu::H265_IDR_N_LP;
|
||||||
DVLOG(LOG_LEVEL_ES) << "Nalu: slice KeyFrame=" << is_key_frame;
|
DVLOG(LOG_LEVEL_ES) << "Nalu: slice KeyFrame=" << is_key_frame;
|
||||||
|
|
|
@ -192,14 +192,14 @@ bool EsParserH26x::ParseInternal() {
|
||||||
next_access_unit_position_ = position;
|
next_access_unit_position_ = position;
|
||||||
}
|
}
|
||||||
RCHECK(ProcessNalu(nalu, &video_slice_info));
|
RCHECK(ProcessNalu(nalu, &video_slice_info));
|
||||||
if (nalu.is_video_slice() && !video_slice_info.valid) {
|
if (nalu.is_vcl() && !video_slice_info.valid) {
|
||||||
// This could happen only if decoder config is not available yet. Drop
|
// This could happen only if decoder config is not available yet. Drop
|
||||||
// this frame.
|
// this frame.
|
||||||
DCHECK(!current_video_slice_info_.valid);
|
DCHECK(!current_video_slice_info_.valid);
|
||||||
next_access_unit_position_set_ = false;
|
next_access_unit_position_set_ = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (nalu.is_video_slice()) {
|
} else if (nalu.is_vcl()) {
|
||||||
// This isn't the first VCL NAL unit. Next access unit should start after
|
// This isn't the first VCL NAL unit. Next access unit should start after
|
||||||
// this NAL unit.
|
// this NAL unit.
|
||||||
next_access_unit_position_set_ = false;
|
next_access_unit_position_set_ = false;
|
||||||
|
|
|
@ -93,7 +93,7 @@ class TestableEsParser : public EsParserH26x {
|
||||||
: (nalu.type() == Nalu::H265_SPS)) {
|
: (nalu.type() == Nalu::H265_SPS)) {
|
||||||
video_slice_info->valid = false;
|
video_slice_info->valid = false;
|
||||||
decoder_config_check_pending_ = true;
|
decoder_config_check_pending_ = true;
|
||||||
} else if (nalu.is_video_slice()) {
|
} else if (nalu.is_vcl()) {
|
||||||
video_slice_info->valid = true;
|
video_slice_info->valid = true;
|
||||||
// This should be the same as EsParserH26x::ProcessNalu.
|
// This should be the same as EsParserH26x::ProcessNalu.
|
||||||
if (codec_type_ == Nalu::kH264) {
|
if (codec_type_ == Nalu::kH264) {
|
||||||
|
|
Loading…
Reference in New Issue