1// SPDX-License-Identifier: Apache-2.0 2// ---------------------------------------------------------------------------- 3// Copyright 2023 Arm Limited 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); you may not 6// use this file except in compliance with the License. You may obtain a copy 7// of the License at: 8// 9// http://www.apache.org/licenses/LICENSE-2.0 10// 11// Unless required by applicable law or agreed to in writing, software 12// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14// License for the specific language governing permissions and limitations 15// under the License. 16// ---------------------------------------------------------------------------- 17 18/** 19 * @brief Unit tests for the vectorized SIMD functionality. 20 */ 21 22#include <limits> 23 24#include "gtest/gtest.h" 25 26#include "../astcenc.h" 27 28namespace astcenc 29{ 30 31/** @brief Test harness for exploring issue #447. */ 32TEST(decode, decode12x12) 33{ 34 astcenc_error status; 35 astcenc_config config; 36 astcenc_context* context; 37 38 static const astcenc_swizzle swizzle { 39 ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A 40 }; 41 42 uint8_t data[16] { 43#if 0 44 0x84,0x00,0x38,0xC8,0x00,0x00,0x00,0x00, 45 0x00,0x00,0x00,0x00,0x00,0xB3,0x4D,0x78 46#else 47 0x29,0x00,0x1A,0x97,0x01,0x00,0x00,0x00, 48 0x00,0x00,0x00,0x00,0x00,0xCF,0x97,0x86 49#endif 50 }; 51 52 uint8_t output[12*12*4]; 53 astcenc_config_init(ASTCENC_PRF_LDR, 12, 12, 1, ASTCENC_PRE_MEDIUM, 0, &config); 54 55 status = astcenc_context_alloc(&config, 1, &context); 56 EXPECT_EQ(status, ASTCENC_SUCCESS); 57 58 astcenc_image image; 59 image.dim_x = 12; 60 image.dim_y = 12; 61 image.dim_z = 1; 62 image.data_type = ASTCENC_TYPE_U8; 63 uint8_t* slices = output; 64 image.data = reinterpret_cast<void**>(&slices); 65 66 status = astcenc_decompress_image(context, data, 16, &image, &swizzle, 0); 67 EXPECT_EQ(status, ASTCENC_SUCCESS); 68 69 for (int y = 0; y < 12; y++) 70 { 71 for (int x = 0; x < 12; x++) 72 { 73 uint8_t* pixel = output + (12 * 4 * y) + (4 * x); 74 printf("[%2dx%2d] = %03d, %03d, %03d, %03d\n", x, y, pixel[0], pixel[1], pixel[2], pixel[3]); 75 } 76 } 77} 78 79} 80