Skip to content

Commit

Permalink
Merge branch 'develop' release candidate v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
stian-svedenborg committed Feb 23, 2016
2 parents bb0b3fc + 534ebae commit 7a7fd69
Show file tree
Hide file tree
Showing 44 changed files with 2,229 additions and 545 deletions.
78 changes: 47 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ set(MAGICKCORE_HDRI_ENABLE 0 CACHE STRING
"If USE_IMAGEMAGICK_INTEGRATION is on, then this constant is passed on to the imagemagick headers. See ImageMagick Docs for more info." FORCE)

# Primary library.
add_library(xyuv
xyuv/src/xyuv.cpp
)
add_library(xyuv
xyuv/src/xyuv.cpp)

target_include_directories(xyuv
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/xyuv/include>
Expand All @@ -38,34 +37,51 @@ target_include_directories(xyuv

# Primary library
add_library(xyuv_core STATIC
xyuv/src/pixel_packer.cpp
xyuv/src/rgb_conversion.cpp
xyuv/src/utility.cpp
xyuv/src/config-parser/chroma_siting_parser.cpp
xyuv/src/config-parser/pixel_format_parser.cpp
xyuv/src/config-parser/read_json.cpp
xyuv/src/config-parser/rgb_conversion_parser.cpp
xyuv/src/config-parser/minicalc/ast.cpp
xyuv/src/config-parser/minicalc/minicalc.cpp
xyuv/src/config-parser/minicalc/parser.cpp
xyuv/src/config-parser/minicalc/operations.cpp
xyuv/src/config-parser/minicalc_entry_point.cpp
xyuv/src/io/xyuv_io.cpp
xyuv/src/io/io_structs.cpp
xyuv/src/format.cpp
xyuv/src/yuv_image.cpp
xyuv/src/subsampler.cpp
xyuv/src/coder.cpp
xyuv/src/rgb_image.cpp
xyuv/src/config-parser/config_manager.cpp
xyuv/src/frame_manipulation.cpp
xyuv/src/comparison_operators.cpp
xyuv/src/config-parser/parse_error.h
xyuv/src/config-parser/parse_helpers.cpp
xyuv/include/xyuv/large_buffer.h
xyuv/src/config-parser/format_validator.h
xyuv/src/config-parser/format_validator.cpp
)
xyuv/src/pixel_packer.cpp
xyuv/src/rgb_conversion.cpp
xyuv/src/utility.cpp
xyuv/src/config-parser/chroma_siting_parser.cpp
xyuv/src/config-parser/pixel_format_parser.cpp
xyuv/src/config-parser/read_json.cpp
xyuv/src/config-parser/rgb_conversion_parser.cpp
xyuv/src/config-parser/minicalc/ast.cpp
xyuv/src/config-parser/minicalc/minicalc.cpp
xyuv/src/config-parser/minicalc/parser.cpp
xyuv/src/config-parser/minicalc/operations.cpp
xyuv/src/config-parser/minicalc_entry_point.cpp
xyuv/src/format.cpp
xyuv/src/yuv_image.cpp
xyuv/src/subsampler.cpp
xyuv/src/coder.cpp
xyuv/src/rgb_image.cpp
xyuv/src/config-parser/config_manager.cpp
xyuv/src/frame_manipulation.cpp
xyuv/src/comparison_operators.cpp
xyuv/src/config-parser/parse_error.h
xyuv/src/config-parser/parse_helpers.cpp
xyuv/include/xyuv/large_buffer.h
xyuv/src/config-parser/format_validator.h
xyuv/src/config-parser/format_validator.cpp
xyuv/src/block_reorder.cpp
xyuv/src/block_reorder.h
xyuv/src/io/xyuv_io.cpp
xyuv/src/io/versions/core_io_structs.h
xyuv/src/io/versions/core_io_structs.cpp
xyuv/src/io/versions/file_format_entry_point.h
# File format versions
xyuv/src/io/versions/0/entry_point.h
xyuv/src/io/versions/0/entry_point.cpp
xyuv/src/io/versions/0/file_header.h
xyuv/src/io/versions/0/io_structs.h
xyuv/src/io/versions/0/io_structs.cpp

xyuv/src/io/versions/1/entry_point.h
xyuv/src/io/versions/1/entry_point.cpp
xyuv/src/io/versions/1/file_header.h
xyuv/src/io/versions/1/io_structs.h
xyuv/src/io/versions/1/io_structs.cpp

)

target_include_directories(xyuv_core
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/xyuv/include>
Expand Down
2 changes: 1 addition & 1 deletion formats/px_fmt/IMC1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
{
# The U plane must start at a line that is a multiple of 16. [MSDN]
"base_offset" : "next_multiple(plane[1].base_offset + plane[1].size, 16 * plane[0].line_stride )",
"base_offset" : "next_multiple(plane[1].base_offset + plane[1].plane_size, 16 * plane[0].line_stride )",

# Much the same as for the V plane
"line_stride" : "plane[0].line_stride",
Expand Down
4 changes: 2 additions & 2 deletions formats/px_fmt/IMC3
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "next_multiple(image_w, macro_px_w)",
"plane_size" : "next_multiple(image_w, macro_px_w)*(image_h/macro_px_h)",
"block_stride" : 8,
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[1].base_offset + plane[1].size",
"base_offset" : "plane[1].base_offset + plane[1].plane_size",
"line_stride" : "next_multiple(image_w, macro_px_w)",
"plane_size" : "next_multiple(image_w, macro_px_w)*(image_h/macro_px_h)",
"block_stride" : 8,
Expand Down
4 changes: 2 additions & 2 deletions formats/px_fmt/IYUV
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[1].base_offset + plane[1].size",
"base_offset" : "plane[1].base_offset + plane[1].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
Expand Down
2 changes: 1 addition & 1 deletion formats/px_fmt/NV12
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*2",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)*2",
"block_stride" : 16,
Expand Down
4 changes: 2 additions & 2 deletions formats/px_fmt/YV12
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[1].base_offset + plane[1].size",
"base_offset" : "plane[1].base_offset + plane[1].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
Expand Down
4 changes: 2 additions & 2 deletions formats/px_fmt/YV16
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[1].base_offset + plane[1].size",
"base_offset" : "plane[1].base_offset + plane[1].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
Expand Down
4 changes: 2 additions & 2 deletions formats/px_fmt/YVU9
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[0].base_offset + plane[0].size",
"base_offset" : "plane[0].base_offset + plane[0].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
"interleave_pattern" : "NO_INTERLEAVING"
},
{
"base_offset" : "plane[1].base_offset + plane[1].size",
"base_offset" : "plane[1].base_offset + plane[1].plane_size",
"line_stride" : "image_w/macro_px_w",
"plane_size" : "(next_multiple(image_w, macro_px_w)/macro_px_w)*(next_multiple(image_h, macro_px_h)/macro_px_h)",
"block_stride" : 8,
Expand Down
32 changes: 16 additions & 16 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

# Add targets
add_executable(unit_tests
main.cpp
parsing_test.cpp
utility_testing.cpp
yuv_image_testing.cpp
rgb_test.cpp
unorm_test.cpp
sampling_test.cpp
TestResources.cpp
TestResources.h
continuation_blocks.cpp
interleave_test.cpp
bit_packing.cpp)
main.cpp
parsing_test.cpp
utility_testing.cpp
yuv_image_testing.cpp
rgb_test.cpp
unorm_test.cpp
sampling_test.cpp
TestResources.cpp
TestResources.h
continuation_blocks.cpp
interleave_test.cpp
bit_packing.cpp block_reorder.cpp)



add_executable(integration_testing
integration_testing/main.cpp
integration_testing/regress_format_templates.cpp
integration_testing/file_format_testing.cpp
integration_testing/main.cpp
integration_testing/regress_format_templates.cpp
integration_testing/file_format_testing.cpp

TestResources.cpp TestResources.h)
TestResources.cpp TestResources.h integration_testing/specific_formats_testing.cpp)

target_include_directories(unit_tests
PRIVATE xyuv.PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion testing/TestResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ Resources::Resources()
, Lena512("testing/integration_testing/test_data/lena512color.png")
, Tiny("testing/integration_testing/test_data/tiny.png")
{

config_.load_configurations("testing/integration_testing/test_data/formats/");
}
142 changes: 142 additions & 0 deletions testing/block_reorder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Stian Valentin Svedenborg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <gtest/gtest.h>
#include <xyuv.h>
#include <xyuv/structures/format.h>
#include <xyuv/frame.h>
#include <xyuv/yuv_image.h>
#include "TestResources.h"
#include "../xyuv/src/utility.h"
#include "../xyuv/src/to_string.h"

std::pair<uint32_t,uint32_t > get_block_order_offset(uint32_t block_x, uint32_t block_y, const ::block_order & block_order);

static xyuv::format create_block_reordered_format() {
xyuv::format format;

format.chroma_siting = Resources::config().get_chroma_siting("444");
format.conversion_matrix = Resources::config().get_conversion_matrix("identity");

format.image_w = 2;
format.image_h = 2;

xyuv::plane plane;

plane.block_order.mega_block_width = 2;
plane.block_order.mega_block_height = 2;

plane.block_order.x_mask[0] = block_order::NOT_USED;
plane.block_order.x_mask[1] = 0;

plane.block_order.y_mask[0] = 0;
plane.block_order.y_mask[1] = block_order::NOT_USED;


plane.base_offset = 0;
plane.interleave_mode = xyuv::interleave_pattern::NO_INTERLEAVING;
plane.block_stride = 8;
plane.line_stride = xyuv::next_multiple(format.image_w, plane.block_order.mega_block_width);

format.size = plane.line_stride*format.image_h;
plane.size = format.size;


format.planes.push_back(plane);

xyuv::channel_block & block = format.channel_blocks[xyuv::channel::Y];
block.w = 1;
block.h = 1;

xyuv::sample s0;
s0.integer_bits = 8;
s0.fractional_bits = 0;
s0.offset = 0;
s0.plane = 0;
s0.has_continuation = false;

block.samples.push_back(s0);


return format;
}


TEST(BlockReorder, BlockOffset) {
block_order bo;

bo.mega_block_height = 0xffffu +1;
bo.mega_block_width = 0xffffu +1;

for (uint8_t i = 0; i < 32; i++) {
bo.x_mask[i] = i;
bo.y_mask[i] = i;
}

ASSERT_EQ(std::make_pair(0u,0u), get_block_order_offset(0xffffffffu, 0xffffffffu, bo));

for (uint8_t i = 0; i < 32; i++) {
bo.x_mask[i] = (i & 1) ? block_order::NOT_USED : i / 2u;
bo.y_mask[i] = (i & 1) ? i / 2u : block_order::NOT_USED ;
}

ASSERT_EQ(std::make_pair(0xffffu, 0xffffu), get_block_order_offset(0xffffffffu, 0xffffffffu, bo));
ASSERT_EQ(std::make_pair(0xffffu, 0xffffu), get_block_order_offset( 0xffffu, 0xffffu, bo));
ASSERT_EQ(std::make_pair(0xffffu, 0x0u ), get_block_order_offset( 0xffu, 0xffu, bo));
ASSERT_EQ(std::make_pair( 0xffu, 0x0u ), get_block_order_offset( 0xfu, 0xfu, bo));
ASSERT_EQ(std::make_pair( 0xfeu, 0x0u ), get_block_order_offset( 0xeu, 0xfu, bo));
ASSERT_EQ(std::make_pair( 0xeeu, 0x0u ), get_block_order_offset(0xeu - 0x4u, 0xfu, bo));
}

TEST(BlockReorder, ReorderTest) {
xyuv::frame frame = xyuv::create_frame(create_block_reordered_format(), nullptr, 0);

frame.data[0] = 0;
frame.data[1] = 2;
frame.data[2] = 1;
frame.data[3] = 3;


xyuv::yuv_image image = decode_frame(frame);

// Check that lines are loaded correctly.
auto fmt1 = frame.format;
fmt1.planes[0].block_order.mega_block_width = 1;
fmt1.planes[0].block_order.mega_block_height = 1;

xyuv::frame linear_frame = encode_frame(image, fmt1);
for (std::size_t i = 0; i < frame.format.size; i++) {
SCOPED_TRACE("First " + xyuv::to_string(i));
ASSERT_EQ(static_cast<uint8_t>(i), linear_frame.data[i]);
}

// Check that operation is invertible
xyuv::frame repacked_frame = encode_frame(image, frame.format);
for (std::size_t i = 0; i < frame.format.size; i++) {
SCOPED_TRACE("First " + xyuv::to_string(i));
ASSERT_EQ(static_cast<uint8_t>(frame.data[i]), repacked_frame.data[i]);
}


}
Loading

0 comments on commit 7a7fd69

Please sign in to comment.