lavfi/vf_transpose: fix regression with semiplanar formats

(e.g. nv12)

Regression since 7b19e76aeb
This commit is contained in:
Rodger Combs 2018-02-21 22:01:51 -06:00
parent 4f40d64e00
commit 0419623cdc
2 changed files with 33 additions and 25 deletions

View File

@ -52,6 +52,14 @@ enum TransposeDir {
TRANSPOSE_CLOCK_FLIP, TRANSPOSE_CLOCK_FLIP,
}; };
typedef struct TransVtable {
void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
uint8_t *dst, ptrdiff_t dst_linesize);
void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
int w, int h);
} TransVtable;
typedef struct TransContext { typedef struct TransContext {
const AVClass *class; const AVClass *class;
int hsub, vsub; int hsub, vsub;
@ -61,11 +69,7 @@ typedef struct TransContext {
int passthrough; ///< PassthroughType, landscape passthrough mode enabled int passthrough; ///< PassthroughType, landscape passthrough mode enabled
int dir; ///< TransposeDir int dir; ///< TransposeDir
void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize, TransVtable vtables[4];
uint8_t *dst, ptrdiff_t dst_linesize);
void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
int w, int h);
} TransContext; } TransContext;
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
@ -233,19 +237,22 @@ static int config_props_output(AVFilterLink *outlink)
else else
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
switch (s->pixsteps[0]) { for (int i = 0; i < 4; i++) {
case 1: s->transpose_block = transpose_block_8_c; TransVtable *v = &s->vtables[i];
s->transpose_8x8 = transpose_8x8_8_c; break; switch (s->pixsteps[i]) {
case 2: s->transpose_block = transpose_block_16_c; case 1: v->transpose_block = transpose_block_8_c;
s->transpose_8x8 = transpose_8x8_16_c; break; v->transpose_8x8 = transpose_8x8_8_c; break;
case 3: s->transpose_block = transpose_block_24_c; case 2: v->transpose_block = transpose_block_16_c;
s->transpose_8x8 = transpose_8x8_24_c; break; v->transpose_8x8 = transpose_8x8_16_c; break;
case 4: s->transpose_block = transpose_block_32_c; case 3: v->transpose_block = transpose_block_24_c;
s->transpose_8x8 = transpose_8x8_32_c; break; v->transpose_8x8 = transpose_8x8_24_c; break;
case 6: s->transpose_block = transpose_block_48_c; case 4: v->transpose_block = transpose_block_32_c;
s->transpose_8x8 = transpose_8x8_48_c; break; v->transpose_8x8 = transpose_8x8_32_c; break;
case 8: s->transpose_block = transpose_block_64_c; case 6: v->transpose_block = transpose_block_48_c;
s->transpose_8x8 = transpose_8x8_64_c; break; v->transpose_8x8 = transpose_8x8_48_c; break;
case 8: v->transpose_block = transpose_block_64_c;
v->transpose_8x8 = transpose_8x8_64_c; break;
}
} }
av_log(ctx, AV_LOG_VERBOSE, av_log(ctx, AV_LOG_VERBOSE,
@ -290,6 +297,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
uint8_t *dst, *src; uint8_t *dst, *src;
int dstlinesize, srclinesize; int dstlinesize, srclinesize;
int x, y; int x, y;
TransVtable *v = &s->vtables[plane];
dstlinesize = out->linesize[plane]; dstlinesize = out->linesize[plane];
dst = out->data[plane] + start * dstlinesize; dst = out->data[plane] + start * dstlinesize;
@ -308,20 +316,20 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
for (y = start; y < end - 7; y += 8) { for (y = start; y < end - 7; y += 8) {
for (x = 0; x < outw - 7; x += 8) { for (x = 0; x < outw - 7; x += 8) {
s->transpose_8x8(src + x * srclinesize + y * pixstep, v->transpose_8x8(src + x * srclinesize + y * pixstep,
srclinesize, srclinesize,
dst + (y - start) * dstlinesize + x * pixstep, dst + (y - start) * dstlinesize + x * pixstep,
dstlinesize); dstlinesize);
} }
if (outw - x > 0 && end - y > 0) if (outw - x > 0 && end - y > 0)
s->transpose_block(src + x * srclinesize + y * pixstep, v->transpose_block(src + x * srclinesize + y * pixstep,
srclinesize, srclinesize,
dst + (y - start) * dstlinesize + x * pixstep, dst + (y - start) * dstlinesize + x * pixstep,
dstlinesize, outw - x, end - y); dstlinesize, outw - x, end - y);
} }
if (end - y > 0) if (end - y > 0)
s->transpose_block(src + 0 * srclinesize + y * pixstep, v->transpose_block(src + 0 * srclinesize + y * pixstep,
srclinesize, srclinesize,
dst + (y - start) * dstlinesize + 0 * pixstep, dst + (y - start) * dstlinesize + 0 * pixstep,
dstlinesize, outw, end - y); dstlinesize, outw, end - y);

View File

@ -45,10 +45,10 @@ gray16be 4aef307021a91b1de67f1d4381a39132
gray16le 76f2afe156edca7ae05cfa4e5867126e gray16le 76f2afe156edca7ae05cfa4e5867126e
gray9be 2c425fa532c940d226822da8b3592310 gray9be 2c425fa532c940d226822da8b3592310
gray9le bcc575942910b3c72eaa72e8794f3acd gray9le bcc575942910b3c72eaa72e8794f3acd
nv12 aca847644e5dc0e942419183014981a4 nv12 1965e3826144686748f2f6b516fca5ba
nv21 098884e968d27286c8cf0d2fb1557dcd nv21 292adaf5271c5c8516b71640458c01f4
p010be 5ff62dffa5dfdf823978c4f563f69c94 p010be ad0de2cc9bff81688b182a870fcf7000
p010le 20131abe34e084b04f1d169c66447825 p010le e7ff5143595021246733ce6bd0a769e8
rgb0 31ea5da7fe779c6ea0a33f1d28aad918 rgb0 31ea5da7fe779c6ea0a33f1d28aad918
rgb24 47654cabaaad79170b90afd5a02161dd rgb24 47654cabaaad79170b90afd5a02161dd
rgb444be 3cac1f0c43a74d2a95eb02e187070845 rgb444be 3cac1f0c43a74d2a95eb02e187070845