mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
Implement VideoDec2
This commit is contained in:
+252
-36
@@ -1,10 +1,12 @@
|
||||
#include "common/abi.h"
|
||||
#include "libs/errno.h"
|
||||
#include "libs/libs.h"
|
||||
#include "libs/videoDec2Decoder.h"
|
||||
#include "loader/symbolDatabase.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -14,6 +16,7 @@ LIB_VERSION("Videodec2", 1, "Videodec2", 1, 1);
|
||||
|
||||
namespace VideoDec2 {
|
||||
|
||||
constexpr int32_t VIDEODEC2_ERROR_API_FAIL = -2128805632; // 0x811d0100
|
||||
constexpr int32_t VIDEODEC2_ERROR_STRUCT_SIZE = -2128805631; // 0x811d0101
|
||||
constexpr int32_t VIDEODEC2_ERROR_ARGUMENT_POINTER = -2128805630; // 0x811d0102
|
||||
constexpr int32_t VIDEODEC2_ERROR_DECODER_INSTANCE = -2128805629; // 0x811d0103
|
||||
@@ -21,13 +24,20 @@ constexpr int32_t VIDEODEC2_ERROR_MEMORY_SIZE = -2128805628; // 0x811d0
|
||||
constexpr int32_t VIDEODEC2_ERROR_MEMORY_POINTER = -2128805627; // 0x811d0105
|
||||
constexpr int32_t VIDEODEC2_ERROR_FRAME_BUFFER_SIZE = -2128805626; // 0x811d0106
|
||||
constexpr int32_t VIDEODEC2_ERROR_FRAME_BUFFER_POINTER = -2128805625; // 0x811d0107
|
||||
constexpr int32_t VIDEODEC2_ERROR_ACCESS_UNIT_SIZE = -2128805619; // 0x811d010d
|
||||
constexpr int32_t VIDEODEC2_ERROR_ACCESS_UNIT_POINTER = -2128805618; // 0x811d010e
|
||||
constexpr int32_t VIDEODEC2_ERROR_OUTPUT_INFO = -2128805617; // 0x811d010f
|
||||
constexpr int32_t VIDEODEC2_ERROR_COMPUTE_QUEUE = -2128805616; // 0x811d0110
|
||||
constexpr int32_t VIDEODEC2_ERROR_CONFIG_INFO = -2128805376; // 0x811d0200
|
||||
constexpr int32_t VIDEODEC2_ERROR_COMPUTE_PIPE_ID = -2128805375; // 0x811d0201
|
||||
constexpr int32_t VIDEODEC2_ERROR_COMPUTE_QUEUE_ID = -2128805374; // 0x811d0202
|
||||
constexpr int32_t VIDEODEC2_ERROR_RESOURCE_TYPE = -2128805373; // 0x811d0203
|
||||
constexpr int32_t VIDEODEC2_ERROR_CODEC_TYPE = -2128805372; // 0x811d0204
|
||||
constexpr int32_t VIDEODEC2_ERROR_INPUT_QUEUE_DEPTH = -2128805370; // 0x811d0206
|
||||
constexpr int32_t VIDEODEC2_ERROR_DPB_FRAME_COUNT = -2128805367; // 0x811d0209
|
||||
constexpr int32_t VIDEODEC2_ERROR_FRAME_WIDTH_HEIGHT = -2128805366; // 0x811d020a
|
||||
constexpr int32_t VIDEODEC2_ERROR_ACCESS_UNIT = -2128805119; // 0x811d0301
|
||||
constexpr int32_t VIDEODEC2_ERROR_OVERSIZE_DECODE = -2128805118; // 0x811d0302
|
||||
|
||||
constexpr uint32_t VIDEODEC2_RESOURCE_TYPE_COMPUTE = 1;
|
||||
constexpr size_t VIDEODEC2_MIN_MEMORY_SIZE = 16ull * 1024ull * 1024ull;
|
||||
@@ -101,6 +111,70 @@ struct Videodec2FrameBuffer {
|
||||
bool is_accepted;
|
||||
};
|
||||
|
||||
struct Videodec2AvcPictureInfo {
|
||||
size_t this_size;
|
||||
bool is_valid;
|
||||
|
||||
uint64_t pts_data;
|
||||
uint64_t dts_data;
|
||||
uint64_t attached_data;
|
||||
|
||||
uint8_t idr_picture_flag;
|
||||
uint8_t profile_idc;
|
||||
uint8_t level_idc;
|
||||
uint32_t pic_width_in_mbs_minus1;
|
||||
uint32_t pic_height_in_map_units_minus1;
|
||||
uint8_t frame_mbs_only_flag;
|
||||
|
||||
uint8_t frame_cropping_flag;
|
||||
uint32_t frame_crop_left_offset;
|
||||
uint32_t frame_crop_right_offset;
|
||||
uint32_t frame_crop_top_offset;
|
||||
uint32_t frame_crop_bottom_offset;
|
||||
|
||||
uint8_t aspect_ratio_info_present_flag;
|
||||
uint8_t aspect_ratio_idc;
|
||||
uint16_t sar_width;
|
||||
uint16_t sar_height;
|
||||
|
||||
uint8_t video_signal_type_present_flag;
|
||||
uint8_t video_format;
|
||||
uint8_t video_full_range_flag;
|
||||
uint8_t colour_description_present_flag;
|
||||
uint8_t colour_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coefficients;
|
||||
|
||||
uint8_t timing_info_present_flag;
|
||||
uint32_t num_units_in_tick;
|
||||
uint32_t time_scale;
|
||||
uint8_t fixed_frame_rate_flag;
|
||||
|
||||
uint8_t bitstream_restriction_flag;
|
||||
uint8_t max_dec_frame_buffering;
|
||||
|
||||
uint8_t pic_struct_present_flag;
|
||||
uint8_t pic_struct;
|
||||
uint8_t field_pic_flag;
|
||||
uint8_t bottom_field_flag;
|
||||
|
||||
uint8_t sequence_parameter_set_present_flag;
|
||||
uint8_t picture_parameter_set_present_flag;
|
||||
uint8_t au_delimiter_present_flag;
|
||||
uint8_t end_of_sequence_present_flag;
|
||||
uint8_t end_of_stream_present_flag;
|
||||
uint8_t filler_data_present_flag;
|
||||
uint8_t picture_timing_sei_present_flag;
|
||||
uint8_t buffering_period_sei_present_flag;
|
||||
|
||||
uint8_t constraint_set0_flag;
|
||||
uint8_t constraint_set1_flag;
|
||||
uint8_t constraint_set2_flag;
|
||||
uint8_t constraint_set3_flag;
|
||||
uint8_t constraint_set4_flag;
|
||||
uint8_t constraint_set5_flag;
|
||||
};
|
||||
|
||||
struct Videodec2ComputeMemoryInfo {
|
||||
size_t this_size;
|
||||
size_t cpu_gpu_memory_size;
|
||||
@@ -116,10 +190,7 @@ struct Videodec2ComputeConfigInfo {
|
||||
uint16_t reserved1;
|
||||
};
|
||||
|
||||
struct DecoderState {
|
||||
uint64_t magic;
|
||||
uint32_t codec_type;
|
||||
};
|
||||
using DecoderState = Decoder::Instance;
|
||||
|
||||
static_assert(sizeof(Videodec2ComputeMemoryInfo) == 24);
|
||||
static_assert(sizeof(Videodec2ComputeConfigInfo) == 16);
|
||||
@@ -128,8 +199,7 @@ static_assert(sizeof(Videodec2DecoderMemoryInfo) == 72);
|
||||
static_assert(sizeof(Videodec2InputData) == 48);
|
||||
static_assert(sizeof(Videodec2OutputInfo) == 56);
|
||||
static_assert(sizeof(Videodec2FrameBuffer) == 32);
|
||||
|
||||
constexpr uint64_t DECODER_MAGIC = 0x4b59545956444543ull; // KYTYVDEC
|
||||
static_assert(sizeof(Videodec2AvcPictureInfo) == 120);
|
||||
|
||||
static std::mutex g_decoder_mutex;
|
||||
static std::unordered_set<void*> g_decoders;
|
||||
@@ -156,15 +226,54 @@ static void FillNoPictureOutput(const Videodec2FrameBuffer* frame_buffer,
|
||||
output_info->frame_height = 0;
|
||||
output_info->frame_buffer = frame_buffer != nullptr ? frame_buffer->frame_buffer : nullptr;
|
||||
output_info->frame_buffer_size = frame_buffer != nullptr ? frame_buffer->frame_buffer_size : 0;
|
||||
output_info->frame_format = VIDEODEC2_FRAME_FORMAT_DEFAULT;
|
||||
output_info->frame_pitch_in_bytes = 0;
|
||||
if (output_info->this_size == sizeof(Videodec2OutputInfo)) {
|
||||
output_info->frame_format = VIDEODEC2_FRAME_FORMAT_DEFAULT;
|
||||
output_info->frame_pitch_in_bytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t ValidateDecoderConfig(const Videodec2DecoderConfigInfo* config) {
|
||||
static int32_t MapDecoderResult(Decoder::Result result) {
|
||||
switch (result) {
|
||||
case Decoder::Result::Ok: return OK;
|
||||
case Decoder::Result::ApiFail: return VIDEODEC2_ERROR_API_FAIL;
|
||||
case Decoder::Result::AccessUnit: return VIDEODEC2_ERROR_ACCESS_UNIT;
|
||||
case Decoder::Result::FrameBufferSize: return VIDEODEC2_ERROR_FRAME_BUFFER_SIZE;
|
||||
case Decoder::Result::OversizeDecode: return VIDEODEC2_ERROR_OVERSIZE_DECODE;
|
||||
}
|
||||
return VIDEODEC2_ERROR_API_FAIL;
|
||||
}
|
||||
|
||||
static void ApplyDecodedOutput(const Decoder::Output& decoded, Videodec2FrameBuffer* frame_buffer,
|
||||
Videodec2OutputInfo* output_info) {
|
||||
frame_buffer->is_accepted = decoded.buffer_accepted;
|
||||
if (!decoded.valid) {
|
||||
return;
|
||||
}
|
||||
output_info->is_valid = true;
|
||||
output_info->is_error_frame = decoded.error_frame;
|
||||
output_info->picture_count = 1;
|
||||
output_info->codec_type = decoded.codec_type;
|
||||
output_info->frame_width = decoded.width;
|
||||
output_info->frame_pitch = decoded.pitch;
|
||||
output_info->frame_height = decoded.height;
|
||||
output_info->frame_buffer = decoded.buffer;
|
||||
output_info->frame_buffer_size = decoded.buffer_size;
|
||||
if (output_info->this_size == sizeof(Videodec2OutputInfo)) {
|
||||
output_info->frame_format = VIDEODEC2_FRAME_FORMAT_DEFAULT;
|
||||
output_info->frame_pitch_in_bytes = decoded.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t ValidateDecoderConfig(const Videodec2DecoderConfigInfo* config,
|
||||
bool require_compute_queue) {
|
||||
if (config->resource_type != VIDEODEC2_RESOURCE_TYPE_COMPUTE) {
|
||||
return VIDEODEC2_ERROR_RESOURCE_TYPE;
|
||||
}
|
||||
|
||||
if (!Decoder::IsCodecSupported(config->codec_type)) {
|
||||
return VIDEODEC2_ERROR_CODEC_TYPE;
|
||||
}
|
||||
|
||||
if (config->reserved0 != 0 || config->reserved1 != 0) {
|
||||
return VIDEODEC2_ERROR_CONFIG_INFO;
|
||||
}
|
||||
@@ -182,8 +291,8 @@ static int32_t ValidateDecoderConfig(const Videodec2DecoderConfigInfo* config) {
|
||||
return VIDEODEC2_ERROR_FRAME_WIDTH_HEIGHT;
|
||||
}
|
||||
|
||||
if (config->compute_queue == nullptr) {
|
||||
return VIDEODEC2_ERROR_CONFIG_INFO;
|
||||
if (require_compute_queue && config->compute_queue == nullptr) {
|
||||
return VIDEODEC2_ERROR_COMPUTE_QUEUE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
@@ -243,7 +352,6 @@ static int32_t KYTY_SYSV_ABI AllocateComputeQueue(
|
||||
}
|
||||
|
||||
*compute_queue = compute_memory_info->cpu_gpu_memory;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -266,7 +374,7 @@ static int32_t KYTY_SYSV_ABI QueryDecoderMemoryInfo(const Videodec2DecoderConfig
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
const auto validation_result = ValidateDecoderConfig(config);
|
||||
const auto validation_result = ValidateDecoderConfig(config, false);
|
||||
if (validation_result != OK) {
|
||||
return validation_result;
|
||||
}
|
||||
@@ -298,7 +406,7 @@ static int32_t KYTY_SYSV_ABI CreateDecoder(const Videodec2DecoderConfigInfo* con
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
const auto validation_result = ValidateDecoderConfig(config);
|
||||
const auto validation_result = ValidateDecoderConfig(config, true);
|
||||
if (validation_result != OK) {
|
||||
return validation_result;
|
||||
}
|
||||
@@ -315,9 +423,11 @@ static int32_t KYTY_SYSV_ABI CreateDecoder(const Videodec2DecoderConfigInfo* con
|
||||
return VIDEODEC2_ERROR_MEMORY_POINTER;
|
||||
}
|
||||
|
||||
auto* state = new DecoderState {};
|
||||
state->magic = DECODER_MAGIC;
|
||||
state->codec_type = config->codec_type;
|
||||
auto* state =
|
||||
Decoder::Create({config->codec_type, config->max_frame_width, config->max_frame_height});
|
||||
if (state == nullptr) {
|
||||
return VIDEODEC2_ERROR_API_FAIL;
|
||||
}
|
||||
|
||||
{
|
||||
std::scoped_lock lock(g_decoder_mutex);
|
||||
@@ -325,7 +435,6 @@ static int32_t KYTY_SYSV_ABI CreateDecoder(const Videodec2DecoderConfigInfo* con
|
||||
}
|
||||
|
||||
*decoder = state;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -343,7 +452,7 @@ static int32_t KYTY_SYSV_ABI DeleteDecoder(Videodec2Decoder decoder) {
|
||||
g_decoders.erase(it);
|
||||
}
|
||||
|
||||
delete state;
|
||||
Decoder::Destroy(state);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -353,8 +462,8 @@ static int32_t KYTY_SYSV_ABI Decode(Videodec2Decoder decoder, const Videodec2Inp
|
||||
Videodec2OutputInfo* output_info) {
|
||||
PRINT_NAME();
|
||||
|
||||
const auto* state = GetDecoder(decoder);
|
||||
if (state == nullptr || state->magic != DECODER_MAGIC) {
|
||||
auto* state = GetDecoder(decoder);
|
||||
if (state == nullptr) {
|
||||
return VIDEODEC2_ERROR_DECODER_INSTANCE;
|
||||
}
|
||||
|
||||
@@ -368,8 +477,12 @@ static int32_t KYTY_SYSV_ABI Decode(Videodec2Decoder decoder, const Videodec2Inp
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
if (input_data->au_size != 0 && input_data->au_data == nullptr) {
|
||||
return VIDEODEC2_ERROR_ARGUMENT_POINTER;
|
||||
if (input_data->au_size == 0) {
|
||||
return VIDEODEC2_ERROR_ACCESS_UNIT_SIZE;
|
||||
}
|
||||
|
||||
if (input_data->au_data == nullptr) {
|
||||
return VIDEODEC2_ERROR_ACCESS_UNIT_POINTER;
|
||||
}
|
||||
|
||||
if (frame_buffer->frame_buffer_size == 0) {
|
||||
@@ -381,17 +494,24 @@ static int32_t KYTY_SYSV_ABI Decode(Videodec2Decoder decoder, const Videodec2Inp
|
||||
}
|
||||
|
||||
frame_buffer->is_accepted = false;
|
||||
FillNoPictureOutput(frame_buffer, output_info, state->codec_type);
|
||||
FillNoPictureOutput(frame_buffer, output_info, Decoder::GetCodecType(state));
|
||||
|
||||
return OK;
|
||||
Decoder::Output decoded {};
|
||||
const auto result =
|
||||
Decoder::Decode(state,
|
||||
{input_data->au_data, input_data->au_size, input_data->pts_data,
|
||||
input_data->dts_data, input_data->attached_data},
|
||||
{frame_buffer->frame_buffer, frame_buffer->frame_buffer_size}, &decoded);
|
||||
ApplyDecodedOutput(decoded, frame_buffer, output_info);
|
||||
return MapDecoderResult(result);
|
||||
}
|
||||
|
||||
static int32_t KYTY_SYSV_ABI Flush(Videodec2Decoder decoder, Videodec2FrameBuffer* frame_buffer,
|
||||
Videodec2OutputInfo* output_info) {
|
||||
PRINT_NAME();
|
||||
|
||||
const auto* state = GetDecoder(decoder);
|
||||
if (state == nullptr || state->magic != DECODER_MAGIC) {
|
||||
auto* state = GetDecoder(decoder);
|
||||
if (state == nullptr) {
|
||||
return VIDEODEC2_ERROR_DECODER_INSTANCE;
|
||||
}
|
||||
|
||||
@@ -404,26 +524,40 @@ static int32_t KYTY_SYSV_ABI Flush(Videodec2Decoder decoder, Videodec2FrameBuffe
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
frame_buffer->is_accepted = false;
|
||||
FillNoPictureOutput(frame_buffer, output_info, state->codec_type);
|
||||
if (frame_buffer->frame_buffer_size == 0) {
|
||||
return VIDEODEC2_ERROR_FRAME_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
if (frame_buffer->frame_buffer == nullptr) {
|
||||
return VIDEODEC2_ERROR_FRAME_BUFFER_POINTER;
|
||||
}
|
||||
|
||||
frame_buffer->is_accepted = false;
|
||||
FillNoPictureOutput(frame_buffer, output_info, Decoder::GetCodecType(state));
|
||||
|
||||
Decoder::Output decoded {};
|
||||
const auto result = Decoder::Flush(
|
||||
state, {frame_buffer->frame_buffer, frame_buffer->frame_buffer_size}, &decoded);
|
||||
ApplyDecodedOutput(decoded, frame_buffer, output_info);
|
||||
return MapDecoderResult(result);
|
||||
}
|
||||
|
||||
static int32_t KYTY_SYSV_ABI Reset(Videodec2Decoder decoder) {
|
||||
PRINT_NAME();
|
||||
|
||||
const auto* state = GetDecoder(decoder);
|
||||
return state != nullptr && state->magic == DECODER_MAGIC ? OK
|
||||
: VIDEODEC2_ERROR_DECODER_INSTANCE;
|
||||
auto* state = GetDecoder(decoder);
|
||||
if (state == nullptr) {
|
||||
return VIDEODEC2_ERROR_DECODER_INSTANCE;
|
||||
}
|
||||
Decoder::Reset(state);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int32_t KYTY_SYSV_ABI GetPictureInfo(const Videodec2OutputInfo* output_info,
|
||||
void* /*first_picture_info*/,
|
||||
void* /*second_picture_info*/) {
|
||||
void* first_picture_info, void* second_picture_info) {
|
||||
PRINT_NAME();
|
||||
|
||||
if (output_info == nullptr) {
|
||||
if (output_info == nullptr || first_picture_info == nullptr) {
|
||||
return VIDEODEC2_ERROR_ARGUMENT_POINTER;
|
||||
}
|
||||
|
||||
@@ -431,6 +565,88 @@ static int32_t KYTY_SYSV_ABI GetPictureInfo(const Videodec2OutputInfo* output_in
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
if (!output_info->is_valid || output_info->picture_count == 0 ||
|
||||
output_info->frame_buffer == nullptr) {
|
||||
return VIDEODEC2_ERROR_OUTPUT_INFO;
|
||||
}
|
||||
|
||||
Decoder::PictureInfo decoded {};
|
||||
if (!Decoder::GetPictureInfo(output_info->frame_buffer, &decoded) ||
|
||||
decoded.codec_type != output_info->codec_type) {
|
||||
return VIDEODEC2_ERROR_OUTPUT_INFO;
|
||||
}
|
||||
|
||||
auto fill_common = [&decoded](void* destination, bool valid) -> int32_t {
|
||||
auto* bytes = static_cast<uint8_t*>(destination);
|
||||
const auto size = *static_cast<const size_t*>(destination);
|
||||
if (size < 40 || size > 256) {
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
std::memset(bytes + sizeof(size_t), 0, size - sizeof(size_t));
|
||||
bytes[8] = valid ? 1 : 0;
|
||||
if (valid) {
|
||||
std::memcpy(bytes + 16, &decoded.pts, sizeof(decoded.pts));
|
||||
std::memcpy(bytes + 24, &decoded.dts, sizeof(decoded.dts));
|
||||
std::memcpy(bytes + 32, &decoded.attached_data, sizeof(decoded.attached_data));
|
||||
}
|
||||
return OK;
|
||||
};
|
||||
|
||||
if (output_info->codec_type == 1) {
|
||||
const auto requested_size = *static_cast<const size_t*>(first_picture_info);
|
||||
if (requested_size != sizeof(Videodec2AvcPictureInfo) &&
|
||||
(requested_size | 16u) != sizeof(Videodec2AvcPictureInfo)) {
|
||||
return VIDEODEC2_ERROR_STRUCT_SIZE;
|
||||
}
|
||||
|
||||
Videodec2AvcPictureInfo picture {};
|
||||
picture.this_size = requested_size;
|
||||
picture.is_valid = true;
|
||||
picture.pts_data = decoded.pts;
|
||||
picture.dts_data = decoded.dts;
|
||||
picture.attached_data = decoded.attached_data;
|
||||
picture.idr_picture_flag = decoded.key_frame ? 1 : 0;
|
||||
picture.profile_idc = static_cast<uint8_t>(decoded.profile);
|
||||
picture.level_idc = static_cast<uint8_t>(decoded.level);
|
||||
picture.pic_width_in_mbs_minus1 = (decoded.width + 15u) / 16u - 1u;
|
||||
picture.pic_height_in_map_units_minus1 = (decoded.height + 15u) / 16u - 1u;
|
||||
picture.frame_mbs_only_flag = 1;
|
||||
picture.frame_cropping_flag = decoded.crop_left != 0 || decoded.crop_right != 0 ||
|
||||
decoded.crop_top != 0 || decoded.crop_bottom != 0
|
||||
? 1
|
||||
: 0;
|
||||
picture.frame_crop_left_offset = decoded.crop_left;
|
||||
picture.frame_crop_right_offset = decoded.crop_right;
|
||||
picture.frame_crop_top_offset = decoded.crop_top;
|
||||
picture.frame_crop_bottom_offset = decoded.crop_bottom;
|
||||
picture.aspect_ratio_info_present_flag =
|
||||
decoded.sar_width != 0 && decoded.sar_height != 0 ? 1 : 0;
|
||||
picture.aspect_ratio_idc = picture.aspect_ratio_info_present_flag ? 255 : 0;
|
||||
picture.sar_width = decoded.sar_width;
|
||||
picture.sar_height = decoded.sar_height;
|
||||
picture.video_signal_type_present_flag = 1;
|
||||
picture.video_format = 5;
|
||||
picture.video_full_range_flag = decoded.color_range == 2 ? 1 : 0;
|
||||
picture.colour_description_present_flag =
|
||||
decoded.color_primaries != 0 || decoded.color_trc != 0 || decoded.color_space != 0 ? 1
|
||||
: 0;
|
||||
picture.colour_primaries = decoded.color_primaries;
|
||||
picture.transfer_characteristics = decoded.color_trc;
|
||||
picture.matrix_coefficients = decoded.color_space;
|
||||
std::memcpy(first_picture_info, &picture, requested_size);
|
||||
} else {
|
||||
const auto result = fill_common(first_picture_info, true);
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (second_picture_info != nullptr) {
|
||||
const auto result = fill_common(second_picture_info, false);
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user