mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 16:52:31 +00:00
avfilter/vf_stereo3d: add interleave columns output format
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
8bd13eb8be
commit
32dd9b2c6e
@ -62,6 +62,8 @@ enum StereoCode {
|
||||
ALTERNATING_RL, // alternating frames (right eye first, left eye second)
|
||||
CHECKERBOARD_LR, // checkerboard pattern (left eye first, right eye second)
|
||||
CHECKERBOARD_RL, // checkerboard pattern (right eye first, left eye second)
|
||||
INTERLEAVE_COLS_LR, // column-interleave (left eye first, right eye second)
|
||||
INTERLEAVE_COLS_RL, // column-interleave (right eye first, left eye second)
|
||||
HDMI, // HDMI frame pack (left eye first, right eye second)
|
||||
STEREO_CODE_COUNT // TODO: needs autodetection
|
||||
};
|
||||
@ -198,6 +200,8 @@ static const AVOption stereo3d_options[] = {
|
||||
{ "sbsr", "side by side right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_RL}, 0, 0, FLAGS, "out" },
|
||||
{ "chl", "checkerboard left first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_LR}, 0, 0, FLAGS, "out" },
|
||||
{ "chr", "checkerboard right first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_RL}, 0, 0, FLAGS, "out" },
|
||||
{ "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "out" },
|
||||
{ "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "out" },
|
||||
{ "hdmi", "HDMI frame pack", 0, AV_OPT_TYPE_CONST, {.i64=HDMI}, 0, 0, FLAGS, "out" },
|
||||
{ NULL }
|
||||
};
|
||||
@ -496,6 +500,10 @@ static int config_output(AVFilterLink *outlink)
|
||||
case CHECKERBOARD_RL:
|
||||
s->out.width = s->width * 2;
|
||||
break;
|
||||
case INTERLEAVE_COLS_LR:
|
||||
case INTERLEAVE_COLS_RL:
|
||||
s->out.width = s->width * 2;
|
||||
break;
|
||||
default:
|
||||
av_log(ctx, AV_LOG_ERROR, "output format %d is not supported\n", s->out.format);
|
||||
return AVERROR(EINVAL);
|
||||
@ -743,6 +751,61 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INTERLEAVE_COLS_LR:
|
||||
case INTERLEAVE_COLS_RL:
|
||||
for (i = 0; i < s->nb_planes; i++) {
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < s->pheight[i]; y++) {
|
||||
uint8_t *dst = out->data[i] + out->linesize[i] * y;
|
||||
uint8_t *left = ileft->data[i] + ileft->linesize[i] * y * s->in.row_step + s->in_off_left[i];
|
||||
uint8_t *right = iright->data[i] + iright->linesize[i] * y * s->in.row_step + s->in_off_right[i];
|
||||
int p, b;
|
||||
|
||||
if (s->out.format == INTERLEAVE_COLS_LR)
|
||||
FFSWAP(uint8_t*, left, right);
|
||||
|
||||
switch (s->pixstep[i]) {
|
||||
case 1:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b++) {
|
||||
dst[x ] = b&1 ? left[p] : right[p];
|
||||
dst[x+1] = !(b&1) ? left[p] : right[p];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b++) {
|
||||
AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
|
||||
AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p]) : AV_RN16(&right[p]));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b++) {
|
||||
AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
|
||||
AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p]) : AV_RB24(&right[p]));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b++) {
|
||||
AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
|
||||
AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p]) : AV_RN32(&right[p]));
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b++) {
|
||||
AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
|
||||
AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p]) : AV_RB48(&right[p]));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b++) {
|
||||
AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
|
||||
AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p]) : AV_RN64(&right[p]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
av_assert0(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user