Skip to content

Commit

Permalink
[Fix] Bad picture on some VP9 HDR streams due not detection of video …
Browse files Browse the repository at this point in the history
…metadata
  • Loading branch information
phunkyfish committed Jan 29, 2024
1 parent ca19bf9 commit 15be1fd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/stream/FFmpegStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,29 @@ DemuxStream* FFmpegStream::AddStream(int streamIdx)
st->iBitsPerPixel = pStream->codecpar->bits_per_coded_sample;
st->iBitRate = static_cast<int>(pStream->codecpar->bit_rate);

st->colorPrimaries = pStream->codecpar->color_primaries;
st->colorSpace = pStream->codecpar->color_space;
st->colorTransferCharacteristic = pStream->codecpar->color_trc;
st->colorRange = pStream->codecpar->color_range;

// https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges
size_t size = 0;
uint8_t* side_data = nullptr;

side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size);
if (side_data && size)
{
st->masteringMetaData = std::make_shared<AVMasteringDisplayMetadata>(
*reinterpret_cast<AVMasteringDisplayMetadata*>(side_data));
}

side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, &size);
if (side_data && size)
{
st->contentLightMetaData = std::make_shared<AVContentLightMetadata>(
*reinterpret_cast<AVContentLightMetadata*>(side_data));
}

AVDictionaryEntry* rtag = av_dict_get(pStream->metadata, "rotate", NULL, 0);
if (rtag)
st->iOrientation = atoi(rtag->value);
Expand Down

0 comments on commit 15be1fd

Please sign in to comment.