Skip to content
Permalink
Browse files
[WebCodecs] Expose encoder color space in decoder config
https://bugs.webkit.org/show_bug.cgi?id=247054
rdar://problem/101582123

Reviewed by Eric Carlson.

Set colorSpace to BT 601 for VP8 and VP9 as per spec.

* LayoutTests/imported/w3c/web-platform-tests/webcodecs/video-encoder.https.any-expected.txt:
* Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoder.cpp:
(WebCore::WebCodecsVideoEncoder::createEncodedChunkMetadata):
* Source/WebCore/platform/LibWebRTCVPXVideoEncoder.cpp:
(WebCore::LibWebRTCVPXVideoEncoder::create):
* Source/WebCore/platform/VideoEncoder.h:

Canonical link: https://commits.webkit.org/256052@main
  • Loading branch information
youennf committed Oct 27, 2022
1 parent 7f9455e commit 55403b23f358a666f864f90892cd67f4b176d0c7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
@@ -1,7 +1,7 @@

PASS Test VideoEncoder construction
PASS Test VideoEncoder.configure()
FAIL Test successful configure(), encode(), and flush() promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'decoderConfig.colorSpace.primaries')"
PASS Test successful configure(), encode(), and flush()
PASS encodeQueueSize test
PASS Test successful reset() and re-confiugre()
PASS Test successful encode() after re-configure().
@@ -177,7 +177,7 @@ WebCodecsEncodedVideoChunkMetadata WebCodecsVideoEncoder::createEncodedChunkMeta
m_activeConfiguration.visibleHeight ? m_activeConfiguration.visibleHeight : m_baseConfiguration.height,
m_activeConfiguration.displayWidth ? m_activeConfiguration.displayWidth : m_baseConfiguration.displayWidth,
m_activeConfiguration.displayHeight ? m_activeConfiguration.displayHeight : m_baseConfiguration.displayHeight,
{ },
m_activeConfiguration.colorSpace,
HardwareAcceleration::NoPreference,
{ }
};
@@ -92,7 +92,10 @@ void LibWebRTCVPXVideoEncoder::create(Type type, const VideoEncoder::Config& con
return;
}
callback(UniqueRef<VideoEncoder> { WTFMove(encoder) });
descriptionCallback({ });

VideoEncoder::ActiveConfiguration configuration;
configuration.colorSpace = PlatformVideoColorSpace { PlatformVideoColorPrimaries::Bt709, PlatformVideoTransferCharacteristics::Iec6196621, PlatformVideoMatrixCoefficients::Smpte170m, false };
descriptionCallback(WTFMove(configuration));
});
});
}
@@ -27,6 +27,7 @@

#if ENABLE(WEB_CODECS)

#include "PlatformVideoColorSpace.h"
#include "VideoFrame.h"
#include <wtf/CompletionHandler.h>
#include <wtf/Expected.h>
@@ -53,6 +54,7 @@ class VideoEncoder {
std::optional<size_t> displayWidth;
std::optional<size_t> displayHeight;
std::optional<Vector<uint8_t>> description;
std::optional<PlatformVideoColorSpace> colorSpace;
};
struct EncodedFrame {
Vector<uint8_t> data;
@@ -297,7 +297,7 @@ void RemoteVideoEncoderCallbacks::notifyEncoderDescription(Vector<uint8_t>&& des
if (protectedThis->m_isClosed)
return;

protectedThis->m_descriptionCallback(VideoEncoder::ActiveConfiguration { { }, { }, { }, { }, { }, WTFMove(description) });
protectedThis->m_descriptionCallback(VideoEncoder::ActiveConfiguration { { }, { }, { }, { }, { }, WTFMove(description), { } });
});
}

0 comments on commit 55403b2

Please sign in to comment.