[FFmpeg-devel] [PATCH v2] avfilter: add overlay vaapi filter

2020-01-05 Thread Xinpeng Sun
Overlay one video on the top of another.

It takes two inputs and has one output. The first input is the "main" video on 
which the
second input is overlaid. This filter requires same memory layout for all the 
inputs.

An example command to use this filter to overlay an image LOGO at the top-left 
corner of
the INPUT video and both inputs are yuv420p format:
FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format 
vaapi \
-i INPUT -i LOGO -filter_complex \
"[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_vaapi, 
hwdownload" \
OUTPUT

Signed-off-by: Xinpeng Sun 
Signed-off-by: Zachary Zhou 
---
 configure  |   3 +
 doc/filters.texi   |  51 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_overlay_vaapi.c | 426 +
 5 files changed, 482 insertions(+)
 create mode 100644 libavfilter/vf_overlay_vaapi.c

diff --git a/configure b/configure
index 965b4c71b8..374a4316c9 100755
--- a/configure
+++ b/configure
@@ -3526,6 +3526,7 @@ openclsrc_filter_deps="opencl"
 overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
+overlay_vaapi_filter_deps="vaapi"
 owdenoise_filter_deps="gpl"
 pan_filter_deps="swresample"
 perspective_filter_deps="gpl"
@@ -3583,6 +3584,7 @@ tonemap_vaapi_filter_deps="vaapi 
VAProcPipelineParameterBuffer_output_hdr_metada
 tonemap_opencl_filter_deps="opencl const_nan"
 transpose_opencl_filter_deps="opencl"
 transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
+overlay_vaapi_filter_deps="vaapi VAProcPipelineCaps_blend_flags"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
@@ -6586,6 +6588,7 @@ if enabled vaapi; then
 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" "VAProcPipelineCaps" rotation_flags
+check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" blend_flags
 check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
diff --git a/doc/filters.texi b/doc/filters.texi
index ba00989987..2d69fa0363 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21124,6 +21124,57 @@ To enable compilation of these filters you need to 
configure FFmpeg with
 
 To use vaapi filters, you need to setup the vaapi device correctly. For more 
information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/VAAPI}
 
+@section overlay_vaapi
+
+Overlay one video on the top of another.
+
+It takes two inputs and has one output. The first input is the "main" video on 
which the second input is overlaid.
+This filter requires same memory layout for all the inputs. So, format 
conversion may be needed.
+
+The filter accepts the following options:
+
+@table @option
+
+@item x
+Set the x coordinate of the overlaid video on the main video.
+Default value is @code{0}.
+
+@item y
+Set the x coordinate of the overlaid video on the main video.
+Default value is @code{0}.
+
+@item w
+Set the width of the overlaid video on the main video.
+Default value is the width of input overlay video.
+
+@item h
+Set the height of the overlaid video on the main video.
+Default value is the height of input overlay video.
+
+@item alpha
+Set blocking detection thresholds. Allowed range is 0.0 to 1.0, it
+requires an input video with alpha channel.
+Default value is @code{0.0}.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Overlay an image LOGO at the top-left corner of the INPUT video. Both inputs 
are yuv420p format.
+@example
+-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p, 
hwupload[b], [a][b]overlay_vaapi" OUTPUT
+@end example
+@item
+Overlay an image LOGO at the offset (200, 100) from the top-left corner of the 
INPUT video.
+The inputs have same memory layout for color channels, the overlay has 
additional alpha plane, like INPUT is yuv420p, and the LOGO is yuva420p.
+@example
+-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, 
hwupload[b], [a][b]overlay_vaapi=x=200:y=100:w=400:h=300:alpha=1.0, hwdownload, 
format=nv12" OUTPUT
+@end example
+
+@end itemize
+
 @section tonemap_vappi
 
 Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with 
tone-mapping.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8b8a5bd535..cc8980e680 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -322,6 +322,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)+= 
vf_overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
 OBJS-$

Re: [FFmpeg-devel] [PATCH V4 1/2] libswscale/x86/yuv2rgb: Change inline assembly into nasm code

2020-01-05 Thread Fu, Ting


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Friday, January 3, 2020 04:36 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V4 1/2] libswscale/x86/yuv2rgb: Change
> inline assembly into nasm code
> 
> On Fri, Jan 03, 2020 at 06:59:28AM +, Fu, Ting wrote:
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Michael Niedermayer
> > > Sent: Friday, December 27, 2019 07:38 PM
> > > To: FFmpeg development discussions and patches
> > > 
> > > Subject: Re: [FFmpeg-devel] [PATCH V4 1/2] libswscale/x86/yuv2rgb:
> > > Change inline assembly into nasm code
> > >
> > > On Thu, Dec 19, 2019 at 11:35:51AM +0800, Ting Fu wrote:
> > > > Tested using this command:
> > > > ./ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \
> > > > -vcodec rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null
> > > >
> > >
> > > > The fps increase from 151 to 389 on my local machine.
> > >
> > > Thats nice but why is there such a difference from changing the way
> > > the code is assembled ?
> > > This should definitly be explained more detailedly in the commit
> > > message
> > >
> > Hi, Michael
> >
> > The fps increasing means mmx compared to C code, not inline compared nasm
> one. I will remove it from the commit message next patch version.
> 
> please test apples against apples, a benchmark of the inline vs NASM code
> certainly cannot hurt. Testing unoptimized vs new optimized code is not
> interresting. Testing old optimized vs new optimized code is interresting
> 

Hi Michael,
As I tested, the nasm-style code is just has the same performance with inline 
assembly, which is 352 fps this time.
So, I just remove it from the commit.

> 
> >
> > >
> > > >
> > > > Signed-off-by: Ting Fu 
> > > > ---
> > > >  libswscale/x86/Makefile   |   1 +
> > > >  libswscale/x86/swscale.c  |  16 +-
> > > >  libswscale/x86/yuv2rgb.c  |  81 +++---
> > > >  libswscale/x86/yuv2rgb_template.c | 441 ++
> > > >  libswscale/x86/yuv_2_rgb.asm  | 270 ++
> > > >  5 files changed, 395 insertions(+), 414 deletions(-)  create mode
[...]
> > >
> > > i would expect EXTERNAL_MMXEXT to imply EXTERNAL_MMX
> > >
> >
> > I was thinking the mmx-only processor. Under this circumstance, the mmx-
> only processor will not be accelerated. Should that be OK? Or it means I will 
> be
> OK for not care much about old mmx-only processor in following patches?
> 
> no
> If MMXEXT implies MMX then MMX == (MMX || MMXEXT)
> 

Modified in new patch v5.

Thank you
Ting Fu

> [...]
___
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 2/2] libswscale/x86/yuv2rgb: add ssse3 version

2020-01-05 Thread Ting Fu
Tested using this command:
/ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \
-vcodec rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null

The fps increase from 389 to 640 on my local machine.

Signed-off-by: Ting Fu 
---
 libswscale/x86/yuv2rgb.c  |   7 +-
 libswscale/x86/yuv2rgb_template.c |  58 +++-
 libswscale/x86/yuv_2_rgb.asm  | 145 ++
 3 files changed, 191 insertions(+), 19 deletions(-)

diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index f3d2bb526e..7015266a7e 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -61,13 +61,18 @@ DECLARE_ASM_CONST(8, uint64_t, pb_07) = 
0x0707070707070707ULL;
 #define COMPILE_TEMPLATE_MMXEXT 1
 #endif /* HAVE_MMXEXT */
 
+//SSSE3 versions
+#if HAVE_SSSE3
+#define COMPILE_TEMPLATE_SSSE3 1
+#endif
+
 #include "yuv2rgb_template.c"
 
 av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
 {
 int cpu_flags = av_get_cpu_flags();
 
-if (EXTERNAL_MMX(cpu_flags)) {
+if (EXTERNAL_MMX(cpu_flags) || EXTERNAL_SSSE3(cpu_flags)) {
 switch (c->dstFormat) {
 case AV_PIX_FMT_RGB32:
 if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
diff --git a/libswscale/x86/yuv2rgb_template.c 
b/libswscale/x86/yuv2rgb_template.c
index e67a85df33..ceaa6dea32 100644
--- a/libswscale/x86/yuv2rgb_template.c
+++ b/libswscale/x86/yuv2rgb_template.c
@@ -40,6 +40,30 @@
 const uint8_t *pv = src[2] +   (y >> vshift) * srcStride[2]; \
 x86_reg index = -h_size / 2; \
 
+extern void ff_yuv_420_rgb24_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuv_420_bgr24_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuv_420_rgb15_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuv_420_rgb16_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuv_420_rgb32_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuv_420_bgr32_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+   const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+   const uint8_t *py_2index);
+extern void ff_yuva_420_rgb32_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+const uint8_t *py_2index, const uint8_t 
*pa_2index);
+extern void ff_yuva_420_bgr32_ssse3(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
+const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
+const uint8_t *py_2index, const uint8_t 
*pa_2index);
 extern void ff_yuv_420_rgb24_mmxext(x86_reg index, uint8_t *image, const 
uint8_t *pu_index,
 const uint8_t *pv_index, const uint64_t 
*pointer_c_dither,
 const uint8_t *py_2index);
@@ -84,7 +108,12 @@ static int yuv420_rgb15(SwsContext *c, const uint8_t *src[],
 c->greenDither = ff_dither8[y   & 1];
 c->redDither   = ff_dither8[(y + 1) & 1];
 #endif
+
+#if COMPILE_TEMPLATE_SSSE3
+ff_yuv_420_rgb15_ssse3(index, image, pu - index, pv - index, 
&(c->redDither), py - 2 * index);
+#else
 ff_yuv_420_rgb15_mmx(index, image, pu - index, pv - index, 
&(c->redDither), py - 2 * index);
+#endif
 }
 return srcSliceH;
 }
@@ -102,7 +131,12 @@ static int yuv420_rgb16(SwsContext *c, const uint8_t 
*src[],
 c->greenDither = ff_dither4[y   & 1];
 c->redDither   = ff_dither8[(y + 1) & 1];
 #endif
+
+#if COMPILE_TEMPLATE_SSSE3
+ff_yuv_420_rgb16_ssse3(index, image, pu - index, pv - index, 
&(c->redDither), py - 2 * index);
+#else
 ff_yuv_420_rgb16_mmx(index, image, pu - index, pv - index, 
&(c->redDither), py - 2 * index);
+#endif
 }
 return srcSliceH;
 }
@@ -115,7 +149,9 @@ static int yuv420_rgb24(SwsContext *c, const uint8_t *src[],
 int y, h_size, vshift;
 YUV2RGB_LOOP(3)
 
-#if COMPILE_TEMPLATE_MMXEXT
+#if COMPILE_TEMP

[FFmpeg-devel] [PATCH V5 1/2] libswscale/x86/yuv2rgb: Change inline assembly into nasm code

2020-01-05 Thread Ting Fu
Signed-off-by: Ting Fu 
---
 libswscale/x86/Makefile   |   1 +
 libswscale/x86/swscale.c  |  16 +-
 libswscale/x86/yuv2rgb.c  |  81 +++---
 libswscale/x86/yuv2rgb_template.c | 441 ++
 libswscale/x86/yuv_2_rgb.asm  | 270 ++
 5 files changed, 395 insertions(+), 414 deletions(-)
 create mode 100644 libswscale/x86/yuv_2_rgb.asm

diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile
index f317d5dd9b..831d5359aa 100644
--- a/libswscale/x86/Makefile
+++ b/libswscale/x86/Makefile
@@ -12,3 +12,4 @@ X86ASM-OBJS += x86/input.o
  \
x86/output.o \
x86/scale.o  \
x86/rgb_2_rgb.o  \
+   x86/yuv_2_rgb.o  \
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 0eed4f18d5..e9d474a1e8 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -29,6 +29,14 @@
 #include "libavutil/cpu.h"
 #include "libavutil/pixdesc.h"
 
+const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
+0x0103010301030103LL,
+0x0200020002000200LL,};
+
+const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
+0x0602060206020602LL,
+0x0004000400040004LL,};
+
 #if HAVE_INLINE_ASM
 
 #define DITHER1XBPP
@@ -38,14 +46,6 @@ DECLARE_ASM_CONST(8, uint64_t, bFC)=   
0xFCFCFCFCFCFCFCFCLL;
 DECLARE_ASM_CONST(8, uint64_t, w10)=   0x0010001000100010LL;
 DECLARE_ASM_CONST(8, uint64_t, w02)=   0x0002000200020002LL;
 
-const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
-0x0103010301030103LL,
-0x0200020002000200LL,};
-
-const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
-0x0602060206020602LL,
-0x0004000400040004LL,};
-
 DECLARE_ASM_CONST(8, uint64_t, b16Mask)=   0x001F001F001F001FLL;
 DECLARE_ASM_CONST(8, uint64_t, g16Mask)=   0x07E007E007E007E0LL;
 DECLARE_ASM_CONST(8, uint64_t, r16Mask)=   0xF800F800F800F800LL;
diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index 5e2f77c20f..f3d2bb526e 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -37,7 +37,7 @@
 #include "libavutil/x86/cpu.h"
 #include "libavutil/cpu.h"
 
-#if HAVE_INLINE_ASM
+#if HAVE_X86ASM
 
 #define DITHER1XBPP // only for MMX
 
@@ -50,70 +50,51 @@ DECLARE_ASM_CONST(8, uint64_t, pb_03) = 
0x0303030303030303ULL;
 DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
 
 //MMX versions
-#if HAVE_MMX_INLINE && HAVE_6REGS
-#undef RENAME
+#if HAVE_MMX
 #undef COMPILE_TEMPLATE_MMXEXT
 #define COMPILE_TEMPLATE_MMXEXT 0
-#define RENAME(a) a ## _mmx
-#include "yuv2rgb_template.c"
-#endif /* HAVE_MMX_INLINE && HAVE_6REGS */
+#endif /* HAVE_MMX */
 
 // MMXEXT versions
-#if HAVE_MMXEXT_INLINE && HAVE_6REGS
-#undef RENAME
+#if HAVE_MMXEXT
 #undef COMPILE_TEMPLATE_MMXEXT
 #define COMPILE_TEMPLATE_MMXEXT 1
-#define RENAME(a) a ## _mmxext
-#include "yuv2rgb_template.c"
-#endif /* HAVE_MMXEXT_INLINE && HAVE_6REGS */
+#endif /* HAVE_MMXEXT */
 
-#endif /* HAVE_INLINE_ASM */
+#include "yuv2rgb_template.c"
 
 av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
 {
-#if HAVE_MMX_INLINE && HAVE_6REGS
 int cpu_flags = av_get_cpu_flags();
 
-#if HAVE_MMXEXT_INLINE
-if (INLINE_MMXEXT(cpu_flags)) {
-switch (c->dstFormat) {
-case AV_PIX_FMT_RGB24:
-return yuv420_rgb24_mmxext;
-case AV_PIX_FMT_BGR24:
-return yuv420_bgr24_mmxext;
-}
-}
-#endif
-
-if (INLINE_MMX(cpu_flags)) {
+if (EXTERNAL_MMX(cpu_flags)) {
 switch (c->dstFormat) {
-case AV_PIX_FMT_RGB32:
-if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
-return yuva420_rgb32_mmx;
+case AV_PIX_FMT_RGB32:
+if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
+#if CONFIG_SWSCALE_ALPHA
+return yuva420_rgb32;
 #endif
-break;
-} else
-return yuv420_rgb32_mmx;
-case AV_PIX_FMT_BGR32:
-if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
-return yuva420_bgr32_mmx;
+break;
+} else
+return yuv420_rgb32;
+case AV_PIX_FMT_BGR32:
+if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
+#if CONFIG_SWSCALE_ALPHA
+return yuva420_bgr32;
 #endif
-break;
-} else
-return yuv420_bgr32_mmx;
-case AV_PIX_FMT_RGB24:
-return yuv420_rgb24_mmx;
-case AV_PIX_FMT_BGR24:
-return yuv420_bgr24_mmx;
-case AV_PIX_FMT_RGB565:
-return yuv420_rgb16_mmx;
-case AV_PIX_FMT_RGB555:
-return yuv420_rgb15_mmx;
-

Re: [FFmpeg-devel] [PATCH v2 3/5] avfilter/scale: separate exprs parse and eval

2020-01-05 Thread Gyan
Ping for the remainder of patchset.  Expression parsing and backup has 
been factorized so code duplication is minimized.


On 01-01-2020 01:12 am, Gyan Doshi wrote:

Retains parsed expressions which allows for better
error-checking and adding animation support.
---

First version was rebased incorrectly in scale_eval_dimensions

  libavfilter/scale_eval.c |  69 +-
  libavfilter/vf_scale.c   | 264 +++
  2 files changed, 246 insertions(+), 87 deletions(-)

diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c
index 6c526a97af..dfec081e15 100644
--- a/libavfilter/scale_eval.c
+++ b/libavfilter/scale_eval.c
@@ -54,46 +54,6 @@ enum var_name {
  VARS_NB
  };
  
-/**

- * This must be kept in sync with var_names so that it is always a
- * complete list of var_names with the scale2ref specific names
- * appended. scale2ref values must appear in the order they appear
- * in the var_name_scale2ref enum but also be below all of the
- * non-scale2ref specific values.
- */
-static const char *const var_names_scale2ref[] = {
-"in_w",   "iw",
-"in_h",   "ih",
-"out_w",  "ow",
-"out_h",  "oh",
-"a",
-"sar",
-"dar",
-"hsub",
-"vsub",
-"ohsub",
-"ovsub",
-"main_w",
-"main_h",
-"main_a",
-"main_sar",
-"main_dar", "mdar",
-"main_hsub",
-"main_vsub",
-NULL
-};
-
-enum var_name_scale2ref {
-VAR_S2R_MAIN_W,
-VAR_S2R_MAIN_H,
-VAR_S2R_MAIN_A,
-VAR_S2R_MAIN_SAR,
-VAR_S2R_MAIN_DAR, VAR_S2R_MDAR,
-VAR_S2R_MAIN_HSUB,
-VAR_S2R_MAIN_VSUB,
-VARS_S2R_NB
-};
-
  int ff_scale_eval_dimensions(void *log_ctx,
  const char *w_expr, const char *h_expr,
  AVFilterLink *inlink, AVFilterLink *outlink,
@@ -104,16 +64,7 @@ int ff_scale_eval_dimensions(void *log_ctx,
  const char *expr;
  int eval_w, eval_h;
  int ret;
-const char scale2ref = outlink->src->nb_inputs == 2 && 
outlink->src->inputs[1] == inlink;
-double var_values[VARS_NB + VARS_S2R_NB], res;
-const AVPixFmtDescriptor *main_desc;
-const AVFilterLink *main_link;
-const char *const *names = scale2ref ? var_names_scale2ref : var_names;
-
-if (scale2ref) {
-main_link = outlink->src->inputs[0];
-main_desc = av_pix_fmt_desc_get(main_link->format);
-}
+double var_values[VARS_NB], res;
  
  var_values[VAR_IN_W]  = var_values[VAR_IW] = inlink->w;

  var_values[VAR_IN_H]  = var_values[VAR_IH] = inlink->h;
@@ -128,32 +79,20 @@ int ff_scale_eval_dimensions(void *log_ctx,
  var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
  var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
  
-if (scale2ref) {

-var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w;
-var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h;
-var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w / 
main_link->h;
-var_values[VARS_NB + VAR_S2R_MAIN_SAR] = 
main_link->sample_aspect_ratio.num ?
-(double) main_link->sample_aspect_ratio.num / 
main_link->sample_aspect_ratio.den : 1;
-var_values[VARS_NB + VAR_S2R_MAIN_DAR] = var_values[VARS_NB + 
VAR_S2R_MDAR] =
-var_values[VARS_NB + VAR_S2R_MAIN_A] * var_values[VARS_NB + 
VAR_S2R_MAIN_SAR];
-var_values[VARS_NB + VAR_S2R_MAIN_HSUB] = 1 << 
main_desc->log2_chroma_w;
-var_values[VARS_NB + VAR_S2R_MAIN_VSUB] = 1 << 
main_desc->log2_chroma_h;
-}
-
  /* evaluate width and height */
  av_expr_parse_and_eval(&res, (expr = w_expr),
-   names, var_values,
+   var_names, var_values,
 NULL, NULL, NULL, NULL, NULL, 0, log_ctx);
  eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = (int) res == 0 ? 
inlink->w : (int) res;
  
  if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr),

-  names, var_values,
+  var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) 
< 0)
  goto fail;
  eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = (int) res == 0 ? 
inlink->h : (int) res;
  /* evaluate again the width, as it may depend on the output height */
  if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr),
-  names, var_values,
+  var_names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) 
< 0)
  goto fail;
  eval_w = (int) res == 0 ? inlink->w : (int) res;
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 5a375fac5d..582b34ce09 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -32,6 +32,7 @@
  #include "scale_eval.h"
  #include "video.h"
  #include "libavutil/avstring.h"
+#include "libavutil/eval.h"
  #include "libavutil/internal.h"
  #include "libavutil/mathematics.h

Re: [FFmpeg-devel] [PATCH v1] doc/filters: add missing entry for the showinfo

2020-01-05 Thread Gyan



On 06-01-2020 07:00 am, lance.lmw...@gmail.com wrote:

From: Limin Wang 

Signed-off-by: Limin Wang 
---
  doc/filters.texi | 9 +
  1 file changed, 9 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6cbbe88..b3574e6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16737,6 +16737,15 @@ The Adler-32 checksum (printed in hexadecimal) of all 
the planes of the input fr
  @item plane_checksum
  The Adler-32 checksum (printed in hexadecimal) of each plane of the input 
frame,
  expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
+
+@item mean
+The mean value of each plane of the input frame, expressed in the form
+"[@var{mean0} @var{mean1} @var{mean2} @var{mean3}]".
+
+@item stdev
+The standard deviation value of each plane of the input frame, expressed in 
the form
+"[@var{stdev0} @var{stdev1} @var{stdev2} @var{stdev3}]".
+
  @end table
  
  @section showpalette


Pushed as 1e3f4b5f19323321ebca68bd7c1dd496933377a3

Thanks,
Gyan
___
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/vf_gblur: fix divide by zero

2020-01-05 Thread zhilizhao


> On Jan 4, 2020, at 9:43 PM, zhilizhao  wrote:
> 
> 
> 
>> On Jan 4, 2020, at 9:09 PM, Paul B Mahol > > wrote:
>> 
>> On 1/4/20, zhilizhao > > wrote:
>>> 
>>> 
 On Jan 4, 2020, at 7:04 PM, Paul B Mahol >>> > wrote:
 
 I do not like this “fix"
>>> 
>>> What do you suggest?  It’s numerical unstable for small sigma.
>> 
>> For small sigma return frames unchanged as it currently does.
> 
> Then which valud should be selected as the threshold:
> 
> 1. A value from which it becomes unstable (it’s not fun to figure it out).
> 
> 2. A reasonable (and random) selected value like 0.25
> 

For function set_params:

static void set_params(float sigma, int steps, float *postscale, float 
*boundaryscale, float *nu)
{
double dnu, lambda;

lambda = (sigma * sigma) / (2.0 * steps);
dnu = (1.0 + 2.0 * lambda - sqrt(1.0 + 4.0 * lambda)) / (2.0 * lambda);
*postscale = pow(dnu / lambda, steps);
*boundaryscale = 1.0 / (1.0 - dnu);
*nu = (float)dnu;
}

1. Check sigma against 0 is not enough, since lambda can be 0 for non-zero sigma
2. Check lambda against 0 is not enough, we should avoid dividing by small 
value, like 'dnu / lambda’.

So there should have a dead-zone for sigma.

> 
>> 
>>> 
 
 On 1/4/20, quinkbl...@foxmail.com  wrote:
> From: Zhao Zhili 
> 
> ./ffmpeg -i ~/Pictures/test.jpg -vf 'gblur=sigma=0' -f null -
> ...
> src/libavfilter/vf_gblur.c:260:59: runtime error: division by zero
> src/libavfilter/vf_gblur.c:261:26: runtime error: division by zero
> ---
> libavfilter/vf_gblur.c | 12 +---
> 1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
> index 2e587f6a0a..e057937fb7 100644
> --- a/libavfilter/vf_gblur.c
> +++ b/libavfilter/vf_gblur.c
> @@ -37,11 +37,17 @@
> #define OFFSET(x) offsetof(GBlurContext, x)
> #define FLAGS
> AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
> 
> +/* Consider the three-sigma rule, for minimum radius of 1 sigma should
> not
> + * be smaller than 1/3. Relax it to 0.25 if the user want to try.
> + */
> +#define SIGMA_MIN   0.25
> +#define SIGMA_MAX   1024.0
> +
> static const AVOption gblur_options[] = {
> -{ "sigma",  "set sigma",OFFSET(sigma),
> AV_OPT_TYPE_FLOAT,
> {.dbl=0.5}, 0.0, 1024, FLAGS },
> +{ "sigma",  "set sigma",OFFSET(sigma),
> AV_OPT_TYPE_FLOAT,
> {.dbl=0.5},  SIGMA_MIN, SIGMA_MAX, FLAGS },
>   { "steps",  "set number of steps",  OFFSET(steps),  AV_OPT_TYPE_INT,
> {.i64=1}, 1,6, FLAGS },
>   { "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,
> {.i64=0xF},   0,  0xF, FLAGS },
> -{ "sigmaV", "set vertical sigma",   OFFSET(sigmaV),
> AV_OPT_TYPE_FLOAT,
> {.dbl=-1},   -1, 1024, FLAGS },
> +{ "sigmaV", "set vertical sigma",   OFFSET(sigmaV),
> AV_OPT_TYPE_FLOAT,
> {.dbl=-1},   -1, SIGMA_MAX, FLAGS },
>   { NULL }
> };
> 
> @@ -244,7 +250,7 @@ static int config_input(AVFilterLink *inlink)
>   if (!s->buffer)
>   return AVERROR(ENOMEM);
> 
> -if (s->sigmaV < 0) {
> +if (s->sigmaV < SIGMA_MIN) {
>   s->sigmaV = s->sigma;
>   }
>   ff_gblur_init(s);
> --
> 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".
 ___
 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 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 

Re: [FFmpeg-devel] [PATCH v2 1/2] lavc/h2645_parse: Don't automatically remove nuh_layer_id > 0 packets

2020-01-05 Thread Andriy Gelman
On Fri, 13. Dec 22:18, Andriy Gelman wrote:
> On Thu, 05. Dec 22:15, Andriy Gelman wrote:
> > From: Andriy Gelman 
> > 
> > HEVC standard supports multi-layer streams (ITU-T H.265 02/2018 Annex
> > F). Each NAL unit belongs to a particular layer defined by nuh_layer_id
> > in the header.
> > 
> > Currently, all NAL units that do not belong to a base layer are
> > automatically removed in ff_h2645_packet_split(). Some data may
> > therefore be lost when future filters/decoders are designed to support
> > multi-layer streams.
> > 
> > A better approach is to forward nuh_layer_id > 0 packets and let blocks
> > down the chain decide how to process them. The condition to remove
> > packets has been moved to hevcdec and cbs.
> > 
> > Found-by: Andreas Rheinhardt 
> > Signed-off-by: Andriy Gelman 
> > ---
> >  libavcodec/cbs_h2645.c   | 3 +++
> >  libavcodec/h2645_parse.c | 7 +++
> >  libavcodec/h2645_parse.h | 5 +
> >  libavcodec/hevc_parse.c  | 2 ++
> >  libavcodec/hevc_parser.c | 3 +++
> >  libavcodec/hevcdec.c | 2 +-
> >  6 files changed, 17 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index 88fa0029cd6..ae32078f246 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -565,6 +565,9 @@ static int 
> > cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
> >  AVBufferRef *ref;
> >  size_t size = nal->size;
> >  
> > +if (nal->nuh_layer_id > 0)
> > +continue;
> > +
> >  // Remove trailing zeroes.
> >  while (size > 0 && nal->data[size - 1] == 0)
> >  --size;
> > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> > index 4808f79a67f..0f3343004f9 100644
> > --- a/libavcodec/h2645_parse.c
> > +++ b/libavcodec/h2645_parse.c
> > @@ -292,23 +292,22 @@ static int get_bit_length(H2645NAL *nal, int 
> > skip_trailing_zeros)
> >  static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
> >  {
> >  GetBitContext *gb = &nal->gb;
> > -int nuh_layer_id;
> >  
> >  if (get_bits1(gb) != 0)
> >  return AVERROR_INVALIDDATA;
> >  
> >  nal->type = get_bits(gb, 6);
> >  
> > -nuh_layer_id   = get_bits(gb, 6);
> > +nal->nuh_layer_id = get_bits(gb, 6);
> >  nal->temporal_id = get_bits(gb, 3) - 1;
> >  if (nal->temporal_id < 0)
> >  return AVERROR_INVALIDDATA;
> >  
> >  av_log(logctx, AV_LOG_DEBUG,
> > "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
> > -   nal->type, hevc_nal_unit_name(nal->type), nuh_layer_id, 
> > nal->temporal_id);
> > +   nal->type, hevc_nal_unit_name(nal->type), nal->nuh_layer_id, 
> > nal->temporal_id);
> >  
> > -return nuh_layer_id == 0;
> > +return 1;
> >  }
> >  
> >  static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
> > diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
> > index 2acf882d3da..3e47f86c53b 100644
> > --- a/libavcodec/h2645_parse.h
> > +++ b/libavcodec/h2645_parse.h
> > @@ -56,6 +56,11 @@ typedef struct H2645NAL {
> >   */
> >  int temporal_id;
> >  
> > +/*
> > + * HEVC only, identifier of layer to which nal unit belongs
> > + */
> > +int nuh_layer_id;
> > +
> >  int skipped_bytes;
> >  int skipped_bytes_pos_size;
> >  int *skipped_bytes_pos;
> > diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
> > index dddb293df64..29dfd479f38 100644
> > --- a/libavcodec/hevc_parse.c
> > +++ b/libavcodec/hevc_parse.c
> > @@ -37,6 +37,8 @@ static int hevc_decode_nal_units(const uint8_t *buf, int 
> > buf_size, HEVCParamSets
> >  
> >  for (i = 0; i < pkt.nb_nals; i++) {
> >  H2645NAL *nal = &pkt.nals[i];
> > +if (nal->nuh_layer_id > 0)
> > +continue;
> >  
> >  /* ignore everything except parameter sets and VCL NALUs */
> >  switch (nal->type) {
> > diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
> > index b444b999550..87d5dba4f5e 100644
> > --- a/libavcodec/hevc_parser.c
> > +++ b/libavcodec/hevc_parser.c
> > @@ -202,6 +202,9 @@ static int parse_nal_units(AVCodecParserContext *s, 
> > const uint8_t *buf,
> >  H2645NAL *nal = &ctx->pkt.nals[i];
> >  GetBitContext *gb = &nal->gb;
> >  
> > +if (nal->nuh_layer_id > 0)
> > +continue;
> > +
> >  switch (nal->type) {
> >  case HEVC_NAL_VPS:
> >  ff_hevc_decode_nal_vps(gb, avctx, ps);
> > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> > index 8f1c162acee..bcd8e67944a 100644
> > --- a/libavcodec/hevcdec.c
> > +++ b/libavcodec/hevcdec.c
> > @@ -3077,7 +3077,7 @@ static int decode_nal_units(HEVCContext *s, const 
> > uint8_t *buf, int length)
> >  
> >  if (s->avctx->skip_frame >= AVDISCARD_ALL ||
> >  (s->avctx->skip_frame >= AVDISCARD_NONREF
> > -&& ff_hevc_nal_is_nonref(nal->type)))
> > +&& ff_hevc_nal_is_nonref(nal->type))

Re: [FFmpeg-devel] [PATCH] CDToons decoder

2020-01-05 Thread Carl Eugen Hoyos
Am So., 5. Jan. 2020 um 22:57 Uhr schrieb Alyssa Milburn :

> diff --git a/libavformat/riff.c b/libavformat/riff.c
> index c73f6e9db0..560a3aa208 100644
> --- a/libavformat/riff.c
> +++ b/libavformat/riff.c
> @@ -491,6 +491,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
>  { AV_CODEC_ID_IMM5, MKTAG('I', 'M', 'M', '5') },
>  { AV_CODEC_ID_MVDV, MKTAG('M', 'V', 'D', 'V') },
>  { AV_CODEC_ID_MVHA, MKTAG('M', 'V', 'H', 'A') },
> +{ AV_CODEC_ID_CDTOONS,  MKTAG('Q', 'k', 'B', 'k') },
>  { AV_CODEC_ID_NONE, 0 }

Does the codec really exist in avi?
I ask because the sample files you provide are mov.
If no avi files exist, please remove above hunk.

And please put your name in the copyright line as
suggested by James.

Thank you, 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 V1 04/12] lavc/libvpxenc: fix memory leak after av_dict_parse_string fail

2020-01-05 Thread myp...@gmail.com
On Sat, Jan 4, 2020 at 7:34 AM James Zern
 wrote:
>
> Hi,
>
> On Tue, Dec 31, 2019 at 9:21 PM Jun Zhao  wrote:
> >
> > From: Jun Zhao 
> >
> > In case of failure, all the successfully set entries are stored in
> > *pm. We need to manually free the created dictionary to avoid
> > memory leak.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  libavcodec/libvpxenc.c |3 +--
> >  1 files changed, 1 insertions(+), 2 deletions(-)
> >
>
> I think this is unnecessary after:
> 9ac1066dc6 avcodec/libvpxenc: use AV_OPT_TYPE_DICT for ts-parameters
Yes, so rebase the patchset with version 2 for other part, 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".

Re: [FFmpeg-devel] [PATCH v3] avfilter/vf_showinfo: Fix erroneous results for mean and stdev with pixel bits >8

2020-01-05 Thread Limin Wang

ping, please review it. I'll add packed format support after that.

On Fri, Nov 29, 2019 at 07:28:23PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Have tested with be and le pixel format on be and le system for >8bit.
> System:
> lmwang@ubuntu:~/ffmpeg.git.mips$ grep HAVE_BIGENDIAN config.h
> #define HAVE_BIGENDIAN 1
> ffmpeg.git git:(showinfo) ✗ grep HAVE_BIGENDIAN config.h
> #define HAVE_BIGENDIAN 0
> 
> Test result:
> 1, yuv420p
> ./ffmpeg -f lavfi  -i 
> color=black:duration=1:r=1:size=1280x720,format=yuv420p,showinfo
> Master:
> mean:[16 128 128] stdev:[0.0 0.0 0.0]
> After applied the patch:
>  mean:[16 128 128] stdev:[0.0 0.0 0.0]
> 
> 2, yuv420p10le
> ./ffmpeg -f lavfi  -i 
> color=black:duration=1:r=1:size=1280x720,format=yuv420p10le,showinfo
> Master:
> mean:[32 1 1] stdev:[32.0 1.0 1.0]
> After applied the patch:
> mean:[64 512 512] stdev:[0.0 0.0 0.0]
> 
> 3, yuv420p10be
> ./ffmpeg -f lavfi  -i 
> color=black:duration=1:r=1:size=1280x720,format=yuv420p10be,showinfo
> Master:
> mean:[32 1 1] stdev:[32.0 1.0 1.0]
> After applied the patch:
> mean:[64 512 512] stdev:[0.0 0.0 0.0]
> 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_showinfo.c | 34 +++---
>  1 file changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index 31f6b32aa4..5856722122 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -24,6 +24,7 @@
>  
>  #include 
>  
> +#include "libavutil/bswap.h"
>  #include "libavutil/adler32.h"
>  #include "libavutil/display.h"
>  #include "libavutil/imgutils.h"
> @@ -202,7 +203,7 @@ static void dump_color_property(AVFilterContext *ctx, 
> AVFrame *frame)
>  av_log(ctx, AV_LOG_INFO, "\n");
>  }
>  
> -static void update_sample_stats(const uint8_t *src, int len, int64_t *sum, 
> int64_t *sum2)
> +static void update_sample_stats_8(const uint8_t *src, int len, int64_t *sum, 
> int64_t *sum2)
>  {
>  int i;
>  
> @@ -212,6 +213,30 @@ static void update_sample_stats(const uint8_t *src, int 
> len, int64_t *sum, int64
>  }
>  }
>  
> +static void update_sample_stats_16(int be, const uint8_t *src, int len, 
> int64_t *sum, int64_t *sum2)
> +{
> +const uint16_t *src1 = (const uint16_t *)src;
> +int i;
> +
> +for (i = 0; i < len / 2; i++) {
> +if ((HAVE_BIGENDIAN && !be) || (!HAVE_BIGENDIAN && be)) {
> +*sum += av_bswap16(src1[i]);
> +*sum2 += av_bswap16(src1[i]) * av_bswap16(src1[i]);
> +} else {
> +*sum += src1[i];
> +*sum2 += src1[i] * src1[i];
> +}
> +}
> +}
> +
> +static void update_sample_stats(int depth, int be, const uint8_t *src, int 
> len, int64_t *sum, int64_t *sum2)
> +{
> +if (depth <= 8)
> +update_sample_stats_8(src, len, sum, sum2);
> +else
> +update_sample_stats_16(be, src, len, sum, sum2);
> +}
> +
>  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>  {
>  AVFilterContext *ctx = inlink->dst;
> @@ -220,12 +245,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  uint32_t plane_checksum[4] = {0}, checksum = 0;
>  int64_t sum[4] = {0}, sum2[4] = {0};
>  int32_t pixelcount[4] = {0};
> +int bitdepth = desc->comp[0].depth;
> +int be = desc->flags & AV_PIX_FMT_FLAG_BE;
>  int i, plane, vsub = desc->log2_chroma_h;
>  
>  for (plane = 0; plane < 4 && s->calculate_checksums && 
> frame->data[plane] && frame->linesize[plane]; plane++) {
>  uint8_t *data = frame->data[plane];
>  int h = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT(inlink->h, vsub) : 
> inlink->h;
>  int linesize = av_image_get_linesize(frame->format, frame->width, 
> plane);
> +int width = linesize >> (bitdepth > 8);
>  
>  if (linesize < 0)
>  return linesize;
> @@ -234,8 +262,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *frame)
>  plane_checksum[plane] = av_adler32_update(plane_checksum[plane], 
> data, linesize);
>  checksum = av_adler32_update(checksum, data, linesize);
>  
> -update_sample_stats(data, linesize, sum+plane, sum2+plane);
> -pixelcount[plane] += linesize;
> +update_sample_stats(bitdepth, be, data, linesize, sum+plane, 
> sum2+plane);
> +pixelcount[plane] += width;
>  data += frame->linesize[plane];
>  }
>  }
> -- 
> 2.21.0
> 

-- 
Thanks,
Limin Wang
___
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 v1] doc/filters: add missing entry for the showinfo

2020-01-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6cbbe88..b3574e6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16737,6 +16737,15 @@ The Adler-32 checksum (printed in hexadecimal) of all 
the planes of the input fr
 @item plane_checksum
 The Adler-32 checksum (printed in hexadecimal) of each plane of the input 
frame,
 expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
+
+@item mean
+The mean value of each plane of the input frame, expressed in the form
+"[@var{mean0} @var{mean1} @var{mean2} @var{mean3}]".
+
+@item stdev
+The standard deviation value of each plane of the input frame, expressed in 
the form
+"[@var{stdev0} @var{stdev1} @var{stdev2} @var{stdev3}]".
+
 @end table
 
 @section showpalette
-- 
2.9.5

___
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/6] avformat: remove uneeded avio_flush() calls from the end of write_header functions

2020-01-05 Thread Marton Balint



On Sun, 5 Jan 2020, Martin Storsjö wrote:


On Sun, 5 Jan 2020, Marton Balint wrote:

The IO context is flushed by libavformat/mux.c after writing the header by 
calling

avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN), so this
change should have no effect at all.

Signed-off-by: Marton Balint 


If I read avio_write_marker correctly, it won't do an implicit flush on these 
calls unless the user actually has set the s->write_data_type function 
pointer - which only is set when used by direct API users.


So for normal cases, if I read it correctly, one can't assume 
avio_write_marker implies a flush in general.


Yes, you are right, I missed that too... I believe the patch is still 
correct if I fix the commit message:


avformat: remove avio_flush() calls from the end of write_header functions

To make it consistent with other muxers.

The user can still control the generic flushing behaviour after 
write_header (same way as after packets) using the -flush_packets option, 
the default typically means to flush unless a non-streamed file output is 
used.


Therefore this change should have no adverse effect on streaming, even if 
it is assumed that the first packet has a clean buffer, so small seekbacks 
within the output buffer work even when the IO context is not seekable.


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 v2] lavc/ffv1: Properly check that the 4th and 5th quant tables are zeroes

2020-01-05 Thread Michael Niedermayer
On Sun, Jan 05, 2020 at 02:45:25PM +, Derek Buitenhuis wrote:
> Currently, the decoder checks the 128th value of the 4th quant table during
> while deriving the context on each sample, in order to speed itself up. This
> is due to relying on the behavior of FFmpeg's FFV1 encoder, in which if that
> value is zero, the entire 4th and 5th quant tables are assumed to be entirely
> zero.
> 
> This does not match the FFV1 spec, which has no such restriction, and after
> some discussion, it was decided to fix FFmpeg to abide by the spec, rather
> than change the spec.
> 
> We will now check whether the 4th and 5th quant tables are zero properly,
> by checking the 128th valye of both tables (which means they are zero due
> to the way they're coded in the bitstream).
> 
> For further context, the FFV1 issue in question is located at:
> 
> https://github.com/FFmpeg/FFV1/issues/169
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavcodec/ffv1_template.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

thx

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

The educated differ from the uneducated as much as the living from the
dead. -- 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] CDToons decoder

2020-01-05 Thread James Almer
On 1/5/2020 6:57 PM, Alyssa Milburn wrote:
> This adds a decoder for Broderbund's sprite-based QuickTime CDToons
> codec, based on the decoder I wrote for ScummVM.
> 
> A couple of samples can be found at http://noopwafel.net/cdtoons/.
> 
> Signed-off-by: Alyssa Milburn 
> ---
>  Changelog   |   1 +
>  doc/general.texi|   2 +
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/cdtoons.c| 438 
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/version.h|   2 +-
>  libavformat/isom.c  |   1 +
>  libavformat/riff.c  |   1 +
>  10 files changed, 454 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/cdtoons.c
> 
> diff --git a/Changelog b/Changelog
> index b9401aaab6..9cac485bb5 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -29,6 +29,7 @@ version :
>  - mvha decoder
>  - MPEG-H 3D Audio support in mp4
>  - thistogram filter
> +- CDToons decoder
>  
>  
>  version 4.2:
> diff --git a/doc/general.texi b/doc/general.texi
> index a5b77e0de1..8fdf8af9fe 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -844,6 +844,8 @@ following image formats are supported:
>  @tab Codec used in Delphine Software International games.
>  @item Discworld II BMV Video @tab @tab  X
>  @item Canopus Lossless Codec @tab @tab  X
> +@item CDToons@tab @tab  X
> +@tab Codec used in various Broderbund games.
>  @item Cinepak@tab @tab  X
>  @item Cirrus Logic AccuPak   @tab  X  @tab  X
>  @tab fourcc: CLJR
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index c1f35b40d8..383a6da32d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -244,6 +244,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o 
> cavsdec.o cavsdsp.o \
>cavsdata.o
>  OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o
>  OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
> +OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
>  OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
>  OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o
>  OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index ec7366144f..a87f29829d 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -68,6 +68,7 @@ extern AVCodec ff_brender_pix_decoder;
>  extern AVCodec ff_c93_decoder;
>  extern AVCodec ff_cavs_decoder;
>  extern AVCodec ff_cdgraphics_decoder;
> +extern AVCodec ff_cdtoons_decoder;
>  extern AVCodec ff_cdxl_decoder;
>  extern AVCodec ff_cfhd_decoder;
>  extern AVCodec ff_cinepak_encoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 119b32dc1f..e9a24165ed 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -460,6 +460,7 @@ enum AVCodecID {
>  AV_CODEC_ID_IMM5,
>  AV_CODEC_ID_MVDV,
>  AV_CODEC_ID_MVHA,
> +AV_CODEC_ID_CDTOONS,
>  
>  /* various PCM "codecs" */
>  AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
> start of audio codecs
> diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c
> new file mode 100644
> index 00..d6c441b8e3
> --- /dev/null
> +++ b/libavcodec/cdtoons.c
> @@ -0,0 +1,438 @@
> +/*
> + * CDToons video decoder
> + * Copyright (C) 2011 The FFmpeg project

2011?

> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * CDToons video decoder
> + * @author Alyssa Milburn 

You could add this as a copyright line above instead.

> + */
> +
> +#include 
> +
> +#include "libavutil/attributes.h"
> +#include "libavutil/internal.h"
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#define CDTOONS_HEADER_SIZE   44
> +#define CDTOONS_MAX_SPRITES 1200
> +
> +typedef struct CDToonsSprite {
> +uint16_t flags;
> +uint16_t owner_frame;
> +uint16_t start_frame;
> +uint16_t end_frame;
> +uint32_t size;
> +uint8_t *data;
> +} CDToonsSprite;
> +
> +typedef struct CDToonsContext {
> +AVCodecContext *avctx;
> +AVFrame *frame;
> +
> +uint16_t last_pal_id;   ///< T

[FFmpeg-devel] [PATCH] CDToons decoder

2020-01-05 Thread Alyssa Milburn
This adds a decoder for Broderbund's sprite-based QuickTime CDToons
codec, based on the decoder I wrote for ScummVM.

A couple of samples can be found at http://noopwafel.net/cdtoons/.

Signed-off-by: Alyssa Milburn 
---
 Changelog   |   1 +
 doc/general.texi|   2 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/cdtoons.c| 438 
 libavcodec/codec_desc.c |   7 +
 libavcodec/version.h|   2 +-
 libavformat/isom.c  |   1 +
 libavformat/riff.c  |   1 +
 10 files changed, 454 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/cdtoons.c

diff --git a/Changelog b/Changelog
index b9401aaab6..9cac485bb5 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - mvha decoder
 - MPEG-H 3D Audio support in mp4
 - thistogram filter
+- CDToons decoder
 
 
 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index a5b77e0de1..8fdf8af9fe 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -844,6 +844,8 @@ following image formats are supported:
 @tab Codec used in Delphine Software International games.
 @item Discworld II BMV Video @tab @tab  X
 @item Canopus Lossless Codec @tab @tab  X
+@item CDToons@tab @tab  X
+@tab Codec used in various Broderbund games.
 @item Cinepak@tab @tab  X
 @item Cirrus Logic AccuPak   @tab  X  @tab  X
 @tab fourcc: CLJR
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1f35b40d8..383a6da32d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -244,6 +244,7 @@ OBJS-$(CONFIG_CAVS_DECODER)+= cavs.o cavsdec.o 
cavsdsp.o \
   cavsdata.o
 OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o ass.o
 OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
+OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
 OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
 OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o
 OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ec7366144f..a87f29829d 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -68,6 +68,7 @@ extern AVCodec ff_brender_pix_decoder;
 extern AVCodec ff_c93_decoder;
 extern AVCodec ff_cavs_decoder;
 extern AVCodec ff_cdgraphics_decoder;
+extern AVCodec ff_cdtoons_decoder;
 extern AVCodec ff_cdxl_decoder;
 extern AVCodec ff_cfhd_decoder;
 extern AVCodec ff_cinepak_encoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 119b32dc1f..e9a24165ed 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -460,6 +460,7 @@ enum AVCodecID {
 AV_CODEC_ID_IMM5,
 AV_CODEC_ID_MVDV,
 AV_CODEC_ID_MVHA,
+AV_CODEC_ID_CDTOONS,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c
new file mode 100644
index 00..d6c441b8e3
--- /dev/null
+++ b/libavcodec/cdtoons.c
@@ -0,0 +1,438 @@
+/*
+ * CDToons video decoder
+ * Copyright (C) 2011 The FFmpeg project
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * CDToons video decoder
+ * @author Alyssa Milburn 
+ */
+
+#include 
+
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define CDTOONS_HEADER_SIZE   44
+#define CDTOONS_MAX_SPRITES 1200
+
+typedef struct CDToonsSprite {
+uint16_t flags;
+uint16_t owner_frame;
+uint16_t start_frame;
+uint16_t end_frame;
+uint32_t size;
+uint8_t *data;
+} CDToonsSprite;
+
+typedef struct CDToonsContext {
+AVCodecContext *avctx;
+AVFrame *frame;
+
+uint16_t last_pal_id;   ///< The index of the active palette sprite.
+uint32_t pal[256];  ///< The currently-used palette data.
+CDToonsSprite sprites[CDTOONS_MAX_SPRITES];
+} CDToonsContext;
+
+static int cdtoons_render_sprite(AVCodecContext *avctx, const uint8_t *data,
+ uint32_t data_size,
+ int dst_x, int dst_y, int width, int height)
+{
+ 

Re: [FFmpeg-devel] [PATCH 6/6] avformat: convert some avio_flush() calls to avio_write_marker(AVIO_DATA_MARKER_FLUSH_POINT)

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


Converting explicit avio_flush() calls helps us to buffer more data and avoid
flushing the IO context too often which causes reduced IO throughput for
non-streamed file output.

The user can control FLUSH_POINT flushing behaviour using the -flush_packets
option, the default typically means to flush unless a non-streamed file output
is used, so this change should have no adverse effect on streaming even if it
is assumed that after an avio_flush() the output buffer is clean so small
seekbacks within the output buffer will work even when the IO context is not
seekable.

Signed-off-by: Marton Balint 
---
libavformat/asfenc.c  | 3 ++-
libavformat/matroskaenc.c | 2 +-
libavformat/movenc.c  | 8 
libavformat/mpegenc.c | 4 ++--
libavformat/mxfenc.c  | 2 +-
libavformat/oggenc.c  | 2 +-
6 files changed, 11 insertions(+), 10 deletions(-)


Possibly ok

// 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".

Re: [FFmpeg-devel] [PATCH 5/6] avformat: remove more unneeded avio_flush() calls

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


These instances are simply redundant or present because avio_flush() used to be
required before doing a seekback. That is no longer the case, aviobuf code does
the flush automatically on seek.

This only affects code which is either disabled for streaming IO contexts or
does no seekbacks after the flush, so this change should have no adverse effect
on streaming.

Signed-off-by: Marton Balint 
---
libavformat/asfenc.c  | 1 -
libavformat/avienc.c  | 1 -
libavformat/gxfenc.c  | 2 --
libavformat/segafilmenc.c | 2 --
libavformat/wavenc.c  | 7 ---
5 files changed, 13 deletions(-)


Possibly ok

// 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".

Re: [FFmpeg-devel] [PATCH 4/6] avformat: remove avio_flush() calls from the end of write_packet functions

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


Removing explicit avio_flush() calls helps us to buffer more data and avoid
flushing the IO context too often which causes reduced IO throughput for
non-streamed file output.

The user can control flushing behaviour at the end of every packet using the
-flush_packets option, the default typically means to flush unless a
non-streamed file output is used.

Therefore this change should have no adverse effect on streaming, even if it is
assumed that a new packet has a clean buffer so small seekbacks within the
output buffer work even when the IO context is not seekable.

Signed-off-by: Marton Balint 
---
libavformat/hashenc.c | 1 -
libavformat/img2enc.c | 1 -
libavformat/mxfenc.c  | 3 ---
3 files changed, 5 deletions(-)


Probably ok

// 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".

Re: [FFmpeg-devel] [PATCH 2/6] avformat: remove uneeded avio_flush() calls from the end of write_header functions

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


The IO context is flushed by libavformat/mux.c after writing the header by 
calling
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN), so this
change should have no effect at all.

Signed-off-by: Marton Balint 


If I read avio_write_marker correctly, it won't do an implicit flush on 
these calls unless the user actually has set the s->write_data_type 
function pointer - which only is set when used by direct API users.


So for normal cases, if I read it correctly, one can't assume 
avio_write_marker implies a flush in general.


// 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".

Re: [FFmpeg-devel] [PATCH 3/6] avformat: remove uneeded avio_flush() calls from the end of write_trailer functions

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


The IO context is always flushed by libavformat/mux.c after write_trailer is
called, so this change should have no effect at all.
---
libavformat/aiffenc.c| 2 --
libavformat/astenc.c | 1 -
libavformat/au.c | 1 -
libavformat/cafenc.c | 1 -
libavformat/flacenc.c| 1 -
libavformat/hashenc.c| 1 -
libavformat/mmf.c| 2 --
libavformat/mpegenc.c| 1 -
libavformat/soxenc.c | 2 --
libavformat/ttaenc.c | 1 -
libavformat/vc1testenc.c | 1 -
libavformat/wavenc.c | 2 --
libavformat/wtvenc.c | 2 --
13 files changed, 18 deletions(-)


LGTM

// 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".

Re: [FFmpeg-devel] [PATCH 1/6] avformat: remove unneded avio_flush() calls before calling avio_close_dyn_buf()

2020-01-05 Thread Martin Storsjö

On Sun, 5 Jan 2020, Marton Balint wrote:


avio_close_dyn_buf() also does avio_flush().

Signed-off-by: Marton Balint 
---
libavformat/hlsenc.c | 2 --
libavformat/oggenc.c | 1 -
libavformat/rtpdec.c | 2 --
3 files changed, 5 deletions(-)


LGTM

// 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 v2] lavc/ffv1: Properly check that the 4th and 5th quant tables are zeroes

2020-01-05 Thread Derek Buitenhuis
Currently, the decoder checks the 128th value of the 4th quant table during
while deriving the context on each sample, in order to speed itself up. This
is due to relying on the behavior of FFmpeg's FFV1 encoder, in which if that
value is zero, the entire 4th and 5th quant tables are assumed to be entirely
zero.

This does not match the FFV1 spec, which has no such restriction, and after
some discussion, it was decided to fix FFmpeg to abide by the spec, rather
than change the spec.

We will now check whether the 4th and 5th quant tables are zero properly,
by checking the 128th valye of both tables (which means they are zero due
to the way they're coded in the bitstream).

For further context, the FFV1 issue in question is located at:

https://github.com/FFmpeg/FFV1/issues/169

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/ffv1_template.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ffv1_template.c b/libavcodec/ffv1_template.c
index f2ab93313a..c5f61b0182 100644
--- a/libavcodec/ffv1_template.c
+++ b/libavcodec/ffv1_template.c
@@ -37,7 +37,7 @@ static inline int RENAME(get_context)(PlaneContext *p, TYPE 
*src,
 const int RT = last[1];
 const int L  = src[-1];
 
-if (p->quant_table[3][127]) {
+if (p->quant_table[3][127] || p->quant_table[4][127]) {
 const int TT = last2[0];
 const int LL = src[-2];
 return p->quant_table[0][(L - LT) & 0xFF] +
-- 
2.25.0.rc0

___
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/6] avformat: remove more unneeded avio_flush() calls

2020-01-05 Thread Marton Balint
These instances are simply redundant or present because avio_flush() used to be
required before doing a seekback. That is no longer the case, aviobuf code does
the flush automatically on seek.

This only affects code which is either disabled for streaming IO contexts or
does no seekbacks after the flush, so this change should have no adverse effect
on streaming.

Signed-off-by: Marton Balint 
---
 libavformat/asfenc.c  | 1 -
 libavformat/avienc.c  | 1 -
 libavformat/gxfenc.c  | 2 --
 libavformat/segafilmenc.c | 2 --
 libavformat/wavenc.c  | 7 ---
 5 files changed, 13 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index d03cff91c0..8eaa9d40ce 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -1130,7 +1130,6 @@ static int asf_write_trailer(AVFormatContext *s)
 return ret;
 asf_write_index(s, asf->index_ptr, asf->maximum_packet, 
asf->next_start_sec);
 }
-avio_flush(s->pb);
 
 if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
 put_chunk(s, 0x4524, 0, 0); /* end of stream */
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 23cc58ea76..d6cfb1b783 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -591,7 +591,6 @@ static void update_odml_entry(AVFormatContext *s, int 
stream_index, int64_t ix,
 int64_t pos;
 int au_byterate, au_ssize, au_scale;
 
-avio_flush(pb);
 pos = avio_tell(pb);
 
 /* Updating one entry in the AVI OpenDML master index */
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index c9fb0dcd91..e09b8d7625 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -863,13 +863,11 @@ static int gxf_write_trailer(AVFormatContext *s)
 return ret;
 gxf_write_flt_packet(s);
 gxf_write_umf_packet(s);
-avio_flush(pb);
 /* update duration in all map packets */
 for (i = 1; i < gxf->map_offsets_nb; i++) {
 avio_seek(pb, gxf->map_offsets[i], SEEK_SET);
 if ((ret = gxf_write_map_packet(s, 1)) < 0)
 return ret;
-avio_flush(pb);
 }
 
 avio_seek(pb, end, SEEK_SET);
diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
index f1048ff808..812d0ad64e 100644
--- a/libavformat/segafilmenc.c
+++ b/libavformat/segafilmenc.c
@@ -362,8 +362,6 @@ static int film_write_header(AVFormatContext 
*format_context)
 
 avio_wb32(pb, film->packet_count);
 
-avio_flush(pb);
-
 /* Finally, write out each packet's data to the header */
 packet = film->start;
 while (packet != NULL) {
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index ea7573139c..f6f5710802 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -411,17 +411,13 @@ static int wav_write_trailer(AVFormatContext *s)
 int rf64 = 0;
 int ret = 0;
 
-avio_flush(pb);
-
 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
 if (wav->write_peak != PEAK_ONLY && avio_tell(pb) - wav->data < 
UINT32_MAX) {
 ff_end_tag(pb, wav->data);
-avio_flush(pb);
 }
 
 if (wav->write_peak && wav->peak_output) {
 ret = peak_write_chunk(s);
-avio_flush(pb);
 }
 
 /* update file size */
@@ -433,8 +429,6 @@ static int wav_write_trailer(AVFormatContext *s)
 avio_seek(pb, 4, SEEK_SET);
 avio_wl32(pb, (uint32_t)(file_size - 8));
 avio_seek(pb, file_size, SEEK_SET);
-
-avio_flush(pb);
 } else {
 av_log(s, AV_LOG_ERROR,
"Filesize %"PRId64" invalid for wav, output file will be 
broken\n",
@@ -454,7 +448,6 @@ static int wav_write_trailer(AVFormatContext *s)
 } else {
 avio_wl32(pb, number_of_samples);
 avio_seek(pb, file_size, SEEK_SET);
-avio_flush(pb);
 }
 }
 
-- 
2.16.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/6] avformat: convert some avio_flush() calls to avio_write_marker(AVIO_DATA_MARKER_FLUSH_POINT)

2020-01-05 Thread Marton Balint
Converting explicit avio_flush() calls helps us to buffer more data and avoid
flushing the IO context too often which causes reduced IO throughput for
non-streamed file output.

The user can control FLUSH_POINT flushing behaviour using the -flush_packets
option, the default typically means to flush unless a non-streamed file output
is used, so this change should have no adverse effect on streaming even if it
is assumed that after an avio_flush() the output buffer is clean so small
seekbacks within the output buffer will work even when the IO context is not
seekable.

Signed-off-by: Marton Balint 
---
 libavformat/asfenc.c  | 3 ++-
 libavformat/matroskaenc.c | 2 +-
 libavformat/movenc.c  | 8 
 libavformat/mpegenc.c | 4 ++--
 libavformat/mxfenc.c  | 2 +-
 libavformat/oggenc.c  | 2 +-
 6 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 8eaa9d40ce..73afb13200 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -892,7 +892,8 @@ static void flush_packet(AVFormatContext *s)
 
 avio_write(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size);
 
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
+
 asf->nb_packets++;
 asf->packet_nb_payloads = 0;
 asf->packet_timestamp_start = -1;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 4b6d14b435..71c9afb15c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2235,7 +2235,7 @@ static void mkv_end_cluster(AVFormatContext *s)
 
 end_ebml_master_crc32(s->pb, &mkv->cluster_bc, mkv);
 mkv->cluster_pos = -1;
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 }
 
 static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e20eea7571..1d9497283f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5152,7 +5152,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) {
 if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)
 mov->reserved_header_pos = avio_tell(s->pb);
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, 
AVIO_DATA_MARKER_FLUSH_POINT);
 mov->moov_written = 1;
 return 0;
 }
@@ -5176,7 +5176,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 mov->tracks[i].entry = 0;
 mov->tracks[i].end_reliable = 0;
 }
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 return 0;
 }
 
@@ -5241,7 +5241,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 }
 
 if (write_moof) {
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, 
AVIO_DATA_MARKER_FLUSH_POINT);
 
 mov_write_moof_tag(s->pb, mov, moof_tracks, mdat_size);
 mov->fragments++;
@@ -5273,7 +5273,7 @@ static int mov_flush_fragment(AVFormatContext *s, int 
force)
 
 mov->mdat_size = 0;
 
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 return 0;
 }
 
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index f8039a42c0..669ff9d152 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -928,7 +928,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 for (i = 0; i < zero_trail_bytes; i++)
 avio_w8(ctx->pb, 0x00);
 
-avio_flush(ctx->pb);
+avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 
 s->packet_number++;
 
@@ -957,7 +957,7 @@ static void put_vcd_padding_sector(AVFormatContext *ctx)
 
 s->vcd_padding_bytes_written += s->packet_size;
 
-avio_flush(ctx->pb);
+avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 
 /* increasing the packet number is correct. The SCR of the following packs
  * is calculated from the packet_number and it has to include the padding
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 396768d51f..374a83d069 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1936,7 +1936,7 @@ static int mxf_write_partition(AVFormatContext *s, int 
bodysid,
 }
 
 if(key)
-avio_flush(pb);
+avio_write_marker(pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 
 return 0;
 }
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 04f7813083..fe89f23e36 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -139,7 +139,7 @@ static int ogg_write_page(AVFormatContext *s, OGGPage 
*page, int extra_flags)
 return size;
 
 avio_write(s->pb, buf, size);
-avio_flush(s->pb);
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 av_fr

[FFmpeg-devel] [PATCH 2/6] avformat: remove uneeded avio_flush() calls from the end of write_header functions

2020-01-05 Thread Marton Balint
The IO context is flushed by libavformat/mux.c after writing the header by 
calling
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN), so this
change should have no effect at all.

Signed-off-by: Marton Balint 
---
 libavformat/aiffenc.c | 3 ---
 libavformat/amr.c | 1 -
 libavformat/asfenc.c  | 2 --
 libavformat/assenc.c  | 1 -
 libavformat/astenc.c  | 2 --
 libavformat/au.c  | 1 -
 libavformat/avienc.c  | 2 --
 libavformat/cafenc.c  | 1 -
 libavformat/ffmetaenc.c   | 1 -
 libavformat/framehash.c   | 1 -
 libavformat/gxfenc.c  | 1 -
 libavformat/icoenc.c  | 2 --
 libavformat/idroqenc.c| 1 -
 libavformat/ilbc.c| 1 -
 libavformat/jacosubenc.c  | 1 -
 libavformat/matroskaenc.c | 2 --
 libavformat/microdvdenc.c | 1 -
 libavformat/mmf.c | 2 --
 libavformat/movenc.c  | 1 -
 libavformat/mpjpeg.c  | 1 -
 libavformat/nutenc.c  | 2 --
 libavformat/rmenc.c   | 1 -
 libavformat/rsoenc.c  | 2 --
 libavformat/smjpegenc.c   | 1 -
 libavformat/soxenc.c  | 2 --
 libavformat/swfenc.c  | 1 -
 libavformat/wavenc.c  | 2 --
 libavformat/webvttenc.c   | 1 -
 28 files changed, 40 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index e25794d185..ec2c7db09a 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -199,9 +199,6 @@ static int aiff_write_header(AVFormatContext *s)
 avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
 
s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);
 
-/* Data is starting here */
-avio_flush(pb);
-
 return 0;
 }
 
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 42840a50a3..650b565b1b 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -60,7 +60,6 @@ static int amr_write_header(AVFormatContext *s)
 } else {
 return -1;
 }
-avio_flush(pb);
 return 0;
 }
 
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 44e11fc763..d03cff91c0 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -801,8 +801,6 @@ static int asf_write_header(AVFormatContext *s)
 return -1;
 }
 
-avio_flush(s->pb);
-
 asf->packet_nb_payloads = 0;
 asf->packet_timestamp_start = -1;
 asf->packet_timestamp_end   = -1;
diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index 12aadca171..68c3396e5a 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -77,7 +77,6 @@ static int write_header(AVFormatContext *s)
 avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, 
Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
 ass->ssa_mode ? "Marked" : "Layer");
 }
-avio_flush(s->pb);
 
 return 0;
 }
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index 578e658891..d38a3aab38 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -101,8 +101,6 @@ static int ast_write_header(AVFormatContext *s)
 avio_wb64(pb, 0);
 avio_wb32(pb, 0);
 
-avio_flush(pb);
-
 return 0;
 }
 
diff --git a/libavformat/au.c b/libavformat/au.c
index cb48e67feb..19a0f56963 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -311,7 +311,6 @@ static int au_write_header(AVFormatContext *s)
 } else {
 avio_wb64(pb, 0); /* annotation field */
 }
-avio_flush(pb);
 
 return 0;
 }
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 940ea33510..23cc58ea76 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -580,8 +580,6 @@ static int avi_write_header(AVFormatContext *s)
 avi->movi_list = ff_start_tag(pb, "LIST");
 ffio_wfourcc(pb, "movi");
 
-avio_flush(pb);
-
 return 0;
 }
 
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 0f7c4ebbb3..8fe1dcef19 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -203,7 +203,6 @@ static int caf_write_header(AVFormatContext *s)
 avio_wb64(pb, -1);//< mChunkSize
 avio_wb32(pb, 0); //< mEditCount
 
-avio_flush(pb);
 return 0;
 }
 
diff --git a/libavformat/ffmetaenc.c b/libavformat/ffmetaenc.c
index a9adbb1d19..800fb1887c 100644
--- a/libavformat/ffmetaenc.c
+++ b/libavformat/ffmetaenc.c
@@ -54,7 +54,6 @@ static int write_header(AVFormatContext *s)
 avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1);
 avio_w8(s->pb, '1');  // version
 avio_w8(s->pb, '\n');
-avio_flush(s->pb);
 return 0;
 }
 
diff --git a/libavformat/framehash.c b/libavformat/framehash.c
index 3ae9092c61..8d90793d7c 100644
--- a/libavformat/framehash.c
+++ b/libavformat/framehash.c
@@ -45,7 +45,6 @@ int ff_framehash_write_header(AVFormatContext *s)
 avio_printf(s->pb, "#sar %d: %d/%d\n", i, 
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
 break;
 }
-avio_flush(s->pb);
 }
 return 0;
 }
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index ad9ddea887..c9fb0dcd91 100644
---

[FFmpeg-devel] [PATCH 4/6] avformat: remove avio_flush() calls from the end of write_packet functions

2020-01-05 Thread Marton Balint
Removing explicit avio_flush() calls helps us to buffer more data and avoid
flushing the IO context too often which causes reduced IO throughput for
non-streamed file output.

The user can control flushing behaviour at the end of every packet using the
-flush_packets option, the default typically means to flush unless a
non-streamed file output is used.

Therefore this change should have no adverse effect on streaming, even if it is
assumed that a new packet has a clean buffer so small seekbacks within the
output buffer work even when the IO context is not seekable.

Signed-off-by: Marton Balint 
---
 libavformat/hashenc.c | 1 -
 libavformat/img2enc.c | 1 -
 libavformat/mxfenc.c  | 3 ---
 3 files changed, 5 deletions(-)

diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index ddc67f53b5..ce609f6efa 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -324,7 +324,6 @@ static int framehash_write_packet(struct AVFormatContext 
*s, AVPacket *pkt)
 }
 
 avio_printf(s->pb, "\n");
-avio_flush(s->pb);
 return 0;
 }
 
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 39398f37a3..5ee99890ce 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -118,7 +118,6 @@ static int write_packet_pipe(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 } else {
 avio_write(s->pb, pkt->data, pkt->size);
-avio_flush(s->pb);
 }
 img->img_number++;
 return 0;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index e187b3845d..396768d51f 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2799,7 +2799,6 @@ static int mxf_write_opatom_packet(AVFormatContext *s, 
AVPacket *pkt, MXFIndexEn
 mxf->edit_units_count++;
 avio_write(pb, pkt->data, pkt->size);
 mxf->body_offset += pkt->size;
-avio_flush(pb);
 
 return 0;
 }
@@ -2937,8 +2936,6 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 mxf->body_offset += 16+4+pkt->size + klv_fill_size(16+4+pkt->size);
 }
 
-avio_flush(pb);
-
 return 0;
 }
 
-- 
2.16.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/6] avformat: remove unneded avio_flush() calls before calling avio_close_dyn_buf()

2020-01-05 Thread Marton Balint
avio_close_dyn_buf() also does avio_flush().

Signed-off-by: Marton Balint 
---
 libavformat/hlsenc.c | 2 --
 libavformat/oggenc.c | 1 -
 libavformat/rtpdec.c | 2 --
 3 files changed, 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 561e3ff736..d130f03ea6 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -459,7 +459,6 @@ static int flush_dynbuf(VariantStream *vs, int 
*range_length)
 
 // flush
 av_write_frame(ctx, NULL);
-avio_flush(ctx->pb);
 
 // write out to file
 *range_length = avio_close_dyn_buf(ctx->pb, &vs->temp_buffer);
@@ -2548,7 +2547,6 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (!vs->init_range_length) {
 uint8_t *buffer = NULL;
 av_write_frame(oc, NULL); /* Flush any buffered data */
-avio_flush(oc->pb);
 
 range_length = avio_close_dyn_buf(oc->pb, &buffer);
 avio_write(vs->out, buffer, range_length);
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index d3ae07351d..04f7813083 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -133,7 +133,6 @@ static int ogg_write_page(AVFormatContext *s, OGGPage 
*page, int extra_flags)
 avio_write(pb, page->data, page->size);
 
 ogg_update_checksum(s, pb, crc_offset);
-avio_flush(pb);
 
 size = avio_close_dyn_buf(pb, &buf);
 if (size < 0)
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index e75a34cb93..3d5b200099 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -415,7 +415,6 @@ void ff_rtp_send_punch_packets(URLContext *rtp_handle)
 avio_wb32(pb, 0); /* Timestamp */
 avio_wb32(pb, 0); /* SSRC */
 
-avio_flush(pb);
 len = avio_close_dyn_buf(pb, &buf);
 if ((len > 0) && buf)
 ffurl_write(rtp_handle, buf, len);
@@ -430,7 +429,6 @@ void ff_rtp_send_punch_packets(URLContext *rtp_handle)
 avio_wb16(pb, 1); /* length in words - 1 */
 avio_wb32(pb, 0); /* our own SSRC */
 
-avio_flush(pb);
 len = avio_close_dyn_buf(pb, &buf);
 if ((len > 0) && buf)
 ffurl_write(rtp_handle, buf, len);
-- 
2.16.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 3/6] avformat: remove uneeded avio_flush() calls from the end of write_trailer functions

2020-01-05 Thread Marton Balint
The IO context is always flushed by libavformat/mux.c after write_trailer is
called, so this change should have no effect at all.
---
 libavformat/aiffenc.c| 2 --
 libavformat/astenc.c | 1 -
 libavformat/au.c | 1 -
 libavformat/cafenc.c | 1 -
 libavformat/flacenc.c| 1 -
 libavformat/hashenc.c| 1 -
 libavformat/mmf.c| 2 --
 libavformat/mpegenc.c| 1 -
 libavformat/soxenc.c | 2 --
 libavformat/ttaenc.c | 1 -
 libavformat/vc1testenc.c | 1 -
 libavformat/wavenc.c | 2 --
 libavformat/wtvenc.c | 2 --
 13 files changed, 18 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index ec2c7db09a..0145596bec 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -263,8 +263,6 @@ static int aiff_write_trailer(AVFormatContext *s)
 file_size = avio_tell(pb);
 avio_seek(pb, aiff->form, SEEK_SET);
 avio_wb32(pb, file_size - aiff->form - 4);
-
-avio_flush(pb);
 }
 
 return ret;
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index d38a3aab38..e0b94b8b63 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -178,7 +178,6 @@ static int ast_write_trailer(AVFormatContext *s)
 }
 
 avio_seek(pb, file_size, SEEK_SET);
-avio_flush(pb);
 }
 return 0;
 }
diff --git a/libavformat/au.c b/libavformat/au.c
index 19a0f56963..4afee85a94 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -326,7 +326,6 @@ static int au_write_trailer(AVFormatContext *s)
 avio_seek(pb, 8, SEEK_SET);
 avio_wb32(pb, (uint32_t)(file_size - au->header_size));
 avio_seek(pb, file_size, SEEK_SET);
-avio_flush(pb);
 }
 
 return 0;
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 8fe1dcef19..98d4d9212f 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -258,7 +258,6 @@ static int caf_write_trailer(AVFormatContext *s)
 avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
 caf->size_buffer_size = 0;
 }
-avio_flush(pb);
 }
 av_freep(&caf->pkt_sizes);
 return 0;
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index abbed38f89..1aae0c97e0 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -349,7 +349,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
 avio_seek(pb, 8, SEEK_SET);
 avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE);
 avio_seek(pb, file_size, SEEK_SET);
-avio_flush(pb);
 } else {
 av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
 }
diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index 34a8fd1f50..ddc67f53b5 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -152,7 +152,6 @@ static int hash_write_trailer(struct AVFormatContext *s)
 av_hash_final_hex(c->hashes[i], buf + strlen(buf), sizeof(buf) - 
strlen(buf));
 av_strlcatf(buf, sizeof(buf), "\n");
 avio_write(s->pb, buf, strlen(buf));
-avio_flush(s->pb);
 }
 
 return 0;
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 4e087fc920..e4768db064 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -171,8 +171,6 @@ static int mmf_write_trailer(AVFormatContext *s)
 avio_write(pb, "\x00\x00\x00\x00", 4);
 
 avio_seek(pb, pos, SEEK_SET);
-
-avio_flush(pb);
 }
 return 0;
 }
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index f6980231a2..f8039a42c0 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -1244,7 +1244,6 @@ static int mpeg_mux_end(AVFormatContext *ctx)
  * it as it is usually not needed by decoders and because it
  * complicates MPEG stream concatenation. */
 // avio_wb32(ctx->pb, ISO_11172_END_CODE);
-// avio_flush(ctx->pb);
 
 for (i = 0; i < ctx->nb_streams; i++) {
 stream = ctx->streams[i]->priv_data;
diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c
index 7259131b03..ce276f88b5 100644
--- a/libavformat/soxenc.c
+++ b/libavformat/soxenc.c
@@ -99,8 +99,6 @@ static int sox_write_trailer(AVFormatContext *s)
 } else
 avio_wb64(pb, num_samples);
 avio_seek(pb, file_size, SEEK_SET);
-
-avio_flush(pb);
 }
 
 return 0;
diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 73c29ae936..4860aab4c1 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -154,7 +154,6 @@ static int tta_write_trailer(AVFormatContext *s)
 tta_queue_flush(s);
 
 ff_ape_write_tag(s);
-avio_flush(s->pb);
 
 return 0;
 }
diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c
index cf95d1d80d..1365bdd660 100644
--- a/libavformat/vc1testenc.c
+++ b/libavformat/vc1testenc.c
@@ -76,7 +76,6 @@ static int vc1test_write_trailer(AVFormatContext *s)
 if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
 avio_seek(pb, 0, SEEK_SET);
 avio_wl24(pb, ctx->frames);
-avio_flush(pb);

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/pgssubdec: Free subtitle on error

2020-01-05 Thread Michael Niedermayer
On Sun, Jan 05, 2020 at 08:44:50AM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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