X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libswscale%2Fslice.c;h=d96db133648d409c1d780785966379307a59e992;hb=0bf3a7361d17d596a5044882098f56817db0e103;hp=db4fa874ffccc43e1b668b252681394b4166fff0;hpb=493240a522fca34882601fbeeda4e17aa40a0303;p=ffmpeg diff --git a/libswscale/slice.c b/libswscale/slice.c index db4fa874ffc..d96db133648 100644 --- a/libswscale/slice.c +++ b/libswscale/slice.c @@ -158,14 +158,10 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src chrY + chrH, lumY + lumH}; - uint8_t *const src_[4] = {src[0] + (relative ? 0 : start[0]) * stride[0], - src[1] + (relative ? 0 : start[1]) * stride[1], - src[2] + (relative ? 0 : start[2]) * stride[2], - src[3] + (relative ? 0 : start[3]) * stride[3]}; - s->width = srcW; - for (i = 0; i < 4; ++i) { + for (i = 0; i < 4 && src[i] != NULL; ++i) { + uint8_t *const src_i = src[i] + (relative ? 0 : start[i]) * stride[i]; int j; int first = s->plane[i].sliceY; int n = s->plane[i].available_lines; @@ -175,13 +171,13 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src if (start[i] >= first && n >= tot_lines) { s->plane[i].sliceH = FFMAX(tot_lines, s->plane[i].sliceH); for (j = 0; j < lines; j+= 1) - s->plane[i].line[start[i] - first + j] = src_[i] + j * stride[i]; + s->plane[i].line[start[i] - first + j] = src_i + j * stride[i]; } else { s->plane[i].sliceY = start[i]; lines = lines > n ? n : lines; s->plane[i].sliceH = lines; for (j = 0; j < lines; j+= 1) - s->plane[i].line[j] = src_[i] + j * stride[i]; + s->plane[i].line[j] = src_i + j * stride[i]; } } @@ -189,23 +185,26 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int src return 0; } -static void fill_ones(SwsSlice *s, int n, int is16bit) +static void fill_ones(SwsSlice *s, int n, int bpc) { - int i; + int i, j, k, size, end; + for (i = 0; i < 4; ++i) { - int j; - int size = s->plane[i].available_lines; + size = s->plane[i].available_lines; for (j = 0; j < size; ++j) { - int k; - int end = is16bit ? n>>1: n; - // fill also one extra element - end += 1; - if (is16bit) + if (bpc == 16) { + end = (n>>1) + 1; for (k = 0; k < end; ++k) ((int32_t*)(s->plane[i].line[j]))[k] = 1<<18; - else + } else if (bpc == 32) { + end = (n>>2) + 1; + for (k = 0; k < end; ++k) + ((int64_t*)(s->plane[i].line[j]))[k] = 1LL<<34; + } else { + end = n + 1; for (k = 0; k < end; ++k) ((int16_t*)(s->plane[i].line[j]))[k] = 1<<14; + } } } } @@ -272,6 +271,9 @@ int ff_init_filters(SwsContext * c) if (c->dstBpc == 16) dst_stride <<= 1; + if (c->dstBpc == 32) + dst_stride <<= 2; + num_ydesc = need_lum_conv ? 2 : 1; num_cdesc = need_chr_conv ? 2 : 1; @@ -302,7 +304,7 @@ int ff_init_filters(SwsContext * c) res = alloc_lines(&c->slice[i], dst_stride, c->dstW); if (res < 0) goto cleanup; - fill_ones(&c->slice[i], dst_stride>>1, c->dstBpc == 16); + fill_ones(&c->slice[i], dst_stride>>1, c->dstBpc); // vertical scaler output ++i;