diff options
author | u3shit <u3shit@gmail.com> | 2023-02-24 23:30:11 +0100 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-02-26 19:41:56 +0100 |
commit | c03bb68372d7034408c2ae04a51d7d1340ad37c3 (patch) | |
tree | 92c8b03bc9e816ec53be265b38be7640adf88811 | |
parent | e736dc2d343a790deaaa9c8ea0bf9aa612db39f8 (diff) | |
download | uxp-c03bb68372d7034408c2ae04a51d7d1340ad37c3.tar.gz |
Issue #2101 - Part 5: Add ColorRange support to video decoders
-rw-r--r-- | dom/media/platforms/agnostic/AOMDecoder.cpp | 2 | ||||
-rw-r--r-- | dom/media/platforms/agnostic/VPXDecoder.cpp | 1 | ||||
-rw-r--r-- | dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp | 1 | ||||
-rw-r--r-- | dom/media/platforms/ffmpeg/FFmpegLibWrapper.h | 1 | ||||
-rw-r--r-- | dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp | 5 |
5 files changed, 10 insertions, 0 deletions
diff --git a/dom/media/platforms/agnostic/AOMDecoder.cpp b/dom/media/platforms/agnostic/AOMDecoder.cpp index 693b98c949..e82871eeaa 100644 --- a/dom/media/platforms/agnostic/AOMDecoder.cpp +++ b/dom/media/platforms/agnostic/AOMDecoder.cpp @@ -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, diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp index ebc85c9e51..7c094f8d1c 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -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, diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp index 6b54baba2b..2fc71b2731 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -170,6 +170,7 @@ FFmpegLibWrapper::Link() (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59)) 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 diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h index b968edd326..807984b01d 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h @@ -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; diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index f76ca0f843..8ab67c79f0 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -389,6 +389,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, |