[FFmpeg-devel] [PATCH v5] avcodec: add av1 VAAPI decoder

2020-10-29 Thread Fei Wang
Example cmdline:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -v verbose \
-c:v av1 -i input.ivf -pix_fmt yuv420p -vsync passthrough -f md5 \
-y out.md5

Signed-off-by: Fei Wang 
---
change:
1.rebase v4 to master.

 Changelog |   1 +
 configure |   3 +
 libavcodec/Makefile   |   1 +
 libavcodec/av1dec.c   |  18 ++-
 libavcodec/hwaccels.h |   1 +
 libavcodec/vaapi_av1.c| 274 ++
 libavcodec/vaapi_decode.c |   6 +
 libavcodec/version.h  |   2 +-
 8 files changed, 304 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/vaapi_av1.c

diff --git a/Changelog b/Changelog
index 27135f38fa..3fdcafc355 100644
--- a/Changelog
+++ b/Changelog
@@ -39,6 +39,7 @@ version :
 - afreqshift and aphaseshift filters
 - High Voltage Software ADPCM encoder
 - LEGO Racers ALP (.tun & .pcm) muxer
+- AV1 VAAPI decoder
 
 
 version 4.3:
diff --git a/configure b/configure
index 8e451ca641..8a9e9b3cd7 100755
--- a/configure
+++ b/configure
@@ -2918,6 +2918,8 @@ videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
 xvmc_deps="X11_extensions_XvMClib_h"
 
+av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx"
+av1_vaapi_hwaccel_select="av1_decoder"
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_videotoolbox_hwaccel_deps="videotoolbox"
@@ -6675,6 +6677,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" "VADecPictureParameterBufferAV1" bit_depth_idx
 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"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 93a7eccc85..9d75dd68af 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -912,6 +912,7 @@ OBJS-$(CONFIG_VAAPI)  += vaapi_decode.o
 OBJS-$(CONFIG_VIDEOTOOLBOX)   += videotoolbox.o
 OBJS-$(CONFIG_VDPAU)  += vdpau.o
 
+OBJS-$(CONFIG_AV1_VAAPI_HWACCEL)  += vaapi_av1.o
 OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
 OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
 OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)   += dxva2_h264.o
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 9566f7aa7d..56712279aa 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -215,7 +215,7 @@ static int get_pixel_format(AVCodecContext *avctx)
 uint8_t bit_depth;
 int ret;
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
-#define HWACCEL_MAX (0)
+#define HWACCEL_MAX (CONFIG_AV1_VAAPI_HWACCEL)
 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 
 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
@@ -276,6 +276,19 @@ static int get_pixel_format(AVCodecContext *avctx)
 return -1;
 s->pix_fmt = pix_fmt;
 
+switch (s->pix_fmt) {
+case AV_PIX_FMT_YUV420P:
+#if CONFIG_AV1_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+case AV_PIX_FMT_YUV420P10:
+#if CONFIG_AV1_VAAPI_HWACCEL
+*fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+break;
+}
+
 *fmtp++ = s->pix_fmt;
 *fmtp = AV_PIX_FMT_NONE;
 
@@ -840,6 +853,9 @@ AVCodec ff_av1_decoder = {
 .flush = av1_decode_flush,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
 .hw_configs= (const AVCodecHWConfigInternal * []) {
+#if CONFIG_AV1_VAAPI_HWACCEL
+HWACCEL_VAAPI(av1),
+#endif
 NULL
 },
 };
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 6109c89bd6..18e9079c55 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 
+extern const AVHWAccel ff_av1_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_videotoolbox_hwaccel;
 extern const AVHWAccel ff_h264_d3d11va_hwaccel;
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c
new file mode 100644
index 00..2b1f49095b
--- /dev/null
+++ b/libavcodec/vaapi_av1.c
@@ -0,0 +1,274 @@
+/*
+ * AV1 HW decode acceleration through VA API
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *

Re: [FFmpeg-devel] [PATCH v4] avcodec: add av1 VAAPI decoder

2020-10-29 Thread Wang, Fei W

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Mark
> Thompson
> Sent: Thursday, October 29, 2020 5:18 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v4] avcodec: add av1 VAAPI decoder
> 
> On 02/10/2020 15:28, Fei Wang wrote:
> > Example cmdline:
> > ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -v verbose \
> > -c:v av1 -i input.ivf -pix_fmt yuv420p -vsync passthrough -f md5 \
> > -y out.md5
> >
> > Signed-off-by: Fei Wang 
> > ---
> >   Changelog |   1 +
> >   configure |   3 +
> >   libavcodec/Makefile   |   1 +
> >   libavcodec/av1dec.c   |  18 ++-
> >   libavcodec/hwaccels.h |   1 +
> >   libavcodec/vaapi_av1.c| 274
> ++
> >   libavcodec/vaapi_decode.c |   6 +
> >   libavcodec/version.h  |   2 +-
> >   8 files changed, 304 insertions(+), 2 deletions(-)
> >   create mode 100644 libavcodec/vaapi_av1.c
> 
> I think this is ok, but I can't test it myself.  Can you rebase against the 
> recent
> changes in av1dec and retest that it is still good?

Rebased with patch v5, and test looks good to me. Thanks.

> 
> A kindof-related question: how does the selection of reference frames for skip
> modes work?  VAAPI isn't being given the SkipModeFrame array, and it doesn't
> appear to have the order hints to be able to work out which frames it should 
> be
> using itself.

Actually in media-driver, it maintains a reference frames parameter list which 
is used
to record and update reference frame's info. And refHint can be got in this 
list, and
with current frame's OrderHint (set by order_hint in 
VADecPictureParameterBufferAV1),
then can work out SkipModeFrame array following spec.

The detail implementation in media-driver is:
https://github.com/intel/media-driver/blob/d934d6c48644227ab066d013a105335ad25ce2bc/media_driver/media_driver_next/agnostic/common/codec/hal/dec/av1/packet/decode_av1_picture_packet.cpp#L1470
 

> 
> Thanks,
> 
> - 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] avformat/mpegtsenc: first timestamp check needed

2020-10-29 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegtsenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 383181d..9e105b7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -232,7 +232,7 @@ typedef struct MpegTSWriteStream {
 int cc;
 int discontinuity;
 int payload_size;
-int first_pts_checked; ///< first pts check needed
+int first_timestamp_checked; ///< first pts/dts check needed
 int prev_payload_key;
 int64_t payload_pts;
 int64_t payload_dts;
@@ -1699,11 +1699,11 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 dts += delay;
 }
 
-if (!ts_st->first_pts_checked && pts == AV_NOPTS_VALUE) {
-av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
+if (!ts_st->first_timestamp_checked && (pts == AV_NOPTS_VALUE || dts == 
AV_NOPTS_VALUE)) {
+av_log(s, AV_LOG_ERROR, "first pts or dts value must be set\n");
 return AVERROR_INVALIDDATA;
 }
-ts_st->first_pts_checked = 1;
+ts_st->first_timestamp_checked = 1;
 
 if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
 const uint8_t *p = buf, *buf_end = p + size;
-- 
1.8.3.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 2/3] avfilter/vf_unsharp: add more pixel format support

2020-10-29 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_unsharp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 416bf1c..e9b6c90 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -201,6 +201,10 @@ static int query_formats(AVFilterContext *ctx)
 static const enum AVPixelFormat pix_fmts[] = {
 AV_PIX_FMT_YUV420P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV444P,  
AV_PIX_FMT_YUV410P,
 AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV440P,  AV_PIX_FMT_YUVJ420P, 
AV_PIX_FMT_YUVJ422P,
+AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
+AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, 
AV_PIX_FMT_YUV440P10,
+AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, 
AV_PIX_FMT_YUV440P12,
+AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
 AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_NONE
 };
 
-- 
1.8.3.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 3/3] fate/filter-video: add 10bit test for unsharp filter

2020-10-29 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 tests/fate/filter-video.mak | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 639f957..f295df4 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -410,6 +410,9 @@ fate-filter-untile: CMD = framecrc -lavfi 
testsrc2=d=1:r=2,untile=2x2
 FATE_FILTER_VSYNTH-$(CONFIG_UNSHARP_FILTER) += fate-filter-unsharp
 fate-filter-unsharp: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf 
unsharp=11:11:-1.5:11:11:-1.5
 
+FATE_FILTER_VSYNTH-$(CONFIG_UNSHARP_FILTER) += fate-filter-unsharp-yuv420p10
+fate-filter-unsharp-yuv420p10: CMD = framecrc -auto_conversion_filters -c:v 
pgmyuv -i $(SRC) -vf format=pix_fmts=yuv420p10,unsharp=11:11:-1.5:11:11:-1.5 
-pix_fmt yuv420p10le -flags +bitexact -sws_flags +accurate_rnd+bitexact
+
 FATE_FILTER_SAMPLES-$(call ALLYES, SMJPEG_DEMUXER MJPEG_DECODER PERMS_FILTER 
HQDN3D_FILTER) += fate-filter-hqdn3d-sample
 fate-filter-hqdn3d-sample: tests/data/filtergraphs/hqdn3d
 fate-filter-hqdn3d-sample: CMD = framecrc -idct simple -i 
$(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/hqdn3d -an
-- 
1.8.3.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 1/3] avfilter/vf_unsharp: add 10bit support

2020-10-29 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/unsharp.h|   3 +
 libavfilter/vf_unsharp.c | 162 +--
 2 files changed, 90 insertions(+), 75 deletions(-)

diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
index a60b30f..253e32d 100644
--- a/libavfilter/unsharp.h
+++ b/libavfilter/unsharp.h
@@ -48,9 +48,12 @@ typedef struct UnsharpContext {
 UnsharpFilterParam luma;   ///< luma parameters (width, height, amount)
 UnsharpFilterParam chroma; ///< chroma parameters (width, height, amount)
 int hsub, vsub;
+int bitdepth;
+int bps;
 int nb_threads;
 int opencl;
 int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame *out);
+int (* unsharp_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
 } UnsharpContext;
 
 #endif /* AVFILTER_UNSHARP_H */
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 7b430b6..416bf1c 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -57,81 +57,90 @@ typedef struct TheadData {
 int height;
 } ThreadData;
 
-static int unsharp_slice(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
-{
-ThreadData *td = arg;
-UnsharpFilterParam *fp = td->fp;
-uint32_t **sc = fp->sc;
-uint32_t *sr = fp->sr;
-const uint8_t *src2 = NULL;  //silence a warning
-const int amount = fp->amount;
-const int steps_x = fp->steps_x;
-const int steps_y = fp->steps_y;
-const int scalebits = fp->scalebits;
-const int32_t halfscale = fp->halfscale;
-
-uint8_t *dst = td->dst;
-const uint8_t *src = td->src;
-const int dst_stride = td->dst_stride;
-const int src_stride = td->src_stride;
-const int width = td->width;
-const int height = td->height;
-const int sc_offset = jobnr * 2 * steps_y;
-const int sr_offset = jobnr * (MAX_MATRIX_SIZE - 1);
-const int slice_start = (height * jobnr) / nb_jobs;
-const int slice_end = (height * (jobnr+1)) / nb_jobs;
-
-int32_t res;
-int x, y, z;
-uint32_t tmp1, tmp2;
-
-if (!amount) {
-av_image_copy_plane(dst + slice_start * dst_stride, dst_stride,
-src + slice_start * src_stride, src_stride,
-width, slice_end - slice_start);
-return 0;
-}
-
-for (y = 0; y < 2 * steps_y; y++)
-memset(sc[sc_offset + y], 0, sizeof(sc[y][0]) * (width + 2 * steps_x));
-
-// if this is not the first tile, we start from (slice_start - steps_y),
-// so we can get smooth result at slice boundary
-if (slice_start > steps_y) {
-src += (slice_start - steps_y) * src_stride;
-dst += (slice_start - steps_y) * dst_stride;
-}
-
-for (y = -steps_y + slice_start; y < steps_y + slice_end; y++) {
-if (y < height)
-src2 = src;
-
-memset(sr + sr_offset, 0, sizeof(sr[0]) * (2 * steps_x - 1));
-for (x = -steps_x; x < width + steps_x; x++) {
-tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
-for (z = 0; z < steps_x * 2; z += 2) {
-tmp2 = sr[sr_offset + z + 0] + tmp1; sr[sr_offset + z + 0] = 
tmp1;
-tmp1 = sr[sr_offset + z + 1] + tmp2; sr[sr_offset + z + 1] = 
tmp2;
-}
-for (z = 0; z < steps_y * 2; z += 2) {
-tmp2 = sc[sc_offset + z + 0][x + steps_x] + tmp1; sc[sc_offset 
+ z + 0][x + steps_x] = tmp1;
-tmp1 = sc[sc_offset + z + 1][x + steps_x] + tmp2; sc[sc_offset 
+ z + 1][x + steps_x] = tmp2;
-}
-if (x >= steps_x && y >= (steps_y + slice_start)) {
-const uint8_t *srx = src - steps_y * src_stride + x - steps_x;
-uint8_t *dsx   = dst - steps_y * dst_stride + x - steps_x;
-
-res = (int32_t)*srx + int32_t) * srx - (int32_t)((tmp1 + 
halfscale) >> scalebits)) * amount) >> 16);
-*dsx = av_clip_uint8(res);
-}
-}
-if (y >= 0) {
-dst += dst_stride;
-src += src_stride;
-}
-}
-return 0;
+#define DEF_UNSHARP_SLICE_FUNC(name, nbits)
   \
+static int name##_##nbits(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)\
+{  
   \
+ThreadData *td = arg;  
   \
+UnsharpFilterParam *fp = td->fp;   
   \
+UnsharpContext *s = ctx->priv; 
   \
+uint32_t **sc = fp->sc;
   \
+uint32_t *sr = fp->sr; 
   \
+co

[FFmpeg-devel] [PATCH] avformat/jacosubdec: Fix unintended fallthrough

2020-10-29 Thread Andreas Rheinhardt
Regression since 715ff75e5dbbbefff7337351db596a9b7a5d4379.

Fixes Coverity issues #1468654 and #1468656.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/jacosubdec.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index e70ceeaafd..14221b166c 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -148,9 +148,15 @@ static int get_shift(int timeres, const char *buf)
 
 ret = 0;
 switch (n) {
-case 4: ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d);
-case 3: ret = sign * (( (int64_t)a*60 + b) * timeres + c);
-case 2: ret = sign * (((int64_t)a) * timeres + b);
+case 4:
+ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d);
+break;
+case 3:
+ret = sign * (( (int64_t)a*60 + b) * timeres + c);
+break;
+case 2:
+ret = sign * (((int64_t)a) * timeres + b);
+break;
 }
 if ((int)ret != ret)
 ret = 0;
-- 
2.25.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".

Re: [FFmpeg-devel] [PATCH 1/4] avformat/apngdec: Check for incomplete reads in append_extradata()

2020-10-29 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: OOM
> Fixes: 
> 26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/apngdec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
> index 0f1d04a365..2e79fdd85c 100644
> --- a/libavformat/apngdec.c
> +++ b/libavformat/apngdec.c
> @@ -140,6 +140,8 @@ static int append_extradata(AVCodecParameters *par, 
> AVIOContext *pb, int len)
>  
>  if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
>  return ret;
> +if (ret < len)
> +return AVERROR_INVALIDDATA;
>  
>  return previous_size;
>  }
> 
Reminds me of
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/255671.html. But
how can this fix an OOM scenario? If avio_read() couldn't read
everything it should read, then we are at the end of the file and the
avio_feof() check will make sure that this is the last iteration of the
loop. Or is this a file that is being written to while it is read? (In
which case an earlier reading attempt might have failed, but a new one
might succeed because there is new data.)

- Andreas
___
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] avcodec/hevcdec: fix stat_coeff save/load for persistent_rice_adaptation_enabled_flag

2020-10-29 Thread Christophe Gisquet
Le mer. 9 sept. 2020 à 07:51, Guangxin Xu  a écrit :
> Hi Mickaël & all,
> any suggestions?

The patch is almost good, though I would have hoped to link at a
relevant part of the specs and TableStatCoeff* beyong just "9.3".

Though as I suspected, there is probably something missing. Maybe
around sync across (tile) threads?

You can check for yourself by running it like:
make fate-hevc-conformance-WPP_HIGH_TP_444_8BIT_RExt_Apple_2
THREADS=12 THREAD_TYPE=slice

Sure enough, the MD5 becomes random:
-0,  0,  0,1,  1179648, 0x78e55a69
-0,  1,  1,1,  1179648, 0x5babb3cb
-0,  2,  2,1,  1179648, 0x65935648
+0,  0,  0,1,  1179648, 0xa9a4a727
+0,  1,  1,1,  1179648, 0xf4bfd32d
+0,  2,  2,1,  1179648, 0x4f28807a
___
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] avfilter/vf_unsharp: add 10bit support

2020-10-29 Thread Linjie Fu
On Thu, Oct 29, 2020 at 7:16 PM  wrote:

> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/unsharp.h|   3 +
>  libavfilter/vf_unsharp.c | 162
> +--
>  2 files changed, 90 insertions(+), 75 deletions(-)
>
> diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
> index a60b30f..253e32d 100644
> --- a/libavfilter/unsharp.h
> +++ b/libavfilter/unsharp.h
> @@ -48,9 +48,12 @@ typedef struct UnsharpContext {
>  UnsharpFilterParam luma;   ///< luma parameters (width, height,
> amount)
>  UnsharpFilterParam chroma; ///< chroma parameters (width, height,
> amount)
>  int hsub, vsub;
> +int bitdepth;
> +int bps;
>  int nb_threads;
>  int opencl;
>  int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame
> *out);
> +int (* unsharp_slice)(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs);
>

Just curious:
Any special reason for the function moving?


>  } UnsharpContext;


>  #endif /* AVFILTER_UNSHARP_H */
> diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
> index 7b430b6..416bf1c 100644
> --- a/libavfilter/vf_unsharp.c
> +++ b/libavfilter/vf_unsharp.c
> @@ -57,81 +57,90 @@ typedef struct TheadData {
>  int height;
>  } ThreadData;
>
> -static int unsharp_slice(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs)
> -{
> -ThreadData *td = arg;
> -UnsharpFilterParam *fp = td->fp;
> -uint32_t **sc = fp->sc;
> -uint32_t *sr = fp->sr;
> -const uint8_t *src2 = NULL;  //silence a warning
> -const int amount = fp->amount;
> -const int steps_x = fp->steps_x;
> -const int steps_y = fp->steps_y;
> -const int scalebits = fp->scalebits;
> -const int32_t halfscale = fp->halfscale;
> -
> -uint8_t *dst = td->dst;
> -const uint8_t *src = td->src;
> -const int dst_stride = td->dst_stride;
> -const int src_stride = td->src_stride;
> -const int width = td->width;
> -const int height = td->height;
> -const int sc_offset = jobnr * 2 * steps_y;
> -const int sr_offset = jobnr * (MAX_MATRIX_SIZE - 1);
> -const int slice_start = (height * jobnr) / nb_jobs;
> -const int slice_end = (height * (jobnr+1)) / nb_jobs;
> -
> -int32_t res;
> -int x, y, z;
> -uint32_t tmp1, tmp2;
> -
> -if (!amount) {
> -av_image_copy_plane(dst + slice_start * dst_stride, dst_stride,
> -src + slice_start * src_stride, src_stride,
> -width, slice_end - slice_start);
> -return 0;
> -}
> -
> -for (y = 0; y < 2 * steps_y; y++)
> -memset(sc[sc_offset + y], 0, sizeof(sc[y][0]) * (width + 2 *
> steps_x));
> -
> -// if this is not the first tile, we start from (slice_start -
> steps_y),
> -// so we can get smooth result at slice boundary
> -if (slice_start > steps_y) {
> -src += (slice_start - steps_y) * src_stride;
> -dst += (slice_start - steps_y) * dst_stride;
> -}
> -
> -for (y = -steps_y + slice_start; y < steps_y + slice_end; y++) {
> -if (y < height)
> -src2 = src;
> -
> -memset(sr + sr_offset, 0, sizeof(sr[0]) * (2 * steps_x - 1));
> -for (x = -steps_x; x < width + steps_x; x++) {
> -tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] :
> src2[x];
> -for (z = 0; z < steps_x * 2; z += 2) {
> -tmp2 = sr[sr_offset + z + 0] + tmp1; sr[sr_offset + z +
> 0] = tmp1;
> -tmp1 = sr[sr_offset + z + 1] + tmp2; sr[sr_offset + z +
> 1] = tmp2;
> -}
> -for (z = 0; z < steps_y * 2; z += 2) {
> -tmp2 = sc[sc_offset + z + 0][x + steps_x] + tmp1;
> sc[sc_offset + z + 0][x + steps_x] = tmp1;
> -tmp1 = sc[sc_offset + z + 1][x + steps_x] + tmp2;
> sc[sc_offset + z + 1][x + steps_x] = tmp2;
> -}
> -if (x >= steps_x && y >= (steps_y + slice_start)) {
> -const uint8_t *srx = src - steps_y * src_stride + x -
> steps_x;
> -uint8_t *dsx   = dst - steps_y * dst_stride + x -
> steps_x;
> -
> -res = (int32_t)*srx + int32_t) * srx -
> (int32_t)((tmp1 + halfscale) >> scalebits)) * amount) >> 16);
> -*dsx = av_clip_uint8(res);
> -}
> -}
> -if (y >= 0) {
> -dst += dst_stride;
> -src += src_stride;
> -}
> -}
> -return 0;
> +#define DEF_UNSHARP_SLICE_FUNC(name, nbits)
>  \
> +static int name##_##nbits(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs)\
> +{
>  \
> +ThreadData *td = arg;
>  \
> +UnsharpFilterParam *fp = td->fp;
> \
> +UnsharpContext *s = ctx->priv;
> \
> +uint32_t **sc = fp->sc;
>  \
> +uint32_t *sr = f

Re: [FFmpeg-devel] [PATCH v4] Unbreak av_malloc_max(0) API/ABI

2020-10-29 Thread Joakim Tjernlund
Ping ..

On Tue, 2020-10-27 at 08:48 +, Joakim Tjernlund wrote:
> 
> Yet a ping ...
> 
> This is a simple technical patch, it just needs a policy decision.
> Can I have one ?
> 
>    Jocke
> 
> On Thu, 2020-10-22 at 14:17 +0200, Joakim Tjernlund wrote:
> > Ping ?
> > 
> >  Jocke
> > 
> > On Fri, 2020-10-16 at 10:57 +0200, Joakim Tjernlund wrote:
> > > From 
> > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1095962&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C63237ba2b4e64972a69e08d87a550bf3%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637393852976888793%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qIoMvpeiu5T4c6X32MRxKJI6%2BX4gOfBQeO7Cr%2FAih0o%3D&reserved=0
> > > 
> > > This seems to be caused by the custom handling of "av_max_alloc(0)" in
> > > Chromium's ffmpeg fork to mean unlimited (added in [1]).
> > > 
> > > Upstream ffmpeg doesn't treat 0 as a special value; versions before 4.3 
> > > seemingly worked
> > > because 32 was subtracted from max_alloc_size (set to 0 by Chromium) 
> > > resulting in an
> > > integer underflow, making the effective limit be SIZE_MAX - 31.
> > > 
> > > Now that the above underflow doesn't happen, the tab just crashes. The 
> > > upstream change
> > > for no longer subtracting 32 from max_alloc_size was included in ffmpeg 
> > > 4.3. [2]
> > > 
> > > [1] 
> > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fthird_party%2Fffmpeg%2F%2B%2F73563&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C63237ba2b4e64972a69e08d87a550bf3%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637393852976888793%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rQSlGjvmBZyttkhlKKvw%2FvQpPnAs1FQ6tlQk6AdIMwg%3D&reserved=0
> > > [2] 
> > > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F731c77589841&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C63237ba2b4e64972a69e08d87a550bf3%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637393852976888793%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=g2PTcFB9KaFZFDDtzlABOV8lHjCG0nYAWUrgI2v%2BhPY%3D&reserved=0
> > > ---
> > > 
> > > Restore av_malloc_max(0) to MAX_INT fixing MS Teams, Discord older 
> > > chromium etc.
> > > 
> > > Signed-off-by: Joakim Tjernlund 
> > > ---
> > > 
> > >  v2: Cover the full API range 0-31
> > > 
> > >  v3: Closer compat with < 4.3 ffmpeg
> > > 
> > >  v4: Adjust size accoriding to Andreas Rheinhardt comments
> > > 
> > >  libavutil/mem.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/libavutil/mem.c b/libavutil/mem.c
> > > index cfb6d8a..44870a9 100644
> > > --- a/libavutil/mem.c
> > > +++ b/libavutil/mem.c
> > > @@ -71,6 +71,8 @@ void  free(void *ptr);
> > >  static size_t max_alloc_size= INT_MAX;
> > > 
> > > 
> > >  void av_max_alloc(size_t max){
> > > +if (max < 32)
> > > +max = SIZE_MAX - 32 + max; /* be compatible to older(< 4.3) 
> > > versions */
> > >  max_alloc_size = max;
> > >  }
> > > 
> > > 
> > 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=04%7C01%7Cjoakim.tjernlund%40infinera.com%7C63237ba2b4e64972a69e08d87a550bf3%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637393852976888793%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3O5tUmaULeUO8OXZtPbEfvEoBBNJuFsakvSoIPA9%2FnI%3D&reserved=0
> 
> 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] [PATCH 2/2] fate/hevc-conformance: add clip for persistent_rice_adaptation_enabled_flag

2020-10-29 Thread Christophe Gisquet
Le sam. 29 août 2020 à 07:52, Xu Guangxin  a écrit :
> you can download it from:
> https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/WPP_HIGH_TP_444_8BIT_RExt_Apple_2.bit

Just for the record, this is now
https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/WPP_HIGH_TP_444_8BIT_RExt_Apple_2.zip

-- 
Christophe
___
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] avcodec: deprecate thread_safe_callbacks

2020-10-29 Thread Anton Khirnov
Quoting Moritz Barsnick (2020-08-10 23:14:59)
> On Tue, Aug 04, 2020 at 13:59:42 +0200, Anton Khirnov wrote:
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -2883,7 +2883,9 @@ static int init_input_stream(int ist_index, char 
> > *error, int error_len)
> >  ist->dec_ctx->opaque= ist;
> >  ist->dec_ctx->get_format= get_format;
> >  ist->dec_ctx->get_buffer2   = get_buffer;
> > +#if LIBAVCODEC_VERSION_MAJOR < 59
> >  ist->dec_ctx->thread_safe_callbacks = 1;
> > +#endif
> 
> Wouldn't this be
> #if FF_API_THREAD_SAFE_CALLBACKS
> ?
> 
> Seems more logical.
> 
> (I can't find more than one use of either FF_API_* or LIBAV*_VERSION_*
> in ffmpeg.c.)

FF_API_* macros are not a part of the public API (since they can be
removed whenever), so user applications are not allowed to use them.

-- 
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 v2 0/7] HEVC native support for Screen content coding

2020-10-29 Thread Christophe Gisquet
Hi,

Le ven. 2 oct. 2020 à 18:12, Guangxin Xu  a écrit :
> Most of scc conformance clip has tiles.
> But currently, the hevc software decoder has many issues for tile cabac
> saving and loading.
> We'd better fix them before starting implement scc tool.
>
> I have queue up some patches to address the cabac issue at [1] and send the
> first one to review at [2]
> but, no one responded to me yet. Do you know who can help review the patch?
> thanks
>
> [1] https://github.com/oddstone/FFmpeg/commits/rext1

This has additional fixes (which looks good, haven't really delved
into it) that unfortunately doesn't fix:

> [2]
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200829055218.32261-1-oddst...@gmail.com/

this patch being run under fate with THREADS=12 THREAD_TYPE=slice

--
Christophe
___
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 0/7] HEVC native support for Screen content coding

2020-10-29 Thread Christophe Gisquet
Hi,

Le mar. 29 sept. 2020 à 17:55, Linjie Fu  a écrit :
> I didn’t see such plans for now, hence adding sufficient error message
> seems to be a proper way.

Hi, as you are the only one active on this decoder, this shouldn't matter, but:
down the line, the ffmpeg project has no way of testing if someone
breaks even the basic parsing of these extensions in the future.
To test, the hardware you mention is needed, as well as maybe specific tests.

At some point, fate lacks some support for verifying h/w decoding. It
would be really nice if some of these companies with all this new
awesome hardware would consider this, and for instance contribute fate
instances to perform such test for the ffmpeg project.

-- 
Christophe
___
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] avcodec: deprecate thread_safe_callbacks

2020-10-29 Thread Anton Khirnov
They add considerable complexity to frame-threading implementation,
which includes an unavoidably leaking error path, while the advantages
of this option to the users are highly dubious.

It should be always possible and desirable for the callers to make their
get_buffer2() implementation thread-safe, so deprecate this option.
---
Postponed the removal until major 60, also documented this explicitly in
APIchanges, so users can test for it.
---
 doc/APIchanges |  5 +++
 doc/multithreading.txt |  3 +-
 fftools/ffmpeg.c   |  2 ++
 libavcodec/avcodec.h   | 13 ++--
 libavcodec/pthread_frame.c | 68 +++---
 libavcodec/thread.h|  4 +++
 libavcodec/utils.c | 13 
 libavcodec/version.h   |  5 ++-
 8 files changed, 102 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c00f103bab..df3d6d1fb0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-xx-xx - xx - lavc 58.113.100 - avcodec.h
+  Deprecate AVCodecContext.thread_safe_callbacks. Starting with
+  LIBAVCODEC_VERSION_MAJOR=60, user callbacks must always be
+  thread-safe when frame threading is used.
+
 2020-xx-xx - xx - lavf 58.64.100 - avformat.h
   Add AVSTREAM_EVENT_FLAG_NEW_PACKETS.
 
diff --git a/doc/multithreading.txt b/doc/multithreading.txt
index 4f645dc147..470194ff85 100644
--- a/doc/multithreading.txt
+++ b/doc/multithreading.txt
@@ -20,8 +20,7 @@ Slice threading -
 
 Frame threading -
 * Restrictions with slice threading also apply.
-* For best performance, the client should set thread_safe_callbacks if it
-  provides a thread-safe get_buffer() callback.
+* Custom get_buffer2() and get_format() callbacks must be thread-safe.
 * There is one frame of delay added for every thread beyond the first one.
   Clients must be able to handle this; the pkt_dts and pkt_pts fields in
   AVFrame will work as usual.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cb7644de6a..c3b9ec01c9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2890,7 +2890,9 @@ static int init_input_stream(int ist_index, char *error, 
int error_len)
 ist->dec_ctx->opaque= ist;
 ist->dec_ctx->get_format= get_format;
 ist->dec_ctx->get_buffer2   = get_buffer;
+#if LIBAVCODEC_VERSION_MAJOR < 60
 ist->dec_ctx->thread_safe_callbacks = 1;
+#endif
 
 av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
 if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 20af3ef00d..3528d1e637 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1314,9 +1314,9 @@ typedef struct AVCodecContext {
  *
  * Some decoders do not support linesizes changing between frames.
  *
- * If frame multithreading is used and thread_safe_callbacks is set,
- * this callback may be called from a different thread, but not from more
- * than one at once. Does not need to be reentrant.
+ * If frame multithreading is used, this callback may be called from a
+ * different thread, but not from more than one at once. Does not need to 
be
+ * reentrant.
  *
  * @see avcodec_align_dimensions2()
  *
@@ -1803,6 +1803,7 @@ typedef struct AVCodecContext {
  */
 int active_thread_type;
 
+#if FF_API_THREAD_SAFE_CALLBACKS
 /**
  * Set by the client if its custom get_buffer() callback can be called
  * synchronously from another thread, which allows faster multithreaded 
decoding.
@@ -1810,8 +1811,14 @@ typedef struct AVCodecContext {
  * Ignored if the default get_buffer() is used.
  * - encoding: Set by user.
  * - decoding: Set by user.
+ *
+ * @deprecated the custom get_buffer2() callback should always be
+ *   thread-safe. Thread-unsafe get_buffer2() implementations will be
+ *   invalid once this field is removed.
  */
+attribute_deprecated
 int thread_safe_callbacks;
+#endif
 
 /**
  * The codec may call this to execute several independent things.
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index f8a01ad8cd..c9d2e00ce3 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -89,6 +89,7 @@ typedef struct PerThreadContext {
 
 atomic_int state;
 
+#if FF_API_THREAD_SAFE_CALLBACKS
 /**
  * Array of frames passed to ff_thread_release_buffer().
  * Frames are released after all threads referencing them are finished.
@@ -102,6 +103,7 @@ typedef struct PerThreadContext {
 
 const enum AVPixelFormat *available_formats; ///< Format array for 
get_format()
 enum AVPixelFormat result_format;///< get_format() result
+#endif
 
 int die;///< Set when the thread should exit.
 
@@ -137,8 +139,10 @@ typedef struct FrameThreadContext {
  

[FFmpeg-devel] [PATCH 1/2] avcodec/tscc2: Don't check for errors for complete VLCs

2020-10-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tscc2.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c
index 6aadb51ad4..9fa28fe9fc 100644
--- a/libavcodec/tscc2.c
+++ b/libavcodec/tscc2.c
@@ -151,8 +151,6 @@ static int tscc2_decode_mb(TSCC2Context *c, int *q, int 
vlc_set,
 dc = get_bits(gb, 8);
 } else {
 dc = get_vlc2(gb, c->dc_vlc.table, 9, 2);
-if (dc == -1)
-return AVERROR_INVALIDDATA;
 if (dc == 0x100)
 dc = get_bits(gb, 8);
 }
@@ -161,15 +159,11 @@ static int tscc2_decode_mb(TSCC2Context *c, int *q, int 
vlc_set,
 c->block[0] = dc;
 
 nc = get_vlc2(gb, c->nc_vlc[vlc_set].table, 9, 1);
-if (nc == -1)
-return AVERROR_INVALIDDATA;
 
 bpos = 1;
 memset(c->block + 1, 0, 15 * sizeof(*c->block));
 for (l = 0; l < nc; l++) {
 ac = get_vlc2(gb, c->ac_vlc[vlc_set].table, 9, 2);
-if (ac == -1)
-return AVERROR_INVALIDDATA;
 if (ac == 0x1000)
 ac = get_bits(gb, 12);
 bpos += ac & 0xF;
-- 
2.25.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 2/2] avcodec/mimic: Inline constants

2020-10-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mimic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index 2563a49d53..0f8103ef85 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -34,6 +34,7 @@
 #include "thread.h"
 
 #define MIMIC_HEADER_SIZE   20
+#define MIMIC_VLC_BITS  11
 
 typedef struct MimicContext {
 AVCodecContext *avctx;
@@ -141,7 +142,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx)
 ctx->prev_index = 0;
 ctx->cur_index  = 15;
 
-if ((ret = init_vlc(&ctx->vlc, 11, FF_ARRAY_ELEMS(huffbits),
+if ((ret = init_vlc(&ctx->vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits),
 huffbits, 1, 1, huffcodes, 4, 4, 0)) < 0) {
 av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n");
 return ret;
@@ -239,7 +240,7 @@ static int vlc_decode_block(MimicContext *ctx, int 
num_coeffs, int qscale)
 int value;
 int coeff;
 
-vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 3);
+vlc = get_vlc2(&ctx->gb, ctx->vlc.table, MIMIC_VLC_BITS, 3);
 if (!vlc) /* end-of-block code */
 return 0;
 if (vlc == -1)
-- 
2.25.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".

Re: [FFmpeg-devel] [PATCH v2 0/7] HEVC native support for Screen content coding

2020-10-29 Thread Christophe Gisquet
Forgot to add this:

Le jeu. 29 oct. 2020 à 14:51, Christophe Gisquet
 a écrit :
> > [1] https://github.com/oddstone/FFmpeg/commits/rext1
>
> This has additional fixes (which looks good, haven't really delved
> into it) that unfortunately doesn't fix:

And I suspect you need these entropy state fixes (and other ones) to
be before adding any such tools, because these tools will not pass
some fate testing without them.

-- 
Christophe
___
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/4] avformat/concatdec: Check filename length before use

2020-10-29 Thread Nicolas George
Michael Niedermayer (12020-10-28):
> Fixes: out array read
> Fixes: 
> 26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/concatdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

This is not the first time such a fix is proposed. If strcmp() does not
behave intelligently, then we need an extra function for the task, but
duplicating the test all over the place is not a good idea.

Regards,

-- 
  Nicolas George


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 2/4] avformat/concatdec: Check filename length before use

2020-10-29 Thread Andreas Rheinhardt
Nicolas George:
> Michael Niedermayer (12020-10-28):
>> Fixes: out array read
>> Fixes: 
>> 26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808
>>
>> Found-by: continuous fuzzing process 
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavformat/concatdec.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> This is not the first time such a fix is proposed. If strcmp() does not
> behave intelligently, then we need an extra function for the task, but
> duplicating the test all over the place is not a good idea.
> 
We already have av_strstart() which would also allow us to avoid
computing strlen(proto) at all.

- Andreas
___
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 0/5] ffmpeg: late A/V encoder init, AVFrame metadata usage

2020-10-29 Thread Jan Ekström
On Wed, Oct 28, 2020 at 4:58 PM Jan Ekström  wrote:
>
> On Tue, Oct 27, 2020 at 8:30 PM Jan Ekström  wrote:
> >
> > This patch set started with a very simple wish to not have to set color
> > related values manually each time when utilizing ffmpeg.c.
> >
> > As of the fourth iteration, the following changes were done since the third:
> > 1. The data size threshold patch was moved to be the first one, thus meaning
> >that there is no case of it not being applied, and the encoder 
> > initialization
> >being moved later.
> > 2. As noted by Anton, as the encoder options are applied after the
> >AVFrame-based configuration, that code can be simplified to just
> >simple passing of values instead of first checking if the option is
> >set in the dictionary.
> > 3. Interlaced/progressive and field order decision making commit has been
> >reworded to include an explanation of the FATE test changes.
> >
> > Unfortunately, audio still needs two locations where the encoder is
> > initialized, due to how avfilter_graph_request_oldest peeks and already puts
> > one AVFrame to be available from the filter graph (which is then utilized
> > as-is as an early return inside both av_buffersink_get_frame_flags and
> > av_buffersink_get_samples). If this would be improved in lavfi (or the call
> > to avfilter_graph_request_oldest removed), we could at least remove one of
> > these.
> >
> > Currently limited to using values for video and started with the basic 
> > values,
> > more can be added later if needed.
> >
> > This probably fixes some trac issues, but with a quick look I couldn't find
> > anything that explicitly was due to lack of video color metadata 
> > passthrough.
> >
>
> Received an approval from Anton, so unless there are objections I will
> be pulling this set in tomorrow evening.
>

Applied patch set as:
453b2f3c154f6b83221940ad411599ded91f7413
3360c9a5679cc9bd83ab5860757ebab8f64ea8ba
67be1ce0c6de330b1c10d1d121819d8a74a7b1f5
7369595c556516b90bf3acdf85043dc11add7d89
fbb44bc51a647862eb05ae3f9d7d49a0be9bed57

Thanks for testing and reviews to everyone who participated,
especially Michael and Anton.

Jan
___
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 4/5] ffmpeg: pass decoded or filtered AVFrame to output stream initialization

2020-10-29 Thread Michael Niedermayer
On Tue, Oct 27, 2020 at 08:30:55PM +0200, Jan Ekström wrote:
> Additionally, reap the first rewards by being able to set the
> color related encoding values based on the passed AVFrame.
> 
> The only tests that seem to have changed their results with this
> change seem to be the MXF tests. There, the muxer writes the
> limited/full range flag to the output container if the encoder
> is not set to "unspecified".

not sure this is useful or interresting but
heres a case where a non mxf file changes

./ffmpeg -i framestep_fails.mov -map 0:v:0 -filter:v "framestep=step=2" 
-codec:v libx264 -t 0.1 -an file-old.mp4
file is from ticket/5414 


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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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 4/4] avcodec/utils: Check sample rate before use for AV_CODEC_ID_BINKAUDIO_DCT in get_audio_frame_duration()

2020-10-29 Thread Michael Niedermayer
On Wed, Oct 28, 2020 at 12:17:47PM +1100, Peter Ross wrote:
> On Tue, Oct 27, 2020 at 05:21:19PM +0100, Michael Niedermayer wrote:
> > Fixes: shift exponent 95 is too large for 32-bit type 'int'
> > Fixes: 
> > 26590/clusterfuzz-testcase-minimized-ffmpeg_dem_SMACKER_fuzzer-5120609937522688
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/utils.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index 93ac1cd9f0..3d978b390e 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -1633,8 +1633,11 @@ static int get_audio_frame_duration(enum AVCodecID 
> > id, int sr, int ch, int ba,
> >  
> >  if (ch > 0) {
> >  /* calc from sample rate and channels */
> > -if (id == AV_CODEC_ID_BINKAUDIO_DCT)
> > +if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
> > +if (sr / 22050 > 22)
> > +return 0;
> >  return (480 << (sr / 22050)) / ch;
> > +}
> >  }
> >  
> >  if (id == AV_CODEC_ID_MP3)
> 
> looks good

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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] avcodec/rkmpp : reset end of stream flag on flush

2020-10-29 Thread David Sowa
This is my first code submission to this project which I did a few days
back and received no feedback,
probably because I've done something wrong.  So I will provide more details
on the issue and the
solution in hopes of moving the process forward.
The code I have that uses libavcodec allows the user to loop over a
subsection of the video file. It does
this by starting at a key frame, playing to the end timestamp, issuing a
flush packet and seeking back
to the initial key frame.  This works correctly with both the soft decode
path and the VAAPI decoder but
fails with the rkmpp decoder.
It fails because internally the rkmpp decoder has no mechanism to allow
more packets to be processed
after a flush packet is received.  The solution is simply to have the flush
packet reset the End of Stream
flag so additional packets can be decoded.
I've been using this fix for 11 months and I would like to get it into the
mainline code mostly just to save
having to remember to port it whenever i pull new code.

regards,
David Sowa

On Mon, Oct 26, 2020 at 4:26 PM David Sowa  wrote:

> Currently the flag eos_reached is set to 1 on end of stream
> and there is no mechanism to reset it to 0. After a flush new
> buffers should be able to be decoded but the eos_reached flag
> causes all the frames to be dropped. Reset the eos_reached flag
> to 0 during the flush operation to allow new frames to be
> decoded.
> ---
>  libavcodec/rkmppdec.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
> index 248020d5d6..bf1bf0b013 100644
> --- a/libavcodec/rkmppdec.c
> +++ b/libavcodec/rkmppdec.c
> @@ -544,6 +544,7 @@ static void rkmpp_flush(AVCodecContext *avctx)
>  ret = decoder->mpi->reset(decoder->ctx);
>  if (ret == MPP_OK) {
>  decoder->first_packet = 1;
> +decoder->eos_reached = 0;
>  } else
>  av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n",
> ret);
>  }
> --
> 2.25.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] tls: Hook up the url_get_short_seek function in the TLS backends

2020-10-29 Thread Martin Storsjö
This makes sure that small seeks forward on https don't end up
doing new requests.
---
 libavformat/tls_gnutls.c  | 7 +++
 libavformat/tls_libtls.c  | 7 +++
 libavformat/tls_mbedtls.c | 7 +++
 libavformat/tls_openssl.c | 7 +++
 libavformat/tls_schannel.c| 7 +++
 libavformat/tls_securetransport.c | 7 +++
 6 files changed, 42 insertions(+)

diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 0c4ef34f5f..f9d5af7096 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -269,6 +269,12 @@ static int tls_get_file_handle(URLContext *h)
 return ffurl_get_file_handle(c->tls_shared.tcp);
 }
 
+static int tls_get_short_seek(URLContext *h)
+{
+TLSContext *s = h->priv_data;
+return ffurl_get_short_seek(s->tls_shared.tcp);
+}
+
 static const AVOption options[] = {
 TLS_COMMON_OPTIONS(TLSContext, tls_shared),
 { NULL }
@@ -288,6 +294,7 @@ const URLProtocol ff_tls_protocol = {
 .url_write  = tls_write,
 .url_close  = tls_close,
 .url_get_file_handle = tls_get_file_handle,
+.url_get_short_seek  = tls_get_short_seek,
 .priv_data_size = sizeof(TLSContext),
 .flags  = URL_PROTOCOL_FLAG_NETWORK,
 .priv_data_class = &tls_class,
diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
index dff7f2d9fb..911c8094b0 100644
--- a/libavformat/tls_libtls.c
+++ b/libavformat/tls_libtls.c
@@ -181,6 +181,12 @@ static int tls_get_file_handle(URLContext *h)
 return ffurl_get_file_handle(c->tls_shared.tcp);
 }
 
+static int tls_get_short_seek(URLContext *h)
+{
+TLSContext *s = h->priv_data;
+return ffurl_get_short_seek(s->tls_shared.tcp);
+}
+
 static const AVOption options[] = {
 TLS_COMMON_OPTIONS(TLSContext, tls_shared),
 { NULL }
@@ -200,6 +206,7 @@ const URLProtocol ff_tls_protocol = {
 .url_write  = ff_tls_write,
 .url_close  = ff_tls_close,
 .url_get_file_handle = tls_get_file_handle,
+.url_get_short_seek  = tls_get_short_seek,
 .priv_data_size = sizeof(TLSContext),
 .flags  = URL_PROTOCOL_FLAG_NETWORK,
 .priv_data_class = &tls_class,
diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 965adf1be4..aadf17760d 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -326,6 +326,12 @@ static int tls_get_file_handle(URLContext *h)
 return ffurl_get_file_handle(c->tls_shared.tcp);
 }
 
+static int tls_get_short_seek(URLContext *h)
+{
+TLSContext *s = h->priv_data;
+return ffurl_get_short_seek(s->tls_shared.tcp);
+}
+
 static const AVOption options[] = {
 TLS_COMMON_OPTIONS(TLSContext, tls_shared), \
 {"key_password", "Password for the private key file", OFFSET(priv_key_pw), 
 AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
@@ -346,6 +352,7 @@ const URLProtocol ff_tls_protocol = {
 .url_write  = tls_write,
 .url_close  = tls_close,
 .url_get_file_handle = tls_get_file_handle,
+.url_get_short_seek  = tls_get_short_seek,
 .priv_data_size = sizeof(TLSContext),
 .flags  = URL_PROTOCOL_FLAG_NETWORK,
 .priv_data_class = &tls_class,
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 002197fa76..e0616acbc8 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -351,6 +351,12 @@ static int tls_get_file_handle(URLContext *h)
 return ffurl_get_file_handle(c->tls_shared.tcp);
 }
 
+static int tls_get_short_seek(URLContext *h)
+{
+TLSContext *s = h->priv_data;
+return ffurl_get_short_seek(s->tls_shared.tcp);
+}
+
 static const AVOption options[] = {
 TLS_COMMON_OPTIONS(TLSContext, tls_shared),
 { NULL }
@@ -370,6 +376,7 @@ const URLProtocol ff_tls_protocol = {
 .url_write  = tls_write,
 .url_close  = tls_close,
 .url_get_file_handle = tls_get_file_handle,
+.url_get_short_seek  = tls_get_short_seek,
 .priv_data_size = sizeof(TLSContext),
 .flags  = URL_PROTOCOL_FLAG_NETWORK,
 .priv_data_class = &tls_class,
diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c
index 4bfaa85228..d4959f75fa 100644
--- a/libavformat/tls_schannel.c
+++ b/libavformat/tls_schannel.c
@@ -589,6 +589,12 @@ static int tls_get_file_handle(URLContext *h)
 return ffurl_get_file_handle(c->tls_shared.tcp);
 }
 
+static int tls_get_short_seek(URLContext *h)
+{
+TLSContext *s = h->priv_data;
+return ffurl_get_short_seek(s->tls_shared.tcp);
+}
+
 static const AVOption options[] = {
 TLS_COMMON_OPTIONS(TLSContext, tls_shared),
 { NULL }
@@ -608,6 +614,7 @@ const URLProtocol ff_tls_protocol = {
 .url_write  = tls_write,
 .url_close  = tls_close,
 .url_get_file_handle = tls_get_file_handle,
+.url_get_short_seek  = tls_get_short_seek,
 .priv_data_size = sizeof(TLSContext),
 .flags  = URL_PROTOCOL_FLAG_NETWORK,
 .priv_data_class = &tls_class,
diff --git a/libavformat/tls_securetranspor

Re: [FFmpeg-devel] [PATCH] tls: Hook up the url_get_short_seek function in the TLS backends

2020-10-29 Thread Andreas Rheinhardt
Martin Storsjö:
> This makes sure that small seeks forward on https don't end up
> doing new requests.
> ---
>  libavformat/tls_gnutls.c  | 7 +++
>  libavformat/tls_libtls.c  | 7 +++
>  libavformat/tls_mbedtls.c | 7 +++
>  libavformat/tls_openssl.c | 7 +++
>  libavformat/tls_schannel.c| 7 +++
>  libavformat/tls_securetransport.c | 7 +++
>  6 files changed, 42 insertions(+)
> 
> diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
> index 0c4ef34f5f..f9d5af7096 100644
> --- a/libavformat/tls_gnutls.c
> +++ b/libavformat/tls_gnutls.c
> @@ -269,6 +269,12 @@ static int tls_get_file_handle(URLContext *h)
>  return ffurl_get_file_handle(c->tls_shared.tcp);
>  }
>  
> +static int tls_get_short_seek(URLContext *h)
> +{
> +TLSContext *s = h->priv_data;
> +return ffurl_get_short_seek(s->tls_shared.tcp);
> +}
> +
>  static const AVOption options[] = {
>  TLS_COMMON_OPTIONS(TLSContext, tls_shared),
>  { NULL }
> @@ -288,6 +294,7 @@ const URLProtocol ff_tls_protocol = {
>  .url_write  = tls_write,
>  .url_close  = tls_close,
>  .url_get_file_handle = tls_get_file_handle,
> +.url_get_short_seek  = tls_get_short_seek,
>  .priv_data_size = sizeof(TLSContext),
>  .flags  = URL_PROTOCOL_FLAG_NETWORK,
>  .priv_data_class = &tls_class,
> diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
> index dff7f2d9fb..911c8094b0 100644
> --- a/libavformat/tls_libtls.c
> +++ b/libavformat/tls_libtls.c
> @@ -181,6 +181,12 @@ static int tls_get_file_handle(URLContext *h)
>  return ffurl_get_file_handle(c->tls_shared.tcp);
>  }
>  
> +static int tls_get_short_seek(URLContext *h)
> +{
> +TLSContext *s = h->priv_data;
> +return ffurl_get_short_seek(s->tls_shared.tcp);
> +}
> +
>  static const AVOption options[] = {
>  TLS_COMMON_OPTIONS(TLSContext, tls_shared),
>  { NULL }
> @@ -200,6 +206,7 @@ const URLProtocol ff_tls_protocol = {
>  .url_write  = ff_tls_write,
>  .url_close  = ff_tls_close,
>  .url_get_file_handle = tls_get_file_handle,
> +.url_get_short_seek  = tls_get_short_seek,
>  .priv_data_size = sizeof(TLSContext),
>  .flags  = URL_PROTOCOL_FLAG_NETWORK,
>  .priv_data_class = &tls_class,
> diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
> index 965adf1be4..aadf17760d 100644
> --- a/libavformat/tls_mbedtls.c
> +++ b/libavformat/tls_mbedtls.c
> @@ -326,6 +326,12 @@ static int tls_get_file_handle(URLContext *h)
>  return ffurl_get_file_handle(c->tls_shared.tcp);
>  }
>  
> +static int tls_get_short_seek(URLContext *h)
> +{
> +TLSContext *s = h->priv_data;
> +return ffurl_get_short_seek(s->tls_shared.tcp);
> +}
> +
>  static const AVOption options[] = {
>  TLS_COMMON_OPTIONS(TLSContext, tls_shared), \
>  {"key_password", "Password for the private key file", 
> OFFSET(priv_key_pw),  AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
> @@ -346,6 +352,7 @@ const URLProtocol ff_tls_protocol = {
>  .url_write  = tls_write,
>  .url_close  = tls_close,
>  .url_get_file_handle = tls_get_file_handle,
> +.url_get_short_seek  = tls_get_short_seek,
>  .priv_data_size = sizeof(TLSContext),
>  .flags  = URL_PROTOCOL_FLAG_NETWORK,
>  .priv_data_class = &tls_class,
> diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
> index 002197fa76..e0616acbc8 100644
> --- a/libavformat/tls_openssl.c
> +++ b/libavformat/tls_openssl.c
> @@ -351,6 +351,12 @@ static int tls_get_file_handle(URLContext *h)
>  return ffurl_get_file_handle(c->tls_shared.tcp);
>  }
>  
> +static int tls_get_short_seek(URLContext *h)
> +{
> +TLSContext *s = h->priv_data;
> +return ffurl_get_short_seek(s->tls_shared.tcp);
> +}
> +
>  static const AVOption options[] = {
>  TLS_COMMON_OPTIONS(TLSContext, tls_shared),
>  { NULL }
> @@ -370,6 +376,7 @@ const URLProtocol ff_tls_protocol = {
>  .url_write  = tls_write,
>  .url_close  = tls_close,
>  .url_get_file_handle = tls_get_file_handle,
> +.url_get_short_seek  = tls_get_short_seek,
>  .priv_data_size = sizeof(TLSContext),
>  .flags  = URL_PROTOCOL_FLAG_NETWORK,
>  .priv_data_class = &tls_class,
> diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c
> index 4bfaa85228..d4959f75fa 100644
> --- a/libavformat/tls_schannel.c
> +++ b/libavformat/tls_schannel.c
> @@ -589,6 +589,12 @@ static int tls_get_file_handle(URLContext *h)
>  return ffurl_get_file_handle(c->tls_shared.tcp);
>  }
>  
> +static int tls_get_short_seek(URLContext *h)
> +{
> +TLSContext *s = h->priv_data;
> +return ffurl_get_short_seek(s->tls_shared.tcp);
> +}
> +
>  static const AVOption options[] = {
>  TLS_COMMON_OPTIONS(TLSContext, tls_shared),
>  { NULL }
> @@ -608,6 +614,7 @@ const URLProtocol ff_tls_protocol = {
>  .url_write  = tls_write,
>  .url_close  = 

Re: [FFmpeg-devel] [PATCH] tls: Hook up the url_get_short_seek function in the TLS backends

2020-10-29 Thread Martin Storsjö

On Thu, 29 Oct 2020, Andreas Rheinhardt wrote:


Martin Storsjö:

This makes sure that small seeks forward on https don't end up
doing new requests.
---
 libavformat/tls_gnutls.c  | 7 +++
 libavformat/tls_libtls.c  | 7 +++
 libavformat/tls_mbedtls.c | 7 +++
 libavformat/tls_openssl.c | 7 +++
 libavformat/tls_schannel.c| 7 +++
 libavformat/tls_securetransport.c | 7 +++
 6 files changed, 42 insertions(+)


All the TLSContexts begin with a common initial sequence, namely
   const AVClass *class;
   TLSShared tls_shared;
So using different functions for them is avoidable.


Yes - and that would also go for the preexisting url_get_file_handle that 
works pretty much the same as this one. It requires a bit more blind 
casting (no easy verification if one backend would have a different layout 
for its context) though...


// Martin
___
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] avformat/dv: allow returning damaged audio

2020-10-29 Thread Michael Niedermayer
These potentially damaged packets are marked as corrupt.
The packet length is predicted based on packet length history,
allowing prediction of the common pattern used in NTSC.

Fixes: Ticket8762
Tested-by: Dave Rice 
Signed-off-by: Michael Niedermayer 
---
 libavformat/dv.c | 60 ++--
 1 file changed, 53 insertions(+), 7 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 3e0d12c0e3..3499cba6f8 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -34,12 +34,20 @@
 #include "libavcodec/dv_profile.h"
 #include "libavcodec/dv.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/timecode.h"
 #include "dv.h"
 #include "libavutil/avassert.h"
 
+#define AS_HASH_SIZE 16
+
+enum AudioConceal {
+AUDIO_CONCEAL_PASS = 1,
+AUDIO_CONCEAL_DROP = 0,
+};
+
 struct DVDemuxContext {
 const AVDVProfile*  sys;/* Current DV profile. E.g.: 525/60, 625/50 */
 AVFormatContext*  fctx;
@@ -50,6 +58,9 @@ struct DVDemuxContext {
 int   ach;
 int   frames;
 uint64_t  abytes;
+uint8_t   as_pack[AS_HASH_SIZE][5];
+uint8_t   as_hash;
+int   dvaudio_concealment;
 };
 
 static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -72,7 +83,7 @@ static inline uint16_t dv_audio_12to16(uint16_t sample)
 return result;
 }
 
-static const uint8_t *dv_extract_pack(const uint8_t *frame, enum dv_pack_type 
t)
+static const uint8_t *dv_extract_pack(DVDemuxContext *d, const uint8_t *frame, 
enum dv_pack_type t)
 {
 int offs;
 int c;
@@ -101,6 +112,17 @@ static const uint8_t *dv_extract_pack(const uint8_t 
*frame, enum dv_pack_type t)
 break;
 }
 
+if (t == dv_audio_source || t == dv_audio_control) {
+int index = (d->as_hash>>1) & (AS_HASH_SIZE-1);
+if (frame[offs] == t) {
+memcpy(d->as_pack[index], &frame[offs], sizeof(d->as_pack[index]));
+} else if (d->as_pack[index][0] && d->dvaudio_concealment == 
AUDIO_CONCEAL_PASS) {
+return d->as_pack[index];
+} else if (d->as_pack[0][0] && d->dvaudio_concealment == 
AUDIO_CONCEAL_PASS) {
+return d->as_pack[0];
+}
+}
+
 return frame[offs] == t ? &frame[offs] : NULL;
 }
 
@@ -116,7 +138,7 @@ static const int dv_audio_frequency[3] = {
  * 3. Audio is always returned as 16-bit linear samples: 12-bit nonlinear 
samples
  *are converted into 16-bit linear ones.
  */
-static int dv_extract_audio(const uint8_t *frame, uint8_t **ppcm,
+static int dv_extract_audio(DVDemuxContext *c, const uint8_t *frame, uint8_t 
**ppcm,
 const AVDVProfile *sys)
 {
 int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
@@ -124,7 +146,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
 const uint8_t *as_pack;
 uint8_t *pcm, ipcm;
 
-as_pack = dv_extract_pack(frame, dv_audio_source);
+as_pack = dv_extract_pack(c, frame, dv_audio_source);
 if (!as_pack)/* No audio ? */
 return 0;
 
@@ -137,6 +159,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
 
 if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency))
 return AVERROR_INVALIDDATA;
+c->as_hash = 2*c->as_hash + smpls;
 
 size= (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */
 half_ch = sys->difseg_size / 2;
@@ -153,6 +176,9 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
 /* for each DIF channel */
 for (chan = 0; chan < sys->n_difchan; chan++) {
 av_assert0(ipcm<4);
+c->audio_pkt[ipcm].flags &= ~AV_PKT_FLAG_CORRUPT;
+if (as_pack >= c->as_pack[0] && as_pack < c->as_pack[AS_HASH_SIZE])
+c->audio_pkt[ipcm].flags |= AV_PKT_FLAG_CORRUPT;
 pcm = ppcm[ipcm++];
 if (!pcm)
 break;
@@ -224,7 +250,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 const uint8_t *as_pack;
 int freq, stype, smpls, quant, i, ach;
 
-as_pack = dv_extract_pack(frame, dv_audio_source);
+as_pack = dv_extract_pack(c, frame, dv_audio_source);
 if (!as_pack || !c->sys) {/* No audio ? */
 c->ach = 0;
 return 0;
@@ -292,7 +318,7 @@ static int dv_extract_video_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);
 
 /* finding out SAR is a little bit messy */
-vsc_pack = dv_extract_pack(frame, dv_video_control);
+vsc_pack = dv_extract_pack(c, frame, dv_video_control);
 apt  = frame[4] & 0x07;
 is16_9   = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
  (!apt && (vsc_pack[2] & 0x07) == 0x07)));
@@ -312,7 +338,7 @@ static int dv_extract_timecode(DVDemuxContext* c, const 
uint8_t* frame, char *tc
 // is only relevant for NTSC systems.
 

Re: [FFmpeg-devel] [PATCH] avformat/jacosubdec: Fix unintended fallthrough

2020-10-29 Thread Michael Niedermayer
On Thu, Oct 29, 2020 at 01:39:35PM +0100, Andreas Rheinhardt wrote:
> Regression since 715ff75e5dbbbefff7337351db596a9b7a5d4379.
> 
> Fixes Coverity issues #1468654 and #1468656.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/jacosubdec.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)

LGTM

thx

[...]
-- 
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".

Re: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_unsharp: add 10bit support

2020-10-29 Thread lance . lmwang
On Thu, Oct 29, 2020 at 09:09:00PM +0800, Linjie Fu wrote:
> On Thu, Oct 29, 2020 at 7:16 PM  wrote:
> 
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/unsharp.h|   3 +
> >  libavfilter/vf_unsharp.c | 162
> > +--
> >  2 files changed, 90 insertions(+), 75 deletions(-)
> >
> > diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
> > index a60b30f..253e32d 100644
> > --- a/libavfilter/unsharp.h
> > +++ b/libavfilter/unsharp.h
> > @@ -48,9 +48,12 @@ typedef struct UnsharpContext {
> >  UnsharpFilterParam luma;   ///< luma parameters (width, height,
> > amount)
> >  UnsharpFilterParam chroma; ///< chroma parameters (width, height,
> > amount)
> >  int hsub, vsub;
> > +int bitdepth;
> > +int bps;
> >  int nb_threads;
> >  int opencl;
> >  int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame
> > *out);
> > +int (* unsharp_slice)(AVFilterContext *ctx, void *arg, int jobnr, int
> > nb_jobs);
> >
> 
> Just curious:
> Any special reason for the function moving?

Sorry, I'm not clear about your question.

> 
> 
> >  } UnsharpContext;
> 
> 
> >  #endif /* AVFILTER_UNSHARP_H */
> > diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
> > index 7b430b6..416bf1c 100644
> > --- a/libavfilter/vf_unsharp.c
> > +++ b/libavfilter/vf_unsharp.c
> > @@ -57,81 +57,90 @@ typedef struct TheadData {
> >  int height;
> >  } ThreadData;
> >
> > -static int unsharp_slice(AVFilterContext *ctx, void *arg, int jobnr, int
> > nb_jobs)
> > -{
> > -ThreadData *td = arg;
> > -UnsharpFilterParam *fp = td->fp;
> > -uint32_t **sc = fp->sc;
> > -uint32_t *sr = fp->sr;
> > -const uint8_t *src2 = NULL;  //silence a warning
> > -const int amount = fp->amount;
> > -const int steps_x = fp->steps_x;
> > -const int steps_y = fp->steps_y;
> > -const int scalebits = fp->scalebits;
> > -const int32_t halfscale = fp->halfscale;
> > -
> > -uint8_t *dst = td->dst;
> > -const uint8_t *src = td->src;
> > -const int dst_stride = td->dst_stride;
> > -const int src_stride = td->src_stride;
> > -const int width = td->width;
> > -const int height = td->height;
> > -const int sc_offset = jobnr * 2 * steps_y;
> > -const int sr_offset = jobnr * (MAX_MATRIX_SIZE - 1);
> > -const int slice_start = (height * jobnr) / nb_jobs;
> > -const int slice_end = (height * (jobnr+1)) / nb_jobs;
> > -
> > -int32_t res;
> > -int x, y, z;
> > -uint32_t tmp1, tmp2;
> > -
> > -if (!amount) {
> > -av_image_copy_plane(dst + slice_start * dst_stride, dst_stride,
> > -src + slice_start * src_stride, src_stride,
> > -width, slice_end - slice_start);
> > -return 0;
> > -}
> > -
> > -for (y = 0; y < 2 * steps_y; y++)
> > -memset(sc[sc_offset + y], 0, sizeof(sc[y][0]) * (width + 2 *
> > steps_x));
> > -
> > -// if this is not the first tile, we start from (slice_start -
> > steps_y),
> > -// so we can get smooth result at slice boundary
> > -if (slice_start > steps_y) {
> > -src += (slice_start - steps_y) * src_stride;
> > -dst += (slice_start - steps_y) * dst_stride;
> > -}
> > -
> > -for (y = -steps_y + slice_start; y < steps_y + slice_end; y++) {
> > -if (y < height)
> > -src2 = src;
> > -
> > -memset(sr + sr_offset, 0, sizeof(sr[0]) * (2 * steps_x - 1));
> > -for (x = -steps_x; x < width + steps_x; x++) {
> > -tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] :
> > src2[x];
> > -for (z = 0; z < steps_x * 2; z += 2) {
> > -tmp2 = sr[sr_offset + z + 0] + tmp1; sr[sr_offset + z +
> > 0] = tmp1;
> > -tmp1 = sr[sr_offset + z + 1] + tmp2; sr[sr_offset + z +
> > 1] = tmp2;
> > -}
> > -for (z = 0; z < steps_y * 2; z += 2) {
> > -tmp2 = sc[sc_offset + z + 0][x + steps_x] + tmp1;
> > sc[sc_offset + z + 0][x + steps_x] = tmp1;
> > -tmp1 = sc[sc_offset + z + 1][x + steps_x] + tmp2;
> > sc[sc_offset + z + 1][x + steps_x] = tmp2;
> > -}
> > -if (x >= steps_x && y >= (steps_y + slice_start)) {
> > -const uint8_t *srx = src - steps_y * src_stride + x -
> > steps_x;
> > -uint8_t *dsx   = dst - steps_y * dst_stride + x -
> > steps_x;
> > -
> > -res = (int32_t)*srx + int32_t) * srx -
> > (int32_t)((tmp1 + halfscale) >> scalebits)) * amount) >> 16);
> > -*dsx = av_clip_uint8(res);
> > -}
> > -}
> > -if (y >= 0) {
> > -dst += dst_stride;
> > -src += src_stride;
> > -}
> > -}
> > -return 0;
> > +#define DEF_UNSHARP_SLICE_FUNC(name, nbits)
> >  \
> > +static int name##_##nbits(AVFilterContext *ctx, void *arg, int

[FFmpeg-devel] [PATCH v2 3/3] fate/filter-video: add 10bit test for unsharp filter

2020-10-29 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 tests/fate/filter-video.mak |  3 ++
 tests/ref/fate/filter-unsharp-yuv420p10 | 55 +
 2 files changed, 58 insertions(+)
 create mode 100644 tests/ref/fate/filter-unsharp-yuv420p10

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 639f957..f295df4 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -410,6 +410,9 @@ fate-filter-untile: CMD = framecrc -lavfi 
testsrc2=d=1:r=2,untile=2x2
 FATE_FILTER_VSYNTH-$(CONFIG_UNSHARP_FILTER) += fate-filter-unsharp
 fate-filter-unsharp: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf 
unsharp=11:11:-1.5:11:11:-1.5
 
+FATE_FILTER_VSYNTH-$(CONFIG_UNSHARP_FILTER) += fate-filter-unsharp-yuv420p10
+fate-filter-unsharp-yuv420p10: CMD = framecrc -auto_conversion_filters -c:v 
pgmyuv -i $(SRC) -vf format=pix_fmts=yuv420p10,unsharp=11:11:-1.5:11:11:-1.5 
-pix_fmt yuv420p10le -flags +bitexact -sws_flags +accurate_rnd+bitexact
+
 FATE_FILTER_SAMPLES-$(call ALLYES, SMJPEG_DEMUXER MJPEG_DECODER PERMS_FILTER 
HQDN3D_FILTER) += fate-filter-hqdn3d-sample
 fate-filter-hqdn3d-sample: tests/data/filtergraphs/hqdn3d
 fate-filter-hqdn3d-sample: CMD = framecrc -idct simple -i 
$(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/hqdn3d -an
diff --git a/tests/ref/fate/filter-unsharp-yuv420p10 
b/tests/ref/fate/filter-unsharp-yuv420p10
new file mode 100644
index 000..20f82f1
--- /dev/null
+++ b/tests/ref/fate/filter-unsharp-yuv420p10
@@ -0,0 +1,55 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 352x288
+#sar 0: 0/1
+0,  0,  0,1,   304128, 0x375a055d
+0,  1,  1,1,   304128, 0x43374234
+0,  2,  2,1,   304128, 0xba34fded
+0,  3,  3,1,   304128, 0xaab09f3b
+0,  4,  4,1,   304128, 0x1e42b90e
+0,  5,  5,1,   304128, 0x135f1088
+0,  6,  6,1,   304128, 0x780c001a
+0,  7,  7,1,   304128, 0x10f209fa
+0,  8,  8,1,   304128, 0x54aa698a
+0,  9,  9,1,   304128, 0x72470a4b
+0, 10, 10,1,   304128, 0x7cac80ed
+0, 11, 11,1,   304128, 0x820ffb09
+0, 12, 12,1,   304128, 0x7386656a
+0, 13, 13,1,   304128, 0x3662c47e
+0, 14, 14,1,   304128, 0x1b07cbce
+0, 15, 15,1,   304128, 0x2577c6d2
+0, 16, 16,1,   304128, 0xb478c1a6
+0, 17, 17,1,   304128, 0x27549b49
+0, 18, 18,1,   304128, 0xd2f628ca
+0, 19, 19,1,   304128, 0x95cc5544
+0, 20, 20,1,   304128, 0x844a1bda
+0, 21, 21,1,   304128, 0x4bcfc8b2
+0, 22, 22,1,   304128, 0x403e2302
+0, 23, 23,1,   304128, 0x275214bf
+0, 24, 24,1,   304128, 0x2f1e8e7b
+0, 25, 25,1,   304128, 0x14d68a42
+0, 26, 26,1,   304128, 0x2d966e74
+0, 27, 27,1,   304128, 0x7d2f0bf2
+0, 28, 28,1,   304128, 0x5744d92e
+0, 29, 29,1,   304128, 0x4c89f858
+0, 30, 30,1,   304128, 0x9702e22e
+0, 31, 31,1,   304128, 0xea18c80e
+0, 32, 32,1,   304128, 0x5290813c
+0, 33, 33,1,   304128, 0xc8909e8c
+0, 34, 34,1,   304128, 0xf9c985f9
+0, 35, 35,1,   304128, 0xcdf626f0
+0, 36, 36,1,   304128, 0xc517d607
+0, 37, 37,1,   304128, 0xe765923b
+0, 38, 38,1,   304128, 0xf12fa5f6
+0, 39, 39,1,   304128, 0x04bf7f2b
+0, 40, 40,1,   304128, 0x695762d6
+0, 41, 41,1,   304128, 0xb1bf1983
+0, 42, 42,1,   304128, 0x654dc4b2
+0, 43, 43,1,   304128, 0x161854b6
+0, 44, 44,1,   304128, 0x3d56b1c1
+0, 45, 45,1,   304128, 0xa16f54a8
+0, 46, 46,1,   304128, 0x02fffb2f
+0, 47, 47,1,   304128, 0x04bddde4
+0, 48, 48,1,   304128, 0xf5687316
+0, 49, 49,1,   304128, 0x2a9a7dc6
-- 
1.8.3.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".

Re: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_unsharp: add 10bit support

2020-10-29 Thread Linjie Fu
On Fri, Oct 30, 2020 at 9:18 AM  wrote:

> On Thu, Oct 29, 2020 at 09:09:00PM +0800, Linjie Fu wrote:
> > On Thu, Oct 29, 2020 at 7:16 PM  wrote:
> >
> > > From: Limin Wang 
> > >
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  libavfilter/unsharp.h|   3 +
> > >  libavfilter/vf_unsharp.c | 162
> > > +--
> > >  2 files changed, 90 insertions(+), 75 deletions(-)
> > >
> > > diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
> > > index a60b30f..253e32d 100644
> > > --- a/libavfilter/unsharp.h
> > > +++ b/libavfilter/unsharp.h
> > > @@ -48,9 +48,12 @@ typedef struct UnsharpContext {
> > >  UnsharpFilterParam luma;   ///< luma parameters (width, height,
> > > amount)
> > >  UnsharpFilterParam chroma; ///< chroma parameters (width, height,
> > > amount)
> > >  int hsub, vsub;
> > > +int bitdepth;
> > > +int bps;
> > >  int nb_threads;
> > >  int opencl;
> > >  int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame
> > > *out);
> > > +int (* unsharp_slice)(AVFilterContext *ctx, void *arg, int jobnr,
> int
> > > nb_jobs);
> > >
> >
> > Just curious:
> > Any special reason for the function moving?
>
> Sorry, I'm not clear about your question.

>
> >
> > >  } UnsharpContext;
> >
> >
> > >  #endif /* AVFILTER_UNSHARP_H */
> > > diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
> > > index 7b430b6..416bf1c 100644
> > > --- a/libavfilter/vf_unsharp.c
> > > +++ b/libavfilter/vf_unsharp.c
> > > @@ -57,81 +57,90 @@ typedef struct TheadData {
> > >  int height;
> > >  } ThreadData;
> > >
> > > -static int unsharp_slice(AVFilterContext *ctx, void *arg, int jobnr,
> int
> > > nb_jobs)
> > > -{
> > > -ThreadData *td = arg;
> > > -UnsharpFilterParam *fp = td->fp;
> > > -uint32_t **sc = fp->sc;
> > > -uint32_t *sr = fp->sr;
> > > -const uint8_t *src2 = NULL;  //silence a warning
> > > -const int amount = fp->amount;
> > > -const int steps_x = fp->steps_x;
> > > -const int steps_y = fp->steps_y;
> > > -const int scalebits = fp->scalebits;
> > > -const int32_t halfscale = fp->halfscale;
> > > -
> > > -uint8_t *dst = td->dst;
> > > -const uint8_t *src = td->src;
> > > -const int dst_stride = td->dst_stride;
> > > -const int src_stride = td->src_stride;
> > > -const int width = td->width;
> > > -const int height = td->height;
> > > -const int sc_offset = jobnr * 2 * steps_y;
> > > -const int sr_offset = jobnr * (MAX_MATRIX_SIZE - 1);
> > > -const int slice_start = (height * jobnr) / nb_jobs;
> > > -const int slice_end = (height * (jobnr+1)) / nb_jobs;
> > > -
> > > -int32_t res;
> > > -int x, y, z;
> > > -uint32_t tmp1, tmp2;
> > > -
> > > -if (!amount) {
> > > -av_image_copy_plane(dst + slice_start * dst_stride,
> dst_stride,
> > > -src + slice_start * src_stride,
> src_stride,
> > > -width, slice_end - slice_start);
> > > -return 0;
> > > -}
> > > -
> > > -for (y = 0; y < 2 * steps_y; y++)
> > > -memset(sc[sc_offset + y], 0, sizeof(sc[y][0]) * (width + 2 *
> > > steps_x));
> > > -
> > > -// if this is not the first tile, we start from (slice_start -
> > > steps_y),
> > > -// so we can get smooth result at slice boundary
> > > -if (slice_start > steps_y) {
> > > -src += (slice_start - steps_y) * src_stride;
> > > -dst += (slice_start - steps_y) * dst_stride;
> > > -}
> > > -
> > > -for (y = -steps_y + slice_start; y < steps_y + slice_end; y++) {
> > > -if (y < height)
> > > -src2 = src;
> > > -
> > > -memset(sr + sr_offset, 0, sizeof(sr[0]) * (2 * steps_x - 1));
> > > -for (x = -steps_x; x < width + steps_x; x++) {
> > > -tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] :
> > > src2[x];
> > > -for (z = 0; z < steps_x * 2; z += 2) {
> > > -tmp2 = sr[sr_offset + z + 0] + tmp1; sr[sr_offset + z
> +
> > > 0] = tmp1;
> > > -tmp1 = sr[sr_offset + z + 1] + tmp2; sr[sr_offset + z
> +
> > > 1] = tmp2;
> > > -}
> > > -for (z = 0; z < steps_y * 2; z += 2) {
> > > -tmp2 = sc[sc_offset + z + 0][x + steps_x] + tmp1;
> > > sc[sc_offset + z + 0][x + steps_x] = tmp1;
> > > -tmp1 = sc[sc_offset + z + 1][x + steps_x] + tmp2;
> > > sc[sc_offset + z + 1][x + steps_x] = tmp2;
> > > -}
> > > -if (x >= steps_x && y >= (steps_y + slice_start)) {
> > > -const uint8_t *srx = src - steps_y * src_stride + x -
> > > steps_x;
> > > -uint8_t *dsx   = dst - steps_y * dst_stride + x -
> > > steps_x;
> > > -
> > > -res = (int32_t)*srx + int32_t) * srx -
> > > (int32_t)((tmp1 + halfscale) >> scalebits)) * amount) >> 16);
> > > -*dsx = av_clip_uint8(res);
> > > -}
> > > -