Re: [FFmpeg-devel] [PATCH] configure: Change the configure check for tonemap_vaapi

2019-12-29 Thread Sun, Xinpeng

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Mark
> Thompson
> Sent: Saturday, December 28, 2019 7:57 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] configure: Change the configure check for
> tonemap_vaapi
> 
> On 24/12/2019 06:32, Xinpeng Sun wrote:
> > "VAProcFilterParameterBufferHDRToneMapping" was defined in libva
> > 2.4.1, which will lead to build failure for the filter tonemap_vaapi
> > for libva 2.3.0 with current check. This patch is to fix this build error.
> >
> > Signed-off-by: Xinpeng Sun 
> > ---
> >  configure | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/configure b/configure
> > index eec43c3b06..157dc30132 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3580,7 +3580,7 @@ tinterlace_filter_deps="gpl"
> >  tinterlace_merge_test_deps="tinterlace_filter"
> >  tinterlace_pad_test_deps="tinterlace_filter"
> >  tonemap_filter_deps="const_nan"
> > -tonemap_vaapi_filter_deps="vaapi
> VAProcPipelineParameterBuffer_output_hdr_metadata"
> > +tonemap_vaapi_filter_deps="vaapi
> VAProcFilterParameterBufferHDRToneMapping_type"
> 
> This is out of order, you could fix that at the same time.

Fixed together in the v2 version.

> 
> >  tonemap_opencl_filter_deps="opencl const_nan"
> >  transpose_opencl_filter_deps="opencl"
> >  transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
> > @@ -6585,7 +6585,7 @@ if enabled vaapi; then
> >
> >  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> > -check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
> output_hdr_metadata
> > +check_struct "va/va.h va/va_vpp.h"
> > + "VAProcFilterParameterBufferHDRToneMapping" type
> 
> You only want the structure itself rather than any particular member of it, 
> right?
> I think that means you want check_type rather than check_struct.

Exactly so. Changed in the v2 version.

Thanks,
Xinpeng

> 
> >  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
> >  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
> >  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
> >
> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org
> with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/2] configure: Reorder the filters part by alphabet

2019-12-29 Thread Xinpeng Sun
Signed-off-by: Xinpeng Sun 
---
 configure | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 01b4acd77e..e7036b04ec 100755
--- a/configure
+++ b/configure
@@ -3510,6 +3510,7 @@ interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
 lensfun_filter_deps="liblensfun version3"
+libvmaf_filter_deps="libvmaf pthreads"
 lv2_filter_deps="lv2"
 mcdeint_filter_deps="avcodec gpl"
 movie_filter_deps="avcodec avformat"
@@ -3530,6 +3531,7 @@ owdenoise_filter_deps="gpl"
 pan_filter_deps="swresample"
 perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
+pixfmts_super2xsai_test_deps="super2xsai_filter"
 pp7_filter_deps="gpl"
 pp_filter_deps="gpl postproc"
 prewitt_opencl_filter_deps="opencl"
@@ -3545,6 +3547,7 @@ sab_filter_deps="gpl swscale"
 scale2ref_filter_deps="swscale"
 scale_filter_deps="swscale"
 scale_qsv_filter_deps="libmfx"
+scale_vaapi_filter_deps="vaapi"
 select_filter_select="scene_sad"
 sharpness_vaapi_filter_deps="vaapi"
 showcqt_filter_deps="avcodec avformat swscale"
@@ -3572,15 +3575,14 @@ sr_filter_select="dnn"
 stereo3d_filter_deps="gpl"
 subtitles_filter_deps="avformat avcodec libass"
 super2xsai_filter_deps="gpl"
-pixfmts_super2xsai_test_deps="super2xsai_filter"
 superequalizer_filter_select="rdft"
 surround_filter_select="rdft"
 tinterlace_filter_deps="gpl"
 tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
-tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
 tonemap_opencl_filter_deps="opencl const_nan"
+tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
 transpose_opencl_filter_deps="opencl"
 transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
 unsharp_opencl_filter_deps="opencl"
@@ -3588,15 +3590,13 @@ uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
 vidstabdetect_filter_deps="libvidstab"
 vidstabtransform_filter_deps="libvidstab"
-libvmaf_filter_deps="libvmaf pthreads"
-zmq_filter_deps="libzmq"
-zoompan_filter_deps="swscale"
-zscale_filter_deps="libzimg const_nan"
-scale_vaapi_filter_deps="vaapi"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
+zmq_filter_deps="libzmq"
+zoompan_filter_deps="swscale"
+zscale_filter_deps="libzimg const_nan"
 
 # examples
 avio_dir_cmd_deps="avformat avutil"
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 1/2] configure: Change the configure check for tonemap_vaapi

2019-12-29 Thread Xinpeng Sun
"VAProcFilterParameterBufferHDRToneMapping" was defined in libva 2.4.1, which 
will lead to
build failure for the filter tonemap_vaapi for libva 2.3.0 with current check. 
This patch
is to fix this build error.

Signed-off-by: Xinpeng Sun 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 43dc409fe6..01b4acd77e 100755
--- a/configure
+++ b/configure
@@ -3579,7 +3579,7 @@ tinterlace_filter_deps="gpl"
 tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
-tonemap_vaapi_filter_deps="vaapi 
VAProcPipelineParameterBuffer_output_hdr_metadata"
+tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
 tonemap_opencl_filter_deps="opencl const_nan"
 transpose_opencl_filter_deps="opencl"
 transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
@@ -6584,7 +6584,7 @@ if enabled vaapi; then
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
-check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" 
output_hdr_metadata
+check_type   "va/va.h va/va_vpp.h" 
"VAProcFilterParameterBufferHDRToneMapping"
 check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
 check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5] avfilter/buffersrc: deprecate sws_param option

2019-12-29 Thread quinkblack
From: Zhao Zhili 

---
Rebase patch on master.

 doc/filters.texi|  8 
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 619542e7b5..341503c7f8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21209,9 +21209,9 @@ Specify the frame rate expected for the video stream.
 The sample (pixel) aspect ratio of the input video.
 
 @item sws_param
-Specify the optional parameters to be used for the scale filter which
-is automatically inserted when an input change is detected in the
-input size or format.
+This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
+to the filtergraph description to specify swscale flags for automatically
+inserted scalers. See @ref{Filtergraph syntax}.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
@@ -21236,7 +21236,7 @@ 
buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
 Alternatively, the options can be specified as a flat string, but this
 syntax is deprecated:
 
-@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
+@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
 
 @section cellauto
 
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 2fa9e00daf..64940d91e2 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -51,7 +51,9 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
 char  *sws_param;
+#endif
 
 AVBufferRef *hw_frames_ctx;
 
@@ -271,10 +273,16 @@ static av_cold int init_video(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
-av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d sws_param:%s\n",
+av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d 
sar:%d/%d\n",
c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
c->time_base.num, c->time_base.den, c->frame_rate.num, 
c->frame_rate.den,
-   c->pixel_aspect.num, c->pixel_aspect.den, (char 
*)av_x_if_null(c->sws_param, ""));
+   c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+if (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+#endif
+
 return 0;
 }
 
@@ -296,7 +304,9 @@ static const AVOption buffer_options[] = {
 { "pixel_aspect",  "sample aspect ratio",OFFSET(pixel_aspect), 
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+#endif
 { NULL },
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 8a9032859f..b029905ed4 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   7
 #define LIBAVFILTER_VERSION_MINOR  70
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -59,6 +59,9 @@
 #ifndef FF_API_FILTER_GET_SET
 #define FF_API_FILTER_GET_SET   (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
+#ifndef FF_API_SWS_PARAM_OPTION
+#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8)
+#endif
 #ifndef FF_API_NEXT
 #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8)
 #endif
-- 
2.22.0



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_convolution: Add x86 SIMD optimizations for filter_row()

2019-12-29 Thread Xu Jun
Hi, Andriy

- Original Message -
> From: "Andriy Gelman" 
> To: "FFmpeg development discussions and patches" 
> Cc: xuju...@sjtu.edu.cn
> Sent: Monday, December 23, 2019 12:50:48 AM
> Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_convolution: Add x86 
> SIMD optimizations for filter_row()

> Xu,
> 
> On Sun, 22. Dec 16:37, xuju...@sjtu.edu.cn wrote:
>> From: Xu Jun 
>> 
>> Read 16 elements from memory, shuffle and parallally compute 4 rows at a 
>> time,
>> shuffle and parallelly write 16 results to memory.
>> Performance improves about 15% compared to v1.
>> 
>> Tested using this command:
>> ./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 
>> 5 6
>> 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8
>> 9:1/45:1/45:1/45:1/45:1:2:3:4:row:row:row:row" -an -vframes 5000 -f null
>> /dev/null -benchmark
>> 
>> after patch:
>> frame= 4317 fps=622 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=24.9x
>> video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
>> muxing
>> overhead: unknown
>> bench: utime=20.539s stime=1.834s rtime=6.943s
>> 
>> before patch(c version):
>> frame= 4317 fps=306 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=12.2x
>> video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
>> muxing
>> overhead: unknown
>> bench: utime=60.591s stime=1.787s rtime=14.100s
>> 
>> Signed-off-by: Xu Jun 
>> ---
>>  libavfilter/x86/vf_convolution.asm| 131 ++
>>  libavfilter/x86/vf_convolution_init.c |   9 ++
>>  2 files changed, 140 insertions(+)
>>  mode change 100644 => 100755 libavfilter/x86/vf_convolution.asm
>> 
>> diff --git a/libavfilter/x86/vf_convolution.asm
>> b/libavfilter/x86/vf_convolution.asm
>> old mode 100644
>> new mode 100755
>> index 754d4d1064..2a09374b00
>> --- a/libavfilter/x86/vf_convolution.asm
>> +++ b/libavfilter/x86/vf_convolution.asm
>> @@ -154,3 +154,134 @@ cglobal filter_3x3, 4, 15, 7, dst, width, rdiv, bias,
>> matrix, ptr, c0, c1, c2, c
>>  INIT_XMM sse4
>>  FILTER_3X3
>>  %endif
>> +
> 
> Patch 2-3 are failing to build:
> https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/list/?series=26
> 
> --
> Andriy

I'm sorry I haven't built patches independently. There seem to be some bugs in 
the dependency of the patches.
I'll fix them in v3.

Xu Jun  
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow test for hevc_add_res

2019-12-29 Thread Fu, Linjie
Hi,

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Friday, December 27, 2019 17:04
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow test
> for hevc_add_res
> 
> Hi,
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> Fu,
> > Linjie
> > Sent: Wednesday, December 18, 2019 09:55
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>; alexan...@khirnov.net; c...@passwd.hu; Paul B
> Mahol
> > ; jamr...@gmail.com; u...@pkh.me
> > Subject: Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow
> test
> > for hevc_add_res
> >
> > Hi,
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > Fu,
> > > Linjie
> > > Sent: Sunday, December 15, 2019 10:02
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>; jamr...@gmail.com; u...@pkh.me; Pierre-
> > > edouard.lep...@insa-rennes.fr
> > > Subject: Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow
> > test
> > > for hevc_add_res
> > >
> > > Hi,
> > >
> > > > -Original Message-
> > > > From: Fu, Linjie 
> > > > Sent: Wednesday, December 11, 2019 16:46
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Fu, Linjie ; Xu, Guangxin
> > 
> > > > Subject: [PATCH 1/4] tests/checkasm: add overflow test for
> > hevc_add_res
> > > >
> > > > Add overflow test for hevc_add_res when int16_t coeff = -32768.
> > > > The result of C is good, while ASM is not.
> > > >
> > > > To verify:
> > > > make fate-checkasm-hevc_add_res
> > > > ffmpeg/tests/checkasm/checkasm --test=hevc_add_res
> > > >
> > > > ./checkasm --test=hevc_add_res
> > > > checkasm: using random seed 679391863
> > > > MMXEXT:
> > > > hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
> > > >   - hevc_add_res.add_residual [FAILED]
> > > > SSE2:
> > > > hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
> > > > hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
> > > > hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
> > > >   - hevc_add_res.add_residual [FAILED]
> > > > AVX:
> > > > hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
> > > > hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
> > > > hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
> > > >   - hevc_add_res.add_residual [FAILED]
> > > > AVX2:
> > > > hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
> > > >   - hevc_add_res.add_residual [FAILED]
> > > > checkasm: 8 of 14 tests have failed
> > > >
> > > > Signed-off-by: Xu Guangxin 
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > >  tests/checkasm/hevc_add_res.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/tests/checkasm/hevc_add_res.c
> > > > b/tests/checkasm/hevc_add_res.c
> > > > index e92c6b4..a6e3b8a 100644
> > > > --- a/tests/checkasm/hevc_add_res.c
> > > > +++ b/tests/checkasm/hevc_add_res.c
> > > > @@ -58,6 +58,7 @@ static void check_add_res(HEVCDSPContext h, int
> > > > bit_depth)
> > > >
> > > >  randomize_buffers(res0, size);
> > > >  randomize_buffers2(dst0, size);
> > > > +res0[0] = 0x8000;// overflow test
> > > >  memcpy(res1, res0, sizeof(*res0) * size);
> > > >  memcpy(dst1, dst0, sizeof(int16_t) * size);
> > > >
> > > > --
> > > > 2.7.4
> > > A kindly ping.
> > > Any comments towards this?
> > >
> > Ping, and looking forward to any feedbacks.
> >
> > This overflow does affect the decode of the clips with coeff=-32768, and
> > makes it
> > difficult(unless by --disbale-asm) to use software decoded result as a
> > reference for
> > comparation with the hardware decoder.
> 
> Ping for review.
> Same issue exists in h264_idct.asm and make the decode fail.
> IMHO we should get this fixed firstly.
> 
> - linjie
> 
Ping.

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavc/pthread_frame: Update user context in ff_frame_thread_free

2019-12-29 Thread Fu, Linjie
Hi,

> -Original Message-
> From: Fu, Linjie 
> Sent: Friday, December 27, 2019 16:48
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH] lavc/pthread_frame: Update user context in
> ff_frame_thread_free
> 
> Resolution/format changes lead to re-initialization of hardware
> accelerations(vaapi/dxva2/..) with new hwaccel_priv_data in
> the worker-thread. But hwaccel_priv_data in user context won't
> be updated until the resolution changing frame is output.
> 
> A termination with "-vframes" just after the reinit will lead to:
> 1. memory leak in worker-thread.
> 2. double free in user-thread.
> 
> Update user context in ff_frame_thread_free with the last thread
> submit_packet() was called on.
> 
> To reproduce:
> ffmpeg -hwaccel vaapi(dxva2) -v verbose -i
> fate-suite/h264/reinit-large_420_8-to-small_420_8.h264 -pix_fmt nv12
> -f rawvideo -vsync passthrough -vframes 47 -y out.yuv
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/pthread_frame.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 36ac0ac..8bdd735 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -657,6 +657,13 @@ void ff_frame_thread_free(AVCodecContext *avctx,
> int thread_count)
> 
>  park_frame_worker_threads(fctx, thread_count);
> 
> +if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
> + 
> fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
> +if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) <
> 0) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
> +}
> +}
> +
>  if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
>  if (update_context_from_thread(fctx->threads->avctx, fctx-
> >prev_thread->avctx, 0) < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
> --
> 2.7.4

Ping.
This patch helps to fix the decoding crashes.

- linjie

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4] avfilter/buffersrc: deprecate sws_param option

2019-12-29 Thread myp...@gmail.com
On Mon, Dec 23, 2019 at 8:23 PM Nicolas George  wrote:
>
> myp...@gmail.com (12019-12-12):
> > LGTM, but  need to wait next release cycle?
>
> What do you mean? There is all the necessary code to let the option
> disappear automatically at the next release.
>
> I shall push soon, unless you point something I have missed.
>
I forgot this strategy (disappear automatically at the next release),
pls push, no other comments
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/avcodec: Add codec_tags array to AVCodec

2019-12-29 Thread James Almer
On 12/29/2019 9:32 PM, Carl Eugen Hoyos wrote:
> Am Mo., 30. Dez. 2019 um 01:19 Uhr schrieb James Almer :
>>
>> On 12/29/2019 8:38 PM, Michael Niedermayer wrote:
>>> This allows the fuzzer to target meaningfull codec tags instead
>>> of hunting the 4gb space, which it seems to have problems with.
>>>
>>> Suggested-by: James
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>  libavcodec/avcodec.h | 6 ++
>>>  1 file changed, 6 insertions(+)
>>>
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 119b32dc1f..b0c6a8f2e3 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -3634,6 +3634,12 @@ typedef struct AVCodec {
>>>   * The user can only access this field via avcodec_get_hw_config().
>>>   */
>>>  const struct AVCodecHWConfigInternal **hw_configs;
>>> +
>>> +/**
>>> + * List of supported codec_tags, terminated by CODEC_TAGS_END.
>>> + */
>>> +const uint32_t *codec_tags;
>>> +#define CODEC_TAGS_END -1
>>
>> Why not zero? 0x could very well be a valid tag (even if
>> unlikely), and we always terminate arrays with 0.
> 
> 0 is a valid codec tag in avi.
> 
> Carl Eugen

Alright, then -1 is fine. It can always be changed to something else if
needed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/avcodec: Add codec_tags array to AVCodec

2019-12-29 Thread Carl Eugen Hoyos
Am Mo., 30. Dez. 2019 um 01:19 Uhr schrieb James Almer :
>
> On 12/29/2019 8:38 PM, Michael Niedermayer wrote:
> > This allows the fuzzer to target meaningfull codec tags instead
> > of hunting the 4gb space, which it seems to have problems with.
> >
> > Suggested-by: James
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/avcodec.h | 6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 119b32dc1f..b0c6a8f2e3 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -3634,6 +3634,12 @@ typedef struct AVCodec {
> >   * The user can only access this field via avcodec_get_hw_config().
> >   */
> >  const struct AVCodecHWConfigInternal **hw_configs;
> > +
> > +/**
> > + * List of supported codec_tags, terminated by CODEC_TAGS_END.
> > + */
> > +const uint32_t *codec_tags;
> > +#define CODEC_TAGS_END -1
>
> Why not zero? 0x could very well be a valid tag (even if
> unlikely), and we always terminate arrays with 0.

0 is a valid codec tag in avi.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/avcodec: Add codec_tags array to AVCodec

2019-12-29 Thread James Almer
On 12/29/2019 8:38 PM, Michael Niedermayer wrote:
> This allows the fuzzer to target meaningfull codec tags instead
> of hunting the 4gb space, which it seems to have problems with.
> 
> Suggested-by: James
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/avcodec.h | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 119b32dc1f..b0c6a8f2e3 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3634,6 +3634,12 @@ typedef struct AVCodec {
>   * The user can only access this field via avcodec_get_hw_config().
>   */
>  const struct AVCodecHWConfigInternal **hw_configs;
> +
> +/**
> + * List of supported codec_tags, terminated by CODEC_TAGS_END.
> + */
> +const uint32_t *codec_tags;
> +#define CODEC_TAGS_END -1

Why not zero? 0x could very well be a valid tag (even if
unlikely), and we always terminate arrays with 0.

Also, should if anything be defined in internal.h, and not in a public
header.

>  } AVCodec;
>  
>  #if FF_API_CODEC_GET_SET
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] tools/target_dec_fuzzer: Use codec_tags list

2019-12-29 Thread Michael Niedermayer
This should make it much quicker for the fuzzer to test
real relevant codec_tags

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index c6e1235ad3..b9e08f74d2 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -212,6 +212,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 ctx->channels   = 
(unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
 ctx->block_align= bytestream2_get_le32(&gbc) & 
0x7FFF;
 ctx->codec_tag  = bytestream2_get_le32(&gbc);
+if (c->codec_tags) {
+int n;
+for (n = 0; c->codec_tags[n] != CODEC_TAGS_END; n++);
+ctx->codec_tag = c->codec_tags[ctx->codec_tag % n];
+}
 keyframes   = bytestream2_get_le64(&gbc);
 ctx->request_channel_layout = bytestream2_get_le64(&gbc);
 
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] avcodec/avcodec: Add codec_tags array to AVCodec

2019-12-29 Thread Michael Niedermayer
This allows the fuzzer to target meaningfull codec tags instead
of hunting the 4gb space, which it seems to have problems with.

Suggested-by: James
Signed-off-by: Michael Niedermayer 
---
 libavcodec/avcodec.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 119b32dc1f..b0c6a8f2e3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3634,6 +3634,12 @@ typedef struct AVCodec {
  * The user can only access this field via avcodec_get_hw_config().
  */
 const struct AVCodecHWConfigInternal **hw_configs;
+
+/**
+ * List of supported codec_tags, terminated by CODEC_TAGS_END.
+ */
+const uint32_t *codec_tags;
+#define CODEC_TAGS_END -1
 } AVCodec;
 
 #if FF_API_CODEC_GET_SET
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] avcodec/hapdec: Add codec_tags list

2019-12-29 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/hapdec.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 8c845770cf..7759f1da3e 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -484,4 +484,12 @@ AVCodec ff_hap_decoder = {
   AV_CODEC_CAP_DR1,
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
   FF_CODEC_CAP_INIT_CLEANUP,
+.codec_tags = (const uint32_t []){
+MKTAG('H','a','p','1'),
+MKTAG('H','a','p','5'),
+MKTAG('H','a','p','Y'),
+MKTAG('H','a','p','A'),
+MKTAG('H','a','p','M'),
+CODEC_TAGS_END,
+},
 };
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] avfilter/image2: Add source file path and basename to each packet side data.

2019-12-29 Thread Marton Balint



On Sun, 29 Dec 2019, Alexandre Heitor Schmidt wrote:


On 26/12/2019 14:01, Alexandre Heitor Schmidt wrote:
> > you may have to only activate this (or at least the full path 
metadata) feature
> > if the user explicitly requests it. Probably the best way to do 
that is to
> > introduce a new option of the image2 demuxer, probably with an 
AV_OPT_TYPE_FLAGS

> > type.
>
> Do you mean image2 should, for example, have another option like 
'enable_path_metadata' which would make the demuxer export the metadata 
only when set to "1"?


Can I add a new parameter to VideoDemuxData in img2.h, named 
export_path_metadata, which, when explicitly set to 1, will allow 
exporting input path as the special metadata parameters 
(lavf.image2dec.source_path and lavf.image2dec.source_basename)? The 
default will be not to export them, so it won't compromise security, as 
discussed previously in this thread.


Yeah, this seems fine as solution.

Thanks,
Marton



Something like this:

In img2.h:

typedef struct VideoDemuxData {
    const AVClass *class;  /**< Class for private options. */
    int img_first;
    int img_last;
    int img_number;
    int64_t pts;
    int img_count;
    int is_pipe;
    int split_planes;   /**< use independent file for each Y, U, V 
plane */

    char path[1024];
    char *pixel_format; /**< Set by a private option. */
    int width, height;  /**< Set by a private option. */
    AVRational framerate;   /**< Set by a private option. */
    int loop;
    int pattern_type; /**< PatternType */
    int use_glob;
#if HAVE_GLOB
    glob_t globstate;
#endif
    int start_number;
    int start_number_range;
    int frame_size;
    int ts_from_file;
    int export_path_metadata; /**< enabled when set to 1. */
} VideoDemuxData;

In img2dec.c:

#define COMMON_OPTIONS \
    { "framerate",    "set the video framerate", OFFSET(framerate),    
AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC }, \
    { "pixel_format", "set video pixel format", OFFSET(pixel_format), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0,   DEC }, \
    { "video_size",   "set video size", OFFSET(width),    
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0,   DEC }, \
    { "loop", "force loop over input file sequence", 
OFFSET(loop), AV_OPT_TYPE_BOOL,   {.i64 = 0   }, 0, 1,   DEC }, \
    { "export_path_metadata", "enable metadata containing input path 
information", OFFSET(export_path_metadata), AV_OPT_TYPE_BOOL, {.i64 = 
0   }, 0, 1,   DEC }, \

    { NULL },

Alex.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] avfilter/image2: Add source file path and basename to each packet side data.

2019-12-29 Thread Alexandre Heitor Schmidt

On 26/12/2019 14:01, Alexandre Heitor Schmidt wrote:
> > you may have to only activate this (or at least the full path 
metadata) feature
> > if the user explicitly requests it. Probably the best way to do 
that is to
> > introduce a new option of the image2 demuxer, probably with an 
AV_OPT_TYPE_FLAGS

> > type.
>
> Do you mean image2 should, for example, have another option like 
'enable_path_metadata' which would make the demuxer export the metadata 
only when set to "1"?


Can I add a new parameter to VideoDemuxData in img2.h, named 
export_path_metadata, which, when explicitly set to 1, will allow 
exporting input path as the special metadata parameters 
(lavf.image2dec.source_path and lavf.image2dec.source_basename)? The 
default will be not to export them, so it won't compromise security, as 
discussed previously in this thread.


Something like this:

In img2.h:

typedef struct VideoDemuxData {
    const AVClass *class;  /**< Class for private options. */
    int img_first;
    int img_last;
    int img_number;
    int64_t pts;
    int img_count;
    int is_pipe;
    int split_planes;   /**< use independent file for each Y, U, V 
plane */

    char path[1024];
    char *pixel_format; /**< Set by a private option. */
    int width, height;  /**< Set by a private option. */
    AVRational framerate;   /**< Set by a private option. */
    int loop;
    int pattern_type; /**< PatternType */
    int use_glob;
#if HAVE_GLOB
    glob_t globstate;
#endif
    int start_number;
    int start_number_range;
    int frame_size;
    int ts_from_file;
    int export_path_metadata; /**< enabled when set to 1. */
} VideoDemuxData;

In img2dec.c:

#define COMMON_OPTIONS \
    { "framerate",    "set the video framerate", OFFSET(framerate),    
AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC }, \
    { "pixel_format", "set video pixel format", OFFSET(pixel_format), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0,   DEC }, \
    { "video_size",   "set video size", OFFSET(width),    
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0,   DEC }, \
    { "loop", "force loop over input file sequence", 
OFFSET(loop), AV_OPT_TYPE_BOOL,   {.i64 = 0   }, 0, 1,   DEC }, \
    { "export_path_metadata", "enable metadata containing input path 
information", OFFSET(export_path_metadata), AV_OPT_TYPE_BOOL, {.i64 = 
0   }, 0, 1,   DEC }, \

    { NULL },

Alex.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] avcodec/8svx: Use av_assert1(0) instead of error message in unreachable code

2019-12-29 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/8svx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index edc945c697..092dbaae04 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -164,8 +164,7 @@ static av_cold int eightsvx_decode_init(AVCodecContext 
*avctx)
 case AV_CODEC_ID_8SVX_FIB: esc->table = fibonacci;break;
 case AV_CODEC_ID_8SVX_EXP: esc->table = exponential;  break;
 default:
-av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", 
avctx->codec->id);
-return AVERROR_INVALIDDATA;
+av_assert1(0);
 }
 avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
 
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/5] tools/target_dec_fuzzer: Fuzz idct_algo value

2019-12-29 Thread Michael Niedermayer
This should improve coverage

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index a9ad226708..3f77ceac52 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -251,6 +251,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 keyframes   = bytestream2_get_le64(&gbc);
 ctx->request_channel_layout = bytestream2_get_le64(&gbc);
 
+ctx->idct_algo  = bytestream2_get_byte(&gbc) % 
25;
+
 if (extradata_size < size) {
 ctx->extradata = av_mallocz(extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (ctx->extradata) {
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/5] tools/target_dec_fuzzer: Fuzz private options of AC3/E-AC3

2019-12-29 Thread Michael Niedermayer
This should improve AC-3 coverage

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 3f77ceac52..42dd36e2af 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -147,7 +147,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
   const AVPacket *avpkt) = NULL;
 AVCodecParserContext *parser = NULL;
 uint64_t keyframes = 0;
-
+AVDictionary *opts = NULL;
 
 if (!c) {
 #ifdef FFMPEG_DECODER
@@ -253,6 +253,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 
 ctx->idct_algo  = bytestream2_get_byte(&gbc) % 
25;
 
+if (flags & 0x20) {
+switch (ctx->codec_id) {
+case AV_CODEC_ID_AC3:
+case AV_CODEC_ID_EAC3:
+av_dict_set_int(&opts, "cons_noisegen", 
bytestream2_get_byte(&gbc) & 1, 0);
+av_dict_set_int(&opts, "heavy_compr",   
bytestream2_get_byte(&gbc) & 1, 0);
+av_dict_set_int(&opts, "target_level",  
(int)(bytestream2_get_byte(&gbc) % 32) - 31, 0);
+av_dict_set_int(&opts, "dmix_mode", 
(int)(bytestream2_get_byte(&gbc) %  4) -  1, 0);
+break;
+}
+}
+
+
 if (extradata_size < size) {
 ctx->extradata = av_mallocz(extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (ctx->extradata) {
@@ -265,11 +278,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 ctx->width = ctx->height = 0;
 }
 
-int res = avcodec_open2(ctx, c, NULL);
+int res = avcodec_open2(ctx, c, &opts);
 if (res < 0) {
 avcodec_free_context(&ctx);
 av_free(parser_avctx);
 av_parser_close(parser);
+av_dict_free(&opts);
 return 0; // Failure of avcodec_open2() does not imply that a issue 
was found
 }
 parser_avctx->codec_id = ctx->codec_id;
@@ -374,5 +388,6 @@ maximums_reached:
 avcodec_free_context(&parser_avctx);
 av_parser_close(parser);
 av_packet_unref(&parsepkt);
+av_dict_free(&opts);
 return 0;
 }
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/5] avcodec/acelp_pitch_delay: Remove unused functions

2019-12-29 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/acelp_pitch_delay.c | 14 --
 libavcodec/acelp_pitch_delay.h | 33 -
 2 files changed, 47 deletions(-)

diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index a070d1b25d..5ab12ae14d 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -56,20 +56,6 @@ int ff_acelp_decode_5_6_bit_to_2nd_delay3(
 return 3 * pitch_delay_min + ac_index - 2;
 }
 
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
-{
-if(ac_index < 463)
-return ac_index + 105;
-else
-return 6 * (ac_index - 368);
-}
-int ff_acelp_decode_6bit_to_2nd_delay6(
-int ac_index,
-int pitch_delay_min)
-{
-return 6 * pitch_delay_min + ac_index - 3;
-}
-
 void ff_acelp_update_past_gain(
 int16_t* quant_energy,
 int gain_corr_factor,
diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h
index 2aade2f226..973cb0caa0 100644
--- a/libavcodec/acelp_pitch_delay.h
+++ b/libavcodec/acelp_pitch_delay.h
@@ -82,39 +82,6 @@ int ff_acelp_decode_4bit_to_2nd_delay3(
 int ac_index,
 int pitch_delay_min);
 
-/**
- * @brief Decode pitch delay of the first subframe encoded by 9 bits
- *with 1/6 precision.
- * @param ac_index adaptive codebook index (9 bits)
- *
- * @return pitch delay in 1/6 units
- *
- * Pitch delay is coded:
- *with 1/6 resolution,  17  < pitch_delay <  95
- *integers only,95 <= pitch_delay <= 143
- *
- * @remark The routine is used in AMR @@12.2k for the first and third 
subframes.
- */
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index);
-
-/**
- * @brief Decode pitch delay of the second subframe encoded by 6 bits
- *with 1/6 precision.
- * @param ac_index adaptive codebook index (6 bits)
- * @param pitch_delay_min lower bound (integer) of pitch delay interval for
- *  second subframe
- *
- * @return pitch delay in 1/6 units
- *
- * Pitch delay is coded:
- *with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5
- *
- * @remark The routine is used in AMR @@12.2k for the second and fourth 
subframes.
- */
-int ff_acelp_decode_6bit_to_2nd_delay6(
-int ac_index,
-int pitch_delay_min);
-
 /**
  * @brief Update past quantized energies
  * @param[in,out]  quant_energy  past quantized energies (5.10)
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/5] tools/target_dec_fuzzer: Also Fuzz with CPU optimizations disabled

2019-12-29 Thread Michael Niedermayer
This should improve coverage of *_c()

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 42dd36e2af..d02db85340 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -240,6 +240,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 if (flags & 0x10)
 ctx->flags2 |= AV_CODEC_FLAG2_FAST;
 
+if (flags & 0x40)
+av_force_cpu_flags(0);
 
 extradata_size = bytestream2_get_le32(&gbc);
 
-- 
2.24.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] tools/target_dec_fuzzer: List valid codec tags (based on fate)

2019-12-29 Thread James Almer
On 12/28/2019 5:16 PM, Michael Niedermayer wrote:
> I am a bit undecided on listing them like this but it seems the
> fuzzer has difficulty finding valid tags (like in hapdec/snappy)
> 
> With this it finds issues in hapdec within seconds locally (with constrained 
> w/h)
> while before on googles machienes it seemed not to get past the codec_tag
> switch at all on the days i checked

What about adding an array of supported codec_tag to AVCodec, much like
the ones in AVOutputFormat and AVInputFormat? One can then be chosen at
random here like i did with codec_id in the bsf fuzzer.

Different decoders and encoders for the same codecs (internal vs
external ones for example) tend to have different feature sets that many
times are informed with codec tags, so this could even be used to choose
the best decoder/encoder assuming more than one is compiled in.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 8/8] lavc/hevcdec: add 4:2:2 8-bit/10-bit VAAPI decode support

2019-12-29 Thread Linjie Fu
Add decode support for 4:2:2 8-bt and 10-bit HEVC Range Extension clips.

Signed-off-by: Linjie Fu 
---
 libavcodec/hevcdec.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 19b0cd8..f60bcf6 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -427,6 +427,12 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 *fmt++ = AV_PIX_FMT_CUDA;
 #endif
 break;
+case AV_PIX_FMT_YUV422P:
+case AV_PIX_FMT_YUV422P10LE:
+#if CONFIG_HEVC_VAAPI_HWACCEL
+   *fmt++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
 case AV_PIX_FMT_YUV420P12:
 case AV_PIX_FMT_YUV444P10:
 case AV_PIX_FMT_YUV444P12:
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 7/8] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

2019-12-29 Thread Linjie Fu
Add function pointer field in vaapi_profile_map[], set profile_parser
for HEVC_REXT to find the exact va_profile.

Also add format map support.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_decode.c | 77 +--
 1 file changed, 47 insertions(+), 30 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..658f26c 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -24,7 +24,7 @@
 #include "decode.h"
 #include "internal.h"
 #include "vaapi_decode.h"
-
+#include "vaapi_hevc.h"
 
 int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
   VAAPIDecodePicture *pic,
@@ -256,6 +256,12 @@ static const struct {
 #ifdef VA_FOURCC_YV16
 MAP(YV16, YUV422P),
 #endif
+#ifdef VA_FOURCC_YUY2
+MAP(YUY2, YUYV422),
+#endif
+#ifdef VA_FOURCC_Y210
+MAP(Y210,Y210),
+#endif
 // 4:4:0
 MAP(422V, YUV440P),
 // 4:4:4
@@ -364,39 +370,44 @@ static const struct {
 enum AVCodecID codec_id;
 int codec_profile;
 VAProfile va_profile;
+VAProfile (*profile_parser)(AVCodecContext *avctx);
 } vaapi_profile_map[] = {
-#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
-MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple ),
-MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   ),
-MAP(H263,UNKNOWN, H263Baseline),
-MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple ),
+#define MAP(c, p, v, f) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v, 
f}
+MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple , NULL ),
+MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2Main   , NULL ),
+MAP(H263,UNKNOWN, H263Baseline, NULL ),
+MAP(MPEG4,   MPEG4_SIMPLE,MPEG4Simple , NULL ),
 MAP(MPEG4,   MPEG4_ADVANCED_SIMPLE,
-   MPEG4AdvancedSimple),
-MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   ),
+   MPEG4AdvancedSimple, NULL ),
+MAP(MPEG4,   MPEG4_MAIN,  MPEG4Main   , NULL ),
 MAP(H264,H264_CONSTRAINED_BASELINE,
-   H264ConstrainedBaseline),
-MAP(H264,H264_MAIN,   H264Main),
-MAP(H264,H264_HIGH,   H264High),
+   H264ConstrainedBaseline, NULL ),
+MAP(H264,H264_MAIN,   H264Main, NULL ),
+MAP(H264,H264_HIGH,   H264High, NULL ),
 #if VA_CHECK_VERSION(0, 37, 0)
-MAP(HEVC,HEVC_MAIN,   HEVCMain),
-MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
+MAP(HEVC,HEVC_MAIN,   HEVCMain, NULL ),
+MAP(HEVC,HEVC_MAIN_10,HEVCMain10  , NULL ),
+#endif
+#if VA_CHECK_VERSION(1, 2, 0)
+MAP(HEVC,HEVC_REXT,   None,
+  ff_vaapi_parse_rext_profile),
 #endif
 MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
-  JPEGBaseline),
-MAP(WMV3,VC1_SIMPLE,  VC1Simple   ),
-MAP(WMV3,VC1_MAIN,VC1Main ),
-MAP(WMV3,VC1_COMPLEX, VC1Advanced ),
-MAP(WMV3,VC1_ADVANCED,VC1Advanced ),
-MAP(VC1, VC1_SIMPLE,  VC1Simple   ),
-MAP(VC1, VC1_MAIN,VC1Main ),
-MAP(VC1, VC1_COMPLEX, VC1Advanced ),
-MAP(VC1, VC1_ADVANCED,VC1Advanced ),
-MAP(VP8, UNKNOWN,   VP8Version0_3 ),
+  JPEGBaseline, NULL ),
+MAP(WMV3,VC1_SIMPLE,  VC1Simple   , NULL ),
+MAP(WMV3,VC1_MAIN,VC1Main , NULL ),
+MAP(WMV3,VC1_COMPLEX, VC1Advanced , NULL ),
+MAP(WMV3,VC1_ADVANCED,VC1Advanced , NULL ),
+MAP(VC1, VC1_SIMPLE,  VC1Simple   , NULL ),
+MAP(VC1, VC1_MAIN,VC1Main , NULL ),
+MAP(VC1, VC1_COMPLEX, VC1Advanced , NULL ),
+MAP(VC1, VC1_ADVANCED,VC1Advanced , NULL ),
+MAP(VP8, UNKNOWN,   VP8Version0_3 , NULL ),
 #if VA_CHECK_VERSION(0, 38, 0)
-MAP(VP9, VP9_0,   VP9Profile0 ),
+MAP(VP9, VP9_0,   VP9Profile0 , NULL ),
 #endif
 #if VA_CHECK_VERSION(0, 39, 0)
-MAP(VP9, VP9_2,   VP9Profile2 ),
+MAP(VP9, VP9_2,   VP9Profile2 , NULL ),
 #endif
 #undef MAP
 };
@@ -415,8 +426,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 VAStatus vas;
 int err, i, j;
 const AVCodecDescriptor *codec_desc;
-VAProfile *profile_list = NULL, matched_va_profile;
-int profile_count, exact_match, matched_ff_profile;
+VAProfile *profile_list = NULL, matched_va_profile, va_profile;
+int profile_count, exact_match, matched_ff_profile, codec_profile;
 
 AVHWDeviceContext*device = (AVHWDeviceContext*)device_ref->data;
 AVVAAPIDeviceContext *hwctx = device->hwctx;
@@ -454,15 +465,21 @@ static int vaapi_de

[FFmpeg-devel] [PATCH 5/8] lavc/hevc_ps: parse constraint flags for HEVC REXT

2019-12-29 Thread Linjie Fu
Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

They have to be passed to hw decoders to determine the exact profile for Range
Extension HEVC.

Signed-off-by: Linjie Fu 
---
 libavcodec/hevc_ps.c | 44 
 libavcodec/hevc_ps.h | 13 -
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a30b8b8..87a1da1 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -267,7 +267,7 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 {
 int i;
 
-if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
+if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 43 + 1)
 return -1;
 
 ptl->profile_space = get_bits(gb, 2);
@@ -295,9 +295,45 @@ static int decode_profile_tier_level(GetBitContext *gb, 
AVCodecContext *avctx,
 ptl->non_packed_constraint_flag = get_bits1(gb);
 ptl->frame_only_constraint_flag = get_bits1(gb);
 
-skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
-skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
-skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
+#define check_profile_idc(idc) \
+ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
+
+if (check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(6) ||
+check_profile_idc(7) || check_profile_idc(8) || check_profile_idc(9) ||
+check_profile_idc(10)) {
+
+ptl->max_12bit_constraint_flag= get_bits1(gb);
+ptl->max_10bit_constraint_flag= get_bits1(gb);
+ptl->max_8bit_constraint_flag = get_bits1(gb);
+ptl->max_422chroma_constraint_flag= get_bits1(gb);
+ptl->max_420chroma_constraint_flag= get_bits1(gb);
+ptl->max_monochrome_constraint_flag   = get_bits1(gb);
+ptl->intra_constraint_flag= get_bits1(gb);
+ptl->one_picture_only_constraint_flag = get_bits1(gb);
+ptl->lower_bit_rate_constraint_flag   = get_bits1(gb);
+
+if (check_profile_idc(5) || check_profile_idc(9) || 
check_profile_idc(10)) {
+ptl->max_14bit_constraint_flag= get_bits1(gb);
+skip_bits_long(gb, 33); // XXX_reserved_zero_33bits[0..32]
+} else {
+skip_bits_long(gb, 34); // XXX_reserved_zero_34bits[0..33]
+}
+} else if (check_profile_idc(2)) {
+skip_bits(gb, 7);
+ptl->one_picture_only_constraint_flag = get_bits1(gb);
+skip_bits_long(gb, 35); // XXX_reserved_zero_35bits[0..34]
+} else {
+skip_bits_long(gb, 43); // XXX_reserved_zero_43bits[0..42]
+}
+
+if ((ptl->profile_idc >=1 && ptl->profile_idc <= 5) || ptl->profile_idc == 
9 ||
+ptl->profile_compatibility_flag[1] || 
ptl->profile_compatibility_flag[2] ||
+ptl->profile_compatibility_flag[3] || 
ptl->profile_compatibility_flag[4] ||
+ptl->profile_compatibility_flag[5] || 
ptl->profile_compatibility_flag[9])
+ptl->inbld_flag = get_bits1(gb);
+else
+skip_bits1(gb);
+#undef check_profile_idc
 
 return 0;
 }
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 2840dc4..8e1bccd 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -177,11 +177,22 @@ typedef struct PTLCommon {
 uint8_t tier_flag;
 uint8_t profile_idc;
 uint8_t profile_compatibility_flag[32];
-uint8_t level_idc;
 uint8_t progressive_source_flag;
 uint8_t interlaced_source_flag;
 uint8_t non_packed_constraint_flag;
 uint8_t frame_only_constraint_flag;
+uint8_t max_12bit_constraint_flag;
+uint8_t max_10bit_constraint_flag;
+uint8_t max_8bit_constraint_flag;
+uint8_t max_422chroma_constraint_flag;
+uint8_t max_420chroma_constraint_flag;
+uint8_t max_monochrome_constraint_flag;
+uint8_t intra_constraint_flag;
+uint8_t one_picture_only_constraint_flag;
+uint8_t lower_bit_rate_constraint_flag;
+uint8_t max_14bit_constraint_flag;
+uint8_t inbld_flag;
+uint8_t level_idc;
 } PTLCommon;
 
 typedef struct PTL {
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 6/8] lavc/vaapi_hevc: add function to find exact va_profile for REXT

2019-12-29 Thread Linjie Fu
Add vaapi_parse_rext_profile and use profile constraint flags to
determine the exact va_profile for HEVC_REXT.

Add build object in Makefile for h265_profile_level dependency.

Signed-off-by: Linjie Fu 
---
 libavcodec/Makefile |  2 +-
 libavcodec/vaapi_hevc.c | 69 +
 libavcodec/vaapi_hevc.h | 24 +
 3 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vaapi_hevc.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1f35b4..7cb914d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -884,7 +884,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
-OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
+OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
 OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
 OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index ab48b73..0604e23 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -27,6 +27,8 @@
 #include "hevcdec.h"
 #include "hwaccel.h"
 #include "vaapi_decode.h"
+#include "vaapi_hevc.h"
+#include "h265_profile_level.h"
 
 typedef struct VAAPIDecodePictureHEVC {
 VAPictureParameterBufferHEVC pic_param;
@@ -494,6 +496,73 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 return 0;
 }
 
+static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel 
*h265_raw_ptl)
+{
+h265_raw_ptl->general_profile_space = general_ptl->profile_space;
+h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
+h265_raw_ptl->general_profile_idc   = general_ptl->profile_idc;
+
+memcpy(h265_raw_ptl->general_profile_compatibility_flag,
+  general_ptl->profile_compatibility_flag, 32 
* sizeof(int));
+
+h265_raw_ptl->general_progressive_source_flag  = 
general_ptl->progressive_source_flag;
+h265_raw_ptl->general_interlaced_source_flag   = 
general_ptl->interlaced_source_flag;
+h265_raw_ptl->general_non_packed_constraint_flag   = 
general_ptl->non_packed_constraint_flag;
+h265_raw_ptl->general_frame_only_constraint_flag   = 
general_ptl->frame_only_constraint_flag;
+h265_raw_ptl->general_max_12bit_constraint_flag= 
general_ptl->max_12bit_constraint_flag;
+h265_raw_ptl->general_max_10bit_constraint_flag= 
general_ptl->max_10bit_constraint_flag;
+h265_raw_ptl->general_max_8bit_constraint_flag = 
general_ptl->max_8bit_constraint_flag;
+h265_raw_ptl->general_max_422chroma_constraint_flag= 
general_ptl->max_422chroma_constraint_flag;
+h265_raw_ptl->general_max_420chroma_constraint_flag= 
general_ptl->max_420chroma_constraint_flag;
+h265_raw_ptl->general_max_monochrome_constraint_flag   = 
general_ptl->max_monochrome_constraint_flag;
+h265_raw_ptl->general_intra_constraint_flag= 
general_ptl->intra_constraint_flag;
+h265_raw_ptl->general_one_picture_only_constraint_flag = 
general_ptl->one_picture_only_constraint_flag;
+h265_raw_ptl->general_lower_bit_rate_constraint_flag   = 
general_ptl->lower_bit_rate_constraint_flag;
+h265_raw_ptl->general_max_14bit_constraint_flag= 
general_ptl->max_14bit_constraint_flag;
+h265_raw_ptl->general_inbld_flag   = 
general_ptl->inbld_flag;
+h265_raw_ptl->general_level_idc= 
general_ptl->level_idc;
+
+return 0;
+}
+
+/*
+ * Find exact va_profile for HEVC Range Extension
+ */
+VAProfile ff_vaapi_parse_rext_profile(AVCodecContext *avctx)
+{
+const HEVCContext *h = avctx->priv_data;
+const HEVCSPS *sps = h->ps.sps;
+const PTL *ptl = &(sps->ptl);
+const PTLCommon *general_ptl = &(ptl->general_ptl);
+const H265ProfileDescriptor *profile = NULL;
+
+H265RawProfileTierLevel *h265_raw_ptl = 
av_mallocz(sizeof(H265RawProfileTierLevel));
+/* convert PTLCommon to H265RawProfileTierLevel */
+ptl_convert(general_ptl, h265_raw_ptl);
+
+profile = ff_h265_get_profile(h265_raw_ptl);
+av_freep(&h265_raw_ptl);
+
+if (!profile)
+return VAProfileNone;
+
+#if VA_CHECK_VERSION(1, 2, 0)
+if (!strcmp(profile->name, "Main 4:2:2 10") ||
+!strcmp(profile->name, "Main 4:2:2 10 Intra"))
+return VAProfileHEVCMain422_10;
+else if (!strcmp(profile->name, "Main 4:4:4") ||
+ !strcmp(profile->name, "Main 4:4:4 Intra"))
+return VAProfileHEVCMain444;
+else if (!strcmp(profile->name, "Main 4:4:4 10") ||
+ !strcmp(profile->name, "Main 4:4:4 10 Intra"))
+return VAProfileHEVCMain444_10;
+#else
+av_log(avctx, AV_LOG_WARNING, "HEV

[FFmpeg-devel] [PATCH 4/8] lavc/vaapi_hevc: Add HEVC Rext parameter for VAPicture and VASlice

2019-12-29 Thread Linjie Fu
Add VAPictureParameterBufferHEVCRext and VASliceParameterBufferHEVCRext.

Pass Range Extension flags to support the decode for HEVC REXT.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_hevc.c | 79 +++--
 1 file changed, 76 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index c69d63d..ab48b73 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -30,7 +30,13 @@
 
 typedef struct VAAPIDecodePictureHEVC {
 VAPictureParameterBufferHEVC pic_param;
+#if VA_CHECK_VERSION(1, 2, 0)
+VAPictureParameterBufferHEVCRext pic_rext_param;
+#endif
 VASliceParameterBufferHEVC last_slice_param;
+#if VA_CHECK_VERSION(1, 2, 0)
+VASliceParameterBufferHEVCRext slice_rext_param;
+#endif
 const uint8_t *last_buffer;
 size_t last_size;
 
@@ -119,6 +125,11 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 const ScalingList *scaling_list = NULL;
 int err, i;
 
+int pic_param_size = sizeof(pic->pic_param);
+#if VA_CHECK_VERSION(1, 2, 0)
+pic_param_size += sizeof(pic->pic_rext_param);
+#endif
+
 pic->pic.output_surface = ff_vaapi_get_surface_id(h->ref->frame);
 
 pic->pic_param = (VAPictureParameterBufferHEVC) {
@@ -208,9 +219,38 @@ static int vaapi_hevc_start_frame(AVCodecContext  
*avctx,
 pic->pic_param.st_rps_bits = 0;
 }
 
+#if VA_CHECK_VERSION(1, 2, 0)
+if (sps->sps_range_extension_flag) {
+pic->pic_rext_param = (VAPictureParameterBufferHEVCRext) {
+.range_extension_pic_fields.bits  = {
+.transform_skip_rotation_enabled_flag   = 
sps->transform_skip_rotation_enabled_flag,
+.transform_skip_context_enabled_flag= 
sps->transform_skip_context_enabled_flag,
+.implicit_rdpcm_enabled_flag= 
sps->implicit_rdpcm_enabled_flag,
+.explicit_rdpcm_enabled_flag= 
sps->explicit_rdpcm_enabled_flag,
+.extended_precision_processing_flag = 
sps->extended_precision_processing_flag,
+.intra_smoothing_disabled_flag  = 
sps->intra_smoothing_disabled_flag,
+.high_precision_offsets_enabled_flag= 
sps->high_precision_offsets_enabled_flag,
+.persistent_rice_adaptation_enabled_flag= 
sps->persistent_rice_adaptation_enabled_flag,
+.cabac_bypass_alignment_enabled_flag= 
sps->cabac_bypass_alignment_enabled_flag,
+.cross_component_prediction_enabled_flag= 
pps->cross_component_prediction_enabled_flag,
+.chroma_qp_offset_list_enabled_flag = 
pps->chroma_qp_offset_list_enabled_flag,
+},
+.diff_cu_chroma_qp_offset_depth = 
pps->diff_cu_chroma_qp_offset_depth,
+.chroma_qp_offset_list_len_minus1   = 
pps->chroma_qp_offset_list_len_minus1,
+.log2_sao_offset_scale_luma = 
pps->log2_sao_offset_scale_luma,
+.log2_sao_offset_scale_chroma   = 
pps->log2_sao_offset_scale_chroma,
+.log2_max_transform_skip_block_size_minus2  = 
pps->log2_max_transform_skip_block_size - 2,
+};
+
+for (i = 0; i < 6; i++)
+pic->pic_rext_param.cb_qp_offset_list[i]= 
pps->cb_qp_offset_list[i];
+for (i = 0; i < 6; i++)
+pic->pic_rext_param.cr_qp_offset_list[i]= 
pps->cr_qp_offset_list[i];
+}
+#endif
 err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic,
 VAPictureParameterBufferType,
-&pic->pic_param, 
sizeof(pic->pic_param));
+&pic->pic_param, pic_param_size);
 if (err < 0)
 goto fail;
 
@@ -255,12 +295,19 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx)
 {
 const HEVCContext*h = avctx->priv_data;
 VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
+const HEVCSPS  *sps = h->ps.sps;
 int ret;
 
+int slice_param_size = sizeof(pic->last_slice_param);
+#if VA_CHECK_VERSION(1, 2, 0)
+if (sps->sps_range_extension_flag)
+slice_param_size += sizeof(pic->slice_rext_param);
+#endif
+
 if (pic->last_size) {
 pic->last_slice_param.LongSliceFlags.fields.LastSliceOfPic = 1;
 ret = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic,
-&pic->last_slice_param, 
sizeof(pic->last_slice_param),
+&pic->last_slice_param, 
slice_param_size,
 pic->last_buffer, 
pic->last_size);
 if (ret < 0)
 goto fail;
@@ -351,6 +398,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
uint32_t  

[FFmpeg-devel] [PATCH 3/8] lavu/hwcontext_vaapi: add vaapi_format_map support for Y210

2019-12-29 Thread Linjie Fu
VA_RT_FORMAT describes the desired sampling format for surface.

When creating surface, VA_RT_FORMAT will be used firstly to choose
the expected fourcc/media_format for the surface. And the fourcc
will be revised by the value of VASurfaceAttribPixelFormat.

Add vaapi_format_map support for new pixel_format Y210.
This is fundamental for both VA-API and QSV.

Signed-off-by: Linjie Fu 
---
 libavutil/hwcontext_vaapi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index cf11764..cfcfc46 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -116,6 +116,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = {
 #endif
 MAP(UYVY, YUV422,  UYVY422, 0),
 MAP(YUY2, YUV422,  YUYV422, 0),
+#ifdef VA_FOURCC_Y210
+MAP(Y210, YUV422_10,  Y210, 0),
+#endif
 MAP(411P, YUV411,  YUV411P, 0),
 MAP(422V, YUV422,  YUV440P, 0),
 MAP(444P, YUV444,  YUV444P, 0),
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/8] swscale: Add swscale input support for Y210

2019-12-29 Thread Linjie Fu
Add swscale input support for Y210, output support and fate
test could be added later if there is requirement for software
CSC to this packed format.

Signed-off-by: Linjie Fu 
---
 libswscale/input.c | 48 
 libswscale/utils.c |  2 ++
 2 files changed, 50 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 064f8da..f79b983 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -552,6 +552,42 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const 
uint8_t *unused0, con
 av_assert1(src1 == src2);
 }
 
+static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src,
+const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
+AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
+}
+}
+
+static void y210be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src,
+const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 2) >> 6);
+AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6) >> 6);
+}
+}
+
+static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0,
+   const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
+}
+
+static void y210be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0,
+   const uint8_t *unused1, int width, uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2 ,AV_RB16(src + i * 4) >> 6);
+}
+
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t 
*unused1, const uint8_t *unused2, int width,
uint32_t *unused)
 {
@@ -1154,6 +1190,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_P016BE:
 c->chrToYV12 = p016BEToUV_c;
 break;
+case AV_PIX_FMT_Y210LE:
+c->chrToYV12 = y210le_UV_c;
+break;
+case AV_PIX_FMT_Y210BE:
+c->chrToYV12 = y210be_UV_c;
+break;
 }
 if (c->chrSrcHSubSample) {
 switch (srcFormat) {
@@ -1586,6 +1628,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->lumToYV12 = grayf32ToY16_bswap_c;
 #endif
 break;
+case AV_PIX_FMT_Y210LE:
+c->lumToYV12 = y210le_Y_c;
+break;
+case AV_PIX_FMT_Y210BE:
+c->chrToYV12 = y210be_Y_c;
+break;
 }
 if (c->needAlpha) {
 if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 57c4fd2..bff498f 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -266,6 +266,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
 [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 },
 [AV_PIX_FMT_NV24]= { 1, 1 },
 [AV_PIX_FMT_NV42]= { 1, 1 },
+[AV_PIX_FMT_Y210BE]  = { 1, 0 },
+[AV_PIX_FMT_Y210LE]  = { 1, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/8] lavu/pix_fmt: add new pixel format y210

2019-12-29 Thread Linjie Fu
Add some packed 4:2:2 10-bit pixel formats for hardware decode support
in VAAPI and QSV.

Signed-off-by: Linjie Fu 
---
 libavutil/pixdesc.c  | 23 +++
 libavutil/pixfmt.h   |  5 +
 libavutil/version.h  |  2 +-
 tests/ref/fate/sws-pixdesc-query |  7 +++
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 05dd4a1..1e118ef 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -205,6 +205,29 @@ static const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 { 0, 4, 1, 0, 8, 3, 7, 2 },/* V */
 },
 },
+[AV_PIX_FMT_Y210LE] = {
+.name = "y210le",
+.nb_components = 3,
+.log2_chroma_w = 1,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
+{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
+{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
+},
+},
+[AV_PIX_FMT_Y210BE] = {
+.name = "y210be",
+.nb_components = 3,
+.log2_chroma_w = 1,
+.log2_chroma_h = 0,
+.comp = {
+{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */
+{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */
+{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */
+},
+.flags = AV_PIX_FMT_FLAG_BE,
+},
 [AV_PIX_FMT_RGB24] = {
 .name = "rgb24",
 .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 37ecebd..7ffa5a0 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -348,6 +348,9 @@ enum AVPixelFormat {
 AV_PIX_FMT_NV24,  ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 
plane for the UV components, which are interleaved (first byte U and the 
following byte V)
 AV_PIX_FMT_NV42,  ///< as above, but U and V bytes are swapped
 
+AV_PIX_FMT_Y210BE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-endian
+AV_PIX_FMT_Y210LE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
little-endian
+
 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 };
 
@@ -436,6 +439,8 @@ enum AVPixelFormat {
 #define AV_PIX_FMT_P010   AV_PIX_FMT_NE(P010BE,  P010LE)
 #define AV_PIX_FMT_P016   AV_PIX_FMT_NE(P016BE,  P016LE)
 
+#define AV_PIX_FMT_Y210   AV_PIX_FMT_NE(Y210BE,  Y210LE)
+
 /**
   * Chromaticity coordinates of the source primaries.
   * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
diff --git a/libavutil/version.h b/libavutil/version.h
index 4de0fa1..af8f614 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  37
+#define LIBAVUTIL_VERSION_MINOR  38
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index e234922..bc9a0d8 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -59,6 +59,8 @@ isNBPS:
   p010le
   xyz12be
   xyz12le
+  y210be
+  y210le
   yuv420p10be
   yuv420p10le
   yuv420p12be
@@ -140,6 +142,7 @@ isBE:
   rgb565be
   rgba64be
   xyz12be
+  y210be
   ya16be
   yuv420p10be
   yuv420p12be
@@ -188,6 +191,8 @@ isYUV:
   uyyvyy411
   xyz12be
   xyz12le
+  y210be
+  y210le
   ya16be
   ya16le
   ya8
@@ -686,6 +691,8 @@ Packed:
   uyyvyy411
   xyz12be
   xyz12le
+  y210be
+  y210le
   ya16be
   ya16le
   ya8
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 0/8] add 4:2:2 8-bit/10-bit VAAPI decode support

2019-12-29 Thread Linjie Fu
Linjie Fu (8):
  lavu/pix_fmt: add new pixel format y210
  swscale: Add swscale input support for Y210
  lavu/hwcontext_vaapi: add vaapi_format_map support for Y210
  lavc/vaapi_hevc: Add HEVC Rext parameter for VAPicture and VASlice
  lavc/hevc_ps: parse constraint flags for HEVC REXT
  lavc/vaapi_hevc: add function to find exact va_profile for REXT
  lavc/vaapi_decode: add profile_parser and format map support for HEVC
REXT
  lavc/hevcdec: add 4:2:2 8-bit/10-bit VAAPI decode support

 libavcodec/Makefile  |   2 +-
 libavcodec/hevc_ps.c |  44 ++--
 libavcodec/hevc_ps.h |  13 +++-
 libavcodec/hevcdec.c |   6 ++
 libavcodec/vaapi_decode.c|  77 
 libavcodec/vaapi_hevc.c  | 148 ++-
 libavcodec/vaapi_hevc.h  |  24 +++
 libavutil/hwcontext_vaapi.c  |   3 +
 libavutil/pixdesc.c  |  23 ++
 libavutil/pixfmt.h   |   5 ++
 libavutil/version.h  |   2 +-
 libswscale/input.c   |  48 +
 libswscale/utils.c   |   2 +
 tests/ref/fate/sws-pixdesc-query |   7 ++
 14 files changed, 364 insertions(+), 40 deletions(-)
 create mode 100644 libavcodec/vaapi_hevc.h

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 001/244] Add a new channel layout API

2019-12-29 Thread Anton Khirnov
Quoting Nicolas George (2019-12-07 21:25:53)
> Anton Khirnov (12019-12-06):
> > The new API is more extensible and allows for custom layouts.
> > More accurate information is exported, eg for decoders that do not
> > set a channel layout, lavc will not make one up for them.
> > 
> > Deprecate the old API working with just uint64_t bitmasks.
> > 
> > Expanded and completed by Vittorio Giovara .
> > Signed-off-by: Vittorio Giovara 
> > ---
> >  libavutil/channel_layout.c | 393 +--
> >  libavutil/channel_layout.h | 415 ++---
> >  libavutil/version.h|   3 +
> >  3 files changed, 719 insertions(+), 92 deletions(-)
> 
> Thanks for sending this here. I will make a few preliminary remarks
> below.
> 
> Before that, I want to mention I think the real trial for this API will
> be integration with libavfilter, especially the format negotiation and
> the user interface of the filters that allow fine control of channels.
> The negotiation, in particular, promises to be an interesting
> algorithmic problem. By "real trial", I mean that it is very possible
> that trying to implement that will make us realize some details need to
> be changed. I have these questions in mind while writing my comments.
> 
> Two important comments to consider, because they affect the structure of
> the API itself:
> 
> - about av_channel_layout_describe(), a general reflection on functions
>   that return strings;
> 
> - about getting a channel by name.
> 

> 
> > +int av_channel_layout_from_mask(AVChannelLayout *channel_layout,
> > +uint64_t mask)
> 
> I find that "channel_layout" all over the place makes the code bulky,
> harder to read. And tiring to write. We could decide on a standard
> shortening for it everywhere. For example chlayout.

In the API namespace (function names) or the parameter names? For the
latter, it can be changed at any time without problem and I don't really
care much. For the former, the header is called channel_layout and I'd
lean towards keeping that aligned with the namespace. Not a very strong
opinion though.

> > +enum AVChannel {
> > +AV_CHAN_FRONT_LEFT,
> > +AV_CHAN_FRONT_RIGHT,
> > +AV_CHAN_FRONT_CENTER,
> > +AV_CHAN_LOW_FREQUENCY,
> > +AV_CHAN_BACK_LEFT,
> > +AV_CHAN_BACK_RIGHT,
> > +AV_CHAN_FRONT_LEFT_OF_CENTER,
> > +AV_CHAN_FRONT_RIGHT_OF_CENTER,
> > +AV_CHAN_BACK_CENTER,
> > +AV_CHAN_SIDE_LEFT,
> > +AV_CHAN_SIDE_RIGHT,
> > +AV_CHAN_TOP_CENTER,
> > +AV_CHAN_TOP_FRONT_LEFT,
> > +AV_CHAN_TOP_FRONT_CENTER,
> > +AV_CHAN_TOP_FRONT_RIGHT,
> > +AV_CHAN_TOP_BACK_LEFT,
> > +AV_CHAN_TOP_BACK_CENTER,
> > +AV_CHAN_TOP_BACK_RIGHT,
> > +/** Stereo downmix. */
> > +AV_CHAN_STEREO_LEFT = 29,
> > +/** See above. */
> > +AV_CHAN_STEREO_RIGHT,
> > +AV_CHAN_WIDE_LEFT,
> > +AV_CHAN_WIDE_RIGHT,
> > +AV_CHAN_SURROUND_DIRECT_LEFT,
> > +AV_CHAN_SURROUND_DIRECT_RIGHT,
> > +AV_CHAN_LOW_FREQUENCY_2,
> > +
> > +/** Channel is empty can be safely skipped. */
> > +AV_CHAN_SILENCE = 64,
> > +};
> > +
> > +enum AVChannelOrder {
> > +/**
> > + * The native channel order, i.e. the channels are in the same order in
> > + * which they are defined in the AVChannel enum. This supports up to 63
> > + * different channels.
> > + */
> > +AV_CHANNEL_ORDER_NATIVE,
> > +/**
> > + * The channel order does not correspond to any other predefined order 
> > and
> > + * is stored as an explicit map. For example, this could be used to 
> > support
> 
> > + * layouts with 64 or more channels, or with channels that could be 
> > skipped.
> 
> [ Already said on 2019-10-30 ]
> "or with channels that could be skipped"? What does that mean. If a
> channel is skipped, it is not present, that can be expressed in the
> mask. Is this a mistake for "duplicated"?

Hmm, this was apparently added by Vittorio so I'm not sure, but would
assume it refers to AV_CHAN_SILENCE.

> 
> > + */
> > +AV_CHANNEL_ORDER_CUSTOM,
> > +/**
> > + * Only the channel count is specified, without any further information
> > + * about the channel order.
> > + */
> > +AV_CHANNEL_ORDER_UNSPEC,
> > +};
> > +
> > +
> >  /**
> >   * @defgroup channel_masks Audio channel masks
> >   *
> > @@ -46,36 +103,41 @@
> >   *
> >   * @{
> >   */
> > -#define AV_CH_FRONT_LEFT 0x0001
> > -#define AV_CH_FRONT_RIGHT0x0002
> > -#define AV_CH_FRONT_CENTER   0x0004
> > -#define AV_CH_LOW_FREQUENCY  0x0008
> > -#define AV_CH_BACK_LEFT  0x0010
> > -#define AV_CH_BACK_RIGHT 0x0020
> > -#define AV_CH_FRONT_LEFT_OF_CENTER   0x0040
> > -#define AV_CH_FRONT_RIGHT_OF_CENTER  0x0080
> > -#define AV_CH_BACK_CENTER0x0100
> > -#define AV_CH_SIDE_LEFT  0x0200
> > -#define AV_CH_SIDE_RIGHT 0x0400
> > -#

Re: [FFmpeg-devel] [PATCH 2/3] avfilter/vf_geq: use per-thread state for expression evaluation

2019-12-29 Thread Marton Balint



On Sun, 29 Dec 2019, Michael Niedermayer wrote:


On Sat, Dec 28, 2019 at 03:46:24PM +0100, Marton Balint wrote:

Fixes ticket #7528.

Signed-off-by: Marton Balint 
---
 libavfilter/vf_geq.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c
index 2905efae24..417b9d 100644
--- a/libavfilter/vf_geq.c
+++ b/libavfilter/vf_geq.c
@@ -377,6 +377,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_j
 int x, y;
 uint8_t *ptr;
 uint16_t *ptr16;
+AVExprState *state = av_expr_state_alloc();

 double values[VAR_VARS_NB];
 values[VAR_W] = geq->values[VAR_W];
@@ -386,6 +387,9 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_j
 values[VAR_SH] = geq->values[VAR_SH];
 values[VAR_T] = geq->values[VAR_T];

+if (!state)
+return AVERROR(ENOMEM);
+
 if (geq->bps == 8) {
 for (y = slice_start; y < slice_end; y++) {
 ptr = geq->dst + linesize * y;
@@ -393,7 +397,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_j

 for (x = 0; x < width; x++) {
 values[VAR_X] = x;
-ptr[x] = av_expr_eval(geq->e[plane], values, geq);
+ptr[x] = av_expr_eval2(geq->e[plane], state, values, geq);
 }
 ptr += linesize;
 }
@@ -404,10 +408,11 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_j
 values[VAR_Y] = y;
 for (x = 0; x < width; x++) {
 values[VAR_X] = x;
-ptr16[x] = av_expr_eval(geq->e[plane], values, geq);
+ptr16[x] = av_expr_eval2(geq->e[plane], state, values, geq);
 }
 }
 }
+av_expr_state_free(&state);


a filter which adds random noise would get its seed reset on each frame and
slice with this, unless iam missing something.

The random values produced by random should be uncorrelatec between frame n and 
m when n!=m


I guess I can make one AVExprState for each thread and keep them during 
the lifetime of the filter. That would resolve the frame correlation, but 
not the slice correlation.


I don't see too many simple ways to deal with this:

1) accept slice correlation and keep the AVExprStates across executions

2) document that the number of filter threads has to be 1 if 
uncorrelated random is required


3) initialize the state with the line number at the beginning of each 
line, which is kind of ugly but would make the filter invariant of the 
thread count used.


Do you have something else in mind? Do you prefer any of these?

Thanks,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avutil/eval: separate AVExpr state to a new AVExprState struct

2019-12-29 Thread Marton Balint



On Sun, 29 Dec 2019, Michael Niedermayer wrote:


On Sat, Dec 28, 2019 at 03:46:23PM +0100, Marton Balint wrote:

Also add helper functions to allocate and free such a struct, and make it
usable by providing a new av_eval_expr2 function for which you can specify a
custom AVExprState.

Signed-off-by: Marton Balint 
---
 doc/APIchanges  |  3 +++
 libavutil/eval.c| 31 +--
 libavutil/eval.h| 27 +++
 libavutil/version.h |  2 +-
 4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 3c24dc6fbc..e4ad364ed9 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21

 API changes, most recent first:

+2020-01-xx - xx - lavu 56.39.100 - eval.h
+  Add av_expr_eval2, av_expr_state_alloc, av_expr_state_free
+
 2019-12-27 - xx - lavu 56.38.100 - eval.h
   Add av_expr_count_func().

diff --git a/libavutil/eval.c b/libavutil/eval.c
index d527f6a9d0..86fb634fd8 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -173,7 +173,11 @@ struct AVExpr {
 double (*func2)(void *, double, double);
 } a;
 struct AVExpr *param[3];
-double *var;
+AVExprState *state;
+};
+
+struct AVExprState {
+double vars[VARS];
 };

 static double etime(double v)
@@ -333,13 +337,23 @@ static double eval_expr(Parser *p, AVExpr *e)

 static int parse_expr(AVExpr **e, Parser *p);

+AVExprState *av_expr_state_alloc(void)
+{
+return av_mallocz(sizeof(AVExprState));
+}
+
+void av_expr_state_free(AVExprState **ps)
+{
+av_freep(ps);
+}
+
 void av_expr_free(AVExpr *e)
 {
 if (!e) return;
 av_expr_free(e->param[0]);
 av_expr_free(e->param[1]);
 av_expr_free(e->param[2]);
-av_freep(&e->var);
+av_expr_state_free(&e->state);
 av_freep(&e);
 }

@@ -724,8 +738,8 @@ int av_expr_parse(AVExpr **expr, const char *s,
 ret = AVERROR(EINVAL);
 goto end;
 }
-e->var= av_mallocz(sizeof(double) *VARS);
-if (!e->var) {
+e->state = av_expr_state_alloc();
+if (!e->state) {
 ret = AVERROR(ENOMEM);
 goto end;
 }
@@ -763,16 +777,21 @@ int av_expr_count_func(AVExpr *e, unsigned *counter, int 
size, int arg)
 return expr_count(e, counter, size, ((int[]){e_const, e_func1, 
e_func2})[arg]);
 }

-double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
+double av_expr_eval2(AVExpr *e, AVExprState *s, const double *const_values, 
void *opaque)
 {
 Parser p = { 0 };
-p.var= e->var;
+p.var = s ? s->vars : e->state->vars;

 p.const_values = const_values;
 p.opaque = opaque;
 return eval_expr(&p, e);
 }

+double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
+{
+return av_expr_eval2(e, NULL, const_values, opaque);
+}
+
 int av_expr_parse_and_eval(double *d, const char *s,
const char * const *const_names, const double 
*const_values,
const char * const *func1_names, double (* const 
*funcs1)(void *, double),
diff --git a/libavutil/eval.h b/libavutil/eval.h
index 068c62cdab..8bd1592f6c 100644
--- a/libavutil/eval.h
+++ b/libavutil/eval.h
@@ -29,6 +29,7 @@
 #include "avutil.h"

 typedef struct AVExpr AVExpr;
+typedef struct AVExprState AVExprState;

 /**
  * Parse and evaluate an expression.
@@ -86,6 +87,22 @@ int av_expr_parse(AVExpr **expr, const char *s,
  */
 double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);

+/**
+ * Evaluate a previously parsed expression using a custom state.
+ *
+ * Some expressions can use stateful functions, like random(), st() and ld().
+ * With this function you can provide your own state to the evaluator instead
+ * of using the internal state of the AVExpr. This makes it possible to use the
+ * same AVExpr in multiple threads each with their own AVExprState avoiding
+ * unprotected concurrent access of the internal AVExpr state.
+ *
+ * @param s the state of the expression, if NULL, the internal state of AVExpr 
will be used
+ * @param const_values a zero terminated array of values for the identifiers 
from av_expr_parse() const_names
+ * @param opaque a pointer which will be passed to all functions from funcs1 
and funcs2
+ * @return the value of the expression
+ */
+double av_expr_eval2(AVExpr *e, AVExprState *s, const double *const_values, 
void *opaque);
+
 /**
  * Track the presence of variables and their number of occurrences in a parsed 
expression
  *
@@ -134,4 +151,14 @@ void av_expr_free(AVExpr *e);
  */
 double av_strtod(const char *numstr, char **tail);

+/**
+ * Allocate a new AVExprState struct
+ */
+AVExprState *av_expr_state_alloc(void);


maybe this should have a double [] argument so the caller can set the
initial variables (or pass NULL if not)


Maybe it is better to simply make the AVExprState struct public 
if setting/getting state manually is something we want to support. What do 
you think?


Thanks,
Marton
__

Re: [FFmpeg-devel] [PATCH 1/3] avutil/eval: separate AVExpr state to a new AVExprState struct

2019-12-29 Thread Michael Niedermayer
On Sat, Dec 28, 2019 at 03:46:23PM +0100, Marton Balint wrote:
> Also add helper functions to allocate and free such a struct, and make it
> usable by providing a new av_eval_expr2 function for which you can specify a
> custom AVExprState.
> 
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges  |  3 +++
>  libavutil/eval.c| 31 +--
>  libavutil/eval.h| 27 +++
>  libavutil/version.h |  2 +-
>  4 files changed, 56 insertions(+), 7 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 3c24dc6fbc..e4ad364ed9 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-01-xx - xx - lavu 56.39.100 - eval.h
> +  Add av_expr_eval2, av_expr_state_alloc, av_expr_state_free
> +
>  2019-12-27 - xx - lavu 56.38.100 - eval.h
>Add av_expr_count_func().
>  
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index d527f6a9d0..86fb634fd8 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -173,7 +173,11 @@ struct AVExpr {
>  double (*func2)(void *, double, double);
>  } a;
>  struct AVExpr *param[3];
> -double *var;
> +AVExprState *state;
> +};
> +
> +struct AVExprState {
> +double vars[VARS];
>  };
>  
>  static double etime(double v)
> @@ -333,13 +337,23 @@ static double eval_expr(Parser *p, AVExpr *e)
>  
>  static int parse_expr(AVExpr **e, Parser *p);
>  
> +AVExprState *av_expr_state_alloc(void)
> +{
> +return av_mallocz(sizeof(AVExprState));
> +}
> +
> +void av_expr_state_free(AVExprState **ps)
> +{
> +av_freep(ps);
> +}
> +
>  void av_expr_free(AVExpr *e)
>  {
>  if (!e) return;
>  av_expr_free(e->param[0]);
>  av_expr_free(e->param[1]);
>  av_expr_free(e->param[2]);
> -av_freep(&e->var);
> +av_expr_state_free(&e->state);
>  av_freep(&e);
>  }
>  
> @@ -724,8 +738,8 @@ int av_expr_parse(AVExpr **expr, const char *s,
>  ret = AVERROR(EINVAL);
>  goto end;
>  }
> -e->var= av_mallocz(sizeof(double) *VARS);
> -if (!e->var) {
> +e->state = av_expr_state_alloc();
> +if (!e->state) {
>  ret = AVERROR(ENOMEM);
>  goto end;
>  }
> @@ -763,16 +777,21 @@ int av_expr_count_func(AVExpr *e, unsigned *counter, 
> int size, int arg)
>  return expr_count(e, counter, size, ((int[]){e_const, e_func1, 
> e_func2})[arg]);
>  }
>  
> -double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
> +double av_expr_eval2(AVExpr *e, AVExprState *s, const double *const_values, 
> void *opaque)
>  {
>  Parser p = { 0 };
> -p.var= e->var;
> +p.var = s ? s->vars : e->state->vars;
>  
>  p.const_values = const_values;
>  p.opaque = opaque;
>  return eval_expr(&p, e);
>  }
>  
> +double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
> +{
> +return av_expr_eval2(e, NULL, const_values, opaque);
> +}
> +
>  int av_expr_parse_and_eval(double *d, const char *s,
> const char * const *const_names, const double 
> *const_values,
> const char * const *func1_names, double (* const 
> *funcs1)(void *, double),
> diff --git a/libavutil/eval.h b/libavutil/eval.h
> index 068c62cdab..8bd1592f6c 100644
> --- a/libavutil/eval.h
> +++ b/libavutil/eval.h
> @@ -29,6 +29,7 @@
>  #include "avutil.h"
>  
>  typedef struct AVExpr AVExpr;
> +typedef struct AVExprState AVExprState;
>  
>  /**
>   * Parse and evaluate an expression.
> @@ -86,6 +87,22 @@ int av_expr_parse(AVExpr **expr, const char *s,
>   */
>  double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
>  
> +/**
> + * Evaluate a previously parsed expression using a custom state.
> + *
> + * Some expressions can use stateful functions, like random(), st() and ld().
> + * With this function you can provide your own state to the evaluator instead
> + * of using the internal state of the AVExpr. This makes it possible to use 
> the
> + * same AVExpr in multiple threads each with their own AVExprState avoiding
> + * unprotected concurrent access of the internal AVExpr state.
> + *
> + * @param s the state of the expression, if NULL, the internal state of 
> AVExpr will be used
> + * @param const_values a zero terminated array of values for the identifiers 
> from av_expr_parse() const_names
> + * @param opaque a pointer which will be passed to all functions from funcs1 
> and funcs2
> + * @return the value of the expression
> + */
> +double av_expr_eval2(AVExpr *e, AVExprState *s, const double *const_values, 
> void *opaque);
> +
>  /**
>   * Track the presence of variables and their number of occurrences in a 
> parsed expression
>   *
> @@ -134,4 +151,14 @@ void av_expr_free(AVExpr *e);
>   */
>  double av_strtod(const char *numstr, char **tail);
>  
> +/**
> + * Allocate a new AVExprState struct
> + */
> +AVExprState *av_expr_state_alloc(void);

maybe thi

Re: [FFmpeg-devel] [PATCH 2/3] avfilter/vf_geq: use per-thread state for expression evaluation

2019-12-29 Thread Michael Niedermayer
On Sat, Dec 28, 2019 at 03:46:24PM +0100, Marton Balint wrote:
> Fixes ticket #7528.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavfilter/vf_geq.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c
> index 2905efae24..417b9d 100644
> --- a/libavfilter/vf_geq.c
> +++ b/libavfilter/vf_geq.c
> @@ -377,6 +377,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
> *arg, int jobnr, int nb_j
>  int x, y;
>  uint8_t *ptr;
>  uint16_t *ptr16;
> +AVExprState *state = av_expr_state_alloc();
>  
>  double values[VAR_VARS_NB];
>  values[VAR_W] = geq->values[VAR_W];
> @@ -386,6 +387,9 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
> *arg, int jobnr, int nb_j
>  values[VAR_SH] = geq->values[VAR_SH];
>  values[VAR_T] = geq->values[VAR_T];
>  
> +if (!state)
> +return AVERROR(ENOMEM);
> +
>  if (geq->bps == 8) {
>  for (y = slice_start; y < slice_end; y++) {
>  ptr = geq->dst + linesize * y;
> @@ -393,7 +397,7 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
> *arg, int jobnr, int nb_j
>  
>  for (x = 0; x < width; x++) {
>  values[VAR_X] = x;
> -ptr[x] = av_expr_eval(geq->e[plane], values, geq);
> +ptr[x] = av_expr_eval2(geq->e[plane], state, values, geq);
>  }
>  ptr += linesize;
>  }
> @@ -404,10 +408,11 @@ static int slice_geq_filter(AVFilterContext *ctx, void 
> *arg, int jobnr, int nb_j
>  values[VAR_Y] = y;
>  for (x = 0; x < width; x++) {
>  values[VAR_X] = x;
> -ptr16[x] = av_expr_eval(geq->e[plane], values, geq);
> +ptr16[x] = av_expr_eval2(geq->e[plane], state, values, geq);
>  }
>  }
>  }
> +av_expr_state_free(&state);

a filter which adds random noise would get its seed reset on each frame and
slice with this, unless iam missing something.

The random values produced by random should be uncorrelatec between frame n and 
m when n!=m

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_geq: fix multiple assignments of ptr in slice_geq_filter

2019-12-29 Thread Michael Niedermayer
On Sat, Dec 28, 2019 at 03:46:25PM +0100, Marton Balint wrote:
> Fixes Coverity CID 1427183.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavfilter/vf_geq.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/ftp: Exit with error on ftp_open if file does not exist

2019-12-29 Thread Michael Niedermayer
On Sat, Dec 28, 2019 at 04:11:54PM +0300, Fotyev V. wrote:
> See attached
> 
> On 2019-12-28 17:17, Michael Niedermayer wrote:
> >On Sat, Dec 28, 2019 at 01:52:04PM +0300, Fotyev V. wrote:
> >>Add a check for code 550 when requesting file size
> >>---
> >>  libavformat/ftp.c | 11 +--
> >>  1 file changed, 9 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/libavformat/ftp.c b/libavformat/ftp.c
> >>index 97ad80d..64a5250 100644
> >>--- a/libavformat/ftp.c
> >>+++ b/libavformat/ftp.c
> >>@@ -391,13 +391,17 @@ static int ftp_file_size(FTPContext *s)
> >>  char command[CONTROL_BUFFER_SIZE];
> >>  char *res = NULL;
> >>  static const int size_codes[] = {213, 0};
> >>+    int resp_code;
> >>
> >>  snprintf(command, sizeof(command), "SIZE %s\r\n", s->path);
> >>-    if (ftp_send_command(s, command, size_codes, &res) == 213 && res &&
> >>strlen(res) > 4) {
> >>+    resp_code = ftp_send_command(s, command, size_codes, &res);
> >patch is corrupted by newlines
> >
> >[...]
> >
> >thx
> >
> >___
> >ffmpeg-devel mailing list
> >ffmpeg-devel@ffmpeg.org
> >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >To unsubscribe, visit link above, or email
> >ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

>  ftp.c |   11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> c28f647f77a69ca7d24024277a89e52160dc642d  
> 0001-libavformat-ftp-Exit-with-error-on-ftp_open-if-file-.patch
> From 46108143e535962dd2d65398e7f794cbeb3e9cd7 Mon Sep 17 00:00:00 2001

> From: ftk 

You may want to put your name in the author field, as this would be what ends
in git as author

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 001/244] Add a new channel layout API

2019-12-29 Thread Anton Khirnov
Quoting Nicolas George (2019-12-17 20:20:00)
> Hi.
> 
> Anton Khirnov (12019-12-10):
> > I disagree. I think I have a fair amount of skill and experience as a C
> > developer, but I still get hit by those issues frequently. It's extra
> > trouble for only theoretical gain.
> 
> I concede this to you, except for the last sentence: I do not agree that
> the gain is only theoretical. We only need to look at the number of
> recent commits fixing possible integer overflows. Signed arithmetic is
> tricky, possibly as tricky as the traps of mixing signed and unsigned.
> The reason we are seeing this only now is because compilers have only
> recently started to optimize these undefined behaviors aggressively. And
> we have only recently started to care. But these are real traps that do
> not happen with unsigned.

Maybe I missed something, but I am not aware of the UB-ness of signed
overflow being a practical problem. Typically, your computation will
return a meaningless result. You would get a similarly meaningless
result from the analogous perfectly well-defined unsigned computation.

to be clear: I am not objecting against fixing UB, but clarifying my
'theoretical gain' comment above.

> 
> I would advise everybody to adopt the policy of always using unsigned
> unless there is a good reason to use signed, instead of the default now
> which is the opposite.
> 
> Of course, for your own code and everybody else, I would not block the
> patch if my advice is not followed. But this is public API, it should be
> clean, so I will insist a little more.

I would agree to that only if it was done consistently across the entire
API. Since the channel count tends to be used in expressions with other
values which are signed (e.g. sample rate). Which means that the users
will have to mix signed and unsigned, making things harder for them.

> 
> Using the logical type has practical benefits. One is that it guarantees
> to the API users that negative values cannot happen, need not to be
> tested. With an unsigned, the value can be injected in size and pointer
> arithmetic directly. With a signed, the API user need either to add an
> useless test or to blindly trust the library. Blindly trusting a piece
> of code should always put people ill at ease.

The guarantee that it cannot be negative in valid cases is already
present, there is no need for users to test that explicitly. The only
conceivable case where it will be negative is a bug in the code
populating the channel layout. Making the value unsigned would not make
such bugs go away, it would only make the value absurdly large instead
of negative.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx265: add a qp option and apply the relevant global AVCodecContext settings to the encoder context

2019-12-29 Thread Michael Niedermayer
On Sun, Dec 29, 2019 at 10:17:48AM -0300, James Almer wrote:
> On 12/29/2019 8:53 AM, Michael Niedermayer wrote:
> > On Sat, Dec 28, 2019 at 08:55:13PM -0300, James Almer wrote:
> >> Signed-off-by: James Almer 
> >> ---
> >>  doc/encoders.texi| 22 ++
> >>  libavcodec/libx265.c | 28 
> >>  2 files changed, 50 insertions(+)
> > 
> > breaks build here, i susupect missing libx265 version check ...
> > 
> > CC  libavcodec/libx265.o
> > libavcodec/libx265.c: In function ‘libx265_encode_init’:
> > libavcodec/libx265.c:237:24: error: ‘struct ’ has no member 
> > named ‘qpMin’
> >  ctx->params->rc.qpMin = avctx->qmin;
> > ^
> > libavcodec/libx265.c:239:24: error: ‘struct ’ has no member 
> > named ‘qpMax’
> >  ctx->params->rc.qpMax = avctx->qmax;
> > ^
> > libavcodec/libx265.c:241:20: error: request for member ‘rc’ in something 
> > not a structure or union
> >  ctx->params.rc.qpStep = avctx->max_qdiff;
> > ^
> 
> Is this a distro provided libx265? The commit that added these fields is
> three and a half years old by now.

no, it just wasnt updated since a long time.

Thanks


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] HEVC: Export motion vectors to frame side data.

2019-12-29 Thread Asaf Kave
---
 libavcodec/hevc_refs.c |  15 
 libavcodec/hevcdec.c   | 173 -
 libavcodec/hevcdec.h   |  13 
 3 files changed, 200 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 7870a72fd6..20f028fa73 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -42,6 +42,9 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, 
int flags)
 av_buffer_unref(&frame->tab_mvf_buf);
 frame->tab_mvf = NULL;
 
+av_buffer_unref(&frame->cuh_buf);
+frame->cuh = NULL;
+
 av_buffer_unref(&frame->rpl_buf);
 av_buffer_unref(&frame->rpl_tab_buf);
 frame->rpl_tab= NULL;
@@ -101,11 +104,17 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 goto fail;
 frame->tab_mvf = (MvField *)frame->tab_mvf_buf->data;
 
+frame->cuh_buf = av_buffer_pool_get(s->cuh_pool);
+if (!frame->cuh_buf)
+goto fail;
+frame->cuh = (CodingUnitHelper *)frame->cuh_buf->data;
+
 frame->rpl_tab_buf = av_buffer_pool_get(s->rpl_tab_pool);
 if (!frame->rpl_tab_buf)
 goto fail;
 frame->rpl_tab   = (RefPicListTab **)frame->rpl_tab_buf->data;
 frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
+frame->cu_count = 0;
 for (j = 0; j < frame->ctb_count; j++)
 frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
 
@@ -161,6 +170,10 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, 
int poc)
 else
 ref->flags = HEVC_FRAME_FLAG_SHORT_REF;
 
+if (s->avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) {
+ref->flags |= HEVC_FRAME_FLAG_MV;
+}
+
 ref->poc  = poc;
 ref->sequence = s->seq_decode;
 ref->frame->crop_left   = s->ps.sps->output_window.left_offset;
@@ -216,6 +229,8 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int 
flush)
 if (ret < 0)
 return ret;
 
+s->output_frame_poc = frame->poc;
+
 av_log(s->avctx, AV_LOG_DEBUG,
"Output frame with POC %d.\n", frame->poc);
 return 1;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 19b0cd815d..aedc559283 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -32,6 +32,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/motion_vector.h"
 
 #include "bswapdsp.h"
 #include "bytestream.h"
@@ -80,6 +81,7 @@ static void pic_arrays_free(HEVCContext *s)
 av_freep(&s->sh.offset);
 
 av_buffer_pool_uninit(&s->tab_mvf_pool);
+av_buffer_pool_uninit(&s->cuh_pool);
 av_buffer_pool_uninit(&s->rpl_tab_pool);
 }
 
@@ -128,9 +130,11 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS 
*sps)
 
 s->tab_mvf_pool = av_buffer_pool_init(min_pu_size * sizeof(MvField),
   av_buffer_allocz);
+s->cuh_pool = av_buffer_pool_init(min_pu_size * sizeof(CodingUnitHelper),
+  av_buffer_allocz);
 s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
   av_buffer_allocz);
-if (!s->tab_mvf_pool || !s->rpl_tab_pool)
+if (!s->tab_mvf_pool || !s->rpl_tab_pool || !s->cuh_pool)
 goto fail;
 
 return 0;
@@ -1806,6 +1810,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, 
int y0,
 int min_pu_width = s->ps.sps->min_pu_width;
 
 MvField *tab_mvf = s->ref->tab_mvf;
+CodingUnitHelper *cuh = s->ref->cuh;
 RefPicList  *refPicList = s->ref->refPicList;
 HEVCFrame *ref0 = NULL, *ref1 = NULL;
 uint8_t *dst0 = POS(0, x0, y0);
@@ -1843,6 +1848,9 @@ static void hls_prediction_unit(HEVCContext *s, int x0, 
int y0,
 for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++)
 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
 
+struct CodingUnitHelper cuh_ = {lc->cu, log2_cb_size };
+cuh[s->ref->cu_count++] = cuh_;
+
 if (current_mv.pred_flag & PF_L0) {
 ref0 = refPicList[0].ref[current_mv.ref_idx[0]];
 if (!ref0)
@@ -3192,6 +3200,160 @@ static int hevc_decode_extradata(HEVCContext *s, 
uint8_t *buf, int length, int f
 return 0;
 }
 
+static int set_mv(AVMotionVector *mv, int puW, int puH,
+  int dst_x, int dst_y,
+  int motion_x, int motion_y, int motion_scale,
+  int direction)
+{
+mv->w = puW;
+mv->h = puH;
+mv->motion_x = motion_x;
+mv->motion_y = motion_y;
+mv->motion_scale = motion_scale;
+mv->dst_x = dst_x;
+mv->dst_y = dst_y;
+mv->src_x = dst_x + motion_x / motion_scale;
+mv->src_y = dst_y + motion_y / motion_scale;
+mv->source = direction ? 1 : -1;
+mv->flags = 0;
+
+return 1;
+}
+
+static int add_mv(HEVCContext *s, AVMotionVector *mvs, MvField current_mv, int 
x0, int

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx265: add a qp option and apply the relevant global AVCodecContext settings to the encoder context

2019-12-29 Thread James Almer
On 12/29/2019 8:53 AM, Michael Niedermayer wrote:
> On Sat, Dec 28, 2019 at 08:55:13PM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  doc/encoders.texi| 22 ++
>>  libavcodec/libx265.c | 28 
>>  2 files changed, 50 insertions(+)
> 
> breaks build here, i susupect missing libx265 version check ...
> 
> CClibavcodec/libx265.o
> libavcodec/libx265.c: In function ‘libx265_encode_init’:
> libavcodec/libx265.c:237:24: error: ‘struct ’ has no member named 
> ‘qpMin’
>  ctx->params->rc.qpMin = avctx->qmin;
> ^
> libavcodec/libx265.c:239:24: error: ‘struct ’ has no member named 
> ‘qpMax’
>  ctx->params->rc.qpMax = avctx->qmax;
> ^
> libavcodec/libx265.c:241:20: error: request for member ‘rc’ in something not 
> a structure or union
>  ctx->params.rc.qpStep = avctx->max_qdiff;
> ^

Is this a distro provided libx265? The commit that added these fields is
three and a half years old by now.

I'm inclined to bump the required library version from 68 to 89, to
reduce clutter from pre-processor checks. But i want to hear Derek's
opinion first since he's the maintainer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/libx265: add a qp option and apply the relevant global AVCodecContext settings to the encoder context

2019-12-29 Thread Michael Niedermayer
On Sat, Dec 28, 2019 at 08:55:13PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  doc/encoders.texi| 22 ++
>  libavcodec/libx265.c | 28 
>  2 files changed, 50 insertions(+)

breaks build here, i susupect missing libx265 version check ...

CC  libavcodec/libx265.o
libavcodec/libx265.c: In function ‘libx265_encode_init’:
libavcodec/libx265.c:237:24: error: ‘struct ’ has no member named 
‘qpMin’
 ctx->params->rc.qpMin = avctx->qmin;
^
libavcodec/libx265.c:239:24: error: ‘struct ’ has no member named 
‘qpMax’
 ctx->params->rc.qpMax = avctx->qmax;
^
libavcodec/libx265.c:241:20: error: request for member ‘rc’ in something not a 
structure or union
 ctx->params.rc.qpStep = avctx->max_qdiff;
^
make: *** [libavcodec/libx265.o] Error 1



[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-29 Thread Paul B Mahol
Gonna apply soon with local minor changes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/2] cmdutils: add show_help_protocol for get protocol options

2019-12-29 Thread Liu Steven


> 在 2019年12月29日,下午4:12,Michael Niedermayer  写道:
> 
> On Sun, Dec 29, 2019 at 01:14:47PM +0800, Liu Steven wrote:
>> 
>> 
>>> 在 2019年11月28日,上午5:24,Michael Niedermayer  写道:
>>> 
>>> On Wed, Nov 27, 2019 at 01:57:02PM +0800, Steven Liu wrote:
 Signed-off-by: Steven Liu 
 ---
 fftools/cmdutils.c   | 14 ++
 fftools/ffmpeg_opt.c |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
>>> 
>>> i think the patchset looks good, but maybe wait a bit before applying
>>> as it involves public API and others may have comments too
>> ping?
> 
> seems not to apply automatically anymore
Will push them manual if there have no objections :D
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Freedom in capitalist society always remains about the same as it was in
> ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Steven
Thanks



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vp9: support hardware decode with resolution changing on inter frame

2019-12-29 Thread Hendrik Leppkes
On Sun, Dec 29, 2019 at 4:21 AM Fu, Linjie  wrote:
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Hendrik Leppkes
> > Sent: Friday, December 27, 2019 18:22
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vp9: support hardware
> > decode with resolution changing on inter frame
> >
> > On Fri, Dec 27, 2019 at 9:59 AM Linjie Fu  wrote:
> > >
> > > VP9 decoder should be able to handle resolution changing on inter
> > > frame without re-initialization. For hardware decoder, re-allocate 
> > > hardware
> > > frame surface.
> > >
> > > Fix #8068 for VA-API.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > Request for comments.
> > > This works for VA-API, however for dxva2 it didn't cover all cases.
> > >
> > > Another idea is to register a call-back function in AVHWAccel (such as
> > > ff_vp9_dxva2_hwaccel) to handle surface re-allocation according to
> > > the hardware decoder.
> > >
> > >  libavcodec/vp9.c | 18 ++
> > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> > > index 0fd15ef..a7b4c6a 100644
> > > --- a/libavcodec/vp9.c
> > > +++ b/libavcodec/vp9.c
> > > @@ -34,6 +34,7 @@
> > >  #include "vp9dec.h"
> > >  #include "libavutil/avassert.h"
> > >  #include "libavutil/pixdesc.h"
> > > +#include "decode.h"
> > >
> > >  #define VP9_SYNCCODE 0x498342
> > >
> > > @@ -220,11 +221,20 @@ static int update_size(AVCodecContext *avctx,
> > int w, int h)
> > >  *fmtp++ = s->pix_fmt;
> > >  *fmtp = AV_PIX_FMT_NONE;
> > >
> > > -ret = ff_thread_get_format(avctx, pix_fmts);
> > > -if (ret < 0)
> > > -return ret;
> > > +if (avctx->internal->hwaccel_priv_data && s->pix_fmt == s->gf_fmt
> > && (s->w != w || s->h != h)) {
> > > +const AVHWDeviceContext *device_ctx =
> > > +(AVHWDeviceContext*)avctx->hw_device_ctx->data;
> > > +ret = ff_decode_get_hw_frames_ctx(avctx, device_ctx->type);
> > > +if (ret < 0)
> > > +return ret;
> > > +} else {
> > > +ret = ff_thread_get_format(avctx, pix_fmts);
> > > +if (ret < 0)
> > > +return ret;
> > > +
> > > +avctx->pix_fmt = ret;
> > > +}
> > >
> > > -avctx->pix_fmt = ret;
> > >  s->gf_fmt  = s->pix_fmt;
> > >  s->w = w;
> > >  s->h = h;
> >
> > hwaccels are not guaranteed to have a hw_frames ctx, and avcodec is
> > not guaranteed to manage the surfaces it decodes to at all (they could
> > be shared with eg. a renderer and allocated externally), as such a
>
> Thanks, and would you please help to share more information about how to 
> reproduce?
> 1. no hw_frame_ctx, only hw_device_ctx
> 2. surfaces shared with a rendered and allocated externally
> (externally provided hw_frames_ctx)
>
> I'd like to step into these and try to find a proper/general solution.
>
> > decoder really can't reliably re-allocate this itself - thats what the
> > get_format callback is for, which informs the user that new dimensions
> > are required.
>
> It's vp9 (and AV1) specific, so I didn't intend to modify in the general 
> path(ff_get_format) firstly.
>
> Instead of fixing in codec(update_size() in vp9.c),  if we are going to 
> handle this in user
> (ff_get_format() in decode.c) to manage the surface, IMHO a modification in 
> API may be needed
> to register a reinit function in AVHWAccel.
> See:
> https://github.com/intel-media-ci/ffmpeg/pull/153
>

If a new callback is needed, then it would need to be a public
user-facing callback, not in AVHWAccel (or maybe in addition to),
otherwise you don't really handle the problem i'm talking about -
namely that avcodec has no control over the hardware frames at all in
some circumstances.

But why can't get_format be used for this? Its already in use for
re-sizing buffers today.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/2] cmdutils: add show_help_protocol for get protocol options

2019-12-29 Thread Michael Niedermayer
On Sun, Dec 29, 2019 at 01:14:47PM +0800, Liu Steven wrote:
> 
> 
> > 在 2019年11月28日,上午5:24,Michael Niedermayer  写道:
> > 
> > On Wed, Nov 27, 2019 at 01:57:02PM +0800, Steven Liu wrote:
> >> Signed-off-by: Steven Liu 
> >> ---
> >> fftools/cmdutils.c   | 14 ++
> >> fftools/ffmpeg_opt.c |  2 +-
> >> 2 files changed, 15 insertions(+), 1 deletion(-)
> > 
> > i think the patchset looks good, but maybe wait a bit before applying
> > as it involves public API and others may have comments too
> ping?

seems not to apply automatically anymore

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".