mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-06 15:49:50 +08:00
avfilter/vpp_amf: add option reset_sar
4b77a0a681 added a new consumer of ff_scale_adjust_dimensions which was recently modified to allow for square pixel output. This commit extends the new option to vpp_amf, and unbreaks the building of vf_amf_common.c
This commit is contained in:
@ -25796,6 +25796,9 @@ pixel format is used.
|
||||
@item force_divisible_by
|
||||
Work the same as the identical @ref{scale} filter options.
|
||||
|
||||
@item reset_sar
|
||||
Works the same as the identical @ref{scale} filter option.
|
||||
|
||||
@anchor{color_profile}
|
||||
@item color_profile
|
||||
Specify all color properties at once.
|
||||
|
@ -158,11 +158,6 @@ int amf_filter_filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (inlink->sample_aspect_ratio.num) {
|
||||
outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
|
||||
} else
|
||||
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
|
||||
|
||||
av_frame_free(&in);
|
||||
return ff_filter_frame(outlink, out);
|
||||
fail:
|
||||
@ -274,6 +269,7 @@ int amf_init_filter_config(AVFilterLink *outlink, enum AVPixelFormat *in_format)
|
||||
enum AVPixelFormat out_sw_format = ctx->format;
|
||||
FilterLink *inl = ff_filter_link(inlink);
|
||||
FilterLink *outl = ff_filter_link(outlink);
|
||||
double w_adj = 1.0;
|
||||
|
||||
if ((err = ff_scale_eval_dimensions(avctx,
|
||||
ctx->w_expr, ctx->h_expr,
|
||||
@ -281,8 +277,11 @@ int amf_init_filter_config(AVFilterLink *outlink, enum AVPixelFormat *in_format)
|
||||
&ctx->width, &ctx->height)) < 0)
|
||||
return err;
|
||||
|
||||
if (ctx->reset_sar && inlink->sample_aspect_ratio.num)
|
||||
w_adj = (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den;
|
||||
|
||||
ff_scale_adjust_dimensions(inlink, &ctx->width, &ctx->height,
|
||||
ctx->force_original_aspect_ratio, ctx->force_divisible_by, 1.0);
|
||||
ctx->force_original_aspect_ratio, ctx->force_divisible_by, w_adj);
|
||||
|
||||
av_buffer_unref(&ctx->amf_device_ref);
|
||||
av_buffer_unref(&ctx->hwframes_in_ref);
|
||||
@ -343,6 +342,13 @@ int amf_init_filter_config(AVFilterLink *outlink, enum AVPixelFormat *in_format)
|
||||
outlink->w = ctx->width;
|
||||
outlink->h = ctx->height;
|
||||
|
||||
if (ctx->reset_sar)
|
||||
outlink->sample_aspect_ratio = (AVRational){1, 1};
|
||||
else if (inlink->sample_aspect_ratio.num) {
|
||||
outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
|
||||
} else
|
||||
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
|
||||
|
||||
hwframes_out->width = outlink->w;
|
||||
hwframes_out->height = outlink->h;
|
||||
|
||||
|
@ -48,6 +48,7 @@ typedef struct AMFFilterContext {
|
||||
char *format_str;
|
||||
int force_original_aspect_ratio;
|
||||
int force_divisible_by;
|
||||
int reset_sar;
|
||||
|
||||
AMFComponent *component;
|
||||
AVBufferRef *amf_device_ref;
|
||||
|
@ -221,6 +221,7 @@ static const AVOption vpp_amf_options[] = {
|
||||
{ "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "force_oar" },
|
||||
{ "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, "force_oar" },
|
||||
{ "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
|
||||
{ "reset_sar", "reset SAR to 1 and scale to square pixels if scaling proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
Reference in New Issue
Block a user