Numerous bug fixes, including strides

This commit is contained in:
mid
2025-10-05 23:23:40 +03:00
parent b6e6713860
commit c91115dad4
4 changed files with 25 additions and 19 deletions

View File

@@ -98,7 +98,7 @@ static int microphone_perform(CHiPubNode *pubn) {
size_t width = roundf(CHi_Time_GetDelta(pubn->ng) * 48000.f);
do {
}while((node->paBufferWriteIdx - node->paBufferReadIdx + pabufsize) % pabufsize < width); // Wait until available
CHiImage *ret = CHi_Image_New(2, 1, 2 * width, width, 1, NULL);
CHiImage *ret = CHi_Image_New(2, 1, (2 * width + 15) & ~15, width, 1, NULL);
if(node->paBufferReadIdx + width >= pabufsize) {
memcpy(ret->data16, node->paBuffer + node->paBufferReadIdx, sizeof(*node->paBuffer) * (pabufsize - node->paBufferReadIdx));
memcpy(ret->data16 + pabufsize - node->paBufferReadIdx, node->paBuffer, sizeof(*node->paBuffer) * (width - pabufsize + node->paBufferReadIdx));

View File

@@ -663,13 +663,15 @@ static int constantsample_perform(CHiPubNode *node) {
size_t w = sz->data.vec4[0] < 1 ? 1 : sz->data.vec4[0];
size_t h = sz->data.vec4[1] < 1 ? 1 : sz->data.vec4[1];
CHiImage *img = CHi_Image_New(2, 4, 8 * w, w, h, NULL);
CHiImage *img = CHi_Image_New(2, 4, 8 * ((w + 1) & ~1), w, h, NULL);
if(CHi_Node_Active(node)) {
for(size_t i = 0; i < w * h; i++) {
img->data16[i * 4 + 0] = sink->data.vec4[2] * 65535;
img->data16[i * 4 + 1] = sink->data.vec4[1] * 65535;
img->data16[i * 4 + 2] = sink->data.vec4[0] * 65535;
img->data16[i * 4 + 3] = 65535;
for(size_t y = 0; y < h; y++) {
for(size_t x = 0; x < w; x++) {
img->data16[y * img->stride / 2 + x * 4 + 0] = sink->data.vec4[2] * 65535;
img->data16[y * img->stride / 2 + x * 4 + 1] = sink->data.vec4[1] * 65535;
img->data16[y * img->stride / 2 + x * 4 + 2] = sink->data.vec4[0] * 65535;
img->data16[y * img->stride / 2 + x * 4 + 3] = 65535;
}
}
}
node->sources->data.sample = img;

View File

@@ -289,6 +289,7 @@ CUTIVIS CHiValue *CHi_Crawl(CHiValue*);
CUTIVIS bool CHi_Node_Active(CHiPubNode*);
CUTIVIS void CHi_Node_Destroy(CHiPubNode*);
#ifdef __cplusplus
}
#endif