Issue #2101 - Part 5: Add ColorRange support to video decoders

This commit is contained in:
u3shit 2023-02-24 23:30:11 +01:00 committed by roytam1
commit e59e8c3b2c
5 changed files with 10 additions and 0 deletions

View file

@ -246,6 +246,8 @@ AOMDecoder::DoDecode(MediaRawData* aSample)
LOG("Unhandled colorspace %d", img->mc);
break;
}
b.mColorRange = img->range == AOM_CR_FULL_RANGE ? ColorRange::FULL
: ColorRange::LIMITED;
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,

View file

@ -173,6 +173,7 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
return YUVColorSpace::BT601;
}
}();
// TODO: need a newer libvpx to support full color range
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,

View file

@ -154,6 +154,7 @@ FFmpegLibWrapper::Link()
AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
AV_FUNC_OPTION(av_frame_get_color_range, AV_FUNC_AVUTIL_ALL)
#undef AV_FUNC
#undef AV_FUNC_OPTION

View file

@ -87,6 +87,7 @@ struct FFmpegLibWrapper
// libavutil optional
int (*av_frame_get_colorspace)(const AVFrame *frame);
int (*av_frame_get_color_range)(const AVFrame *frame);
PRLibrary* mAVCodecLib;
PRLibrary* mAVUtilLib;

View file

@ -381,6 +381,11 @@ FFmpegVideoDecoder<LIBAV_VER>::CreateImage(int64_t aOffset, int64_t aPts,
break;
}
}
if (mLib->av_frame_get_color_range) {
auto range = mLib->av_frame_get_color_range(mFrame);
b.mColorRange = range == AVCOL_RANGE_JPEG ? ColorRange::FULL : ColorRange::LIMITED;
}
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mInfo,
mImageContainer,