Skip to content

Commit 2ec1b5b

Browse files
committed
API change - pass swizzzle structs by reference.
1 parent 8f0f258 commit 2ec1b5b

6 files changed

Lines changed: 23 additions & 23 deletions

File tree

Source/astcenc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(
729729
*
730730
* @param context Codec context.
731731
* @param[in,out] image An input image, in 2D slices.
732-
* @param swizzle Compression data swizzle.
732+
* @param swizzle Compression data swizzle, applied before compression.
733733
* @param[out] data_out Pointer to output data array.
734734
* @param data_len Length of the output data array.
735735
* @param thread_index Thread index [0..N-1] of calling thread.
@@ -739,7 +739,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(
739739
ASTCENC_PUBLIC astcenc_error astcenc_compress_image(
740740
astcenc_context* context,
741741
astcenc_image* image,
742-
astcenc_swizzle swizzle,
742+
const astcenc_swizzle* swizzle,
743743
uint8_t* data_out,
744744
size_t data_len,
745745
unsigned int thread_index);
@@ -766,7 +766,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(
766766
* @param[in] data Pointer to compressed data.
767767
* @param data_len Length of the compressed data, in bytes.
768768
* @param[in,out] image_out Output image.
769-
* @param swizzle Decompression data swizzle.
769+
* @param swizzle Decompression data swizzle, applied after decompression.
770770
* @param thread_index Thread index [0..N-1] of calling thread.
771771
*
772772
* @return ASTCENC_SUCCESS on success, or an error if decompression failed.
@@ -776,7 +776,7 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(
776776
const uint8_t* data,
777777
size_t data_len,
778778
astcenc_image* image_out,
779-
astcenc_swizzle swizzle,
779+
const astcenc_swizzle* swizzle,
780780
unsigned int thread_index);
781781

782782
/**

Source/astcenc_compute_variance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ unsigned int init_compute_averages_and_variances(
574574
float alpha_power,
575575
int avg_var_kernel_radius,
576576
int alpha_kernel_radius,
577-
astcenc_swizzle swz,
577+
const astcenc_swizzle& swz,
578578
pixel_region_variance_args& arg,
579579
avg_var_args& ag
580580
) {

Source/astcenc_entry.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static astcenc_error validate_compression_swz(
254254
}
255255

256256
static astcenc_error validate_compression_swizzle(
257-
astcenc_swizzle swizzle
257+
const astcenc_swizzle& swizzle
258258
) {
259259
if (validate_compression_swz(swizzle.r) ||
260260
validate_compression_swz(swizzle.g) ||
@@ -289,7 +289,7 @@ static astcenc_error validate_decompression_swz(
289289
}
290290

291291
static astcenc_error validate_decompression_swizzle(
292-
astcenc_swizzle swizzle
292+
const astcenc_swizzle& swizzle
293293
) {
294294
if (validate_decompression_swz(swizzle.r) ||
295295
validate_decompression_swz(swizzle.g) ||
@@ -875,7 +875,7 @@ static void compress_image(
875875
astcenc_error astcenc_compress_image(
876876
astcenc_context* ctx,
877877
astcenc_image* imagep,
878-
astcenc_swizzle swizzle,
878+
const astcenc_swizzle* swizzle,
879879
uint8_t* data_out,
880880
size_t data_len,
881881
unsigned int thread_index
@@ -897,7 +897,7 @@ astcenc_error astcenc_compress_image(
897897
return ASTCENC_ERR_BAD_CONTEXT;
898898
}
899899

900-
status = validate_compression_swizzle(swizzle);
900+
status = validate_compression_swizzle(*swizzle);
901901
if (status != ASTCENC_SUCCESS)
902902
{
903903
return status;
@@ -938,7 +938,7 @@ astcenc_error astcenc_compress_image(
938938

939939
return init_compute_averages_and_variances(
940940
image, ctx->config.v_rgb_power, ctx->config.v_a_power,
941-
ctx->config.v_rgba_radius, ctx->config.a_scale_radius, swizzle,
941+
ctx->config.v_rgba_radius, ctx->config.a_scale_radius, *swizzle,
942942
ctx->arg, ctx->ag);
943943
};
944944

@@ -952,7 +952,7 @@ astcenc_error astcenc_compress_image(
952952
// Wait for compute_averages_and_variances to complete before compressing
953953
ctx->manage_avg_var.wait();
954954

955-
compress_image(*ctx, thread_index, image, swizzle, data_out);
955+
compress_image(*ctx, thread_index, image, *swizzle, data_out);
956956

957957
// Wait for compress to complete before freeing memory
958958
ctx->manage_compress.wait();
@@ -998,7 +998,7 @@ astcenc_error astcenc_decompress_image(
998998
const uint8_t* data,
999999
size_t data_len,
10001000
astcenc_image* image_outp,
1001-
astcenc_swizzle swizzle,
1001+
const astcenc_swizzle* swizzle,
10021002
unsigned int thread_index
10031003
) {
10041004
astcenc_error status;
@@ -1010,7 +1010,7 @@ astcenc_error astcenc_decompress_image(
10101010
return ASTCENC_ERR_BAD_PARAM;
10111011
}
10121012

1013-
status = validate_decompression_swizzle(swizzle);
1013+
status = validate_decompression_swizzle(*swizzle);
10141014
if (status != ASTCENC_SUCCESS)
10151015
{
10161016
return status;
@@ -1069,7 +1069,7 @@ astcenc_error astcenc_decompress_image(
10691069
&scb, &blk);
10701070

10711071
write_imageblock(image_out, &blk, ctx->bsd,
1072-
x * block_x, y * block_y, z * block_z, swizzle);
1072+
x * block_x, y * block_y, z * block_z, *swizzle);
10731073
}
10741074

10751075
ctx->manage_decompress.complete_task_assignment(count);

Source/astcenc_image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void fetch_imageblock(
158158
int xpos,
159159
int ypos,
160160
int zpos,
161-
astcenc_swizzle swz
161+
const astcenc_swizzle& swz
162162
) {
163163
int xsize = img.dim_x;
164164
int ysize = img.dim_y;
@@ -273,7 +273,7 @@ void write_imageblock(
273273
int xpos,
274274
int ypos,
275275
int zpos,
276-
astcenc_swizzle swz
276+
const astcenc_swizzle& swz
277277
) {
278278
int xsize = img.dim_x;
279279
int ysize = img.dim_y;

Source/astcenc_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ unsigned int init_compute_averages_and_variances(
11141114
float alpha_power,
11151115
int avg_var_kernel_radius,
11161116
int alpha_kernel_radius,
1117-
astcenc_swizzle swz,
1117+
const astcenc_swizzle& swz,
11181118
pixel_region_variance_args& arg,
11191119
avg_var_args& ag);
11201120

@@ -1132,7 +1132,7 @@ void fetch_imageblock(
11321132
int xpos,
11331133
int ypos,
11341134
int zpos,
1135-
astcenc_swizzle swz);
1135+
const astcenc_swizzle& swz);
11361136

11371137
// write an image block to the output file buffer.
11381138
// the data written are taken from orig_data.
@@ -1144,7 +1144,7 @@ void write_imageblock(
11441144
int xpos,
11451145
int ypos,
11461146
int zpos,
1147-
astcenc_swizzle swz);
1147+
const astcenc_swizzle& swz);
11481148

11491149
float compute_symbolic_block_difference(
11501150
const astcenc_config& config,

Source/astcenccli_toplevel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void compression_workload_runner(
161161

162162
compression_workload* work = static_cast<compression_workload*>(payload);
163163
astcenc_error error = astcenc_compress_image(
164-
work->context, work->image, work->swizzle,
164+
work->context, work->image, &work->swizzle,
165165
work->data_out, work->data_len, thread_id);
166166

167167
// This is a racy update, so which error gets returned is a random, but it
@@ -182,7 +182,7 @@ static void decompression_workload_runner(
182182
decompression_workload* work = static_cast<decompression_workload*>(payload);
183183
astcenc_error error = astcenc_decompress_image(
184184
work->context, work->data, work->data_len,
185-
work->image_out, work->swizzle, thread_id);
185+
work->image_out, &work->swizzle, thread_id);
186186

187187
// This is a racy update, so which error gets returned is a random, but it
188188
// will reliably report an error if an error occurs
@@ -1561,7 +1561,7 @@ int main(
15611561
else
15621562
{
15631563
work.error = astcenc_compress_image(
1564-
work.context, work.image, work.swizzle,
1564+
work.context, work.image, &work.swizzle,
15651565
work.data_out, work.data_len, 0);
15661566
}
15671567

@@ -1613,7 +1613,7 @@ int main(
16131613
{
16141614
work.error = astcenc_decompress_image(
16151615
work.context, work.data, work.data_len,
1616-
work.image_out, work.swizzle, 0);
1616+
work.image_out, &work.swizzle, 0);
16171617
}
16181618

16191619
if (work.error != ASTCENC_SUCCESS)

0 commit comments

Comments
 (0)