On 19/01/18 00:41, Jun Zhao wrote: > On 2018/1/19 8:25, Mark Thompson wrote: >> On 18/01/18 05:18, Jun Zhao wrote: >>> From d157fdbffebd07066b1a857398e1067615f908b3 Mon Sep 17 00:00:00 2001 >>> From: Jun Zhao <jun.z...@intel.com> >>> Date: Mon, 8 Jan 2018 16:02:35 +0800 >>> Subject: [PATCH V3 2/6] lavfi: use common VPP infrastructure for >>> vf_scale_vaapi. >>> >>> Use the common VPP infrastructure re-work vf_scale_vaapi. >>> >>> Signed-off-by: Jun Zhao <jun.z...@intel.com> >>> --- >>> libavfilter/Makefile | 2 +- >>> libavfilter/vf_scale_vaapi.c | 353 >>> +++++-------------------------------------- >>> 2 files changed, 41 insertions(+), 314 deletions(-) >>> >>> ... >>> >>> static av_cold int scale_vaapi_init(AVFilterContext *avctx) >>> { >>> - ScaleVAAPIContext *ctx = avctx->priv; >>> + VAAPIVPPContext *vpp_ctx = avctx->priv; >>> + ScaleVAAPIContext *ctx = (ScaleVAAPIContext *)vpp_ctx->priv_data; >> The extra indirection means this is reading ctx before it's set. E.g. try: >> >> $ gdb --args ./ffmpeg_g -y -hwaccel vaapi -hwaccel_device >> /dev/dri/renderD129 -hwaccel_output_format vaapi -i input.mp4 -vf >> 'scale_vaapi=format=invalid' -f null - >> ... >> Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault. >> 0x0000555556927515 in format_line (avcl=0x55555843b950, level=16, >> fmt=0x555556984f69 "Invalid output format.\n", vl=0x7fffffffcfb0, >> part=0x7fffffffbf20, print_prefix=0x55555708c708 <print_prefix>, >> type=0x7fffffffbb18) at src/libavutil/log.c:258 >> 258 AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) + >> (gdb) bt >> #0 0x0000555556927515 in format_line (avcl=0x55555843b950, level=16, >> fmt=0x555556984f69 "Invalid output format.\n", vl=0x7fffffffcfb0, >> part=0x7fffffffbf20, print_prefix=0x55555708c708 <print_prefix>, >> type=0x7fffffffbb18) at src/libavutil/log.c:258 >> #1 0x00005555569278da in av_log_default_callback (ptr=0x55555843b950, >> level=16, fmt=0x555556984f69 "Invalid output format.\n", vl=0x7fffffffcfb0) >> at src/libavutil/log.c:320 >> #2 0x0000555556927d05 in av_vlog (avcl=0x55555843b950, level=16, >> fmt=0x555556984f69 "Invalid output format.\n", vl=0x7fffffffcfb0) at >> src/libavutil/log.c:377 >> #3 0x0000555556927cc4 in av_log (avcl=0x55555843b950, level=16, >> fmt=0x555556984f69 "Invalid output format.\n") at src/libavutil/log.c:369 >> #4 0x0000555555844bac in scale_vaapi_init (avctx=0x55555836ad80) at >> src/libavfilter/vf_scale_vaapi.c:151 >> >> >> I still think having VAAPIVPPContext as the first element of >> ScaleVAAPIContext would be cleaner. >> > This issue have been fix in local, if we put VAAPIVPPContext as the > first element of ScaleVAAPIContex, I can't find a way to reuse VPP > common APP. > > e,g, for: scale_vaapi_vpp_config_input, need to implement as: (the first > version ) > > > static int scale_vaapi_config_input(AVFilterLink *inlink) > { > AVFilterContext *avctx = inlink->dst; > ScaleVAAPIContext *ctx = avctx->priv; > VAAPIVPPContext *vpp_ctx = ctx->vpp_ctx; return > vaapi_vpp_config_input(inlink, vpp_ctx); > }
No, you don't need this function - it's completely equivalent to calling ff_vaapi_vpp_context_input() directly in what you currently have, because avctx->priv is a pointer to both the ScaleVAAPIContext and its first member which is the VAAPIVPPContext. - Mark _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel