}
}
- LOG(INFO) << "Framerate: [" << video_stream_info.framerate_num << "] ["
- << video_stream_info.framerate_den << "]";
+ video_codec_ = video_config.codec();
+ if (hdr_info_.compare(video_config.hdr_info()) != 0) {
+ is_hdr_changed_ = true;
+ hdr_info_ = video_config.hdr_info();
+ }
+
+ LOG_ID(INFO, player_id_) << "Framerate: [" << video_stream_info.framerate_num
+ << "] [" << video_stream_info.framerate_den << "]"
+ << " ,is_hdr_changed_ : " << is_hdr_changed_
+ << " ,hdr info:" << hdr_info_;
if (!SetVideoSubmitDataType(video_config)) {
LOG(ERROR) << "SetVideoSubmitDataType failed.";
// This filed only set when PushMediaPacket
packet.matroska_color_info = nullptr;
+ FillHDRIntoPacket(type, buffer, &packet);
unsigned int tz_handle = buffer->tz_handle() ? buffer->tz_handle() : 0;
#if TIZEN_VERSION_AT_LEAST(6, 0, 0)
}
#endif
+void MediaPlayerESPlusPlayerTV::HDRStringToMatroskaColor(
+ const std::string& hdr_info,
+ esplusplayer_matroska_color* matroska_color) {
+ const char* fmt =
+ "matrixCoefficients:%u bitsPerChannel:%u chromaSubsamplingHorz:%u "
+ "chromaSubsamplingVert:%u"
+ " cbSubsamplingHorz:%u cbSubsamplingVert:%u chromaSitingHorz:%u "
+ "chromaSitingVert:%u"
+ " range:%u transferCharacteristics:%u primaries:%u maxCLL:%u maxFALL:%u"
+ " RX:%lf RY:%lf GX:%lf GY:%lf BX:%lf BY:%lf wX:%lf wY:%lf"
+ " luminanceMax:%lf luminanceMin:%lf";
+
+ memset(matroska_color, 0, sizeof(esplusplayer_matroska_color));
+ if (sscanf(hdr_info.c_str(), fmt, &(matroska_color->matrix_coefficients),
+ &(matroska_color->bits_per_channel),
+ &(matroska_color->chroma_subsampling_horizontal),
+ &(matroska_color->chroma_subsampling_vertical),
+ &(matroska_color->cb_subsampling_horizontal),
+ &(matroska_color->cb_subsampling_vertical),
+ &(matroska_color->chroma_siting_horizontal),
+ &(matroska_color->chroma_siting_vertical),
+ &(matroska_color->range),
+ &(matroska_color->transfer_characteristics),
+ &(matroska_color->primaries), &(matroska_color->max_cll),
+ &(matroska_color->max_fall),
+ &(matroska_color->metadata.primary_r_chromaticity_x),
+ &(matroska_color->metadata.primary_r_chromaticity_y),
+ &(matroska_color->metadata.primary_g_chromaticity_x),
+ &(matroska_color->metadata.primary_g_chromaticity_y),
+ &(matroska_color->metadata.primary_b_chromaticity_x),
+ &(matroska_color->metadata.primary_b_chromaticity_y),
+ &(matroska_color->metadata.white_point_chromaticity_x),
+ &(matroska_color->metadata.white_point_chromaticity_y),
+ &(matroska_color->metadata.luminance_max),
+ &(matroska_color->metadata.luminance_min)) != 23) {
+ LOG(ERROR) << "HDRStringToMatroskaColor hdr string invalid. " << hdr_info;
+ return;
+ }
+
+ LOG_ID(INFO, player_id_)
+ << "matrixCoefficients:" << matroska_color->matrix_coefficients
+ << " bitsPerChannel:" << matroska_color->bits_per_channel
+ << " chromaSubsamplingHorz:"
+ << matroska_color->chroma_subsampling_horizontal
+ << " chromaSubsamplingVert:"
+ << matroska_color->chroma_subsampling_vertical
+ << " cbSubsamplingHorz:" << matroska_color->cb_subsampling_horizontal
+ << " cbSubsamplingVert:" << matroska_color->cb_subsampling_vertical
+ << " chromaSitingHorz:" << matroska_color->chroma_siting_horizontal
+ << " chromaSitingVert:" << matroska_color->chroma_siting_vertical
+ << " range:" << matroska_color->range
+ << " transferCharacteristics:" << matroska_color->transfer_characteristics
+ << " primaries:" << matroska_color->primaries
+ << " maxCLL:" << matroska_color->max_cll
+ << " maxFALL:" << matroska_color->max_fall
+ << " RX:" << matroska_color->metadata.primary_r_chromaticity_x
+ << " RY:" << matroska_color->metadata.primary_r_chromaticity_y
+ << " GX:" << matroska_color->metadata.primary_g_chromaticity_x
+ << " GY:" << matroska_color->metadata.primary_g_chromaticity_y
+ << " BX:" << matroska_color->metadata.primary_b_chromaticity_x
+ << " BY:" << matroska_color->metadata.primary_b_chromaticity_y
+ << " wX:" << matroska_color->metadata.white_point_chromaticity_x
+ << " wY:" << matroska_color->metadata.white_point_chromaticity_y
+ << " luminanceMax:" << matroska_color->metadata.luminance_max
+ << " luminanceMin:" << matroska_color->metadata.luminance_min;
+}
+
+void MediaPlayerESPlusPlayerTV::FillHDRIntoPacket(
+ DemuxerStream::Type type,
+ scoped_refptr<DecoderBuffer> buffer,
+ esplusplayer_es_packet* packet) {
+ if (type != media::DemuxerStream::VIDEO)
+ return;
+
+ if (!buffer) {
+ LOG_ID(ERROR, player_id_)
+ << "decoder buffer is null, cannot get HDR10 metadata";
+ return;
+ }
+
+ // update HDR info in the first packet
+ if (is_hdr_changed_) {
+ HDRStringToMatroskaColor(hdr_info_, &matroska_color_);
+ packet->matroska_color_info = &matroska_color_;
+ is_hdr_changed_ = false;
+ }
+
+ if (!buffer->has_side_data()) {
+ LOG_ID(ERROR, player_id_) << "decoder buffer has no side data";
+ return;
+ }
+
+ if (buffer->side_data()->alpha_data.empty()) {
+ LOG_ID(ERROR, player_id_) << "decoder buffer has no alpha data";
+ return;
+ }
+
+ uint8_t* side_data = (uint8_t*)buffer->side_data()->alpha_data.data();
+ size_t side_data_size = buffer->side_data()->alpha_data.size();
+
+ if (side_data_size > 8) {
+ // follow cobalt's check about hdr10plus inf
+ std::vector<uint8_t> side_data_vec;
+ size_t side_data_vec_size = 0;
+ uint64_t blockAddId = 0;
+ for (int j = 0; j < 8; ++j) {
+ blockAddId = (blockAddId << 8) | side_data[j];
+ }
+
+ if (blockAddId == 0x04) {
+ side_data_vec_size = side_data_size - 8;
+ side_data_vec.resize(side_data_vec_size);
+ memcpy(&side_data_vec[0], side_data + 8,
+ sizeof(uint8_t) * side_data_vec_size);
+ }
+
+ packet->hdr10p_metadata_size = side_data_vec_size;
+ packet->hdr10p_metadata =
+ reinterpret_cast<char*>(const_cast<uint8_t*>(side_data_vec.data()));
+ matroska_color_.isHDR10p = true;
+ }
+}
+
} // namespace media