Message ID | 20190531004449.16987-1-zhong.li@intel.com |
---|---|
State | Accepted |
Commit | 4208b428c4730f86438ec777642c6e455845b670 |
Headers | show |
Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li <zhong.li@intel.com>: > @@ -104,6 +109,8 @@ static const AVOption options[] = { > { "width", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, > { "h", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > { "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > + { "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS }, AV_OPT_TYPE_PIXEL_FMT? Or do I miss something? Carl Eugen
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Carl Eugen Hoyos > Sent: Saturday, June 1, 2019 4:43 AM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format > option > > Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li <zhong.li@intel.com>: > > > @@ -104,6 +109,8 @@ static const AVOption options[] = { > > { "width", "Output video width", OFFSET(ow), > AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, > > { "h", "Output video height", OFFSET(oh), > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > > { "height", "Output video height", OFFSET(oh), > > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > > + { "format", "Output pixel format", OFFSET(output_format_str), > > + AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS }, > > AV_OPT_TYPE_PIXEL_FMT? > Or do I miss something? > > Carl Eugen It is a string and converted to AVPixelFormat using av_get_pix_fmt() Keep alignment with vf_scaling_qsv/npp/vaapi.c
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf > Of Li, Zhong > Sent: Monday, June 3, 2019 10:59 AM > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format > option > > > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On > Behalf > > Of Carl Eugen Hoyos > > Sent: Saturday, June 1, 2019 4:43 AM > > To: FFmpeg development discussions and patches > > <ffmpeg-devel@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format > > option > > > > Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li <zhong.li@intel.com>: > > > > > @@ -104,6 +109,8 @@ static const AVOption options[] = { > > > { "width", "Output video width", OFFSET(ow), > > AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, > > > { "h", "Output video height", OFFSET(oh), > > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > > > { "height", "Output video height", OFFSET(oh), > > > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, > > > + { "format", "Output pixel format", OFFSET(output_format_str), > > > + AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS }, > > > > AV_OPT_TYPE_PIXEL_FMT? > > Or do I miss something? > > > > Carl Eugen > > It is a string and converted to AVPixelFormat using av_get_pix_fmt() >Keep alignment with vf_scaling_qsv/npp/vaapi.c Does this answer make sense? If so will push it soon.
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 41a9f38962..39079a410b 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -57,6 +57,10 @@ typedef struct VPPContext{ int out_width; int out_height; + /** + * Output sw format. AV_PIX_FMT_NONE for no conversion. + */ + enum AVPixelFormat out_format; AVRational framerate; /* target framerate */ int use_frc; /* use framerate conversion */ @@ -79,6 +83,7 @@ typedef struct VPPContext{ char *cx, *cy, *cw, *ch; char *ow, *oh; + char *output_format_str; } VPPContext; static const AVOption options[] = { @@ -104,6 +109,8 @@ static const AVOption options[] = { { "width", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, { "h", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, { "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, + { "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS }, + { NULL } }; @@ -207,6 +214,23 @@ release: return ret; } +static av_cold int vpp_init(AVFilterContext *ctx) +{ + VPPContext *vpp = ctx->priv; + + if (!strcmp(vpp->output_format_str, "same")) { + vpp->out_format = AV_PIX_FMT_NONE; + } else { + vpp->out_format = av_get_pix_fmt(vpp->output_format_str); + if (vpp->out_format == AV_PIX_FMT_NONE) { + av_log(ctx, AV_LOG_ERROR, "Unrecognized output pixel format: %s\n", vpp->output_format_str); + return AVERROR(EINVAL); + } + } + + return 0; +} + static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; @@ -251,6 +275,7 @@ static int config_output(AVFilterLink *outlink) QSVVPPCrop crop = { 0 }; mfxExtBuffer *ext_buf[ENH_FILTERS_COUNT]; AVFilterLink *inlink = ctx->inputs[0]; + enum AVPixelFormat in_format; outlink->w = vpp->out_width; outlink->h = vpp->out_height; @@ -258,10 +283,19 @@ static int config_output(AVFilterLink *outlink) outlink->time_base = av_inv_q(vpp->framerate); param.filter_frame = NULL; - param.out_sw_format = AV_PIX_FMT_NV12; param.num_ext_buf = 0; param.ext_buf = ext_buf; + if (inlink->format == AV_PIX_FMT_QSV) { + if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data) + return AVERROR(EINVAL); + else + in_format = ((AVHWFramesContext*)inlink->hw_frames_ctx->data)->sw_format; + } else + in_format = inlink->format; + + param.out_sw_format = (vpp->out_format == AV_PIX_FMT_NONE) ? in_format : vpp->out_format; + if (vpp->use_crop) { crop.in_idx = 0; crop.x = vpp->crop_x; @@ -421,6 +455,7 @@ AVFilter ff_vf_vpp_qsv = { .description = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."), .priv_size = sizeof(VPPContext), .query_formats = query_formats, + .init = vpp_init, .uninit = vpp_uninit, .inputs = vpp_inputs, .outputs = vpp_outputs,
1. Currently output format is hard-coded as NV12, thus means CSC is always done for not NV12 input such as P010. Follow original input format as default output. 2. Add an option to specify output format. Signed-off-by: Zhong Li <zhong.li@intel.com> --- libavfilter/vf_vpp_qsv.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)