1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavfi/stereo3d: Set SAR for every output frame.

Fixes ticket #6672.
This commit is contained in:
Carl Eugen Hoyos 2017-09-18 23:10:06 +02:00
parent 2f3a3a7e32
commit b4b02477bd

View File

@ -150,6 +150,7 @@ typedef struct Stereo3DContext {
AVFrame *prev; AVFrame *prev;
int blanks; int blanks;
int in_off_left[4], in_off_right[4]; int in_off_left[4], in_off_right[4];
AVRational aspect;
Stereo3DDSPContext dsp; Stereo3DDSPContext dsp;
} Stereo3DContext; } Stereo3DContext;
@ -359,11 +360,11 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *inlink = ctx->inputs[0];
Stereo3DContext *s = ctx->priv; Stereo3DContext *s = ctx->priv;
AVRational aspect = inlink->sample_aspect_ratio;
AVRational fps = inlink->frame_rate; AVRational fps = inlink->frame_rate;
AVRational tb = inlink->time_base; AVRational tb = inlink->time_base;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
int ret; int ret;
s->aspect = inlink->sample_aspect_ratio;
switch (s->in.format) { switch (s->in.format) {
case INTERLEAVE_COLS_LR: case INTERLEAVE_COLS_LR:
@ -404,25 +405,25 @@ static int config_output(AVFilterLink *outlink)
switch (s->in.format) { switch (s->in.format) {
case SIDE_BY_SIDE_2_LR: case SIDE_BY_SIDE_2_LR:
aspect.num *= 2; s->aspect.num *= 2;
case SIDE_BY_SIDE_LR: case SIDE_BY_SIDE_LR:
s->width = inlink->w / 2; s->width = inlink->w / 2;
s->in.off_right = s->width; s->in.off_right = s->width;
break; break;
case SIDE_BY_SIDE_2_RL: case SIDE_BY_SIDE_2_RL:
aspect.num *= 2; s->aspect.num *= 2;
case SIDE_BY_SIDE_RL: case SIDE_BY_SIDE_RL:
s->width = inlink->w / 2; s->width = inlink->w / 2;
s->in.off_left = s->width; s->in.off_left = s->width;
break; break;
case ABOVE_BELOW_2_LR: case ABOVE_BELOW_2_LR:
aspect.den *= 2; s->aspect.den *= 2;
case ABOVE_BELOW_LR: case ABOVE_BELOW_LR:
s->in.row_right = s->in.row_right =
s->height = inlink->h / 2; s->height = inlink->h / 2;
break; break;
case ABOVE_BELOW_2_RL: case ABOVE_BELOW_2_RL:
aspect.den *= 2; s->aspect.den *= 2;
case ABOVE_BELOW_RL: case ABOVE_BELOW_RL:
s->in.row_left = s->in.row_left =
s->height = inlink->h / 2; s->height = inlink->h / 2;
@ -486,19 +487,19 @@ static int config_output(AVFilterLink *outlink)
break; break;
} }
case SIDE_BY_SIDE_2_LR: case SIDE_BY_SIDE_2_LR:
aspect.den *= 2; s->aspect.den *= 2;
case SIDE_BY_SIDE_LR: case SIDE_BY_SIDE_LR:
s->out.width = s->width * 2; s->out.width = s->width * 2;
s->out.off_right = s->width; s->out.off_right = s->width;
break; break;
case SIDE_BY_SIDE_2_RL: case SIDE_BY_SIDE_2_RL:
aspect.den *= 2; s->aspect.den *= 2;
case SIDE_BY_SIDE_RL: case SIDE_BY_SIDE_RL:
s->out.width = s->width * 2; s->out.width = s->width * 2;
s->out.off_left = s->width; s->out.off_left = s->width;
break; break;
case ABOVE_BELOW_2_LR: case ABOVE_BELOW_2_LR:
aspect.num *= 2; s->aspect.num *= 2;
case ABOVE_BELOW_LR: case ABOVE_BELOW_LR:
s->out.height = s->height * 2; s->out.height = s->height * 2;
s->out.row_right = s->height; s->out.row_right = s->height;
@ -514,7 +515,7 @@ static int config_output(AVFilterLink *outlink)
s->out.row_right = s->height + s->blanks; s->out.row_right = s->height + s->blanks;
break; break;
case ABOVE_BELOW_2_RL: case ABOVE_BELOW_2_RL:
aspect.num *= 2; s->aspect.num *= 2;
case ABOVE_BELOW_RL: case ABOVE_BELOW_RL:
s->out.height = s->height * 2; s->out.height = s->height * 2;
s->out.row_left = s->height; s->out.row_left = s->height;
@ -576,7 +577,7 @@ static int config_output(AVFilterLink *outlink)
outlink->h = s->out.height; outlink->h = s->out.height;
outlink->frame_rate = fps; outlink->frame_rate = fps;
outlink->time_base = tb; outlink->time_base = tb;
outlink->sample_aspect_ratio = aspect; outlink->sample_aspect_ratio = s->aspect;
if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, s->width)) < 0) if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, s->width)) < 0)
return ret; return ret;
@ -1075,6 +1076,7 @@ copy:
av_frame_free(&s->prev); av_frame_free(&s->prev);
av_frame_free(&inpicref); av_frame_free(&inpicref);
} }
out->sample_aspect_ratio = s->aspect;
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }