Merge branch 'main' into cmake

This commit is contained in:
Cosmin Stejerean 2023-09-03 10:01:08 -07:00
commit 274c885253
7 changed files with 38 additions and 29 deletions

View File

@ -23,7 +23,8 @@ jobs:
- name: Update Issues - name: Update Issues
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use SHAKA_BOT_TOKEN if found, otherwise the default GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.SHAKA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
run: | run: |
cd update-issues cd update-issues
npm ci npm ci

View File

@ -1,19 +1,11 @@
name: Validate PR Title name: Validate PR Title
# We recommend that maintainers use this Chrome/Firefox extension so that
# squashed PRs will have the merged commit message default to the PR title and
# description: https://github.com/zachwhaley/squashed-merge-message
#
# This avoids the need to amend commits after the fact to match the desired PR
# syntax. As long as the PR itself is properly-formatted, this extension will
# help you commit the right format to the repo, too. This, in turn, feeds the
# changelog and release workflows.
on: on:
# NOTE: The automated PRs from release-please-action do not seem to trigger # NOTE: The automated PRs from release-please-action do not seem to trigger
# any of the default PR triggers (opened, synchronize, reopened). So we need # any of the default PR triggers (opened, synchronize, reopened). So we need
# additional types. This is a good set that makes it easy to trigger the # additional types. This is a good set that makes it easy to trigger the
# workflow manually if needed. # workflow manually if needed. This is not neccessary if your release-please
# workflow uses a personal access token (PAT) from Shaka Bot.
pull_request_target: pull_request_target:
types: types:
- opened - opened
@ -30,6 +22,6 @@ jobs:
name: Validate PR Title name: Validate PR Title
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: amannn/action-semantic-pull-request@v4 - uses: amannn/action-semantic-pull-request@v5
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -69,6 +69,7 @@ class VideoStreamInfo : public StreamInfo {
uint32_t trick_play_factor() const { return trick_play_factor_; } uint32_t trick_play_factor() const { return trick_play_factor_; }
uint32_t playback_rate() const { return playback_rate_; } uint32_t playback_rate() const { return playback_rate_; }
const std::vector<uint8_t>& eme_init_data() const { return eme_init_data_; } const std::vector<uint8_t>& eme_init_data() const { return eme_init_data_; }
const std::vector<uint8_t>& colr_data() const { return colr_data_; }
void set_extra_config(const std::vector<uint8_t>& extra_config) { void set_extra_config(const std::vector<uint8_t>& extra_config) {
extra_config_ = extra_config; extra_config_ = extra_config;
@ -90,6 +91,9 @@ class VideoStreamInfo : public StreamInfo {
size_t eme_init_data_size) { size_t eme_init_data_size) {
eme_init_data_.assign(eme_init_data, eme_init_data + eme_init_data_size); eme_init_data_.assign(eme_init_data, eme_init_data + eme_init_data_size);
} }
void set_colr_data(const uint8_t* colr_data, size_t colr_data_size) {
colr_data_.assign(colr_data, colr_data + colr_data_size);
}
private: private:
// Extra codec configuration in a stream of mp4 boxes. It is only applicable // Extra codec configuration in a stream of mp4 boxes. It is only applicable
@ -128,6 +132,9 @@ class VideoStreamInfo : public StreamInfo {
// https://w3c.github.io/encrypted-media/#initialization-data. // https://w3c.github.io/encrypted-media/#initialization-data.
std::vector<uint8_t> eme_init_data_; std::vector<uint8_t> eme_init_data_;
// Raw colr atom data. It is only applicable to the mp4 container.
std::vector<uint8_t> colr_data_;
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
// generated copy constructor and assignment operator. Since the extra data is // generated copy constructor and assignment operator. Since the extra data is
// typically small, the performance impact is minimal. // typically small, the performance impact is minimal.

View File

@ -1472,29 +1472,33 @@ FourCC ColorParameters::BoxType() const {
} }
bool ColorParameters::ReadWriteInternal(BoxBuffer* buffer) { bool ColorParameters::ReadWriteInternal(BoxBuffer* buffer) {
if (buffer->reader()) { if (buffer->Reading()) {
RCHECK((buffer->reader())->ReadFourCC(&color_parameter_type) && BoxReader* reader = buffer->reader();
(buffer->reader())->Read2(&color_primaries) && DCHECK(reader);
(buffer->reader())->Read2(&transfer_characteristics) &&
(buffer->reader())->Read2(&matrix_coefficients)); // Parse and store the raw box for colr atom preservation in the output mp4.
raw_box.assign(reader->data(), reader->data() + reader->size());
// Parse individual parameters for full codec string formation.
RCHECK(reader->ReadFourCC(&color_parameter_type) &&
reader->Read2(&color_primaries) &&
reader->Read2(&transfer_characteristics) &&
reader->Read2(&matrix_coefficients));
// Type nclc does not contain video_full_range_flag data, and thus, it has 1 // Type nclc does not contain video_full_range_flag data, and thus, it has 1
// less byte than nclx. Only extract video_full_range_flag if of type nclx. // less byte than nclx. Only extract video_full_range_flag if of type nclx.
if (color_parameter_type == FOURCC_nclx) { if (color_parameter_type == FOURCC_nclx) {
RCHECK((buffer->reader())->Read1(&video_full_range_flag)); RCHECK(reader->Read1(&video_full_range_flag));
} }
} else {
// When writing, only need to write the raw_box.
DCHECK(!raw_box.empty());
buffer->writer()->AppendVector(raw_box);
} }
// TODO(caitlinocallaghan) Add the ability to write the colr atom and include
// it in the muxed mp4.
return true; return true;
} }
size_t ColorParameters::ComputeSizeInternal() { size_t ColorParameters::ComputeSizeInternal() {
// This box is optional. Skip it if it is not initialized. return raw_box.size();
if (color_parameter_type == FOURCC_NULL)
return 0;
return HeaderSize() + kFourCCSize + sizeof(color_primaries) +
sizeof(transfer_characteristics) + sizeof(matrix_coefficients) +
sizeof(video_full_range_flag);
} }
PixelAspectRatio::PixelAspectRatio() = default; PixelAspectRatio::PixelAspectRatio() = default;
@ -1654,9 +1658,10 @@ size_t VideoSampleEntry::ComputeSizeInternal() {
size_t size = HeaderSize() + sizeof(data_reference_index) + sizeof(width) + size_t size = HeaderSize() + sizeof(data_reference_index) + sizeof(width) +
sizeof(height) + sizeof(kVideoResolution) * 2 + sizeof(height) + sizeof(kVideoResolution) * 2 +
sizeof(kVideoFrameCount) + sizeof(kVideoDepth) + sizeof(kVideoFrameCount) + sizeof(kVideoDepth) +
pixel_aspect.ComputeSize() + sinf.ComputeSize() + colr.ComputeSize() + pixel_aspect.ComputeSize() +
codec_configuration.ComputeSize() + kCompressorNameSize + 6 + sinf.ComputeSize() + codec_configuration.ComputeSize() +
4 + 16 + 2; // 6 + 4 bytes reserved, 16 + 2 bytes predefined. kCompressorNameSize + 6 + 4 + 16 +
2; // 6 + 4 bytes reserved, 16 + 2 bytes predefined.
for (CodecConfiguration& codec_config : extra_codec_configs) for (CodecConfiguration& codec_config : extra_codec_configs)
size += codec_config.ComputeSize(); size += codec_config.ComputeSize();
return size; return size;

View File

@ -276,6 +276,7 @@ struct ColorParameters : Box {
uint16_t transfer_characteristics = 1; uint16_t transfer_characteristics = 1;
uint16_t matrix_coefficients = 1; uint16_t matrix_coefficients = 1;
uint8_t video_full_range_flag = 0; uint8_t video_full_range_flag = 0;
std::vector<uint8_t> raw_box;
}; };
struct PixelAspectRatio : Box { struct PixelAspectRatio : Box {

View File

@ -725,6 +725,8 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
0, // trick_play_factor 0, // trick_play_factor
nalu_length_size, track->media.header.language.code, is_encrypted)); nalu_length_size, track->media.header.language.code, is_encrypted));
video_stream_info->set_extra_config(entry.ExtraCodecConfigsAsVector()); video_stream_info->set_extra_config(entry.ExtraCodecConfigsAsVector());
video_stream_info->set_colr_data((entry.colr.raw_box).data(),
(entry.colr.raw_box).size());
// Set pssh raw data if it has. // Set pssh raw data if it has.
if (moov_->pssh.size() > 0) { if (moov_->pssh.size() > 0) {

View File

@ -431,6 +431,7 @@ bool MP4Muxer::GenerateVideoTrak(const VideoStreamInfo* video_info,
CodecToFourCC(video_info->codec(), video_info->h26x_stream_format()); CodecToFourCC(video_info->codec(), video_info->h26x_stream_format());
video.width = video_info->width(); video.width = video_info->width();
video.height = video_info->height(); video.height = video_info->height();
video.colr.raw_box = video_info->colr_data();
video.codec_configuration.data = video_info->codec_config(); video.codec_configuration.data = video_info->codec_config();
if (!video.ParseExtraCodecConfigsVector(video_info->extra_config())) { if (!video.ParseExtraCodecConfigsVector(video_info->extra_config())) {
LOG(ERROR) << "Malformed extra codec configs: " LOG(ERROR) << "Malformed extra codec configs: "