Re: [FFmpeg-devel] [PATCH] avformat/hls: Set AVFMT_TS_DISCONT flag on HLS input format

2019-10-28 Thread Steven Liu


> 在 2019年10月29日,01:09,Dennis Mungai  写道:
> 
> On Mon, 28 Oct 2019 at 05:45, Steven Liu  wrote:
>> 
>> 
>> 
>>> 在 2019年10月28日,02:39,Philip Langdale  写道:
>>> 
>>> There have been many reports over the years about problems when
>>> taking an HLS stream as input to `ffmpeg` where there are timestamp
>>> discontinuities present. This is explicitly supported in the
>>> HLS spec (EXT-X-DISCONTINUITY) and often used for ad injection.
>>> 
>>> Various fixes and work-arounds have been proposed over the years,
>>> but one step that seems obvious, even if it's not a complete fix,
>>> is to mark the HLS input format as supporting discontinuities. This
>>> will prevent timestamp fixup logic in ffmpeg.c kicking in that ends
>>> up mangling the timestamps unnecessarily.
>>> 
>>> I've tested this out with an example provided by Joe Koberg early
>>> last year, and it is sufficient to allow `ffmpeg` to download and
>>> mux the stream correctly. Joe had briefly suggested that other
>>> situations can still be handled incorrectly, but this seems like
>>> a strict improvement.
>>> 
>>> Joe's example:
>>> 
>>> https://s3.amazonaws.com/playon-test-videos/discont_test_new/discont_test.m3u8
>>> ---
>>> libavformat/hls.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>>> index d7f4d5b442..ac151d5ca4 100644
>>> --- a/libavformat/hls.c
>>> +++ b/libavformat/hls.c
>>> @@ -2326,7 +2326,7 @@ AVInputFormat ff_hls_demuxer = {
>>>.long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
>>>.priv_class = _class,
>>>.priv_data_size = sizeof(HLSContext),
>>> -.flags  = AVFMT_NOGENSEARCH,
>>> +.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
>>>.read_probe = hls_probe,
>>>.read_header= hls_read_header,
>>>.read_packet= hls_read_packet,
>>> --
>>> 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”.
>> 
>> LGTM, whatever other more reasons, this can fix one of those problems.
>> 
>> Thanks
>> Steven
> 
> This patch actually fixes the occurence of DTS and PTS discontinuities
> I've been seeing with (some) HLS inputs that have discontinuities due
> to ad insertion(s). 10+ hours later without a single discontinuity.

Thanks Dennis, Will push this patch after 24hours if there have no objections.
> ___
> 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".

Thanks
Steven





___
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/mips: msa optimizations for vc1dsp

2019-10-28 Thread Shiyou Yin
>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of gxw
>Sent: Monday, October 21, 2019 3:57 PM
>To: ffmpeg-devel@ffmpeg.org
>Subject: [FFmpeg-devel] [PATCH v2] avcodec/mips: msa optimizations for vc1dsp
>
>Performance of WMV3 decoding has speed up from 3.66x to 5.23x tested on 3A4000.
>---
> libavcodec/mips/Makefile|   1 +
> libavcodec/mips/vc1dsp_init_mips.c  |  30 ++-
> libavcodec/mips/vc1dsp_mips.h   |  23 ++
> libavcodec/mips/vc1dsp_msa.c| 461 
> libavutil/mips/generic_macros_msa.h |   3 +
> 5 files changed, 514 insertions(+), 4 deletions(-)
> create mode 100644 libavcodec/mips/vc1dsp_msa.c
>
>diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile
>index c5b54d5..b4993f6 100644
>--- a/libavcodec/mips/Makefile
>+++ b/libavcodec/mips/Makefile
>@@ -89,3 +89,4 @@ MMI-OBJS-$(CONFIG_WMV2DSP)+= 
>mips/wmv2dsp_mmi.o
> MMI-OBJS-$(CONFIG_HEVC_DECODER)   += mips/hevcdsp_mmi.o
> MMI-OBJS-$(CONFIG_VP3DSP) += mips/vp3dsp_idct_mmi.o
> MMI-OBJS-$(CONFIG_VP9_DECODER)+= mips/vp9_mc_mmi.o
>+MSA-OBJS-$(CONFIG_VC1_DECODER)+= mips/vc1dsp_msa.o
>diff --git a/libavcodec/mips/vc1dsp_init_mips.c 
>b/libavcodec/mips/vc1dsp_init_mips.c
>index 4adc9e1..c0007ff 100644
>--- a/libavcodec/mips/vc1dsp_init_mips.c
>+++ b/libavcodec/mips/vc1dsp_init_mips.c
>@@ -23,6 +23,10 @@
> #include "vc1dsp_mips.h"
> #include "config.h"
>
>+#define FN_ASSIGN(OP, X, Y, INSN) \
>+dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = 
>ff_##OP##vc1_mspel_mc##X##Y##INSN; \
>+dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = 
>ff_##OP##vc1_mspel_mc##X##Y##_16##INSN
>+
> #if HAVE_MMI
> static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp)
> {
>@@ -49,10 +53,6 @@ static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp)
> dsp->vc1_v_loop_filter16 = ff_vc1_v_loop_filter16_mmi;
> dsp->vc1_h_loop_filter16 = ff_vc1_h_loop_filter16_mmi;
>
>-#define FN_ASSIGN(OP, X, Y, INSN) \
>-dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = 
>ff_##OP##vc1_mspel_mc##X##Y##INSN; \
>-dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = 
>ff_##OP##vc1_mspel_mc##X##Y##_16##INSN
>-
> FN_ASSIGN(put_, 0, 0, _mmi);
> FN_ASSIGN(put_, 0, 1, _mmi);
> FN_ASSIGN(put_, 0, 2, _mmi);
>@@ -100,9 +100,31 @@ static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp)
> }
> #endif /* HAVE_MMI */
>
>+#if HAVE_MSA
>+static av_cold void vc1dsp_init_msa(VC1DSPContext *dsp)
>+{
>+dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_msa;
>+dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_msa;
>+dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_msa;
>+
>+FN_ASSIGN(put_, 1, 1, _msa);
>+FN_ASSIGN(put_, 1, 2, _msa);
>+FN_ASSIGN(put_, 1, 3, _msa);
>+FN_ASSIGN(put_, 2, 1, _msa);
>+FN_ASSIGN(put_, 2, 2, _msa);
>+FN_ASSIGN(put_, 2, 3, _msa);
>+FN_ASSIGN(put_, 3, 1, _msa);
>+FN_ASSIGN(put_, 3, 2, _msa);
>+FN_ASSIGN(put_, 3, 3, _msa);
>+}
>+#endif /* HAVE_MSA */
>+
> av_cold void ff_vc1dsp_init_mips(VC1DSPContext *dsp)
> {
> #if HAVE_MMI
> vc1dsp_init_mmi(dsp);
> #endif /* HAVE_MMI */
>+#if HAVE_MSA
>+vc1dsp_init_msa(dsp);
>+#endif /* HAVE_MSA */
> }
>diff --git a/libavcodec/mips/vc1dsp_mips.h b/libavcodec/mips/vc1dsp_mips.h
>index 0db85fa..5f72e60 100644
>--- a/libavcodec/mips/vc1dsp_mips.h
>+++ b/libavcodec/mips/vc1dsp_mips.h
>@@ -191,4 +191,27 @@ void ff_avg_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* 
>align 8 */,
>   uint8_t *src /* align 1 */,
>   int stride, int h, int x, int y);
>
>+void ff_vc1_inv_trans_8x8_msa(int16_t block[64]);
>+void ff_vc1_inv_trans_8x4_msa(uint8_t *dest, ptrdiff_t linesize, int16_t 
>*block);
>+void ff_vc1_inv_trans_4x8_msa(uint8_t *dest, ptrdiff_t linesize, int16_t 
>*block);
>+
>+#define FF_PUT_VC1_MSPEL_MC_MSA(hmode, vmode) 
>\
>+void ff_put_vc1_mspel_mc ## hmode ## vmode ## _msa(uint8_t *dst,  
>\
>+  const uint8_t *src, 
>\
>+  ptrdiff_t stride, int rnd); 
>\
>+void ff_put_vc1_mspel_mc ## hmode ## vmode ## _16_msa(uint8_t *dst,   
>\
>+  const uint8_t *src, 
>\
>+  ptrdiff_t stride, int rnd);
>+
>+FF_PUT_VC1_MSPEL_MC_MSA(1, 1);
>+FF_PUT_VC1_MSPEL_MC_MSA(1, 2);
>+FF_PUT_VC1_MSPEL_MC_MSA(1, 3);
>+
>+FF_PUT_VC1_MSPEL_MC_MSA(2, 1);
>+FF_PUT_VC1_MSPEL_MC_MSA(2, 2);
>+FF_PUT_VC1_MSPEL_MC_MSA(2, 3);
>+
>+FF_PUT_VC1_MSPEL_MC_MSA(3, 1);
>+FF_PUT_VC1_MSPEL_MC_MSA(3, 2);
>+FF_PUT_VC1_MSPEL_MC_MSA(3, 3);
> #endif /* AVCODEC_MIPS_VC1DSP_MIPS_H */
>diff --git a/libavcodec/mips/vc1dsp_msa.c b/libavcodec/mips/vc1dsp_msa.c
>new file mode 100644
>index 000..6e588e8
>--- /dev/null
>+++ b/libavcodec/mips/vc1dsp_msa.c
>@@ -0,0 

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

2019-10-28 Thread Michael Niedermayer
On Mon, Oct 28, 2019 at 02:48:21PM +0100, Paul B Mahol wrote:
> The new API is more extensible and allows for custom layouts.
> More accurate information is exported, eg for decoders that do not
> set a channel layout, lavc will not make one up for them.
> 
> Deprecate the old API working with just uint64_t bitmasks.
> 
> Original commit by Anton Khirnov .
> Expanded and completed by Vittorio Giovara .
> Adapted for FFmpeg by Paul B Mahol .
> 
> Signed-off-by: Anton Khirnov 
> Signed-off-by: Vittorio Giovara 
> Signed-off-by: Paul B Mahol 
> ---
>  libavutil/channel_layout.c | 385 --
>  libavutil/channel_layout.h | 411 ++---
>  libavutil/version.h|   3 +
>  3 files changed, 709 insertions(+), 90 deletions(-)
> 
> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
> index 3bd5ee29b7..9112af32a6 100644
> --- a/libavutil/channel_layout.c
> +++ b/libavutil/channel_layout.c
[...]

./ffmpeg  -v 0 -layouts
looses the channel names 



[...]
> +void av_channel_layout_from_mask(AVChannelLayout *channel_layout,
> + uint64_t mask)
> +{
> +channel_layout->order   = AV_CHANNEL_ORDER_NATIVE;
> +channel_layout->nb_channels = av_popcount64(mask);

is this correct in relation to AV_CH_LAYOUT_NATIVE ?


> +channel_layout->u.mask  = mask;
> +}


[...]
> +/**
> + * Initialize a native channel layout from a bitmask indicating which 
> channels
> + * are present.
> + *
> + * @note channel_layout should be properly allocated as described above.
> + *
> + * @param channel_layout the layout structure to be initialized
> + * @param mask bitmask describing the channel layout
> + */
> +void av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t 
> mask);

This possibly should return a error code
for example a mask of 0 would not be valid

thx

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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] avfilter: add median filter

2019-10-28 Thread Paul B Mahol
Will apply slightly improved version soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/apedec: Only clear the needed buffer space, instead of all

2019-10-28 Thread Paul B Mahol
probably ok

On 10/28/19, Michael Niedermayer  wrote:
> Fixes: Timeout (15sec -> 0.4sec)
> Fixes:
> 18396/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5730080487112704
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/apedec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> index 75c6a96437..2dd197a7f2 100644
> --- a/libavcodec/apedec.c
> +++ b/libavcodec/apedec.c
> @@ -1516,7 +1516,7 @@ static int ape_decode_frame(AVCodecContext *avctx,
> void *data,
>  av_fast_malloc(>decoded_buffer, >decoded_size,
> decoded_buffer_size);
>  if (!s->decoded_buffer)
>  return AVERROR(ENOMEM);
> -memset(s->decoded_buffer, 0, s->decoded_size);
> +memset(s->decoded_buffer, 0, decoded_buffer_size);
>  s->decoded[0] = s->decoded_buffer;
>  s->decoded[1] = s->decoded_buffer + FFALIGN(blockstodecode, 8);
>
> --
> 2.23.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/wmalosslessdec: Fix some integer anomalies

2019-10-28 Thread Paul B Mahol
Trivial change, LGTM

On 10/28/19, Michael Niedermayer  wrote:
> Fixes: left shift of negative value -341180
> Fixes:
> 18401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-568638013440
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wmalosslessdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
> index 19bac949d4..d4f18b9841 100644
> --- a/libavcodec/wmalosslessdec.c
> +++ b/libavcodec/wmalosslessdec.c
> @@ -766,7 +766,7 @@ static void revert_cdlms ## bits (WmallDecodeCtx *s, int
> ch, \
>  for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
>  for (icoef = coef_begin; icoef < coef_end; icoef++) { \
>  int##bits##_t *prevvalues = (int##bits##_t
> *)s->cdlms[ch][ilms].lms_prevvalues; \
> -pred = 1 << (s->cdlms[ch][ilms].scaling - 1); \
> +pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \
>  residue = s->channel_residues[ch][icoef]; \
>  pred += s->dsp.scalarproduct_and_madd_int## bits
> (s->cdlms[ch][ilms].coefs, \
>  prevvalues +
> s->cdlms[ch][ilms].recent, \
> @@ -987,9 +987,9 @@ static int decode_subframe(WmallDecodeCtx *s)
>
>  for (j = 0; j < subframe_len; j++) {
>  if (s->bits_per_sample == 16) {
> -*s->samples_16[c]++ = (int16_t) s->channel_residues[c][j]
> << padding_zeroes;
> +*s->samples_16[c]++ = (int16_t) s->channel_residues[c][j] *
> (1 << padding_zeroes);
>  } else {
> -*s->samples_32[c]++ = s->channel_residues[c][j] <<
> (padding_zeroes + 8);
> +*s->samples_32[c]++ = s->channel_residues[c][j] * (256 <<
> padding_zeroes);
>  }
>  }
>  }
> --
> 2.23.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/adpcm: Fix invalid shifts in ADPCM DTK

2019-10-28 Thread Paul B Mahol
Trivial change, LGTM

On 10/28/19, Michael Niedermayer  wrote:
> Fixes: left shift of negative value -1
> Fixes:
> 18397/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_DTK_fuzzer-5675653487132672
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/adpcm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index a8e74522b3..53d8d0be6a 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -1723,7 +1723,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
> void *data,
>  else
>  sampledat = sign_extend(byte >> 4, 4);
>
> -sampledat = (((sampledat << 12) >> (header & 0xf)) <<
> 6) + prev;
> +sampledat = ((sampledat * (1 << 12)) >> (header & 0xf))
> * (1 << 6) + prev;
>  *samples++ = av_clip_int16(sampledat >> 6);
>  c->status[channel].sample2 =
> c->status[channel].sample1;
>  c->status[channel].sample1 = sampledat;
> --
> 2.23.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 3/3] avcodec/wmalosslessdec: Fix some integer anomalies

2019-10-28 Thread Michael Niedermayer
Fixes: left shift of negative value -341180
Fixes: 
18401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-568638013440

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

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 19bac949d4..d4f18b9841 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -766,7 +766,7 @@ static void revert_cdlms ## bits (WmallDecodeCtx *s, int 
ch, \
 for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
 for (icoef = coef_begin; icoef < coef_end; icoef++) { \
 int##bits##_t *prevvalues = (int##bits##_t 
*)s->cdlms[ch][ilms].lms_prevvalues; \
-pred = 1 << (s->cdlms[ch][ilms].scaling - 1); \
+pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \
 residue = s->channel_residues[ch][icoef]; \
 pred += s->dsp.scalarproduct_and_madd_int## bits 
(s->cdlms[ch][ilms].coefs, \
 prevvalues + 
s->cdlms[ch][ilms].recent, \
@@ -987,9 +987,9 @@ static int decode_subframe(WmallDecodeCtx *s)
 
 for (j = 0; j < subframe_len; j++) {
 if (s->bits_per_sample == 16) {
-*s->samples_16[c]++ = (int16_t) s->channel_residues[c][j] << 
padding_zeroes;
+*s->samples_16[c]++ = (int16_t) s->channel_residues[c][j] * (1 
<< padding_zeroes);
 } else {
-*s->samples_32[c]++ = s->channel_residues[c][j] << 
(padding_zeroes + 8);
+*s->samples_32[c]++ = s->channel_residues[c][j] * (256 << 
padding_zeroes);
 }
 }
 }
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 1/3] avcodec/apedec: Only clear the needed buffer space, instead of all

2019-10-28 Thread Michael Niedermayer
Fixes: Timeout (15sec -> 0.4sec)
Fixes: 
18396/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5730080487112704

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 75c6a96437..2dd197a7f2 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1516,7 +1516,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void 
*data,
 av_fast_malloc(>decoded_buffer, >decoded_size, decoded_buffer_size);
 if (!s->decoded_buffer)
 return AVERROR(ENOMEM);
-memset(s->decoded_buffer, 0, s->decoded_size);
+memset(s->decoded_buffer, 0, decoded_buffer_size);
 s->decoded[0] = s->decoded_buffer;
 s->decoded[1] = s->decoded_buffer + FFALIGN(blockstodecode, 8);
 
-- 
2.23.0

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

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

[FFmpeg-devel] [PATCH 2/3] avcodec/adpcm: Fix invalid shifts in ADPCM DTK

2019-10-28 Thread Michael Niedermayer
Fixes: left shift of negative value -1
Fixes: 
18397/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_DTK_fuzzer-5675653487132672

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

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index a8e74522b3..53d8d0be6a 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -1723,7 +1723,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void 
*data,
 else
 sampledat = sign_extend(byte >> 4, 4);
 
-sampledat = (((sampledat << 12) >> (header & 0xf)) << 6) + 
prev;
+sampledat = ((sampledat * (1 << 12)) >> (header & 0xf)) * 
(1 << 6) + prev;
 *samples++ = av_clip_int16(sampledat >> 6);
 c->status[channel].sample2 = c->status[channel].sample1;
 c->status[channel].sample1 = sampledat;
-- 
2.23.0

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

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

Re: [FFmpeg-devel] [PATCH] avformat/hls: Set AVFMT_TS_DISCONT flag on HLS input format

2019-10-28 Thread Dennis Mungai
On Mon, 28 Oct 2019 at 05:45, Steven Liu  wrote:
>
>
>
> > 在 2019年10月28日,02:39,Philip Langdale  写道:
> >
> > There have been many reports over the years about problems when
> > taking an HLS stream as input to `ffmpeg` where there are timestamp
> > discontinuities present. This is explicitly supported in the
> > HLS spec (EXT-X-DISCONTINUITY) and often used for ad injection.
> >
> > Various fixes and work-arounds have been proposed over the years,
> > but one step that seems obvious, even if it's not a complete fix,
> > is to mark the HLS input format as supporting discontinuities. This
> > will prevent timestamp fixup logic in ffmpeg.c kicking in that ends
> > up mangling the timestamps unnecessarily.
> >
> > I've tested this out with an example provided by Joe Koberg early
> > last year, and it is sufficient to allow `ffmpeg` to download and
> > mux the stream correctly. Joe had briefly suggested that other
> > situations can still be handled incorrectly, but this seems like
> > a strict improvement.
> >
> > Joe's example:
> >
> > https://s3.amazonaws.com/playon-test-videos/discont_test_new/discont_test.m3u8
> > ---
> > libavformat/hls.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > index d7f4d5b442..ac151d5ca4 100644
> > --- a/libavformat/hls.c
> > +++ b/libavformat/hls.c
> > @@ -2326,7 +2326,7 @@ AVInputFormat ff_hls_demuxer = {
> > .long_name  = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
> > .priv_class = _class,
> > .priv_data_size = sizeof(HLSContext),
> > -.flags  = AVFMT_NOGENSEARCH,
> > +.flags  = AVFMT_NOGENSEARCH | AVFMT_TS_DISCONT,
> > .read_probe = hls_probe,
> > .read_header= hls_read_header,
> > .read_packet= hls_read_packet,
> > --
> > 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”.
>
> LGTM, whatever other more reasons, this can fix one of those problems.
>
> Thanks
> Steven

This patch actually fixes the occurence of DTS and PTS discontinuities
I've been seeing with (some) HLS inputs that have discontinuities due
to ad insertion(s). 10+ hours later without a single discontinuity.
___
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] avfilter: remove unused private field of AVFilterLink

2019-10-28 Thread Zhao Zhili


> On Oct 28, 2019, at 9:15 PM, Moritz Barsnick  wrote:
> 
> On Mon, Oct 28, 2019 at 14:09:53 +0100, Moritz Barsnick wrote:
>>> -unsigned flags;
>> 
>> Since this is a public header, this is part of the API and cannot be
>> removed without a deprecation period.
> 
> Sorry, I missed that it says "Applications must not normally access the
> link structure directly."

Actually, I take the following comments as reference, it dating back to 2012

/*
 * All fields below this line are not part of the public API. They
 * may not be used outside of libavfilter and can be changed and
 * removed at will.
 * New public fields should be added right above.
 *
 */

> 
> Forget my comment, and sorry for the noise.
> 
> Moritz
> ___
> 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] Add a new channel layout API

2019-10-28 Thread Paul B Mahol
The new API is more extensible and allows for custom layouts.
More accurate information is exported, eg for decoders that do not
set a channel layout, lavc will not make one up for them.

Deprecate the old API working with just uint64_t bitmasks.

Original commit by Anton Khirnov .
Expanded and completed by Vittorio Giovara .
Adapted for FFmpeg by Paul B Mahol .

Signed-off-by: Anton Khirnov 
Signed-off-by: Vittorio Giovara 
Signed-off-by: Paul B Mahol 
---
 libavutil/channel_layout.c | 385 --
 libavutil/channel_layout.h | 411 ++---
 libavutil/version.h|   3 +
 3 files changed, 709 insertions(+), 90 deletions(-)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 3bd5ee29b7..9112af32a6 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -37,75 +37,87 @@ struct channel_name {
 };
 
 static const struct channel_name channel_names[] = {
- [0] = { "FL","front left"},
- [1] = { "FR","front right"   },
- [2] = { "FC","front center"  },
- [3] = { "LFE",   "low frequency" },
- [4] = { "BL","back left" },
- [5] = { "BR","back right"},
- [6] = { "FLC",   "front left-of-center"  },
- [7] = { "FRC",   "front right-of-center" },
- [8] = { "BC","back center"   },
- [9] = { "SL","side left" },
-[10] = { "SR","side right"},
-[11] = { "TC","top center"},
-[12] = { "TFL",   "top front left"},
-[13] = { "TFC",   "top front center"  },
-[14] = { "TFR",   "top front right"   },
-[15] = { "TBL",   "top back left" },
-[16] = { "TBC",   "top back center"   },
-[17] = { "TBR",   "top back right"},
-[29] = { "DL","downmix left"  },
-[30] = { "DR","downmix right" },
-[31] = { "WL","wide left" },
-[32] = { "WR","wide right"},
-[33] = { "SDL",   "surround direct left"  },
-[34] = { "SDR",   "surround direct right" },
-[35] = { "LFE2",  "low frequency 2"   },
+[AV_CHAN_FRONT_LEFT  ] = { "FL" },
+[AV_CHAN_FRONT_RIGHT ] = { "FR" },
+[AV_CHAN_FRONT_CENTER] = { "FC" },
+[AV_CHAN_LOW_FREQUENCY   ] = { "LFE" },
+[AV_CHAN_BACK_LEFT   ] = { "BL" },
+[AV_CHAN_BACK_RIGHT  ] = { "BR" },
+[AV_CHAN_FRONT_LEFT_OF_CENTER] = { "FLC" },
+[AV_CHAN_FRONT_RIGHT_OF_CENTER   ] = { "FRC" },
+[AV_CHAN_BACK_CENTER ] = { "BC" },
+[AV_CHAN_SIDE_LEFT   ] = { "SL" },
+[AV_CHAN_SIDE_RIGHT  ] = { "SR" },
+[AV_CHAN_TOP_CENTER  ] = { "TC" },
+[AV_CHAN_TOP_FRONT_LEFT  ] = { "TFL" },
+[AV_CHAN_TOP_FRONT_CENTER] = { "TFC" },
+[AV_CHAN_TOP_FRONT_RIGHT ] = { "TFR" },
+[AV_CHAN_TOP_BACK_LEFT   ] = { "TBL" },
+[AV_CHAN_TOP_BACK_CENTER ] = { "TBC" },
+[AV_CHAN_TOP_BACK_RIGHT  ] = { "TBR" },
+[AV_CHAN_STEREO_LEFT ] = { "DL" },
+[AV_CHAN_STEREO_RIGHT] = { "DR" },
+[AV_CHAN_WIDE_LEFT   ] = { "WL" },
+[AV_CHAN_WIDE_RIGHT  ] = { "WR" },
+[AV_CHAN_SURROUND_DIRECT_LEFT] = { "SDL" },
+[AV_CHAN_SURROUND_DIRECT_RIGHT   ] = { "SDR" },
+[AV_CHAN_LOW_FREQUENCY_2 ] = { "LFE2" },
+[AV_CHAN_SILENCE ] = { "PAD" },
 };
 
-static const char *get_channel_name(int channel_id)
+const char *av_channel_name(enum AVChannel channel_id)
 {
 if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
 return NULL;
 return channel_names[channel_id].name;
 }
 
+int av_channel_from_string(const char *str)
+{
+for (int i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) {
+if (channel_names[i].name && !strcmp(str, channel_names[i].name)) {
+return i;
+}
+}
+return AVERROR(EINVAL);
+}
+
 static const struct {
 const char *name;
-int nb_channels;
-uint64_t layout;
+AVChannelLayout layout;
 } channel_layout_map[] = {
-{ "mono",1,  AV_CH_LAYOUT_MONO },
-{ "stereo",  2,  AV_CH_LAYOUT_STEREO },
-{ "2.1", 3,  AV_CH_LAYOUT_2POINT1 },
-{ "3.0", 3,  AV_CH_LAYOUT_SURROUND },
-{ "3.0(back)",   3,  AV_CH_LAYOUT_2_1 },
-{ "4.0", 4,  AV_CH_LAYOUT_4POINT0 },
-{ "quad",4,  AV_CH_LAYOUT_QUAD },
-{ "quad(side)",  4,  AV_CH_LAYOUT_2_2 },
-{ "3.1", 4,  AV_CH_LAYOUT_3POINT1 },
-{ "5.0", 5,  AV_CH_LAYOUT_5POINT0_BACK },
-{ "5.0(side)",   5,  AV_CH_LAYOUT_5POINT0 },
-{ "4.1", 5,  AV_CH_LAYOUT_4POINT1 },
-{ "5.1", 6,  

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

2019-10-28 Thread Paul B Mahol
On 10/28/19, Moritz Barsnick  wrote:
> On Sat, Oct 26, 2019 at 21:44:02 +0200, Paul B Mahol wrote:
>> +Pick median pixel from certain rectangle defined by radius.
>
> Is radius the correct term within a rectangle? (Just wondering, I do
> understand the intent.)
>
>> +memset(coarse, 0, sizeof(coarse));
>> +memset(fine, 0, sizeof(fine));
>> +memset(luc, 0, sizeof(luc));
>
> Shouldn't this be
> memset(arrayptr, 0, sizeof(*arrayptr));

They are on stack and and locally changed to use memset but
initialization instead.

> ?
>
>> +MedianContext *s = ctx->priv;
>> +
>> +for (int i = 0; i < s->nb_threads && s->coarse && s->fine; i++) {
>> +av_freep(>coarse[i]);
>> +av_freep(>fine[i]);
>> +}
>
> s->coarse and s->fine are constant in this scope. Instead of checking
> them on each iteration, you could just exit early of they are (or
> either is) NULL. Not that performance matters here at all.
>
> I don't understand the rest functionally, looks fine to me.
>
> Cheers,
> Moritz
> ___
> 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] avfilter: add median filter

2019-10-28 Thread Paul B Mahol
On 10/28/19, Moritz Barsnick  wrote:
> On Sat, Oct 26, 2019 at 21:44:02 +0200, Paul B Mahol wrote:
>> +Pick median pixel from certain rectangle defined by radius.
>
> Is radius the correct term within a rectangle? (Just wondering, I do
> understand the intent.)

Correct term.

>
>> +memset(coarse, 0, sizeof(coarse));
>> +memset(fine, 0, sizeof(fine));
>> +memset(luc, 0, sizeof(luc));
>
> Shouldn't this be
> memset(arrayptr, 0, sizeof(*arrayptr));
> ?
>
>> +MedianContext *s = ctx->priv;
>> +
>> +for (int i = 0; i < s->nb_threads && s->coarse && s->fine; i++) {
>> +av_freep(>coarse[i]);
>> +av_freep(>fine[i]);
>> +}
>
> s->coarse and s->fine are constant in this scope. Instead of checking
> them on each iteration, you could just exit early of they are (or
> either is) NULL. Not that performance matters here at all.
>
> I don't understand the rest functionally, looks fine to me.
>
> Cheers,
> Moritz
> ___
> 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] avfilter/vf_sr: correct flags since the filter changes frame w/h

2019-10-28 Thread Paul B Mahol
LGTM

On 10/28/19, Guo, Yejun  wrote:
> If filter changes frame w/h, AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
> cannot be supported.
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/vf_sr.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
> index 0433246..b90643c 100644
> --- a/libavfilter/vf_sr.c
> +++ b/libavfilter/vf_sr.c
> @@ -317,5 +317,4 @@ AVFilter ff_vf_sr = {
>  .inputs= sr_inputs,
>  .outputs   = sr_outputs,
>  .priv_class= _class,
> -.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
>  };
> --
> 2.7.4
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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] avfilter/vf_sr: correct flags since the filter changes frame w/h

2019-10-28 Thread Guo, Yejun
If filter changes frame w/h, AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
cannot be supported.

Signed-off-by: Guo, Yejun 
---
 libavfilter/vf_sr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 0433246..b90643c 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -317,5 +317,4 @@ AVFilter ff_vf_sr = {
 .inputs= sr_inputs,
 .outputs   = sr_outputs,
 .priv_class= _class,
-.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
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] avfilter: remove unused private field of AVFilterLink

2019-10-28 Thread Moritz Barsnick
On Mon, Oct 28, 2019 at 14:09:53 +0100, Moritz Barsnick wrote:
> > -unsigned flags;
>
> Since this is a public header, this is part of the API and cannot be
> removed without a deprecation period.

Sorry, I missed that it says "Applications must not normally access the
link structure directly."

Forget my comment, and sorry for the noise.

Moritz
___
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] avfilter: add median filter

2019-10-28 Thread Moritz Barsnick
On Sat, Oct 26, 2019 at 21:44:02 +0200, Paul B Mahol wrote:
> +Pick median pixel from certain rectangle defined by radius.

Is radius the correct term within a rectangle? (Just wondering, I do
understand the intent.)

> +memset(coarse, 0, sizeof(coarse));
> +memset(fine, 0, sizeof(fine));
> +memset(luc, 0, sizeof(luc));

Shouldn't this be
memset(arrayptr, 0, sizeof(*arrayptr));
?

> +MedianContext *s = ctx->priv;
> +
> +for (int i = 0; i < s->nb_threads && s->coarse && s->fine; i++) {
> +av_freep(>coarse[i]);
> +av_freep(>fine[i]);
> +}

s->coarse and s->fine are constant in this scope. Instead of checking
them on each iteration, you could just exit early of they are (or
either is) NULL. Not that performance matters here at all.

I don't understand the rest functionally, looks fine to me.

Cheers,
Moritz
___
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] avfilter: remove unused private field of AVFilterLink

2019-10-28 Thread Moritz Barsnick
On Fri, Oct 18, 2019 at 14:36:31 +0800, quinkbl...@foxmail.com wrote:
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index 3eaa8a4089..3c87f4864a 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -572,11 +572,6 @@ struct AVFilterLink {
>   */
>  int channels;
>
> -/**
> - * Link processing flags.
> - */
> -unsigned flags;
> -

Since this is a public header, this is part of the API and cannot be
removed without a deprecation period.

Moritz
___
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 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Guo, Yejun


> -Original Message-
> From: Paul B Mahol [mailto:one...@gmail.com]
> Sent: Monday, October 28, 2019 8:01 PM
> To: Guo, Yejun 
> Cc: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add a
> generic filter for image proccessing with dnn networks
> 
> On 10/28/19, Paul B Mahol  wrote:
> > On 10/28/19, Guo, Yejun  wrote:
> >>
> >>
> >>> -Original Message-
> >>> From: Paul B Mahol [mailto:one...@gmail.com]
> >>> Sent: Monday, October 28, 2019 4:00 PM
> >>> To: FFmpeg development discussions and patches
> 
> >>> Cc: Guo, Yejun 
> >>> Subject: Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing:
> >>> add
> >>> a
> >>> generic filter for image proccessing with dnn networks
> >>>
> >>> On 10/21/19, Guo, Yejun  wrote:
> >>> > This filter accepts all the dnn networks which do image processing.
> >>> > Currently, frame with formats rgb24 and bgr24 are supported. Other
> >>> > formats such as gray and YUV will be supported next. The dnn network
> >>> > can accept data in float32 or uint8 format. And the dnn network can
...
> >>> > +
> >>> > +typedef struct DnnProcessingContext {
> >>> > +const AVClass *class;
> >>> > +
> >>> > +char *model_filename;
> >>> > +DNNBackendType backend_type;
> >>> > +enum AVPixelFormat fmt;
> >>>
> >>> This should be int.
> >>
> >> could you please help to explain a bit more why 'enum AVPixelFormat'
> >> should
> >> be int.
> >>
> >> I searched 'AV_OPT_TYPE_PIXEL_FMT' in vf_* files and found 'enum
> >> AVPixelFormat' is used in
> >> vf_mergeplanes.c, vf_program_opencl.c and vf_tonemap_opencl.c.
> >
> > That is error, I gonna fix mergeplanes ASAP. Sometimes enum may use
> > completely another type, Michael may know more.
> > Besides options assumes ints and not enums.
> 
> Actually they take also enums, so it should be safe. So ignore this one. 
> Sorry.

got it, no problem, thanks.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] tools/probetest: replace the deprecated API

2019-10-28 Thread Moritz Barsnick
On Sat, Oct 26, 2019 at 22:18:32 +0800, zhongli_...@126.com wrote:
>  AVInputFormat *fmt = NULL;
> +void *fmt_opaque = NULL;
>
> -while ((fmt = av_iformat_next(fmt))) {
> +while ((fmt = av_demuxer_iterate(_opaque))) {

Doesn't this give you (new) warnings? fmt needs to be const now:
const AVInputFormat *fmt = NULL;
as far as I can tell.

icc should give you:
warning #2332: a value of type "const AVInputFormat *" cannot be assigned to an 
entity of type "AVInputFormat *" (dropping qualifiers)

Cheers,
Moritz
___
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 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Paul B Mahol
On 10/28/19, Paul B Mahol  wrote:
> On 10/28/19, Guo, Yejun  wrote:
>>
>>
>>> -Original Message-
>>> From: Paul B Mahol [mailto:one...@gmail.com]
>>> Sent: Monday, October 28, 2019 4:00 PM
>>> To: FFmpeg development discussions and patches 
>>> Cc: Guo, Yejun 
>>> Subject: Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing:
>>> add
>>> a
>>> generic filter for image proccessing with dnn networks
>>>
>>> On 10/21/19, Guo, Yejun  wrote:
>>> > This filter accepts all the dnn networks which do image processing.
>>> > Currently, frame with formats rgb24 and bgr24 are supported. Other
>>> > formats such as gray and YUV will be supported next. The dnn network
>>> > can accept data in float32 or uint8 format. And the dnn network can
>>> > change frame size.
>>> >
>>> > Let's take an example with the following python script. This script
>>> > halves the value of the first channel of the pixel.
>>> > import tensorflow as tf
>>> > import numpy as np
>>> > import scipy.misc
>>> > in_img = scipy.misc.imread('in.bmp')
>>> > in_img = in_img.astype(np.float32)/255.0
>>> > in_data = in_img[np.newaxis, :]
>>> > filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0,
>>> > 1.]).reshape(1,1,3,3).astype(np.float32)
>>> > filter = tf.Variable(filter_data)
>>> > x = tf.placeholder(tf.float32, shape=[1, None, None, 3],
>>> > name='dnn_in')
>>> > y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID',
>>> > name='dnn_out')
>>> > sess=tf.Session()
>>> > sess.run(tf.global_variables_initializer())
>>> > output = sess.run(y, feed_dict={x: in_data})
>>> > graph_def = tf.graph_util.convert_variables_to_constants(sess,
>>> > sess.graph_def, ['dnn_out'])
>>> > tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb',
>>> > as_text=False)
>>> > output = output * 255.0
>>> > output = output.astype(np.uint8)
>>> > scipy.misc.imsave("out.bmp", np.squeeze(output))
>>>
>>> So this one executes python code without ever returning or using
>>> AVFrame*
>>> ?
>>> This is extremely limited usage.
>>
>> the purpose of this script is to demo how to setup and execute dnn models
>> with python+tensorflow.
>> The only relationship with ffmpeg is that the script prepares the model
>> file
>> halve_first_channel.pb.
>>
>> The next description shows how ffmpeg can execute the model in a filter.
>>
>> I'll try to update the commit log to avoid misleading words, thanks.
>>
>>>
>>> >
>>> > - generate halve_first_channel.pb with the above script
>>> > - generate halve_first_channel.model with tools/python/convert.py
>>> > - try with following commands
>>> >   ./ffmpeg -i input.jpg -vf
>>> >
>>> dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_
>>> out:fmt=rgb24:dnn_backend=native
>>> > -y out.native.png
>>> >   ./ffmpeg -i input.jpg -vf
>>> >
>>> dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:f
>>> mt=rgb24:dnn_backend=tensorflow
>>> > -y out.tf.png
>>> >
>>> > Signed-off-by: Guo, Yejun 
>>> > ---
>>> >  configure   |   1 +
>>> >  doc/filters.texi|  44 ++
>>> >  libavfilter/Makefile|   1 +
>>> >  libavfilter/allfilters.c|   1 +
>>> >  libavfilter/vf_dnn_processing.c | 333
>>> > 
>>> >  5 files changed, 380 insertions(+)
>>> >  create mode 100644 libavfilter/vf_dnn_processing.c
>>> >
>>> > diff --git a/configure b/configure
>>> > index 8413826..bf2bac9 100755
>>> > --- a/configure
>>> > +++ b/configure
>>> > @@ -3460,6 +3460,7 @@ derain_filter_select="dnn"
>>> >  deshake_filter_select="pixelutils"
>>> >  deshake_opencl_filter_deps="opencl"
>>> >  dilation_opencl_filter_deps="opencl"
>>> > +dnn_processing_filter_select="dnn"
>>> >  drawtext_filter_deps="libfreetype"
>>> >  drawtext_filter_suggest="libfontconfig libfribidi"
>>> >  elbg_filter_deps="avcodec"
>>> > diff --git a/doc/filters.texi b/doc/filters.texi
>>> > index bdc4136..c11a616 100644
>>> > --- a/doc/filters.texi
>>> > +++ b/doc/filters.texi
>>> > @@ -8928,6 +8928,50 @@ ffmpeg -i INPUT -f lavfi -i
>>> > nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
>>> >  @end example
>>> >  @end itemize
>>> >
>>> > +@section dnn_processing
>>> > +
>>> > +Do image processing with deep neural networks. Currently only AVFrame
>>> with
>>> > RGB24
>>> > +and BGR24 are supported, more formats will be added later.
>>> > +
>>> > +The filter accepts the following options:
>>> > +
>>> > +@table @option
>>> > +@item dnn_backend
>>> > +Specify which DNN backend to use for model loading and execution.
>>> > This
>>> > option accepts
>>> > +the following values:
>>> > +
>>> > +@table @samp
>>> > +@item native
>>> > +Native implementation of DNN loading and execution.
>>> > +
>>> > +@item tensorflow
>>> > +TensorFlow backend. To enable this backend you
>>> > +need to install the TensorFlow for C library (see
>>> > +@url{https://www.tensorflow.org/install/install_c}) and configure
>>> > FFmpeg
>>> > with
>>> > +@code{--enable-libtensorflow}
>>> > 

Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Paul B Mahol
On 10/28/19, Guo, Yejun  wrote:
>
>
>> -Original Message-
>> From: Paul B Mahol [mailto:one...@gmail.com]
>> Sent: Monday, October 28, 2019 4:00 PM
>> To: FFmpeg development discussions and patches 
>> Cc: Guo, Yejun 
>> Subject: Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add
>> a
>> generic filter for image proccessing with dnn networks
>>
>> On 10/21/19, Guo, Yejun  wrote:
>> > This filter accepts all the dnn networks which do image processing.
>> > Currently, frame with formats rgb24 and bgr24 are supported. Other
>> > formats such as gray and YUV will be supported next. The dnn network
>> > can accept data in float32 or uint8 format. And the dnn network can
>> > change frame size.
>> >
>> > Let's take an example with the following python script. This script
>> > halves the value of the first channel of the pixel.
>> > import tensorflow as tf
>> > import numpy as np
>> > import scipy.misc
>> > in_img = scipy.misc.imread('in.bmp')
>> > in_img = in_img.astype(np.float32)/255.0
>> > in_data = in_img[np.newaxis, :]
>> > filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0,
>> > 1.]).reshape(1,1,3,3).astype(np.float32)
>> > filter = tf.Variable(filter_data)
>> > x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
>> > y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID',
>> > name='dnn_out')
>> > sess=tf.Session()
>> > sess.run(tf.global_variables_initializer())
>> > output = sess.run(y, feed_dict={x: in_data})
>> > graph_def = tf.graph_util.convert_variables_to_constants(sess,
>> > sess.graph_def, ['dnn_out'])
>> > tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb',
>> > as_text=False)
>> > output = output * 255.0
>> > output = output.astype(np.uint8)
>> > scipy.misc.imsave("out.bmp", np.squeeze(output))
>>
>> So this one executes python code without ever returning or using AVFrame*
>> ?
>> This is extremely limited usage.
>
> the purpose of this script is to demo how to setup and execute dnn models
> with python+tensorflow.
> The only relationship with ffmpeg is that the script prepares the model file
> halve_first_channel.pb.
>
> The next description shows how ffmpeg can execute the model in a filter.
>
> I'll try to update the commit log to avoid misleading words, thanks.
>
>>
>> >
>> > - generate halve_first_channel.pb with the above script
>> > - generate halve_first_channel.model with tools/python/convert.py
>> > - try with following commands
>> >   ./ffmpeg -i input.jpg -vf
>> >
>> dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_
>> out:fmt=rgb24:dnn_backend=native
>> > -y out.native.png
>> >   ./ffmpeg -i input.jpg -vf
>> >
>> dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:f
>> mt=rgb24:dnn_backend=tensorflow
>> > -y out.tf.png
>> >
>> > Signed-off-by: Guo, Yejun 
>> > ---
>> >  configure   |   1 +
>> >  doc/filters.texi|  44 ++
>> >  libavfilter/Makefile|   1 +
>> >  libavfilter/allfilters.c|   1 +
>> >  libavfilter/vf_dnn_processing.c | 333
>> > 
>> >  5 files changed, 380 insertions(+)
>> >  create mode 100644 libavfilter/vf_dnn_processing.c
>> >
>> > diff --git a/configure b/configure
>> > index 8413826..bf2bac9 100755
>> > --- a/configure
>> > +++ b/configure
>> > @@ -3460,6 +3460,7 @@ derain_filter_select="dnn"
>> >  deshake_filter_select="pixelutils"
>> >  deshake_opencl_filter_deps="opencl"
>> >  dilation_opencl_filter_deps="opencl"
>> > +dnn_processing_filter_select="dnn"
>> >  drawtext_filter_deps="libfreetype"
>> >  drawtext_filter_suggest="libfontconfig libfribidi"
>> >  elbg_filter_deps="avcodec"
>> > diff --git a/doc/filters.texi b/doc/filters.texi
>> > index bdc4136..c11a616 100644
>> > --- a/doc/filters.texi
>> > +++ b/doc/filters.texi
>> > @@ -8928,6 +8928,50 @@ ffmpeg -i INPUT -f lavfi -i
>> > nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
>> >  @end example
>> >  @end itemize
>> >
>> > +@section dnn_processing
>> > +
>> > +Do image processing with deep neural networks. Currently only AVFrame
>> with
>> > RGB24
>> > +and BGR24 are supported, more formats will be added later.
>> > +
>> > +The filter accepts the following options:
>> > +
>> > +@table @option
>> > +@item dnn_backend
>> > +Specify which DNN backend to use for model loading and execution. This
>> > option accepts
>> > +the following values:
>> > +
>> > +@table @samp
>> > +@item native
>> > +Native implementation of DNN loading and execution.
>> > +
>> > +@item tensorflow
>> > +TensorFlow backend. To enable this backend you
>> > +need to install the TensorFlow for C library (see
>> > +@url{https://www.tensorflow.org/install/install_c}) and configure
>> > FFmpeg
>> > with
>> > +@code{--enable-libtensorflow}
>> > +@end table
>> > +
>> > +Default value is @samp{native}.
>> > +
>> > +@item model
>> > +Set path to model file specifying network architecture and its
>> > parameters.
>> > +Note that different 

Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Guo, Yejun


> -Original Message-
> From: Paul B Mahol [mailto:one...@gmail.com]
> Sent: Monday, October 28, 2019 4:00 PM
> To: FFmpeg development discussions and patches 
> Cc: Guo, Yejun 
> Subject: Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add a
> generic filter for image proccessing with dnn networks
> 
> On 10/21/19, Guo, Yejun  wrote:
> > This filter accepts all the dnn networks which do image processing.
> > Currently, frame with formats rgb24 and bgr24 are supported. Other
> > formats such as gray and YUV will be supported next. The dnn network
> > can accept data in float32 or uint8 format. And the dnn network can
> > change frame size.
> >
> > Let's take an example with the following python script. This script
> > halves the value of the first channel of the pixel.
> > import tensorflow as tf
> > import numpy as np
> > import scipy.misc
> > in_img = scipy.misc.imread('in.bmp')
> > in_img = in_img.astype(np.float32)/255.0
> > in_data = in_img[np.newaxis, :]
> > filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0,
> > 1.]).reshape(1,1,3,3).astype(np.float32)
> > filter = tf.Variable(filter_data)
> > x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
> > y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID',
> > name='dnn_out')
> > sess=tf.Session()
> > sess.run(tf.global_variables_initializer())
> > output = sess.run(y, feed_dict={x: in_data})
> > graph_def = tf.graph_util.convert_variables_to_constants(sess,
> > sess.graph_def, ['dnn_out'])
> > tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb',
> > as_text=False)
> > output = output * 255.0
> > output = output.astype(np.uint8)
> > scipy.misc.imsave("out.bmp", np.squeeze(output))
> 
> So this one executes python code without ever returning or using AVFrame* ?
> This is extremely limited usage.

the purpose of this script is to demo how to setup and execute dnn models with 
python+tensorflow.
The only relationship with ffmpeg is that the script prepares the model file 
halve_first_channel.pb.

The next description shows how ffmpeg can execute the model in a filter.

I'll try to update the commit log to avoid misleading words, thanks.

> 
> >
> > - generate halve_first_channel.pb with the above script
> > - generate halve_first_channel.model with tools/python/convert.py
> > - try with following commands
> >   ./ffmpeg -i input.jpg -vf
> >
> dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_
> out:fmt=rgb24:dnn_backend=native
> > -y out.native.png
> >   ./ffmpeg -i input.jpg -vf
> >
> dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:f
> mt=rgb24:dnn_backend=tensorflow
> > -y out.tf.png
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  configure   |   1 +
> >  doc/filters.texi|  44 ++
> >  libavfilter/Makefile|   1 +
> >  libavfilter/allfilters.c|   1 +
> >  libavfilter/vf_dnn_processing.c | 333
> > 
> >  5 files changed, 380 insertions(+)
> >  create mode 100644 libavfilter/vf_dnn_processing.c
> >
> > diff --git a/configure b/configure
> > index 8413826..bf2bac9 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3460,6 +3460,7 @@ derain_filter_select="dnn"
> >  deshake_filter_select="pixelutils"
> >  deshake_opencl_filter_deps="opencl"
> >  dilation_opencl_filter_deps="opencl"
> > +dnn_processing_filter_select="dnn"
> >  drawtext_filter_deps="libfreetype"
> >  drawtext_filter_suggest="libfontconfig libfribidi"
> >  elbg_filter_deps="avcodec"
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index bdc4136..c11a616 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -8928,6 +8928,50 @@ ffmpeg -i INPUT -f lavfi -i
> > nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
> >  @end example
> >  @end itemize
> >
> > +@section dnn_processing
> > +
> > +Do image processing with deep neural networks. Currently only AVFrame
> with
> > RGB24
> > +and BGR24 are supported, more formats will be added later.
> > +
> > +The filter accepts the following options:
> > +
> > +@table @option
> > +@item dnn_backend
> > +Specify which DNN backend to use for model loading and execution. This
> > option accepts
> > +the following values:
> > +
> > +@table @samp
> > +@item native
> > +Native implementation of DNN loading and execution.
> > +
> > +@item tensorflow
> > +TensorFlow backend. To enable this backend you
> > +need to install the TensorFlow for C library (see
> > +@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg
> > with
> > +@code{--enable-libtensorflow}
> > +@end table
> > +
> > +Default value is @samp{native}.
> > +
> > +@item model
> > +Set path to model file specifying network architecture and its parameters.
> > +Note that different backends use different file formats. TensorFlow and
> > native
> > +backend can load files for only its format.
> > +
> > +Native model file (.model) can be generated from TensorFlow 

[FFmpeg-devel] [PATCH] avformat/rtsp: fix wrong codec setup for some sdp

2019-10-28 Thread Hyun Yoo
rtsp_st->sdp_payload_type is the first codec in 'm=' tag
st->codecpar->id is the first supported codec in 'a=' tag
the two is not guaranteed to be same for example when
1) the order between attributes is random(rfc4566 doesn't force it)
2) the first codec is same for 'm=' and 'a=' but it is unsupported codec
   then st->codecpar->id will be the next one in 'a='(if it's supported)

Signed-off-by: Hyun Yoo 
---
 libavformat/rtsp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 859defa592..d0b246feb1 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -569,6 +569,9 @@ static void sdp_parse_line(AVFormatContext *s, 
SDPParseState *s1,
 get_word(buf1, sizeof(buf1), );
 payload_type = atoi(buf1);
 rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
+// parse only sdp_payload_type specified in 'm=' tag
+if (rtsp_st->sdp_payload_type != payload_type)
+return;
 if (rtsp_st->stream_index >= 0) {
 st = s->streams[rtsp_st->stream_index];
 sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
@@ -582,6 +585,10 @@ static void sdp_parse_line(AVFormatContext *s, 
SDPParseState *s1,
 // let dynamic protocol handlers have a stab at the line.
 get_word(buf1, sizeof(buf1), );
 payload_type = atoi(buf1);
+rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
+// parse only sdp_payload_type specified in 'm=' tag
+if (rtsp_st->sdp_payload_type != payload_type)
+return;
 if (s1->seen_rtpmap) {
 parse_fmtp(s, rt, payload_type, buf);
 } else {
-- 
2.23.0.windows.1

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

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

Re: [FFmpeg-devel] [PATCH V2 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Paul B Mahol
On 10/21/19, Guo, Yejun  wrote:
> This filter accepts all the dnn networks which do image processing.
> Currently, frame with formats rgb24 and bgr24 are supported. Other
> formats such as gray and YUV will be supported next. The dnn network
> can accept data in float32 or uint8 format. And the dnn network can
> change frame size.
>
> Let's take an example with the following python script. This script
> halves the value of the first channel of the pixel.
> import tensorflow as tf
> import numpy as np
> import scipy.misc
> in_img = scipy.misc.imread('in.bmp')
> in_img = in_img.astype(np.float32)/255.0
> in_data = in_img[np.newaxis, :]
> filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0,
> 1.]).reshape(1,1,3,3).astype(np.float32)
> filter = tf.Variable(filter_data)
> x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
> y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID',
> name='dnn_out')
> sess=tf.Session()
> sess.run(tf.global_variables_initializer())
> output = sess.run(y, feed_dict={x: in_data})
> graph_def = tf.graph_util.convert_variables_to_constants(sess,
> sess.graph_def, ['dnn_out'])
> tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb',
> as_text=False)
> output = output * 255.0
> output = output.astype(np.uint8)
> scipy.misc.imsave("out.bmp", np.squeeze(output))

So this one executes python code without ever returning or using AVFrame* ?
This is extremely limited usage.

>
> - generate halve_first_channel.pb with the above script
> - generate halve_first_channel.model with tools/python/convert.py
> - try with following commands
>   ./ffmpeg -i input.jpg -vf
> dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=native
> -y out.native.png
>   ./ffmpeg -i input.jpg -vf
> dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=tensorflow
> -y out.tf.png
>
> Signed-off-by: Guo, Yejun 
> ---
>  configure   |   1 +
>  doc/filters.texi|  44 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_dnn_processing.c | 333
> 
>  5 files changed, 380 insertions(+)
>  create mode 100644 libavfilter/vf_dnn_processing.c
>
> diff --git a/configure b/configure
> index 8413826..bf2bac9 100755
> --- a/configure
> +++ b/configure
> @@ -3460,6 +3460,7 @@ derain_filter_select="dnn"
>  deshake_filter_select="pixelutils"
>  deshake_opencl_filter_deps="opencl"
>  dilation_opencl_filter_deps="opencl"
> +dnn_processing_filter_select="dnn"
>  drawtext_filter_deps="libfreetype"
>  drawtext_filter_suggest="libfontconfig libfribidi"
>  elbg_filter_deps="avcodec"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bdc4136..c11a616 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -8928,6 +8928,50 @@ ffmpeg -i INPUT -f lavfi -i
> nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
>  @end example
>  @end itemize
>
> +@section dnn_processing
> +
> +Do image processing with deep neural networks. Currently only AVFrame with
> RGB24
> +and BGR24 are supported, more formats will be added later.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item dnn_backend
> +Specify which DNN backend to use for model loading and execution. This
> option accepts
> +the following values:
> +
> +@table @samp
> +@item native
> +Native implementation of DNN loading and execution.
> +
> +@item tensorflow
> +TensorFlow backend. To enable this backend you
> +need to install the TensorFlow for C library (see
> +@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg
> with
> +@code{--enable-libtensorflow}
> +@end table
> +
> +Default value is @samp{native}.
> +
> +@item model
> +Set path to model file specifying network architecture and its parameters.
> +Note that different backends use different file formats. TensorFlow and
> native
> +backend can load files for only its format.
> +
> +Native model file (.model) can be generated from TensorFlow model file
> (.pb) by using tools/python/convert.py
> +
> +@item input
> +Set the input name of the dnn network.
> +
> +@item output
> +Set the output name of the dnn network.
> +
> +@item fmt
> +Set the pixel format for the Frame. Allowed values are
> @code{AV_PIX_FMT_RGB24}, and @code{AV_PIX_FMT_BGR24}.
> +Default value is @code{AV_PIX_FMT_RGB24}.
> +
> +@end table
> +
>  @section drawbox
>
>  Draw a colored box on the input image.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 63d2fba..47a485a 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -224,6 +224,7 @@ OBJS-$(CONFIG_DILATION_OPENCL_FILTER)+=
> vf_neighbor_opencl.o opencl.o \
>  opencl/neighbor.o
>  OBJS-$(CONFIG_DISPLACE_FILTER)   += vf_displace.o framesync.o
>  OBJS-$(CONFIG_DOUBLEWEAVE_FILTER)+= vf_weave.o
> 

Re: [FFmpeg-devel] [PATCH V3] avfilter/vf_bilateral: process command to set the parameter at runtime

2019-10-28 Thread Tao Zhang
ping

leozhang  于2019年10月24日周四 下午5:18写道:
>
> Reviewed-by: Paul B Mahol 
> Reviewed-by: Jun Zhao 
> Signed-off-by: leozhang 
> ---
>  libavfilter/vf_bilateral.c | 57 
> ++
>  1 file changed, 43 insertions(+), 14 deletions(-)
>
> diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
> index 3c9d800..4d7bf68 100644
> --- a/libavfilter/vf_bilateral.c
> +++ b/libavfilter/vf_bilateral.c
> @@ -29,6 +29,8 @@
>  #include "internal.h"
>  #include "video.h"
>
> +#include 
> +
>  typedef struct BilateralContext {
>  const AVClass *class;
>
> @@ -54,7 +56,7 @@ typedef struct BilateralContext {
>  } BilateralContext;
>
>  #define OFFSET(x) offsetof(BilateralContext, x)
> -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +#define FLAGS 
> AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
>
>  static const AVOption bilateral_options[] = {
>  { "sigmaS", "set spatial sigma",OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, 
> {.dbl=0.1}, 0.0,  10, FLAGS },
> @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx)
>  return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
>  }
>
> -static int config_input(AVFilterLink *inlink)
> +static int init_lut(BilateralContext *s)
>  {
> -BilateralContext *s = inlink->dst->priv;
> -const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
>  float inv_sigma_range;
>
> -s->depth = desc->comp[0].depth;
>  inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1));
>
>  //compute a lookup table
>  for (int i = 0; i < (1 << s->depth); i++)
>  s->range_table[i] = expf(-i * inv_sigma_range);
>
> +return 0;
> +}
> +
> +static int config_input(AVFilterLink *inlink)
> +{
> +BilateralContext *s = inlink->dst->priv;
> +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
> +
> +s->depth = desc->comp[0].depth;
> +init_lut(s);
> +
>  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, 
> desc->log2_chroma_w);
>  s->planewidth[0] = s->planewidth[3] = inlink->w;
>  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, 
> desc->log2_chroma_h);
> @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *in)
>  return ff_filter_frame(outlink, out);
>  }
>
> +static int process_command(AVFilterContext *ctx, const char *cmd, const char 
> *args,
> +   char *res, int res_len, int flags)
> +{
> +BilateralContext *s = ctx->priv;
> +int ret;
> +float old_sigmaR = s->sigmaR;
> +
> +if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, 
> flags)) < 0) {
> +return ret;
> +}
> +
> +if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 
> 0) {
> +s->sigmaR = old_sigmaR;
> +}
> +
> +return ret;
> +}
> +
>  static av_cold void uninit(AVFilterContext *ctx)
>  {
>  BilateralContext *s = ctx->priv;
> @@ -358,13 +386,14 @@ static const AVFilterPad bilateral_outputs[] = {
>  };
>
>  AVFilter ff_vf_bilateral = {
> -.name  = "bilateral",
> -.description   = NULL_IF_CONFIG_SMALL("Apply Bilateral filter."),
> -.priv_size = sizeof(BilateralContext),
> -.priv_class= _class,
> -.uninit= uninit,
> -.query_formats = query_formats,
> -.inputs= bilateral_inputs,
> -.outputs   = bilateral_outputs,
> -.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
> +.name= "bilateral",
> +.description = NULL_IF_CONFIG_SMALL("Apply Bilateral filter."),
> +.priv_size   = sizeof(BilateralContext),
> +.priv_class  = _class,
> +.uninit  = uninit,
> +.query_formats   = query_formats,
> +.inputs  = bilateral_inputs,
> +.outputs = bilateral_outputs,
> +.flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
> +.process_command = process_command,
>  };
> --
> 1.8.3.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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 4/4] avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks

2019-10-28 Thread Guo, Yejun


> -Original Message-
> From: Guo, Yejun
> Sent: Monday, October 21, 2019 8:39 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun 
> Subject: [PATCH V2 4/4] avfilter/vf_dnn_processing: add a generic filter for
> image proccessing with dnn networks
> 
> This filter accepts all the dnn networks which do image processing.
> Currently, frame with formats rgb24 and bgr24 are supported. Other
> formats such as gray and YUV will be supported next. The dnn network
> can accept data in float32 or uint8 format. And the dnn network can
> change frame size.
> 
> Let's take an example with the following python script. This script
> halves the value of the first channel of the pixel.
> import tensorflow as tf
> import numpy as np
> import scipy.misc
> in_img = scipy.misc.imread('in.bmp')
> in_img = in_img.astype(np.float32)/255.0
> in_data = in_img[np.newaxis, :]
> filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0,
> 1.]).reshape(1,1,3,3).astype(np.float32)
> filter = tf.Variable(filter_data)
> x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
> y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID', 
> name='dnn_out')
> sess=tf.Session()
> sess.run(tf.global_variables_initializer())
> output = sess.run(y, feed_dict={x: in_data})
> graph_def = tf.graph_util.convert_variables_to_constants(sess,
> sess.graph_def, ['dnn_out'])
> tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb', as_text=False)
> output = output * 255.0
> output = output.astype(np.uint8)
> scipy.misc.imsave("out.bmp", np.squeeze(output))
> 
> - generate halve_first_channel.pb with the above script
> - generate halve_first_channel.model with tools/python/convert.py
> - try with following commands
>   ./ffmpeg -i input.jpg -vf
> dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_
> out:fmt=rgb24:dnn_backend=native -y out.native.png
>   ./ffmpeg -i input.jpg -vf
> dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:f
> mt=rgb24:dnn_backend=tensorflow -y out.tf.png
> 
> Signed-off-by: Guo, Yejun 
> ---
>  configure   |   1 +
>  doc/filters.texi|  44 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_dnn_processing.c | 333
> 
>  5 files changed, 380 insertions(+)


this patch set asks for review, thanks.

btw, the first 3 patches is to improve dnn module base and can be reviewed 
first.
The fourth patch is a filter based on dnn and can be reviewed secondly.
I put them together to explain why dnn module needs such change. 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".