6868#include <sys/types.h>
6969#include <assert.h>
7070#include <math.h>
71-
71+ #include <stdint.h>
7272
7373/* Synchronization variables */
7474
@@ -946,11 +946,14 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
946946 uint8_t * filters = context -> filters ;
947947 uint8_t * filters_meta = context -> filters_meta ;
948948 bool memcpyed = context -> header_flags & (uint8_t )BLOSC_MEMCPYED ;
949-
949+ bool output_is_disposable = (context -> preparams != NULL ) ? context -> preparams -> output_is_disposable : false;
950+
950951 /* Prefilter function */
951952 if (context -> prefilter != NULL ) {
952953 /* Set unwritten values to zero */
953- memset (_dest , 0 , bsize );
954+ if (!output_is_disposable ) {
955+ memset (_dest , 0 , bsize );
956+ }
954957 // Create new prefilter parameters for this block (must be private for each thread)
955958 blosc2_prefilter_params preparams ;
956959 memcpy (& preparams , context -> preparams , sizeof (preparams ));
@@ -965,8 +968,14 @@ uint8_t* pipeline_forward(struct thread_context* thread_context, const int32_t b
965968 preparams .ttmp = thread_context -> tmp ;
966969 preparams .ttmp_nbytes = thread_context -> tmp_nbytes ;
967970 preparams .ctx = context ;
971+ preparams .output_is_disposable = output_is_disposable ;
968972
969973 if (context -> prefilter (& preparams ) != 0 ) {
974+ if (output_is_disposable ) {
975+ // Output is going to be discarded; no more filters are required
976+ BLOSC_TRACE_INFO ("Output is disposable" );
977+ return _dest ;
978+ }
970979 BLOSC_TRACE_ERROR ("Execution of prefilter function failed" );
971980 return NULL ;
972981 }
@@ -1087,6 +1096,7 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
10871096 int32_t ctbytes = 0 ; /* number of compressed bytes in block */
10881097 int32_t maxout ;
10891098 int32_t typesize = context -> typesize ;
1099+ bool output_is_disposable = (context -> preparams != NULL ) ? context -> preparams -> output_is_disposable : false;
10901100 const char * compname ;
10911101 int accel ;
10921102 const uint8_t * _src ;
@@ -1149,6 +1159,13 @@ static int blosc_c(struct thread_context* thread_context, int32_t bsize,
11491159 ntbytes += sizeof (int32_t );
11501160 ctbytes += sizeof (int32_t );
11511161
1162+ if (context -> header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && output_is_disposable ) {
1163+ // Simulate a run of 0s
1164+ BLOSC_TRACE_INFO ("Output is disposable, simulating a run of 0s" );
1165+ memset (dest - 4 , 0 , sizeof (int32_t ));
1166+ continue ;
1167+ }
1168+
11521169 const uint8_t * ip = (uint8_t * ) _src + j * neblock ;
11531170 const uint8_t * ipbound = (uint8_t * ) _src + (j + 1 ) * neblock ;
11541171
0 commit comments