1
我試圖執行顏色轉換Func
,它將輸出到3個單獨的緩衝區。函數有一個4×8位通道交錯緩衝器(BGRA)和3個輸出緩衝器(Y,Co和Cg),每個緩衝器的值均爲16位。目前,我使用這段代碼:從RGB到YUV的顏色轉換(YCoCg)
void rgb_to_ycocg(const uint8_t *pSrc, int32_t srcStep, int16_t *pDst[3], int32_t dstStep[3], int width, int height)
{
Buffer<uint8_t> inRgb((uint8_t *)pSrc, 4, width, height);
Buffer<int16_t> outY(pDst[0], width, height);
Buffer<int16_t> outCo(pDst[1], width, height);
Buffer<int16_t> outCg(pDst[2], width, height);
Var x, y, c;
Func calcY, calcCo, calcCg, inRgb16;
inRgb16(c, x, y) = cast<int16_t>(inRgb(c, x, y));
calcY(x, y) = (inRgb16(0, x, y) + ((inRgb16(2, x, y) - inRgb16(0, x, y)) >> 1)) + ((inRgb16(1, x, y) - (inRgb16(0, x, y) + ((inRgb16(2, x, y) - inRgb16(0, x, y)) >> 1))) >> 1);
calcCo(x, y) = inRgb16(2, x, y) - inRgb16(0, x, y);
calcCg(x, y) = inRgb16(1, x, y) - (inRgb16(0, x, y) + ((inRgb16(2, x, y) - inRgb16(0, x, y)) >> 1));
Pipeline p =Pipeline({calcY, calcCo, calcCg});
p.vectorize(x, 16).parallel(y);
p.realize({ outY, outCo, outCg });
}
的問題是,我比參考實現(基本在C循環)越來越表現不佳。我知道我需要嘗試更好的調度,但我認爲我在輸入/輸出緩衝區方面做了錯誤。我看過這些教程並試圖想出一種方法來輸出到多個緩衝區。使用Pipeline
是我能找到的唯一方法。我會更好地製作3 Func
並分別打電話給他們嗎?這是否正確使用Pipeline
類?
感謝您的回答,我知道的重新編譯的問題,但我很高興看到它可以用元組完成。我明天會試試這個。再次感謝! –