Re: [FFmpeg-devel] [PATCH] DSD and DST speed improvements

2019-08-01 Thread David Bryant
On 7/31/19 11:49 PM, Paul B Mahol wrote:
> Hi,
>
> patches attached.
>
> This time DSD decoding is approx %50 faster on old Celeron N3050 CPUs and 2
> threads.

I see about 42% speedup on Core Duo E8400 (36x to 52x) for a 5-channel file.

On the same file encoded in DST, the improvement almost disappears (2.47x to 
2.54x) because the DST part takes about 15x more
CPU than the dsd2pcm part; would be extremely valuable to multi-thread that 
instead and leave the dsd2pcm alone.

And this breaks my WavPack DSD decoder, but I guess I can't complain about that 
yet.  :)


>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


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

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

[FFmpeg-devel] [PATCH] FATE/dnn: let fate/dnn tests depend on ffmpeg static libraries

2019-08-01 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 tests/dnn/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index b2e6680..0e050ea 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -4,8 +4,8 @@ DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)
 DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
 -include $(wildcard $(DNNTESTOBJS:.o=.d))
 
-$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
-   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_EXTRALIBS) 
$(ELIBS)
+$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_STATIC_DEP_LIBS)
+   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) 
$(FF_STATIC_DEP_LIBS) $(ELIBS)
 
 testclean::
$(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF))
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH v2] avcodec/vaapi_encode_h264: add support for a/53 closed caption sei

2019-08-01 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Aman Gupta
> Sent: Friday, August 2, 2019 07:33
> To: ffmpeg-devel@ffmpeg.org
> Cc: Aman Gupta 
> Subject: [FFmpeg-devel] [PATCH v2] avcodec/vaapi_encode_h264: add
> support for a/53 closed caption sei
> 
> From: Aman Gupta 
> 
> Signed-off-by: Aman Gupta 
> ---
>  libavcodec/vaapi_encode_h264.c | 24 +++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vaapi_encode_h264.c
> b/libavcodec/vaapi_encode_h264.c
> index f4965d8b09..9860bacb91 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -39,6 +39,7 @@ enum {
>  SEI_TIMING = 0x01,
>  SEI_IDENTIFIER = 0x02,
>  SEI_RECOVERY_POINT = 0x04,
> +SEI_A53_CC = 0x08,
>  };
> 
>  // Random (version 4) ISO 11578 UUID.
> @@ -98,6 +99,8 @@ typedef struct VAAPIEncodeH264Context {
>  H264RawSEIRecoveryPointsei_recovery_point;
>  H264RawSEIUserDataUnregistered sei_identifier;
>  char  *sei_identifier_string;
> +H264RawSEIUserDataRegistered   sei_a53cc;
> +void  *sei_a53cc_data;
> 
>  int aud_needed;
>  int sei_needed;
> @@ -251,6 +254,11 @@ static int
> vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
>  sei->payload[i].payload.recovery_point = 
> priv->sei_recovery_point;
>  ++i;
>  }
> +if (priv->sei_needed & SEI_A53_CC) {
> +sei->payload[i].payload_type =
> H264_SEI_TYPE_USER_DATA_REGISTERED;
> +sei->payload[i].payload.user_data_registered = priv->sei_a53cc;
> +++i;
> +}
> 
>  sei->payload_count = i;
>  av_assert0(sei->payload_count > 0);
> @@ -626,7 +634,8 @@ static int
> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>  VAAPIEncodePicture  *prev = pic->prev;
>  VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : NULL;
>  VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
> -int i;
> +int i, err;
> +size_t sei_a53cc_len;
> 
>  if (pic->type == PICTURE_TYPE_IDR) {
>  av_assert0(pic->display_order == pic->encode_order);
> @@ -700,6 +709,18 @@ static int
> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>  priv->sei_needed |= SEI_RECOVERY_POINT;
>  }
> 
> +av_freep(>sei_a53cc_data);

Is this necessary?

> +err = ff_alloc_a53_sei(pic->input_image, 0, >sei_a53cc_data,
> _a53cc_len);

IMHO, an option "a53cc" is needed under "SEI", like 
identifier/timing/recovery_point does.
And check before setting a53_sei will be good.

> +if (err < 0)
> +return err;
> +if (priv->sei_a53cc_data != NULL) {

"If (priv->sei_a53cc_data)" can be enough.

Regards,

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

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

Re: [FFmpeg-devel] [PATCH] Revert "fate: add unit test for dnn-layer-pad"

2019-08-01 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Hendrik Leppkes
> Sent: Thursday, August 01, 2019 11:14 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] Revert "fate: add unit test for
> dnn-layer-pad"
> 
> On Thu, Aug 1, 2019 at 4:53 PM Guo, Yejun  wrote:
> >
> > This reverts commit 3805aae47966b691f825abab6843f55676437a02.
> >
> > this test calls internal DNN functions within libavfilter, it is
> > not allowed, and so revert it.
> >
> 
> Its not that its not allowed, it just needs to be setup properly. We
> have for example the "checkasm" tests, which test internal modules
> which have no public API at all. You can check how that is setup.

got it, thanks Handrik, I'll use the same method as checkasm.

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-08-01 Thread Juan De León
Fixed

design doc: 
https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |   2 +
 libavutil/frame.h   |   6 ++
 libavutil/quantization_params.c |  42 +
 libavutil/quantization_params.h | 101 
 4 files changed, 151 insertions(+)
 create mode 100644 libavutil/quantization_params.c
 create mode 100644 libavutil/quantization_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..be1a9c3a9c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -60,6 +60,7 @@ HEADERS = adler32.h   
  \
   pixdesc.h \
   pixelutils.h  \
   pixfmt.h  \
+  quantization_params.h \
   random_seed.h \
   rc4.h \
   rational.h\
@@ -140,6 +141,7 @@ OBJS = adler32.o
\
parseutils.o \
pixdesc.o\
pixelutils.o \
+   quantization_params.o\
random_seed.o\
rational.o   \
reverse.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..b64fd9c02c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,12 @@ enum AVFrameSideDataType {
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
 AV_FRAME_DATA_REGIONS_OF_INTEREST,
+/**
+ * To extract quantization parameters from supported decoders.
+ * The data is stored as AVQuantizationParamsArray type, described in
+ * libavuitl/quantization_params.h
+ */
+AV_FRAME_DATA_QUANTIZATION_PARAMS,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/quantization_params.c b/libavutil/quantization_params.c
new file mode 100644
index 00..152be71ba7
--- /dev/null
+++ b/libavutil/quantization_params.c
@@ -0,0 +1,42 @@
+/*
+ * 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 "libavutil/quantization_params.h"
+
+static const char* const QP_NAMES_H264[] = {"qp", "qpcb", "qpcr"};
+
+static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", "quvac",
+   "qiyac", "qiydc", "qiuvdc", 
"qiuvac"};
+
+static const char* const QP_NAMES_AV1[] = {"qyac", "qydc", "qudc", "quac", 
"qvdc", "qvac",
+  "qiyac", "qiydc", "qiudc", "qiuac", 
"qivdc", "qivac"};
+
+const char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, 
int index)
+{
+switch (codec_id) {
+case AV_EXTRACT_QP_CODEC_ID_H264:
+return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index] :NULL;
+case AV_EXTRACT_QP_CODEC_ID_VP9:
+return index < AV_QP_ARR_SIZE_VP9  ? QP_NAMES_VP9[index]  :NULL;
+case AV_EXTRACT_QP_CODEC_ID_AV1:
+return index < AV_QP_ARR_SIZE_AV1  ? QP_NAMES_AV1[index]  :NULL;
+default:
+return NULL;
+}
+}
diff --git a/libavutil/quantization_params.h b/libavutil/quantization_params.h
new file mode 100644
index 00..23f4311293
--- /dev/null
+++ b/libavutil/quantization_params.h
@@ -0,0 +1,101 @@
+/*
+ * 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 

[FFmpeg-devel] [PATCH v2] avcodec/vaapi_encode_h264: add support for a/53 closed caption sei

2019-08-01 Thread Aman Gupta
From: Aman Gupta 

Signed-off-by: Aman Gupta 
---
 libavcodec/vaapi_encode_h264.c | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f4965d8b09..9860bacb91 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -39,6 +39,7 @@ enum {
 SEI_TIMING = 0x01,
 SEI_IDENTIFIER = 0x02,
 SEI_RECOVERY_POINT = 0x04,
+SEI_A53_CC = 0x08,
 };
 
 // Random (version 4) ISO 11578 UUID.
@@ -98,6 +99,8 @@ typedef struct VAAPIEncodeH264Context {
 H264RawSEIRecoveryPointsei_recovery_point;
 H264RawSEIUserDataUnregistered sei_identifier;
 char  *sei_identifier_string;
+H264RawSEIUserDataRegistered   sei_a53cc;
+void  *sei_a53cc_data;
 
 int aud_needed;
 int sei_needed;
@@ -251,6 +254,11 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 sei->payload[i].payload.recovery_point = priv->sei_recovery_point;
 ++i;
 }
+if (priv->sei_needed & SEI_A53_CC) {
+sei->payload[i].payload_type = H264_SEI_TYPE_USER_DATA_REGISTERED;
+sei->payload[i].payload.user_data_registered = priv->sei_a53cc;
+++i;
+}
 
 sei->payload_count = i;
 av_assert0(sei->payload_count > 0);
@@ -626,7 +634,8 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 VAAPIEncodePicture  *prev = pic->prev;
 VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : NULL;
 VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
-int i;
+int i, err;
+size_t sei_a53cc_len;
 
 if (pic->type == PICTURE_TYPE_IDR) {
 av_assert0(pic->display_order == pic->encode_order);
@@ -700,6 +709,18 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->sei_needed |= SEI_RECOVERY_POINT;
 }
 
+av_freep(>sei_a53cc_data);
+err = ff_alloc_a53_sei(pic->input_image, 0, >sei_a53cc_data, 
_a53cc_len);
+if (err < 0)
+return err;
+if (priv->sei_a53cc_data != NULL) {
+priv->sei_a53cc.itu_t_t35_country_code = 181;
+priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
+priv->sei_a53cc.data_length = sei_a53cc_len - 1;
+
+priv->sei_needed |= SEI_A53_CC;
+}
+
 vpic->CurrPic = (VAPictureH264) {
 .picture_id  = pic->recon_surface,
 .frame_idx   = hpic->frame_num,
@@ -1245,6 +1266,7 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext 
*avctx)
 ff_cbs_fragment_free(priv->cbc, >current_access_unit);
 ff_cbs_close(>cbc);
 av_freep(>sei_identifier_string);
+av_freep(>sei_a53cc_data);
 
 return ff_vaapi_encode_close(avctx);
 }
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-08-01 Thread Michael Niedermayer
On Tue, Jul 30, 2019 at 06:47:23PM -0700, Juan De León wrote:
> Removed AVQuantizationParamsArray to prevent ambiguous memory allocation.
> For simplicity, the side data will be allocated as an array of 
> AVQuantizationParams and the last element of the array will have w and h set 
> to 0.
> 
> Better explained in the doc.
> design doc: 
> https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing
> 
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/frame.h   |   6 ++
>  libavutil/quantization_params.c |  41 +
>  libavutil/quantization_params.h | 101 
>  4 files changed, 150 insertions(+)
>  create mode 100644 libavutil/quantization_params.c
>  create mode 100644 libavutil/quantization_params.h

doesnt build here

libavutil/quantization_params.c: In function ‘av_get_qp_type_string’:
libavutil/quantization_params.c:33:72: error: ‘NULL’ undeclared (first use in 
this function)
 return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index] :NULL;
^
libavutil/quantization_params.c:33:72: note: each undeclared identifier is 
reported only once for each function it appears in
libavutil/quantization_params.c:41:1: error: control reaches end of non-void 
function [-Werror=return-type]
 }
 ^
cc1: some warnings being treated as errors
make: *** [libavutil/quantization_params.o] Error 1

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


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

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

[FFmpeg-devel] [PATCH 2/5] avcodec/pnm: Check magic bytes directly without pnm_get()

2019-08-01 Thread Michael Niedermayer
Fixes: Timeout (10sec -> 30ms) (case 15089)
Fixes: 
15089/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PBM_fuzzer-5767535057698816
Fixes: 
16001/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGM_fuzzer-5199169645445120
Fixes: 
16003/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-5076443270217728

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/pnm.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index a9771710c2..a613f13477 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "internal.h"
@@ -68,9 +69,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * 
const s)
 int h, w, depth, maxval;
 int ret;
 
-pnm_get(s, buf1, sizeof(buf1));
-if(buf1[0] != 'P')
+if (s->bytestream_end - s->bytestream < 3 ||
+s->bytestream[0] != 'P' ||
+s->bytestream[1] < '1'  ||
+s->bytestream[1] > '7')
 return AVERROR_INVALIDDATA;
+pnm_get(s, buf1, sizeof(buf1));
 s->type= buf1[1]-'0';
 
 if (s->type==1 || s->type==4) {
@@ -152,7 +156,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext 
* const s)
 }
 return 0;
 } else {
-return AVERROR_INVALIDDATA;
+av_assert0(0);
 }
 pnm_get(s, buf1, sizeof(buf1));
 w = atoi(buf1);
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 3/5] avcodec/pnm: skip reading trailing bytes in get_pnm()

2019-08-01 Thread Michael Niedermayer
None of the keys we support is that long and other keys
lead to decoder failure. None of the values is expected
to be longer, they are all numbers or short keywords.

This simplifies the code

Fixes: Timeout (9sec->43ms)
Fixes: 
15177/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAM_fuzzer-5080556716425216

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/pnm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index a613f13477..28143617c4 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -58,8 +58,6 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
 c = *bs++;
 }
 *s = '\0';
-while (bs < end && !pnm_space(c))
-c = *bs++;
 sc->bytestream = bs;
 }
 
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 5/5] avcodec/pnm_parser: Use memmove() to handle "overread"

2019-08-01 Thread Michael Niedermayer
This is significantly faster

Fixes: Timeout (1sec after this and the previous commit)
Fixes: 
15558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PPM_fuzzer-5705273643106304

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/pnm_parser.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 5339bebde9..94777d2cca 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -41,8 +41,11 @@ static int pnm_parse(AVCodecParserContext *s, AVCodecContext 
*avctx,
 int next = END_NOT_FOUND;
 int skip = 0;
 
-for (; pc->overread > 0; pc->overread--) {
-pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
+if (pc->overread > 0) {
+memmove(pc->buffer + pc->index, pc->buffer + pc->overread_index, 
pc->overread);
+pc->index  += pc->overread;
+pc->overread_index += pc->overread;
+pc->overread = 0;
 }
 
 if (pnmpc->remaining_bytes) {
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 4/5] avcodec/parser: Optimize ff_combine_frame() with massivly negative next

2019-08-01 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
15558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PPM_fuzzer-5705273643106304

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/parser.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 3e19810a94..a63f532c48 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -295,6 +295,10 @@ int ff_combine_frame(ParseContext *pc, int next,
 *buf  = pc->buffer;
 }
 
+if (next < -8) {
+pc->overread += -8 - next;
+next = -8;
+}
 /* store overread bytes */
 for (; next < 0; next++) {
 pc->state   = pc->state   << 8 | pc->buffer[pc->last_index + next];
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 1/5] avcodec/vp8: do vp7_fade_frame() later

2019-08-01 Thread Michael Niedermayer
Fixes: Timeout (100sec -> 5sec)
Fixes: 
15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416

Untested as none of the vp7 samples i found executes this codepath

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp8.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index ba79e5fdab..efc62aabaf 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -501,15 +501,10 @@ static void fade(uint8_t *dst, ptrdiff_t dst_linesize,
 }
 }
 
-static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
+static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
 {
-int alpha = (int8_t) vp8_rac_get_uint(c, 8);
-int beta  = (int8_t) vp8_rac_get_uint(c, 8);
 int ret;
 
-if (c->end <= c->buffer && c->bits >= 0)
-return AVERROR_INVALIDDATA;
-
 if (!s->keyframe && (alpha || beta)) {
 int width  = s->mb_width * 16;
 int height = s->mb_height * 16;
@@ -549,6 +544,8 @@ static int vp7_decode_frame_header(VP8Context *s, const 
uint8_t *buf, int buf_si
 int part1_size, hscale, vscale, i, j, ret;
 int width  = s->avctx->width;
 int height = s->avctx->height;
+int alpha = 0;
+int beta  = 0;
 
 if (buf_size < 4) {
 return AVERROR_INVALIDDATA;
@@ -665,8 +662,8 @@ static int vp7_decode_frame_header(VP8Context *s, const 
uint8_t *buf, int buf_si
 return AVERROR_INVALIDDATA;
 /* E. Fading information for previous frame */
 if (s->fade_present && vp8_rac_get(c)) {
-if ((ret = vp7_fade_frame(s ,c)) < 0)
-return ret;
+alpha = (int8_t) vp8_rac_get_uint(c, 8);
+beta  = (int8_t) vp8_rac_get_uint(c, 8);
 }
 
 /* F. Loop filter type */
@@ -696,6 +693,12 @@ static int vp7_decode_frame_header(VP8Context *s, const 
uint8_t *buf, int buf_si
 vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
 }
 
+if (c->end <= c->buffer && c->bits >= 0)
+return AVERROR_INVALIDDATA;
+
+if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
+return ret;
+
 return 0;
 }
 
-- 
2.22.0

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

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

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v3]

2019-08-01 Thread Marton Balint



On Thu, 1 Aug 2019, Andreas Håkon wrote:


Hi Marton,

First of all, a new version [v4] is posted here:
https://patchwork.ffmpeg.org/patch/14121/


I replied to the wrong (v3) mail, but I commented the v4 version.



However, I'll comment on your suggestions, as they are reasonable.


‐‐‐ Original Message ‐‐‐
On Wednesday, 31 de July de 2019 23:58, Marton Balint  wrote:


> +for (i = 0; i < ts->nb_services; i++) {
> +service = ts->services[i];
> +service->pcr_st = NULL;
> +}
> +

This loop is not needed as far as I see. service is already initialized
and service->pcr_st is zero initialized so you don't need to set it to
NULL explicitly.


I prefer to initilize any variable. Futhermore, Andriy has commented to
do it inside the mpegts_add_service function. I prefer his approach.


You allocate the MpegTSService struct with av_mallocz therefore pcr_st it 
is already initialized to NULL, re-initializing it to NULL is pointless.






> +
> +/* program service checks */
> +program = av_find_program_from_stream(s, NULL, i);
> +do {
> +for (j = 0; j < ts->nb_services; j++) {
> +if (program) {
> +/* search for the services corresponding to this program 
*/
> +if (ts->services[j]->program == program)
> +service = ts->services[j];
> +else
> +continue;
> +}
> +
> +ts_st->service = service;
> +
> +/* check for PMT pid conflicts */
> +if (ts_st->pid == service->pmt.pid) {
> +av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
ts_st->pid);
> +ret = AVERROR(EINVAL);
> +goto fail;
> +}
> +
> +/* update PCR pid by using the first video stream */
> +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> +service->pcr_pid == 0x1fff) {
> +service->pcr_pid = ts_st->pid;
> +service->pcr_st  = st;
> +}
> +
> +/* store this stream as a candidate PCR if the service 
doesn't have any */
> +if (service->pcr_pid == 0x1fff &&
> +!service->pcr_st) {
> +service->pcr_st  = st;
> +}
> +
> +/* exit when just one single service */
> +if (!program)
> +break;
> +}
> +program = program ? av_find_program_from_stream(s, program, i) : 
NULL;
> +} while (program);


Maybe I miss something but as far as I see only this block needs to be in
the loop, the rest is not. So you can actually write this:



False! All checks require to be completed inside the loop.
Please, note that one stream (aka pid) can be assigned to multiple programs.
So we need to iterate over all programs and services.


My problem is that the body of the inner loop, after the if (program) 
condition is executed exactly once. Therefore it does not belong to a 
loop.






/* program service checks */
program = av_find_program_from_stream(s, NULL, i);
do {
if (program) {
for (j = 0; j < ts->nb_services; j++) {

 if (ts->services[j]->program == program) {

 service = ts->services[j];

 break;
 }
 }
 }


ts_st->service = service;

/* check for PMT pid conflicts */
...

This way you also ensure that ts_st->service is always set for every
stream which is kind of how the old code worked, right?


Not really. The "service" can be assigned on two ways: or using the iteration
over all programs, or in the creation of a new service with the call
to the "mpegts_add_service()" function when no programs are defined.


To be frank, the whole ts_st->service is bogus, because a stream can 
belong to multiple services, so on what grounds do we select one?


I'd suggest to remove service from MpegTSWriteStream and move
pcr_packet_count and pcr_packet_period from MpegTSService to 
MpegTSWriteStream. Of course this should be yet another, separate patch, a 
prerequisite to this one.







> -
> -  ts_st->service = service;
>
>

You are setting this for all programs of the stream, so effectively the
stream's service will be the last program (service) the stream is part of.
Maybe you should aim for the first instead?


No. That's doesn't have sense. The objective of the code (old and new) is:

- Assign a pid for the PCR.
- Check for conflicts with the pid number.

To achieve this you need to compare with all PMTs. And futhermore, you need
to iterate over all services as the pid can be inside one or more of them.

And note this: the "ts_st->service = service" will be assigned to the
"last" service only when no programs are defined. So in this case only one
service 

Re: [FFmpeg-devel] [PATCH] mpegts pat and sdt period should respect user options

2019-08-01 Thread Tomas Hulata
Hi, sorry for delay, I wasn't tracking response, let's try it as 
attachment.


Thx

On 6/6/19 11:58 PM, Michael Niedermayer wrote:

On Wed, Jun 05, 2019 at 11:13:20PM +0200, Tomas Hulata wrote:

When mux_rate (CBR) is defined, pat/sdt period setting is now respected. In
case of VBR, leave it as it was.

---
  libavformat/mpegtsenc.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..5ad1f813e0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -999,10 +999,18 @@ static int mpegts_init(AVFormatContext *s)
  ts->last_sdt_ts = AV_NOPTS_VALUE;

git doesnt like this patch
Applying: mpegts pat and sdt period should respect user options
error: corrupt patch at line 10

[...]


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

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

--
S pozdravom
Tomas Hulata
/vedoucí úseku systemových inženýrů/
tel: +420 733 163 238
NETBOX  

SMART Comp. a.s., Kubíčkova 8, 635 00, Brno
Tel./fax: +420 544 423 411, www.netbox.cz

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..d2706b7d80 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -999,10 +999,18 @@ static int mpegts_init(AVFormatContext *s)
 ts->last_sdt_ts = AV_NOPTS_VALUE;
 // The user specified a period, use only it
 if (ts->pat_period < INT_MAX/2) {
-ts->pat_packet_period = INT_MAX;
+        if (ts->mux_rate > 1)
+            ts->pat_packet_period = (int64_t)ts->mux_rate * ts->pat_period /
+                                    (TS_PACKET_SIZE * 8);
+        else
+            ts->pat_packet_period = INT_MAX;
 }
 if (ts->sdt_period < INT_MAX/2) {
-ts->sdt_packet_period = INT_MAX;
+        if (ts->mux_rate > 1)
+            ts->sdt_packet_period = (int64_t)ts->mux_rate * ts->sdt_period /
+                                    (TS_PACKET_SIZE * 8);
+        else
+            ts->sdt_packet_period = INT_MAX;
 }
 
 // output a PCR as soon as possible


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

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

[FFmpeg-devel] [PATCH] avcodec/vaapi_encode_h264: add support for a/53 closed caption sei

2019-08-01 Thread Aman Gupta
From: Aman Gupta 

Signed-off-by: Aman Gupta 
---
 libavcodec/vaapi_encode_h264.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f4965d8b09..f66e483b7f 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -39,6 +39,7 @@ enum {
 SEI_TIMING = 0x01,
 SEI_IDENTIFIER = 0x02,
 SEI_RECOVERY_POINT = 0x04,
+SEI_A53_CC = 0x08,
 };
 
 // Random (version 4) ISO 11578 UUID.
@@ -96,6 +97,7 @@ typedef struct VAAPIEncodeH264Context {
 H264RawSEIBufferingPeriod  sei_buffering_period;
 H264RawSEIPicTimingsei_pic_timing;
 H264RawSEIRecoveryPointsei_recovery_point;
+H264RawSEIUserDataRegistered   sei_a53_cc;
 H264RawSEIUserDataUnregistered sei_identifier;
 char  *sei_identifier_string;
 
@@ -251,6 +253,11 @@ static int 
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
 sei->payload[i].payload.recovery_point = priv->sei_recovery_point;
 ++i;
 }
+if (priv->sei_needed & SEI_A53_CC) {
+sei->payload[i].payload_type = H264_SEI_TYPE_USER_DATA_REGISTERED;
+sei->payload[i].payload.user_data_registered = priv->sei_a53_cc;
+++i;
+}
 
 sei->payload_count = i;
 av_assert0(sei->payload_count > 0);
@@ -626,7 +633,8 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 VAAPIEncodePicture  *prev = pic->prev;
 VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : NULL;
 VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
-int i;
+AVFrameSideData *side_data = NULL;
+int i, err;
 
 if (pic->type == PICTURE_TYPE_IDR) {
 av_assert0(pic->display_order == pic->encode_order);
@@ -700,6 +708,27 @@ static int 
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
 priv->sei_needed |= SEI_RECOVERY_POINT;
 }
 
+side_data = av_frame_get_side_data(pic->input_image, AV_FRAME_DATA_A53_CC);
+if (side_data && side_data->size) {
+priv->sei_a53_cc.itu_t_t35_country_code = 181;
+priv->sei_a53_cc.data_length = side_data->size + 9;
+err = av_reallocp(>sei_a53_cc.data, 
priv->sei_a53_cc.data_length);
+if (err < 0)
+return err;
+priv->sei_a53_cc.data[0] = 0;
+priv->sei_a53_cc.data[1] = 49;
+priv->sei_a53_cc.data[2] = 'G';
+priv->sei_a53_cc.data[3] = 'A';
+priv->sei_a53_cc.data[4] = '9';
+priv->sei_a53_cc.data[5] = '4';
+priv->sei_a53_cc.data[6] = 3;
+priv->sei_a53_cc.data[7] = 0xc0 | (side_data->size/3);
+priv->sei_a53_cc.data[8] = 255;
+memcpy(priv->sei_a53_cc.data+9, side_data->data, side_data->size);
+
+priv->sei_needed |= SEI_A53_CC;
+}
+
 vpic->CurrPic = (VAPictureH264) {
 .picture_id  = pic->recon_surface,
 .frame_idx   = hpic->frame_num,
@@ -1245,6 +1274,7 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext 
*avctx)
 ff_cbs_fragment_free(priv->cbc, >current_access_unit);
 ff_cbs_close(>cbc);
 av_freep(>sei_identifier_string);
+av_freep(>sei_a53_cc.data);
 
 return ff_vaapi_encode_close(avctx);
 }
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-08-01 Thread Juan De León
On Tue, Jul 30, 2019 at 6:50 PM Juan De León  wrote:

> Removed AVQuantizationParamsArray to prevent ambiguous memory allocation.
> For simplicity, the side data will be allocated as an array of
> AVQuantizationParams and the last element of the array will have w and h
> set to 0.
>
> Better explained in the doc.
> design doc:
> https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing
>
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/frame.h   |   6 ++
>  libavutil/quantization_params.c |  41 +
>  libavutil/quantization_params.h | 101 
>  4 files changed, 150 insertions(+)
>  create mode 100644 libavutil/quantization_params.c
>  create mode 100644 libavutil/quantization_params.h
>
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 8a7a44e4b5..be1a9c3a9c 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -60,6 +60,7 @@ HEADERS = adler32.h
>\
>pixdesc.h \
>pixelutils.h  \
>pixfmt.h  \
> +  quantization_params.h \
>random_seed.h \
>rc4.h \
>rational.h\
> @@ -140,6 +141,7 @@ OBJS = adler32.o
>   \
> parseutils.o \
> pixdesc.o\
> pixelutils.o \
> +   quantization_params.o\
> random_seed.o\
> rational.o   \
> reverse.o\
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 5d3231e7bb..b64fd9c02c 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -179,6 +179,12 @@ enum AVFrameSideDataType {
>   * array element is implied by AVFrameSideData.size /
> AVRegionOfInterest.self_size.
>   */
>  AV_FRAME_DATA_REGIONS_OF_INTEREST,
> +/**
> + * To extract quantization parameters from supported decoders.
> + * The data is stored as AVQuantizationParamsArray type, described in
> + * libavuitl/quantization_params.h
> + */
> +AV_FRAME_DATA_QUANTIZATION_PARAMS,
>  };
>
>  enum AVActiveFormatDescription {
> diff --git a/libavutil/quantization_params.c
> b/libavutil/quantization_params.c
> new file mode 100644
> index 00..7d8b0a4526
> --- /dev/null
> +++ b/libavutil/quantization_params.c
> @@ -0,0 +1,41 @@
> +/*
> + * 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/quantization_params.h"
> +
> +static const char* const QP_NAMES_H264[] = {"qp", "qpcb", "qpcr"};
> +
> +static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc",
> "quvac",
> +   "qiyac", "qiydc", "qiuvdc",
> "qiuvac"};
> +
> +static const char* const QP_NAMES_AV1[] = {"qyac", "qydc", "qudc",
> "quac", "qvdc", "qvac",
> +  "qiyac", "qiydc", "qiudc", "qiuac",
> "qivdc", "qivac"};
> +
> +const char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs
> codec_id, int index)
> +{
> +switch (codec_id) {
> +case AV_EXTRACT_QP_CODEC_ID_H264:
> +return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index]
> :NULL;
> +case AV_EXTRACT_QP_CODEC_ID_VP9:
> +return index < AV_QP_ARR_SIZE_VP9  ? QP_NAMES_VP9[index]
> :NULL;
> +case AV_EXTRACT_QP_CODEC_ID_AV1:
> +return index < AV_QP_ARR_SIZE_AV1  ? QP_NAMES_AV1[index]
> :NULL;
> +default:
> +return NULL;
> +}
> +}
> diff --git a/libavutil/quantization_params.h
> b/libavutil/quantization_params.h
> new file 

Re: [FFmpeg-devel] [PATCH] DSD and DST speed improvements

2019-08-01 Thread Carl Eugen Hoyos
Am Do., 1. Aug. 2019 um 08:55 Uhr schrieb Paul B Mahol :

> patches attached.
>
> This time DSD decoding is approx %50 faster on old Celeron N3050 CPUs and 2
> threads.

As written on irc:
On both Intel and ppc, I see worse performance for threads=2 and threads =6
than threads=1 with this patch (with heavily increased cpu load).
For threads=4, I see a speedup of around 10% at more than twice the cpu load
compared with threads=1.

Above test was done with only the lavc patch applied. If I also use
the lavf patch,
the speedup for threads=4 is not reproducible anymore.

Even the (assumed to be slow) powerpc cpu allows 17x realtime decoding with
current FFmpeg, I am not sure this task is worth the trouble.

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

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

Re: [FFmpeg-devel] [PATCH] lavfi/zmq: Avoid mem copy past the end of input buffer

2019-08-01 Thread Carl Eugen Hoyos
Am Di., 30. Juli 2019 um 23:25 Uhr schrieb Andriy Gelman
:
>
> From: Andriy Gelman 
>
> ---
>  libavfilter/f_zmq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
> index 89da5bef06..744c721305 100644
> --- a/libavfilter/f_zmq.c
> +++ b/libavfilter/f_zmq.c
> @@ -139,7 +139,7 @@ static int recv_msg(AVFilterContext *ctx, char **buf, int 
> *buf_size)
>  ret = AVERROR(ENOMEM);
>  goto end;
>  }
> -memcpy(*buf, zmq_msg_data(), *buf_size);
> +memcpy(*buf, zmq_msg_data(), *buf_size - 1);

Patch applied.

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

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

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-08-01 Thread Gaullier Nicolas
> > > MXF has a UL registered for Dolby-E:
> I also notice this UL is already in mxf.c, but added commented out by 
> Baptiste back in 2006..
There are two ways for signalling dolby-E in MXF : channel status IF using an 
AES3 descriptor, or the registered UL for Sound Essence Coding.
ARD/ZDF/HDF requires both but it is very specific. The use of the channel 
status only seems a little bit more common, I have seen it in Harmonic files.
But at the end, what is really highly widespread is to have no signaling at all.

> So, a general solution is needed. When the user knows the audio is Dolby-E 
> then they can obviously just override the decoder, if they want (not always). 
> Another typical case is "if you think the audio is Dolby- E, automatically 
> decode it so I don't blow my speakers!". An option could allow 
> avformat_find_stream_info() to wait for the first audio packet and probe it, 
> and not take what the demuxer says at face value.
Concerning a general solution, the problem is even worse : nowadays MXF files 
are mostly structured with mono audio tracks (ARD/ZDF, AS-10 in France etc.)...
My idea was to enable the submux only for wav/mxf/potentially quicktime because 
I don't see use case for other formats; but this require stereo audio.
For a more general solution (MXF with mono audio tracks specifically), I have 
in mind to build an audio filter : a graph would merge the L/R to build a 
dolbyE stream that the filter could decode: this is not very handy for users, 
but I don't know how it could be done otherwise.
I am currently working with an AVOption in MXF contexts, but if you think 
avformat_find_stream_info() is a better way, I will take a look... but I am not 
very confident with my knowledge of ffmpeg for that work, and I will rather 
certainly concentrate on the general case with the audio filter if this is 
valid for you ?

Thank you for all your comments
Nicolas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Paul B Mahol
On Thu, Aug 1, 2019 at 6:07 PM Pedro Arthur  wrote:

> Hi,
>
> Em qui, 1 de ago de 2019 às 06:36, Paul B Mahol 
> escreveu:
> >
> > Why test uses internal function, why was this allowed to be committed at
> > all?
> > Who is reviewing this mess?
> >
> > Why test does not use normal filtergraph?
> >
> I was responsible for pushing the patch, thanks for point out the issues.
> Could you provide more details regarding the proper way to make the test?
>
>
I believe Hendrik already pointed to right answer, in another thread.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Pedro Arthur
Hi,

Em qui, 1 de ago de 2019 às 06:36, Paul B Mahol  escreveu:
>
> Why test uses internal function, why was this allowed to be committed at
> all?
> Who is reviewing this mess?
>
> Why test does not use normal filtergraph?
>
I was responsible for pushing the patch, thanks for point out the issues.
Could you provide more details regarding the proper way to make the test?

Thanks.

> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavu/tx: add support for double precision FFT and MDCT

2019-08-01 Thread Lynne
Jul 27, 2019, 7:29 PM by d...@lynne.ee:

> Simply moves and templates the actual transforms to support an
> additional data type.
> Unlike the float version, which is equal or better than libfftw3f,
> double precision output is bit identical with libfftw3.
>

Planning to push attached version soon.
Just some minor changes (moved the radix permute to tx_priv, added if guards).

>From 3ea4284c2bc65cb3aee0f00e4c3e5ef5b75c3508 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Sat, 27 Jul 2019 18:54:20 +0100
Subject: [PATCH v2] lavu/tx: add support for double precision FFT and MDCT

Simply moves and templates the actual transforms to support an
additional data type.
Unlike the float version, which is equal or better than libfftw3f,
double precision output is bit identical with libfftw3.
---
 doc/APIchanges  |   3 +
 libavutil/Makefile  |   2 +
 libavutil/tx.c  | 691 +---
 libavutil/tx.h  |  12 +
 libavutil/tx_double.c   |  21 ++
 libavutil/tx_float.c|  21 ++
 libavutil/tx_priv.h | 105 ++
 libavutil/tx_template.c | 643 +
 libavutil/version.h |   2 +-
 9 files changed, 824 insertions(+), 676 deletions(-)
 create mode 100644 libavutil/tx_double.c
 create mode 100644 libavutil/tx_float.c
 create mode 100644 libavutil/tx_priv.h
 create mode 100644 libavutil/tx_template.c

diff --git a/doc/APIchanges b/doc/APIchanges
index 07331b16e7..6603a8229e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-07-27 - xx - lavu 56.33.100 - tx.h
+  Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
+
  8< - FFmpeg 4.2 was cut here  8< -
 
 2019-06-21 - a30e44098a - lavu 56.30.100 - frame.h
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..57e6e3d7e8 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -161,6 +161,8 @@ OBJS = adler32.o\
xtea.o   \
tea.o\
tx.o \
+   tx_float.o   \
+   tx_double.o
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
diff --git a/libavutil/tx.c b/libavutil/tx.c
index 93f6e489d3..83e36f88cc 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -1,10 +1,4 @@
 /*
- * Copyright (c) 2019 Lynne 
- * Power of two FFT:
- * Copyright (c) 2008 Loren Merritt
- * Copyright (c) 2002 Fabrice Bellard
- * Partly based on libdjbfft by D. J. Bernstein
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -22,576 +16,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
-#include "tx.h"
-#include "thread.h"
-#include "mem.h"
-#include "avassert.h"
-
-typedef float FFTSample;
-typedef AVComplexFloat FFTComplex;
-
-struct AVTXContext {
-int n;  /* Nptwo part */
-int m;  /* Ptwo part */
-
-FFTComplex *exptab; /* MDCT exptab */
-FFTComplex *tmp;/* Temporary buffer needed for all compound transforms */
-int*pfatab; /* Input/Output mapping for compound transforms */
-int*revtab; /* Input mapping for power of two transforms */
-};
-
-#define FFT_NAME(x) x
-
-#define COSTABLE(size) \
-static DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2]
-
-static FFTSample * const FFT_NAME(ff_cos_tabs)[18];
-
-COSTABLE(16);
-COSTABLE(32);
-COSTABLE(64);
-COSTABLE(128);
-COSTABLE(256);
-COSTABLE(512);
-COSTABLE(1024);
-COSTABLE(2048);
-COSTABLE(4096);
-COSTABLE(8192);
-COSTABLE(16384);
-COSTABLE(32768);
-COSTABLE(65536);
-COSTABLE(131072);
-
-static av_cold void init_ff_cos_tabs(int index)
-{
-int m = 1 << index;
-double freq = 2*M_PI/m;
-FFTSample *tab = FFT_NAME(ff_cos_tabs)[index];
-for(int i = 0; i <= m/4; i++)
-tab[i] = cos(i*freq);
-for(int i = 1; i < m/4; i++)
-tab[m/2 - i] = tab[i];
-}
-
-typedef struct CosTabsInitOnce {
-void (*func)(void);
-AVOnce control;
-} CosTabsInitOnce;
-
-#define INIT_FF_COS_TABS_FUNC(index, size) \
-static av_cold void init_ff_cos_tabs_ ## size (void)   \
-{  \
-init_ff_cos_tabs(index);   \
-}
-
-INIT_FF_COS_TABS_FUNC(4, 16)
-INIT_FF_COS_TABS_FUNC(5, 32)
-INIT_FF_COS_TABS_FUNC(6, 64)
-INIT_FF_COS_TABS_FUNC(7, 128)
-INIT_FF_COS_TABS_FUNC(8, 256)
-INIT_FF_COS_TABS_FUNC(9, 512)
-INIT_FF_COS_TABS_FUNC(10, 1024)
-INIT_FF_COS_TABS_FUNC(11, 2048)
-INIT_FF_COS_TABS_FUNC(12, 

Re: [FFmpeg-devel] [PATCH] lavfi/zmq: Avoid mem copy past the end of input buffer

2019-08-01 Thread Paul B Mahol
On Tue, Jul 30, 2019 at 11:24 PM Andriy Gelman 
wrote:

> From: Andriy Gelman 
>
> ---
>  libavfilter/f_zmq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
> index 89da5bef06..744c721305 100644
> --- a/libavfilter/f_zmq.c
> +++ b/libavfilter/f_zmq.c
> @@ -139,7 +139,7 @@ static int recv_msg(AVFilterContext *ctx, char **buf,
> int *buf_size)
>  ret = AVERROR(ENOMEM);
>  goto end;
>  }
> -memcpy(*buf, zmq_msg_data(), *buf_size);
> +memcpy(*buf, zmq_msg_data(), *buf_size - 1);
>  (*buf)[*buf_size-1] = 0;
>
>  end:
> --
> 2.22.0
>

LGTM, I can not apply it, so I kindly ask other committers to apply it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Revert "fate: add unit test for dnn-layer-pad"

2019-08-01 Thread Hendrik Leppkes
On Thu, Aug 1, 2019 at 4:53 PM Guo, Yejun  wrote:
>
> This reverts commit 3805aae47966b691f825abab6843f55676437a02.
>
> this test calls internal DNN functions within libavfilter, it is
> not allowed, and so revert it.
>

Its not that its not allowed, it just needs to be setup properly. We
have for example the "checkasm" tests, which test internal modules
which have no public API at all. You can check how that is setup.

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

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

[FFmpeg-devel] [PATCH] Revert "fate: add unit test for dnn-layer-pad"

2019-08-01 Thread Guo, Yejun
This reverts commit 3805aae47966b691f825abab6843f55676437a02.

this test calls internal DNN functions within libavfilter, it is
not allowed, and so revert it.

Signed-off-by: Guo, Yejun 
---
 tests/Makefile |   5 +-
 tests/dnn/Makefile |  11 ---
 tests/dnn/dnn-layer-pad-test.c | 203 -
 tests/fate/dnn.mak |   8 --
 4 files changed, 1 insertion(+), 226 deletions(-)
 delete mode 100644 tests/dnn/Makefile
 delete mode 100644 tests/dnn/dnn-layer-pad-test.c
 delete mode 100644 tests/fate/dnn.mak

diff --git a/tests/Makefile b/tests/Makefile
index 0ef571b..624292d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -10,8 +10,7 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF)
 $(AREF): CMP=
 
 APITESTSDIR := tests/api
-DNNTESTSDIR := tests/dnn
-FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 
$(APITESTSDIR) $(DNNTESTSDIR)
+FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs 
tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 
$(APITESTSDIR)
 OUTDIRS += $(FATE_OUTDIRS)
 
 $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1
@@ -86,7 +85,6 @@ FILTERDEMDECENCMUX = $(call ALLYES, $(1:%=%_FILTER) 
$(2)_DEMUXER $(3)_DECODER $(
 PARSERDEMDEC   = $(call ALLYES, $(1)_PARSER $(2)_DEMUXER $(3)_DECODER)
 
 include $(SRC_PATH)/$(APITESTSDIR)/Makefile
-include $(SRC_PATH)/$(DNNTESTSDIR)/Makefile
 
 include $(SRC_PATH)/tests/fate/acodec.mak
 include $(SRC_PATH)/tests/fate/vcodec.mak
@@ -120,7 +118,6 @@ include $(SRC_PATH)/tests/fate/cover-art.mak
 include $(SRC_PATH)/tests/fate/dca.mak
 include $(SRC_PATH)/tests/fate/demux.mak
 include $(SRC_PATH)/tests/fate/dfa.mak
-include $(SRC_PATH)/tests/fate/dnn.mak
 include $(SRC_PATH)/tests/fate/dnxhd.mak
 include $(SRC_PATH)/tests/fate/dpcm.mak
 include $(SRC_PATH)/tests/fate/ea.mak
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
deleted file mode 100644
index b2e6680..000
--- a/tests/dnn/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-DNNTESTPROGS += dnn-layer-pad
-
-DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
-DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
--include $(wildcard $(DNNTESTOBJS:.o=.d))
-
-$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
-   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_EXTRALIBS) 
$(ELIBS)
-
-testclean::
-   $(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF))
diff --git a/tests/dnn/dnn-layer-pad-test.c b/tests/dnn/dnn-layer-pad-test.c
deleted file mode 100644
index 28a49eb..000
--- a/tests/dnn/dnn-layer-pad-test.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2019 Guo Yejun
- *
- * 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 
-#include "libavfilter/dnn/dnn_backend_native_layer_pad.h"
-
-#define EPSON 0.1
-
-static int test_with_mode_symmetric(void)
-{
-// the input data and expected data are generated with below python code.
-/*
-x = tf.placeholder(tf.float32, shape=[1, None, None, 3])
-y = tf.pad(x, [[0, 0], [2, 3], [3, 2], [0, 0]], 'SYMMETRIC')
-data = np.arange(48).reshape(1, 4, 4, 3);
-
-sess=tf.Session()
-sess.run(tf.global_variables_initializer())
-output = sess.run(y, feed_dict={x: data})
-
-print(list(data.flatten()))
-print(list(output.flatten()))
-print(data.shape)
-print(output.shape)
-*/
-
-LayerPadParams params;
-float input[1*4*4*3] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
40, 41, 42, 43, 44, 45, 46, 47
-};
-float expected_output[1*9*9*3] = {
-18.0, 19.0, 20.0, 15.0, 16.0, 17.0, 12.0, 13.0, 14.0, 12.0, 13.0, 
14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 21.0, 22.0, 23.0, 
18.0, 19.0, 20.0, 6.0, 7.0, 8.0, 3.0,
-4.0, 5.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 
9.0, 10.0, 11.0, 9.0, 10.0, 11.0, 6.0, 7.0, 8.0, 6.0, 7.0, 8.0, 3.0, 4.0, 5.0, 
0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0,
-4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 9.0, 10.0, 11.0, 6.0, 

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-08-01 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Wednesday, July 31, 2019 14:04
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> 
> On Tue, Jul 30, 2019 at 10:27:10AM -0300, James Almer wrote:
> > On 7/30/2019 6:33 AM, Carl Eugen Hoyos wrote:
> > > Am Di., 30. Juli 2019 um 11:25 Uhr schrieb Fu, Linjie 
> > > :
> > >>
> > >>> -Original Message-
> > >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > >>> Of Carl Eugen Hoyos
> > >>> Sent: Tuesday, July 30, 2019 16:06
> > >>> To: FFmpeg development discussions and patches  > >>> de...@ffmpeg.org>
> > >>> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> > >>> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> > >>>
> > >>> Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu
> :
> > 
> >  Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
> >  whether encoder supports variable dimension encoding.
> > >>>
> > >>> Isn't this about variable (or "changing") "resolutions" instead of
> dimensions?
> > >>>
> > >>
> > >> Comment is welcome and "variable resolutions" is good.
> > >
> > >> But is "dimension" not quite suitable for the meaning of "variable size"?
> > >
> > > It took me some time to understand that "dimension" implies resolution,
> > > especially since the FFmpeg documentation mentions resolution iirc.
> > >
> > > Carl Eugen
> >
> > We have a AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS flag to signal
> resolution
> > changes, so both words seem to be used interchangeably.
> >
> 
> > This also makes me think that the existing
> AV_CODEC_CAP_PARAM_CHANGE
> > codec cap can be used for this already, without the need for a new one.
> > It should a matter of using AV_PKT_DATA_PARAM_CHANGE packet side
> data
> > afterwards in some form.
> 
> if AV_PKT_DATA_PARAM_CHANGE is used then other parameters would
> need to
> be handled too i think.
> For example pixel format changes alongside width and height.
> And it leaves some areas of uncertanity which may require more flags
> like does a aspect ratio change or a change of one of the colorspace
> parameters need a encoder "flush/restart". (the flush is done from
> outside the encoder in the patch so the code would need to know)
> 
> Also for symmetry, if AV_PKT_DATA_PARAM_CHANGE expects sidedata on
> the input side of the decoder, something should produce matching
> side data on the encoder side.
> 
> encoder -> decoder should continue working. So only a demuxer
> generating the side data could be a problem.

Sounds like a new flag will be more robust?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-08-01 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Zern
> Sent: Thursday, August 1, 2019 07:15
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 3/3] lavc/libvpxenc: add dynamic
> resolution encode support for libvpx
> 
> Hi,
> 
> On Tue, Jul 30, 2019 at 10:06 PM Linjie Fu  wrote:
> > [...]
> > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > index feb52ea..800ba18 100644
> > --- a/libavcodec/libvpxenc.c
> > +++ b/libavcodec/libvpxenc.c
> > @@ -1067,6 +1067,15 @@ static int vpx_encode(AVCodecContext *avctx,
> AVPacket *pkt,
> >  int res, coded_size;
> >  vpx_enc_frame_flags_t flags = 0;
> >
> > +if (frame && (avctx->width != frame->width ||
> > +  avctx->height != frame->height)) {
> > +avctx->width  = frame->width;
> > +avctx->height = frame->height;
> > +
> > +avctx->codec->close(avctx);
> 
> You shouldn't need to destroy the encoder for a resolution change,
> unless I'm missing something. Take a look at resize_test.cc [1].
> 
> [1]
> https://chromium.googlesource.com/webm/libvpx/+/refs/heads/master/te
> st/resize_test.cc#305

Yes, IMHO vp8 supports resolution change in key frame, and for vp9,  resolution 
change
is supported per frame, thus current modification may lead to unnecessary Key 
frames.

Will find a better solution. Thanks.

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

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

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v4]

2019-08-01 Thread Andriy Gelman
Andreas,

On Thu, 01. Aug 08:24, Andreas Håkon wrote:
> Hi Andriy,
> 
> 
> ‐‐‐ Original Message ‐‐‐
> On Thursday, 1 de August de 2019 0:23, Andriy Gelman 
>  wrote:
> 
> > > +for (i = 0; i < ts->nb_services; i++) {
> > > +service = ts->services[i];
> > > +service->pcr_st = NULL;
> > > +}
> > > +
> >
> > If you are going to add pcr_st to MpegTSService then it would make sense to 
> > move the
> > initialization to mpegts_add_service function.
> 
> Good idea!
> 
> 
> > > +
> > > +/* program service checks */
> > > +program = av_find_program_from_stream(s, NULL, i);
> > > +do {
> > > +for (j = 0; j < ts->nb_services; j++) {
> > > +if (program) {
> > > +/* search for the services corresponding to this 
> > > program */
> > > +if (ts->services[j]->program == program)
> > > +service = ts->services[j];
> > > +else
> > > +continue;
> > > +}
> > > +
> > > +ts_st->service = service;
> > > +
> > > +/* check for PMT pid conflicts */
> > > +if (ts_st->pid == service->pmt.pid) {
> > > +av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> > > ts_st->pid);
> > > +ret = AVERROR(EINVAL);
> > > +goto fail;
> > > +}
> > > +
> > > +/* update PCR pid by using the first video stream */
> > > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > > +service->pcr_pid == 0x1fff) {
> > > +service->pcr_pid = ts_st->pid;
> > > +service->pcr_st  = st;
> > > +}
> > > +
> > > +/* store this stream as a candidate PCR if the service 
> > > doesn't have any */
> > > +if (service->pcr_pid == 0x1fff &&
> > > +!service->pcr_st) {
> > > +service->pcr_st  = st;
> > > +}
> > > +
> > > +/* exit when just one single service */
> > > +if (!program)
> > > +break;
> > > +}
> > > +program = program ? av_find_program_from_stream(s, program, 
> > > i) : NULL;
> > > +} while (program);
> >
> > This may be easier to digest if you separate the cases when
> > s->nb_programs == 0 and s->nb_programs > 0. Maybe something like this could
> > work:
> 
> Well, the code works, right?
> So let me to comment some things previous to discuss your suggestion:
> 
> 1. I prefer to leave the code close to the original one. If someone needs to 
> do
>more changes, it's preferable to do small changes. Don't you think so?
> 
> 2. The difference between "s->nb_programs == 0" and "s->nb_programs > 0" is 
> because
>the old code. From my point of view, the special case when "s->nb_programs 
> == 0"
>is a little sloppy. However, I need to consider it, so for this reason the 
> code
>handles it.

Yes, I believe the code works. 
But, readability is also very important. Think about someone who is not familiar
with the code. It's tough to see straightaway how the two cases s->nb_programs 
== 0 and
and s->nb_programs > 0 are handled differently. Also, I believe it's easier for 
bugs to be
appear if someone modifies this code. 

I think Marton or Michael should have the final say. 

> 
> > /*update service when no programs defined. use default service */
> > if (s->nb_programs == 0) {
> >
> > ret = update_service_and_set_pcr(s, st, service);
> > if (ret < 0)
> > goto fail:
> >
> >
> > }
> >
> > /*find program for i-th stream */
> > program = av_find_program_from_stream(s, NULL, i);
> > while (s->nb_programs > 0 && program) {
> >
> > /*find the service that this program belongs to */
> > for (j = 0; j < ts->nb_services; j++) {
> >
> > if (ts->services[j]->program == program) {
> >
> > service = ts->services[j];
> >
> > break;
> > }
> > }
> >
> 
> No, no! The loop requires to complete it for all services!
> Every service requires a PCR, and the PCR can be inside a
> shared stream. So if we break for the first service, then
> other services will not be processed.
> Please, see that the code is inside a loop and uses a continue
> when the program doesn't match.

The break refers to the "for" loop and not the "while" loop. 
You'll find the next service in the next iteration of the while loop.

> 
> >
> > ret = update_service_and_set_pcr(s, st, service);
> > if (ret < 0)
> > goto fail:
> >
> > /*find next program that this stream belongs to */
> > program = av_find_program_from_stream(s, program, i);
> > }
> >
> > /*we need to define the function update_service_and_set_pcr */
> > static int update_service_and_set_pcr(AVFormatContext *s, AVStream *st, 
> > MpegTSService *service)
> > {
> >
> > 

[FFmpeg-devel] [PATCH] avcodec/msrle: remove unused items

2019-08-01 Thread Paul B Mahol
Hi,

patch attached.


0001-avcodec-msrle-remove-unused-items.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH]Support for Frame Doubling/ Tripling in FFMPEG's HEVC Decoder by parsing the picture_struct SEI value (Support for http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.h

2019-08-01 Thread Devin Heitmueller
> On Aug 1, 2019, at 8:46 AM, Praveen Kumar  wrote:
> 
> Hi,
> 
> This patch has the implementation for frame duplication (doubling/ tripling) 
> in FFmpeg's HEVC decoder based on the picture_structre SEI value (7 for 
> doubling and 8 for tripling) set while encoding.
> This addresses the requirement mentioned in the thread 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html
> 
> Thanks & Regards,
> Praveen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Hi Praveen,

Thanks for your contribution.   If somebody wants to get pic_timing modes 1/2 
working as well in ffmpeg's HEVC decoder, I can probably get that work 
sponsored.  I wrote a libavfilter module to recombine the fields and work 
around the issue, but it would obviously be much better if the decoder did it 
properly to begin with (and there’s no way my filter approach would be accepted 
upstream).

If we could get this done, it would result in ffmpeg properly decoding 
interlaced streams generated by x265, as well as fixing the issue with VLC 
playing the streams at half vertical resolution and twice the frame rate (since 
VLC relies on libavcodec for HEVC decoding).

There is at least one other commercial HEVC encoder I’ve seen which puts out 
modes 11/12 and hence that would be useful as well.  I suspect supporting that 
would be a relatively small incremental step from making modes 1/2 work.

Reach out to me privately if anybody is interested in doing such a project.

Devin

---
Devin Heitmueller - LTN Global Communications
dheitmuel...@ltnglobal.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH]Support for Frame Doubling/ Tripling in FFMPEG's HEVC Decoder by parsing the picture_struct SEI value (Support for http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html)

2019-08-01 Thread Praveen Kumar
Hi,

This patch has the implementation for frame duplication (doubling/ tripling) in 
FFmpeg's HEVC decoder based on the picture_structre SEI value (7 for doubling 
and 8 for tripling) set while encoding.
This addresses the requirement mentioned in the thread 
http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html

Thanks & Regards,
Praveen


Support-for-Frame-Doubling-Tripling-in-FFMPEG-HEVC-Decoder.patch
Description: Support-for-Frame-Doubling-Tripling-in-FFMPEG-HEVC-Decoder.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Nicolas George
> Sent: Thursday, August 01, 2019 5:10 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] dnn: rename function from
> dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad
> 
> Paul B Mahol (12019-08-01):
> > I do not like this.
> 
> I agree. The av namespace is for public functions.

sorry that the test uses the internal function at unit test level.
I'll send out a patch to revert it since it is not allowed, I'll then consider 
a better solution for the test.

My intention was to verify the dnn layers separately and directly, so one test 
for each layer was my choice.
And so I can add more dnn layers and its unit test one by one, and then add dnn 
generic filters at proper time.

I now know it is not the right choice and I'll plan to add filter test into 
FATE after a meaningful filter is enabled.

> 
> Regards,
> 
> --
>   Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Ticket #7124: Fixes compiler bug - replace vec_lvsl/vec_perm with vec_xl

2019-08-01 Thread Moritz Barsnick
Hi,

On Thu, Aug 01, 2019 at 07:42:28 -0400, ckerchne wrote:

Just a small hint: You patch was corrupted by newlines inserted by your
email client.

Try attaching the patch file, or using git send-email.

> > --- a/libswscale/ppc/yuv2rgb_altivec.c
> > +++ b/libswscale/ppc/yuv2rgb_altivec.c
> > @@ -305,9 +305,6 @@ static int altivec_ ## name(SwsContext *c, const
> > unsigned char **in,  \
> >  vector signed short R1, G1, B1;
> >\
> >  vector unsigned char R, G, B;
> >\
> >
> >\
> > -const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;
> >\
> > -vector unsigned char align_perm;
> >\
> > -
> >\

See also here how the formatting ended up:
https://patchwork.ffmpeg.org/patch/14045/

Also please prefix the first line of the commit message with
"swscale/ppc/yuv2rgb_altivec:". The "Fixes #" part can go lower
into the commit message body (like to the last line, as a separate
parapgraph, for example).

Cheers,
Moritz

P.S.: I can't review this anyway. ;-)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] Ticket #7124: Fixes compiler bug - replace vec_lvsl/vec_perm with vec_xl

2019-08-01 Thread ckerchne

On 2019-07-23 08:51, ckerchne wrote:

A bug exist with the gcc compilers for Power in versions 6.x and 7.x
(verified with 6.3 and 7.4). It was fixed in version 8.x (verified
with 8.3). I was using a Power 9 ppc64le machine for building and
testing.

It appears the compiler is generating the wrong code for little endian
machines for the vec_lvsl/vec_perm instruction combos in some cases.
If these instructions are replaced with vec_xl, the problem goes away
for all versions of the compilers.

---
 libswscale/ppc/yuv2rgb_altivec.c | 24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/libswscale/ppc/yuv2rgb_altivec.c 
b/libswscale/ppc/yuv2rgb_altivec.c

index c1e2852adb..536545293d 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -305,9 +305,6 @@ static int altivec_ ## name(SwsContext *c, const
unsigned char **in,  \
 vector signed short R1, G1, B1;
   \
 vector unsigned char R, G, B;  
   \

   \
-const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;   
   \
-vector unsigned char align_perm;   
   \
-   
   \
 vector signed short lCY   = c->CY; 
   \
 vector signed short lOY   = c->OY; 
   \
 vector signed short lCRV  = c->CRV;
   \

@@ -338,26 +335,13 @@ static int altivec_ ## name(SwsContext *c, const
unsigned char **in,  \
 vec_dstst(oute, (0x0202 | (((w * 3 + 32) / 32) << 16)), 
1);   \

   \
 for (j = 0; j < w / 16; j++) { 
   \
-y1ivP = (const vector unsigned char *) y1i;
   \
-y2ivP = (const vector unsigned char *) y2i;
   \
-uivP  = (const vector unsigned char *) ui; 
   \
-vivP  = (const vector unsigned char *) vi; 
   \
-   
   \
-align_perm = vec_lvsl(0, y1i); 
   \
-y0 = (vector unsigned char)
   \
- vec_perm(y1ivP[0], y1ivP[1], align_perm); 
   \
+y0 = vec_xl(0, y1i);   
   \

   \
-align_perm = vec_lvsl(0, y2i); 
   \
-y1 = (vector unsigned char)
   \
- vec_perm(y2ivP[0], y2ivP[1], align_perm); 
   \
+y1 = vec_xl(0, y2i);   
   \

   \
-align_perm = vec_lvsl(0, ui);  
   \
-u = (vector signed char)   
   \
-vec_perm(uivP[0], uivP[1], align_perm);
   \
+u = (vector signed char) vec_xl(0, ui);
   \

   \
-align_perm = vec_lvsl(0, vi);  
   \
-v = (vector signed char)   
   \
-vec_perm(vivP[0], vivP[1], align_perm);
   \
+v = (vector signed char) vec_xl(0, vi);
   \

   \
 u = (vector signed char)   
   \
 vec_sub(u, 
   \

--
2.17.1

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

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

Could someone please engage on this issue?  It's been almost 10 days.

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

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

Re: [FFmpeg-devel] [PATCH] FATE: add hls single file mode test case

2019-08-01 Thread Liu Steven


> 在 2019年7月30日,下午5:16,Steven Liu  写道:
> 
> Signed-off-by: Steven Liu 
> ---
> tests/fate/hlsenc.mak |  11 +
> tests/ref/fate/hls-segment-single | 772 ++
> 2 files changed, 783 insertions(+)
> create mode 100644 tests/ref/fate/hls-segment-single
> 
> diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
> index 98d67f96df..ff58094252 100644
> --- a/tests/fate/hlsenc.mak
> +++ b/tests/fate/hlsenc.mak
> @@ -52,6 +52,17 @@ FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER 
> MPEGTS_DEMUXER AEVALSRC_FIL
> fate-hls-segment-size: tests/data/hls_segment_size.m3u8
> fate-hls-segment-size: CMD = framecrc -flags +bitexact -i 
> $(TARGET_PATH)/tests/data/hls_segment_size.m3u8 -vf setpts=N*23
> 
> +tests/data/hls_segment_single.m3u8: TAG = GEN
> +tests/data/hls_segment_single.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
> + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
> + -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f hls 
> -hls_flags single_file -map 0 \
> + -hls_list_size 0 -codec:a mp2fixed -hls_segment_filename 
> $(TARGET_PATH)/tests/data/hls_segment_single.ts \
> + $(TARGET_PATH)/tests/data/hls_segment_single.m3u8 2>/dev/null
> +
> +FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
> AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-hls-segment-single
> +fate-hls-segment-single: tests/data/hls_segment_single.m3u8
> +fate-hls-segment-single: CMD = framecrc -flags +bitexact -i 
> $(TARGET_PATH)/tests/data/hls_segment_single.m3u8 -vf setpts=N*23
> +
> tests/data/hls_init_time.m3u8: TAG = GEN
> tests/data/hls_init_time.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
>   $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
> diff --git a/tests/ref/fate/hls-segment-single 
> b/tests/ref/fate/hls-segment-single
> new file mode 100644
> index 00..ee3c7b2c62
> --- /dev/null
> +++ b/tests/ref/fate/hls-segment-single
> @@ -0,0 +1,772 @@
> +#tb 0: 1/44100
> +#media_type 0: audio
> +#codec_id 0: pcm_s16le
> +#sample_rate 0: 44100
> +#channel_layout 0: 4
> +#channel_layout_name 0: mono
> +0,  0,  0, 1152, 2304, 0x907cb7fa
> +0,   1152,   1152, 1152, 2304, 0xb8dc7525
> +0,   2304,   2304, 1152, 2304, 0x3e7d6905
> +0,   3456,   3456, 1152, 2304, 0xef47877b
> +0,   4608,   4608, 1152, 2304, 0xfe916b7e
> +0,   5760,   5760, 1152, 2304, 0xe3d08cde
> +0,   6912,   6912, 1152, 2304, 0xff7f86cf
> +0,   8064,   8064, 1152, 2304, 0x843e6f95
> +0,   9216,   9216, 1152, 2304, 0x81577c26
> +0,  10368,  10368, 1152, 2304, 0x04a085d5
> +0,  11520,  11520, 1152, 2304, 0x1c5a76f5
> +0,  12672,  12672, 1152, 2304, 0x4ee78623
> +0,  13824,  13824, 1152, 2304, 0x8ec861dc
> +0,  14976,  14976, 1152, 2304, 0x0ca179d8
> +0,  16128,  16128, 1152, 2304, 0xc6da750f
> +0,  17280,  17280, 1152, 2304, 0xf6bf79b5
> +0,  18432,  18432, 1152, 2304, 0x97b88a43
> +0,  19584,  19584, 1152, 2304, 0xf13c7b9c
> +0,  20736,  20736, 1152, 2304, 0xdfba83af
> +0,  21888,  21888, 1152, 2304, 0xc9467d4b
> +0,  23040,  23040, 1152, 2304, 0xbbb58e2b
> +0,  24192,  24192, 1152, 2304, 0x3a1078ea
> +0,  25344,  25344, 1152, 2304, 0xe9587a5c
> +0,  26496,  26496, 1152, 2304, 0xef5a8039
> +0,  27648,  27648, 1152, 2304, 0x9d5f782f
> +0,  28800,  28800, 1152, 2304, 0x1a548291
> +0,  29952,  29952, 1152, 2304, 0x07517701
> +0,  31104,  31104, 1152, 2304, 0x78127d6e
> +0,  32256,  32256, 1152, 2304, 0x62e2788a
> +0,  33408,  33408, 1152, 2304, 0x29397ad9
> +0,  34560,  34560, 1152, 2304, 0x45da82d6
> +0,  35712,  35712, 1152, 2304, 0x8ed66e51
> +0,  36864,  36864, 1152, 2304, 0x660775cd
> +0,  38016,  38016, 1152, 2304, 0x802c767a
> +0,  39168,  39168, 1152, 2304, 0xcc055840
> +0,  40320,  40320, 1152, 2304, 0x701b7eaf
> +0,  41472,  41472, 1152, 2304, 0x8290749f
> +0,  42624,  42624, 1152, 2304, 0x2c7b7d30
> +0,  43776,  43776, 1152, 2304, 0xe4f17743
> +0,  44928,  44928, 1152, 2304, 0x0e747d6e
> +0,  46080,  46080, 1152, 2304, 0xbe7775a0
> +0,  47232,  47232, 1152, 2304, 0xcf797673
> +0,  48384,  48384, 1152, 2304, 0x29cb7800
> +0,  49536,  49536, 1152, 2304, 0xfc947890
> +0,  50688,  50688, 1152, 2304, 0x62757fc6
> +0,  51840,  51840, 1152, 2304, 0x098876d0
> +0,  52992,  52992, 1152, 2304, 0xa9567ee2
> +0,  54144,  54144,

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Paul B Mahol
Why test uses internal function, why was this allowed to be committed at
all?
Who is reviewing this mess?

Why test does not use normal filtergraph?

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

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

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v3]

2019-08-01 Thread Andreas Håkon
Hi Marton,

First of all, a new version [v4] is posted here:
https://patchwork.ffmpeg.org/patch/14121/

However, I'll comment on your suggestions, as they are reasonable.


‐‐‐ Original Message ‐‐‐
On Wednesday, 31 de July de 2019 23:58, Marton Balint  wrote:

> > +for (i = 0; i < ts->nb_services; i++) {
> > +service = ts->services[i];
> > +service->pcr_st = NULL;
> > +}
> > +
>
> This loop is not needed as far as I see. service is already initialized
> and service->pcr_st is zero initialized so you don't need to set it to
> NULL explicitly.

I prefer to initilize any variable. Futhermore, Andriy has commented to
do it inside the mpegts_add_service function. I prefer his approach.


> > +
> > +/* program service checks */
> > +program = av_find_program_from_stream(s, NULL, i);
> > +do {
> > +for (j = 0; j < ts->nb_services; j++) {
> > +if (program) {
> > +/* search for the services corresponding to this 
> > program */
> > +if (ts->services[j]->program == program)
> > +service = ts->services[j];
> > +else
> > +continue;
> > +}
> > +
> > +ts_st->service = service;
> > +
> > +/* check for PMT pid conflicts */
> > +if (ts_st->pid == service->pmt.pid) {
> > +av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> > ts_st->pid);
> > +ret = AVERROR(EINVAL);
> > +goto fail;
> > +}
> > +
> > +/* update PCR pid by using the first video stream */
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > +service->pcr_pid == 0x1fff) {
> > +service->pcr_pid = ts_st->pid;
> > +service->pcr_st  = st;
> > +}
> > +
> > +/* store this stream as a candidate PCR if the service 
> > doesn't have any */
> > +if (service->pcr_pid == 0x1fff &&
> > +!service->pcr_st) {
> > +service->pcr_st  = st;
> > +}
> > +
> > +/* exit when just one single service */
> > +if (!program)
> > +break;
> > +}
> > +program = program ? av_find_program_from_stream(s, program, i) 
> > : NULL;
> > +} while (program);
>
>
> Maybe I miss something but as far as I see only this block needs to be in
> the loop, the rest is not. So you can actually write this:
>

False! All checks require to be completed inside the loop.
Please, note that one stream (aka pid) can be assigned to multiple programs.
So we need to iterate over all programs and services.


> /* program service checks */
> program = av_find_program_from_stream(s, NULL, i);
> do {
> if (program) {
> for (j = 0; j < ts->nb_services; j++) {
>
>  if (ts->services[j]->program == program) {
>
>  service = ts->services[j];
>
>  break;
>  }
>  }
>  }
>
>
> ts_st->service = service;
>
> /* check for PMT pid conflicts */
> ...
>
> This way you also ensure that ts_st->service is always set for every
> stream which is kind of how the old code worked, right?

Not really. The "service" can be assigned on two ways: or using the iteration
over all programs, or in the creation of a new service with the call
to the "mpegts_add_service()" function when no programs are defined.


>
> > -
> > -  ts_st->service = service;
> >
> >
>
> You are setting this for all programs of the stream, so effectively the
> stream's service will be the last program (service) the stream is part of.
> Maybe you should aim for the first instead?

No. That's doesn't have sense. The objective of the code (old and new) is:

- Assign a pid for the PCR.
- Check for conflicts with the pid number.

To achieve this you need to compare with all PMTs. And futhermore, you need
to iterate over all services as the pid can be inside one or more of them.

And note this: the "ts_st->service = service" will be assigned to the
"last" service only when no programs are defined. So in this case only one
service exists, then first==last. In any other case (when one or programs
exist) any "ts_st->service = service" is assigned after the iteration over
the program list.

As a summary: the code is fine.


> > +
> > +/* check for PMT pid conflicts */
> > +if (ts_st->pid == service->pmt.pid) {
> > +av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> > ts_st->pid);
> > +ret = AVERROR(EINVAL);
> > +goto fail;
> > +}
> > +
> > +/* update PCR pid by using the first video stream */
> > +if 

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Nicolas George
Paul B Mahol (12019-08-01):
> I do not like this.

I agree. The av namespace is for public functions.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Paul B Mahol
I do not like this.

On Thu, Aug 1, 2019 at 8:22 AM Guo, Yejun  wrote:

> background:
> DNN (deep neural network) is a sub module of libavfilter, and FATE/dnn
> is unit test for the DNN module, one unit test for one dnn layer.
> The unit tests are not based on the APIs exported by libavfilter,
> they just directly call into the functions within DNN submodule.
> (It is not easy for the test to call libavfilter APIs to verify dnn
> layers.)
>
> There is an issue when run the following command:
> build$ ../ffmpeg/configure --disable-static --enable-shared
> make
> make fate-dnn-layer-pad
>
> And part of error message:
> tests/dnn/dnn-layer-pad-test.o: In function `test_with_mode_symmetric':
> /work/media/ffmpeg/build/src/tests/dnn/dnn-layer-pad-test.c:73: undefined
> reference to `dnn_execute_layer_pad'
>
> The root cause is that function dnn_execute_layer_pad is a LOCAL symbol
> in libavfilter.so, and so the linker could not find it when build
> dnn-layer-pad-test.
>
> To check it, just run: readelf -s libavfilter/libavfilter.so | grep dnn
>
> There are three possible mothods to fix this issue.
> 1). delete the dnn unit tests from FATE.
> I don't think it is a good choice.
>
> 2). ask people to build static library if he wants to use FATE.
>
> 3). export the dnn layer functions.
> And it is what this patch for.
>
> Besides the function rename to export from .so library, we also need
> to add option -Wl,-rpath to build the dnn unit tests, so the path is
> written into the test binary and help to find the .so libraries during
> execution.
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/dnn/dnn_backend_native.c   | 2 +-
>  libavfilter/dnn/dnn_backend_native_layer_pad.c | 2 +-
>  libavfilter/dnn/dnn_backend_native_layer_pad.h | 2 +-
>  tests/dnn/Makefile | 4 +++-
>  tests/dnn/dnn-layer-pad-test.c | 6 +++---
>  5 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/libavfilter/dnn/dnn_backend_native.c
> b/libavfilter/dnn/dnn_backend_native.c
> index 09c583b..fa412e0 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -377,7 +377,7 @@ DNNReturnType ff_dnn_execute_model_native(const
> DNNModel *model, DNNData *output
>  break;
>  case MIRROR_PAD:
>  pad_params = (LayerPadParams *)network->layers[layer].params;
> -dnn_execute_layer_pad(network->layers[layer - 1].output,
> network->layers[layer].output,
> +avfilter_dnn_execute_layer_pad(network->layers[layer -
> 1].output, network->layers[layer].output,
>pad_params, 1, cur_height, cur_width,
> cur_channels);
>  cur_height = cur_height + pad_params->paddings[1][0] +
> pad_params->paddings[1][1];
>  cur_width = cur_width + pad_params->paddings[2][0] +
> pad_params->paddings[2][1];
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c
> b/libavfilter/dnn/dnn_backend_native_layer_pad.c
> index 5417d73..526ddfe 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_pad.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c
> @@ -48,7 +48,7 @@ static int after_get_buddy(int given, int border,
> LayerPadModeParam mode)
>  }
>  }
>
> -void dnn_execute_layer_pad(const float *input, float *output, const
> LayerPadParams *params, int number, int height, int width, int channel)
> +void avfilter_dnn_execute_layer_pad(const float *input, float *output,
> const LayerPadParams *params, int number, int height, int width, int
> channel)
>  {
>  int32_t before_paddings;
>  int32_t after_paddings;
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.h
> b/libavfilter/dnn/dnn_backend_native_layer_pad.h
> index 0fbe652..3f93d6d 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_pad.h
> +++ b/libavfilter/dnn/dnn_backend_native_layer_pad.h
> @@ -35,6 +35,6 @@ typedef struct LayerPadParams{
>  float constant_values;
>  } LayerPadParams;
>
> -void dnn_execute_layer_pad(const float *input, float *output, const
> LayerPadParams *params, int number, int height, int width, int channel);
> +void avfilter_dnn_execute_layer_pad(const float *input, float *output,
> const LayerPadParams *params, int number, int height, int width, int
> channel);
>
>  #endif
> diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
> index b2e6680..a34f2e7 100644
> --- a/tests/dnn/Makefile
> +++ b/tests/dnn/Makefile
> @@ -4,8 +4,10 @@ DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%)
> $(DNNTESTPROGS:%=$(DNNTESTSDIR)
>  DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
>  -include $(wildcard $(DNNTESTOBJS:.o=.d))
>
> +LDDNNFLAGS =
> -Wl,-rpath=:libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
> +
>  $(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
> -   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^)
> $(FF_EXTRALIBS) $(ELIBS)
> +   $(LD) $(LDFLAGS) $(LDDNNFLAGS) 

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v4]

2019-08-01 Thread Andreas Håkon
Hi Andriy,


‐‐‐ Original Message ‐‐‐
On Thursday, 1 de August de 2019 0:23, Andriy Gelman  
wrote:

> > +for (i = 0; i < ts->nb_services; i++) {
> > +service = ts->services[i];
> > +service->pcr_st = NULL;
> > +}
> > +
>
> If you are going to add pcr_st to MpegTSService then it would make sense to 
> move the
> initialization to mpegts_add_service function.

Good idea!


> > +
> > +/* program service checks */
> > +program = av_find_program_from_stream(s, NULL, i);
> > +do {
> > +for (j = 0; j < ts->nb_services; j++) {
> > +if (program) {
> > +/* search for the services corresponding to this 
> > program */
> > +if (ts->services[j]->program == program)
> > +service = ts->services[j];
> > +else
> > +continue;
> > +}
> > +
> > +ts_st->service = service;
> > +
> > +/* check for PMT pid conflicts */
> > +if (ts_st->pid == service->pmt.pid) {
> > +av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> > ts_st->pid);
> > +ret = AVERROR(EINVAL);
> > +goto fail;
> > +}
> > +
> > +/* update PCR pid by using the first video stream */
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > +service->pcr_pid == 0x1fff) {
> > +service->pcr_pid = ts_st->pid;
> > +service->pcr_st  = st;
> > +}
> > +
> > +/* store this stream as a candidate PCR if the service 
> > doesn't have any */
> > +if (service->pcr_pid == 0x1fff &&
> > +!service->pcr_st) {
> > +service->pcr_st  = st;
> > +}
> > +
> > +/* exit when just one single service */
> > +if (!program)
> > +break;
> > +}
> > +program = program ? av_find_program_from_stream(s, program, i) 
> > : NULL;
> > +} while (program);
>
> This may be easier to digest if you separate the cases when
> s->nb_programs == 0 and s->nb_programs > 0. Maybe something like this could
> work:

Well, the code works, right?
So let me to comment some things previous to discuss your suggestion:

1. I prefer to leave the code close to the original one. If someone needs to do
   more changes, it's preferable to do small changes. Don't you think so?

2. The difference between "s->nb_programs == 0" and "s->nb_programs > 0" is 
because
   the old code. From my point of view, the special case when "s->nb_programs 
== 0"
   is a little sloppy. However, I need to consider it, so for this reason the 
code
   handles it.

> /*update service when no programs defined. use default service */
> if (s->nb_programs == 0) {
>
> ret = update_service_and_set_pcr(s, st, service);
> if (ret < 0)
> goto fail:
>
>
> }
>
> /*find program for i-th stream */
> program = av_find_program_from_stream(s, NULL, i);
> while (s->nb_programs > 0 && program) {
>
> /*find the service that this program belongs to */
> for (j = 0; j < ts->nb_services; j++) {
>
> if (ts->services[j]->program == program) {
>
> service = ts->services[j];
>
> break;
> }
> }
>

No, no! The loop requires to complete it for all services!
Every service requires a PCR, and the PCR can be inside a
shared stream. So if we break for the first service, then
other services will not be processed.
Please, see that the code is inside a loop and uses a continue
when the program doesn't match.

>
> ret = update_service_and_set_pcr(s, st, service);
> if (ret < 0)
> goto fail:
>
> /*find next program that this stream belongs to */
> program = av_find_program_from_stream(s, program, i);
> }
>
> /*we need to define the function update_service_and_set_pcr */
> static int update_service_and_set_pcr(AVFormatContext *s, AVStream *st, 
> MpegTSService *service)
> {
>
> MpegTSWriteStream *ts_st = st->priv_data;
>
> ts_st->service = service;
>
>
> /* check for PMT pid conflicts */
> if (ts_st->pid == service->pmt.pid) {
>
> av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\\n", ts_st->pid);
>
> return AVERROR(EINVAL);
> }
>
>
> /* update PCR pid by using the first video stream */
> if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
>
> service->pcr_pid == 0x1fff) {
>
> service->pcr_pid = ts_st->pid;
>
> service->pcr_st  = st;
>
> }
>
>
> /* store this stream as a candidate PCR if the service doesn't have any */
> if (service->pcr_pid == 0x1fff)
>
> service->pcr_st  = st;
>
>
> return 0;
> }

As commented before IMHO the code is more clear if we leave the service
checks here and not in a new function. When others update the code will
see that "all" 

[FFmpeg-devel] [PATCH] DSD and DST speed improvements

2019-08-01 Thread Paul B Mahol
Hi,

patches attached.

This time DSD decoding is approx %50 faster on old Celeron N3050 CPUs and 2
threads.


0001-avformat-dsfdec-set-packet-pts-duration-pos-correctl.patch
Description: Binary data


0002-avcodec-dsddec-add-slice-threading-support.patch
Description: Binary data


0003-avcodec-dstdec-add-slice-threading-support.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dsddec: add slice threading support

2019-08-01 Thread Paul B Mahol
On Thu, Aug 1, 2019 at 3:56 AM David Bryant  wrote:

>
> On 7/30/19 1:43 AM, Carl Eugen Hoyos wrote:
> > Am So., 28. Juli 2019 um 23:35 Uhr schrieb Paul B Mahol <
> one...@gmail.com>:
> >> Hi,
> >>
> >> patch attached.
> > As just posted on irc:
> > On an 8-core Intel cpu, this makes decoding slower by a factor two,
> > heating the cpu
> > ten times as much, on a multi-core powerpc, decoding is nearly two
> > times slower, and
> > heats nearly eight times as much.
>
> I can verify the greatly increased CPU load on a dual core system also. I
> also verified that the outputted audio data is correct
> (identical to unmodified code) and that there are no more samples being
> processed, indicating it's probably just threading overhead.
>
> The dsd2pcm conversion is pretty optimized and I suspect that's just way
> too fast to be worth multi-threading.
>

It appears it is not, see new patches.
As suspected using uint8s and unaligned bufer for stuff leads to big
slowdown when multi-threading.


>
> As I suggested earlier, it's the DST decompression that is worth looking
> into for threading.
>
> -David
>
>
> >
> > Carl Eugen
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

[Patch content]

This update removed the code line below:
+{ "flags", "+cgop" },

For the "forced_idr" parameter is controlling this, but not the 
AV_CODEC_FLAG_CLOSED_GOP flag. Thanks Li Zhong for catching it.

Regards,
Sun, Jing
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] Recall: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Sun, Jing A
Sun, Jing A would like to recall the message, "[PATCH v16 1/2] lavc/svt_hevc: 
add libsvt hevc encoder wrapper".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

[Patch content]

This update removed the code line below:
+{ "flags", "+cgop" },

For the "forced_idr" parameter is controlling this, but not the 
AV_CODEC_FLAG_CLOSED_GOP flag. Thanks Li Zhong for catching it.

Regards,
Sun, Jing


-Original Message-
From: Sun, Jing A 
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jun Zhao 
Signed-off-by: Jing Sun 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 500 +++
 libavcodec/version.h |   2 +-
 5 files changed, 507 insertions(+), 1 deletion(-)  create mode 100644 
libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 5a4f507..3a6cab7 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
+  --enable-libsvthevc  enable HEVC encoding via svt [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -1788,6 +1789,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3183,6 +3185,7 @@ libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
 libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
+libsvt_hevc_encoder_deps="libsvthevc"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
@@ -6230,6 +6233,7 @@ enabled libsoxr   && require libsoxr soxr.h 
soxr_create -lsoxr
 enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
sftp_init
 enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
speex_decoder_init
 enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
srt/srt.h srt_socket
+enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc EbApi.h 
EbInitHandle
 enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
TF_Version -ltensorflow
 enabled libtesseract  && require_pkg_config libtesseract tesseract 
tesseract/capi.h TessBaseAPICreate
 enabled libtheora && require libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cd73fb..d39f568 
100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -991,6 +991,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
libopus.o \
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 
d2f9a39..d8788a7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -707,6 +707,7 @@ extern AVCodec ff_librsvg_decoder;  extern AVCodec 
ff_libshine_encoder;  extern AVCodec ff_libspeex_encoder;  extern AVCodec 
ff_libspeex_decoder;
+extern AVCodec ff_libsvt_hevc_encoder;
 extern AVCodec ff_libtheora_encoder;
 extern AVCodec ff_libtwolame_encoder;
 extern AVCodec ff_libvo_amrwbenc_encoder; diff --git 
a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c new file mode 100644 
index 000..b0e21a36
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,500 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2019 Intel Corporation
+*
+* 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 

[FFmpeg-devel] [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Jing Sun
Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jun Zhao 
Signed-off-by: Jing Sun 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 500 +++
 libavcodec/version.h |   2 +-
 5 files changed, 507 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 5a4f507..3a6cab7 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
+  --enable-libsvthevc  enable HEVC encoding via svt [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -1788,6 +1789,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3183,6 +3185,7 @@ libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
 libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
+libsvt_hevc_encoder_deps="libsvthevc"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
@@ -6230,6 +6233,7 @@ enabled libsoxr   && require libsoxr soxr.h 
soxr_create -lsoxr
 enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
sftp_init
 enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
speex_decoder_init
 enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
srt/srt.h srt_socket
+enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc EbApi.h 
EbInitHandle
 enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
TF_Version -ltensorflow
 enabled libtesseract  && require_pkg_config libtesseract tesseract 
tesseract/capi.h TessBaseAPICreate
 enabled libtheora && require libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fb..d39f568 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -991,6 +991,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
libopus.o \
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39..d8788a7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -707,6 +707,7 @@ extern AVCodec ff_librsvg_decoder;
 extern AVCodec ff_libshine_encoder;
 extern AVCodec ff_libspeex_encoder;
 extern AVCodec ff_libspeex_decoder;
+extern AVCodec ff_libsvt_hevc_encoder;
 extern AVCodec ff_libtheora_encoder;
 extern AVCodec ff_libtwolame_encoder;
 extern AVCodec ff_libvo_amrwbenc_encoder;
diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
new file mode 100644
index 000..b0e21a36
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,500 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2019 Intel Corporation
+*
+* 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 this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "EbErrorCodes.h"
+#include "EbTime.h"
+#include "EbApi.h"
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/opt.h"
+
+#include "internal.h"
+#include "avcodec.h"
+
+typedef enum eos_status {
+EOS_NOT_REACHED = 0,
+EOS_SENT,
+EOS_RECEIVED
+}EOS_STATUS;
+
+typedef struct SvtContext {
+AVClass *class;
+
+EB_H265_ENC_CONFIGURATION enc_params;
+EB_COMPONENTTYPE *svt_handle;
+EB_BUFFERHEADERTYPE in_buf;
+EOS_STATUS eos_flag;

[FFmpeg-devel] [PATCH] dnn: rename function from dnn_execute_layer_pad to avfilter_dnn_execute_layer_pad

2019-08-01 Thread Guo, Yejun
background:
DNN (deep neural network) is a sub module of libavfilter, and FATE/dnn
is unit test for the DNN module, one unit test for one dnn layer.
The unit tests are not based on the APIs exported by libavfilter,
they just directly call into the functions within DNN submodule.
(It is not easy for the test to call libavfilter APIs to verify dnn layers.)

There is an issue when run the following command:
build$ ../ffmpeg/configure --disable-static --enable-shared
make
make fate-dnn-layer-pad

And part of error message:
tests/dnn/dnn-layer-pad-test.o: In function `test_with_mode_symmetric':
/work/media/ffmpeg/build/src/tests/dnn/dnn-layer-pad-test.c:73: undefined 
reference to `dnn_execute_layer_pad'

The root cause is that function dnn_execute_layer_pad is a LOCAL symbol
in libavfilter.so, and so the linker could not find it when build 
dnn-layer-pad-test.

To check it, just run: readelf -s libavfilter/libavfilter.so | grep dnn

There are three possible mothods to fix this issue.
1). delete the dnn unit tests from FATE.
I don't think it is a good choice.

2). ask people to build static library if he wants to use FATE.

3). export the dnn layer functions.
And it is what this patch for.

Besides the function rename to export from .so library, we also need
to add option -Wl,-rpath to build the dnn unit tests, so the path is
written into the test binary and help to find the .so libraries during 
execution.

Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c   | 2 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.c | 2 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.h | 2 +-
 tests/dnn/Makefile | 4 +++-
 tests/dnn/dnn-layer-pad-test.c | 6 +++---
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 09c583b..fa412e0 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -377,7 +377,7 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 break;
 case MIRROR_PAD:
 pad_params = (LayerPadParams *)network->layers[layer].params;
-dnn_execute_layer_pad(network->layers[layer - 1].output, 
network->layers[layer].output,
+avfilter_dnn_execute_layer_pad(network->layers[layer - 1].output, 
network->layers[layer].output,
   pad_params, 1, cur_height, cur_width, 
cur_channels);
 cur_height = cur_height + pad_params->paddings[1][0] + 
pad_params->paddings[1][1];
 cur_width = cur_width + pad_params->paddings[2][0] + 
pad_params->paddings[2][1];
diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c 
b/libavfilter/dnn/dnn_backend_native_layer_pad.c
index 5417d73..526ddfe 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_pad.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c
@@ -48,7 +48,7 @@ static int after_get_buddy(int given, int border, 
LayerPadModeParam mode)
 }
 }
 
-void dnn_execute_layer_pad(const float *input, float *output, const 
LayerPadParams *params, int number, int height, int width, int channel)
+void avfilter_dnn_execute_layer_pad(const float *input, float *output, const 
LayerPadParams *params, int number, int height, int width, int channel)
 {
 int32_t before_paddings;
 int32_t after_paddings;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.h 
b/libavfilter/dnn/dnn_backend_native_layer_pad.h
index 0fbe652..3f93d6d 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_pad.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_pad.h
@@ -35,6 +35,6 @@ typedef struct LayerPadParams{
 float constant_values;
 } LayerPadParams;
 
-void dnn_execute_layer_pad(const float *input, float *output, const 
LayerPadParams *params, int number, int height, int width, int channel);
+void avfilter_dnn_execute_layer_pad(const float *input, float *output, const 
LayerPadParams *params, int number, int height, int width, int channel);
 
 #endif
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index b2e6680..a34f2e7 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -4,8 +4,10 @@ DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)
 DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
 -include $(wildcard $(DNNTESTOBJS:.o=.d))
 
+LDDNNFLAGS = 
-Wl,-rpath=:libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
+
 $(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
-   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_EXTRALIBS) 
$(ELIBS)
+   $(LD) $(LDFLAGS) $(LDDNNFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) 
$(FF_EXTRALIBS) $(ELIBS)
 
 testclean::
$(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF))
diff --git a/tests/dnn/dnn-layer-pad-test.c b/tests/dnn/dnn-layer-pad-test.c
index 28a49eb..078a2f4 100644
---