Revert "svc_encoder_rtc: support adding local metadata" This reverts commit 378f15d1cbd5102f89a52881bcdcf2c010f3c5c8. Reason: exclude the layer-specific metadata API from libaom v3.13.0. Change-Id: Ia689cad2ce9f168c652731d90708359bcefc3147
diff --git a/examples/multilayer_metadata.cc b/examples/multilayer_metadata.cc index 4ab1349..9427029 100644 --- a/examples/multilayer_metadata.cc +++ b/examples/multilayer_metadata.cc
@@ -430,49 +430,6 @@ return true; } -bool parse_multilayer_layer_local_metadata( - std::ifstream &file, int min_indent, int *line_idx, - std::vector<FrameLocalMetadata> &frames) { - bool has_list_prefix; - int indent = -1; - std::string field_name; - ParsedValue value; - bool syntax_error; - while (parse_line(file, min_indent, /*is_list=*/true, &indent, - &has_list_prefix, line_idx, &field_name, &value, - &syntax_error)) { - if (has_list_prefix) { - frames.push_back({}); - } - if (frames.empty()) { - fprintf(stderr, "Error: Missing list prefix '-' at line %d\n", *line_idx); - return false; - } - - if (field_name == "frame_idx") { - RETURN_IF_FALSE( - value.IntegerValueInRange(0, std::numeric_limits<long>::max(), - *line_idx, &frames.back().frame_idx)); - } else if (field_name == "alpha") { - RETURN_IF_FALSE(parse_multilayer_layer_alpha( - file, - /*min_indent=*/indent + 1, line_idx, &frames.back().alpha)); - - } else if (field_name == "depth") { - RETURN_IF_FALSE(parse_multilayer_layer_depth( - file, - /*min_indent=*/indent + 1, line_idx, &frames.back().depth)); - - } else { - fprintf(stderr, "Error: Unknown field %s at line %d\n", - field_name.c_str(), *line_idx); - return false; - } - } - if (syntax_error) return false; - return true; -} - bool validate_layer(const LayerMetadata &layer, bool layer_has_alpha, bool layer_has_depth) { if (layer_has_alpha != (layer.layer_type == MULTILAYER_LAYER_TYPE_ALPHA && @@ -518,8 +475,7 @@ // Validate the previous layer. if (!layers.empty()) { - RETURN_IF_FALSE( - validate_layer(layers.back(), layer_has_alpha, layer_has_depth)); + validate_layer(layers.back(), layer_has_alpha, layer_has_depth); } if (layers.size() == 1 && layers.back().layer_color_description.second) { fprintf(stderr, @@ -564,25 +520,24 @@ layer->layer_color_description = value_present(color_properties); } else if ((field_name == "alpha")) { layer_has_alpha = true; - RETURN_IF_FALSE(parse_multilayer_layer_alpha(file, - /*min_indent=*/indent + 1, - line_idx, &layer->alpha)); + RETURN_IF_FALSE(parse_multilayer_layer_alpha( + file, + /*min_indent=*/indent + 1, line_idx, &layer->global_alpha_info)); } else if (field_name == "depth") { layer_has_depth = true; - RETURN_IF_FALSE(parse_multilayer_layer_depth(file, - /*min_indent=*/indent + 1, - line_idx, &layer->depth)); - if ((layer->depth.d_min.second || layer->depth.d_max.second) && - layer->depth.disparity_ref_view_id == (layers.size() - 1)) { + RETURN_IF_FALSE(parse_multilayer_layer_depth( + file, + /*min_indent=*/indent + 1, line_idx, &layer->global_depth_info)); + if ((layer->global_depth_info.d_min.second || + layer->global_depth_info.d_max.second) && + layer->global_depth_info.disparity_ref_view_id == + (layers.size() - 1)) { fprintf(stderr, "disparity_ref_view_id must be different from the layer's id " "for layer %d (zero-based index)\n", static_cast<int>(layers.size()) - 1); return false; } - } else if (field_name == "local_metadata") { - RETURN_IF_FALSE(parse_multilayer_layer_local_metadata( - file, /*min_indent=*/indent + 1, line_idx, layer->local_metadata)); } else { fprintf(stderr, "Error: Unknown field %s at line %d\n", field_name.c_str(), *line_idx); @@ -590,8 +545,7 @@ } } if (syntax_error) return false; - RETURN_IF_FALSE( - validate_layer(layers.back(), layer_has_alpha, layer_has_depth)); + validate_layer(layers.back(), layer_has_alpha, layer_has_depth); return true; } @@ -832,33 +786,6 @@ return true; } -void print_alpha_information(const AlphaInformation &alpha) { - printf(" alpha_simple_flag: %d\n", alpha.alpha_simple_flag); - if (!alpha.alpha_simple_flag) { - printf(" alpha_bit_depth: %d\n", alpha.alpha_bit_depth); - printf(" alpha_clip_idc: %d\n", alpha.alpha_clip_idc); - printf(" alpha_incr_flag: %d\n", alpha.alpha_incr_flag); - printf(" alpha_transparent_value: %hu\n", alpha.alpha_transparent_value); - printf(" alpha_opaque_value: %hu\n", alpha.alpha_opaque_value); - printf(" alpha_color_description: %s\n", - format_color_properties(alpha.alpha_color_description).c_str()); - } -} - -void print_depth_information(const DepthInformation &depth) { - printf(" z_near: %s\n", - format_depth_representation_element(depth.z_near).c_str()); - printf(" z_far: %s\n", - format_depth_representation_element(depth.z_far).c_str()); - printf(" d_min: %s\n", - format_depth_representation_element(depth.d_min).c_str()); - printf(" d_max: %s\n", - format_depth_representation_element(depth.d_max).c_str()); - printf(" depth_representation_type: %d\n", - depth.depth_representation_type); - printf(" disparity_ref_view_id: %d\n", depth.disparity_ref_view_id); -} - } // namespace double depth_representation_element_to_double( @@ -954,21 +881,45 @@ printf(" layer_color_description: %s\n", format_color_properties(layer.layer_color_description).c_str()); if (layer.layer_type == MULTILAYER_LAYER_TYPE_ALPHA) { - if (layer.layer_metadata_scope >= SCOPE_GLOBAL) { - printf(" global alpha:\n"); - print_alpha_information(layer.alpha); - } - for (const FrameLocalMetadata &local_metadata : layer.local_metadata) { - printf(" local alpha for frame %ld:\n", local_metadata.frame_idx); - print_alpha_information(local_metadata.alpha); + printf(" alpha:\n"); + printf(" alpha_use_idc: %d\n", layer.global_alpha_info.alpha_use_idc); + printf(" alpha_simple_flag: %d\n", + layer.global_alpha_info.alpha_simple_flag); + if (!layer.global_alpha_info.alpha_simple_flag) { + printf(" alpha_bit_depth: %d\n", + layer.global_alpha_info.alpha_bit_depth); + printf(" alpha_clip_idc: %d\n", + layer.global_alpha_info.alpha_clip_idc); + printf(" alpha_incr_flag: %d\n", + layer.global_alpha_info.alpha_incr_flag); + printf(" alpha_transparent_value: %hu\n", + layer.global_alpha_info.alpha_transparent_value); + printf(" alpha_opaque_value: %hu\n", + layer.global_alpha_info.alpha_opaque_value); + printf(" alpha_color_description: %s\n", + format_color_properties( + layer.global_alpha_info.alpha_color_description) + .c_str()); } } else if (layer.layer_type == MULTILAYER_LAYER_TYPE_DEPTH) { - printf(" global depth:\n"); - print_depth_information(layer.depth); - for (const FrameLocalMetadata &local_metadata : layer.local_metadata) { - printf(" local depth for frame %ld:\n", local_metadata.frame_idx); - print_depth_information(local_metadata.depth); - } + printf(" depth:\n"); + printf(" z_near: %s\n", + format_depth_representation_element(layer.global_depth_info.z_near) + .c_str()); + printf(" z_far: %s\n", + format_depth_representation_element(layer.global_depth_info.z_far) + .c_str()); + printf(" d_min: %s\n", + format_depth_representation_element(layer.global_depth_info.d_min) + .c_str()); + printf(" d_max: %s\n", + format_depth_representation_element(layer.global_depth_info.d_max) + .c_str()); + printf(" depth_representation_type: %d\n", + layer.global_depth_info.depth_representation_type); + printf(" disparity_ref_view_id: %d\n", + layer.global_depth_info.disparity_ref_view_id); + printf("\n"); } } printf("\n");
diff --git a/examples/multilayer_metadata.h b/examples/multilayer_metadata.h index 1ac1c3c..392f1c5 100644 --- a/examples/multilayer_metadata.h +++ b/examples/multilayer_metadata.h
@@ -61,7 +61,7 @@ std::pair<DepthRepresentationElement, bool> z_far; std::pair<DepthRepresentationElement, bool> d_min; std::pair<DepthRepresentationElement, bool> d_max; - uint8_t depth_representation_type; // [0, 2]. Values 3 to 15 are reserved. + uint8_t depth_representation_type; // [0, 15] // Only relevant if d_min or d_max are present. uint8_t disparity_ref_view_id; // [0, 3] }; @@ -110,14 +110,6 @@ // 4 to 7 are reserved. }; -struct FrameLocalMetadata { - long frame_idx; - // Relevant for MULTILAYER_LAYER_TYPE_ALPHA with scope != SCOPE_GLOBAL. - AlphaInformation alpha; - // Relevant for MULTILAYER_LAYER_TYPE_DEPTH with scope != SCOPE_GLOBAL. - DepthInformation depth; -}; - struct LayerMetadata { LayerType layer_type; // [0, 31] bool luma_plane_only_flag; @@ -129,12 +121,9 @@ std::pair<ColorProperties, bool> layer_color_description; // Relevant for MULTILAYER_LAYER_TYPE_ALPHA with scope >= SCOPE_GLOBAL. - AlphaInformation alpha; + AlphaInformation global_alpha_info; // Relevant for MULTILAYER_LAYER_TYPE_DEPTH with scope >= SCOPE_GLOBAL. - DepthInformation depth; - - // Relevant when scope != SCOPE_GLOBAL. - std::vector<FrameLocalMetadata> local_metadata; + DepthInformation global_depth_info; }; struct MultilayerMetadata {
diff --git a/examples/svc_encoder_rtc.cc b/examples/svc_encoder_rtc.cc index 7509fa6..10c2102 100644 --- a/examples/svc_encoder_rtc.cc +++ b/examples/svc_encoder_rtc.cc
@@ -1463,55 +1463,8 @@ } } -static void write_alpha_information( - struct aom_write_bit_buffer *buffer, - const libaom_examples::AlphaInformation &alpha_info) { - write_literal(buffer, alpha_info.alpha_use_idc, 2); - write_literal(buffer, alpha_info.alpha_simple_flag, 1); - if (!alpha_info.alpha_simple_flag) { - write_literal(buffer, alpha_info.alpha_bit_depth, 3, /*offset=*/8); - write_literal(buffer, alpha_info.alpha_clip_idc, 2); - write_literal(buffer, alpha_info.alpha_incr_flag, 1); - write_literal(buffer, alpha_info.alpha_transparent_value, - alpha_info.alpha_bit_depth + 1); - write_literal(buffer, alpha_info.alpha_opaque_value, - alpha_info.alpha_bit_depth + 1); - if (buffer->bit_offset % 8 != 0) { - // ai_byte_alignment_bits - write_literal(buffer, 0, 8 - (buffer->bit_offset % 8)); - } - assert(buffer->bit_offset % 8 == 0); - - write_literal(buffer, 0, 6); // ai_reserved_6bits - write_color_properties(buffer, alpha_info.alpha_color_description); - } else { - write_literal(buffer, 0, 5); // ai_reserved_5bits - } -} - -static void write_depth_information( - struct aom_write_bit_buffer *buffer, - const libaom_examples::DepthInformation &depth_info) { - write_literal(buffer, depth_info.z_near.second, 1); - write_literal(buffer, depth_info.z_far.second, 1); - write_literal(buffer, depth_info.d_min.second, 1); - write_literal(buffer, depth_info.d_max.second, 1); - write_literal(buffer, depth_info.depth_representation_type, 4); - if (depth_info.d_min.second || depth_info.d_max.second) { - write_literal(buffer, depth_info.disparity_ref_view_id, 2); - } - write_depth_representation_element(buffer, depth_info.z_near); - write_depth_representation_element(buffer, depth_info.z_far); - write_depth_representation_element(buffer, depth_info.d_min); - write_depth_representation_element(buffer, depth_info.d_max); - if (buffer->bit_offset % 8 != 0) { - write_literal(buffer, 0, 8 - (buffer->bit_offset % 8)); - } -} - static void add_multilayer_metadata( - aom_image_t *frame, const libaom_examples::MultilayerMetadata &multilayer, - int frame_idx, int spatial_id) { + aom_image_t *frame, const libaom_examples::MultilayerMetadata &multilayer) { // Large enough buffer for the multilayer metadata. // Each layer's metadata is less than 100 bytes and there are at most 4 // layers. @@ -1553,12 +1506,51 @@ if (layer.layer_type == libaom_examples::MULTILAYER_LAYER_TYPE_ALPHA && layer.layer_metadata_scope >= libaom_examples::SCOPE_GLOBAL) { - write_alpha_information(&buffer, layer.alpha); + const libaom_examples::AlphaInformation &alpha_info = + layer.global_alpha_info; + write_literal(&buffer, alpha_info.alpha_use_idc, 2); + write_literal(&buffer, alpha_info.alpha_simple_flag, 1); + if (!alpha_info.alpha_simple_flag) { + write_literal(&buffer, alpha_info.alpha_bit_depth, 3, /*offset=*/8); + write_literal(&buffer, alpha_info.alpha_clip_idc, 2); + write_literal(&buffer, alpha_info.alpha_incr_flag, 1); + write_literal(&buffer, alpha_info.alpha_transparent_value, + alpha_info.alpha_bit_depth + 1); + write_literal(&buffer, alpha_info.alpha_opaque_value, + alpha_info.alpha_bit_depth + 1); + if (buffer.bit_offset % 8 != 0) { + // ai_byte_alignment_bits + write_literal(&buffer, 0, 8 - (buffer.bit_offset % 8)); + } + assert(buffer.bit_offset % 8 == 0); + + write_literal(&buffer, 0, 6); // ai_reserved_6bits + write_color_properties(&buffer, alpha_info.alpha_color_description); + } else { + write_literal(&buffer, 0, 5); // ai_reserved_5bits + } + assert(buffer.bit_offset % 8 == 0); } else if (layer.layer_type == libaom_examples::MULTILAYER_LAYER_TYPE_DEPTH && layer.layer_metadata_scope >= libaom_examples::SCOPE_GLOBAL) { - write_depth_information(&buffer, layer.depth); + const libaom_examples::DepthInformation &depth_info = + layer.global_depth_info; + write_literal(&buffer, depth_info.z_near.second, 1); + write_literal(&buffer, depth_info.z_far.second, 1); + write_literal(&buffer, depth_info.d_min.second, 1); + write_literal(&buffer, depth_info.d_max.second, 1); + write_literal(&buffer, depth_info.depth_representation_type, 4); + if (depth_info.d_min.second || depth_info.d_max.second) { + write_literal(&buffer, depth_info.disparity_ref_view_id, 2); + } + write_depth_representation_element(&buffer, depth_info.z_near); + write_depth_representation_element(&buffer, depth_info.z_far); + write_depth_representation_element(&buffer, depth_info.d_min); + write_depth_representation_element(&buffer, depth_info.d_max); + if (buffer.bit_offset % 8 != 0) { + write_literal(&buffer, 0, 8 - (buffer.bit_offset % 8)); + } assert(buffer.bit_offset % 8 == 0); } @@ -1580,36 +1572,6 @@ AOM_MIF_KEY_FRAME)) { die("Error: Failed to add metadata\n"); } - - if ((int)multilayer.layers.size() > spatial_id) { - const libaom_examples::LayerMetadata &layer = multilayer.layers[spatial_id]; - for (const libaom_examples::FrameLocalMetadata &local_metadata : - layer.local_metadata) { - if (local_metadata.frame_idx == frame_idx) { - if (layer.layer_type == libaom_examples::MULTILAYER_LAYER_TYPE_ALPHA) { - buffer = { data.data(), 0 }; - write_alpha_information(&buffer, local_metadata.alpha); - if (aom_img_add_metadata(frame, - 34 /*METADATA_TYPE_ALPHA_INFORMATION*/, - buffer.bit_buffer, buffer.bit_offset / 8, - AOM_MIF_ANY_FRAME_LAYER_SPECIFIC)) { - die("Error: Failed to add metadata\n"); - } - } else if (layer.layer_type == - libaom_examples::MULTILAYER_LAYER_TYPE_DEPTH) { - buffer = { data.data(), 0 }; - write_depth_information(&buffer, local_metadata.depth); - if (aom_img_add_metadata(frame, - 35 /*METADATA_TYPE_DEPTH_INFORMATION*/, - buffer.bit_buffer, buffer.bit_offset / 8, - AOM_MIF_ANY_FRAME_LAYER_SPECIFIC)) { - die("Error: Failed to add metadata\n"); - } - } - break; - } - } - } } #if CONFIG_AV1_DECODER @@ -2171,7 +2133,7 @@ &ref_frame_comp_pred); } if (app_input.multilayer_metadata_file != NULL) { - add_multilayer_metadata(&raw, multilayer_metadata, frame_cnt, slx); + add_multilayer_metadata(&raw, multilayer_metadata); } // Set the speed per layer. if (test_speed_per_layer) {
diff --git a/test/multilayer_metadata_test.cc b/test/multilayer_metadata_test.cc index 42eee3b..33ce45f 100644 --- a/test/multilayer_metadata_test.cc +++ b/test/multilayer_metadata_test.cc
@@ -22,27 +22,27 @@ TEST(MultilayerMetadataTest, ParseAlpha) { const std::string metadata = R"( - use_case: 1 # global alpha - layers: - - layer_type: 5 # alpha - luma_plane_only_flag: 1 - layer_metadata_scope: 2 # global - alpha: - alpha_use_idc: 1 # premultiplied - alpha_bit_depth: 8 - alpha_transparent_value: 0 - alpha_opaque_value: 4 +use_case: 1 # global alpha +layers: + - layer_type: 5 # alpha + luma_plane_only_flag: 1 + layer_metadata_scope: 2 # global + alpha: + alpha_use_idc: 1 # premultiplied + alpha_bit_depth: 8 + alpha_transparent_value: 0 + alpha_opaque_value: 4 - - layer_type: 1 # texture - luma_plane_only_flag: 0 - layer_metadata_scope: 2 # global - layer_color_description: - color_range: 1 - color_primaries: 1 - transfer_characteristics: 13 - matrix_coefficients: 6 + - layer_type: 1 # texture + luma_plane_only_flag: 0 + layer_metadata_scope: 2 # global + layer_color_description: + color_range: 1 + color_primaries: 1 + transfer_characteristics: 13 + matrix_coefficients: 6 - )"; + )"; libaom_test::TempOutFile tmp_file(/*text_mode=*/true); fprintf(tmp_file.file(), "%s", metadata.c_str()); fflush(tmp_file.file()); @@ -55,10 +55,10 @@ EXPECT_EQ(multilayer.layers[0].layer_type, 5); EXPECT_EQ(multilayer.layers[0].luma_plane_only_flag, 1); EXPECT_EQ(multilayer.layers[0].layer_metadata_scope, 2); - EXPECT_EQ(multilayer.layers[0].alpha.alpha_use_idc, 1); - EXPECT_EQ(multilayer.layers[0].alpha.alpha_bit_depth, 8); - EXPECT_EQ(multilayer.layers[0].alpha.alpha_transparent_value, 0); - EXPECT_EQ(multilayer.layers[0].alpha.alpha_opaque_value, 4); + EXPECT_EQ(multilayer.layers[0].global_alpha_info.alpha_use_idc, 1); + EXPECT_EQ(multilayer.layers[0].global_alpha_info.alpha_bit_depth, 8); + EXPECT_EQ(multilayer.layers[0].global_alpha_info.alpha_transparent_value, 0); + EXPECT_EQ(multilayer.layers[0].global_alpha_info.alpha_opaque_value, 4); EXPECT_EQ(multilayer.layers[1].layer_type, 1); EXPECT_EQ(multilayer.layers[1].luma_plane_only_flag, 0); EXPECT_EQ(multilayer.layers[1].layer_metadata_scope, 2); @@ -76,26 +76,26 @@ TEST(MultilayerMetadataTest, ParseDepth) { const std::string metadata = R"( - use_case: 2 # global depth - layers: - - layer_type: 6 # depth - luma_plane_only_flag: 1 - layer_metadata_scope: 2 # global - depth: - z_near: 1.456 - z_far: 9.786 - depth_representation_type: 2 +use_case: 2 # global depth +layers: + - layer_type: 6 # depth + luma_plane_only_flag: 1 + layer_metadata_scope: 2 # global + depth: + z_near: 1.456 + z_far: 9.786 + depth_representation_type: 2 - - layer_type: 1 # texture - luma_plane_only_flag: 0 - layer_metadata_scope: 2 # global - layer_color_description: - color_range: 1 - color_primaries: 1 - transfer_characteristics: 13 - matrix_coefficients: 6 + - layer_type: 1 # texture + luma_plane_only_flag: 0 + layer_metadata_scope: 2 # global + layer_color_description: + color_range: 1 + color_primaries: 1 + transfer_characteristics: 13 + matrix_coefficients: 6 - )"; + )"; libaom_test::TempOutFile tmp_file(/*text_mode=*/true); fprintf(tmp_file.file(), "%s", metadata.c_str()); fflush(tmp_file.file()); @@ -107,15 +107,16 @@ EXPECT_EQ(multilayer.layers[0].layer_type, 6); EXPECT_EQ(multilayer.layers[0].luma_plane_only_flag, 1); EXPECT_EQ(multilayer.layers[0].layer_metadata_scope, 2); - EXPECT_TRUE(multilayer.layers[0].depth.z_near.second); + EXPECT_TRUE(multilayer.layers[0].global_depth_info.z_near.second); EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].depth.z_near.first), + multilayer.layers[0].global_depth_info.z_near.first), 1.456, 0.00001); - EXPECT_TRUE(multilayer.layers[0].depth.z_far.second); + EXPECT_TRUE(multilayer.layers[0].global_depth_info.z_far.second); EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].depth.z_far.first), + multilayer.layers[0].global_depth_info.z_far.first), 9.786, 0.00001); - EXPECT_EQ(multilayer.layers[0].depth.depth_representation_type, 2); + EXPECT_EQ(multilayer.layers[0].global_depth_info.depth_representation_type, + 2); EXPECT_EQ(multilayer.layers[1].layer_type, 1); EXPECT_EQ(multilayer.layers[1].luma_plane_only_flag, 0); EXPECT_EQ(multilayer.layers[1].layer_metadata_scope, 2); @@ -131,115 +132,22 @@ 6); } -TEST(MultilayerMetadataTest, ParseLocalDepth) { - const std::string metadata = R"( -use_case: 4 # depth -layers: - - layer_type: 6 # depth - luma_plane_only_flag: 1 - layer_metadata_scope: 3 # mixed - depth: - z_near: 1.456 - z_far: 9.786 - depth_representation_type: 2 - local_metadata: - - frame_idx: 4 - depth: - z_near: 2.78933 - z_far: 20.663 - depth_representation_type: 0 - - frame_idx: 100 - depth: - z_near: 0 - z_far: 24 - depth_representation_type: 0 - - - layer_type: 1 # texture - luma_plane_only_flag: 0 - layer_metadata_scope: 3 # mixed - layer_color_description: - color_range: 1 - color_primaries: 1 - transfer_characteristics: 13 - matrix_coefficients: 6 - )"; - libaom_test::TempOutFile tmp_file; - fprintf(tmp_file.file(), "%s", metadata.c_str()); - fflush(tmp_file.file()); - - MultilayerMetadata multilayer; - EXPECT_TRUE(parse_multilayer_file(tmp_file.file_name().c_str(), &multilayer)); - EXPECT_EQ(multilayer.use_case, 4); - ASSERT_EQ(multilayer.layers.size(), 2); - EXPECT_EQ(multilayer.layers[0].layer_type, 6); - EXPECT_EQ(multilayer.layers[0].luma_plane_only_flag, 1); - EXPECT_EQ(multilayer.layers[0].layer_metadata_scope, 3); - EXPECT_TRUE(multilayer.layers[0].depth.z_near.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].depth.z_near.first), - 1.456, 0.00001); - EXPECT_TRUE(multilayer.layers[0].depth.z_far.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].depth.z_far.first), - 9.786, 0.00001); - EXPECT_EQ(multilayer.layers[0].depth.depth_representation_type, 2); - ASSERT_EQ(multilayer.layers[0].local_metadata.size(), 2); - EXPECT_EQ(multilayer.layers[0].local_metadata[0].frame_idx, 4); - EXPECT_TRUE(multilayer.layers[0].local_metadata[0].depth.z_near.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].local_metadata[0].depth.z_near.first), - 2.78933, 0.00001); - EXPECT_TRUE(multilayer.layers[0].local_metadata[0].depth.z_far.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].local_metadata[0].depth.z_far.first), - 20.663, 0.00001); - EXPECT_EQ( - multilayer.layers[0].local_metadata[0].depth.depth_representation_type, - 0); - EXPECT_EQ(multilayer.layers[0].local_metadata[1].frame_idx, 100); - EXPECT_TRUE(multilayer.layers[0].local_metadata[1].depth.z_near.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].local_metadata[1].depth.z_near.first), - 0, 0.00001); - EXPECT_TRUE(multilayer.layers[0].local_metadata[1].depth.z_far.second); - EXPECT_NEAR(depth_representation_element_to_double( - multilayer.layers[0].local_metadata[1].depth.z_far.first), - 24, 0.00001); - EXPECT_EQ( - multilayer.layers[0].local_metadata[1].depth.depth_representation_type, - 0); - EXPECT_EQ(multilayer.layers[1].layer_type, 1); - EXPECT_EQ(multilayer.layers[1].luma_plane_only_flag, 0); - EXPECT_EQ(multilayer.layers[1].layer_metadata_scope, 3); - EXPECT_TRUE(multilayer.layers[1].layer_color_description.second); - EXPECT_EQ(multilayer.layers[1].layer_color_description.first.color_range, 1); - EXPECT_EQ(multilayer.layers[1].layer_color_description.first.color_primaries, - 1); - EXPECT_EQ(multilayer.layers[1] - .layer_color_description.first.transfer_characteristics, - 13); - EXPECT_EQ( - multilayer.layers[1].layer_color_description.first.matrix_coefficients, - 6); - EXPECT_EQ(multilayer.layers[1].local_metadata.size(), 0); -} - TEST(MultilayerMetadataTest, ParseInvalid) { const std::string metadata = R"( -use_case: 3 # alpha +use_case: 1 # global alpha layers: - layer_type: 5 # alpha luma_plane_only_flag: 1 - layer_metadata_scope: 3 # mixed + layer_metadata_scope: 2 # global - layer_type: 1 # texture luma_plane_only_flag: 0 - layer_metadata_scope: 3 # mixed + layer_metadata_scope: 2 # global - layer_type: 6 # depth => bad layer type luma_plane_only_flag: 1 - layer_metadata_scope: 3 # mixed + layer_metadata_scope: 2 # global )"; libaom_test::TempOutFile tmp_file(/*text_mode=*/true); fprintf(tmp_file.file(), "%s", metadata.c_str()); @@ -254,16 +162,16 @@ TEST(MultilayerMetadataTest, ParseBadIndent) { const std::string metadata = R"( - use_case: 1 # global alpha - layers: - - layer_type: 5 # alpha - luma_plane_only_flag: 1 - layer_metadata_scope: 2 # global +use_case: 1 # global alpha +layers: + - layer_type: 5 # alpha + luma_plane_only_flag: 1 + layer_metadata_scope: 2 # global - - layer_type: 1 # texture - luma_plane_only_flag: 0 - layer_metadata_scope: 2 # global - )"; + - layer_type: 1 # texture + luma_plane_only_flag: 0 + layer_metadata_scope: 2 # global + )"; libaom_test::TempOutFile tmp_file(/*text_mode=*/true); fprintf(tmp_file.file(), "%s", metadata.c_str()); fflush(tmp_file.file()); @@ -277,17 +185,17 @@ TEST(MultilayerMetadataTest, ParseUnknownField) { const std::string metadata = R"( - use_case: 1 # global alpha - layers: - - layer_type: 5 # alpha - luma_plane_only_flag: 1 - layer_metadata_scope: 2 # global - foobar: 42 +use_case: 1 # global alpha +layers: + - layer_type: 5 # alpha + luma_plane_only_flag: 1 + layer_metadata_scope: 2 # global + foobar: 42 - - layer_type: 1 # texture - luma_plane_only_flag: 0 - layer_metadata_scope: 2 # global - )"; + - layer_type: 1 # texture + luma_plane_only_flag: 0 + layer_metadata_scope: 2 # global + )"; libaom_test::TempOutFile tmp_file(/*text_mode=*/true); fprintf(tmp_file.file(), "%s", metadata.c_str()); fflush(tmp_file.file());