Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DASH): Add video transfer characteristics. #1210

Merged
merged 11 commits into from
Sep 8, 2023

Conversation

sr1990
Copy link
Contributor

@sr1990 sr1990 commented May 27, 2023

This PR is related to #1035

@sr1990 sr1990 changed the title feat(DASH):Add video transfer characteristics. feat(DASH): Add video transfer characteristics. May 27, 2023
packager/mpd/base/period.cc Outdated Show resolved Hide resolved
packager/mpd/base/mpd_utils.cc Show resolved Hide resolved
packager/mpd/base/mpd_utils.cc Outdated Show resolved Hide resolved
@joeyparrish joeyparrish added type: enhancement New feature or request status: waiting on response Waiting on a response from the reporter(s) of the issue labels Jul 5, 2023
@github-actions
Copy link

Closing due to inactivity. If the author would like to continue this PR, they can reopen it (preferred) or start a new one (if needed).

@github-actions github-actions bot closed this Jul 24, 2023
@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jul 24, 2023
@joeyparrish joeyparrish reopened this Jul 24, 2023
@joeyparrish
Copy link
Member

The robot is not smart enough to recognize new commits as activity. I'll update it soon. Reopening the PR.

@@ -162,6 +162,16 @@ std::string GetAdaptationSetKey(const MediaInfo& media_info,
if (!ignore_codec) {
key.append(":");
key.append(GetBaseCodec(media_info));

if (media_info.video_info().has_transfer_characteristics()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sr1990, I added a comment to the Dolby section of this, and made it so that explicit transfer characteristics take priority over the assumption of PQ for Dolby. Please take a look, and let me know if you agree.

// - Common CCIP values.
// Dolby vision:
// https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-DASH
if (media_info.video_info().has_transfer_characteristics()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sr1990, I made the same change here. Please take a look.

@joeyparrish
Copy link
Member

@sr1990, I will merge this if you approve of my edits. If not, we can discuss it further. Thanks!

@joeyparrish
Copy link
Member

My change caused a test failure where the golden output changed from transfer characteristics of 16 to 2. Why is that?
Should a Dolby codec string really override an explicit setting where media_info.video_info().has_transfer_characteristics()? Is the test input mp4 wrong for this scenario?

@sr1990
Copy link
Contributor Author

sr1990 commented Jul 25, 2023

@joeyparrish Thanks for reviewing.
I don't think the input mp4 is wrong as I had checked Dolby Profile 5 content at https://developer.dolby.com/tools-media/sample-media/video-streams/dolby-vision-streams/ which also has the transfer function set to 2 (unspecified). The content is inaccessible now. Please let me know if you can access it.

Found https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf which mentions that for DV Profile 5:
• Color Transfer Function Index shall be set to 2 (Unspecified) in the colr atom.
Not sure why it is set to 2.

Looks like HLS's GetVideoRange method was written based on the above reasoning.
Also, to keep DASH code consistent with GetVideoRange method:

std::string MediaPlaylist::GetVideoRange() const {
,
I think we should give the codec string higher priority over transfer characteristics in case of Dolby.
What do you think?

@joeyparrish
Copy link
Member

I don't think the input mp4 is wrong as I had checked Dolby Profile 5 content at https://developer.dolby.com/tools-media/sample-media/video-streams/dolby-vision-streams/ which also has the transfer function set to 2 (unspecified).

Found https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf which mentions that for DV Profile 5: • Color Transfer Function Index shall be set to 2 (Unspecified) in the colr atom. Not sure why it is set to 2.

I think we should give the codec string higher priority over transfer characteristics in case of Dolby.
What do you think?

Okay, then this is a peculiarity of Dolby, and Dolby codec strings really should have higher priority. But we should add a comment to the code in those places to explain it, because it's not at all obvious. I suggest something like:

  // Apple's docs for DV profile 5 state: "Color Transfer Function Index shall
  // be set to 2 (Unspecified) in the colr atom."  So we can't trust the colr
  // atom for Dolby inputs, and must set the transfer function based on the
  // codec string alone.

@sr1990
Copy link
Contributor Author

sr1990 commented Jul 27, 2023

@joeyparrish Sounds good. Right now we are getting the transfer characteristics from SPS VUI and not colr atom. Looks like #1205 and #1251 are working on reading and writing the colr atom.
I think we can complete this PR right now without the comment and once PRs for colr reading and writing are done, add the colr box for dolby vision as per the spec (even if the input does not contain the colr box) and with the comment.
OR if you prefer, we can complete this PR after mentioned PRs are done.

For adding the colr box for dolby p5 content, in
MP4Muxer::GenerateVideoTrak
check

if (video_info->codec() == kCodecH265DolbyVision &&
   video_info->codec_string().find("dvh1.05") != std::string::npos)) {
1. Get HEVCDecoderConfigurationRecord from video_info->codec_config()
2. Check if HEVCDecoderConfigurationRecord has profile set to Main 10
3. If above is true, add a colr atom with
• Color Primaries set to 2 (Unspecified).
• Color Transfer Function Index set to 2 (Unspecified).
• Color Matrix Index set to 2 (Unspecified).
}

@sr1990
Copy link
Contributor Author

sr1990 commented Aug 28, 2023

@joeyparrish, based on conversation at #1255

Dolby Vision profile 5 must be PQ. The VUI information is optional, 
usually we don't care the value of transfer_characteristics, 
both 2(UNSPECIFIED) and 16 (PQ) are valid.

I think we should keep the original code and add the above comment w/o writing the colr atom.
Please let me know what you think.

@joeyparrish
Copy link
Member

Sounds good.

This reverts commit 783f70b8a114fa7af81e417795b3ea2cba2bdcbe.
This reverts commit c5a6009c03188e393e6ada0f5bb61da10b57f27e.
@sr1990
Copy link
Contributor Author

sr1990 commented Sep 5, 2023

Sounds good.

Updated.

@joeyparrish
Copy link
Member

@sr1990, thank you for your patience and persistence!

@joeyparrish joeyparrish merged commit 8465f5f into shaka-project:main Sep 8, 2023
12 of 21 checks passed
cosmin added a commit to cosmin/shaka-packager that referenced this pull request Sep 18, 2023
cosmin added a commit that referenced this pull request Sep 19, 2023
build in CMake branch is broken at least locally on OS X after #1210 was
merged which introduced some new warnings and reintroduced
base::nullopt.
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Nov 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants