1cc1dc7a3Sopenharmony_ci// SPDX-License-Identifier: Apache-2.0 2cc1dc7a3Sopenharmony_ci// ---------------------------------------------------------------------------- 3cc1dc7a3Sopenharmony_ci// Copyright 2011-2023 Arm Limited 4cc1dc7a3Sopenharmony_ci// 5cc1dc7a3Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); you may not 6cc1dc7a3Sopenharmony_ci// use this file except in compliance with the License. You may obtain a copy 7cc1dc7a3Sopenharmony_ci// of the License at: 8cc1dc7a3Sopenharmony_ci// 9cc1dc7a3Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 10cc1dc7a3Sopenharmony_ci// 11cc1dc7a3Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 12cc1dc7a3Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13cc1dc7a3Sopenharmony_ci// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14cc1dc7a3Sopenharmony_ci// License for the specific language governing permissions and limitations 15cc1dc7a3Sopenharmony_ci// under the License. 16cc1dc7a3Sopenharmony_ci// ---------------------------------------------------------------------------- 17cc1dc7a3Sopenharmony_ci 18cc1dc7a3Sopenharmony_ci/** 19cc1dc7a3Sopenharmony_ci * @brief Functions and data declarations. 20cc1dc7a3Sopenharmony_ci */ 21cc1dc7a3Sopenharmony_ci 22cc1dc7a3Sopenharmony_ci#ifndef ASTCENCCLI_INTERNAL_INCLUDED 23cc1dc7a3Sopenharmony_ci#define ASTCENCCLI_INTERNAL_INCLUDED 24cc1dc7a3Sopenharmony_ci 25cc1dc7a3Sopenharmony_ci#include <cstddef> 26cc1dc7a3Sopenharmony_ci#include <cstdint> 27cc1dc7a3Sopenharmony_ci#include <cstdio> 28cc1dc7a3Sopenharmony_ci#include <cstdlib> 29cc1dc7a3Sopenharmony_ci 30cc1dc7a3Sopenharmony_ci#include "astcenc.h" 31cc1dc7a3Sopenharmony_ci#include "astcenc_mathlib.h" 32cc1dc7a3Sopenharmony_ci 33cc1dc7a3Sopenharmony_ci/** 34cc1dc7a3Sopenharmony_ci * @brief The payload stored in a compressed ASTC image. 35cc1dc7a3Sopenharmony_ci */ 36cc1dc7a3Sopenharmony_cistruct astc_compressed_image 37cc1dc7a3Sopenharmony_ci{ 38cc1dc7a3Sopenharmony_ci /** @brief The block width in texels. */ 39cc1dc7a3Sopenharmony_ci unsigned int block_x; 40cc1dc7a3Sopenharmony_ci 41cc1dc7a3Sopenharmony_ci /** @brief The block height in texels. */ 42cc1dc7a3Sopenharmony_ci unsigned int block_y; 43cc1dc7a3Sopenharmony_ci 44cc1dc7a3Sopenharmony_ci /** @brief The block depth in texels. */ 45cc1dc7a3Sopenharmony_ci unsigned int block_z; 46cc1dc7a3Sopenharmony_ci 47cc1dc7a3Sopenharmony_ci /** @brief The image width in texels. */ 48cc1dc7a3Sopenharmony_ci unsigned int dim_x; 49cc1dc7a3Sopenharmony_ci 50cc1dc7a3Sopenharmony_ci /** @brief The image height in texels. */ 51cc1dc7a3Sopenharmony_ci unsigned int dim_y; 52cc1dc7a3Sopenharmony_ci 53cc1dc7a3Sopenharmony_ci /** @brief The image depth in texels. */ 54cc1dc7a3Sopenharmony_ci unsigned int dim_z; 55cc1dc7a3Sopenharmony_ci 56cc1dc7a3Sopenharmony_ci /** @brief The binary data payload. */ 57cc1dc7a3Sopenharmony_ci uint8_t* data; 58cc1dc7a3Sopenharmony_ci 59cc1dc7a3Sopenharmony_ci /** @brief The binary data length in bytes. */ 60cc1dc7a3Sopenharmony_ci size_t data_len; 61cc1dc7a3Sopenharmony_ci}; 62cc1dc7a3Sopenharmony_ci 63cc1dc7a3Sopenharmony_ci/** 64cc1dc7a3Sopenharmony_ci * @brief Config options that have been read from command line. 65cc1dc7a3Sopenharmony_ci */ 66cc1dc7a3Sopenharmony_cistruct cli_config_options 67cc1dc7a3Sopenharmony_ci{ 68cc1dc7a3Sopenharmony_ci /** @brief The number of threads to use for processing. */ 69cc1dc7a3Sopenharmony_ci unsigned int thread_count; 70cc1dc7a3Sopenharmony_ci 71cc1dc7a3Sopenharmony_ci /** @brief The number of repeats to execute for benchmarking. */ 72cc1dc7a3Sopenharmony_ci unsigned int repeat_count; 73cc1dc7a3Sopenharmony_ci 74cc1dc7a3Sopenharmony_ci /** @brief The number of image slices to load for a 3D image. */ 75cc1dc7a3Sopenharmony_ci unsigned int array_size; 76cc1dc7a3Sopenharmony_ci 77cc1dc7a3Sopenharmony_ci /** @brief @c true if running in silent mode with minimal output. */ 78cc1dc7a3Sopenharmony_ci bool silentmode; 79cc1dc7a3Sopenharmony_ci 80cc1dc7a3Sopenharmony_ci /** @brief @c true if the images should be y-flipped. */ 81cc1dc7a3Sopenharmony_ci bool y_flip; 82cc1dc7a3Sopenharmony_ci 83cc1dc7a3Sopenharmony_ci /** @brief @c true if diagnostic images should be stored. */ 84cc1dc7a3Sopenharmony_ci bool diagnostic_images; 85cc1dc7a3Sopenharmony_ci 86cc1dc7a3Sopenharmony_ci /** @brief The low exposure fstop for error computation. */ 87cc1dc7a3Sopenharmony_ci int low_fstop; 88cc1dc7a3Sopenharmony_ci 89cc1dc7a3Sopenharmony_ci /** @brief The high exposure fstop for error computation. */ 90cc1dc7a3Sopenharmony_ci int high_fstop; 91cc1dc7a3Sopenharmony_ci 92cc1dc7a3Sopenharmony_ci /** @brief The pre-encode swizzle. */ 93cc1dc7a3Sopenharmony_ci astcenc_swizzle swz_encode; 94cc1dc7a3Sopenharmony_ci 95cc1dc7a3Sopenharmony_ci /** @brief The post-decode swizzle. */ 96cc1dc7a3Sopenharmony_ci astcenc_swizzle swz_decode; 97cc1dc7a3Sopenharmony_ci}; 98cc1dc7a3Sopenharmony_ci 99cc1dc7a3Sopenharmony_ci/** 100cc1dc7a3Sopenharmony_ci * @brief Print a string to stderr. 101cc1dc7a3Sopenharmony_ci */ 102cc1dc7a3Sopenharmony_cistatic inline void print_error( 103cc1dc7a3Sopenharmony_ci const char* format 104cc1dc7a3Sopenharmony_ci) { 105cc1dc7a3Sopenharmony_ci fprintf(stderr, "%s", format); 106cc1dc7a3Sopenharmony_ci} 107cc1dc7a3Sopenharmony_ci 108cc1dc7a3Sopenharmony_ci/** 109cc1dc7a3Sopenharmony_ci * @brief Print a formatted string to stderr. 110cc1dc7a3Sopenharmony_ci */ 111cc1dc7a3Sopenharmony_citemplate<typename ... _Args> 112cc1dc7a3Sopenharmony_cistatic inline void print_error( 113cc1dc7a3Sopenharmony_ci const char* format, 114cc1dc7a3Sopenharmony_ci _Args...args 115cc1dc7a3Sopenharmony_ci) { 116cc1dc7a3Sopenharmony_ci fprintf(stderr, format, args...); 117cc1dc7a3Sopenharmony_ci} 118cc1dc7a3Sopenharmony_ci 119cc1dc7a3Sopenharmony_ci/** 120cc1dc7a3Sopenharmony_ci * @brief Load uncompressed image. 121cc1dc7a3Sopenharmony_ci * 122cc1dc7a3Sopenharmony_ci * @param filename The file path on disk. 123cc1dc7a3Sopenharmony_ci * @param y_flip Should this image be Y flipped? 124cc1dc7a3Sopenharmony_ci * @param[out] is_hdr Is the loaded image HDR? 125cc1dc7a3Sopenharmony_ci * @param[out] component_count The number of components in the loaded image. 126cc1dc7a3Sopenharmony_ci * 127cc1dc7a3Sopenharmony_ci * @return The astc image file, or nullptr on error. 128cc1dc7a3Sopenharmony_ci */ 129cc1dc7a3Sopenharmony_ciastcenc_image* load_ncimage( 130cc1dc7a3Sopenharmony_ci const char* filename, 131cc1dc7a3Sopenharmony_ci bool y_flip, 132cc1dc7a3Sopenharmony_ci bool& is_hdr, 133cc1dc7a3Sopenharmony_ci unsigned int& component_count); 134cc1dc7a3Sopenharmony_ci 135cc1dc7a3Sopenharmony_ci/** 136cc1dc7a3Sopenharmony_ci * @brief Load uncompressed PNG image. 137cc1dc7a3Sopenharmony_ci * 138cc1dc7a3Sopenharmony_ci * @param filename The file path on disk. 139cc1dc7a3Sopenharmony_ci * @param y_flip Should this image be Y flipped? 140cc1dc7a3Sopenharmony_ci * @param[out] is_hdr Is the loaded image HDR? 141cc1dc7a3Sopenharmony_ci * @param[out] component_count The number of components in the loaded image. 142cc1dc7a3Sopenharmony_ci * 143cc1dc7a3Sopenharmony_ci * @return The astc image file, or nullptr on error. 144cc1dc7a3Sopenharmony_ci */ 145cc1dc7a3Sopenharmony_ciastcenc_image* load_png_with_wuffs( 146cc1dc7a3Sopenharmony_ci const char* filename, 147cc1dc7a3Sopenharmony_ci bool y_flip, 148cc1dc7a3Sopenharmony_ci bool& is_hdr, 149cc1dc7a3Sopenharmony_ci unsigned int& component_count); 150cc1dc7a3Sopenharmony_ci 151cc1dc7a3Sopenharmony_ci/** 152cc1dc7a3Sopenharmony_ci * @brief Save an uncompressed image. 153cc1dc7a3Sopenharmony_ci * 154cc1dc7a3Sopenharmony_ci * @param img The source data for the image. 155cc1dc7a3Sopenharmony_ci * @param filename The name of the file to save. 156cc1dc7a3Sopenharmony_ci * @param y_flip Should the image be vertically flipped? 157cc1dc7a3Sopenharmony_ci * 158cc1dc7a3Sopenharmony_ci * @return @c true if the image saved OK, @c false on error. 159cc1dc7a3Sopenharmony_ci */ 160cc1dc7a3Sopenharmony_cibool store_ncimage( 161cc1dc7a3Sopenharmony_ci const astcenc_image* img, 162cc1dc7a3Sopenharmony_ci const char* filename, 163cc1dc7a3Sopenharmony_ci int y_flip); 164cc1dc7a3Sopenharmony_ci 165cc1dc7a3Sopenharmony_ci/** 166cc1dc7a3Sopenharmony_ci * @brief Check if the output file type requires a specific bitness. 167cc1dc7a3Sopenharmony_ci * 168cc1dc7a3Sopenharmony_ci * @param filename The file name, containing hte extension to check. 169cc1dc7a3Sopenharmony_ci * 170cc1dc7a3Sopenharmony_ci * @return Valid values are: 171cc1dc7a3Sopenharmony_ci * * -1 - error - unknown file type. 172cc1dc7a3Sopenharmony_ci * * 0 - no enforced bitness. 173cc1dc7a3Sopenharmony_ci * * 8 - enforced 8-bit UNORM. 174cc1dc7a3Sopenharmony_ci * * 16 - enforced 16-bit FP16. 175cc1dc7a3Sopenharmony_ci */ 176cc1dc7a3Sopenharmony_ciint get_output_filename_enforced_bitness( 177cc1dc7a3Sopenharmony_ci const char* filename); 178cc1dc7a3Sopenharmony_ci 179cc1dc7a3Sopenharmony_ci/** 180cc1dc7a3Sopenharmony_ci * @brief Allocate a new image in a canonical format. 181cc1dc7a3Sopenharmony_ci * 182cc1dc7a3Sopenharmony_ci * Allocated images must be freed with a @c free_image() call. 183cc1dc7a3Sopenharmony_ci * 184cc1dc7a3Sopenharmony_ci * @param bitness The number of bits per component (8, 16, or 32). 185cc1dc7a3Sopenharmony_ci * @param dim_x The width of the image, in texels. 186cc1dc7a3Sopenharmony_ci * @param dim_y The height of the image, in texels. 187cc1dc7a3Sopenharmony_ci * @param dim_z The depth of the image, in texels. 188cc1dc7a3Sopenharmony_ci * 189cc1dc7a3Sopenharmony_ci * @return The allocated image, or @c nullptr on error. 190cc1dc7a3Sopenharmony_ci */ 191cc1dc7a3Sopenharmony_ciastcenc_image* alloc_image( 192cc1dc7a3Sopenharmony_ci unsigned int bitness, 193cc1dc7a3Sopenharmony_ci unsigned int dim_x, 194cc1dc7a3Sopenharmony_ci unsigned int dim_y, 195cc1dc7a3Sopenharmony_ci unsigned int dim_z); 196cc1dc7a3Sopenharmony_ci 197cc1dc7a3Sopenharmony_ci/** 198cc1dc7a3Sopenharmony_ci * @brief Free an image. 199cc1dc7a3Sopenharmony_ci * 200cc1dc7a3Sopenharmony_ci * @param img The image to free. 201cc1dc7a3Sopenharmony_ci */ 202cc1dc7a3Sopenharmony_civoid free_image( 203cc1dc7a3Sopenharmony_ci astcenc_image* img); 204cc1dc7a3Sopenharmony_ci 205cc1dc7a3Sopenharmony_ci/** 206cc1dc7a3Sopenharmony_ci * @brief Determine the number of active components in an image. 207cc1dc7a3Sopenharmony_ci * 208cc1dc7a3Sopenharmony_ci * @param img The image to analyze. 209cc1dc7a3Sopenharmony_ci * 210cc1dc7a3Sopenharmony_ci * @return The number of active components in the image. 211cc1dc7a3Sopenharmony_ci */ 212cc1dc7a3Sopenharmony_ciint determine_image_components( 213cc1dc7a3Sopenharmony_ci const astcenc_image* img); 214cc1dc7a3Sopenharmony_ci 215cc1dc7a3Sopenharmony_ci/** 216cc1dc7a3Sopenharmony_ci * @brief Load a compressed .astc image. 217cc1dc7a3Sopenharmony_ci * 218cc1dc7a3Sopenharmony_ci * @param filename The file to load. 219cc1dc7a3Sopenharmony_ci * @param img The image to populate with loaded data. 220cc1dc7a3Sopenharmony_ci * 221cc1dc7a3Sopenharmony_ci * @return Non-zero on error, zero on success. 222cc1dc7a3Sopenharmony_ci */ 223cc1dc7a3Sopenharmony_ciint load_cimage( 224cc1dc7a3Sopenharmony_ci const char* filename, 225cc1dc7a3Sopenharmony_ci astc_compressed_image& img); 226cc1dc7a3Sopenharmony_ci 227cc1dc7a3Sopenharmony_ci/** 228cc1dc7a3Sopenharmony_ci * @brief Store a compressed .astc image. 229cc1dc7a3Sopenharmony_ci * 230cc1dc7a3Sopenharmony_ci * @param img The image to store. 231cc1dc7a3Sopenharmony_ci * @param filename The file to save. 232cc1dc7a3Sopenharmony_ci * 233cc1dc7a3Sopenharmony_ci * @return Non-zero on error, zero on success. 234cc1dc7a3Sopenharmony_ci */ 235cc1dc7a3Sopenharmony_ciint store_cimage( 236cc1dc7a3Sopenharmony_ci const astc_compressed_image& img, 237cc1dc7a3Sopenharmony_ci const char* filename); 238cc1dc7a3Sopenharmony_ci 239cc1dc7a3Sopenharmony_ci/** 240cc1dc7a3Sopenharmony_ci * @brief Load a compressed .ktx image. 241cc1dc7a3Sopenharmony_ci * 242cc1dc7a3Sopenharmony_ci * @param filename The file to load. 243cc1dc7a3Sopenharmony_ci * @param is_srgb Is this an sRGB encoded file? 244cc1dc7a3Sopenharmony_ci * @param img The image to populate with loaded data. 245cc1dc7a3Sopenharmony_ci * 246cc1dc7a3Sopenharmony_ci * @return Non-zero on error, zero on success. 247cc1dc7a3Sopenharmony_ci */ 248cc1dc7a3Sopenharmony_cibool load_ktx_compressed_image( 249cc1dc7a3Sopenharmony_ci const char* filename, 250cc1dc7a3Sopenharmony_ci bool& is_srgb, 251cc1dc7a3Sopenharmony_ci astc_compressed_image& img) ; 252cc1dc7a3Sopenharmony_ci 253cc1dc7a3Sopenharmony_ci/** 254cc1dc7a3Sopenharmony_ci * @brief Store a compressed .ktx image. 255cc1dc7a3Sopenharmony_ci * 256cc1dc7a3Sopenharmony_ci * @param img The image to store. 257cc1dc7a3Sopenharmony_ci * @param filename The file to store. 258cc1dc7a3Sopenharmony_ci * @param is_srgb Is this an sRGB encoded file? 259cc1dc7a3Sopenharmony_ci * 260cc1dc7a3Sopenharmony_ci * @return Non-zero on error, zero on success. 261cc1dc7a3Sopenharmony_ci */ 262cc1dc7a3Sopenharmony_cibool store_ktx_compressed_image( 263cc1dc7a3Sopenharmony_ci const astc_compressed_image& img, 264cc1dc7a3Sopenharmony_ci const char* filename, 265cc1dc7a3Sopenharmony_ci bool is_srgb); 266cc1dc7a3Sopenharmony_ci 267cc1dc7a3Sopenharmony_ci/** 268cc1dc7a3Sopenharmony_ci * @brief Create an image from a 2D float data array. 269cc1dc7a3Sopenharmony_ci * 270cc1dc7a3Sopenharmony_ci * @param data The raw input data. 271cc1dc7a3Sopenharmony_ci * @param dim_x The width of the image, in texels. 272cc1dc7a3Sopenharmony_ci * @param dim_y The height of the image, in texels. 273cc1dc7a3Sopenharmony_ci * @param y_flip Should this image be vertically flipped? 274cc1dc7a3Sopenharmony_ci * 275cc1dc7a3Sopenharmony_ci * @return The populated image. 276cc1dc7a3Sopenharmony_ci */ 277cc1dc7a3Sopenharmony_ciastcenc_image* astc_img_from_floatx4_array( 278cc1dc7a3Sopenharmony_ci const float* data, 279cc1dc7a3Sopenharmony_ci unsigned int dim_x, 280cc1dc7a3Sopenharmony_ci unsigned int dim_y, 281cc1dc7a3Sopenharmony_ci bool y_flip); 282cc1dc7a3Sopenharmony_ci 283cc1dc7a3Sopenharmony_ci/** 284cc1dc7a3Sopenharmony_ci * @brief Create an image from a 2D byte data array. 285cc1dc7a3Sopenharmony_ci * 286cc1dc7a3Sopenharmony_ci * @param data The raw input data. 287cc1dc7a3Sopenharmony_ci * @param dim_x The width of the image, in texels. 288cc1dc7a3Sopenharmony_ci * @param dim_y The height of the image, in texels. 289cc1dc7a3Sopenharmony_ci * @param y_flip Should this image be vertically flipped? 290cc1dc7a3Sopenharmony_ci * 291cc1dc7a3Sopenharmony_ci * @return The populated image. 292cc1dc7a3Sopenharmony_ci */ 293cc1dc7a3Sopenharmony_ciastcenc_image* astc_img_from_unorm8x4_array( 294cc1dc7a3Sopenharmony_ci const uint8_t* data, 295cc1dc7a3Sopenharmony_ci unsigned int dim_x, 296cc1dc7a3Sopenharmony_ci unsigned int dim_y, 297cc1dc7a3Sopenharmony_ci bool y_flip); 298cc1dc7a3Sopenharmony_ci 299cc1dc7a3Sopenharmony_ci/** 300cc1dc7a3Sopenharmony_ci * @brief Create a flattened RGBA FLOAT32 data array for a single slice from an image structure. 301cc1dc7a3Sopenharmony_ci * 302cc1dc7a3Sopenharmony_ci * The returned data array is allocated with @c new[] and must be freed with a @c delete[] call. 303cc1dc7a3Sopenharmony_ci * 304cc1dc7a3Sopenharmony_ci * @param img The input image. 305cc1dc7a3Sopenharmony_ci * @param y_flip Should the data in the array be Y flipped? 306cc1dc7a3Sopenharmony_ci * @param z_index The slice index to convert. 307cc1dc7a3Sopenharmony_ci * 308cc1dc7a3Sopenharmony_ci * @return The data array. 309cc1dc7a3Sopenharmony_ci */ 310cc1dc7a3Sopenharmony_cifloat* floatx4_array_from_astc_img( 311cc1dc7a3Sopenharmony_ci const astcenc_image* img, 312cc1dc7a3Sopenharmony_ci bool y_flip, 313cc1dc7a3Sopenharmony_ci unsigned int z_index); 314cc1dc7a3Sopenharmony_ci 315cc1dc7a3Sopenharmony_ci/** 316cc1dc7a3Sopenharmony_ci * @brief Create a flattened RGBA UNORM8 data array from an image structure. 317cc1dc7a3Sopenharmony_ci * 318cc1dc7a3Sopenharmony_ci * The returned data array is allocated with @c new[] and must be freed with a @c delete[] call. 319cc1dc7a3Sopenharmony_ci * 320cc1dc7a3Sopenharmony_ci * @param img The input image. 321cc1dc7a3Sopenharmony_ci * @param y_flip Should the data in the array be Y flipped? 322cc1dc7a3Sopenharmony_ci * 323cc1dc7a3Sopenharmony_ci * @return The data array. 324cc1dc7a3Sopenharmony_ci */ 325cc1dc7a3Sopenharmony_ciuint8_t* unorm8x4_array_from_astc_img( 326cc1dc7a3Sopenharmony_ci const astcenc_image* img, 327cc1dc7a3Sopenharmony_ci bool y_flip); 328cc1dc7a3Sopenharmony_ci 329cc1dc7a3Sopenharmony_ci/* ============================================================================ 330cc1dc7a3Sopenharmony_ci Functions for printing build info and help messages 331cc1dc7a3Sopenharmony_ci============================================================================ */ 332cc1dc7a3Sopenharmony_ci 333cc1dc7a3Sopenharmony_ci/** 334cc1dc7a3Sopenharmony_ci * @brief Print the tool copyright and version header to stdout. 335cc1dc7a3Sopenharmony_ci */ 336cc1dc7a3Sopenharmony_civoid astcenc_print_header(); 337cc1dc7a3Sopenharmony_ci 338cc1dc7a3Sopenharmony_ci/** 339cc1dc7a3Sopenharmony_ci * @brief Print the tool copyright, version, and short-form help to stdout. 340cc1dc7a3Sopenharmony_ci */ 341cc1dc7a3Sopenharmony_civoid astcenc_print_shorthelp(); 342cc1dc7a3Sopenharmony_ci 343cc1dc7a3Sopenharmony_ci/** 344cc1dc7a3Sopenharmony_ci * @brief Print the tool copyright, version, and long-form help to stdout. 345cc1dc7a3Sopenharmony_ci */ 346cc1dc7a3Sopenharmony_civoid astcenc_print_longhelp(); 347cc1dc7a3Sopenharmony_ci 348cc1dc7a3Sopenharmony_ci/** 349cc1dc7a3Sopenharmony_ci * @brief Compute error metrics comparing two images. 350cc1dc7a3Sopenharmony_ci * 351cc1dc7a3Sopenharmony_ci * @param compute_hdr_metrics True if HDR metrics should be computed. 352cc1dc7a3Sopenharmony_ci * @param compute_normal_metrics True if normal map metrics should be computed. 353cc1dc7a3Sopenharmony_ci * @param input_components The number of input color components. 354cc1dc7a3Sopenharmony_ci * @param img1 The original image. 355cc1dc7a3Sopenharmony_ci * @param img2 The compressed image. 356cc1dc7a3Sopenharmony_ci * @param fstop_lo The low exposure fstop (HDR only). 357cc1dc7a3Sopenharmony_ci * @param fstop_hi The high exposure fstop (HDR only). 358cc1dc7a3Sopenharmony_ci */ 359cc1dc7a3Sopenharmony_civoid compute_error_metrics( 360cc1dc7a3Sopenharmony_ci bool compute_hdr_metrics, 361cc1dc7a3Sopenharmony_ci bool compute_normal_metrics, 362cc1dc7a3Sopenharmony_ci int input_components, 363cc1dc7a3Sopenharmony_ci const astcenc_image* img1, 364cc1dc7a3Sopenharmony_ci const astcenc_image* img2, 365cc1dc7a3Sopenharmony_ci int fstop_lo, 366cc1dc7a3Sopenharmony_ci int fstop_hi); 367cc1dc7a3Sopenharmony_ci 368cc1dc7a3Sopenharmony_ci/** 369cc1dc7a3Sopenharmony_ci * @brief Get the current time. 370cc1dc7a3Sopenharmony_ci * 371cc1dc7a3Sopenharmony_ci * @return The current time in seconds since arbitrary epoch. 372cc1dc7a3Sopenharmony_ci */ 373cc1dc7a3Sopenharmony_cidouble get_time(); 374cc1dc7a3Sopenharmony_ci 375cc1dc7a3Sopenharmony_ci/** 376cc1dc7a3Sopenharmony_ci * @brief Get the number of CPU cores. 377cc1dc7a3Sopenharmony_ci * 378cc1dc7a3Sopenharmony_ci * @return The number of online or onlineable CPU cores in the system. 379cc1dc7a3Sopenharmony_ci */ 380cc1dc7a3Sopenharmony_ciint get_cpu_count(); 381cc1dc7a3Sopenharmony_ci 382cc1dc7a3Sopenharmony_ci/** 383cc1dc7a3Sopenharmony_ci * @brief Launch N worker threads and wait for them to complete. 384cc1dc7a3Sopenharmony_ci * 385cc1dc7a3Sopenharmony_ci * All threads run the same thread function, and have the same thread payload, but are given a 386cc1dc7a3Sopenharmony_ci * unique thread ID (0 .. N-1) as a parameter to the run function to allow thread-specific behavior. 387cc1dc7a3Sopenharmony_ci * 388cc1dc7a3Sopenharmony_ci * @param operation The name of the operation for this async task. 389cc1dc7a3Sopenharmony_ci * @param thread_count The number of threads to spawn. 390cc1dc7a3Sopenharmony_ci * @param func The function to execute. Must have the signature: 391cc1dc7a3Sopenharmony_ci * void (int thread_count, int thread_id, void* payload) 392cc1dc7a3Sopenharmony_ci * @param payload Pointer to an opaque thread payload object. 393cc1dc7a3Sopenharmony_ci */ 394cc1dc7a3Sopenharmony_civoid launch_threads( 395cc1dc7a3Sopenharmony_ci const char* operation, 396cc1dc7a3Sopenharmony_ci int thread_count, 397cc1dc7a3Sopenharmony_ci void (*func)(int, int, void*), 398cc1dc7a3Sopenharmony_ci void *payload); 399cc1dc7a3Sopenharmony_ci 400cc1dc7a3Sopenharmony_ci/** 401cc1dc7a3Sopenharmony_ci * @brief The main entry point. 402cc1dc7a3Sopenharmony_ci * 403cc1dc7a3Sopenharmony_ci * @param argc The number of arguments. 404cc1dc7a3Sopenharmony_ci * @param argv The vector of arguments. 405cc1dc7a3Sopenharmony_ci * 406cc1dc7a3Sopenharmony_ci * @return 0 on success, non-zero otherwise. 407cc1dc7a3Sopenharmony_ci */ 408cc1dc7a3Sopenharmony_ciint astcenc_main( 409cc1dc7a3Sopenharmony_ci int argc, 410cc1dc7a3Sopenharmony_ci char **argv); 411cc1dc7a3Sopenharmony_ci 412cc1dc7a3Sopenharmony_ci#endif 413