Skip to content

Commit

Permalink
[WebCodecs] Expose encoder color space in decoder config
Browse files Browse the repository at this point in the history
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 55403b2
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().
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Modules/webcodecs/WebCodecsVideoEncoder.cpp
Expand Up @@ -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,
{ }
};
Expand Down
5 changes: 4 additions & 1 deletion Source/WebCore/platform/LibWebRTCVPXVideoEncoder.cpp
Expand Up @@ -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));
});
});
}
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/VideoEncoder.h
Expand Up @@ -27,6 +27,7 @@

#if ENABLE(WEB_CODECS)

#include "PlatformVideoColorSpace.h"
#include "VideoFrame.h"
#include <wtf/CompletionHandler.h>
#include <wtf/Expected.h>
Expand All @@ -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;
Expand Down
Expand Up @@ -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), { } });
});
}

Expand Down

0 comments on commit 55403b2

Please sign in to comment.