[FFmpeg-devel] [PATCH] avcodec: Refactor common nvdec hwaccel logic

2017-11-18 Thread Philip Langdale
The 'simple' hwaccels (not h.264 and hevc) all use the same bitstream
management and reference lookup logic so let's refactor all that into
common functions.

Signed-off-by: Philip Langdale 
---
 libavcodec/nvdec.c| 46 +++
 libavcodec/nvdec.h|  4 
 libavcodec/nvdec_mpeg12.c | 53 -
 libavcodec/nvdec_vc1.c| 55 ++-
 libavcodec/nvdec_vp9.c| 53 +
 5 files changed, 65 insertions(+), 146 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 3d62840e9f..97ff605f0f 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -475,6 +475,36 @@ finish:
 return ret;
 }
 
+int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
+{
+NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
+int ret = ff_nvdec_end_frame(avctx);
+ctx->bitstream = NULL;
+return ret;
+}
+
+int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
+ uint32_t size)
+{
+NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
+void *tmp;
+
+tmp = av_fast_realloc(ctx->slice_offsets, >slice_offsets_allocated,
+  (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));
+if (!tmp)
+return AVERROR(ENOMEM);
+ctx->slice_offsets = tmp;
+
+if (!ctx->bitstream)
+ctx->bitstream = (uint8_t*)buffer;
+
+ctx->slice_offsets[ctx->nb_slices] = buffer - ctx->bitstream;
+ctx->bitstream_len += size;
+ctx->nb_slices++;
+
+return 0;
+}
+
 int ff_nvdec_frame_params(AVCodecContext *avctx,
   AVBufferRef *hw_frames_ctx,
   int dpb_size)
@@ -520,3 +550,19 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
 
 return 0;
 }
+
+int ff_nvdec_get_ref_idx(AVFrame *frame)
+{
+FrameDecodeData *fdd;
+NVDECFrame *cf;
+
+if (!frame || !frame->private_ref)
+return -1;
+
+fdd = (FrameDecodeData*)frame->private_ref->data;
+cf  = (NVDECFrame*)fdd->hwaccel_priv;
+if (!cf)
+return -1;
+
+return cf->idx;
+}
diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h
index 14d29ee94b..90578d5a1c 100644
--- a/libavcodec/nvdec.h
+++ b/libavcodec/nvdec.h
@@ -58,8 +58,12 @@ int ff_nvdec_decode_init(AVCodecContext *avctx);
 int ff_nvdec_decode_uninit(AVCodecContext *avctx);
 int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame);
 int ff_nvdec_end_frame(AVCodecContext *avctx);
+int ff_nvdec_simple_end_frame(AVCodecContext *avctx);
+int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
+ uint32_t size);
 int ff_nvdec_frame_params(AVCodecContext *avctx,
   AVBufferRef *hw_frames_ctx,
   int dpb_size);
+int ff_nvdec_get_ref_idx(AVFrame *frame);
 
 #endif /* AVCODEC_NVDEC_H */
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index 127e843d85..db9cebeddd 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -25,22 +25,6 @@
 #include "nvdec.h"
 #include "decode.h"
 
-static int get_ref_idx(AVFrame *frame)
-{
-FrameDecodeData *fdd;
-NVDECFrame *cf;
-
-if (!frame || !frame->private_ref)
-return -1;
-
-fdd = (FrameDecodeData*)frame->private_ref->data;
-cf  = (NVDECFrame*)fdd->hwaccel_priv;
-if (!cf)
-return -1;
-
-return cf->idx;
-}
-
 static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t 
*buffer, uint32_t size)
 {
 MpegEncContext *s = avctx->priv_data;
@@ -71,8 +55,8 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, 
const uint8_t *buffer
  s->pict_type == AV_PICTURE_TYPE_P,
 
 .CodecSpecific.mpeg2 = {
-.ForwardRefIdx = get_ref_idx(s->last_picture.f),
-.BackwardRefIdx= get_ref_idx(s->next_picture.f),
+.ForwardRefIdx = ff_nvdec_get_ref_idx(s->last_picture.f),
+.BackwardRefIdx= ff_nvdec_get_ref_idx(s->next_picture.f),
 
 .picture_coding_type= s->pict_type,
 .full_pel_forward_vector= s->full_pel[0],
@@ -99,35 +83,6 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, 
const uint8_t *buffer
 return 0;
 }
 
-static int nvdec_mpeg12_end_frame(AVCodecContext *avctx)
-{
-NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
-int ret = ff_nvdec_end_frame(avctx);
-ctx->bitstream = NULL;
-return ret;
-}
-
-static int nvdec_mpeg12_decode_slice(AVCodecContext *avctx, const uint8_t 
*buffer, uint32_t size)
-{
-NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
-void *tmp;
-
-tmp = av_fast_realloc(ctx->slice_offsets, >slice_offsets_allocated,
-  (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets));
-if (!tmp)
-return 

Re: [FFmpeg-devel] [PATCH] avformat/subfile: allow to extract till EOF

2017-11-18 Thread Gyan Doshi

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


[FFmpeg-devel] [PATCH 3/3] x86/jpeg2000dsp: add ff_ict_float_{fma3, fma4}

2017-11-18 Thread James Almer
jpeg2000_ict_float_c: 2296.0
jpeg2000_ict_float_sse: 628.0
jpeg2000_ict_float_avx: 317.0
jpeg2000_ict_float_fma3: 262.0

Signed-off-by: James Almer 
---
 libavcodec/x86/jpeg2000dsp.asm| 20 
 libavcodec/x86/jpeg2000dsp_init.c | 10 ++
 2 files changed, 30 insertions(+)

diff --git a/libavcodec/x86/jpeg2000dsp.asm b/libavcodec/x86/jpeg2000dsp.asm
index 56b5fbd606..61dfdd4f71 100644
--- a/libavcodec/x86/jpeg2000dsp.asm
+++ b/libavcodec/x86/jpeg2000dsp.asm
@@ -74,6 +74,19 @@ align 16
 movaps   m1, [src1q+csizeq]
 movaps   m2, [src2q+csizeq]
 
+%if cpuflag(fma4) || cpuflag(fma3)
+%if cpuflag(fma4)
+fnmaddps  m5, m1, ICT1, m0
+fmaddps   m4, m2, ICT0, m0
+%else ; fma3
+movapsm5, m1
+movapsm4, m2
+fnmaddps  m5, m5, ICT1, m0
+fmaddps   m4, m4, ICT0, m0
+%endif
+fmaddps   m0, m1, ICT3, m0
+fnmaddps  m5, m2, ICT2, m5
+%else ; non FMA
 %if cpuflag(avx)
 mulpsm5, m1, ICT1
 mulpsm4, m2, ICT0
@@ -93,6 +106,7 @@ align 16
 addpsm4, m4, m0
 addpsm0, m0, m1
 subpsm5, m5, m2
+%endif
 
 movaps   [src0q+csizeq], m4
 movaps   [src2q+csizeq], m0
@@ -106,6 +120,12 @@ INIT_XMM sse
 ICT_FLOAT 10
 INIT_YMM avx
 ICT_FLOAT 9
+%if HAVE_FMA4_EXTERNAL
+INIT_XMM fma4
+ICT_FLOAT 9
+%endif
+INIT_YMM fma3
+ICT_FLOAT 9
 
 ;***
 ; ff_rct_int_(int32_t *src0, int32_t *src1, int32_t *src2, int csize)
diff --git a/libavcodec/x86/jpeg2000dsp_init.c 
b/libavcodec/x86/jpeg2000dsp_init.c
index baa81383ea..7310a1d0e1 100644
--- a/libavcodec/x86/jpeg2000dsp_init.c
+++ b/libavcodec/x86/jpeg2000dsp_init.c
@@ -26,6 +26,8 @@
 
 void ff_ict_float_sse(void *src0, void *src1, void *src2, int csize);
 void ff_ict_float_avx(void *src0, void *src1, void *src2, int csize);
+void ff_ict_float_fma3(void *src0, void *src1, void *src2, int csize);
+void ff_ict_float_fma4(void *src0, void *src1, void *src2, int csize);
 void ff_rct_int_sse2 (void *src0, void *src1, void *src2, int csize);
 void ff_rct_int_avx2 (void *src0, void *src1, void *src2, int csize);
 
@@ -44,6 +46,14 @@ av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c)
 c->mct_decode[FF_DWT97] = ff_ict_float_avx;
 }
 
+if (EXTERNAL_FMA4(cpu_flags)) {
+c->mct_decode[FF_DWT97] = ff_ict_float_fma4;
+}
+
+if (EXTERNAL_FMA3_FAST(cpu_flags)) {
+c->mct_decode[FF_DWT97] = ff_ict_float_fma3;
+}
+
 if (EXTERNAL_AVX2_FAST(cpu_flags)) {
 c->mct_decode[FF_DWT53] = ff_rct_int_avx2;
 }
-- 
2.14.2

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


[FFmpeg-devel] [PATCH 2/3] checkasm/jpeg2000dsp: add test for ict_float

2017-11-18 Thread James Almer
Signed-off-by: James Almer 
---
 tests/checkasm/jpeg2000dsp.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/tests/checkasm/jpeg2000dsp.c b/tests/checkasm/jpeg2000dsp.c
index 4251f8982a..bce534dbaf 100644
--- a/tests/checkasm/jpeg2000dsp.c
+++ b/tests/checkasm/jpeg2000dsp.c
@@ -33,6 +33,13 @@
 src[i] = rnd(); \
 } while (0)
 
+#define randomize_buffers_float()\
+do { \
+int i;   \
+for (i = 0; i < BUF_SIZE*3; i++) \
+src[i] = (float)rnd() / (UINT_MAX >> 5); \
+} while (0)
+
 static void check_rct_int(void)
 {
 LOCAL_ALIGNED_32(int32_t, src, [BUF_SIZE*3]);
@@ -57,6 +64,30 @@ static void check_rct_int(void)
 bench_new(new0, new1, new2, BUF_SIZE);
 }
 
+static void check_ict_float(void)
+{
+LOCAL_ALIGNED_32(float, src, [BUF_SIZE*3]);
+LOCAL_ALIGNED_32(float, ref, [BUF_SIZE*3]);
+LOCAL_ALIGNED_32(float, new, [BUF_SIZE*3]);
+float *ref0 = [BUF_SIZE*0], *new0 = [BUF_SIZE*0];
+float *ref1 = [BUF_SIZE*1], *new1 = [BUF_SIZE*1];
+float *ref2 = [BUF_SIZE*2], *new2 = [BUF_SIZE*2];
+
+declare_func(void, void *src0, void *src1, void *src2, int csize);
+
+randomize_buffers_float();
+memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
+memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
+call_ref(ref0, ref1, ref2, BUF_SIZE);
+call_new(new0, new1, new2, BUF_SIZE);
+if (!float_near_abs_eps_array(ref0, new0, 1.0e-5, BUF_SIZE) ||
+!float_near_abs_eps_array(ref1, new1, 1.0e-5, BUF_SIZE) ||
+!float_near_abs_eps_array(ref2, new2, 1.0e-5, BUF_SIZE))
+fail();
+memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
+bench_new(new0, new1, new2, BUF_SIZE);
+}
+
 void checkasm_check_jpeg2000dsp(void)
 {
 Jpeg2000DSPContext h;
@@ -65,6 +96,8 @@ void checkasm_check_jpeg2000dsp(void)
 
 if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
 check_rct_int();
+if (check_func(h.mct_decode[FF_DWT97], "jpeg2000_ict_float"))
+check_ict_float();
 
 report("mct_decode");
 }
-- 
2.14.2

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


[FFmpeg-devel] [PATCH 1/3] checkasm/jpeg2000: refactor rct_int test

2017-11-18 Thread James Almer
Signed-off-by: James Almer 
---
 tests/checkasm/jpeg2000dsp.c | 43 +--
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/tests/checkasm/jpeg2000dsp.c b/tests/checkasm/jpeg2000dsp.c
index 48559df085..4251f8982a 100644
--- a/tests/checkasm/jpeg2000dsp.c
+++ b/tests/checkasm/jpeg2000dsp.c
@@ -29,43 +29,42 @@
 #define randomize_buffers() \
 do {\
 int i;  \
-for (i = 0; i < BUF_SIZE; i += 4) { \
-uint32_t r = rnd(); \
-AV_WN32A(ref0 + i, r);  \
-AV_WN32A(new0 + i, r);  \
-r = rnd();  \
-AV_WN32A(ref1 + i, r);  \
-AV_WN32A(new1 + i, r);  \
-r = rnd();  \
-AV_WN32A(ref2 + i, r);  \
-AV_WN32A(new2 + i, r);  \
-}   \
+for (i = 0; i < BUF_SIZE*3; i++)\
+src[i] = rnd(); \
 } while (0)
 
-static void check_mct(uint8_t *ref0, uint8_t *ref1, uint8_t *ref2,
-  uint8_t *new0, uint8_t *new1, uint8_t *new2) {
+static void check_rct_int(void)
+{
+LOCAL_ALIGNED_32(int32_t, src, [BUF_SIZE*3]);
+LOCAL_ALIGNED_32(int32_t, ref, [BUF_SIZE*3]);
+LOCAL_ALIGNED_32(int32_t, new, [BUF_SIZE*3]);
+int32_t *ref0 = [BUF_SIZE*0], *new0 = [BUF_SIZE*0];
+int32_t *ref1 = [BUF_SIZE*1], *new1 = [BUF_SIZE*1];
+int32_t *ref2 = [BUF_SIZE*2], *new2 = [BUF_SIZE*2];
+
 declare_func(void, void *src0, void *src1, void *src2, int csize);
 
 randomize_buffers();
-call_ref(ref0, ref1, ref2, BUF_SIZE / sizeof(int32_t));
-call_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
-if (memcmp(ref0, new0, BUF_SIZE) || memcmp(ref1, new1, BUF_SIZE) ||
-memcmp(ref2, new2, BUF_SIZE))
+memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src));
+memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
+call_ref(ref0, ref1, ref2, BUF_SIZE);
+call_new(new0, new1, new2, BUF_SIZE);
+if (memcmp(ref0, new0, BUF_SIZE * sizeof(*src)) ||
+memcmp(ref1, new1, BUF_SIZE * sizeof(*src)) ||
+memcmp(ref2, new2, BUF_SIZE * sizeof(*src)))
 fail();
-bench_new(new0, new1, new2, BUF_SIZE / sizeof(int32_t));
+memcpy(new, src, BUF_SIZE * 3 * sizeof(*src));
+bench_new(new0, new1, new2, BUF_SIZE);
 }
 
 void checkasm_check_jpeg2000dsp(void)
 {
-LOCAL_ALIGNED_32(uint8_t, ref, [BUF_SIZE*3]);
-LOCAL_ALIGNED_32(uint8_t, new, [BUF_SIZE*3]);
 Jpeg2000DSPContext h;
 
 ff_jpeg2000dsp_init();
 
 if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int"))
-check_mct([BUF_SIZE*0], [BUF_SIZE*1], [BUF_SIZE*2],
-  [BUF_SIZE*0], [BUF_SIZE*1], [BUF_SIZE*2]);
+check_rct_int();
 
 report("mct_decode");
 }
-- 
2.14.2

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: Allow "-to" on input files in addition to "-t"

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 10:36:51AM +0300, vi0...@gmail.com wrote:
> From: Vitaly _Vi Shukela 
> 
> For some strange reason "-t" option was only implemented
> for input files while both "-t" and "-to" were available
> for use for output files. This made extracting a range from
> input file inconvenient.
> 
> This patch enables -to option for input so one can do
> 
> ffmpeg -ss 1:23:20 -to 1:27:22.3 -i myinput.mkv ...
> 
> Signed-off-by: Vitaly _Vi Shukela 
> ---
>  doc/ffmpeg.texi  |  4 ++--
>  fftools/ffmpeg_opt.c | 17 -
>  2 files changed, 18 insertions(+), 3 deletions(-)

will apply

thanks

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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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


Re: [FFmpeg-devel] [PATCH] avformat/dashenc: fix min_seg_duration option size

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 03:11:45PM +, James Cowgill wrote:
> In the DASHContext structure, min_seg_duration is declared as an int,
> but the AVOption list claimed it was an INT64. Change the option list
> to use the correct size, which should fix some initialization errors
> seen on big-endian platforms.
> 
> Signed-off-by: James Cowgill 
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

thanks

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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


Re: [FFmpeg-devel] [PATCH 1/2] libavcodec: Move ff_print_debug_info2 to mpegutils.c.

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 06:10:58PM +, Kieran Kunhya wrote:
> $subj

>  mpegutils.c |  313 
> +++
>  mpegutils.h |8 +
>  mpegvideo.c |  314 
> 
>  mpegvideo.h |4 
>  4 files changed, 321 insertions(+), 318 deletions(-)
> 67ef33fa104ce335aabb2f17a771365c7d419326  
> 0001-libavcodec-Move-ff_print_debug_info2-to-mpegutils.c.patch
> From 0caa6974d32788e6c73b0b6251afdab419e16a2d Mon Sep 17 00:00:00 2001
> From: Kieran Kunhya 
> Date: Sat, 18 Nov 2017 18:00:48 +
> Subject: [PATCH 1/2] libavcodec: Move ff_print_debug_info2 to mpegutils.c.

LGTM

thx

[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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


[FFmpeg-devel] [PATCH 4/4] fate: add v210 mov test

2017-11-18 Thread Dave Rice
From fe9e3aa13ecf3b4cb81f279696bcc21602662e7a Mon Sep 17 00:00:00 2001
From: Dave Rice 
Date: Sat, 18 Nov 2017 20:32:33 -0500
Subject: [PATCH 4/4] fate: add v210 mov test

---
 tests/fate/vcodec.mak | 4 
 tests/ref/vsynth/vsynth1-mov-v210 | 4 
 2 files changed, 8 insertions(+)
 create mode 100644 tests/ref/vsynth/vsynth1-mov-v210

diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index bbcf25d72a..0206312a53 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -360,6 +360,10 @@ fate-vsynth%-mov-bpp16:  CODEC   = rawvideo
 fate-vsynth%-mov-bpp16:  ENCOPTS = -pix_fmt rgb565le
 fate-vsynth%-mov-bpp16:  FMT  = mov
 
+FATE_VCODEC-$(call ENCDEC, V210, MOV) += mov-v210
+fate-vsynth%-mov-v210:  CODEC = v210
+fate-vsynth%-mov-v210:  FMT   = mov
+
 FATE_VCODEC-$(call ENCDEC, ROQ, ROQ)+= roqvideo
 fate-vsynth%-roqvideo:   CODEC   = roqvideo
 fate-vsynth%-roqvideo:   ENCOPTS = -frames 5
diff --git a/tests/ref/vsynth/vsynth1-mov-v210 
b/tests/ref/vsynth/vsynth1-mov-v210
new file mode 100644
index 00..035f8df6ff
--- /dev/null
+++ b/tests/ref/vsynth/vsynth1-mov-v210
@@ -0,0 +1,4 @@
+a96ffa7a9ccb8242cb462dd698b3e222 *tests/data/fate/vsynth1-mov-v210.mov
+14746427 tests/data/fate/vsynth1-mov-v210.mov
+2ba7f4ca302f3c4147860b9dfb12b6e4 *tests/data/fate/vsynth1-mov-v210.out.rawvideo
+stddev:1.84 PSNR: 42.81 MAXDIFF:   29 bytes:  7603200/  7603200
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 1/4] avformat/movenc: correct ImageDescription for uncompressed ycbcr

2017-11-18 Thread Dave Rice
This patch set updates movenc to write uncompressed ycbcr in mov following 
requirements in Apple’s TN2162, 
https://developer.apple.com/library/content/technotes/tn2162/_index.html. 
Thanks to Carl and Michael for comments on an earlier version of this patchset.


From 26d9ca470f104d8448000b13c2cc97b8fc5c15ba Mon Sep 17 00:00:00 2001
From: Dave Rice 
Date: Thu, 16 Nov 2017 11:53:32 -0500
Subject: [PATCH 1/4] avformat/movenc: correct ImageDescription for
 uncompressed ycbcr

Per
https://developer.apple.com/library/content/technotes/tn2162/_index.html
.
---
 libavformat/movenc.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cc3fc19d9b..ce51c4b3d2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1832,6 +1832,13 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *tr
 char compressor_name[32] = { 0 };
 int avid = 0;
 
+int uncompressed_ycbcr = ((track->par->codec_id == AV_CODEC_ID_RAWVIDEO && 
track->par->format == AV_PIX_FMT_UYVY422)
+   || (track->par->codec_id == AV_CODEC_ID_RAWVIDEO && 
track->par->format == AV_PIX_FMT_YUYV422)
+   ||  track->par->codec_id == AV_CODEC_ID_V308
+   ||  track->par->codec_id == AV_CODEC_ID_V408
+   ||  track->par->codec_id == AV_CODEC_ID_V410
+   ||  track->par->codec_id == AV_CODEC_ID_V210);
+
 avio_wb32(pb, 0); /* size */
 if (mov->encryption_scheme != MOV_ENC_NONE) {
 ffio_wfourcc(pb, "encv");
@@ -1842,11 +1849,15 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *tr
 avio_wb16(pb, 0); /* Reserved */
 avio_wb16(pb, 1); /* Data-reference index */
 
-avio_wb16(pb, 0); /* Codec stream version */
+if (uncompressed_ycbcr) {
+avio_wb16(pb, 2); /* Codec stream version */
+} else {
+avio_wb16(pb, 0); /* Codec stream version */
+}
 avio_wb16(pb, 0); /* Codec stream revision (=0) */
 if (track->mode == MODE_MOV) {
 ffio_wfourcc(pb, "FFMP"); /* Vendor */
-if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO) {
+if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO || 
uncompressed_ycbcr) {
 avio_wb32(pb, 0); /* Temporal Quality */
 avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
 } else {
@@ -1870,7 +1881,10 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *tr
 avio_w8(pb, strlen(compressor_name));
 avio_write(pb, compressor_name, 31);
 
-if (track->mode == MODE_MOV && track->par->bits_per_coded_sample)
+if (track->mode == MODE_MOV &&
+   (track->par->codec_id == AV_CODEC_ID_V410 || track->par->codec_id == 
AV_CODEC_ID_V210))
+avio_wb16(pb, 0x18);
+else if (track->mode == MODE_MOV && track->par->bits_per_coded_sample)
 avio_wb16(pb, track->par->bits_per_coded_sample |
   (track->par->format == AV_PIX_FMT_GRAY8 ? 0x20 : 0));
 else
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 3/4] avformat/movenc: force colr atom for uncompressed yuv in mov

2017-11-18 Thread Dave Rice
From 41da5e48f8788b85dd7a382030bb2866c506cc03 Mon Sep 17 00:00:00 2001
From: Dave Rice 
Date: Sat, 18 Nov 2017 20:31:27 -0500
Subject: [PATCH 3/4] avformat/movenc: force colr atom for uncompressed yuv in
 mov
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As required by Apple’s TN2162.
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index aaa1dedfd7..86960b19c1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1978,7 +1978,7 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *tr
 else
 av_log(mov->fc, AV_LOG_WARNING, "Not writing 'gama' atom. Format 
is not MOV.\n");
 }
-if (mov->flags & FF_MOV_FLAG_WRITE_COLR) {
+if (mov->flags & FF_MOV_FLAG_WRITE_COLR || uncompressed_ycbcr) {
 if (track->mode == MODE_MOV || track->mode == MODE_MP4)
 mov_write_colr_tag(pb, track);
 else
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 2/4] avformat/movenc: write clap atom for uncompressed yuv in mov

2017-11-18 Thread Dave Rice
From e9079167c199791e652fe9cd3550333b819a8a9a Mon Sep 17 00:00:00 2001
From: Dave Rice 
Date: Thu, 16 Nov 2017 11:29:06 -0500
Subject: [PATCH 2/4] avformat/movenc: write clap atom for uncompressed yuv in
 mov

fixes 6145
---
 libavformat/movenc.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ce51c4b3d2..aaa1dedfd7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1686,6 +1686,21 @@ static int mov_write_sv3d_tag(AVFormatContext *s, 
AVIOContext *pb, AVSphericalMa
 return update_size(pb, sv3d_pos);
 }
 
+static int mov_write_clap_tag(AVIOContext *pb, MOVTrack *track)
+{
+avio_wb32(pb, 40);
+ffio_wfourcc(pb, "clap");
+avio_wb32(pb, track->par->width); /* apertureWidth_N */
+avio_wb32(pb, 1); /* apertureWidth_D (= 1) */
+avio_wb32(pb, track->height); /* apertureHeight_N */
+avio_wb32(pb, 1); /* apertureHeight_D (= 1) */
+avio_wb32(pb, 0); /* horizOff_N (= 0) */
+avio_wb32(pb, 1); /* horizOff_D (= 1) */
+avio_wb32(pb, 0); /* vertOff_N (= 0) */
+avio_wb32(pb, 1); /* vertOff_D (= 1) */
+return 40;
+}
+
 static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
 {
 AVRational sar;
@@ -1984,6 +1999,10 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *tr
 mov_write_pasp_tag(pb, track);
 }
 
+if (uncompressed_ycbcr){
+mov_write_clap_tag(pb, track);
+}
+
 if (mov->encryption_scheme != MOV_ENC_NONE) {
 ff_mov_cenc_write_sinf_tag(track, pb, mov->encryption_kid);
 }
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH] Download dash content with byte range info

2017-11-18 Thread 刘歧

> 在 2017年11月18日,07:13,Colin NG  写道:
> 
> ---
> libavformat/dashdec.c | 39 +--
> 1 file changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 0e3afd2..671ae9d 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -522,6 +522,25 @@ static enum AVMediaType get_content_type(xmlNodePtr node)
> return type;
> }
> 
> +static struct fragment * get_Fragment(char *range)
static struct fragment *get_fragment(char *range)
> +{
> +struct fragment * seg =  av_mallocz(sizeof(struct fragment));
> +
> +if (!seg)
> +return NULL;
> +
> +memset(seg, 0, sizeof(struct fragment));
remove memset.
> +seg->size = -1;
> +if (range)  {
> +char *str_end_offset;
> +char *str_offset = av_strtok(range, "-", _end_offset);
> +seg->url_offset = strtoll(str_offset, NULL, 10);
> +seg->size = strtoll(str_end_offset, NULL, 10) -seg->url_offset;
> +}
> +
> +return seg;
> +}
> +
> static int parse_manifest_segmenturlnode(AVFormatContext *s, struct 
> representation *rep,
>  xmlNodePtr fragmenturl_node,
>  xmlNodePtr *baseurl_nodes,
> @@ -530,33 +549,40 @@ static int 
> parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
> {
> char *initialization_val = NULL;
> char *media_val = NULL;
> +char *range_val = NULL;
> 
> if (!av_strcasecmp(fragmenturl_node->name, (const char 
> *)"Initialization")) {
> initialization_val = xmlGetProp(fragmenturl_node, "sourceURL");
> -if (initialization_val) {
> -rep->init_section = av_mallocz(sizeof(struct fragment));
> +range_val = xmlGetProp(fragmenturl_node, "range");
> +if (initialization_val || range_val) {
> +rep->init_section = get_Fragment(range_val);
> if (!rep->init_section) {
> xmlFree(initialization_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> rep->init_section->url = get_content_url(baseurl_nodes, 4,
>  rep_id_val,
>  rep_bandwidth_val,
>  initialization_val);
> +
> if (!rep->init_section->url) {
> av_free(rep->init_section);
> xmlFree(initialization_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> -rep->init_section->size = -1;
> xmlFree(initialization_val);
> +xmlFree(range_val);
> }
> } else if (!av_strcasecmp(fragmenturl_node->name, (const char 
> *)"SegmentURL")) {
> media_val = xmlGetProp(fragmenturl_node, "media");
> -if (media_val) {
> -struct fragment *seg = av_mallocz(sizeof(struct fragment));
> +range_val = xmlGetProp(fragmenturl_node, "mediaRange");
> +if (media_val || range_val) {
> +struct fragment *seg =  get_Fragment(range_val);
> if (!seg) {
> xmlFree(media_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> seg->url = get_content_url(baseurl_nodes, 4,
> @@ -566,11 +592,12 @@ static int 
> parse_manifest_segmenturlnode(AVFormatContext *s, struct representati
> if (!seg->url) {
> av_free(seg);
> xmlFree(media_val);
> +xmlFree(range_val);
> return AVERROR(ENOMEM);
> }
> -seg->size = -1;
> dynarray_add(>fragments, >n_fragments, seg);
> xmlFree(media_val);
> +xmlFree(range_val);
> }
> }
> 
> -- 
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 09/13] compat/cuda: Pass a logging context to load functions

2017-11-18 Thread Timo Rothenpieler

lgtm



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec: Implement mpeg2 nvdec hwaccel

2017-11-18 Thread Timo Rothenpieler

Am 18.11.2017 um 17:38 schrieb Carl Eugen Hoyos:

2017-11-16 17:36 GMT+01:00 Philip Langdale :


+AVHWAccel ff_mpeg2_nvdec_hwaccel = {
+.name = "mpeg2_nvdec",
+.type = AVMEDIA_TYPE_VIDEO,
+.id   = AV_CODEC_ID_MPEG2VIDEO,
+.pix_fmt  = AV_PIX_FMT_CUDA,
+.start_frame  = nvdec_mpeg12_start_frame,
+.end_frame= nvdec_mpeg12_end_frame,
+.decode_slice = nvdec_mpeg12_decode_slice,
+.frame_params = nvdec_mpeg12_frame_params,
+.init = ff_nvdec_decode_init,
+.uninit   = ff_nvdec_decode_uninit,
+.priv_data_size   = sizeof(NVDECContext),
+};
+#endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a75c885768..5b25a9a8ac 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@

  #define LIBAVCODEC_VERSION_MAJOR  58
  #define LIBAVCODEC_VERSION_MINOR   3
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103


It doesn't really matter but we usually do a minor
bump when adding a hwaccel/encoder/demuxer/...


Doing a bunch of minor bumps for all the nvdec hwaccels that are coming 
in in short succession seems a bit too forward to me. Which is why I 
opted for micro bumps so far.




smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Source for http://ffmpeg.org/contact.html and documentation.html ?

2017-11-18 Thread Mark Thompson
On 18/11/17 22:32, Jim DeLaHunt wrote:
> Hello, all:
> 
> From what sources are the web pages http://ffmpeg.org/contact.html and 
> https://ffmpeg.org/documentation.html generated?
> 
> Sister web pages, like https://ffmpeg.org/ffmpeg.html and 
> http://ffmpeg.org/developer.html, are generated from .texi files in the 
> FFmpeg repository. Are contact.html and documentation.html different?
> 
> And, are these top-level website pages open to patches from ordinary FFmpeg 
> contributors?

Yes.  The repo can be found at .

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


[FFmpeg-devel] Source for http://ffmpeg.org/contact.html and documentation.html ?

2017-11-18 Thread Jim DeLaHunt

Hello, all:

From what sources are the web pages http://ffmpeg.org/contact.html and 
https://ffmpeg.org/documentation.html generated?


Sister web pages, like https://ffmpeg.org/ffmpeg.html and 
http://ffmpeg.org/developer.html, are generated from .texi files in the 
FFmpeg repository. Are contact.html and documentation.html different?


And, are these top-level website pages open to patches from ordinary 
FFmpeg contributors?


I had a look at the documentation.html, the repository, and 
https://trac.ffmpeg.org/wiki, and didn't find my answer there.


Best regards,
    --Jim DeLaHunt, Vancouver, Canada

--
--Jim DeLaHunt, j...@jdlh.com http://blog.jdlh.com/ (http://jdlh.com/)
  multilingual websites consultant

  355-1027 Davie St, Vancouver BC V6E 4L2, Canada
 Canada mobile +1-604-376-8953

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


[FFmpeg-devel] [PATCH] avcodec: Implement mpeg1 nvdec hwaccel

2017-11-18 Thread Philip Langdale
Once I remembered that there's a separate decoder type for mpeg1,
even though params struct is shared with mpeg2, everything worked.

Signed-off-by: Philip Langdale 
---
 Changelog |  2 +-
 configure |  2 ++
 libavcodec/Makefile   |  1 +
 libavcodec/allcodecs.c|  1 +
 libavcodec/mpeg12dec.c|  3 +++
 libavcodec/nvdec.c|  1 +
 libavcodec/nvdec_mpeg12.c | 18 +-
 libavcodec/version.h  |  4 ++--
 8 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/Changelog b/Changelog
index cda59166fc..7833c4ad09 100644
--- a/Changelog
+++ b/Changelog
@@ -13,7 +13,7 @@ version :
 - PCE support for extended channel layouts in the AAC encoder
 - native aptX encoder and decoder
 - Raw aptX muxer and demuxer
-- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-2, VC1 and VP9 hwaccel decoding
+- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2, VC1 and VP9 hwaccel decoding
 - Intel QSV-accelerated overlay filter
 - mcompand audio filter
 
diff --git a/configure b/configure
index 8b7b7e164b..31e7fcc4c0 100755
--- a/configure
+++ b/configure
@@ -2698,6 +2698,8 @@ mjpeg_cuvid_hwaccel_select="mjpeg_cuvid_decoder"
 mpeg_xvmc_hwaccel_deps="xvmc"
 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
 mpeg1_cuvid_hwaccel_select="mpeg1_cuvid_decoder"
+mpeg1_nvdec_hwaccel_deps="nvdec"
+mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 494c76da76..0573454c7b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -849,6 +849,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
 OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
+OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)+= nvdec_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)+= vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
 OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e0adb71951..e9df7049de 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -87,6 +87,7 @@ static void register_all(void)
 REGISTER_HWACCEL(HEVC_VIDEOTOOLBOX, hevc_videotoolbox);
 REGISTER_HWACCEL(MJPEG_CUVID,   mjpeg_cuvid);
 REGISTER_HWACCEL(MPEG1_CUVID,   mpeg1_cuvid);
+REGISTER_HWACCEL(MPEG1_NVDEC,   mpeg1_nvdec);
 REGISTER_HWACCEL(MPEG1_XVMC,mpeg1_xvmc);
 REGISTER_HWACCEL(MPEG1_VDPAU,   mpeg1_vdpau);
 REGISTER_HWACCEL(MPEG1_VIDEOTOOLBOX, mpeg1_videotoolbox);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 2b213eebcd..5a51d09bb0 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1130,6 +1130,9 @@ static void quant_matrix_rebuild(uint16_t *matrix, const 
uint8_t *old_perm,
 }
 
 static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_MPEG1_NVDEC_HWACCEL
+AV_PIX_FMT_CUDA,
+#endif
 #if CONFIG_MPEG1_XVMC_HWACCEL
 AV_PIX_FMT_XVMC,
 #endif
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 3d62840e9f..c29d45f9b3 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -54,6 +54,7 @@ static int map_avcodec_id(enum AVCodecID id)
 switch (id) {
 case AV_CODEC_ID_H264:   return cudaVideoCodec_H264;
 case AV_CODEC_ID_HEVC:   return cudaVideoCodec_HEVC;
+case AV_CODEC_ID_MPEG1VIDEO: return cudaVideoCodec_MPEG1;
 case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2;
 case AV_CODEC_ID_VC1:return cudaVideoCodec_VC1;
 case AV_CODEC_ID_VP9:return cudaVideoCodec_VP9;
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index 127e843d85..9913ff17c8 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -1,5 +1,5 @@
 /*
- * MPEG-2 HW decode acceleration through NVDEC
+ * MPEG-1/2 HW decode acceleration through NVDEC
  *
  * Copyright (c) 2017 Philip Langdale
  *
@@ -150,3 +150,19 @@ AVHWAccel ff_mpeg2_nvdec_hwaccel = {
 .priv_data_size   = sizeof(NVDECContext),
 };
 #endif
+
+#if CONFIG_MPEG1_NVDEC_HWACCEL
+AVHWAccel ff_mpeg1_nvdec_hwaccel = {
+.name = "mpeg1_nvdec",
+.type = AVMEDIA_TYPE_VIDEO,
+.id   = AV_CODEC_ID_MPEG1VIDEO,
+.pix_fmt  = AV_PIX_FMT_CUDA,
+.start_frame  = nvdec_mpeg12_start_frame,
+.end_frame= nvdec_mpeg12_end_frame,
+.decode_slice = nvdec_mpeg12_decode_slice,
+.frame_params = nvdec_mpeg12_frame_params,
+.init = ff_nvdec_decode_init,
+.uninit   = ff_nvdec_decode_uninit,
+.priv_data_size   = sizeof(NVDECContext),
+};
+#endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 

Re: [FFmpeg-devel] [DEVEL][PATCH v3] ffmpeg: fix channel_layout bug on non-default layout

2017-11-18 Thread pkv.stream

Le 18/11/2017 à 9:26 PM, Michael Niedermayer a écrit :

On Sat, Nov 18, 2017 at 11:41:54AM +0100, pkv.stream wrote:

Hi Michael

  ffmpeg_opt.c |   12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)
a7c71fb1ccd7d91b61033be70dfd324b4e3f3c34  
0001-ffmpeg-fix-channel_layout-bug-on-non-default-layout.patch
 From fb7f7f6e01cc242e13d0e640f583dffe6e7a8ada Mon Sep 17 00:00:00 2001
From: pkviet
Date: Mon, 2 Oct 2017 11:14:31 +0200
Subject: [PATCH] ffmpeg: fix channel_layout bug on non-default layout

Fix for ticket 6706.
The -channel_layout option was not working when the channel layout was not
a default one (ex: for 4 channels, quad was interpreted as 4.0 which is
the default layout for 4 channels; or octagonal interpreted as 7.1).
This led to the spurious auto-insertion of an auto-resampler filter
remapping the channels even if input and output had identical channel
layouts.
The fix operates by directly calling the channel layout if defined in
options. If the layout is undefined, the default layout is selected as
before the fix.
---
  fftools/ffmpeg_opt.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ca6f10d..8941d66 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1785,6 +1785,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, 
AVFormatContext *oc, in
  AVStream *st;
  OutputStream *ost;
  AVCodecContext *audio_enc;
+AVDictionaryEntry *output_layout;
  ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
  st  = ost->st;
@@ -1799,7 +1800,10 @@ static OutputStream *new_audio_stream(OptionsContext *o, 
AVFormatContext *oc, in
  char *sample_fmt = NULL;
  MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st);
-
+output_layout = av_dict_get(ost->encoder_opts,"channel_layout", NULL, 
AV_DICT_IGNORE_SUFFIX);
+if (output_layout) {
+audio_enc->channel_layout = strtoull(output_layout->value, NULL, 
10);
+}

why is this handled different from audio_channels ?
that is why is this not using MATCH_PER_STREAM_OPT() ?
(yes this would require some changes but i wonder why this would be
  handled differently)

Hi
I did try to use the MATCH_PER_STREAM_OPT() but didn't manage to
have it working. Also I was a bit hesitant to modify the
OptionsContext struct, and preferred something minimal.
If you think this can definitely be made to work without too much
coding and prefer such a solution, I'll retry working on a
MATCH_PER_STREAM_OPT() solution.

i dont really know if it "can definitely be made to work without too much
coding", it just seemed odd how this is handled differently

I have another version of the patch working with MATCH_PER_STREAM_OPT() ;
but the changes to code are more important, and it's a bit hacky
(defines an internal OptionDef) ... so not sure it is any better
than the few lines of patch v3.
I've checked that stream specifiers ( :a:0 ) are passed correctly
and that two streams with different layouts are also treated
correctly (the previous patch without MATCH_PER_STREAM_OPT() works
also; those were two points you singled out in your review).
  I have no real opinion on the best course, which to pick or even to
let the bug hanging (I'm only trying to fix it due to my work on the
aac PCE patch of atomnuker ; the bug prevents full use of the new
PCE capability).
It's Ok with me if you decide to forgo these attempts to fix the bug
and let the bug stay.
I'm not impacted by the bug in my case use (encode 16 channels in
aac); just trying to be thorough in my (akward) contributions and
trying to give back to the project.
Tell me the best course; or if you see a way to make my
MATCH_PER_STREAM_OPT() code less hacky.

iam sure theres a way to do this less hacky
why do you need a 2nd table ? or rather why does it not work if you
put the entry in the main table ? (so there are 2 entries one for
OPT_SPEC and one for teh callback, will it not send the data to both
matching entries ?


Hi
it does work in the main table.
I didn't want to pollute it. But if you say it is OK then I'll update 
accordingly and send a separate patch then.

thanks

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


Re: [FFmpeg-devel] [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 11:15:55AM -0500, DeHackEd wrote:
> On 11/18/2017 05:56 AM, Michael Niedermayer wrote:
> > On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote:
> >> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> >> index aacc185..877fd67 100644
> >> --- a/fftools/ffmpeg_filter.c
> >> +++ b/fftools/ffmpeg_filter.c
> >> @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg)
> >>  graph = avfilter_graph_alloc();
> >>  if (!graph)
> >>  return AVERROR(ENOMEM);
> >> +graph->nb_threads = 1;
> > 
> > if you checked that it doesnt reduce threads for simple & complex
> > graphs that are used then LGTM
> > 
> 
> Yes I have verified that to be the case. Test method was
> $ strace -e trace=clone ./ffmpeg_g -filter_complex 'testsrc2[out]' ...

ok, will apply

thanks

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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


Re: [FFmpeg-devel] [DEVEL][PATCH v3] ffmpeg: fix channel_layout bug on non-default layout

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 11:41:54AM +0100, pkv.stream wrote:
> Hi Michael
>   ffmpeg_opt.c |   12 ++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
> a7c71fb1ccd7d91b61033be70dfd324b4e3f3c34  
> 0001-ffmpeg-fix-channel_layout-bug-on-non-default-layout.patch
>  From fb7f7f6e01cc242e13d0e640f583dffe6e7a8ada Mon Sep 17 00:00:00 2001
> From: pkviet
> Date: Mon, 2 Oct 2017 11:14:31 +0200
> Subject: [PATCH] ffmpeg: fix channel_layout bug on non-default layout
> 
> Fix for ticket 6706.
> The -channel_layout option was not working when the channel layout was not
> a default one (ex: for 4 channels, quad was interpreted as 4.0 which is
> the default layout for 4 channels; or octagonal interpreted as 7.1).
> This led to the spurious auto-insertion of an auto-resampler filter
> remapping the channels even if input and output had identical channel
> layouts.
> The fix operates by directly calling the channel layout if defined in
> options. If the layout is undefined, the default layout is selected as
> before the fix.
> ---
>   fftools/ffmpeg_opt.c | 12 ++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index ca6f10d..8941d66 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -1785,6 +1785,7 @@ static OutputStream 
> *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in
>   AVStream *st;
>   OutputStream *ost;
>   AVCodecContext *audio_enc;
> +AVDictionaryEntry *output_layout;
>   ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
>   st  = ost->st;
> @@ -1799,7 +1800,10 @@ static OutputStream 
> *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in
>   char *sample_fmt = NULL;
>   MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, 
>  oc, st);
> -
> +output_layout = av_dict_get(ost->encoder_opts,"channel_layout", 
> NULL, AV_DICT_IGNORE_SUFFIX);
> +if (output_layout) {
> +audio_enc->channel_layout = strtoull(output_layout->value, 
> NULL, 10);
> +}
> >>>why is this handled different from audio_channels ?
> >>>that is why is this not using MATCH_PER_STREAM_OPT() ?
> >>>(yes this would require some changes but i wonder why this would be
> >>>  handled differently)
> >>Hi
> >>I did try to use the MATCH_PER_STREAM_OPT() but didn't manage to
> >>have it working. Also I was a bit hesitant to modify the
> >>OptionsContext struct, and preferred something minimal.
> >>If you think this can definitely be made to work without too much
> >>coding and prefer such a solution, I'll retry working on a
> >>MATCH_PER_STREAM_OPT() solution.
> >i dont really know if it "can definitely be made to work without too much
> >coding", it just seemed odd how this is handled differently
> 
> I have another version of the patch working with MATCH_PER_STREAM_OPT() ;
> but the changes to code are more important, and it's a bit hacky
> (defines an internal OptionDef) ... so not sure it is any better
> than the few lines of patch v3.
> I've checked that stream specifiers ( :a:0 ) are passed correctly
> and that two streams with different layouts are also treated
> correctly (the previous patch without MATCH_PER_STREAM_OPT() works
> also; those were two points you singled out in your review).
>  I have no real opinion on the best course, which to pick or even to
> let the bug hanging (I'm only trying to fix it due to my work on the
> aac PCE patch of atomnuker ; the bug prevents full use of the new
> PCE capability).
> It's Ok with me if you decide to forgo these attempts to fix the bug
> and let the bug stay.
> I'm not impacted by the bug in my case use (encode 16 channels in
> aac); just trying to be thorough in my (akward) contributions and
> trying to give back to the project.

> Tell me the best course; or if you see a way to make my
> MATCH_PER_STREAM_OPT() code less hacky.

iam sure theres a way to do this less hacky
why do you need a 2nd table ? or rather why does it not work if you
put the entry in the main table ? (so there are 2 entries one for
OPT_SPEC and one for teh callback, will it not send the data to both
matching entries ?



> 
> Regards
> 
> >[...]
> >
> >
> >___
> >ffmpeg-devel mailing list
> >ffmpeg-devel@ffmpeg.org
> >http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 

>  cmdutils.h   |1 +
>  ffmpeg.h |3 +++
>  ffmpeg_opt.c |   41 +
>  3 files changed, 41 insertions(+), 4 deletions(-)
> 7c1249f0cb4daa1aebbf94b0e785e644997f754a  0001-ffmpeg-fix-ticket-6706.patch
> From 00c3c724544b16c19282b39644e2584f9c4a4181 Mon Sep 17 00:00:00 2001
> From: pkviet 
> Date: Sat, 18 Nov 2017 

Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Mark Thompson
On 18/11/17 20:18, Rostislav Pehlivanov wrote:
> On 18 November 2017 at 20:11, James Almer  wrote:
> 
>> On 11/18/2017 5:03 PM, Rostislav Pehlivanov wrote:
>>> On 18 November 2017 at 19:17, James Almer  wrote:
>>>
 On 11/18/2017 4:07 PM, Mark Thompson wrote:
> On 18/11/17 19:00, Rostislav Pehlivanov wrote:
>> On 18 November 2017 at 18:47, Mark Thompson  wrote:
>>
>>> ---
>>>  doc/APIchanges   |  4 
>>>  libavcodec/avcodec.h | 13 +
>>>  libavcodec/utils.c   | 16 +---
>>>  libavcodec/version.h |  3 +++
>>>  4 files changed, 25 insertions(+), 11 deletions(-)
>>>
>>>
>>>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>>>  {
>>> diff --git a/libavcodec/version.h b/libavcodec/version.h
>>> index 5b25a9a8ac..693f67386c 100644
>>> --- a/libavcodec/version.h
>>> +++ b/libavcodec/version.h
>>> @@ -123,6 +123,9 @@
>>>  #ifndef FF_API_CODEC_GET_SET
>>>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
>>>  #endif
>>> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
>>> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR <
>> 60)
>>>
>>
>> 60? That's 2 bumps away, this should be 59, no?
>
> Two bumps away is the usual number, isn't it?  Or does it count as
 not-bumped-yet for this purpose because we are still in the unstable
>> period?

 The number doesn't matter as long as the condition evaluates to true
 when it's meant to.
 If you use 59 and there's a bump before the two years period for this
 specific deprecation is over, then the line will have to be changed to
 60 during said bump to make sure the API doesn't get disabled.
 However using 60 would mean that the line can be left alone. The bump
 that changes the major to 60 is unlikely to happen before the two year
 mark.

 So it's fine as is. No need to change it.


>>> It'll be forgotten and it'll take 4 years to remove. How is anyone
>> supposed
>>> to know when something's meant to be removed aside from the MAJOR
>> version?
>>
>> By git blaming version.h to look at the exact date of the commits that
>> deprecated every listed API, same as it's done every time a bump takes
>> place.
>>
>> As long as whoever handles the bump does it properly then it shouldn't
>> make a difference. But if you feel more comfortable making it 59 then it
>> can be changed. Both values are fine.
>>
> 
> I'd be more comfortable with 59, that should save effort on the part of the
> person doing the bump.

Ok, changed to 59.

Thanks,

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


Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Rostislav Pehlivanov
On 18 November 2017 at 20:11, James Almer  wrote:

> On 11/18/2017 5:03 PM, Rostislav Pehlivanov wrote:
> > On 18 November 2017 at 19:17, James Almer  wrote:
> >
> >> On 11/18/2017 4:07 PM, Mark Thompson wrote:
> >>> On 18/11/17 19:00, Rostislav Pehlivanov wrote:
>  On 18 November 2017 at 18:47, Mark Thompson  wrote:
> 
> > ---
> >  doc/APIchanges   |  4 
> >  libavcodec/avcodec.h | 13 +
> >  libavcodec/utils.c   | 16 +---
> >  libavcodec/version.h |  3 +++
> >  4 files changed, 25 insertions(+), 11 deletions(-)
> >
> >
> >  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
> >  {
> > diff --git a/libavcodec/version.h b/libavcodec/version.h
> > index 5b25a9a8ac..693f67386c 100644
> > --- a/libavcodec/version.h
> > +++ b/libavcodec/version.h
> > @@ -123,6 +123,9 @@
> >  #ifndef FF_API_CODEC_GET_SET
> >  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
> >  #endif
> > +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
> > +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR <
> 60)
> >
> 
>  60? That's 2 bumps away, this should be 59, no?
> >>>
> >>> Two bumps away is the usual number, isn't it?  Or does it count as
> >> not-bumped-yet for this purpose because we are still in the unstable
> period?
> >>
> >> The number doesn't matter as long as the condition evaluates to true
> >> when it's meant to.
> >> If you use 59 and there's a bump before the two years period for this
> >> specific deprecation is over, then the line will have to be changed to
> >> 60 during said bump to make sure the API doesn't get disabled.
> >> However using 60 would mean that the line can be left alone. The bump
> >> that changes the major to 60 is unlikely to happen before the two year
> >> mark.
> >>
> >> So it's fine as is. No need to change it.
> >>
> >>
> > It'll be forgotten and it'll take 4 years to remove. How is anyone
> supposed
> > to know when something's meant to be removed aside from the MAJOR
> version?
>
> By git blaming version.h to look at the exact date of the commits that
> deprecated every listed API, same as it's done every time a bump takes
> place.
>
> As long as whoever handles the bump does it properly then it shouldn't
> make a difference. But if you feel more comfortable making it 59 then it
> can be changed. Both values are fine.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

I'd be more comfortable with 59, that should save effort on the part of the
person doing the bump.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread James Almer
On 11/18/2017 5:03 PM, Rostislav Pehlivanov wrote:
> On 18 November 2017 at 19:17, James Almer  wrote:
> 
>> On 11/18/2017 4:07 PM, Mark Thompson wrote:
>>> On 18/11/17 19:00, Rostislav Pehlivanov wrote:
 On 18 November 2017 at 18:47, Mark Thompson  wrote:

> ---
>  doc/APIchanges   |  4 
>  libavcodec/avcodec.h | 13 +
>  libavcodec/utils.c   | 16 +---
>  libavcodec/version.h |  3 +++
>  4 files changed, 25 insertions(+), 11 deletions(-)
>
>
>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>  {
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 5b25a9a8ac..693f67386c 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -123,6 +123,9 @@
>  #ifndef FF_API_CODEC_GET_SET
>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
>  #endif
> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
>

 60? That's 2 bumps away, this should be 59, no?
>>>
>>> Two bumps away is the usual number, isn't it?  Or does it count as
>> not-bumped-yet for this purpose because we are still in the unstable period?
>>
>> The number doesn't matter as long as the condition evaluates to true
>> when it's meant to.
>> If you use 59 and there's a bump before the two years period for this
>> specific deprecation is over, then the line will have to be changed to
>> 60 during said bump to make sure the API doesn't get disabled.
>> However using 60 would mean that the line can be left alone. The bump
>> that changes the major to 60 is unlikely to happen before the two year
>> mark.
>>
>> So it's fine as is. No need to change it.
>>
>>
> It'll be forgotten and it'll take 4 years to remove. How is anyone supposed
> to know when something's meant to be removed aside from the MAJOR version?

By git blaming version.h to look at the exact date of the commits that
deprecated every listed API, same as it's done every time a bump takes
place.

As long as whoever handles the bump does it properly then it shouldn't
make a difference. But if you feel more comfortable making it 59 then it
can be changed. Both values are fine.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] FFmpeg 3.4.1

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 09:50:33AM +0100, Hendrik Leppkes wrote:
> On Sat, Nov 18, 2017 at 3:05 AM, Michael Niedermayer
>  wrote:
> > On Fri, Nov 17, 2017 at 09:55:47AM +0100, Hendrik Leppkes wrote:
> >> On Fri, Nov 17, 2017 at 5:00 AM, Michael Niedermayer
> >>  wrote:
> >> > On Thu, Nov 16, 2017 at 01:51:34PM +0100, Carl Eugen Hoyos wrote:
> >> >> 2017-11-16 13:44 GMT+01:00 Michael Niedermayer :
> >> >> > On Thu, Nov 16, 2017 at 01:04:27AM +0100, Carl Eugen Hoyos wrote:
> >> >> >> 2017-11-15 13:34 GMT+01:00 Michael Niedermayer 
> >> >> >> :
> >> >> >> > Hi all
> >> >> >> >
> >> >> >> > I intend to make 3.4.1 very soon
> >> >> >>
> >> >> >> Shouldn't we first decide on how to proceed with #6775?
> >> >> >
> >> >> > This would be ideal.
> >> >> >
> >> >> > IIUC this is a regression from 
> >> >> > bddb2343b6e594e312dadb5d21b408702929ae04
> >> >>
> >> >> This was confirmed by more than one developer, yes.
> >> >>
> >> >> > I see a patch that is said to improve 6775, can that be applied and
> >> >> > would that resolve this ?
> >> >>
> >> >> Iiuc, it would not completely resolve the issue, see:
> >> >> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=881536
> >> >>
> >> >> > If so why was it not applied yet ?
> >> >>
> >> >> The patch did not get support here, see:
> >> >> [FFmpeg-devel] [PATCH] lavc: reset codec on receiving packet after EOF
> >> >> in compat_decode
> >> >
> >> >
> >> > Is someone working on fixing this better than with the available patch ?
> >> >
> >>
> >> I don't even agree this needs fixing. Those projects use the API wrong.
> >
> > Had we documented the correct/wrong use precissely in the past when
> > these wrong uses where written ?
> >
> > Because if it was documented then few should have made the mistake.
> > But it seems this affects multiple projects, so i wonder if our API
> > really excluded the use
> >
> 
> Apparently not well enough, but I also don't even understand why you
> would *want* to drain in the middle of decoding.
> 
> The only mention of sending NULL/0 packets (in 3.0 docs, before the
> new API was introduced) do include the "at the end", however.
> 
> From CODEC_CAP_DELAY:
>  * Decoders:
>  * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
>  * avpkt->size=0 at the end to get the delayed data until the decoder no 
> longer
>  * returns frames.
> 
> From avcodec_decode_video2
> * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
> * between input and output, these need to be fed with avpkt->data=NULL,
> * avpkt->size=0 at the end to return the remaining frames.
> 
> There is a few more mentions of the same concept, but as far as I can
> see all include the key words "at the end".
> 

> For the suggested patch, draining and flushing in the middle of a
> bitstream is still going to result in problems, though, since it
> removes all reference frames, for example.
> The original behavior cannot really be stored, which was to just keep
> feeding frames into the decoder after a drain without a flush.
> However, some decoders actually crashed when you did this, so this was
> a rather unsafe action to begin with (not an issue any longer, since
> this pattern is now blocked).

Did the previous code really work if the frame after a flush was not a
new keyframe or there was some use of previous references ?


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

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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


Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Rostislav Pehlivanov
On 18 November 2017 at 19:17, James Almer  wrote:

> On 11/18/2017 4:07 PM, Mark Thompson wrote:
> > On 18/11/17 19:00, Rostislav Pehlivanov wrote:
> >> On 18 November 2017 at 18:47, Mark Thompson  wrote:
> >>
> >>> ---
> >>>  doc/APIchanges   |  4 
> >>>  libavcodec/avcodec.h | 13 +
> >>>  libavcodec/utils.c   | 16 +---
> >>>  libavcodec/version.h |  3 +++
> >>>  4 files changed, 25 insertions(+), 11 deletions(-)
> >>>
> >>>
> >>>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
> >>>  {
> >>> diff --git a/libavcodec/version.h b/libavcodec/version.h
> >>> index 5b25a9a8ac..693f67386c 100644
> >>> --- a/libavcodec/version.h
> >>> +++ b/libavcodec/version.h
> >>> @@ -123,6 +123,9 @@
> >>>  #ifndef FF_API_CODEC_GET_SET
> >>>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
> >>>  #endif
> >>> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
> >>> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
> >>>
> >>
> >> 60? That's 2 bumps away, this should be 59, no?
> >
> > Two bumps away is the usual number, isn't it?  Or does it count as
> not-bumped-yet for this purpose because we are still in the unstable period?
>
> The number doesn't matter as long as the condition evaluates to true
> when it's meant to.
> If you use 59 and there's a bump before the two years period for this
> specific deprecation is over, then the line will have to be changed to
> 60 during said bump to make sure the API doesn't get disabled.
> However using 60 would mean that the line can be left alone. The bump
> that changes the major to 60 is unlikely to happen before the two year
> mark.
>
> So it's fine as is. No need to change it.
>
>
It'll be forgotten and it'll take 4 years to remove. How is anyone supposed
to know when something's meant to be removed aside from the MAJOR version?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 11:12:17AM -0800, Sasi Inguva wrote:
> Signed-off-by: Sasi Inguva 
> ---
>  libavformat/mov.c| 54 
> 
>  tests/fate/mov.mak   |  5 
>  tests/ref/fate/mov-guess-delay-1 |  3 +++
>  tests/ref/fate/mov-guess-delay-2 |  3 +++
>  4 files changed, 65 insertions(+)
>  create mode 100644 tests/ref/fate/mov-guess-delay-1
>  create mode 100644 tests/ref/fate/mov-guess-delay-2
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index fd170baa57..7354652c6e 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -3213,6 +3213,58 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, 
> unsigned int* ctts_count, uns
>  return *ctts_count;
>  }
>  
> +static void mov_guess_video_delay(MOVContext *c, AVStream* st) {
> +MOVStreamContext *msc = st->priv_data;
> +int ind;
> +int ctts_ind = 0;
> +int ctts_sample = 0;
> +int64_t curr_pts = AV_NOPTS_VALUE;
> +int64_t prev_pts = AV_NOPTS_VALUE;
> +int64_t prev_max_pts = AV_NOPTS_VALUE;
> +int num_swaps = 0;
> +
> +if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
> +(st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
> + st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
> + st->codecpar->codec_id == AV_CODEC_ID_VC1 ||
> + st->codecpar->codec_id == AV_CODEC_ID_H263 ||
> + st->codecpar->codec_id == AV_CODEC_ID_H264 ||
> + st->codecpar->codec_id == AV_CODEC_ID_HEVC)) {

Do all these cases really need this ?

video_delay = 0 is also a valid value so it can be set to 0 already
intentionally


> +st->codecpar->video_delay = 0;
> +for(ind = 0; ind < st->nb_index_entries && ctts_ind < 
> msc->ctts_count; ++ind) {
> +curr_pts = st->index_entries[ind].timestamp + 
> msc->ctts_data[ctts_ind].duration;
> +

> +// This is used as an indication that the previous GOP has ended 
> and a
> +// new GOP has started.

this is not neccesary a GOP uless i misread the code


> +if (curr_pts > prev_max_pts) {
> +st->codecpar->video_delay = 
> FFMIN(FFMAX(st->codecpar->video_delay, num_swaps), 16);
> +num_swaps = 0;
> +prev_max_pts = curr_pts;
> +}
> +
> +// Compute delay as the no. of "drop"s in PTS inside a GOP.
> +// Frames: I0 I1 B0 B1 B2
> +// PTS: 0  4  1  2  3 -> num_swaps = delay = 1 (4->1)
> +//
> +// Frames: I0 I1 B1 B0 B2
> +// PTS: 0  4  2  1  3 -> num_swaps = delay = 2 (4->2, 2->1)

This may be incorret

consider
PTS0  5  2  1  4  3
BUFFER 0  05 25 25 45 45 5
OUT  0  1  2  3  4  5

So this is a delay = 2 but your code would set 3 i think


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

Those who are best at talking, realize last or never when they are wrong.


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


Re: [FFmpeg-devel] RPM library deployments

2017-11-18 Thread Lou Logan
On Fri, Nov 17, 2017, at 01:10 PM, Gardner, Greg - 0995 - MITLL wrote:
> Hey folks,
> 
> Could someone put me in touch with whoever builds the ffmpeg-libs RPM?

It's not from us, a third-party makes that, but I'm not sure who. FFmpeg
only provides source code.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] ffmpeg: Allow "-to" on input files in addition to "-t"

2017-11-18 Thread vi0oss
From: Vitaly _Vi Shukela 

For some strange reason "-t" option was only implemented
for input files while both "-t" and "-to" were available
for use for output files. This made extracting a range from
input file inconvenient.

This patch enables -to option for input so one can do

ffmpeg -ss 1:23:20 -to 1:27:22.3 -i myinput.mkv ...

Signed-off-by: Vitaly _Vi Shukela 
---
 doc/ffmpeg.texi  |  4 ++--
 fftools/ffmpeg_opt.c | 17 -
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 7db80ebf6a..9a90d7327a 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -289,8 +289,8 @@ see @ref{time duration syntax,,the Time duration section in 
the ffmpeg-utils(1)
 
 -to and -t are mutually exclusive and -t has priority.
 
-@item -to @var{position} (@emph{output})
-Stop writing the output at @var{position}.
+@item -to @var{position} (@emph{input/output})
+Stop writing the output or reading the input at @var{position}.
 @var{position} must be a time duration specification,
 see @ref{time duration syntax,,the Time duration section in the 
ffmpeg-utils(1) manual,ffmpeg-utils}.
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 47d384166c..f66f672c3c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -976,6 +976,21 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 char *data_codec_name = NULL;
 int scan_all_pmts_set = 0;
 
+if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
+o->stop_time = INT64_MAX;
+av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; 
using -t.\n");
+}
+
+if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
+int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : 
o->start_time;
+if (o->stop_time <= start_time) {
+av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; 
aborting.\n");
+exit_program(1);
+} else {
+o->recording_time = o->stop_time - start_time;
+}
+}
+
 if (o->format) {
 if (!(file_iformat = av_find_input_format(o->format))) {
 av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", 
o->format);
@@ -3407,7 +3422,7 @@ const OptionDef options[] = {
 OPT_INPUT | OPT_OUTPUT,  { .off = 
OFFSET(recording_time) },
 "record or transcode \"duration\" seconds of audio/video",
 "duration" },
-{ "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_OUTPUT,  { .off 
= OFFSET(stop_time) },
+{ "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,  { .off = OFFSET(stop_time) },
 "record or transcode stop time", "time_stop" },
 { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off 
= OFFSET(limit_filesize) },
 "set the limit file size in bytes", "limit_size" },
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] fix bug in af_pan channel coefficient parser

2017-11-18 Thread Michael Roitzsch
Hi FFmpeg team,

I was using af_pan to subtract one audio file from another. I first used an 
amerge filter and then configured the pan filter with a channel formula like 
c0=c0-c2|c1=c1-c3.

However, this does not work as expected. In debug output, I can see that 
channel 0 correctly uses gain coefficients 1 and -1 for c0 and c2. But channel 
1 incorrectly uses -1 and -1 for c1 and c3.

I looked into the code and found that the sign handling is currently wrong. 
When the last contribution of a formula is subtracted, the sign variable will 
be correctly set to -1 in line 191. But when then leaving the gains loop in 
line 189, because we reached the end of the formula for an output channel, sign 
is not reset. We therefore re-enter the gains loop for the next output channel 
with sign still -1. The first gain in this new formula will therefore be 
negated.

The attached patch fixes the problem for me.

Regards,
Michael



0001-fix-sign-handling-in-channel-coefficient-parser.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] RPM library deployments

2017-11-18 Thread Gardner, Greg - 0995 - MITLL
Hey folks,

Could someone put me in touch with whoever builds the ffmpeg-libs RPM?

I recently installed the ffmpeg-libs package on RHEL7 and I noticed that it 
does not follow the common convention of symlinking its *.so static object the 
appropriate version.  Instead, it simply deploys them with their full version 
numbers, which messes with our builds (which look for just the *.so file, not 
*.so.1.1 and so on)

Cheers!

Greg Gardner
Subcontractor, MIT Lincoln Laboratory, Group 95
Bench:   (781) 981-2831
Cell: (401)573-0052

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


Re: [FFmpeg-devel] [PATCH] avfilter: add fillborders filter

2017-11-18 Thread Paul B Mahol
On 11/18/17, Rostislav Pehlivanov  wrote:
> On 18 November 2017 at 18:53, Paul B Mahol  wrote:
>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi |  31 ++
>>  libavfilter/Makefile |   1 +
>>  libavfilter/allfilters.c |   1 +
>>  libavfilter/vf_fillborders.c | 232 ++
>> +
>>  4 files changed, 265 insertions(+)
>>  create mode 100644 libavfilter/vf_fillborders.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 5d99437871..7a23d8de04 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -8607,6 +8607,37 @@ ffmpeg -i file.ts -vf
>> find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover
>> new.m
>>  @end example
>>  @end itemize
>>
>> +@section fillborders
>> +
>> +Fill borders of the input video.
>> +
>> +It accepts the following options:
>> +
>> +@table @option
>> +@item left
>> +Number of pixels to fill from left border.
>> +
>> +@item right
>> +Number of pixels to fill from right border.
>> +
>> +@item top
>> +Number of pixels to fill from top border.
>> +
>> +@item bottom
>> +Number of pixels to fill from bottom border.
>> +
>> +@item mode
>> +Set fill mode.
>> +
>> +It accepts the following values:
>> +@table @samp
>> +@item smear
>> +fill pixels using outermost pixels
>> +@item mirror
>> +fill pixels using mirroring
>> +@end table
>> +@end table
>> +
>>  @section floodfill
>>
>>
> MpegvideoEncDSPContext->draw_edges seems to pretty much do that, and it has
> SIMD. Could you use it instead?

Its in wrong library, and is just smear mode.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-11-18 Thread Sasi Inguva
Signed-off-by: Sasi Inguva 
---
 libavformat/mov.c| 54 
 tests/fate/mov.mak   |  5 
 tests/ref/fate/mov-guess-delay-1 |  3 +++
 tests/ref/fate/mov-guess-delay-2 |  3 +++
 4 files changed, 65 insertions(+)
 create mode 100644 tests/ref/fate/mov-guess-delay-1
 create mode 100644 tests/ref/fate/mov-guess-delay-2

diff --git a/libavformat/mov.c b/libavformat/mov.c
index fd170baa57..7354652c6e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3213,6 +3213,58 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, 
unsigned int* ctts_count, uns
 return *ctts_count;
 }
 
+static void mov_guess_video_delay(MOVContext *c, AVStream* st) {
+MOVStreamContext *msc = st->priv_data;
+int ind;
+int ctts_ind = 0;
+int ctts_sample = 0;
+int64_t curr_pts = AV_NOPTS_VALUE;
+int64_t prev_pts = AV_NOPTS_VALUE;
+int64_t prev_max_pts = AV_NOPTS_VALUE;
+int num_swaps = 0;
+
+if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
+(st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
+ st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
+ st->codecpar->codec_id == AV_CODEC_ID_VC1 ||
+ st->codecpar->codec_id == AV_CODEC_ID_H263 ||
+ st->codecpar->codec_id == AV_CODEC_ID_H264 ||
+ st->codecpar->codec_id == AV_CODEC_ID_HEVC)) {
+st->codecpar->video_delay = 0;
+for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; 
++ind) {
+curr_pts = st->index_entries[ind].timestamp + 
msc->ctts_data[ctts_ind].duration;
+
+// This is used as an indication that the previous GOP has ended 
and a
+// new GOP has started.
+if (curr_pts > prev_max_pts) {
+st->codecpar->video_delay = 
FFMIN(FFMAX(st->codecpar->video_delay, num_swaps), 16);
+num_swaps = 0;
+prev_max_pts = curr_pts;
+}
+
+// Compute delay as the no. of "drop"s in PTS inside a GOP.
+// Frames: I0 I1 B0 B1 B2
+// PTS: 0  4  1  2  3 -> num_swaps = delay = 1 (4->1)
+//
+// Frames: I0 I1 B1 B0 B2
+// PTS: 0  4  2  1  3 -> num_swaps = delay = 2 (4->2, 2->1)
+if (prev_pts != AV_NOPTS_VALUE) {
+if (curr_pts < prev_pts)
+++num_swaps;
+}
+
+prev_pts = curr_pts;
+ctts_sample++;
+if (ctts_sample == msc->ctts_data[ctts_ind].count) {
+ctts_ind++;
+ctts_sample = 0;
+}
+}
+av_log(c->fc, AV_LOG_DEBUG, "Setting codecpar->delay to %d for stream 
st: %d\n",
+   st->codecpar->video_delay, st->index);
+}
+}
+
 static void mov_current_sample_inc(MOVStreamContext *sc)
 {
 sc->current_sample++;
@@ -3846,6 +3898,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 // Fix index according to edit lists.
 mov_fix_index(mov, st);
 }
+
+mov_guess_video_delay(mov, st);
 }
 
 static int test_same_origin(const char *src, const char *ref) {
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 76f66ff498..ef89e62096 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -11,6 +11,8 @@ FATE_MOV = fate-mov-3elist \
fate-mov-440hz-10ms \
fate-mov-ibi-elst-starts-b \
fate-mov-elst-ends-betn-b-and-i \
+   fate-mov-guess-delay-1 \
+   fate-mov-guess-delay-2 \
 
 FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -72,3 +74,6 @@ fate-mov-spherical-mono: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entries str
 fate-mov-gpmf-remux: CMD = md5 -i 
$(TARGET_SAMPLES)/mov/fake-gp-media-with-real-gpmf.mp4 -map 0 -c copy -fflags 
+bitexact -f mp4
 fate-mov-gpmf-remux: CMP = oneline
 fate-mov-gpmf-remux: REF = 8f48e435ee1f6b7e173ea756141eabf3
+
+fate-mov-guess-delay-1: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4
+fate-mov-guess-delay-2: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_pyramid_nobsrestriction.mp4
\ No newline at end of file
diff --git a/tests/ref/fate/mov-guess-delay-1 b/tests/ref/fate/mov-guess-delay-1
new file mode 100644
index 00..96cb67be0c
--- /dev/null
+++ b/tests/ref/fate/mov-guess-delay-1
@@ -0,0 +1,3 @@
+[STREAM]
+has_b_frames=1
+[/STREAM]
diff --git a/tests/ref/fate/mov-guess-delay-2 b/tests/ref/fate/mov-guess-delay-2
new file mode 100644
index 00..248de1c3ea
--- /dev/null
+++ b/tests/ref/fate/mov-guess-delay-2
@@ -0,0 +1,3 @@
+[STREAM]
+has_b_frames=2
+[/STREAM]
-- 
2.15.0.448.gf294e3d99a-goog

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread James Almer
On 11/18/2017 4:07 PM, Mark Thompson wrote:
> On 18/11/17 19:00, Rostislav Pehlivanov wrote:
>> On 18 November 2017 at 18:47, Mark Thompson  wrote:
>>
>>> ---
>>>  doc/APIchanges   |  4 
>>>  libavcodec/avcodec.h | 13 +
>>>  libavcodec/utils.c   | 16 +---
>>>  libavcodec/version.h |  3 +++
>>>  4 files changed, 25 insertions(+), 11 deletions(-)
>>>
>>>
>>>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>>>  {
>>> diff --git a/libavcodec/version.h b/libavcodec/version.h
>>> index 5b25a9a8ac..693f67386c 100644
>>> --- a/libavcodec/version.h
>>> +++ b/libavcodec/version.h
>>> @@ -123,6 +123,9 @@
>>>  #ifndef FF_API_CODEC_GET_SET
>>>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
>>>  #endif
>>> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
>>> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
>>>
>>
>> 60? That's 2 bumps away, this should be 59, no?
> 
> Two bumps away is the usual number, isn't it?  Or does it count as 
> not-bumped-yet for this purpose because we are still in the unstable period?

The number doesn't matter as long as the condition evaluates to true
when it's meant to.
If you use 59 and there's a bump before the two years period for this
specific deprecation is over, then the line will have to be changed to
60 during said bump to make sure the API doesn't get disabled.
However using 60 would mean that the line can be left alone. The bump
that changes the major to 60 is unlikely to happen before the two year mark.

So it's fine as is. No need to change it.

> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


[FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-11-18 Thread Sasi Inguva
Done. is there a better way to identify codecs that might need 
Signed-off-by: Sasi Inguva 
---
 libavformat/mov.c| 52 
 tests/fate/mov.mak   |  5 
 tests/ref/fate/mov-guess-delay-1 |  3 +++
 tests/ref/fate/mov-guess-delay-2 |  3 +++
 4 files changed, 63 insertions(+)
 create mode 100644 tests/ref/fate/mov-guess-delay-1
 create mode 100644 tests/ref/fate/mov-guess-delay-2

diff --git a/libavformat/mov.c b/libavformat/mov.c
index fd170baa57..687297be33 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3213,6 +3213,56 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, 
unsigned int* ctts_count, uns
 return *ctts_count;
 }
 
+static void mov_guess_video_delay(MOVContext *c, AVStream* st) {
+MOVStreamContext *msc = st->priv_data;
+int ind;
+int ctts_ind = 0;
+int ctts_sample = 0;
+int64_t curr_pts = AV_NOPTS_VALUE;
+int64_t prev_pts = AV_NOPTS_VALUE;
+int64_t prev_max_pts = AV_NOPTS_VALUE;
+int num_swaps = 0;
+
+if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
+(st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
+ st->codecpar->codec_id == AV_CODEC_ID_H263 ||
+ st->codecpar->codec_id == AV_CODEC_ID_H264 ||
+ st->codecpar->codec_id == AV_CODEC_ID_HEVC)) {
+st->codecpar->video_delay = 0;
+for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; 
++ind) {
+curr_pts = st->index_entries[ind].timestamp + 
msc->ctts_data[ctts_ind].duration;
+
+// This is used as an indication that the previous GOP has ended 
and a
+// new GOP has started.
+if (curr_pts > prev_max_pts) {
+st->codecpar->video_delay = 
FFMIN(FFMAX(st->codecpar->video_delay, num_swaps), 16);
+num_swaps = 0;
+prev_max_pts = curr_pts;
+}
+
+// Compute delay as the no. of "drop"s in PTS inside a GOP.
+// Frames: I0 I1 B0 B1 B2
+// PTS: 0  4  1  2  3 -> num_swaps = delay = 1 (4->1)
+//
+// Frames: I0 I1 B1 B0 B2
+// PTS: 0  4  2  1  3 -> num_swaps = delay = 2 (4->2, 2->1)
+if (prev_pts != AV_NOPTS_VALUE) {
+if (curr_pts < prev_pts)
+++num_swaps;
+}
+
+prev_pts = curr_pts;
+ctts_sample++;
+if (ctts_sample == msc->ctts_data[ctts_ind].count) {
+ctts_ind++;
+ctts_sample = 0;
+}
+}
+av_log(c->fc, AV_LOG_DEBUG, "Setting codecpar->delay to %d for stream 
st: %d\n",
+   st->codecpar->video_delay, st->index);
+}
+}
+
 static void mov_current_sample_inc(MOVStreamContext *sc)
 {
 sc->current_sample++;
@@ -3846,6 +3896,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 // Fix index according to edit lists.
 mov_fix_index(mov, st);
 }
+
+mov_guess_video_delay(mov, st);
 }
 
 static int test_same_origin(const char *src, const char *ref) {
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 76f66ff498..ef89e62096 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -11,6 +11,8 @@ FATE_MOV = fate-mov-3elist \
fate-mov-440hz-10ms \
fate-mov-ibi-elst-starts-b \
fate-mov-elst-ends-betn-b-and-i \
+   fate-mov-guess-delay-1 \
+   fate-mov-guess-delay-2 \
 
 FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -72,3 +74,6 @@ fate-mov-spherical-mono: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entries str
 fate-mov-gpmf-remux: CMD = md5 -i 
$(TARGET_SAMPLES)/mov/fake-gp-media-with-real-gpmf.mp4 -map 0 -c copy -fflags 
+bitexact -f mp4
 fate-mov-gpmf-remux: CMP = oneline
 fate-mov-gpmf-remux: REF = 8f48e435ee1f6b7e173ea756141eabf3
+
+fate-mov-guess-delay-1: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4
+fate-mov-guess-delay-2: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_pyramid_nobsrestriction.mp4
\ No newline at end of file
diff --git a/tests/ref/fate/mov-guess-delay-1 b/tests/ref/fate/mov-guess-delay-1
new file mode 100644
index 00..96cb67be0c
--- /dev/null
+++ b/tests/ref/fate/mov-guess-delay-1
@@ -0,0 +1,3 @@
+[STREAM]
+has_b_frames=1
+[/STREAM]
diff --git a/tests/ref/fate/mov-guess-delay-2 b/tests/ref/fate/mov-guess-delay-2
new file mode 100644
index 00..248de1c3ea
--- /dev/null
+++ b/tests/ref/fate/mov-guess-delay-2
@@ -0,0 +1,3 @@
+[STREAM]
+has_b_frames=2
+[/STREAM]
-- 
2.15.0.448.gf294e3d99a-goog

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


Re: [FFmpeg-devel] [PATCH 03/13] lavc: Use hardware config information in ff_get_format()

2017-11-18 Thread Mark Thompson
On 18/11/17 18:47, Mark Thompson wrote:
> This removes the dependency that hardware pixel formats previously had on
> AVHWAccel instances, meaning only those which actually do something need
> exist after this patch.
> 
> Also updates avcodec_default_get_format() to be able to choose hardware
> formats if either a matching device has been supplied or no additional
> external configuration is required, and avcodec_get_hw_frames_parameters()
> to use the hardware config rather than searching the old hwaccel list.
> 
> The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it
> no longer does anything (the codec already contains the pointers to the
> matching hwaccels).
> ---
>  libavcodec/avcodec.h  |   7 --
>  libavcodec/cuviddec.c |   2 -
>  libavcodec/decode.c   | 285 
> +++---
>  libavcodec/internal.h |  11 +-
>  4 files changed, 208 insertions(+), 97 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index a7f1e23fc2..8b2bec1ce9 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> ...
> +for (i = 0;; i++) {
> +hw_config = avctx->codec->hw_configs[i];
> +if (!hw_config)
> +break;
> +if (hw_config->public.pix_fmt == user_choice)
>  break;
> -}
>  }

This needs to check for avctx->codec->hw_configs being non-NULL, and 
immediately fall into the below case if it isn't.  (Stupidly I was only testing 
with codecs where it's set...)

>  
> -if (!setup_hwaccel(avctx, ret, desc->name))
> +if (!hw_config) {
> +// No config available, so no extra setup required.
> +ret = user_choice;
>  break;
> +}

Fixed locally.

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


Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Mark Thompson
On 18/11/17 19:00, Rostislav Pehlivanov wrote:
> On 18 November 2017 at 18:47, Mark Thompson  wrote:
> 
>> ---
>>  doc/APIchanges   |  4 
>>  libavcodec/avcodec.h | 13 +
>>  libavcodec/utils.c   | 16 +---
>>  libavcodec/version.h |  3 +++
>>  4 files changed, 25 insertions(+), 11 deletions(-)
>>
>>
>>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>>  {
>> diff --git a/libavcodec/version.h b/libavcodec/version.h
>> index 5b25a9a8ac..693f67386c 100644
>> --- a/libavcodec/version.h
>> +++ b/libavcodec/version.h
>> @@ -123,6 +123,9 @@
>>  #ifndef FF_API_CODEC_GET_SET
>>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
>>  #endif
>> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
>> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
>>
> 
> 60? That's 2 bumps away, this should be 59, no?

Two bumps away is the usual number, isn't it?  Or does it count as 
not-bumped-yet for this purpose because we are still in the unstable period?

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


Re: [FFmpeg-devel] [PATCH 06/13] lavc: Delete all fake hwaccels

2017-11-18 Thread Mark Thompson
On 18/11/17 18:47, Mark Thompson wrote:
> They are now unused.
> ---
>  configure | 32 +
>  libavcodec/mediacodec.c   |  2 +-
>  libavcodec/mediacodecdec_common.c | 42 
> ---
>  libavcodec/mmaldec.c  | 28 --
>  libavcodec/qsvdec_h2645.c | 18 -
>  libavcodec/qsvdec_other.c | 27 -
>  6 files changed, 6 insertions(+), 143 deletions(-)

Thanks to James on IRC for noticing that I missed removing the actual cuvid 
hwaccel structures (though all references to them are gone).

Fixed locally.

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


Re: [FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Rostislav Pehlivanov
On 18 November 2017 at 18:47, Mark Thompson  wrote:

> ---
>  doc/APIchanges   |  4 
>  libavcodec/avcodec.h | 13 +
>  libavcodec/utils.c   | 16 +---
>  libavcodec/version.h |  3 +++
>  4 files changed, 25 insertions(+), 11 deletions(-)
>
>
>  int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
>  {
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 5b25a9a8ac..693f67386c 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -123,6 +123,9 @@
>  #ifndef FF_API_CODEC_GET_SET
>  #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
>  #endif
> +#ifndef FF_API_USER_VISIBLE_AVHWACCEL
> +#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
>

60? That's 2 bumps away, this should be 59, no?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add fillborders filter

2017-11-18 Thread Rostislav Pehlivanov
On 18 November 2017 at 18:53, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  31 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/vf_fillborders.c | 232 ++
> +
>  4 files changed, 265 insertions(+)
>  create mode 100644 libavfilter/vf_fillborders.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 5d99437871..7a23d8de04 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -8607,6 +8607,37 @@ ffmpeg -i file.ts -vf 
> find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover
> new.m
>  @end example
>  @end itemize
>
> +@section fillborders
> +
> +Fill borders of the input video.
> +
> +It accepts the following options:
> +
> +@table @option
> +@item left
> +Number of pixels to fill from left border.
> +
> +@item right
> +Number of pixels to fill from right border.
> +
> +@item top
> +Number of pixels to fill from top border.
> +
> +@item bottom
> +Number of pixels to fill from bottom border.
> +
> +@item mode
> +Set fill mode.
> +
> +It accepts the following values:
> +@table @samp
> +@item smear
> +fill pixels using outermost pixels
> +@item mirror
> +fill pixels using mirroring
> +@end table
> +@end table
> +
>  @section floodfill
>
>
MpegvideoEncDSPContext->draw_edges seems to pretty much do that, and it has
SIMD. Could you use it instead?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 13/13] vaapi_decode: Ignore the profile when not useful

2017-11-18 Thread Mark Thompson
Enables VP8 decoding - the decoder places the the bitstream version
in the profile field, which we want to ignore.
---
 libavcodec/vaapi_decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d36ef906a2..572b3a40ac 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -324,7 +324,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 int profile_match = 0;
 if (avctx->codec_id != vaapi_profile_map[i].codec_id)
 continue;
-if (avctx->profile == vaapi_profile_map[i].codec_profile)
+if (avctx->profile == vaapi_profile_map[i].codec_profile ||
+vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
 profile_match = 1;
 for (j = 0; j < profile_count; j++) {
 if (vaapi_profile_map[i].va_profile == profile_list[j]) {
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 07/13] lavc: Mark all AVHWAccel structures as const

2017-11-18 Thread Mark Thompson
---
 libavcodec/avcodec.h  |  2 +-
 libavcodec/decode.c   |  2 +-
 libavcodec/dxva2_h264.c   |  6 +--
 libavcodec/dxva2_hevc.c   |  6 +--
 libavcodec/dxva2_mpeg2.c  |  6 +--
 libavcodec/dxva2_vc1.c| 12 +++---
 libavcodec/hwaccels.h | 94 +++
 libavcodec/nvdec_h264.c   |  2 +-
 libavcodec/nvdec_hevc.c   |  2 +-
 libavcodec/nvdec_mpeg12.c |  2 +-
 libavcodec/nvdec_vc1.c|  4 +-
 libavcodec/nvdec_vp9.c|  2 +-
 libavcodec/vaapi_h264.c   |  2 +-
 libavcodec/vaapi_hevc.c   |  2 +-
 libavcodec/vaapi_mpeg2.c  |  2 +-
 libavcodec/vaapi_mpeg4.c  |  4 +-
 libavcodec/vaapi_vc1.c|  4 +-
 libavcodec/vaapi_vp9.c|  2 +-
 libavcodec/vdpau_h264.c   |  2 +-
 libavcodec/vdpau_hevc.c   |  2 +-
 libavcodec/vdpau_mpeg12.c |  4 +-
 libavcodec/vdpau_mpeg4.c  |  2 +-
 libavcodec/vdpau_vc1.c|  4 +-
 libavcodec/videotoolbox.c | 12 +++---
 24 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c05dbfe777..14f20fae0c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2635,7 +2635,7 @@ typedef struct AVCodecContext {
  * - encoding: unused.
  * - decoding: Set by libavcodec
  */
-struct AVHWAccel *hwaccel;
+const struct AVHWAccel *hwaccel;
 
 /**
  * Hardware accelerator context.
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8b2bec1ce9..890b596b7b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1252,7 +1252,7 @@ static int hwaccel_init(AVCodecContext *avctx,
 return AVERROR(ENOMEM);
 }
 
-avctx->hwaccel = (AVHWAccel*)hwaccel;
+avctx->hwaccel = hwaccel;
 err = hwaccel->init(avctx);
 if (err < 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed setup for format %s: "
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index ee35b20e82..a4278c80b5 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -518,7 +518,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_H264_DXVA2_HWACCEL
-AVHWAccel ff_h264_dxva2_hwaccel = {
+const AVHWAccel ff_h264_dxva2_hwaccel = {
 .name   = "h264_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
@@ -535,7 +535,7 @@ AVHWAccel ff_h264_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_H264_D3D11VA_HWACCEL
-AVHWAccel ff_h264_d3d11va_hwaccel = {
+const AVHWAccel ff_h264_d3d11va_hwaccel = {
 .name   = "h264_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
@@ -552,7 +552,7 @@ AVHWAccel ff_h264_d3d11va_hwaccel = {
 #endif
 
 #if CONFIG_H264_D3D11VA2_HWACCEL
-AVHWAccel ff_h264_d3d11va2_hwaccel = {
+const AVHWAccel ff_h264_d3d11va2_hwaccel = {
 .name   = "h264_d3d11va2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_H264,
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 542afc383a..0ae07d304f 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -422,7 +422,7 @@ static int dxva2_hevc_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_HEVC_DXVA2_HWACCEL
-AVHWAccel ff_hevc_dxva2_hwaccel = {
+const AVHWAccel ff_hevc_dxva2_hwaccel = {
 .name   = "hevc_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
@@ -439,7 +439,7 @@ AVHWAccel ff_hevc_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_HEVC_D3D11VA_HWACCEL
-AVHWAccel ff_hevc_d3d11va_hwaccel = {
+const AVHWAccel ff_hevc_d3d11va_hwaccel = {
 .name   = "hevc_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
@@ -456,7 +456,7 @@ AVHWAccel ff_hevc_d3d11va_hwaccel = {
 #endif
 
 #if CONFIG_HEVC_D3D11VA2_HWACCEL
-AVHWAccel ff_hevc_d3d11va2_hwaccel = {
+const AVHWAccel ff_hevc_d3d11va2_hwaccel = {
 .name   = "hevc_d3d11va2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_HEVC,
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index df5fe59a7d..a57778b427 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -317,7 +317,7 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
 }
 
 #if CONFIG_MPEG2_DXVA2_HWACCEL
-AVHWAccel ff_mpeg2_dxva2_hwaccel = {
+const AVHWAccel ff_mpeg2_dxva2_hwaccel = {
 .name   = "mpeg2_dxva2",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_MPEG2VIDEO,
@@ -334,7 +334,7 @@ AVHWAccel ff_mpeg2_dxva2_hwaccel = {
 #endif
 
 #if CONFIG_MPEG2_D3D11VA_HWACCEL
-AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
+const AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
 .name   = "mpeg2_d3d11va",
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_MPEG2VIDEO,
@@ -351,7 +351,7 @@ AVHWAccel ff_mpeg2_d3d11va_hwaccel = {
 #endif
 
 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
-AVHWAccel ff_mpeg2_d3d11va2_hwaccel = {
+const AVHWAccel ff_mpeg2_d3d11va2_hwaccel = {
 .name   = 

[FFmpeg-devel] [PATCH 10/13] vaapi: Make the decode profile matching more explicit

2017-11-18 Thread Mark Thompson
Also fixes a bug where it could attempt to decode with an unsupported
codec if allow-profile-mismatch was set.
---
 libavcodec/vaapi_decode.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d467bed874..d36ef906a2 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -287,8 +287,8 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 VAStatus vas;
 int err, i, j;
 const AVCodecDescriptor *codec_desc;
-VAProfile profile, va_profile, *profile_list = NULL;
-int profile_count, exact_match, alt_profile;
+VAProfile *profile_list = NULL, matched_va_profile;
+int profile_count, exact_match, matched_ff_profile;
 const AVPixFmtDescriptor *sw_desc, *desc;
 
 AVHWDeviceContext*device = (AVHWDeviceContext*)device_ref->data;
@@ -317,7 +317,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 goto fail;
 }
 
-profile = VAProfileNone;
+matched_va_profile = VAProfileNone;
 exact_match = 0;
 
 for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
@@ -326,23 +326,22 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 continue;
 if (avctx->profile == vaapi_profile_map[i].codec_profile)
 profile_match = 1;
-profile = vaapi_profile_map[i].va_profile;
 for (j = 0; j < profile_count; j++) {
-if (profile == profile_list[j]) {
+if (vaapi_profile_map[i].va_profile == profile_list[j]) {
 exact_match = profile_match;
 break;
 }
 }
 if (j < profile_count) {
+matched_va_profile = vaapi_profile_map[i].va_profile;
+matched_ff_profile = vaapi_profile_map[i].codec_profile;
 if (exact_match)
 break;
-alt_profile = vaapi_profile_map[i].codec_profile;
-va_profile = vaapi_profile_map[i].va_profile;
 }
 }
 av_freep(_list);
 
-if (profile == VAProfileNone) {
+if (matched_va_profile == VAProfileNone) {
 av_log(avctx, AV_LOG_ERROR, "No support for codec %s "
"profile %d.\n", codec_desc->name, avctx->profile);
 err = AVERROR(ENOSYS);
@@ -356,8 +355,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
codec_desc->name, avctx->profile);
 av_log(avctx, AV_LOG_WARNING, "Using possibly-"
"incompatible profile %d instead.\n",
-   alt_profile);
-profile = va_profile;
+   matched_ff_profile);
 } else {
 av_log(avctx, AV_LOG_VERBOSE, "Codec %s profile %d not "
"supported for hardware decode.\n",
@@ -367,7 +365,7 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 }
 }
 
-vas = vaCreateConfig(hwctx->display, profile,
+vas = vaCreateConfig(hwctx->display, matched_va_profile,
  VAEntrypointVLD, NULL, 0,
  va_config);
 if (vas != VA_STATUS_SUCCESS) {
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 09/13] compat/cuda: Pass a logging context to load functions

2017-11-18 Thread Mark Thompson
---
The cuda load error is easily hit by "-hwaccel auto".


 compat/cuda/dynlink_loader.h | 18 +-
 libavcodec/cuviddec.c|  2 +-
 libavcodec/nvdec.c   |  2 +-
 libavcodec/nvenc.c   |  4 ++--
 libavutil/hwcontext_cuda.c   |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/compat/cuda/dynlink_loader.h b/compat/cuda/dynlink_loader.h
index 7d2c87449e..fa43782c9a 100644
--- a/compat/cuda/dynlink_loader.h
+++ b/compat/cuda/dynlink_loader.h
@@ -59,29 +59,29 @@
 #define LOAD_LIBRARY(l, path) \
 do {  \
 if (!((l) = dlopen(path, RTLD_LAZY))) {   \
-av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", path); \
+av_log(logctx, AV_LOG_ERROR, "Cannot load %s\n", path); \
 ret = AVERROR_UNKNOWN;\
 goto error;   \
 } \
-av_log(NULL, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
+av_log(logctx, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
 } while (0)
 
 #define LOAD_SYMBOL(fun, tp, symbol)\
 do {\
 if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \
-av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
+av_log(logctx, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
 ret = AVERROR_UNKNOWN;  \
 goto error; \
 }   \
-av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
+av_log(logctx, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
 } while (0)
 
 #define LOAD_SYMBOL_OPT(fun, tp, symbol) \
 do { \
 if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) {  \
-av_log(NULL, AV_LOG_DEBUG, "Cannot load optional %s\n", symbol); \
+av_log(logctx, AV_LOG_DEBUG, "Cannot load optional %s\n", symbol); 
\
 } else { \
-av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol);  \
+av_log(logctx, AV_LOG_TRACE, "Loaded sym: %s\n", symbol);  
\
 }\
 } while (0)
 
@@ -187,7 +187,7 @@ static inline void nvenc_free_functions(NvencFunctions 
**functions)
 }
 
 #ifdef AV_COMPAT_DYNLINK_CUDA_H
-static inline int cuda_load_functions(CudaFunctions **functions)
+static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
 {
 GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME);
 
@@ -210,7 +210,7 @@ static inline int cuda_load_functions(CudaFunctions 
**functions)
 }
 #endif
 
-static inline int cuvid_load_functions(CuvidFunctions **functions)
+static inline int cuvid_load_functions(CuvidFunctions **functions, void 
*logctx)
 {
 GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
 
@@ -244,7 +244,7 @@ static inline int cuvid_load_functions(CuvidFunctions 
**functions)
 GENERIC_LOAD_FUNC_FINALE(cuvid);
 }
 
-static inline int nvenc_load_functions(NvencFunctions **functions)
+static inline int nvenc_load_functions(NvencFunctions **functions, void 
*logctx)
 {
 GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME);
 
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 346e54e7c6..33e9140f89 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -836,7 +836,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
 goto error;
 }
 
-ret = cuvid_load_functions(>cvdl);
+ret = cuvid_load_functions(>cvdl, avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed loading nvcuvid.\n");
 goto error;
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 3d62840e9f..30e5258b07 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -174,7 +174,7 @@ static int nvdec_decoder_create(AVBufferRef **out, 
AVBufferRef *hw_device_ref,
 decoder->cuda_ctx = device_hwctx->cuda_ctx;
 decoder->cudl = device_hwctx->internal->cuda_dl;
 
-ret = cuvid_load_functions(>cvdl);
+ret = cuvid_load_functions(>cvdl, logctx);
 if (ret < 0) {
 av_log(logctx, AV_LOG_ERROR, "Failed loading nvcuvid.\n");
 goto fail;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index e07280b568..79f7dce5f1 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -133,11 +133,11 @@ static av_cold int nvenc_load_libraries(AVCodecContext 
*avctx)
 uint32_t nvenc_max_ver;
 

[FFmpeg-devel] [PATCH] avfilter: add fillborders filter

2017-11-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  31 ++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_fillborders.c | 232 +++
 4 files changed, 265 insertions(+)
 create mode 100644 libavfilter/vf_fillborders.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 5d99437871..7a23d8de04 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8607,6 +8607,37 @@ ffmpeg -i file.ts -vf 
find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.m
 @end example
 @end itemize
 
+@section fillborders
+
+Fill borders of the input video.
+
+It accepts the following options:
+
+@table @option
+@item left
+Number of pixels to fill from left border.
+
+@item right
+Number of pixels to fill from right border.
+
+@item top
+Number of pixels to fill from top border.
+
+@item bottom
+Number of pixels to fill from bottom border.
+
+@item mode
+Set fill mode.
+
+It accepts the following values:
+@table @samp
+@item smear
+fill pixels using outermost pixels
+@item mirror
+fill pixels using mirroring
+@end table
+@end table
+
 @section floodfill
 
 Flood area with values of same pixel components with another values.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9acae3ff5b..7566d19e59 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -192,6 +192,7 @@ OBJS-$(CONFIG_FIELDHINT_FILTER)  += 
vf_fieldhint.o
 OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o
 OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o
 OBJS-$(CONFIG_FIND_RECT_FILTER)  += vf_find_rect.o lavfutils.o
+OBJS-$(CONFIG_FILLBORDERS_FILTER)+= vf_fillborders.o
 OBJS-$(CONFIG_FLOODFILL_FILTER)  += vf_floodfill.o
 OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o
 OBJS-$(CONFIG_FPS_FILTER)+= vf_fps.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index a838309569..3c61474e91 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -202,6 +202,7 @@ static void register_all(void)
 REGISTER_FILTER(FIELDMATCH, fieldmatch, vf);
 REGISTER_FILTER(FIELDORDER, fieldorder, vf);
 REGISTER_FILTER(FIND_RECT,  find_rect,  vf);
+REGISTER_FILTER(FILLBORDERS,fillborders,vf);
 REGISTER_FILTER(FLOODFILL,  floodfill,  vf);
 REGISTER_FILTER(FORMAT, format, vf);
 REGISTER_FILTER(FPS,fps,vf);
diff --git a/libavfilter/vf_fillborders.c b/libavfilter/vf_fillborders.c
new file mode 100644
index 00..62b5c840b0
--- /dev/null
+++ b/libavfilter/vf_fillborders.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * 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
+ */
+
+#include "libavutil/colorspace.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+enum FillMode { FM_SMEAR, FM_MIRROR, NB_MODES };
+
+typedef struct Borders {
+int left, right, top, bottom;
+} Borders;
+
+typedef struct FillBordersContext {
+const AVClass *class;
+int left, right, top, bottom;
+int mode;
+
+int nb_planes;
+Borders borders[4];
+int planewidth[4];
+int planeheight[4];
+
+void (*fillborders)(struct FillBordersContext *s, AVFrame *frame);
+} FillBordersContext;
+
+static int query_formats(AVFilterContext *ctx)
+{
+static const enum AVPixelFormat pix_fmts[] = {
+AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P,
+AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
+AV_PIX_FMT_YUV440P,  AV_PIX_FMT_YUVJ440P,
+AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
+AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
+AV_PIX_FMT_NONE
+};
+AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
+if (!fmts_list)
+return AVERROR(ENOMEM);
+return ff_set_common_formats(ctx, fmts_list);
+}
+
+static void smear_borders(FillBordersContext *s, AVFrame *frame)
+{
+int p, y;
+
+for (p = 0; p < 

[FFmpeg-devel] [PATCH 06/13] lavc: Delete all fake hwaccels

2017-11-18 Thread Mark Thompson
They are now unused.
---
 configure | 32 +
 libavcodec/mediacodec.c   |  2 +-
 libavcodec/mediacodecdec_common.c | 42 ---
 libavcodec/mmaldec.c  | 28 --
 libavcodec/qsvdec_h2645.c | 18 -
 libavcodec/qsvdec_other.c | 27 -
 6 files changed, 6 insertions(+), 143 deletions(-)

diff --git a/configure b/configure
index 1695ae1770..3d3c0bd7c3 100755
--- a/configure
+++ b/configure
@@ -2659,25 +2659,20 @@ h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_videotoolbox_hwaccel_deps="videotoolbox"
 h263_videotoolbox_hwaccel_select="h263_decoder"
-h264_cuvid_hwaccel_select="h264_cuvid_decoder"
 h264_d3d11va_hwaccel_deps="d3d11va"
 h264_d3d11va_hwaccel_select="h264_decoder"
 h264_d3d11va2_hwaccel_deps="d3d11va"
 h264_d3d11va2_hwaccel_select="h264_decoder"
 h264_dxva2_hwaccel_deps="dxva2"
 h264_dxva2_hwaccel_select="h264_decoder"
-h264_mediacodec_hwaccel_deps="mediacodec"
-h264_mmal_hwaccel_deps="mmal"
 h264_nvdec_hwaccel_deps="nvdec"
 h264_nvdec_hwaccel_select="h264_decoder"
-h264_qsv_hwaccel_deps="libmfx"
 h264_vaapi_hwaccel_deps="vaapi"
 h264_vaapi_hwaccel_select="h264_decoder"
 h264_vdpau_hwaccel_deps="vdpau"
 h264_vdpau_hwaccel_select="h264_decoder"
 h264_videotoolbox_hwaccel_deps="videotoolbox"
 h264_videotoolbox_hwaccel_select="h264_decoder"
-hevc_cuvid_hwaccel_select="hevc_cuvid_decoder"
 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
 hevc_d3d11va_hwaccel_select="hevc_decoder"
 hevc_mediacodec_hwaccel_deps="mediacodec"
@@ -2687,35 +2682,28 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_nvdec_hwaccel_deps="nvdec"
 hevc_nvdec_hwaccel_select="hevc_decoder"
-hevc_qsv_hwaccel_deps="libmfx"
 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
 hevc_vaapi_hwaccel_select="hevc_decoder"
 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
 hevc_vdpau_hwaccel_select="hevc_decoder"
 hevc_videotoolbox_hwaccel_deps="videotoolbox"
 hevc_videotoolbox_hwaccel_select="hevc_decoder"
-mjpeg_cuvid_hwaccel_select="mjpeg_cuvid_decoder"
 mpeg_xvmc_hwaccel_deps="xvmc"
 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
-mpeg1_cuvid_hwaccel_select="mpeg1_cuvid_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
 mpeg1_xvmc_hwaccel_deps="xvmc"
 mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
-mpeg2_cuvid_hwaccel_select="mpeg2_cuvid_decoder"
 mpeg2_d3d11va_hwaccel_deps="d3d11va"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_d3d11va2_hwaccel_deps="d3d11va"
 mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
-mpeg2_mediacodec_hwaccel_deps="mediacodec"
-mpeg2_mmal_hwaccel_deps="mmal"
 mpeg2_nvdec_hwaccel_deps="nvdec"
 mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
-mpeg2_qsv_hwaccel_deps="libmfx"
 mpeg2_vaapi_hwaccel_deps="vaapi"
 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
 mpeg2_vdpau_hwaccel_deps="vdpau"
@@ -2724,9 +2712,6 @@ mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
 mpeg2_xvmc_hwaccel_deps="xvmc"
 mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
-mpeg4_cuvid_hwaccel_select="mpeg4_cuvid_decoder"
-mpeg4_mediacodec_hwaccel_deps="mediacodec"
-mpeg4_mmal_hwaccel_deps="mmal"
 mpeg4_vaapi_hwaccel_deps="vaapi"
 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
 mpeg4_vdpau_hwaccel_deps="vdpau"
@@ -2740,25 +2725,18 @@ vc1_d3d11va2_hwaccel_deps="d3d11va"
 vc1_d3d11va2_hwaccel_select="vc1_decoder"
 vc1_dxva2_hwaccel_deps="dxva2"
 vc1_dxva2_hwaccel_select="vc1_decoder"
-vc1_mmal_hwaccel_deps="mmal"
 vc1_nvdec_hwaccel_deps="nvdec"
 vc1_nvdec_hwaccel_select="vc1_decoder"
-vc1_qsv_hwaccel_deps="libmfx"
 vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
-vp8_cuvid_hwaccel_select="vp8_cuvid_decoder"
-vp9_cuvid_hwaccel_select="vp9_cuvid_decoder"
-vp8_mediacodec_hwaccel_deps="mediacodec"
-vp8_qsv_hwaccel_deps="libmfx"
 vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va_hwaccel_select="vp9_decoder"
 vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va2_hwaccel_select="vp9_decoder"
 vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
 vp9_dxva2_hwaccel_select="vp9_decoder"
-vp9_mediacodec_hwaccel_deps="mediacodec"
 vp9_nvdec_hwaccel_deps="nvdec"
 vp9_nvdec_hwaccel_select="vp9_decoder"
 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
@@ -2799,7 +2777,7 @@ h264_mediacodec_decoder_select="h264_mp4toannexb_bsf 
h264_parser"
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
 h264_omx_encoder_deps="omx"

[FFmpeg-devel] [PATCH 01/13] lavc: Add codec metadata to indicate hardware support

2017-11-18 Thread Mark Thompson
---
 doc/APIchanges   |  3 +++
 libavcodec/avcodec.h | 74 
 libavcodec/hwaccel.h | 18 +
 libavcodec/utils.c   | 12 +
 4 files changed, 107 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index d336f6ce22..a3c5e21765 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
+  Add AVCodecHWConfig and avcodec_get_hw_config().
+
 2017-xx-xx - xxx - lavc 58.3.100 - avcodec.h
   Add avcodec_get_hw_frames_parameters().
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 442b558d4b..5bbeb67a0d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -36,6 +36,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/dict.h"
 #include "libavutil/frame.h"
+#include "libavutil/hwcontext.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
@@ -3279,6 +3280,61 @@ typedef struct AVProfile {
 const char *name; ///< short name for the profile
 } AVProfile;
 
+enum {
+/**
+ * The codec supports this format via the hw_device_ctx interface.
+ *
+ * When selecting this format, AVCodecContext.hw_device_ctx should
+ * have been set to a device of the specified type before calling
+ * avcodec_open2().
+ */
+AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
+/**
+ * The codec supports this format via the hw_frames_ctx interface.
+ *
+ * When selecting this format for a decoder,
+ * AVCodecContext.hw_frames_ctx should be set to a suitable frames
+ * context inside the get_format() callback.  The frames context
+ * must have been created on a device of the specified type.
+ */
+AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
+/**
+ * The codec supports this format by some internal method.
+ *
+ * This format can be selected without any additional configuration -
+ * no device or frames context is required.
+ */
+AV_CODEC_HW_CONFIG_METHOD_INTERNAL  = 0x04,
+/**
+ * The codec supports this format by some ad-hoc method.
+ *
+ * Additional settings and/or function calls are required.  See the
+ * codec-specific documentation for details.  (Methods requiring
+ * this sort of configuration are deprecated and others should be
+ * used in preference.)
+ */
+AV_CODEC_HW_CONFIG_METHOD_AD_HOC= 0x08,
+};
+
+typedef struct AVCodecHWConfig {
+/**
+ * A hardware pixel format which the codec can use.
+ */
+enum AVPixelFormat pix_fmt;
+/**
+ * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
+ * setup methods which can be used with this configuration.
+ */
+int methods;
+/**
+ * The device type associated with the configuration.
+ *
+ * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
+ * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
+ */
+enum AVHWDeviceType device_type;
+} AVCodecHWConfig;
+
 typedef struct AVCodecDefault AVCodecDefault;
 
 struct AVSubtitle;
@@ -3404,6 +3460,15 @@ typedef struct AVCodec {
  * packets before decoding.
  */
 const char *bsfs;
+
+/**
+ * Array of pointers to hardware configurations supported by the codec,
+ * or NULL if no hardware supported.  The array is terminated by a NULL
+ * pointer.
+ *
+ * The user can only access this field via avcodec_get_hw_config().
+ */
+const struct AVCodecHWConfigInternal **hw_configs;
 } AVCodec;
 
 #if FF_API_CODEC_GET_SET
@@ -3414,6 +3479,15 @@ int av_codec_get_max_lowres(const AVCodec *codec);
 struct MpegEncContext;
 
 /**
+ * Retrieve supported hardware configurations for a codec.
+ *
+ * Values of index from zero to some maximum return the indexed configuration
+ * descriptor; all other values return NULL.  If the codec does not support
+ * any hardware configurations then it will always return NULL.
+ */
+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
+
+/**
  * @defgroup lavc_hwaccel AVHWAccel
  * @{
  */
diff --git a/libavcodec/hwaccel.h b/libavcodec/hwaccel.h
index 124fbbf1fd..0198c7f858 100644
--- a/libavcodec/hwaccel.h
+++ b/libavcodec/hwaccel.h
@@ -19,6 +19,24 @@
 #ifndef AVCODEC_HWACCEL_H
 #define AVCODEC_HWACCEL_H
 
+#include "avcodec.h"
+
+
 #define HWACCEL_CAP_ASYNC_SAFE  (1 << 0)
 
+
+typedef struct AVCodecHWConfigInternal {
+/**
+ * This is the structure which will be returned to the user by
+ * avcodec_get_hw_config().
+ */
+AVCodecHWConfig public;
+/**
+ * If this configuration uses a hwaccel, a pointer to it.
+ * If not, NULL.
+ */
+const AVHWAccel *hwaccel;
+} AVCodecHWConfigInternal;
+
+
 #endif /* AVCODEC_HWACCEL_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e50de6e89b..01bf7556f7 100644
--- 

[FFmpeg-devel] [PATCH 04/13] lavc: Deprecate av_hwaccel_next() and av_register_hwaccel()

2017-11-18 Thread Mark Thompson
---
 doc/APIchanges   |  4 
 libavcodec/avcodec.h | 13 +
 libavcodec/utils.c   | 16 +---
 libavcodec/version.h |  3 +++
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a3c5e21765..547d0019ba 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -16,6 +16,10 @@ libavutil: 2017-10-21
 API changes, most recent first:
 
 2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
+  Deprecate user visibility of the AVHWAccel structure and the functions
+  av_register_hwaccel() and av_hwaccel_next().
+
+2017-xx-xx - xxx - lavc 58.x+1.0 - avcodec.h
   Add AVCodecHWConfig and avcodec_get_hw_config().
 
 2017-xx-xx - xxx - lavc 58.3.100 - avcodec.h
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fb18f46ea2..c05dbfe777 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3489,6 +3489,10 @@ const AVCodecHWConfig *avcodec_get_hw_config(const 
AVCodec *codec, int index);
 
 /**
  * @defgroup lavc_hwaccel AVHWAccel
+ *
+ * @note  Nothing in this structure should be accessed by the user.  At some
+ *point in future it will not be externally visible at all.
+ *
  * @{
  */
 typedef struct AVHWAccel {
@@ -5874,17 +5878,26 @@ void av_fast_padded_mallocz(void *ptr, unsigned int 
*size, size_t min_size);
  */
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
 
+#if FF_API_USER_VISIBLE_AVHWACCEL
 /**
  * Register the hardware accelerator hwaccel.
+ *
+ * @deprecated  This function doesn't do anything.
  */
+attribute_deprecated
 void av_register_hwaccel(AVHWAccel *hwaccel);
 
 /**
  * If hwaccel is NULL, returns the first registered hardware accelerator,
  * if hwaccel is non-NULL, returns the next registered hardware accelerator
  * after hwaccel, or NULL if hwaccel is the last one.
+ *
+ * @deprecated  AVHWaccel structures contain no user-serviceable parts, so
+ *  this function should not be used.
  */
+attribute_deprecated
 AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel);
+#endif
 
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 01bf7556f7..417ebcb770 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1897,22 +1897,16 @@ const AVCodecHWConfig *avcodec_get_hw_config(const 
AVCodec *codec, int index)
 return >hw_configs[index]->public;
 }
 
-static AVHWAccel *first_hwaccel = NULL;
-static AVHWAccel **last_hwaccel = _hwaccel;
-
-void av_register_hwaccel(AVHWAccel *hwaccel)
+#if FF_API_USER_VISIBLE_AVHWACCEL
+AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel)
 {
-AVHWAccel **p = last_hwaccel;
-hwaccel->next = NULL;
-while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
-p = &(*p)->next;
-last_hwaccel = >next;
+return NULL;
 }
 
-AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel)
+void av_register_hwaccel(AVHWAccel *hwaccel)
 {
-return hwaccel ? hwaccel->next : first_hwaccel;
 }
+#endif
 
 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5b25a9a8ac..693f67386c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -123,6 +123,9 @@
 #ifndef FF_API_CODEC_GET_SET
 #define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_USER_VISIBLE_AVHWACCEL
+#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 60)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] 8-bit hevc decoding optimization on aarch64 with neon

2017-11-18 Thread James Almer
On 11/18/2017 3:31 PM, Rostislav Pehlivanov wrote:
>>
>>
>>
>> On 18 November 2017 at 17:35, Rafal Dabrowa  wrote:
>>
>> This is a proposal of performance optimizations for 8-bit
>> hevc video decoding on aarch64 platform with neon (simd) extension.
>>
>> I'm testing my optimizations on NanoPi M3 device. I'm using
>> mainly "Big Buck Bunny" video file in format 1280x720 for testing.
>> The video file was pulled from libde265.org page, see
>> http://www.libde265.org/hevc-bitstreams/bbb-1280x720-cfg06.mkv
>> The movie duration is 00:10:34.53.
>>
>> Overall performance gain is about 2x. Without optimizations the movie
>> playback stops in practice after a few seconds. With
>> optimizations the file is played smoothly 99% of the time.
>>
>> For performance testing the following command was used:
>>
>> time ./ffmpeg -hide_banner -i ~/bbb-1280x720-cfg06.mkv -f yuv4mpegpipe
>> - >/dev/null
>>
>> The video file was pre-read before test to minimize disk reads during
>> testing.
>> Program execution time without optimization was as follows:
>>
>> real11m48.576s
>> user43m8.111s
>> sys 0m12.469s
>>
>> Execution time with optimizations:
>>
>> real6m17.046s
>> user21m19.792s
>> sys 0m14.724s
>>
>>
>> The patch contains optimizations for most heavily used qpel, epel, sao and
>> idct
>> functions.  Among the functions provided for optimization there are two
>> intensively used, but not optimized in this patch:
>> hevc_v_loop_filter_luma_8
>> and hevc_h_loop_filter_luma_8. I have no idea how they could be optimized
>> hence I leaved them without optimizations.
>>
>>
>>
>> Signed-off-by: Rafal Dabrowa 
>> ---
>>  libavcodec/aarch64/Makefile   |5 +
>>  libavcodec/aarch64/hevcdsp_epel_8.S   | 3949 
>>  libavcodec/aarch64/hevcdsp_idct_8.S   | 1980 ++
>>  libavcodec/aarch64/hevcdsp_init_aarch64.c |  170 +
>>  libavcodec/aarch64/hevcdsp_qpel_8.S   | 5666
>> +
>>  libavcodec/aarch64/hevcdsp_sao_8.S|  166 +
>>  libavcodec/hevcdsp.c  |2 +
>>  libavcodec/hevcdsp.h  |1 +
>>  8 files changed, 11939 insertions(+)
>>  create mode 100644 libavcodec/aarch64/hevcdsp_epel_8.S
>>  create mode 100644 libavcodec/aarch64/hevcdsp_idct_8.S
>>  create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c
>>  create mode 100644 libavcodec/aarch64/hevcdsp_qpel_8.S
>>  create mode 100644 libavcodec/aarch64/hevcdsp_sao_8.S
> 
> 
> 
> Very nice.
> The way we test SIMD is to put START_TIMER("function_name"); and
> STOP_TIMER; (they're located in libavutil/timer.h) around where the
> function gets called in the C code, then we do a run with the C code (no
> SIMD) and a separate run with whatever SIMD optimizations we're
> implementing. We take the last printed value of both runs and that's what's
> used to measure speedup.
> 
> I don't think there's a need to split the patch into multiple patches for
> each idividual version though yet, that's usually only done if some
> function's C implementation is faster than the SIMD code.

It would be nice however to at least split it into two patches, one for
MC and one for SAO.

Also, no way to use macros in aarch64 asm files? ~11k lines of code is a
lot to add, and I'm sure a sizable portion is duplicated with only some
small differences between functions.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 12/13] vaapi: Add VP8 decode hwaccel

2017-11-18 Thread Mark Thompson
---
 configure  |   3 +
 libavcodec/Makefile|   1 +
 libavcodec/hwaccels.h  |   1 +
 libavcodec/vaapi_vp8.c | 237 +
 libavcodec/vp8.c   |   6 ++
 5 files changed, 248 insertions(+)
 create mode 100644 libavcodec/vaapi_vp8.c

diff --git a/configure b/configure
index 3d3c0bd7c3..77fc2fec11 100755
--- a/configure
+++ b/configure
@@ -2731,6 +2731,8 @@ vc1_vaapi_hwaccel_deps="vaapi"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
 vc1_vdpau_hwaccel_select="vc1_decoder"
+vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8"
+vp8_vaapi_hwaccel_select="vp8_decoder"
 vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
 vp9_d3d11va_hwaccel_select="vp9_decoder"
 vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
@@ -5703,6 +5705,7 @@ check_type "windows.h d3d11.h" "ID3D11VideoContext"
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
+check_type "va/va.h va/va_dec_vp8.h" "VAPictureParameterBufferVP8"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
 check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
 check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 494c76da76..7ba682e02a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -869,6 +869,7 @@ OBJS-$(CONFIG_VC1_NVDEC_HWACCEL)  += nvdec_vc1.o
 OBJS-$(CONFIG_VC1_QSV_HWACCEL)+= qsvdec_other.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)  += vaapi_vc1.o
 OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)  += vdpau_vc1.o
+OBJS-$(CONFIG_VP8_VAAPI_HWACCEL)  += vaapi_vp8.o
 OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL)+= dxva2_vp9.o
 OBJS-$(CONFIG_VP9_DXVA2_HWACCEL)  += dxva2_vp9.o
 OBJS-$(CONFIG_VP9_NVDEC_HWACCEL)  += nvdec_vp9.o
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index c8081dc05c..8083806520 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -57,6 +57,7 @@ extern const AVHWAccel ff_vc1_dxva2_hwaccel;
 extern const AVHWAccel ff_vc1_nvdec_hwaccel;
 extern const AVHWAccel ff_vc1_vaapi_hwaccel;
 extern const AVHWAccel ff_vc1_vdpau_hwaccel;
+extern const AVHWAccel ff_vp8_vaapi_hwaccel;
 extern const AVHWAccel ff_vp9_d3d11va_hwaccel;
 extern const AVHWAccel ff_vp9_d3d11va2_hwaccel;
 extern const AVHWAccel ff_vp9_dxva2_hwaccel;
diff --git a/libavcodec/vaapi_vp8.c b/libavcodec/vaapi_vp8.c
new file mode 100644
index 00..2426b30f13
--- /dev/null
+++ b/libavcodec/vaapi_vp8.c
@@ -0,0 +1,237 @@
+/*
+ * 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
+ */
+
+#include 
+#include 
+
+#include "hwaccel.h"
+#include "vaapi_decode.h"
+#include "vp8.h"
+
+static VASurfaceID vaapi_vp8_surface_id(VP8Frame *vf)
+{
+if (vf)
+return ff_vaapi_get_surface_id(vf->tf.f);
+else
+return VA_INVALID_SURFACE;
+}
+
+static int vaapi_vp8_start_frame(AVCodecContext  *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t   size)
+{
+const VP8Context *s = avctx->priv_data;
+VAAPIDecodePicture *pic = 
s->framep[VP56_FRAME_CURRENT]->hwaccel_picture_private;
+VAPictureParameterBufferVP8 pp;
+VAProbabilityDataBufferVP8 prob;
+VAIQMatrixBufferVP8 quant;
+int err, i, j, k;
+
+pic->output_surface = vaapi_vp8_surface_id(s->framep[VP56_FRAME_CURRENT]);
+
+pp = (VAPictureParameterBufferVP8) {
+.frame_width = avctx->width,
+.frame_height= avctx->height,
+
+.last_ref_frame  = 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_PREVIOUS]),
+.golden_ref_frame= 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_GOLDEN]),
+.alt_ref_frame   = 
vaapi_vp8_surface_id(s->framep[VP56_FRAME_GOLDEN2]),
+.out_of_loop_frame   = VA_INVALID_SURFACE,
+
+.pic_fields.bits = {
+.key_frame   = !s->keyframe,
+.version = s->profile,
+
+.segmentation_enabled= s->segmentation.enabled,
+  

[FFmpeg-devel] [PATCH 08/13] ffmpeg: Use codec hardware config to configure hwaccels

2017-11-18 Thread Mark Thompson
Removes specific support for all hwaccels supported by the generic code
(DXVA2, D3D11VA, NVDEC, VAAPI, VDPAU and videotoolbox).
---
 fftools/ffmpeg.c |  77 +++-
 fftools/ffmpeg.h |  10 +--
 fftools/ffmpeg_hw.c  | 244 +++
 fftools/ffmpeg_opt.c |  55 ++--
 4 files changed, 250 insertions(+), 136 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index babd85f7bc..acff815e74 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2782,45 +2782,77 @@ fail:
 av_freep();
 }
 
-static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt, enum HWAccelID 
selected_hwaccel_id)
-{
-int i;
-for (i = 0; hwaccels[i].name; i++)
-if (hwaccels[i].pix_fmt == pix_fmt &&
-(!selected_hwaccel_id || selected_hwaccel_id == HWACCEL_AUTO || 
hwaccels[i].id == selected_hwaccel_id))
-return [i];
-return NULL;
-}
-
 static enum AVPixelFormat get_format(AVCodecContext *s, const enum 
AVPixelFormat *pix_fmts)
 {
 InputStream *ist = s->opaque;
 const enum AVPixelFormat *p;
 int ret;
 
-for (p = pix_fmts; *p != -1; p++) {
+for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);
-const HWAccel *hwaccel;
+const AVCodecHWConfig  *config = NULL;
+int i;
 
 if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
 break;
 
-hwaccel = get_hwaccel(*p, ist->hwaccel_id);
-if (!hwaccel ||
-(ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) 
||
-(ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != 
hwaccel->id))
-continue;
+if (ist->hwaccel_id == HWACCEL_GENERIC ||
+ist->hwaccel_id == HWACCEL_AUTO) {
+for (i = 0;; i++) {
+config = avcodec_get_hw_config(s->codec, i);
+if (!config)
+break;
+if (!(config->methods &
+  AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
+continue;
+if (config->pix_fmt == *p)
+break;
+}
+}
+if (config) {
+if (config->device_type != ist->hwaccel_device_type) {
+// Different hwaccel offered, ignore.
+continue;
+}
 
-ret = hwaccel->init(s);
-if (ret < 0) {
-if (ist->hwaccel_id == hwaccel->id) {
+ret = hwaccel_decode_init(s);
+if (ret < 0) {
+if (ist->hwaccel_id == HWACCEL_GENERIC) {
+av_log(NULL, AV_LOG_FATAL,
+   "%s hwaccel requested for input stream #%d:%d, "
+   "but cannot be initialized.\n",
+   av_hwdevice_get_type_name(config->device_type),
+   ist->file_index, ist->st->index);
+return AV_PIX_FMT_NONE;
+}
+continue;
+}
+} else {
+const HWAccel *hwaccel = NULL;
+int i;
+for (i = 0; hwaccels[i].name; i++) {
+if (hwaccels[i].pix_fmt == *p) {
+hwaccel = [i];
+break;
+}
+}
+if (!hwaccel) {
+// No hwaccel supporting this pixfmt.
+continue;
+}
+if (hwaccel->id != ist->hwaccel_id) {
+// Does not match requested hwaccel.
+continue;
+}
+
+ret = hwaccel->init(s);
+if (ret < 0) {
 av_log(NULL, AV_LOG_FATAL,
"%s hwaccel requested for input stream #%d:%d, "
"but cannot be initialized.\n", hwaccel->name,
ist->file_index, ist->st->index);
 return AV_PIX_FMT_NONE;
 }
-continue;
 }
 
 if (ist->hw_frames_ctx) {
@@ -2829,8 +2861,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, 
const enum AVPixelFormat
 return AV_PIX_FMT_NONE;
 }
 
-ist->active_hwaccel_id = hwaccel->id;
-ist->hwaccel_pix_fmt   = *p;
+ist->hwaccel_pix_fmt = *p;
 break;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index e0977e1bf1..8bb5bae862 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -61,14 +61,9 @@
 enum HWAccelID {
 HWACCEL_NONE = 0,
 HWACCEL_AUTO,
-HWACCEL_VDPAU,
-HWACCEL_DXVA2,
-HWACCEL_VIDEOTOOLBOX,
+HWACCEL_GENERIC,
 HWACCEL_QSV,
-HWACCEL_VAAPI,
 HWACCEL_CUVID,
-HWACCEL_D3D11VA,
-HWACCEL_NVDEC,
 };
 
 typedef struct HWAccel {
@@ -76,7 +71,6 @@ typedef struct HWAccel {
 int (*init)(AVCodecContext *s);
 enum HWAccelID id;
 enum AVPixelFormat pix_fmt;
-enum AVHWDeviceType device_type;
 } HWAccel;
 
 typedef 

[FFmpeg-devel] [PATCH 02/13] lavc: Add hardware config metadata for decoders supporting hardware output

2017-11-18 Thread Mark Thompson
This includes a pointer to the associated hwaccel for decoders using
hwaccels - these will be used later to implement the hwaccel setup
without needing a global list.

Also added is a new file listing all hwaccels as external declarations -
this will be used later to generate the hwaccel list at configure time.
---
 libavcodec/cuviddec.c  | 15 ++
 libavcodec/h263dec.c   | 13 +
 libavcodec/h264dec.c   | 25 
 libavcodec/hevcdec.c   | 25 
 libavcodec/hwaccel.h   | 50 
 libavcodec/hwaccels.h  | 72 ++
 libavcodec/mediacodecdec.c | 18 
 libavcodec/mmaldec.c   |  7 +
 libavcodec/mpeg12dec.c | 42 ++-
 libavcodec/mpeg4videodec.c | 13 +
 libavcodec/qsvdec.c| 13 +
 libavcodec/qsvdec.h|  3 ++
 libavcodec/qsvdec_h2645.c  |  2 ++
 libavcodec/qsvdec_other.c  |  3 ++
 libavcodec/vc1dec.c| 43 +++
 libavcodec/vp9.c   | 19 
 16 files changed, 362 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/hwaccels.h

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 6370348639..0e5123304a 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"
 
 typedef struct CuvidContext
@@ -1094,6 +1095,19 @@ static const AVOption options[] = {
 { NULL }
 };
 
+static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
+&(const AVCodecHWConfigInternal) {
+.public = {
+.pix_fmt = AV_PIX_FMT_CUDA,
+.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+   AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
+.device_type = AV_HWDEVICE_TYPE_CUDA
+},
+.hwaccel = NULL,
+},
+NULL
+};
+
 #define DEFINE_CUVID_CODEC(x, X) \
 static const AVClass x##_cuvid_class = { \
 .class_name = #x "_cuvid", \
@@ -1127,6 +1141,7 @@ static const AVOption options[] = {
 AV_PIX_FMT_P010, \
 AV_PIX_FMT_P016, \
 AV_PIX_FMT_NONE }, \
+.hw_configs = cuvid_hw_configs, \
 };
 
 #if CONFIG_HEVC_CUVID_DECODER
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index c7cf4bc0c2..cf66e520b0 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,6 +33,7 @@
 #include "flv.h"
 #include "h263.h"
 #include "h263_parser.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg4video.h"
@@ -756,4 +757,16 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+},
 };
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index be187eb5f4..b03024d4a3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -47,6 +47,7 @@
 #include "h264_mvpred.h"
 #include "h264_ps.h"
 #include "golomb.h"
+#include "hwaccel.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
@@ -1059,6 +1060,30 @@ AVCodec ff_h264_decoder = {
 .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
  AV_CODEC_CAP_FRAME_THREADS,
+.hw_configs= (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H264_DXVA2_HWACCEL
+   HWACCEL_DXVA2(h264),
+#endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+   HWACCEL_D3D11VA(h264),
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+   HWACCEL_D3D11VA2(h264),
+#endif
+#if CONFIG_H264_NVDEC_HWACCEL
+   HWACCEL_NVDEC(h264),
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+   HWACCEL_VAAPI(h264),
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+   HWACCEL_VDPAU(h264),
+#endif
+#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
+   HWACCEL_VIDEOTOOLBOX(h264),
+#endif
+   NULL
+   },
 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING,
 .flush = flush_dpb,
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
diff --git 

[FFmpeg-devel] [PATCH 11/13] vp8: Add hwaccel hooks

2017-11-18 Thread Mark Thompson
Also adds some extra fields to the main context structure that may
be needed by a hwaccel decoder.

The current behaviour of the WebP decoder is maintained by adding an
additional field to the VP8 decoder private context to indicate that
it is actually being used as WebP (no hwaccel is supported for that
case).
---
 libavcodec/vp8.c  | 206 --
 libavcodec/vp8.h  |  33 +
 libavcodec/webp.c |   1 +
 3 files changed, 172 insertions(+), 68 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 7841a9d964..31cd6a0d81 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -27,6 +27,7 @@
 #include "libavutil/imgutils.h"
 
 #include "avcodec.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mathops.h"
 #include "rectangle.h"
@@ -72,16 +73,30 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int 
ref)
 if ((ret = ff_thread_get_buffer(s->avctx, >tf,
 ref ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
 return ret;
-if (!(f->seg_map = av_buffer_allocz(s->mb_width * s->mb_height))) {
-ff_thread_release_buffer(s->avctx, >tf);
-return AVERROR(ENOMEM);
+if (!(f->seg_map = av_buffer_allocz(s->mb_width * s->mb_height)))
+goto fail;
+if (s->avctx->hwaccel) {
+const AVHWAccel *hwaccel = s->avctx->hwaccel;
+if (hwaccel->frame_priv_data_size) {
+f->hwaccel_priv_buf = 
av_buffer_allocz(hwaccel->frame_priv_data_size);
+if (!f->hwaccel_priv_buf)
+goto fail;
+f->hwaccel_picture_private = f->hwaccel_priv_buf->data;
+}
 }
 return 0;
+
+fail:
+av_buffer_unref(>seg_map);
+ff_thread_release_buffer(s->avctx, >tf);
+return AVERROR(ENOMEM);
 }
 
 static void vp8_release_frame(VP8Context *s, VP8Frame *f)
 {
 av_buffer_unref(>seg_map);
+av_buffer_unref(>hwaccel_priv_buf);
+f->hwaccel_picture_private = NULL;
 ff_thread_release_buffer(s->avctx, >tf);
 }
 
@@ -99,6 +114,12 @@ static int vp8_ref_frame(VP8Context *s, VP8Frame *dst, 
VP8Frame *src)
 vp8_release_frame(s, dst);
 return AVERROR(ENOMEM);
 }
+if (src->hwaccel_picture_private) {
+dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
+if (!dst->hwaccel_priv_buf)
+return AVERROR(ENOMEM);
+dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
+}
 
 return 0;
 }
@@ -140,7 +161,7 @@ static VP8Frame *vp8_find_free_buffer(VP8Context *s)
 av_log(s->avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
 abort();
 }
-if (frame->tf.f->data[0])
+if (frame->tf.f->buf[0])
 vp8_release_frame(s, frame);
 
 return frame;
@@ -218,8 +239,9 @@ static void parse_segment_info(VP8Context *s)
 int i;
 
 s->segmentation.update_map = vp8_rac_get(c);
+s->segmentation.update_feature_data = vp8_rac_get(c);
 
-if (vp8_rac_get(c)) { // update segment feature data
+if (s->segmentation.update_feature_data) {
 s->segmentation.absolute_vals = vp8_rac_get(c);
 
 for (i = 0; i < 4; i++)
@@ -274,6 +296,7 @@ static int setup_partitions(VP8Context *s, const uint8_t 
*buf, int buf_size)
 int size = AV_RL24(sizes + 3 * i);
 if (buf_size - size < 0)
 return -1;
+s->coeff_partition_size[i] = size;
 
 ret = ff_vp56_init_range_decoder(>coeff_partition[i], buf, size);
 if (ret < 0)
@@ -281,7 +304,11 @@ static int setup_partitions(VP8Context *s, const uint8_t 
*buf, int buf_size)
 buf  += size;
 buf_size -= size;
 }
-return ff_vp56_init_range_decoder(>coeff_partition[i], buf, buf_size);
+
+s->coeff_partition_size[i] = buf_size;
+ff_vp56_init_range_decoder(>coeff_partition[i], buf, buf_size);
+
+return 0;
 }
 
 static void vp7_get_quants(VP8Context *s)
@@ -308,28 +335,28 @@ static void vp8_get_quants(VP8Context *s)
 VP56RangeCoder *c = >c;
 int i, base_qi;
 
-int yac_qi = vp8_rac_get_uint(c, 7);
-int ydc_delta  = vp8_rac_get_sint(c, 4);
-int y2dc_delta = vp8_rac_get_sint(c, 4);
-int y2ac_delta = vp8_rac_get_sint(c, 4);
-int uvdc_delta = vp8_rac_get_sint(c, 4);
-int uvac_delta = vp8_rac_get_sint(c, 4);
+s->quant.yac_qi = vp8_rac_get_uint(c, 7);
+s->quant.ydc_delta  = vp8_rac_get_sint(c, 4);
+s->quant.y2dc_delta = vp8_rac_get_sint(c, 4);
+s->quant.y2ac_delta = vp8_rac_get_sint(c, 4);
+s->quant.uvdc_delta = vp8_rac_get_sint(c, 4);
+s->quant.uvac_delta = vp8_rac_get_sint(c, 4);
 
 for (i = 0; i < 4; i++) {
 if (s->segmentation.enabled) {
 base_qi = s->segmentation.base_quant[i];
 if (!s->segmentation.absolute_vals)
-base_qi += yac_qi;
+base_qi += s->quant.yac_qi;
 } else
-base_qi = yac_qi;
+base_qi = s->quant.yac_qi;
 
-s->qmat[i].luma_qmul[0]= 

[FFmpeg-devel] [PATCH 05/13] lavc: Remove register mechanism for hwaccels

2017-11-18 Thread Mark Thompson
There is no longer any need for a list of them at runtime, because
decoders now carry the pointers to their associated hwaccels internally.
The file containing external declarations is now used to make the list
of hwaccels for configure.
---
 configure  |  2 +-
 libavcodec/allcodecs.c | 80 --
 2 files changed, 1 insertion(+), 81 deletions(-)

diff --git a/configure b/configure
index 8b7b7e164b..1695ae1770 100755
--- a/configure
+++ b/configure
@@ -3509,7 +3509,6 @@ find_things(){
 
 ENCODER_LIST=$(find_things  encoder  ENC  libavcodec/allcodecs.c)
 DECODER_LIST=$(find_things  decoder  DEC  libavcodec/allcodecs.c)
-HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
 MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
 DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
@@ -3525,6 +3524,7 @@ find_things_extern(){
 }
 
 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter 
libavcodec/bitstream_filters.c)
+HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol 
libavformat/protocols.c)
 
 AVCODEC_COMPONENTS_LIST="
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e0adb71951..4a21687b20 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -29,13 +29,6 @@
 #include "avcodec.h"
 #include "version.h"
 
-#define REGISTER_HWACCEL(X, x)  \
-{   \
-extern AVHWAccel ff_##x##_hwaccel;  \
-if (CONFIG_##X##_HWACCEL)   \
-av_register_hwaccel(_##x##_hwaccel); \
-}
-
 #define REGISTER_ENCODER(X, x)  \
 {   \
 extern AVCodec ff_##x##_encoder;\
@@ -61,79 +54,6 @@
 
 static void register_all(void)
 {
-/* hardware accelerators */
-REGISTER_HWACCEL(H263_VAAPI,h263_vaapi);
-REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);
-REGISTER_HWACCEL(H264_CUVID,h264_cuvid);
-REGISTER_HWACCEL(H264_D3D11VA,  h264_d3d11va);
-REGISTER_HWACCEL(H264_D3D11VA2, h264_d3d11va2);
-REGISTER_HWACCEL(H264_DXVA2,h264_dxva2);
-REGISTER_HWACCEL(H264_MEDIACODEC,   h264_mediacodec);
-REGISTER_HWACCEL(H264_MMAL, h264_mmal);
-REGISTER_HWACCEL(H264_NVDEC,h264_nvdec);
-REGISTER_HWACCEL(H264_QSV,  h264_qsv);
-REGISTER_HWACCEL(H264_VAAPI,h264_vaapi);
-REGISTER_HWACCEL(H264_VDPAU,h264_vdpau);
-REGISTER_HWACCEL(H264_VIDEOTOOLBOX, h264_videotoolbox);
-REGISTER_HWACCEL(HEVC_CUVID,hevc_cuvid);
-REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
-REGISTER_HWACCEL(HEVC_D3D11VA2, hevc_d3d11va2);
-REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
-REGISTER_HWACCEL(HEVC_NVDEC,hevc_nvdec);
-REGISTER_HWACCEL(HEVC_MEDIACODEC,   hevc_mediacodec);
-REGISTER_HWACCEL(HEVC_QSV,  hevc_qsv);
-REGISTER_HWACCEL(HEVC_VAAPI,hevc_vaapi);
-REGISTER_HWACCEL(HEVC_VDPAU,hevc_vdpau);
-REGISTER_HWACCEL(HEVC_VIDEOTOOLBOX, hevc_videotoolbox);
-REGISTER_HWACCEL(MJPEG_CUVID,   mjpeg_cuvid);
-REGISTER_HWACCEL(MPEG1_CUVID,   mpeg1_cuvid);
-REGISTER_HWACCEL(MPEG1_XVMC,mpeg1_xvmc);
-REGISTER_HWACCEL(MPEG1_VDPAU,   mpeg1_vdpau);
-REGISTER_HWACCEL(MPEG1_VIDEOTOOLBOX, mpeg1_videotoolbox);
-REGISTER_HWACCEL(MPEG2_CUVID,   mpeg2_cuvid);
-REGISTER_HWACCEL(MPEG2_XVMC,mpeg2_xvmc);
-REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va);
-REGISTER_HWACCEL(MPEG2_D3D11VA2,mpeg2_d3d11va2);
-REGISTER_HWACCEL(MPEG2_DXVA2,   mpeg2_dxva2);
-REGISTER_HWACCEL(MPEG2_MMAL,mpeg2_mmal);
-REGISTER_HWACCEL(MPEG2_NVDEC,   mpeg2_nvdec);
-REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv);
-REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
-REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
-REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
-REGISTER_HWACCEL(MPEG2_MEDIACODEC,  mpeg2_mediacodec);
-REGISTER_HWACCEL(MPEG4_CUVID,   mpeg4_cuvid);
-REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
-REGISTER_HWACCEL(MPEG4_MMAL,mpeg4_mmal);
-REGISTER_HWACCEL(MPEG4_VAAPI,   mpeg4_vaapi);
-REGISTER_HWACCEL(MPEG4_VDPAU,   mpeg4_vdpau);
-REGISTER_HWACCEL(MPEG4_VIDEOTOOLBOX, mpeg4_videotoolbox);
-REGISTER_HWACCEL(VC1_CUVID, vc1_cuvid);
-REGISTER_HWACCEL(VC1_D3D11VA,   vc1_d3d11va);
-REGISTER_HWACCEL(VC1_D3D11VA2,  vc1_d3d11va2);
-REGISTER_HWACCEL(VC1_DXVA2, 

[FFmpeg-devel] [PATCH 03/13] lavc: Use hardware config information in ff_get_format()

2017-11-18 Thread Mark Thompson
This removes the dependency that hardware pixel formats previously had on
AVHWAccel instances, meaning only those which actually do something need
exist after this patch.

Also updates avcodec_default_get_format() to be able to choose hardware
formats if either a matching device has been supplied or no additional
external configuration is required, and avcodec_get_hw_frames_parameters()
to use the hardware config rather than searching the old hwaccel list.

The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it
no longer does anything (the codec already contains the pointers to the
matching hwaccels).
---
 libavcodec/avcodec.h  |   7 --
 libavcodec/cuviddec.c |   2 -
 libavcodec/decode.c   | 285 +++---
 libavcodec/internal.h |  11 +-
 4 files changed, 208 insertions(+), 97 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5bbeb67a0d..fb18f46ea2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3652,13 +3652,6 @@ typedef struct AVHWAccel {
  * that avctx->hwaccel_priv_data is invalid.
  */
 int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx);
-
-/**
- * Some hwaccels are ambiguous if only the id and pix_fmt fields are used.
- * If non-NULL, the associated AVCodec must have
- * FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set.
- */
-const AVClass *decoder_class;
 } AVHWAccel;
 
 /**
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 0e5123304a..346e54e7c6 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -1120,7 +1120,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] 
= {
 .type   = AVMEDIA_TYPE_VIDEO, \
 .id = AV_CODEC_ID_##X, \
 .pix_fmt= AV_PIX_FMT_CUDA, \
-.decoder_class  = ##_cuvid_class, \
 }; \
 AVCodec ff_##x##_cuvid_decoder = { \
 .name   = #x "_cuvid", \
@@ -1135,7 +1134,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] 
= {
 .receive_frame  = cuvid_output_frame, \
 .flush  = cuvid_flush, \
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
-.caps_internal  = FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS, \
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
 AV_PIX_FMT_NV12, \
 AV_PIX_FMT_P010, \
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a7f1e23fc2..8b2bec1ce9 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -40,6 +40,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "thread.h"
 
@@ -1077,33 +1078,67 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
AVSubtitle *sub,
 return ret;
 }
 
-static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
+enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx,
+  const enum AVPixelFormat *fmt)
 {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-return desc->flags & AV_PIX_FMT_FLAG_HWACCEL;
-}
-
-enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const 
enum AVPixelFormat *fmt)
-{
-while (*fmt != AV_PIX_FMT_NONE && is_hwaccel_pix_fmt(*fmt))
-++fmt;
-return fmt[0];
-}
-
-static AVHWAccel *find_hwaccel(AVCodecContext *avctx,
-   enum AVPixelFormat pix_fmt)
-{
-AVHWAccel *hwaccel = NULL;
-const AVClass *av_class =
-(avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS)
-? avctx->codec->priv_class : NULL;
-
-while ((hwaccel = av_hwaccel_next(hwaccel))) {
-if (hwaccel->decoder_class == av_class && hwaccel->id == 
avctx->codec_id
-&& hwaccel->pix_fmt == pix_fmt)
-return hwaccel;
+const AVPixFmtDescriptor *desc;
+const AVCodecHWConfig *config;
+int i, n;
+
+// If a device was supplied when the codec was opened, assume that the
+// user wants to use it.
+if (avctx->hw_device_ctx && avctx->codec->hw_configs) {
+AVHWDeviceContext *device_ctx =
+(AVHWDeviceContext*)avctx->hw_device_ctx->data;
+for (i = 0;; i++) {
+config = >codec->hw_configs[i]->public;
+if (!config)
+break;
+if (!(config->methods &
+  AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX))
+continue;
+if (device_ctx->type != config->device_type)
+continue;
+for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) {
+if (config->pix_fmt == fmt[n])
+return fmt[n];
+}
+}
+}
+// No device or other setup, so we have to choose from things which
+// don't any other external information.
+
+// If 

Re: [FFmpeg-devel] [PATCH] 8-bit hevc decoding optimization on aarch64 with neon

2017-11-18 Thread Rostislav Pehlivanov
>
>
>
> On 18 November 2017 at 17:35, Rafal Dabrowa  wrote:
>
> This is a proposal of performance optimizations for 8-bit
> hevc video decoding on aarch64 platform with neon (simd) extension.
>
> I'm testing my optimizations on NanoPi M3 device. I'm using
> mainly "Big Buck Bunny" video file in format 1280x720 for testing.
> The video file was pulled from libde265.org page, see
> http://www.libde265.org/hevc-bitstreams/bbb-1280x720-cfg06.mkv
> The movie duration is 00:10:34.53.
>
> Overall performance gain is about 2x. Without optimizations the movie
> playback stops in practice after a few seconds. With
> optimizations the file is played smoothly 99% of the time.
>
> For performance testing the following command was used:
>
> time ./ffmpeg -hide_banner -i ~/bbb-1280x720-cfg06.mkv -f yuv4mpegpipe
> - >/dev/null
>
> The video file was pre-read before test to minimize disk reads during
> testing.
> Program execution time without optimization was as follows:
>
> real11m48.576s
> user43m8.111s
> sys 0m12.469s
>
> Execution time with optimizations:
>
> real6m17.046s
> user21m19.792s
> sys 0m14.724s
>
>
> The patch contains optimizations for most heavily used qpel, epel, sao and
> idct
> functions.  Among the functions provided for optimization there are two
> intensively used, but not optimized in this patch:
> hevc_v_loop_filter_luma_8
> and hevc_h_loop_filter_luma_8. I have no idea how they could be optimized
> hence I leaved them without optimizations.
>
>
>
> Signed-off-by: Rafal Dabrowa 
> ---
>  libavcodec/aarch64/Makefile   |5 +
>  libavcodec/aarch64/hevcdsp_epel_8.S   | 3949 
>  libavcodec/aarch64/hevcdsp_idct_8.S   | 1980 ++
>  libavcodec/aarch64/hevcdsp_init_aarch64.c |  170 +
>  libavcodec/aarch64/hevcdsp_qpel_8.S   | 5666
> +
>  libavcodec/aarch64/hevcdsp_sao_8.S|  166 +
>  libavcodec/hevcdsp.c  |2 +
>  libavcodec/hevcdsp.h  |1 +
>  8 files changed, 11939 insertions(+)
>  create mode 100644 libavcodec/aarch64/hevcdsp_epel_8.S
>  create mode 100644 libavcodec/aarch64/hevcdsp_idct_8.S
>  create mode 100644 libavcodec/aarch64/hevcdsp_init_aarch64.c
>  create mode 100644 libavcodec/aarch64/hevcdsp_qpel_8.S
>  create mode 100644 libavcodec/aarch64/hevcdsp_sao_8.S



Very nice.
The way we test SIMD is to put START_TIMER("function_name"); and
STOP_TIMER; (they're located in libavutil/timer.h) around where the
function gets called in the C code, then we do a run with the C code (no
SIMD) and a separate run with whatever SIMD optimizations we're
implementing. We take the last printed value of both runs and that's what's
used to measure speedup.

I don't think there's a need to split the patch into multiple patches for
each idividual version though yet, that's usually only done if some
function's C implementation is faster than the SIMD code.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] h264dec: Remove mpegvideo dependency, it's not needed any more

2017-11-18 Thread James Almer
On 11/18/2017 3:11 PM, Kieran Kunhya wrote:
> $subj
> 

> From 5f9073ba61c4cb8eeb933e9e461b5d1dfe58fe13 Mon Sep 17 00:00:00 2001
> From: Kieran Kunhya 
> Date: Sat, 18 Nov 2017 18:06:01 +
> Subject: [PATCH 2/2] h264dec: Remove mpegvideo dependency, it's not needed any
>  more
> 
> ---
>  libavcodec/h264dec.c | 15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index be187eb5f4..f60e5bfbd4 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -50,7 +50,6 @@
>  #include "mathops.h"
>  #include "me_cmp.h"
>  #include "mpegutils.h"
> -#include "mpeg4video.h"
>  #include "profiles.h"
>  #include "rectangle.h"
>  #include "thread.h"
> @@ -913,14 +912,12 @@ static int finalize_frame(H264Context *h, AVFrame *dst, 
> H264Picture *out, int *g
>  
>  *got_frame = 1;
>  
> -if (CONFIG_MPEGVIDEO) {
> -ff_print_debug_info2(h->avctx, dst, NULL,
> - out->mb_type,
> - out->qscale_table,
> - out->motion_val,
> - NULL,
> - h->mb_width, h->mb_height, h->mb_stride, 1);
> -}
> +ff_print_debug_info2(h->avctx, dst, NULL,

Don't remove the CONFIG_MPEGVIDEO check. h264_decoder does not pull
mpegvideo in configure.
You can still remove mpeg4video.h with the check in place. CONFIG_ and
HAVE_ defines are from config.h

> + out->mb_type,
> + out->qscale_table,
> + out->motion_val,
> + NULL,
> + h->mb_width, h->mb_height, h->mb_stride, 1);
>  }
>  
>  return 0;
> -- 
> 2.11.0.windows.1
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] h264dec: Remove mpegvideo dependency, it's not needed any more

2017-11-18 Thread Kieran Kunhya
$subj


0002-h264dec-Remove-mpegvideo-dependency-it-s-not-needed-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] libavcodec: Move ff_print_debug_info2 to mpegutils.c.

2017-11-18 Thread Kieran Kunhya
$subj


0001-libavcodec-Move-ff_print_debug_info2-to-mpegutils.c.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] 8-bit hevc decoding optimization on aarch64 with neon

2017-11-18 Thread Carl Eugen Hoyos
2017-11-18 18:35 GMT+01:00 Rafal Dabrowa :

> For performance testing the following command was used:
>
> time ./ffmpeg -hide_banner -i ~/bbb-1280x720-cfg06.mkv -f yuv4mpegpipe - 
> >/dev/null

An alternative is:
./ffmpeg -benchmark -i ~/bbb-1280x720-cfg06.mkv -f null -

> The video file was pre-read before test to minimize disk reads during testing.
> Program execution time without optimization was as follows:
>
> real11m48.576s
> user43m8.111s
> sys 0m12.469s
>
> Execution time with optimizations:
>
> real6m17.046s
> user21m19.792s
> sys 0m14.724s

Looks impressive.


> +av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth)
> +{
> +int cpu_flags = av_get_cpu_flags();
> +
> +if (have_neon(cpu_flags) && bit_depth == 8) {
> +NEON8_FNASSIGN(c->put_hevc_epel, 0, 0, pel_pixels);
> +NEON8_FNASSIGN(c->put_hevc_epel, 0, 1, epel_h);
> +NEON8_FNASSIGN(c->put_hevc_epel, 1, 0, epel_v);
> +NEON8_FNASSIGN(c->put_hevc_epel, 1, 1, epel_hv);
> +NEON8_FNASSIGN(c->put_hevc_epel_uni, 1, 0, epel_uni_v);
> +NEON8_FNASSIGN(c->put_hevc_epel_uni, 1, 1, epel_uni_hv);
> +NEON8_FNASSIGN(c->put_hevc_epel_bi, 0, 0, pel_bi_pixels);
> +NEON8_FNASSIGN(c->put_hevc_epel_bi, 0, 1, epel_bi_h);
> +NEON8_FNASSIGN(c->put_hevc_epel_bi, 1, 0, epel_bi_v);
> +NEON8_FNASSIGN(c->put_hevc_epel_bi, 1, 1, epel_bi_hv);
> +NEON8_FNASSIGN(c->put_hevc_qpel, 0, 0, pel_pixels);
> +NEON8_FNASSIGN(c->put_hevc_qpel, 0, 1, qpel_h);
> +NEON8_FNASSIGN(c->put_hevc_qpel, 1, 0, qpel_v);
> +NEON8_FNASSIGN(c->put_hevc_qpel, 1, 1, qpel_hv);
> +NEON8_FNASSIGN(c->put_hevc_qpel_uni, 0, 1, qpel_uni_h);
> +NEON8_FNASSIGN(c->put_hevc_qpel_uni, 1, 0, qpel_uni_v);
> +NEON8_FNASSIGN(c->put_hevc_qpel_uni, 1, 1, qpel_uni_hv);
> +NEON8_FNASSIGN(c->put_hevc_qpel_bi, 0, 0, pel_bi_pixels);
> +NEON8_FNASSIGN(c->put_hevc_qpel_bi, 0, 1, qpel_bi_h);
> +NEON8_FNASSIGN(c->put_hevc_qpel_bi, 1, 0, qpel_bi_v);
> +NEON8_FNASSIGN(c->put_hevc_qpel_bi, 1, 1, qpel_bi_hv);

I wonder if it would have made sense to test and send that patches
in smaller portions, so that those with possible improvements
can be identified.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Refund request of travel costs for GSoC Summit 2017

2017-11-18 Thread Thilo Borgmann
Am 18.11.17 um 18:28 schrieb Thilo Borgmann:
> forgot so long about this :)
> Find the reciepe attached to this mail.

Sorry for spam...

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


Re: [FFmpeg-devel] [PATCH] avcodec: Implement mpeg2 nvdec hwaccel

2017-11-18 Thread Philip Langdale
On Sat, 18 Nov 2017 17:38:06 +0100
Carl Eugen Hoyos  wrote:

> 2017-11-16 17:36 GMT+01:00 Philip Langdale :
> 
> > +AVHWAccel ff_mpeg2_nvdec_hwaccel = {
> > +.name = "mpeg2_nvdec",
> > +.type = AVMEDIA_TYPE_VIDEO,
> > +.id   = AV_CODEC_ID_MPEG2VIDEO,
> > +.pix_fmt  = AV_PIX_FMT_CUDA,
> > +.start_frame  = nvdec_mpeg12_start_frame,
> > +.end_frame= nvdec_mpeg12_end_frame,
> > +.decode_slice = nvdec_mpeg12_decode_slice,
> > +.frame_params = nvdec_mpeg12_frame_params,
> > +.init = ff_nvdec_decode_init,
> > +.uninit   = ff_nvdec_decode_uninit,
> > +.priv_data_size   = sizeof(NVDECContext),
> > +};
> > +#endif
> > diff --git a/libavcodec/version.h b/libavcodec/version.h
> > index a75c885768..5b25a9a8ac 100644
> > --- a/libavcodec/version.h
> > +++ b/libavcodec/version.h
> > @@ -29,7 +29,7 @@
> >
> >  #define LIBAVCODEC_VERSION_MAJOR  58
> >  #define LIBAVCODEC_VERSION_MINOR   3
> > -#define LIBAVCODEC_VERSION_MICRO 102
> > +#define LIBAVCODEC_VERSION_MICRO 103  
> 
> It doesn't really matter but we usually do a minor
> bump when adding a hwaccel/encoder/demuxer/...

I was following what Timo did for the vp9 hwaccel, but I can do a minor
next time.

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


[FFmpeg-devel] Refund request of travel costs for GSoC Summit 2017

2017-11-18 Thread Thilo Borgmann
Hi,

some time ago Carl Eugen and me went to the GSoC Summit. See review mail for 
details.

Here comes the refund request for my flight. Costs were 478.82€ total, I'll 
send the invoice to Stefano privately as usual.

Thanks,
Thilo 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/tcp: Fix type of argument optlen to getsockopt()

2017-11-18 Thread Carl Eugen Hoyos
2017-11-18 3:24 GMT+01:00 Michael Niedermayer :
> On Sun, Nov 12, 2017 at 03:29:21PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes a warning on aix here.
>>
>> Please comment, Carl Eugen
>
>>  tcp.c |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> fa136707423e2f36ee2400c37c2d9fefb027fe80  
>> 0001-lavf-tcp-Fix-the-type-of-the-optlen-argument-to-gets.patch
>> From cd61d9b7b52fd6c74cb19a8e9383b3a2056e67b2 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos 
>> Date: Sun, 12 Nov 2017 15:23:14 +0100
>> Subject: [PATCH] lavf/tcp: Fix the type of the optlen argument to
>>  getsockopt().
>>
>> Fixes a warning on aix:
>> libavformat/tcp.c:283:58: warning: passing argument 5 of 'getsockopt' from 
>> incompatible pointer type
>
> should be ok if you checked the type in the specs

The header is confirmed by the information on opengroup.org, so pushed.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec: Implement mpeg2 nvdec hwaccel

2017-11-18 Thread Carl Eugen Hoyos
2017-11-16 17:36 GMT+01:00 Philip Langdale :

> +AVHWAccel ff_mpeg2_nvdec_hwaccel = {
> +.name = "mpeg2_nvdec",
> +.type = AVMEDIA_TYPE_VIDEO,
> +.id   = AV_CODEC_ID_MPEG2VIDEO,
> +.pix_fmt  = AV_PIX_FMT_CUDA,
> +.start_frame  = nvdec_mpeg12_start_frame,
> +.end_frame= nvdec_mpeg12_end_frame,
> +.decode_slice = nvdec_mpeg12_decode_slice,
> +.frame_params = nvdec_mpeg12_frame_params,
> +.init = ff_nvdec_decode_init,
> +.uninit   = ff_nvdec_decode_uninit,
> +.priv_data_size   = sizeof(NVDECContext),
> +};
> +#endif
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index a75c885768..5b25a9a8ac 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,7 +29,7 @@
>
>  #define LIBAVCODEC_VERSION_MAJOR  58
>  #define LIBAVCODEC_VERSION_MINOR   3
> -#define LIBAVCODEC_VERSION_MICRO 102
> +#define LIBAVCODEC_VERSION_MICRO 103

It doesn't really matter but we usually do a minor
bump when adding a hwaccel/encoder/demuxer/...

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


Re: [FFmpeg-devel] [PATCH] avcodec: Implement mpeg2 nvdec hwaccel

2017-11-18 Thread Philip Langdale
On Sat, 18 Nov 2017 12:11:52 +0100
Timo Rothenpieler  wrote:

> Am 16.11.2017 um 17:36 schrieb Philip Langdale:
> > This is mostly straight-forward. The weird part is that it should
> > just work for mpeg1, but I see corruption in my test cases, so I'm
> > going to try and fix that separately.
> > 
> > Signed-off-by: Philip Langdale 
> > ---
> >   Changelog |   2 +-
> >   configure |   2 +
> >   libavcodec/Makefile   |   1 +
> >   libavcodec/allcodecs.c|   1 +
> >   libavcodec/mpeg12dec.c|   3 +
> >   libavcodec/nvdec.c|  11 ++--
> >   libavcodec/nvdec_mpeg12.c | 153
> > ++
> > libavcodec/version.h  |   2 +- 8 files changed, 168
> > insertions(+), 7 deletions(-) create mode 100644
> > libavcodec/nvdec_mpeg12.c
> > 
> > diff --git a/Changelog b/Changelog
> > index d2b5530ad7..385fe4037c 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -13,7 +13,7 @@ version :
> >   - PCE support for extended channel layouts in the AAC encoder
> >   - native aptX encoder and decoder
> >   - Raw aptX muxer and demuxer
> > -- NVIDIA NVDEC-accelerated H.264, HEVC, VC1 and VP9 hwaccel
> > decoding +- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-2, VC1 and
> > VP9 hwaccel decoding
> >   - Intel QSV-accelerated overlay filter
> >   
> >   
> > diff --git a/configure b/configure
> > index 84f0a04925..1eedad208b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2713,6 +2713,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2"
> >   mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
> >   mpeg2_mediacodec_hwaccel_deps="mediacodec"
> >   mpeg2_mmal_hwaccel_deps="mmal"
> > +mpeg2_nvdec_hwaccel_deps="nvdec"
> > +mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
> >   mpeg2_qsv_hwaccel_deps="libmfx"
> >   mpeg2_vaapi_hwaccel_deps="vaapi"
> >   mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 6315672573..494c76da76 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -854,6 +854,7 @@ OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) +=
> > videotoolbox.o OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) +=
> > mpegvideo_xvmc.o OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)  +=
> > dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)+=
> > dxva2_mpeg2.o +OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)+=
> > nvdec_mpeg12.o OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)  +=
> > qsvdec_other.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)+=
> > vaapi_mpeg2.o OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)+=
> > vdpau_mpeg12.o diff --git a/libavcodec/allcodecs.c
> > b/libavcodec/allcodecs.c index e213f3757c..e0adb71951 100644
> > --- a/libavcodec/allcodecs.c
> > +++ b/libavcodec/allcodecs.c
> > @@ -96,6 +96,7 @@ static void register_all(void)
> >   REGISTER_HWACCEL(MPEG2_D3D11VA2,mpeg2_d3d11va2);
> >   REGISTER_HWACCEL(MPEG2_DXVA2,   mpeg2_dxva2);
> >   REGISTER_HWACCEL(MPEG2_MMAL,mpeg2_mmal);
> > +REGISTER_HWACCEL(MPEG2_NVDEC,   mpeg2_nvdec);
> >   REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv);
> >   REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
> >   REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
> > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> > index d5bc5f21b2..2b213eebcd 100644
> > --- a/libavcodec/mpeg12dec.c
> > +++ b/libavcodec/mpeg12dec.c
> > @@ -1141,6 +1141,9 @@ static const enum AVPixelFormat
> > mpeg1_hwaccel_pixfmt_list_420[] = { };
> >   
> >   static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] =
> > { +#if CONFIG_MPEG2_NVDEC_HWACCEL
> > +AV_PIX_FMT_CUDA,
> > +#endif
> >   #if CONFIG_MPEG2_XVMC_HWACCEL
> >   AV_PIX_FMT_XVMC,
> >   #endif
> > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
> > index 20d7c3db27..3d62840e9f 100644
> > --- a/libavcodec/nvdec.c
> > +++ b/libavcodec/nvdec.c
> > @@ -52,11 +52,12 @@ typedef struct NVDECFramePool {
> >   static int map_avcodec_id(enum AVCodecID id)
> >   {
> >   switch (id) {
> > -case AV_CODEC_ID_H264: return cudaVideoCodec_H264;
> > -case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC;
> > -case AV_CODEC_ID_VC1:  return cudaVideoCodec_VC1;
> > -case AV_CODEC_ID_VP9:  return cudaVideoCodec_VP9;
> > -case AV_CODEC_ID_WMV3:  return cudaVideoCodec_VC1;
> > +case AV_CODEC_ID_H264:   return cudaVideoCodec_H264;
> > +case AV_CODEC_ID_HEVC:   return cudaVideoCodec_HEVC;
> > +case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2;
> > +case AV_CODEC_ID_VC1:return cudaVideoCodec_VC1;
> > +case AV_CODEC_ID_VP9:return cudaVideoCodec_VP9;
> > +case AV_CODEC_ID_WMV3:   return cudaVideoCodec_VC1;
> >   }
> >   return -1;
> >   }
> > diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
> > new file mode 100644
> > index 00..a03b51dd17
> > --- /dev/null
> > +++ b/libavcodec/nvdec_mpeg12.c
> > @@ -0,0 +1,153 @@
> > +/*
> 

Re: [FFmpeg-devel] [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph

2017-11-18 Thread DeHackEd
On 11/18/2017 05:56 AM, Michael Niedermayer wrote:
> On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote:
>> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
>> index aacc185..877fd67 100644
>> --- a/fftools/ffmpeg_filter.c
>> +++ b/fftools/ffmpeg_filter.c
>> @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg)
>>  graph = avfilter_graph_alloc();
>>  if (!graph)
>>  return AVERROR(ENOMEM);
>> +graph->nb_threads = 1;
> 
> if you checked that it doesnt reduce threads for simple & complex
> graphs that are used then LGTM
> 

Yes I have verified that to be the case. Test method was
$ strace -e trace=clone ./ffmpeg_g -filter_complex 'testsrc2[out]' ...

The graph is disposed of within the same function. This is why I am proposing
this change.

Number of threads is a complex filtergraph is handled by the parameter
-filter_complex_threads

> thanks
> 
> [...]
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


Re: [FFmpeg-devel] [PATCH] avfilter: add normalize filter

2017-11-18 Thread Paul B Mahol
On 11/16/17, Richard Ling  wrote:
> On 24 October 2017 at 07:26, Paul B Mahol  wrote:
>> On 9/14/17, Richard Ling  wrote:
>>> Hi,
>>>
>>> This patch adds a filter to normalize (contrast stretch) RGB video.
>>> Comments welcome.
>>>
>>> R.
>>
>> What's status of this?
>
> I created a new patch based on the feedback from Nicolas, but I was
> not able to get Gmail to send it back to me without mangling it.
> According to the answer at the bottom of
> https://stackoverflow.com/questions/6535761/how-to-email-patches-formatted-with-git-format-patch
> it is not possible to send git patches with gmail due to their broken
> mailer.
> So I just set it aside.
>
> Maybe there's some other way to send a patch (base64, attached zip file,
> ???)

Just attach patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add acontrast filter

2017-11-18 Thread Paul B Mahol
On 11/18/17, Rostislav Pehlivanov  wrote:
> On 18 November 2017 at 10:44, Paul B Mahol  wrote:
>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi   |  10 +++
>>  libavfilter/Makefile   |   1 +
>>  libavfilter/af_acontrast.c | 219 ++
>> +++
>>  libavfilter/allfilters.c   |   1 +
>>  4 files changed, 231 insertions(+)
>>  create mode 100644 libavfilter/af_acontrast.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 5d99437871..e35952510b 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -429,6 +429,16 @@ How much to use compressed signal in output. Default
>> is 1.
>>  Range is between 0 and 1.
>>  @end table
>>
>> +@section acontrast
>> +Simple audio dynamic range commpression/expansion filter.
>> +
>> +The filter accepts the following options:
>> +
>> +@table @option
>> +@item c
>> +Set contrast. Default is 33. Allowed range is between 0 and 100.
>> +@end table
>> +
>>  @section acopy
>>
>>  Copy the input audio source unchanged to the output. This is mainly
>> useful for
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index 9acae3ff5b..71c6333a52 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -31,6 +31,7 @@ OBJS-$(CONFIG_QSVVPP)+= qsvvpp.o
>>  # audio filters
>>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>> +OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
>>  OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
>>  OBJS-$(CONFIG_ACRUSHER_FILTER)   += af_acrusher.o
>> diff --git a/libavfilter/af_acontrast.c b/libavfilter/af_acontrast.c
>> new file mode 100644
>> index 00..38de08ffe5
>> --- /dev/null
>> +++ b/libavfilter/af_acontrast.c
>> @@ -0,0 +1,219 @@
>> +/*
>> + * Copyright (c) 2008 Rob Sykes
>> + * Copyright (c) 2017 Paul B Mahol
>> + *
>> + * 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
>> + */
>> +
>> +#include "libavutil/channel_layout.h"
>> +#include "libavutil/opt.h"
>> +#include "avfilter.h"
>> +#include "audio.h"
>> +#include "formats.h"
>> +
>> +typedef struct AudioContrastContext {
>> +const AVClass *class;
>> +float contrast;
>> +void (*filter)(void **dst, const void **src,
>> +   int nb_samples, int channels, float contrast);
>> +} AudioContrastContext;
>> +
>> +#define OFFSET(x) offsetof(AudioContrastContext, x)
>> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> +
>> +static const AVOption acontrast_options[] = {
>> +{ "c", "set contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT,
>> {.dbl=33}, 0, 100, A },
>>
>
> "contrast" instead of "c"? Not sure if single letter options are a good
> idea.
>
>
>
>> +{ NULL }
>> +};
>> +
>> +AVFILTER_DEFINE_CLASS(acontrast);
>> +
>> +static int query_formats(AVFilterContext *ctx)
>> +{
>> +AVFilterFormats *formats = NULL;
>> +AVFilterChannelLayouts *layouts = NULL;
>> +static const enum AVSampleFormat sample_fmts[] = {
>> +AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
>> +AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
>> +AV_SAMPLE_FMT_NONE
>> +};
>> +int ret;
>> +
>> +formats = ff_make_format_list(sample_fmts);
>> +if (!formats)
>> +return AVERROR(ENOMEM);
>> +ret = ff_set_common_formats(ctx, formats);
>> +if (ret < 0)
>> +return ret;
>> +
>> +layouts = ff_all_channel_counts();
>> +if (!layouts)
>> +return AVERROR(ENOMEM);
>> +
>> +ret = ff_set_common_channel_layouts(ctx, layouts);
>> +if (ret < 0)
>> +return ret;
>> +
>> +formats = ff_all_samplerates();
>> +return ff_set_common_samplerates(ctx, formats);
>> +}
>> +
>> +static void filter_flt(void **d, const void **s,
>> +   int nb_samples, int channels,
>> +   float contrast)
>> +{
>> +const float *src = s[0];
>> +float *dst = d[0];
>> +int n, c;
>> +
>> +for (n = 0; n < nb_samples; n++) {
>> +for (c = 0; c < channels; c++) {
>> +   

Re: [FFmpeg-devel] [PATCH] avfilter: add acontrast filter

2017-11-18 Thread Rostislav Pehlivanov
On 18 November 2017 at 10:44, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi   |  10 +++
>  libavfilter/Makefile   |   1 +
>  libavfilter/af_acontrast.c | 219 ++
> +++
>  libavfilter/allfilters.c   |   1 +
>  4 files changed, 231 insertions(+)
>  create mode 100644 libavfilter/af_acontrast.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 5d99437871..e35952510b 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -429,6 +429,16 @@ How much to use compressed signal in output. Default
> is 1.
>  Range is between 0 and 1.
>  @end table
>
> +@section acontrast
> +Simple audio dynamic range commpression/expansion filter.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item c
> +Set contrast. Default is 33. Allowed range is between 0 and 100.
> +@end table
> +
>  @section acopy
>
>  Copy the input audio source unchanged to the output. This is mainly
> useful for
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 9acae3ff5b..71c6333a52 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -31,6 +31,7 @@ OBJS-$(CONFIG_QSVVPP)+= qsvvpp.o
>  # audio filters
>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
> +OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
>  OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
>  OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
>  OBJS-$(CONFIG_ACRUSHER_FILTER)   += af_acrusher.o
> diff --git a/libavfilter/af_acontrast.c b/libavfilter/af_acontrast.c
> new file mode 100644
> index 00..38de08ffe5
> --- /dev/null
> +++ b/libavfilter/af_acontrast.c
> @@ -0,0 +1,219 @@
> +/*
> + * Copyright (c) 2008 Rob Sykes
> + * Copyright (c) 2017 Paul B Mahol
> + *
> + * 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
> + */
> +
> +#include "libavutil/channel_layout.h"
> +#include "libavutil/opt.h"
> +#include "avfilter.h"
> +#include "audio.h"
> +#include "formats.h"
> +
> +typedef struct AudioContrastContext {
> +const AVClass *class;
> +float contrast;
> +void (*filter)(void **dst, const void **src,
> +   int nb_samples, int channels, float contrast);
> +} AudioContrastContext;
> +
> +#define OFFSET(x) offsetof(AudioContrastContext, x)
> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +
> +static const AVOption acontrast_options[] = {
> +{ "c", "set contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT,
> {.dbl=33}, 0, 100, A },
>

"contrast" instead of "c"? Not sure if single letter options are a good
idea.



> +{ NULL }
> +};
> +
> +AVFILTER_DEFINE_CLASS(acontrast);
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +AVFilterFormats *formats = NULL;
> +AVFilterChannelLayouts *layouts = NULL;
> +static const enum AVSampleFormat sample_fmts[] = {
> +AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
> +AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
> +AV_SAMPLE_FMT_NONE
> +};
> +int ret;
> +
> +formats = ff_make_format_list(sample_fmts);
> +if (!formats)
> +return AVERROR(ENOMEM);
> +ret = ff_set_common_formats(ctx, formats);
> +if (ret < 0)
> +return ret;
> +
> +layouts = ff_all_channel_counts();
> +if (!layouts)
> +return AVERROR(ENOMEM);
> +
> +ret = ff_set_common_channel_layouts(ctx, layouts);
> +if (ret < 0)
> +return ret;
> +
> +formats = ff_all_samplerates();
> +return ff_set_common_samplerates(ctx, formats);
> +}
> +
> +static void filter_flt(void **d, const void **s,
> +   int nb_samples, int channels,
> +   float contrast)
> +{
> +const float *src = s[0];
> +float *dst = d[0];
> +int n, c;
> +
> +for (n = 0; n < nb_samples; n++) {
> +for (c = 0; c < channels; c++) {
> +double d = src[c] * M_PI_2;
> +
> +dst[c] = sin(d + contrast * sin(d * 4));
>

sinf() instead of sin()



> +}
> +
> +dst += c;
> +src += c;
> +}
> +}
> +
> +static 

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-11-18 Thread Carl Eugen Hoyos
2017-11-18 7:12 GMT+01:00 Sasi Inguva :

> +if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
> +(st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
> + st->codecpar->codec_id == AV_CODEC_ID_H263 ||
> + st->codecpar->codec_id == AV_CODEC_ID_H264 ||
> + st->codecpar->codec_id == AV_CODEC_ID_HEVC))

Sorry if I misunderstand but shouldn't this also include MPEG4 (and
VC1)?

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


[FFmpeg-devel] [PATCH] avformat/dashenc: fix min_seg_duration option size

2017-11-18 Thread James Cowgill
In the DASHContext structure, min_seg_duration is declared as an int,
but the AVOption list claimed it was an INT64. Change the option list
to use the correct size, which should fix some initialization errors
seen on big-endian platforms.

Signed-off-by: James Cowgill 
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index d5554d1df0..ddad3351fd 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1181,7 +1181,7 @@ static const AVOption options[] = {
 { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 
id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { 0 
}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
 { "window_size", "number of segments kept in the manifest", 
OFFSET(window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E },
 { "extra_window_size", "number of segments kept outside of the manifest 
before removing from disk", OFFSET(extra_window_size), AV_OPT_TYPE_INT, { .i64 
= 5 }, 0, INT_MAX, E },
-{ "min_seg_duration", "minimum segment duration (in microseconds)", 
OFFSET(min_seg_duration), AV_OPT_TYPE_INT64, { .i64 = 500 }, 0, INT_MAX, E 
},
+{ "min_seg_duration", "minimum segment duration (in microseconds)", 
OFFSET(min_seg_duration), AV_OPT_TYPE_INT, { .i64 = 500 }, 0, INT_MAX, E },
 { "remove_at_exit", "remove all segments when finished", 
OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "use_template", "Use SegmentTemplate instead of SegmentList", 
OFFSET(use_template), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
 { "use_timeline", "Use SegmentTimeline in SegmentTemplate", 
OFFSET(use_timeline), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH] avcodec: Implement mpeg2 nvdec hwaccel

2017-11-18 Thread Timo Rothenpieler

Am 16.11.2017 um 17:36 schrieb Philip Langdale:

This is mostly straight-forward. The weird part is that it should
just work for mpeg1, but I see corruption in my test cases, so I'm
going to try and fix that separately.

Signed-off-by: Philip Langdale 
---
  Changelog |   2 +-
  configure |   2 +
  libavcodec/Makefile   |   1 +
  libavcodec/allcodecs.c|   1 +
  libavcodec/mpeg12dec.c|   3 +
  libavcodec/nvdec.c|  11 ++--
  libavcodec/nvdec_mpeg12.c | 153 ++
  libavcodec/version.h  |   2 +-
  8 files changed, 168 insertions(+), 7 deletions(-)
  create mode 100644 libavcodec/nvdec_mpeg12.c

diff --git a/Changelog b/Changelog
index d2b5530ad7..385fe4037c 100644
--- a/Changelog
+++ b/Changelog
@@ -13,7 +13,7 @@ version :
  - PCE support for extended channel layouts in the AAC encoder
  - native aptX encoder and decoder
  - Raw aptX muxer and demuxer
-- NVIDIA NVDEC-accelerated H.264, HEVC, VC1 and VP9 hwaccel decoding
+- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-2, VC1 and VP9 hwaccel decoding
  - Intel QSV-accelerated overlay filter
  
  
diff --git a/configure b/configure

index 84f0a04925..1eedad208b 100755
--- a/configure
+++ b/configure
@@ -2713,6 +2713,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2"
  mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
  mpeg2_mediacodec_hwaccel_deps="mediacodec"
  mpeg2_mmal_hwaccel_deps="mmal"
+mpeg2_nvdec_hwaccel_deps="nvdec"
+mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
  mpeg2_qsv_hwaccel_deps="libmfx"
  mpeg2_vaapi_hwaccel_deps="vaapi"
  mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6315672573..494c76da76 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -854,6 +854,7 @@ OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
  OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o
  OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)  += dxva2_mpeg2.o
  OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)+= dxva2_mpeg2.o
+OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)+= nvdec_mpeg12.o
  OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)  += qsvdec_other.o
  OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)+= vaapi_mpeg2.o
  OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)+= vdpau_mpeg12.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e213f3757c..e0adb71951 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -96,6 +96,7 @@ static void register_all(void)
  REGISTER_HWACCEL(MPEG2_D3D11VA2,mpeg2_d3d11va2);
  REGISTER_HWACCEL(MPEG2_DXVA2,   mpeg2_dxva2);
  REGISTER_HWACCEL(MPEG2_MMAL,mpeg2_mmal);
+REGISTER_HWACCEL(MPEG2_NVDEC,   mpeg2_nvdec);
  REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv);
  REGISTER_HWACCEL(MPEG2_VAAPI,   mpeg2_vaapi);
  REGISTER_HWACCEL(MPEG2_VDPAU,   mpeg2_vdpau);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index d5bc5f21b2..2b213eebcd 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1141,6 +1141,9 @@ static const enum AVPixelFormat 
mpeg1_hwaccel_pixfmt_list_420[] = {
  };
  
  static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {

+#if CONFIG_MPEG2_NVDEC_HWACCEL
+AV_PIX_FMT_CUDA,
+#endif
  #if CONFIG_MPEG2_XVMC_HWACCEL
  AV_PIX_FMT_XVMC,
  #endif
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 20d7c3db27..3d62840e9f 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -52,11 +52,12 @@ typedef struct NVDECFramePool {
  static int map_avcodec_id(enum AVCodecID id)
  {
  switch (id) {
-case AV_CODEC_ID_H264: return cudaVideoCodec_H264;
-case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC;
-case AV_CODEC_ID_VC1:  return cudaVideoCodec_VC1;
-case AV_CODEC_ID_VP9:  return cudaVideoCodec_VP9;
-case AV_CODEC_ID_WMV3:  return cudaVideoCodec_VC1;
+case AV_CODEC_ID_H264:   return cudaVideoCodec_H264;
+case AV_CODEC_ID_HEVC:   return cudaVideoCodec_HEVC;
+case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2;
+case AV_CODEC_ID_VC1:return cudaVideoCodec_VC1;
+case AV_CODEC_ID_VP9:return cudaVideoCodec_VP9;
+case AV_CODEC_ID_WMV3:   return cudaVideoCodec_VC1;
  }
  return -1;
  }
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
new file mode 100644
index 00..a03b51dd17
--- /dev/null
+++ b/libavcodec/nvdec_mpeg12.c
@@ -0,0 +1,153 @@
+/*
+ * MPEG-2 HW decode acceleration through NVDEC
+ *
+ * Copyright (c) 2017 Philip Langdale
+ *
+ * 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 

Re: [FFmpeg-devel] [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph

2017-11-18 Thread Michael Niedermayer
On Thu, Nov 16, 2017 at 08:25:50PM -0500, DeHackEd wrote:
> Hello,
> 
> Simple one-line patch to avoid creating threads on a filtergrpah which does 
> not
> get used during execution. This saves a superfluous thread creation and
> tear-down cycle.
> 
> Besides cleanliness, the main driver for this feature is a system I have 
> access
> to with a large number of cores/threads. Threads count towards ulimits and the
> default of 1 filtergraph thread per CPU thread is undesirable.

>  ffmpeg_filter.c |1 +
>  1 file changed, 1 insertion(+)
> 8900e0a4dfa60c9c6c0f0612489d85080b213db8  
> 0001-ffmpeg_filter-use-nb_threads-1-on-unused-filtergraph.patch
> From 999a38ae38178c2ab3ba8a9ef116e7ec08474302 Mon Sep 17 00:00:00 2001
> From: DHE 
> Date: Thu, 16 Nov 2017 20:09:37 -0500
> Subject: [PATCH] ffmpeg_filter: use nb_threads=1 on unused filtergraph
> 
> Signed-off-by: DHE 
> ---
>  fftools/ffmpeg_filter.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index aacc185..877fd67 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -340,6 +340,7 @@ int init_complex_filtergraph(FilterGraph *fg)
>  graph = avfilter_graph_alloc();
>  if (!graph)
>  return AVERROR(ENOMEM);
> +graph->nb_threads = 1;

if you checked that it doesnt reduce threads for simple & complex
graphs that are used then LGTM

thanks

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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


Re: [FFmpeg-devel] [mov] Fix leak of frame_duration_buffer in mov_fix_index().

2017-11-18 Thread Michael Niedermayer
On Sat, Nov 18, 2017 at 02:35:35PM +0530, Sasi Inguva wrote:
> LGTM. Thanks for the fix.

will apply

thanks

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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


Re: [FFmpeg-devel] [mpegaudio] Use ff_thread_once for fixed, float table init.

2017-11-18 Thread Michael Niedermayer
On Fri, Nov 17, 2017 at 02:52:30PM -0800, Dale Curtis wrote:
> These tables are static so they should only be initialized once
> instead of on every call to ff_mpadsp_init().
> 
> Signed-off-by: Dale Curtis 

>  mpegaudiodsp.c |8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 9709276718a21c3995476e37d18279152b760adf  once_table_init_v1.patch
> From 70ffbeb41f0432c72701f6147385e9aa47bf8419 Mon Sep 17 00:00:00 2001
> From: Dale Curtis 
> Date: Fri, 17 Nov 2017 14:51:09 -0800
> Subject: [PATCH] [mpegaudio] Use ff_thread_once for fixed, float table init.
> 
> These tables are static so they should only be initialized once
> instead of on every call to ff_mpadsp_init().
> 
> Signed-off-by: Dale Curtis 
> ---
>  libavcodec/mpegaudiodsp.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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


Re: [FFmpeg-devel] [avformat] Prevent undefined shift with wrap_bits > 63.

2017-11-18 Thread Michael Niedermayer
On Fri, Nov 17, 2017 at 01:46:39PM -0800, Dale Curtis wrote:
> Derp, actually, 2 << 63 doesn't fit in int64_t either, this check should be
> < 63. Fixed.
> 
> 
> 
> On Fri, Nov 17, 2017 at 1:38 PM, Dale Curtis 
> wrote:
> 
> > 2 << (wrap_bits=64 - 1) does not fit in int64_t; apply the check
> > used in other places that handle wrap bits to ensure the values
> > are <= 63.
> >
> > Signed-off-by: Dale Curtis 
> >
> >

>  utils.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 2f61647f4321bebca803154960f74643d4670ee8  wrap_bits_v2.patch
> From 4ae4992326487ba0e42fa7fcf2a53fe3d4564780 Mon Sep 17 00:00:00 2001
> From: Dale Curtis 
> Date: Fri, 17 Nov 2017 13:35:56 -0800
> Subject: [PATCH] [avformat] Prevent undefined shift with wrap_bits >= 63.
> 
> 2 << (wrap_bits=63 - 1) does not fit in int64_t; apply the check
> used in other places that handle wrap bits to ensure the values
> are < 63.
> 
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index ff5e14df6c..65d111459f 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1738,8 +1738,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
>  // current one had no dts, we will set this to 
> AV_NOPTS_VALUE.
>  int64_t last_dts = next_pkt->dts;
>  while (pktl && next_pkt->pts == AV_NOPTS_VALUE) {
> -if (pktl->pkt.stream_index == next_pkt->stream_index &&
> -(av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << 
> (wrap_bits - 1)) < 0)) {
> +if (pktl->pkt.stream_index == next_pkt->stream_index && 
> wrap_bits < 63 &&
> +av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << 
> (wrap_bits - 1)) < 0) {

this would skip the code for wrap_bits >= 63, this does not look
correct

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


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


[FFmpeg-devel] [PATCH] avfilter: add acontrast filter

2017-11-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  10 +++
 libavfilter/Makefile   |   1 +
 libavfilter/af_acontrast.c | 219 +
 libavfilter/allfilters.c   |   1 +
 4 files changed, 231 insertions(+)
 create mode 100644 libavfilter/af_acontrast.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 5d99437871..e35952510b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -429,6 +429,16 @@ How much to use compressed signal in output. Default is 1.
 Range is between 0 and 1.
 @end table
 
+@section acontrast
+Simple audio dynamic range commpression/expansion filter.
+
+The filter accepts the following options:
+
+@table @option
+@item c
+Set contrast. Default is 33. Allowed range is between 0 and 100.
+@end table
+
 @section acopy
 
 Copy the input audio source unchanged to the output. This is mainly useful for
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9acae3ff5b..71c6333a52 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -31,6 +31,7 @@ OBJS-$(CONFIG_QSVVPP)+= qsvvpp.o
 # audio filters
 OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
 OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
+OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
 OBJS-$(CONFIG_ACOPY_FILTER)  += af_acopy.o
 OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
 OBJS-$(CONFIG_ACRUSHER_FILTER)   += af_acrusher.o
diff --git a/libavfilter/af_acontrast.c b/libavfilter/af_acontrast.c
new file mode 100644
index 00..38de08ffe5
--- /dev/null
+++ b/libavfilter/af_acontrast.c
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2008 Rob Sykes
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * 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
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+
+typedef struct AudioContrastContext {
+const AVClass *class;
+float contrast;
+void (*filter)(void **dst, const void **src,
+   int nb_samples, int channels, float contrast);
+} AudioContrastContext;
+
+#define OFFSET(x) offsetof(AudioContrastContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption acontrast_options[] = {
+{ "c", "set contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT, {.dbl=33}, 0, 
100, A },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(acontrast);
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
+AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
+AV_SAMPLE_FMT_NONE
+};
+int ret;
+
+formats = ff_make_format_list(sample_fmts);
+if (!formats)
+return AVERROR(ENOMEM);
+ret = ff_set_common_formats(ctx, formats);
+if (ret < 0)
+return ret;
+
+layouts = ff_all_channel_counts();
+if (!layouts)
+return AVERROR(ENOMEM);
+
+ret = ff_set_common_channel_layouts(ctx, layouts);
+if (ret < 0)
+return ret;
+
+formats = ff_all_samplerates();
+return ff_set_common_samplerates(ctx, formats);
+}
+
+static void filter_flt(void **d, const void **s,
+   int nb_samples, int channels,
+   float contrast)
+{
+const float *src = s[0];
+float *dst = d[0];
+int n, c;
+
+for (n = 0; n < nb_samples; n++) {
+for (c = 0; c < channels; c++) {
+double d = src[c] * M_PI_2;
+
+dst[c] = sin(d + contrast * sin(d * 4));
+}
+
+dst += c;
+src += c;
+}
+}
+
+static void filter_dbl(void **d, const void **s,
+   int nb_samples, int channels,
+   float contrast)
+{
+const double *src = s[0];
+double *dst = d[0];
+int n, c;
+
+for (n = 0; n < nb_samples; n++) {
+for (c = 0; c < channels; c++) {
+double d = src[c] * M_PI_2;
+
+dst[c] = sin(d + contrast * sin(d * 4));
+}
+
+dst += c;
+src += c;
+}
+}
+
+static void 

Re: [FFmpeg-devel] [DEVEL][PATCH v3] ffmpeg: fix channel_layout bug on non-default layout

2017-11-18 Thread pkv.stream

Hi Michael

  ffmpeg_opt.c |   12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)
a7c71fb1ccd7d91b61033be70dfd324b4e3f3c34  
0001-ffmpeg-fix-channel_layout-bug-on-non-default-layout.patch
 From fb7f7f6e01cc242e13d0e640f583dffe6e7a8ada Mon Sep 17 00:00:00 2001
From: pkviet
Date: Mon, 2 Oct 2017 11:14:31 +0200
Subject: [PATCH] ffmpeg: fix channel_layout bug on non-default layout

Fix for ticket 6706.
The -channel_layout option was not working when the channel layout was not
a default one (ex: for 4 channels, quad was interpreted as 4.0 which is
the default layout for 4 channels; or octagonal interpreted as 7.1).
This led to the spurious auto-insertion of an auto-resampler filter
remapping the channels even if input and output had identical channel
layouts.
The fix operates by directly calling the channel layout if defined in
options. If the layout is undefined, the default layout is selected as
before the fix.
---
  fftools/ffmpeg_opt.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ca6f10d..8941d66 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1785,6 +1785,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, 
AVFormatContext *oc, in
  AVStream *st;
  OutputStream *ost;
  AVCodecContext *audio_enc;
+AVDictionaryEntry *output_layout;
  ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
  st  = ost->st;
@@ -1799,7 +1800,10 @@ static OutputStream *new_audio_stream(OptionsContext *o, 
AVFormatContext *oc, in
  char *sample_fmt = NULL;
  MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st);
-
+output_layout = av_dict_get(ost->encoder_opts,"channel_layout", NULL, 
AV_DICT_IGNORE_SUFFIX);
+if (output_layout) {
+audio_enc->channel_layout = strtoull(output_layout->value, NULL, 
10);
+}

why is this handled different from audio_channels ?
that is why is this not using MATCH_PER_STREAM_OPT() ?
(yes this would require some changes but i wonder why this would be
  handled differently)

Hi
I did try to use the MATCH_PER_STREAM_OPT() but didn't manage to
have it working. Also I was a bit hesitant to modify the
OptionsContext struct, and preferred something minimal.
If you think this can definitely be made to work without too much
coding and prefer such a solution, I'll retry working on a
MATCH_PER_STREAM_OPT() solution.

i dont really know if it "can definitely be made to work without too much
coding", it just seemed odd how this is handled differently


I have another version of the patch working with MATCH_PER_STREAM_OPT() ;
but the changes to code are more important, and it's a bit hacky 
(defines an internal OptionDef) ... so not sure it is any better than 
the few lines of patch v3.
I've checked that stream specifiers ( :a:0 ) are passed correctly and 
that two streams with different layouts are also treated correctly (the 
previous patch without MATCH_PER_STREAM_OPT() works also; those were two 
points you singled out in your review).
 I have no real opinion on the best course, which to pick or even to 
let the bug hanging (I'm only trying to fix it due to my work on the aac 
PCE patch of atomnuker ; the bug prevents full use of the new PCE 
capability).
It's Ok with me if you decide to forgo these attempts to fix the bug and 
let the bug stay.
I'm not impacted by the bug in my case use (encode 16 channels in aac); 
just trying to be thorough in my (akward) contributions and trying to 
give back to the project.
Tell me the best course; or if you see a way to make my 
MATCH_PER_STREAM_OPT() code less hacky.


Regards


[...]


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



From 00c3c724544b16c19282b39644e2584f9c4a4181 Mon Sep 17 00:00:00 2001
From: pkviet 
Date: Sat, 18 Nov 2017 00:26:50 +0100
Subject: [PATCH] ffmpeg: fix ticket 6706

Fix regression with channel_layout option which is not passed
correctly from output streams to filters when the channel layout is not
a default one.
---
 fftools/cmdutils.h   |  1 +
 fftools/ffmpeg.h |  3 +++
 fftools/ffmpeg_opt.c | 41 +
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 2997ee3..fa2b255 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -155,6 +155,7 @@ typedef struct SpecifierOpt {
 uint8_t *str;
 inti;
 int64_t  i64;
+uint64_t ui64;
 float  f;
 double   dbl;
 } u;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index e0977e1..5c45df4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -121,6 +121,8 @@ typedef struct OptionsContext {
 intnb_frame_sizes;
 SpecifierOpt *frame_pix_fmts;
 int  

Re: [FFmpeg-devel] [mov] Fix leak of frame_duration_buffer in mov_fix_index().

2017-11-18 Thread Sasi Inguva
LGTM. Thanks for the fix.

On Sat, Nov 18, 2017 at 4:24 AM, Dale Curtis 
wrote:

> Should be unconditionally freed at the end of mov_fix_index() in case it
> hasn't been used during the fix up.
>
> Signed-off-by: Dale Curtis 
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] FFmpeg 3.4.1

2017-11-18 Thread Hendrik Leppkes
On Sat, Nov 18, 2017 at 3:05 AM, Michael Niedermayer
 wrote:
> On Fri, Nov 17, 2017 at 09:55:47AM +0100, Hendrik Leppkes wrote:
>> On Fri, Nov 17, 2017 at 5:00 AM, Michael Niedermayer
>>  wrote:
>> > On Thu, Nov 16, 2017 at 01:51:34PM +0100, Carl Eugen Hoyos wrote:
>> >> 2017-11-16 13:44 GMT+01:00 Michael Niedermayer :
>> >> > On Thu, Nov 16, 2017 at 01:04:27AM +0100, Carl Eugen Hoyos wrote:
>> >> >> 2017-11-15 13:34 GMT+01:00 Michael Niedermayer 
>> >> >> :
>> >> >> > Hi all
>> >> >> >
>> >> >> > I intend to make 3.4.1 very soon
>> >> >>
>> >> >> Shouldn't we first decide on how to proceed with #6775?
>> >> >
>> >> > This would be ideal.
>> >> >
>> >> > IIUC this is a regression from bddb2343b6e594e312dadb5d21b408702929ae04
>> >>
>> >> This was confirmed by more than one developer, yes.
>> >>
>> >> > I see a patch that is said to improve 6775, can that be applied and
>> >> > would that resolve this ?
>> >>
>> >> Iiuc, it would not completely resolve the issue, see:
>> >> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=881536
>> >>
>> >> > If so why was it not applied yet ?
>> >>
>> >> The patch did not get support here, see:
>> >> [FFmpeg-devel] [PATCH] lavc: reset codec on receiving packet after EOF
>> >> in compat_decode
>> >
>> >
>> > Is someone working on fixing this better than with the available patch ?
>> >
>>
>> I don't even agree this needs fixing. Those projects use the API wrong.
>
> Had we documented the correct/wrong use precissely in the past when
> these wrong uses where written ?
>
> Because if it was documented then few should have made the mistake.
> But it seems this affects multiple projects, so i wonder if our API
> really excluded the use
>

Apparently not well enough, but I also don't even understand why you
would *want* to drain in the middle of decoding.

The only mention of sending NULL/0 packets (in 3.0 docs, before the
new API was introduced) do include the "at the end", however.

From CODEC_CAP_DELAY:
 * Decoders:
 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
 * returns frames.

From avcodec_decode_video2
* @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
* between input and output, these need to be fed with avpkt->data=NULL,
* avpkt->size=0 at the end to return the remaining frames.

There is a few more mentions of the same concept, but as far as I can
see all include the key words "at the end".

For the suggested patch, draining and flushing in the middle of a
bitstream is still going to result in problems, though, since it
removes all reference frames, for example.
The original behavior cannot really be stored, which was to just keep
feeding frames into the decoder after a drain without a flush.
However, some decoders actually crashed when you did this, so this was
a rather unsafe action to begin with (not an issue any longer, since
this pattern is now blocked).

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