diff --git a/src/openzl/compress/graph_registry.c b/src/openzl/compress/graph_registry.c index 06fd79c70..f72c71749 100644 --- a/src/openzl/compress/graph_registry.c +++ b/src/openzl/compress/graph_registry.c @@ -132,7 +132,7 @@ const InternalGraphDesc GR_standardGraphs[ZL_PrivateStandardGraphID_end] = { REGISTER_DYNAMIC_GRAPH(ZL_StandardGraphID_fse, "!zl.fse", ZL_Type_serial, EI_fseDynamicGraph), REGISTER_DYNAMIC_GRAPH(ZL_StandardGraphID_huffman, "!zl.huffman", ZL_Type_serial | ZL_Type_struct | ZL_Type_numeric, EI_huffmanDynamicGraph), REGISTER_DYNAMIC_GRAPH(ZL_StandardGraphID_entropy, "!zl.entropy", ZL_Type_serial | ZL_Type_struct | ZL_Type_numeric, EI_entropyDynamicGraph), - REGISTER_SELECTOR(ZL_StandardGraphID_constant, "!zl.constant", SI_selector_constant, ZL_Type_serial | ZL_Type_struct), + REGISTER_SELECTOR(ZL_StandardGraphID_constant, "!zl.constant", SI_selector_constant, ZL_Type_serial | ZL_Type_struct | ZL_Type_numeric), REGISTER_STATIC_GRAPH(ZL_StandardGraphID_zstd, "!zl.zstd", ZL_Type_serial, ZL_PrivateStandardNodeID_zstd, _1_SUCCESSOR(ZL_PrivateStandardGraphID_serial_store) ), REGISTER_SELECTOR(ZL_StandardGraphID_bitpack, "!zl.bitpack", SI_selector_bitpack, ZL_Type_serial | ZL_Type_numeric), REGISTER_STATIC_GRAPH(ZL_StandardGraphID_flatpack, "!zl.flatpack", ZL_Type_serial, ZL_PrivateStandardNodeID_flatpack, _2_SUCCESSORS(ZL_PrivateStandardGraphID_serial_store, ZL_PrivateStandardGraphID_serial_store) ), diff --git a/src/openzl/compress/selectors/selector_constant.c b/src/openzl/compress/selectors/selector_constant.c index d8419e1e1..a75aab43d 100644 --- a/src/openzl/compress/selectors/selector_constant.c +++ b/src/openzl/compress/selectors/selector_constant.c @@ -30,6 +30,10 @@ static int isSingleBytePattern(const ZL_Input* inputStream) * * Single-byte patterns (0x00, 0xFF, 0x55, etc.) are routed * to CONSTANT_SERIAL (more efficient). + * + * Note: data arriving at this selector should be verified constant. + * No verification is done here, but if the data is not constant, + * operation will later fail, on reaching the constant node. */ ZL_GraphID SI_selector_constant( @@ -43,11 +47,12 @@ ZL_GraphID SI_selector_constant( (void)nbCustomGraphs; ZL_Type const inType = ZL_Input_type(inputStream); - ZL_ASSERT(inType == ZL_Type_serial || inType == ZL_Type_struct); + ZL_ASSERT( + inType == ZL_Type_serial || inType == ZL_Type_struct + || inType == ZL_Type_numeric); /* If all bytes are identical, Serial path is more efficient */ - if (ZL_Input_eltWidth(inputStream) > 1 - && isSingleBytePattern(inputStream)) { + if (isSingleBytePattern(inputStream)) { return ZL_GRAPH_CONSTANT_SERIAL; } @@ -55,9 +60,9 @@ ZL_GraphID SI_selector_constant( case ZL_Type_serial: return ZL_GRAPH_CONSTANT_SERIAL; case ZL_Type_struct: + case ZL_Type_numeric: return ZL_GRAPH_CONSTANT_FIXED; /* fallthrough - not supported */ - case ZL_Type_numeric: case ZL_Type_string: default: ZL_REQUIRE(0, "Unsupported input type for constant selector"); diff --git a/src/openzl/compress/selectors/selector_constant.h b/src/openzl/compress/selectors/selector_constant.h index 30196c345..81cbc4997 100644 --- a/src/openzl/compress/selectors/selector_constant.h +++ b/src/openzl/compress/selectors/selector_constant.h @@ -9,7 +9,7 @@ ZL_BEGIN_C_DECLS // .selector_f = SI_selector_constant, -// .inStreamType = ZL_Type_serial | ZL_Type_struct, +// .inStreamType = ZL_Type_serial | ZL_Type_struct | ZL_Type_numeric, ZL_GraphID SI_selector_constant( const ZL_Selector* selCtx, const ZL_Input* inputStream,