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
thexai committed Mar 2, 2021
1 parent a6fe80b commit 1e44241
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(VideoPicture* pVideoPicture)
(m_pCodecContext->profile == FF_PROFILE_H264_HIGH_10||
m_pCodecContext->profile == FF_PROFILE_H264_HIGH_10_INTRA))
pVideoPicture->colorBits = 10;
else if (m_pCodecContext->codec_id == AV_CODEC_ID_VP9 &&
(m_pCodecContext->profile == FF_PROFILE_VP9_2 ||
m_pCodecContext->profile == FF_PROFILE_VP9_3))
pVideoPicture->colorBits = 10;

if (m_pCodecContext->color_range == AVCOL_RANGE_JPEG ||
m_pCodecContext->pix_fmt == AV_PIX_FMT_YUVJ420P)
Expand Down
22 changes: 22 additions & 0 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,28 @@ CDemuxStream* CDVDDemuxFFmpeg::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;

int 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 1e44241

Please sign in to comment.