Cleanup: Add ibuf channel expectation asserts in VSE code

Whole of VSE assumes that all images are always 4 channels. Add
asserts in several places to more clearly indicate that.

Pull Request: https://projects.blender.org/blender/blender/pulls/132546
This commit is contained in:
Aras Pranckevicius
2025-01-02 14:33:52 +01:00
committed by Aras Pranckevicius
parent 426d1683ee
commit 4546367bb3
3 changed files with 12 additions and 0 deletions

View File

@@ -119,6 +119,12 @@ void wipe_effect_get_handle(SeqEffectHandle &rval);
template<typename OpT>
static void apply_effect_op(const OpT &op, const ImBuf *src1, const ImBuf *src2, ImBuf *dst)
{
BLI_assert_msg(src1->channels == 0 || src1->channels == 4,
"Sequencer only supports 4 channel images");
BLI_assert_msg(src2->channels == 0 || src2->channels == 4,
"Sequencer only supports 4 channel images");
BLI_assert_msg(dst->channels == 0 || dst->channels == 4,
"Sequencer only supports 4 channel images");
blender::threading::parallel_for(
blender::IndexRange(size_t(dst->x) * dst->y), 32 * 1024, [&](blender::IndexRange range) {
int64_t offset = range.first() * 4;

View File

@@ -126,6 +126,10 @@ template<typename T> static void apply_modifier_op(T &op, ImBuf *ibuf, const ImB
if (ibuf == nullptr) {
return;
}
BLI_assert_msg(ibuf->channels == 0 || ibuf->channels == 4,
"Sequencer only supports 4 channel images");
BLI_assert_msg(mask == nullptr || mask->channels == 0 || mask->channels == 4,
"Sequencer only supports 4 channel images");
threading::parallel_for(IndexRange(size_t(ibuf->x) * ibuf->y), 32 * 1024, [&](IndexRange range) {
uchar *image_byte = ibuf->byte_buffer.data;

View File

@@ -597,6 +597,8 @@ static void sequencer_preprocess_transform_crop(
static void multiply_ibuf(ImBuf *ibuf, const float fmul, const bool multiply_alpha)
{
BLI_assert_msg(ibuf->channels == 0 || ibuf->channels == 4,
"Sequencer only supports 4 channel images");
const size_t pixel_count = IMB_get_rect_len(ibuf);
if (ibuf->byte_buffer.data != nullptr) {
threading::parallel_for(IndexRange(pixel_count), 64 * 1024, [&](IndexRange range) {