Always copy color space on decoder output Some external decoders might not populate the color space information on the output. Bug: chromium:40269844 Change-Id: I124fe30bf46ce84a988ec1cd5d73e7ae1ae480f3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/399220 Reviewed-by: Palak Agarwal <agpalak@google.com> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45097}
diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index ab23106..c605cf7 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc
@@ -24,6 +24,7 @@ #include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/video/color_space.h" #include "api/video/encoded_frame.h" #include "api/video/encoded_image.h" #include "api/video/video_content_type.h" @@ -160,6 +161,7 @@ decodedImage.set_ntp_time_ms(frame_info->ntp_time_ms); decodedImage.set_packet_infos(frame_info->packet_infos); decodedImage.set_rotation(frame_info->rotation); + decodedImage.set_color_space(frame_info->color_space); VideoFrame::RenderParameters render_parameters = _timing->RenderParameters(); if (render_parameters.max_composition_delay_in_frames) { // Subtract frames that are in flight. @@ -345,6 +347,9 @@ frame_info.ntp_time_ms = frame.ntp_time_ms_; frame_info.packet_infos = frame.PacketInfos(); frame_info.frame_instrumentation_data = frame_instrumentation_data; + const webrtc::ColorSpace* color_space = frame.ColorSpace(); + if (color_space) + frame_info.color_space = *color_space; // Set correctly only for key frames. Thus, use latest key frame // content type. If the corresponding key frame was lost, decode will fail
diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h index 160576c..83e1f45 100644 --- a/modules/video_coding/generic_decoder.h +++ b/modules/video_coding/generic_decoder.h
@@ -22,6 +22,7 @@ #include "api/rtp_packet_infos.h" #include "api/sequence_checker.h" #include "api/units/timestamp.h" +#include "api/video/color_space.h" #include "api/video/encoded_frame.h" #include "api/video/encoded_image.h" #include "api/video/video_content_type.h" @@ -64,6 +65,7 @@ std::optional< std::variant<FrameInstrumentationSyncData, FrameInstrumentationData>> frame_instrumentation_data; + std::optional<ColorSpace> color_space; }; class VCMDecodedFrameCallback : public DecodedImageCallback {