From 0d8ccbf5cd5c241cb17b27d852d13678c61bf314 Mon Sep 17 00:00:00 2001 From: TheM14 Date: Sun, 8 Nov 2026 16:13:09 +0800 Subject: [PATCH] Update the kernel header to ABI 6 Both copies of joc_core.h follow the main repository: third_party/joc/include for the cplugin and fork/files/audio/decode for the ad_joc patch now carry JOC_ABI_VERSION 6, frame parameters and EMDF payload info at v2, the JOC_FRAME_STATUS_* values and the calling convention chosen per platform. joc_stream.h and joc_version.h are unchanged, so neither integration needs a code change. The plugin compares the loaded core's abi_version() with JOC_ABI_VERSION at load time, so the vendored header has to match the new joc_core.dll. Rebuilt against commit 3f0d5e87fe41b90d9350528d2dca2ca82a637a3f with -DJOC_CORE_SOURCE: joc_mpv.dll and joc_core.dll build, the plugin compiles against ABI 6, and the built joc_core.dll reports abi 6 / version 1.2.0. --- fork/files/audio/decode/joc_core.h | 42 ++++++++++++++++++++++-------- third_party/joc/include/joc_core.h | 42 ++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/fork/files/audio/decode/joc_core.h b/fork/files/audio/decode/joc_core.h index 428597b..6afcc92 100644 --- a/fork/files/audio/decode/joc_core.h +++ b/fork/files/audio/decode/joc_core.h @@ -36,27 +36,30 @@ #include "joc_version.h" -#define JOC_ABI_VERSION 5u -#define JOC_FRAME_PARAMS_VERSION 1u -#define JOC_EMDF_INFO_VERSION 1u +#define JOC_ABI_VERSION 6u +#define JOC_FRAME_PARAMS_VERSION 2u +#define JOC_EMDF_INFO_VERSION 2u #define JOC_TASK_CONFIG_VERSION 4u #define JOC_TASK_RESULT_VERSION 2u #define JOC_EVENT_VERSION 1u /* JOC_STATIC: this branch exists for building the sources directly into an application, where nothing is imported or exported. */ +#if defined(_WIN32) + #define JOC_CALL __cdecl +#else + #define JOC_CALL +#endif + #if defined(JOC_STATIC) #define JOC_API - #define JOC_CALL __cdecl #elif defined(_WIN32) #if defined(JOC_BUILD_DLL) #define JOC_API __declspec(dllexport) #else #define JOC_API __declspec(dllimport) #endif - #define JOC_CALL __cdecl #else #define JOC_API __attribute__((visibility("default"))) - #define JOC_CALL #endif #ifdef __cplusplus @@ -152,8 +155,7 @@ JOC_API const char* JOC_CALL joc_last_error_detail(void); typedef struct joc_emdf_payload_info { uint8_t id; uint8_t reserved[3]; - uint16_t sample_offset; /* EMDF outer smpoffst, 11 bits */ - uint16_t reserved2; + uint32_t sample_offset; /* EMDF outer smpoffst: variable_bits(11) */ uint32_t bit_offset; uint32_t size; /* payload bytes */ } joc_emdf_payload_info; @@ -170,7 +172,8 @@ typedef struct joc_emdf_info { /* Per-object ID14/JOC descriptor plus its dequantized matrix. * dq[dp][ch][pb] is zero filled outside [0,n_dpoints) x [0,n_channels) x - * [0,n_bands). Absent objects are entirely zero. */ + * [0,n_bands). Absent objects are entirely zero. offset_ts holds the raw + * 5-bit JOC offsets (legal range 0..23, strictly increasing per object). */ typedef struct joc_object_params { uint8_t present; uint8_t num_bands_idx; @@ -185,6 +188,21 @@ typedef struct joc_object_params { double dq[JOC_MAX_DPOINTS][JOC_MAX_CORE_CHANNELS][JOC_MAX_PARAMETER_BANDS]; } joc_object_params; +/* Per-frame JOC parse status (joc_frame_params.status). A non-zero status makes + * the frame invalid for rendering: the renderer holds the previous matrices or + * passes the core PCM through instead of decoding the matrix. Only status 3 + * still carries a complete object list (object count clamped to 15) for + * diagnostics; statuses 2 and 4 stop the parse after the failing header field. */ +enum { + JOC_FRAME_STATUS_OK = 0, + JOC_FRAME_STATUS_UNSUPPORTED_DMX = 2, /* joc_dmx_config_idx outside 0..4 */ + JOC_FRAME_STATUS_OBJECTS_CLAMPED = 3, /* declared object count above 15 */ + JOC_FRAME_STATUS_BAD_PARAMETER_BAND = 4, /* unknown num_bands index */ + JOC_FRAME_STATUS_BAD_OFFSET_TS = 5, /* offset_ts outside 0..23 or not */ + /* strictly increasing */ + JOC_FRAME_STATUS_TRAILING_DATA = 6 /* bytes after joc_data alignment */ +}; + typedef struct joc_frame_params { uint32_t struct_size; uint32_t struct_version; @@ -196,12 +214,14 @@ typedef struct joc_frame_params { uint8_t clipgain_x_bits; uint8_t clipgain_y_bits; uint8_t objects_clamped; /* num_objects_bits+1 exceeded 15 */ - uint32_t seq_count; /* 10-bit JOC sequence counter, parsed only */ + uint32_t seq_count; /* 10-bit JOC sequence counter */ uint32_t present_mask; /* bit i == object i present */ + uint8_t status; /* JOC_FRAME_STATUS_* */ + uint8_t reserved[3]; uint32_t data_end_bits; /* bit position just after joc_data */ uint32_t trailing_bits; /* bits left after joc_data (padding/ext) */ uint8_t tail_bytes[8]; /* first up to 8 trailing bytes, for A/B */ - double clipgain; /* 1 + (y/32) * 2^(x-4), bit-exact */ + double clipgain; /* 2^(x-4) * (1 + y/32), bit-exact */ joc_object_params objects[JOC_MAX_OBJECTS]; } joc_frame_params; diff --git a/third_party/joc/include/joc_core.h b/third_party/joc/include/joc_core.h index 428597b..6afcc92 100644 --- a/third_party/joc/include/joc_core.h +++ b/third_party/joc/include/joc_core.h @@ -36,27 +36,30 @@ #include "joc_version.h" -#define JOC_ABI_VERSION 5u -#define JOC_FRAME_PARAMS_VERSION 1u -#define JOC_EMDF_INFO_VERSION 1u +#define JOC_ABI_VERSION 6u +#define JOC_FRAME_PARAMS_VERSION 2u +#define JOC_EMDF_INFO_VERSION 2u #define JOC_TASK_CONFIG_VERSION 4u #define JOC_TASK_RESULT_VERSION 2u #define JOC_EVENT_VERSION 1u /* JOC_STATIC: this branch exists for building the sources directly into an application, where nothing is imported or exported. */ +#if defined(_WIN32) + #define JOC_CALL __cdecl +#else + #define JOC_CALL +#endif + #if defined(JOC_STATIC) #define JOC_API - #define JOC_CALL __cdecl #elif defined(_WIN32) #if defined(JOC_BUILD_DLL) #define JOC_API __declspec(dllexport) #else #define JOC_API __declspec(dllimport) #endif - #define JOC_CALL __cdecl #else #define JOC_API __attribute__((visibility("default"))) - #define JOC_CALL #endif #ifdef __cplusplus @@ -152,8 +155,7 @@ JOC_API const char* JOC_CALL joc_last_error_detail(void); typedef struct joc_emdf_payload_info { uint8_t id; uint8_t reserved[3]; - uint16_t sample_offset; /* EMDF outer smpoffst, 11 bits */ - uint16_t reserved2; + uint32_t sample_offset; /* EMDF outer smpoffst: variable_bits(11) */ uint32_t bit_offset; uint32_t size; /* payload bytes */ } joc_emdf_payload_info; @@ -170,7 +172,8 @@ typedef struct joc_emdf_info { /* Per-object ID14/JOC descriptor plus its dequantized matrix. * dq[dp][ch][pb] is zero filled outside [0,n_dpoints) x [0,n_channels) x - * [0,n_bands). Absent objects are entirely zero. */ + * [0,n_bands). Absent objects are entirely zero. offset_ts holds the raw + * 5-bit JOC offsets (legal range 0..23, strictly increasing per object). */ typedef struct joc_object_params { uint8_t present; uint8_t num_bands_idx; @@ -185,6 +188,21 @@ typedef struct joc_object_params { double dq[JOC_MAX_DPOINTS][JOC_MAX_CORE_CHANNELS][JOC_MAX_PARAMETER_BANDS]; } joc_object_params; +/* Per-frame JOC parse status (joc_frame_params.status). A non-zero status makes + * the frame invalid for rendering: the renderer holds the previous matrices or + * passes the core PCM through instead of decoding the matrix. Only status 3 + * still carries a complete object list (object count clamped to 15) for + * diagnostics; statuses 2 and 4 stop the parse after the failing header field. */ +enum { + JOC_FRAME_STATUS_OK = 0, + JOC_FRAME_STATUS_UNSUPPORTED_DMX = 2, /* joc_dmx_config_idx outside 0..4 */ + JOC_FRAME_STATUS_OBJECTS_CLAMPED = 3, /* declared object count above 15 */ + JOC_FRAME_STATUS_BAD_PARAMETER_BAND = 4, /* unknown num_bands index */ + JOC_FRAME_STATUS_BAD_OFFSET_TS = 5, /* offset_ts outside 0..23 or not */ + /* strictly increasing */ + JOC_FRAME_STATUS_TRAILING_DATA = 6 /* bytes after joc_data alignment */ +}; + typedef struct joc_frame_params { uint32_t struct_size; uint32_t struct_version; @@ -196,12 +214,14 @@ typedef struct joc_frame_params { uint8_t clipgain_x_bits; uint8_t clipgain_y_bits; uint8_t objects_clamped; /* num_objects_bits+1 exceeded 15 */ - uint32_t seq_count; /* 10-bit JOC sequence counter, parsed only */ + uint32_t seq_count; /* 10-bit JOC sequence counter */ uint32_t present_mask; /* bit i == object i present */ + uint8_t status; /* JOC_FRAME_STATUS_* */ + uint8_t reserved[3]; uint32_t data_end_bits; /* bit position just after joc_data */ uint32_t trailing_bits; /* bits left after joc_data (padding/ext) */ uint8_t tail_bytes[8]; /* first up to 8 trailing bytes, for A/B */ - double clipgain; /* 1 + (y/32) * 2^(x-4), bit-exact */ + double clipgain; /* 2^(x-4) * (1 + y/32), bit-exact */ joc_object_params objects[JOC_MAX_OBJECTS]; } joc_frame_params;