[FFmpeg-devel] [PATCH] avcodec/vp8: fix multiple ff_thread_finish_setup() calls

2019-11-12 Thread quinkblack
From: Zhao Zhili 

vp7 decoder doesn't set update_thread_context field
---
 libavcodec/vp8.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index eb51d1f3c9..b4deb3ed67 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2715,7 +2715,8 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 s->next_framep[VP56_FRAME_CURRENT] = curframe;
 
-ff_thread_finish_setup(avctx);
+if (avctx->codec->update_thread_context)
+ff_thread_finish_setup(avctx);
 
 if (avctx->hwaccel) {
 ret = avctx->hwaccel->start_frame(avctx, avpkt->data, avpkt->size);
-- 
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] [PATCH] fate/filter-video: add test for dnn_processing with model halve_first_channel

2019-11-12 Thread Guo, Yejun


> -Original Message-
> From: Guo, Yejun
> Sent: Wednesday, November 13, 2019 1:41 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun 
> Subject: [PATCH] fate/filter-video: add test for dnn_processing with model
> halve_first_channel
> 
> Signed-off-by: Guo, Yejun 
> ---
>  tests/fate/filter-video.mak|  3 ++
>  .../fate/filter-dnn_processing-halve_first_channel | 55
> ++
>  2 files changed, 58 insertions(+)
>  create mode 100644 tests/ref/fate/filter-dnn_processing-halve_first_channel
> 
> diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
> index b520690..576f142 100644
> --- a/tests/fate/filter-video.mak
> +++ b/tests/fate/filter-video.mak
> @@ -259,6 +259,9 @@ FATE_FILTER_SAMPLES-$(call ALLYES, PNG_DECODER
> APNG_DEMUXER FORMAT_FILTER COLOR_
>  FATE_FILTER_VSYNTH-$(CONFIG_PHASE_FILTER) += fate-filter-phase
>  fate-filter-phase: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf phase
> 
> +FATE_FILTER_VSYNTH-$(CONFIG_DNN_PROCESSING_FILTER) +=
> fate-filter-dnn_processing-halve_first_channel
> +fate-filter-dnn_processing-halve_first_channel: CMD = framecrc -c:v pgmyuv -i
> $(SRC) -vf
> dnn_processing=model=$(TARGET_SAMPLES)/dnn_processing/halve_first_cha
> nnel.model:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=native


the test material is at 
https://github.com/guoyejun/fate-suite/tree/master/dnn_processing, 
could someone help to upload to fate-suite, thanks.

I got the following line at 
https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite, 
If you need a sample uploaded send a mail to samples-request.

but I did not find the detail email address of 'samples-request'.
___
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/filter-video: add test for dnn_processing with model halve_first_channel

2019-11-12 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 tests/fate/filter-video.mak|  3 ++
 .../fate/filter-dnn_processing-halve_first_channel | 55 ++
 2 files changed, 58 insertions(+)
 create mode 100644 tests/ref/fate/filter-dnn_processing-halve_first_channel

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index b520690..576f142 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -259,6 +259,9 @@ FATE_FILTER_SAMPLES-$(call ALLYES, PNG_DECODER APNG_DEMUXER 
FORMAT_FILTER COLOR_
 FATE_FILTER_VSYNTH-$(CONFIG_PHASE_FILTER) += fate-filter-phase
 fate-filter-phase: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf phase
 
+FATE_FILTER_VSYNTH-$(CONFIG_DNN_PROCESSING_FILTER) += 
fate-filter-dnn_processing-halve_first_channel
+fate-filter-dnn_processing-halve_first_channel: CMD = framecrc -c:v pgmyuv -i 
$(SRC) -vf 
dnn_processing=model=$(TARGET_SAMPLES)/dnn_processing/halve_first_channel.model:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=native
+
 FATE_REMOVEGRAIN += fate-filter-removegrain-mode-00
 fate-filter-removegrain-mode-00: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-frames:v 1 -vf removegrain=0:0:0
 
diff --git a/tests/ref/fate/filter-dnn_processing-halve_first_channel 
b/tests/ref/fate/filter-dnn_processing-halve_first_channel
new file mode 100644
index 000..ad7deda
--- /dev/null
+++ b/tests/ref/fate/filter-dnn_processing-halve_first_channel
@@ -0,0 +1,55 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 352x288
+#sar 0: 0/1
+0,  0,  0,1,   304128, 0xdecb04c8
+0,  1,  1,1,   304128, 0x55d9a543
+0,  2,  2,1,   304128, 0x11ae175c
+0,  3,  3,1,   304128, 0x2cbc8734
+0,  4,  4,1,   304128, 0xa8e5cb1f
+0,  5,  5,1,   304128, 0xb6d9ce81
+0,  6,  6,1,   304128, 0x51613881
+0,  7,  7,1,   304128, 0x09b9614f
+0,  8,  8,1,   304128, 0x172a6901
+0,  9,  9,1,   304128, 0x30237bf4
+0, 10, 10,1,   304128, 0xb8646354
+0, 11, 11,1,   304128, 0xe2dd8145
+0, 12, 12,1,   304128, 0x6f0b3cea
+0, 13, 13,1,   304128, 0xb1a04427
+0, 14, 14,1,   304128, 0xe0ab42cf
+0, 15, 15,1,   304128, 0xd4dc3224
+0, 16, 16,1,   304128, 0xdb3462a1
+0, 17, 17,1,   304128, 0x1d9931a1
+0, 18, 18,1,   304128, 0x17c80e7a
+0, 19, 19,1,   304128, 0x800d587b
+0, 20, 20,1,   304128, 0x97d67832
+0, 21, 21,1,   304128, 0xffc116db
+0, 22, 22,1,   304128, 0x80510bc1
+0, 23, 23,1,   304128, 0xbf838895
+0, 24, 24,1,   304128, 0x3c8ce931
+0, 25, 25,1,   304128, 0x8640e1cd
+0, 26, 26,1,   304128, 0xa944fcac
+0, 27, 27,1,   304128, 0x7cef3f83
+0, 28, 28,1,   304128, 0x3c8d60d2
+0, 29, 29,1,   304128, 0x83fad1ef
+0, 30, 30,1,   304128, 0xbd6031ac
+0, 31, 31,1,   304128, 0x9e63188a
+0, 32, 32,1,   304128, 0x0e45cb70
+0, 33, 33,1,   304128, 0x02a9ec32
+0, 34, 34,1,   304128, 0x6ff674cc
+0, 35, 35,1,   304128, 0x7d1143e6
+0, 36, 36,1,   304128, 0x52c6b9b7
+0, 37, 37,1,   304128, 0x16696d9c
+0, 38, 38,1,   304128, 0x0612973f
+0, 39, 39,1,   304128, 0xed130f6a
+0, 40, 40,1,   304128, 0xe0051904
+0, 41, 41,1,   304128, 0x6930d331
+0, 42, 42,1,   304128, 0x35f722f7
+0, 43, 43,1,   304128, 0x0adb7e81
+0, 44, 44,1,   304128, 0x1eb10598
+0, 45, 45,1,   304128, 0x73ec2115
+0, 46, 46,1,   304128, 0xf9d24a8c
+0, 47, 47,1,   304128, 0x94a3748d
+0, 48, 48,1,   304128, 0xbaeac1d5
+0, 49, 49,1,   304128, 0x5493efd3
-- 
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] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-11-12 Thread Andriy Gelman
From: Andriy Gelman 

Fixes #8079

During initialization of a v4l2m2m device, the configured pix_fmt can be
different to the pix_fmt of the encoder (i.e. avctx->pix_fmt).

For example on the Odroid XU4:
./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264

will configure the v4l2 encoder to pix_fmt nv21, whereas the input
frames will be yuv444p.

This commit checks that the configured v4l2 pix_fmt on device is the
same as avctx->pix_fmt. If they are different the initialization fails
and an error is returned. Tested on RPI4 and Odroid XU4.

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m_enc.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 474e6bef897..c0e82afe354 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -30,6 +30,7 @@
 #include "libavutil/opt.h"
 #include "v4l2_context.h"
 #include "v4l2_m2m.h"
+#include "v4l2_fmt.h"
 
 #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
 #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
@@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
 V4L2Context *capture, *output;
 V4L2m2mContext *s;
 V4L2m2mPriv *priv = avctx->priv_data;
+enum AVPixelFormat pix_fmt_output;
+uint32_t v4l2_fmt_output;
 int ret;
 
 ret = ff_v4l2_m2m_create_context(priv, );
@@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
 }
 s->avctx = avctx;
 
+if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
+v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
+else
+v4l2_fmt_output = output->format.fmt.pix.pixelformat;
+
+pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, 
AV_CODEC_ID_RAWVIDEO);
+if (pix_fmt_output != avctx->pix_fmt) {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt_output);
+av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
desc->name);
+return AVERROR(EINVAL);
+}
+
 return v4l2_prepare_encoder(s);
 }
 
-- 
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 5/5] avformat: add an AV1 Annex B demuxer

2019-11-12 Thread James Almer
On 11/13/2019 12:20 AM, Carl Eugen Hoyos wrote:
> 
> 
>> Am 12.11.2019 um 04:01 schrieb James Almer :
>>
>>> On 11/11/2019 2:36 PM, Carl Eugen Hoyos wrote:
>>>
>>>
 Am 11.11.2019 um 22:36 schrieb James Almer :

 +AVInputFormat ff_obu_demuxer = {
 +.name   = "obu",
>>>
>>> Why is the demuxer not called “av1”?
>>>
>>> Thank you, Carl Eugen
>>> (Sleepless in Japan)
>>
>> I liked obu more, being the extension used for Annex B encapsulated
>> samples, but i'm fine changing it to av1 if others prefer that.
> 
> I would have preferred av1 ...

You'll be happy to know i decided to go with your suggestion, then :p

> 
>>
>> The problem will be what to do with the eventual raw Section 5 OBU demuxer.
> 
> ... but I have no idea what the Section 5 demuxer is (or which one of the two 
> is more likely to need on occasion demuxer forcing).

"Section 5" is just raw AV1 OBUs, and what gets multiplexed into
containers. It's similar to raw h264 NALUs.
"Annex B" is a trivial encapsulation for said raw OBUs, to easily
delimit frames and Temporal Units. I can barely be considered a container.

I called the Annex B demuxer av1. An eventual raw OBU demuxer can then
be called obu.

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

Re: [FFmpeg-devel] [PATCH 5/5] avformat: add an AV1 Annex B demuxer

2019-11-12 Thread Carl Eugen Hoyos


> Am 12.11.2019 um 04:01 schrieb James Almer :
> 
>> On 11/11/2019 2:36 PM, Carl Eugen Hoyos wrote:
>> 
>> 
>>> Am 11.11.2019 um 22:36 schrieb James Almer :
>>> 
>>> +AVInputFormat ff_obu_demuxer = {
>>> +.name   = "obu",
>> 
>> Why is the demuxer not called “av1”?
>> 
>> Thank you, Carl Eugen
>> (Sleepless in Japan)
> 
> I liked obu more, being the extension used for Annex B encapsulated
> samples, but i'm fine changing it to av1 if others prefer that.

I would have preferred av1 ...

> 
> The problem will be what to do with the eventual raw Section 5 OBU demuxer.

... but I have no idea what the Section 5 demuxer is (or which one of the two 
is more likely to need on occasion demuxer forcing).

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

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Steven Liu


> 在 2019年11月13日,09:02,myp...@gmail.com 写道:
> 
> On Wed, Nov 13, 2019 at 7:24 AM Paul B Mahol  wrote:
>> 
>> On 11/13/19, Michael Niedermayer  wrote:
>>> On Tue, Nov 12, 2019 at 12:48:09PM +0100, Paul B Mahol wrote:
 If this filter is same speed or better than boxblur, it should replace
 boxblur filter, as boxblur filter is GPL.
>>> 
>>> relicensing boxblur should not be hard if someone needs the code to be
>>> under lgpl
>> 
>> I do not think so, look at geq, lots of devs no longer contactable,
>> 
> Maybe we can keep both based on the license choice
I think your suggestion is better :D
> ___
> 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 v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Sun, Xinpeng

> -Original Message-
> From: Song, Ruiling 
> Sent: Wednesday, November 13, 2019 9:05 AM
> To: FFmpeg development discussions and patches 
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: RE: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for
> H2S
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Xinpeng Sun
> > Sent: Tuesday, November 12, 2019 5:00 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Sun, Xinpeng ; Zhou, Zachary
> > 
> > Subject: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter
> > for H2S
> >
> > It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> > conversion with tone-mapping. It supports HDR10 only as input
> > temporarily.
> >
> > H2S: P010 -> NV12
> Have you tried P010 HDR to P010 SDR? Does it work? I think people may like use
> 10bit SDR because it has more color details.
> 
I will check if it works in the driver. If yes, I can add P010 HDR to P010 SDR 
in the next version.

> >
> > An example command to use this filter with vaapi codecs:
> > FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -
> > hwaccel_output_format vaapi \ -i INPUT -vf
> > 'tonemap_vaapi=h2s,hwdownload,format=nv12' -pix_fmt nv12 \ -f rawvideo
> > -y OUTPUT
> >
> > Signed-off-by: Xinpeng Sun 
> > Signed-off-by: Zachary Zhou 
> > ---
> >  doc/filters.texi   |  30 
> >  libavfilter/Makefile   |   1 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/vaapi_vpp.c|   5 +
> >  libavfilter/vf_tonemap_vaapi.c | 272
> > +
> >  5 files changed, 309 insertions(+)
> >  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi index
> > 6800124574..b1c466ba24 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -20754,6 +20754,36 @@ Convert HDR(PQ/HLG) video to bt2020-transfer-
> > characteristic p010 format using li  @end example  @end itemize
> >
> This should not be here. Please move above opencl video filters or start 
> another
> chapter dedicated for vaapi accelerated video filters somewhere.
I will fix it in the next version.

> > +@section tonemap_vappi
> > +
> > +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> > conversion with tone-mapping.
> > +It maps the dynamic range of HDR10 content to the SDR content.
> > +It only accepts HDR10 as input temporarilly.
> > +
> > +It accepts the following parameters:
> > +
> > +@table @option
> > +@item type
> > +Specify the tone-mapping operator to be used.
> > +
> > +Possible values are:
> > +@table @var
> > +@item h2s
> > +Perform H2S(HDR to SDR), convert from p010 to nv12 @end table
> > +
> > +@end table
> > +
> > +@subsection Example
> > +
> > +@itemize
> > +@item
> > +Convert HDR video to SDR video from p010 format to nv12 format.
> > +@example
> > +-i INPUT -vf "tonemap_vaapi=h2s" OUTPUT @end example @end itemize
> > +
> >  @section unsharp_opencl
> >
> >  Sharpen or blur the input video.
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile index
> > fce930360d..90a0e9945e 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -410,6 +410,7 @@ OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o
> > framesync.o
> >  OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o colorspace.o
> >  OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o
> > colorspace.o opencl.o \
> >  opencl/tonemap.o
> > opencl/colorspace_common.o
> > +OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER)  += vf_tonemap_vaapi.o
> > vaapi_vpp.o
> >  OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
> >  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
> >  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index
> > 7c1e19e1da..b2fb1f8a98 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -390,6 +390,7 @@ extern AVFilter ff_vf_tlut2;  extern AVFilter
> > ff_vf_tmix;  extern AVFilter ff_vf_tonemap;  extern AVFilter
> > ff_vf_tonemap_opencl;
> > +extern AVFilter ff_vf_tonemap_vaapi;
> >  extern AVFilter ff_vf_tpad;
> >  extern AVFilter ff_vf_transpose;
> >  extern AVFilter ff_vf_transpose_npp;
> > diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c index
> > b5b245c8af..5776243fa0 100644
> > --- a/libavfilter/vaapi_vpp.c
> > +++ b/libavfilter/vaapi_vpp.c
> > @@ -257,6 +257,11 @@ static const VAAPIColourProperties
> > vaapi_colour_standard_map[] = {
> >  { VAProcColorStandardSMPTE170M,   6,  6,  6 },
> >  { VAProcColorStandardSMPTE240M,   7,  7,  7 },
> >  { VAProcColorStandardGenericFilm, 8,  1,  1 },
> > +
> > +#if VA_CHECK_VERSION(2, 3, 0)
> > +{ VAProcColorStandardExplicit,9,  16, AVCOL_SPC_BT2020_NCL},
> > +#endif
> > +
> >  #if VA_CHECK_VERSION(1, 1, 0)
> >  { VAProcColorStandardSRGB,1, 13,  0 },
> >   

Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Sun, Xinpeng

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Carl
> Eugen Hoyos
> Sent: Tuesday, November 12, 2019 5:52 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for
> H2S
> 
> Hi!
> 
> > Am 12.11.2019 um 17:59 schrieb Xinpeng Sun :
> >
> > It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> > conversion with tone-mapping. It supports HDR10 only as input temporarily.
> >
> > H2S: P010 -> NV12
> 
> No objection here but could you tell us if you (Intel) already have a plan 
> how to
> deal with H2H?
> 
> Thank you for your effort, Carl Eugen

Thanks for your quick feedback!
H2H is under development. In our new plan, P010->P010 will take place of 
P010->A2R10G10B10.

> ___
> 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 01/10] avformat/mpegtsenc: allow any sensible PID for elementary and pmt pids

2019-11-12 Thread Limin Wang
On Tue, Nov 12, 2019 at 10:28:57PM +0100, Marton Balint wrote:
> Also make sure that assigned PID numbers are valid and fix the error message
> for the previous PID collision checks.
> 
> Signed-off-by: Marton Balint 
> ---
>  doc/muxers.texi |  7 ---
>  libavformat/mpegts.h|  4 
>  libavformat/mpegtsenc.c | 21 ++---
>  3 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 09ded7d48a..c36ae60f19 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1582,11 +1582,12 @@ Advanced Codec Digital HDTV service.
>  @end table
>  
>  @item mpegts_pmt_start_pid @var{integer}
> -Set the first PID for PMT. Default is @code{0x1000}. Max is @code{0x1f00}.
> +Set the first PID for PMTs. Default is @code{0x1000}, minimum is 
> @code{0x0010},
> +maximum is @code{0x1ffe}.

I think the valid pid range can consider change to [0x20, 0x1ffa] 

as 0x0010-0x001F is used by DVB metadata, like NIT, SDT etc, it'll valid
both for DVB and ATSC standard. ARIB standard is reserved x20-0x2F, but
it's not well known.

0x1ff0-0x1ffe is reserved by ATSC atandard, 0x1FFB is used by PSIP and EA 
data(A/65),
0x1ffe is used by DOCSIS. 

I notice AWS Elemental encoder allow maximum is 0x1ff6.

reference link:
https://en.wikipedia.org/wiki/MPEG_transport_stream
https://docs.aws.amazon.com/medialive/latest/apireference/channels-channelid-start.html
https://www.scte.org/SCTEDocs/Standards/SCTE%20137-6%202017.pdf
https://www.atsc.org/wp-content/uploads/2015/03/A53-Part-3-2013.pdf


>  
>  @item mpegts_start_pid @var{integer}
> -Set the first PID for data packets. Default is @code{0x0100}. Max is
> -@code{0x0f00}.
> +Set the first PID for elementary streams. Default is @code{0x0100}, minimum 
> is
> +@code{0x0010}, maximum is @code{0x1ffe}.
>  
>  @item mpegts_m2ts_mode @var{boolean}
>  Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
> diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
> index ecc3d3374c..9a7f2c1d11 100644
> --- a/libavformat/mpegts.h
> +++ b/libavformat/mpegts.h
> @@ -63,6 +63,10 @@
>   * streams and other data tables */
>  #define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth 
> padding) */
>  
> +/* PMT and elementary stream PID range */
> +#define FIRST_OTHER_PID 0x0010
> +#define  LAST_OTHER_PID 0x1FFE
> +
>  /* table ids */
>  #define PAT_TID 0x00 /* Program Association section */
>  #define CAT_TID 0x01 /* Conditional Access section */
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 9f8f1715c9..fbc7305dc1 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -912,19 +912,26 @@ static int mpegts_init(AVFormatContext *s)
>  
>  /* MPEG pid values < 16 are reserved. Applications which set st->id 
> in
>   * this range are assigned a calculated pid. */
> -if (st->id < 16) {
> +if (st->id < FIRST_OTHER_PID) {
>  ts_st->pid = ts->start_pid + i;
> -} else if (st->id < 0x1FFF) {
> -ts_st->pid = st->id;
>  } else {
> +ts_st->pid = st->id;
> +}
> +if (ts_st->pid > LAST_OTHER_PID) {
>  av_log(s, AV_LOG_ERROR,
> -   "Invalid stream id %d, must be less than 8191\n", st->id);
> +   "Invalid stream id %d, must be less than %d\n", st->id, 
> LAST_OTHER_PID + 1);
>  ret = AVERROR(EINVAL);
>  goto fail;
>  }
>  for (j = 0; j < ts->nb_services; j++) {
> +if (ts->services[j]->pmt.pid > LAST_OTHER_PID) {
> +av_log(s, AV_LOG_ERROR,
> +   "Invalid PMT PID %d, must be less than %d\n", 
> ts->services[j]->pmt.pid, LAST_OTHER_PID + 1);
> +ret = AVERROR(EINVAL);
> +goto fail;
> +}
>  if (ts_st->pid == ts->services[j]->pmt.pid) {
> -av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> ts_st->pid);
> +av_log(s, AV_LOG_ERROR, "PID %d cannot be both elementary 
> and PMT PID\n", ts_st->pid);
>  ret = AVERROR(EINVAL);
>  goto fail;
>  }
> @@ -1888,10 +1895,10 @@ static const AVOption options[] = {
>AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
>  { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
>offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
> -  { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
> +  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
> AV_OPT_FLAG_ENCODING_PARAM },
>  { "mpegts_start_pid", "Set the first pid.",
>offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
> -  { .i64 = 0x0100 }, 0x0010, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM },
> +  { .i64 = 0x0100 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
> AV_OPT_FLAG_ENCODING_PARAM },
>  { "mpegts_m2ts_mode", "Enable m2ts mode.",
>

Re: [FFmpeg-devel] [PATCH 2/5 v4] avcodec: add an AV1 frame merge bitstream filter

2019-11-12 Thread James Almer
On 11/12/2019 6:24 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer 
>> ---
>> Now using an index to swap fragments.
>>
>> I noticed that the input packet containing props is not necessarily the first
>> in a TU, so adapted the code accordingly. This fixes warnings about missing
>> timestamps when trying to merge the output of av1_frame_split, where the 
>> source
>> had the visible frames at the end of a TU rather than at the beginning.
>>
>> Not going to bother with indexes for the packets. av_packet_move_ref() is far
>> from expensive, unlike creating buffer references and expanding the 
>> fragment's
>> unit buffer.
>>
>>  configure|   1 +
>>  libavcodec/Makefile  |   1 +
>>  libavcodec/av1_frame_merge_bsf.c | 169 +++
>>  libavcodec/bitstream_filters.c   |   1 +
>>  4 files changed, 172 insertions(+)
>>  create mode 100644 libavcodec/av1_frame_merge_bsf.c
>>
>> diff --git a/configure b/configure
>> index 1de90e93fd..70f60997c1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
>>  
>>  # bitstream_filters
>>  aac_adtstoasc_bsf_select="adts_header"
>> +av1_frame_merge_bsf_select="cbs_av1"
>>  av1_frame_split_bsf_select="cbs_av1"
>>  av1_metadata_bsf_select="cbs_av1"
>>  eac3_core_bsf_select="ac3_parser"
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index b990c6ba87..006a472a6d 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
>>  # bitstream filters
>>  OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o 
>> mpeg4audio.o
>>  OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
>> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
>>  OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
>>  OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
>>  OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
>> diff --git a/libavcodec/av1_frame_merge_bsf.c 
>> b/libavcodec/av1_frame_merge_bsf.c
>> new file mode 100644
>> index 00..96a9e6e863
>> --- /dev/null
>> +++ b/libavcodec/av1_frame_merge_bsf.c
>> @@ -0,0 +1,169 @@
>> +/*
>> + * Copyright (c) 2019 James Almer 
>> + *
>> + * 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 "avcodec.h"
>> +#include "bsf.h"
>> +#include "cbs.h"
>> +#include "cbs_av1.h"
>> +
>> +typedef struct AV1FMergeContext {
>> +CodedBitstreamContext *cbc;
>> +CodedBitstreamFragment frag[2];
>> +AVPacket *pkt, *in;
>> +int idx;
>> +} AV1FMergeContext;
>> +
>> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
>> +{
>> +AV1FMergeContext *ctx = bsf->priv_data;
>> +CodedBitstreamFragment *frag = >frag[ctx->idx], *tu = 
>> >frag[!ctx->idx];
>> +AVPacket *in = ctx->in, *buffer_pkt = ctx->pkt;
>> +int err, i;
>> +
>> +err = ff_bsf_get_packet_ref(bsf, in);
>> +if (err < 0) {
>> +if (err == AVERROR_EOF && tu->nb_units > 0)
>> +goto eof;
>> +return err;
>> +}
>> +
>> +err = ff_cbs_read_packet(ctx->cbc, frag, in);
>> +if (err < 0) {
>> +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
>> +goto fail;
>> +}
>> +
>> +if (frag->nb_units == 0) {
>> +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
>> +err = AVERROR_INVALIDDATA;
>> +goto fail;
>> +}
>> +
>> +if (tu->nb_units == 0 && frag->units[0].type != 
>> AV1_OBU_TEMPORAL_DELIMITER) {
>> +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n");
>> +err = AVERROR_INVALIDDATA;
>> +goto fail;
>> +}
>> +
>> +if (tu->nb_units > 0 && frag->units[0].type == 
>> AV1_OBU_TEMPORAL_DELIMITER) {
>> +eof:
>> +err = ff_cbs_write_packet(ctx->cbc, buffer_pkt, tu);
>> +if (err < 0) {
>> +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
>> +goto fail;
>> +}
>> +av_packet_move_ref(out, buffer_pkt);
>> +
>> +ff_cbs_fragment_reset(ctx->cbc, tu);
>> +
>> +for (i = 1; i < frag->nb_units; i++) {
>> +

Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Carl Eugen Hoyos
> Sent: Tuesday, November 12, 2019 5:52 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for
> H2S
> 
> Hi!
> 
> > Am 12.11.2019 um 17:59 schrieb Xinpeng Sun :
> >
> > It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> conversion
> > with tone-mapping. It supports HDR10 only as input temporarily.
> >
> > H2S: P010 -> NV12
> 
> No objection here but could you tell us if you (Intel) already have a plan how
> to deal with H2H?
Hi Carl,

I guess H2S would be much more useful than H2H. So I think it is ok to make H2S 
patch work well and acceptable.

Ruiling
> 
> Thank you for your effort, 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".

Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xinpeng Sun
> Sent: Tuesday, November 12, 2019 5:00 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for
> H2S
> 
> It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> conversion
> with tone-mapping. It supports HDR10 only as input temporarily.
> 
> H2S: P010 -> NV12
Have you tried P010 HDR to P010 SDR? Does it work? I think people may like use 
10bit SDR because it has more color details.

> 
> An example command to use this filter with vaapi codecs:
> FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -
> hwaccel_output_format vaapi \
> -i INPUT -vf 'tonemap_vaapi=h2s,hwdownload,format=nv12' -pix_fmt nv12 \
> -f rawvideo -y OUTPUT
> 
> Signed-off-by: Xinpeng Sun 
> Signed-off-by: Zachary Zhou 
> ---
>  doc/filters.texi   |  30 
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vaapi_vpp.c|   5 +
>  libavfilter/vf_tonemap_vaapi.c | 272
> +
>  5 files changed, 309 insertions(+)
>  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6800124574..b1c466ba24 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -20754,6 +20754,36 @@ Convert HDR(PQ/HLG) video to bt2020-transfer-
> characteristic p010 format using li
>  @end example
>  @end itemize
> 
This should not be here. Please move above opencl video filters or start 
another chapter dedicated for vaapi accelerated video filters somewhere.
> +@section tonemap_vappi
> +
> +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> conversion with tone-mapping.
> +It maps the dynamic range of HDR10 content to the SDR content.
> +It only accepts HDR10 as input temporarilly.
> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item type
> +Specify the tone-mapping operator to be used.
> +
> +Possible values are:
> +@table @var
> +@item h2s
> +Perform H2S(HDR to SDR), convert from p010 to nv12
> +@end table
> +
> +@end table
> +
> +@subsection Example
> +
> +@itemize
> +@item
> +Convert HDR video to SDR video from p010 format to nv12 format.
> +@example
> +-i INPUT -vf "tonemap_vaapi=h2s" OUTPUT
> +@end example
> +@end itemize
> +
>  @section unsharp_opencl
> 
>  Sharpen or blur the input video.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fce930360d..90a0e9945e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -410,6 +410,7 @@ OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o
> framesync.o
>  OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o colorspace.o
>  OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o
> colorspace.o opencl.o \
>  opencl/tonemap.o 
> opencl/colorspace_common.o
> +OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER)  += vf_tonemap_vaapi.o
> vaapi_vpp.o
>  OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
>  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
>  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 7c1e19e1da..b2fb1f8a98 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -390,6 +390,7 @@ extern AVFilter ff_vf_tlut2;
>  extern AVFilter ff_vf_tmix;
>  extern AVFilter ff_vf_tonemap;
>  extern AVFilter ff_vf_tonemap_opencl;
> +extern AVFilter ff_vf_tonemap_vaapi;
>  extern AVFilter ff_vf_tpad;
>  extern AVFilter ff_vf_transpose;
>  extern AVFilter ff_vf_transpose_npp;
> diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> index b5b245c8af..5776243fa0 100644
> --- a/libavfilter/vaapi_vpp.c
> +++ b/libavfilter/vaapi_vpp.c
> @@ -257,6 +257,11 @@ static const VAAPIColourProperties
> vaapi_colour_standard_map[] = {
>  { VAProcColorStandardSMPTE170M,   6,  6,  6 },
>  { VAProcColorStandardSMPTE240M,   7,  7,  7 },
>  { VAProcColorStandardGenericFilm, 8,  1,  1 },
> +
> +#if VA_CHECK_VERSION(2, 3, 0)
> +{ VAProcColorStandardExplicit,9,  16, AVCOL_SPC_BT2020_NCL},
> +#endif
> +
>  #if VA_CHECK_VERSION(1, 1, 0)
>  { VAProcColorStandardSRGB,1, 13,  0 },
>  { VAProcColorStandardXVYCC601,1, 11,  5 },
> diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
> new file mode 100644
> index 00..27ee17bf00
> --- /dev/null
> +++ b/libavfilter/vf_tonemap_vaapi.c
> @@ -0,0 +1,272 @@
> +/*
> + * 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 

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread myp...@gmail.com
On Wed, Nov 13, 2019 at 7:24 AM Paul B Mahol  wrote:
>
> On 11/13/19, Michael Niedermayer  wrote:
> > On Tue, Nov 12, 2019 at 12:48:09PM +0100, Paul B Mahol wrote:
> >> If this filter is same speed or better than boxblur, it should replace
> >> boxblur filter, as boxblur filter is GPL.
> >
> > relicensing boxblur should not be hard if someone needs the code to be
> > under lgpl
>
> I do not think so, look at geq, lots of devs no longer contactable,
>
Maybe we can keep both based on the license choice
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Paul B Mahol
On 11/13/19, Michael Niedermayer  wrote:
> On Tue, Nov 12, 2019 at 12:48:09PM +0100, Paul B Mahol wrote:
>> If this filter is same speed or better than boxblur, it should replace
>> boxblur filter, as boxblur filter is GPL.
>
> relicensing boxblur should not be hard if someone needs the code to be
> under lgpl

I do not think so, look at geq, lots of devs no longer contactable,

>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The educated differ from the uneducated as much as the living from the
> dead. -- Aristotle
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Michael Niedermayer
On Tue, Nov 12, 2019 at 12:48:09PM +0100, Paul B Mahol wrote:
> If this filter is same speed or better than boxblur, it should replace
> boxblur filter, as boxblur filter is GPL.

relicensing boxblur should not be hard if someone needs the code to be
under lgpl

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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

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

[FFmpeg-devel] [PATCH 3/4] avcodec/wmaprodec: Check offset

2019-11-12 Thread Michael Niedermayer
Fixes: index 33280 out of bounds for type 'float [32768]'
Fixes: 
18718/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5635373899710464

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

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 070bb32af8..a753044ea7 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1803,6 +1803,11 @@ static int xma_decode_packet(AVCodecContext *avctx, void 
*data,
 ret = decode_packet(avctx, >xma[s->current_stream], 
s->frames[s->current_stream],
 _stream_frame_ptr, avpkt);
 
+if (got_stream_frame_ptr && s->offset[s->current_stream] >= 64) {
+got_stream_frame_ptr = 0;
+ret = AVERROR_INVALIDDATA;
+}
+
 /* copy stream samples (1/2ch) to sample buffer (Nch) */
 if (got_stream_frame_ptr) {
 int start_ch = s->start_channel[s->current_stream];
-- 
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 4/4] avcodec/wmaprodec: Set packet_loss when we error out on a sanity check

2019-11-12 Thread Michael Niedermayer
Fixes: left shift of negative value -34
Fixes: 
18719/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAPRO_fuzzer-5642658173419520

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

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index a753044ea7..53c6cee61e 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1644,6 +1644,7 @@ static int decode_packet(AVCodecContext *avctx, 
WMAProDecodeCtx *s,
 if (avctx->codec_id == AV_CODEC_ID_WMAPRO && buf_size < 
avctx->block_align) {
 av_log(avctx, AV_LOG_ERROR, "Input packet too small (%d < %d)\n",
buf_size, avctx->block_align);
+s->packet_loss = 1;
 return AVERROR_INVALIDDATA;
 }
 
-- 
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/4] avcodec/wmaprodec: Check if the channel sum of all internal contexts match the external

2019-11-12 Thread Michael Niedermayer
Fixes: NULL pointer dereference
Fixes: 
18689/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA1_fuzzer-5715114640015360

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

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index e001dd6e4e..070bb32af8 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1930,6 +1930,8 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
 s->start_channel[i] = start_channels;
 start_channels += s->xma[i].nb_channels;
 }
+if (start_channels != avctx->channels)
+return AVERROR_INVALIDDATA;
 
 return ret;
 }
-- 
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/4] avcodec/truemotion2: Fix 2 integer overflows in tm2_low_res_block()

2019-11-12 Thread Michael Niedermayer
Fixes: signed integer overflow: 1778647621 + 574372924 cannot be represented in 
type 'int'
Fixes: 
18692/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-6248679635943424

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

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index fbdb657363..7d70746339 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -586,10 +586,10 @@ static inline void tm2_low_res_block(TM2Context *ctx, 
AVFrame *pic, int bx, int
 last[0] = (int)((unsigned)last[1]  - ctx->D[0] - ctx->D[1] - ctx->D[2] 
- ctx->D[3])>> 1;
 last[2] = (int)((unsigned)last[1] + last[3]) >> 1;
 
-t1 = ctx->D[0] + ctx->D[1];
+t1 = ctx->D[0] + (unsigned)ctx->D[1];
 ctx->D[0] = t1 >> 1;
 ctx->D[1] = t1 - (t1 >> 1);
-t2 = ctx->D[2] + ctx->D[3];
+t2 = ctx->D[2] + (unsigned)ctx->D[3];
 ctx->D[2] = t2 >> 1;
 ctx->D[3] = t2 - (t2 >> 1);
 
-- 
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 2/5 v4] avcodec: add an AV1 frame merge bitstream filter

2019-11-12 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
> Now using an index to swap fragments.
> 
> I noticed that the input packet containing props is not necessarily the first
> in a TU, so adapted the code accordingly. This fixes warnings about missing
> timestamps when trying to merge the output of av1_frame_split, where the 
> source
> had the visible frames at the end of a TU rather than at the beginning.
> 
> Not going to bother with indexes for the packets. av_packet_move_ref() is far
> from expensive, unlike creating buffer references and expanding the fragment's
> unit buffer.
> 
>  configure|   1 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/av1_frame_merge_bsf.c | 169 +++
>  libavcodec/bitstream_filters.c   |   1 +
>  4 files changed, 172 insertions(+)
>  create mode 100644 libavcodec/av1_frame_merge_bsf.c
> 
> diff --git a/configure b/configure
> index 1de90e93fd..70f60997c1 100755
> --- a/configure
> +++ b/configure
> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
>  
>  # bitstream_filters
>  aac_adtstoasc_bsf_select="adts_header"
> +av1_frame_merge_bsf_select="cbs_av1"
>  av1_frame_split_bsf_select="cbs_av1"
>  av1_metadata_bsf_select="cbs_av1"
>  eac3_core_bsf_select="ac3_parser"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index b990c6ba87..006a472a6d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
>  # bitstream filters
>  OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o mpeg4audio.o
>  OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
>  OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
>  OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
>  OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
> diff --git a/libavcodec/av1_frame_merge_bsf.c 
> b/libavcodec/av1_frame_merge_bsf.c
> new file mode 100644
> index 00..96a9e6e863
> --- /dev/null
> +++ b/libavcodec/av1_frame_merge_bsf.c
> @@ -0,0 +1,169 @@
> +/*
> + * Copyright (c) 2019 James Almer 
> + *
> + * 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 "avcodec.h"
> +#include "bsf.h"
> +#include "cbs.h"
> +#include "cbs_av1.h"
> +
> +typedef struct AV1FMergeContext {
> +CodedBitstreamContext *cbc;
> +CodedBitstreamFragment frag[2];
> +AVPacket *pkt, *in;
> +int idx;
> +} AV1FMergeContext;
> +
> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
> +{
> +AV1FMergeContext *ctx = bsf->priv_data;
> +CodedBitstreamFragment *frag = >frag[ctx->idx], *tu = 
> >frag[!ctx->idx];
> +AVPacket *in = ctx->in, *buffer_pkt = ctx->pkt;
> +int err, i;
> +
> +err = ff_bsf_get_packet_ref(bsf, in);
> +if (err < 0) {
> +if (err == AVERROR_EOF && tu->nb_units > 0)
> +goto eof;
> +return err;
> +}
> +
> +err = ff_cbs_read_packet(ctx->cbc, frag, in);
> +if (err < 0) {
> +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
> +goto fail;
> +}
> +
> +if (frag->nb_units == 0) {
> +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
> +err = AVERROR_INVALIDDATA;
> +goto fail;
> +}
> +
> +if (tu->nb_units == 0 && frag->units[0].type != 
> AV1_OBU_TEMPORAL_DELIMITER) {
> +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n");
> +err = AVERROR_INVALIDDATA;
> +goto fail;
> +}
> +
> +if (tu->nb_units > 0 && frag->units[0].type == 
> AV1_OBU_TEMPORAL_DELIMITER) {
> +eof:
> +err = ff_cbs_write_packet(ctx->cbc, buffer_pkt, tu);
> +if (err < 0) {
> +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
> +goto fail;
> +}
> +av_packet_move_ref(out, buffer_pkt);
> +
> +ff_cbs_fragment_reset(ctx->cbc, tu);
> +
> +for (i = 1; i < frag->nb_units; i++) {
> +if (frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
> +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle 
> of a packet.\n");
> +err = 

[FFmpeg-devel] [PATCH 09/10] avformat/mpegtsenc: support generating standalone PCR PID for m2ts

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 2191c134ac..d8a74f4fe1 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -36,6 +36,8 @@
 
 #define PCR_TIME_BASE 2700
 #define M2TS_DEFAULT_MUXRATE 5400
+#define M2TS_PCR_PID 0x1001
+#define M2TS_PCR_RETRANS_TIME 50
 
 /* write DVB SI sections */
 
@@ -99,6 +101,8 @@ typedef struct MpegTSWrite {
 int m2ts_audio_pid;
 int m2ts_subtitle_pid;
 int m2ts_other_pid;
+int64_t m2ts_pcr_period;
+int64_t m2ts_last_pcr;
 
 int pcr_period_ms;
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
@@ -769,7 +773,7 @@ static MpegTSService *mpegts_add_service(AVFormatContext 
*s, int sid,
 return NULL;
 service->pmt.pid   = ts->pmt_start_pid + ts->nb_services;
 service->sid   = sid;
-service->pcr_pid   = 0x1fff;
+service->pcr_pid   = ts->m2ts_mode ? M2TS_PCR_PID : 0x1fff;
 if (encode_str8(service->provider_name, provider_name) < 0 ||
 encode_str8(service->name, service_name) < 0) {
 av_log(s, AV_LOG_ERROR, "Too long service or provider name\n");
@@ -1031,7 +1035,11 @@ static int mpegts_init(AVFormatContext *s)
 if (ts->copyts < 1)
 ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
 
-select_pcr_streams(s);
+ts->m2ts_pcr_period = av_rescale(ts->pcr_period_ms == -1 ? 
M2TS_PCR_RETRANS_TIME : ts->pcr_period_ms, PCR_TIME_BASE, 1000);
+ts->m2ts_last_pcr   = ts->first_pcr - ts->m2ts_pcr_period;
+
+if (!ts->m2ts_mode)
+select_pcr_streams(s);
 
 ts->last_pat_ts = AV_NOPTS_VALUE;
 ts->last_sdt_ts = AV_NOPTS_VALUE;
@@ -1115,24 +1123,23 @@ static void mpegts_insert_null_packet(AVFormatContext 
*s, int force)
 }
 
 /* Write a single transport stream packet with a PCR and no payload */
-static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st)
+static void mpegts_insert_pcr_only(AVFormatContext *s, int pid, int cc, int 
*discontinuity)
 {
 MpegTSWrite *ts = s->priv_data;
-MpegTSWriteStream *ts_st = st->priv_data;
 uint8_t *q;
 uint8_t buf[TS_PACKET_SIZE];
 
 q= buf;
 *q++ = 0x47;
-*q++ = ts_st->pid >> 8;
-*q++ = ts_st->pid;
-*q++ = 0x20 | ts_st->cc;   /* Adaptation only */
+*q++ = pid >> 8;
+*q++ = pid;
+*q++ = 0x20 | cc;   /* Adaptation only */
 /* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) 
*/
 *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
 *q++ = 0x10;   /* Adaptation flags: PCR present */
-if (ts_st->discontinuity) {
+if (discontinuity && *discontinuity) {
 q[-1] |= 0x80;
-ts_st->discontinuity = 0;
+*discontinuity = 0;
 }
 
 /* PCR coded into 6 bytes */
@@ -1143,6 +1150,12 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, 
AVStream *st)
 write_packet(s, buf);
 }
 
+static void mpegts_insert_pcr_only_for_stream(AVFormatContext *s, AVStream *st)
+{
+MpegTSWriteStream *ts_st = st->priv_data;
+mpegts_insert_pcr_only(s, ts_st->pid, ts_st->cc, _st->discontinuity);
+}
+
 static void write_pts(uint8_t *q, int fourbits, int64_t pts)
 {
 int val;
@@ -1237,6 +1250,11 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 pcr = get_pcr(ts, s->pb);
 if (pcr >= ts->next_pcr) {
 int64_t next_pcr = INT64_MAX;
+if (ts->m2ts_mode) {
+mpegts_insert_pcr_only(s, M2TS_PCR_PID, 0, NULL);
+ts->m2ts_last_pcr = FFMAX(pcr - ts->m2ts_pcr_period, 
ts->m2ts_last_pcr + ts->m2ts_pcr_period);
+next_pcr = FFMIN(next_pcr, ts->m2ts_last_pcr + 
ts->m2ts_pcr_period);
+} else {
 for (int i = 0; i < s->nb_streams; i++) {
 /* Make the current stream the last, because for that we
  * can insert the pcr into the payload later */
@@ -1247,7 +1265,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 if (pcr - ts_st2->last_pcr >= ts_st2->pcr_period) {
 ts_st2->last_pcr = FFMAX(pcr - ts_st2->pcr_period, 
ts_st2->last_pcr + ts_st2->pcr_period);
 if (st2 != st) {
-mpegts_insert_pcr_only(s, st2);
+mpegts_insert_pcr_only_for_stream(s, st2);
 pcr = get_pcr(ts, s->pb);
 } else {
 write_pcr = 1;
@@ -1256,12 +1274,13 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 next_pcr = FFMIN(next_pcr, ts_st2->last_pcr + 
ts_st2->pcr_period);
 }
 }
+}
 ts->next_pcr 

[FFmpeg-devel] [PATCH 07/10] avformat/mpegtsenc: count packets instead of using avio_tell

2019-11-12 Thread Marton Balint
Next patch needs this.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index be41311bf7..a4b28f7d74 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
 int64_t sdt_period_us;
 int64_t last_pat_ts;
 int64_t last_sdt_ts;
+int64_t nb_packets;
 
 int omit_video_pes_length;
 } MpegTSWrite;
@@ -719,7 +720,7 @@ invalid:
 
 static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
 {
-return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
+return av_rescale(ts->nb_packets * TS_PACKET_SIZE + 11, 8 * PCR_TIME_BASE, 
ts->mux_rate) +
ts->first_pcr;
 }
 
@@ -734,6 +735,7 @@ static void write_packet(AVFormatContext *s, const uint8_t 
*packet)
sizeof(tp_extra_header));
 }
 avio_write(s->pb, packet, TS_PACKET_SIZE);
+ts->nb_packets++;
 }
 
 static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 08/10] avformat/mpegtsenc: simulate a CBR stream for m2ts mode

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a4b28f7d74..2191c134ac 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -35,6 +35,7 @@
 #include "mpegts.h"
 
 #define PCR_TIME_BASE 2700
+#define M2TS_DEFAULT_MUXRATE 5400
 
 /* write DVB SI sections */
 
@@ -869,8 +870,13 @@ static int mpegts_init(AVFormatContext *s)
 ts->m2ts_subtitle_pid = 0x1200;
 ts->m2ts_other_pid= 0x1300; // should not be needed
 
-if (ts->m2ts_mode)
+if (ts->m2ts_mode) {
 ts->pmt_start_pid = 0x0100;
+if (ts->mux_rate <= 1) {
+ts->mux_rate = M2TS_DEFAULT_MUXRATE;
+av_log(s, AV_LOG_INFO, "Muxrate is not set for m2ts mode, using %d 
bps\n", ts->mux_rate);
+}
+}
 
 if (s->max_delay < 0) /* Not set by the caller */
 s->max_delay = 0;
@@ -1088,11 +1094,17 @@ static int write_pcr_bits(uint8_t *buf, int64_t pcr)
 }
 
 /* Write a single null transport stream packet */
-static void mpegts_insert_null_packet(AVFormatContext *s)
+static void mpegts_insert_null_packet(AVFormatContext *s, int force)
 {
+MpegTSWrite *ts = s->priv_data;
 uint8_t *q;
 uint8_t buf[TS_PACKET_SIZE];
 
+if (ts->m2ts_mode && !force) {
+ts->nb_packets++;
+return;
+}
+
 q= buf;
 *q++ = 0x47;
 *q++ = 0x00 | 0x1f;
@@ -1251,7 +1263,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 if (write_pcr)
 mpegts_insert_pcr_only(s, st);
 else
-mpegts_insert_null_packet(s);
+mpegts_insert_null_packet(s, 0);
 /* recalculate write_pcr and possibly retransmit si_info */
 continue;
 }
@@ -1824,7 +1836,7 @@ static void mpegts_write_flush(AVFormatContext *s)
 if (ts->m2ts_mode) {
 int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
 while (packets++ < 32)
-mpegts_insert_null_packet(s);
+mpegts_insert_null_packet(s, 1);
 }
 }
 
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 10/10] avformat/mpegtsenc: fix indentation

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index d8a74f4fe1..df015f588d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1255,26 +1255,26 @@ static void mpegts_write_pes(AVFormatContext *s, 
AVStream *st,
 ts->m2ts_last_pcr = FFMAX(pcr - ts->m2ts_pcr_period, 
ts->m2ts_last_pcr + ts->m2ts_pcr_period);
 next_pcr = FFMIN(next_pcr, ts->m2ts_last_pcr + 
ts->m2ts_pcr_period);
 } else {
-for (int i = 0; i < s->nb_streams; i++) {
-/* Make the current stream the last, because for that we
- * can insert the pcr into the payload later */
-int st2_index = i < st->index ? i : (i + 1 == 
s->nb_streams ? st->index : i + 1);
-AVStream *st2 = s->streams[st2_index];
-MpegTSWriteStream *ts_st2 = st2->priv_data;
-if (ts_st2->pcr_period) {
-if (pcr - ts_st2->last_pcr >= ts_st2->pcr_period) {
-ts_st2->last_pcr = FFMAX(pcr - ts_st2->pcr_period, 
ts_st2->last_pcr + ts_st2->pcr_period);
-if (st2 != st) {
-mpegts_insert_pcr_only_for_stream(s, st2);
-pcr = get_pcr(ts, s->pb);
-} else {
-write_pcr = 1;
+for (int i = 0; i < s->nb_streams; i++) {
+/* Make the current stream the last, because for that 
we
+ * can insert the pcr into the payload later */
+int st2_index = i < st->index ? i : (i + 1 == 
s->nb_streams ? st->index : i + 1);
+AVStream *st2 = s->streams[st2_index];
+MpegTSWriteStream *ts_st2 = st2->priv_data;
+if (ts_st2->pcr_period) {
+if (pcr - ts_st2->last_pcr >= ts_st2->pcr_period) {
+ts_st2->last_pcr = FFMAX(pcr - 
ts_st2->pcr_period, ts_st2->last_pcr + ts_st2->pcr_period);
+if (st2 != st) {
+mpegts_insert_pcr_only_for_stream(s, st2);
+pcr = get_pcr(ts, s->pb);
+} else {
+write_pcr = 1;
+}
 }
+next_pcr = FFMIN(next_pcr, ts_st2->last_pcr + 
ts_st2->pcr_period);
 }
-next_pcr = FFMIN(next_pcr, ts_st2->last_pcr + 
ts_st2->pcr_period);
 }
 }
-}
 ts->next_pcr = next_pcr;
 }
 if (dts != AV_NOPTS_VALUE && (dts - pcr / 300) > delay) {
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 05/10] avformat/mpegtsenc: add padding to m2ts streams

2019-11-12 Thread Marton Balint
6144 byte alignment is needed.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index eac0e5ab81..726e4786ad 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1774,6 +1774,7 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 
 static void mpegts_write_flush(AVFormatContext *s)
 {
+MpegTSWrite *ts = s->priv_data;
 int i;
 
 /* flush current packets */
@@ -1788,6 +1789,12 @@ static void mpegts_write_flush(AVFormatContext *s)
 ts_st->opus_queued_samples = 0;
 }
 }
+
+if (ts->m2ts_mode) {
+int packets = (avio_tell(s->pb) / (TS_PACKET_SIZE + 4)) % 32;
+while (packets++ < 32)
+mpegts_insert_null_packet(s);
+}
 }
 
 static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 03/10] avformat/mpegtsenc: move around setting m2ts_mode

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 46cfc68904..fb2e44ba20 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -850,6 +850,14 @@ static int mpegts_init(AVFormatContext *s)
 int *pids;
 int ret;
 
+if (ts->m2ts_mode == -1) {
+if (av_match_ext(s->url, "m2ts")) {
+ts->m2ts_mode = 1;
+} else {
+ts->m2ts_mode = 0;
+}
+}
+
 if (s->max_delay < 0) /* Not set by the caller */
 s->max_delay = 0;
 
@@ -1002,14 +1010,6 @@ static int mpegts_init(AVFormatContext *s)
av_rescale(ts->sdt_period, 1000, PCR_TIME_BASE),
av_rescale(ts->pat_period, 1000, PCR_TIME_BASE));
 
-if (ts->m2ts_mode == -1) {
-if (av_match_ext(s->url, "m2ts")) {
-ts->m2ts_mode = 1;
-} else {
-ts->m2ts_mode = 0;
-}
-}
-
 return 0;
 
 fail:
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 06/10] avformat/mpegtsenc: use standard pids for m2ts

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/muxers.texi |  6 --
 libavformat/mpegtsenc.c | 31 ++-
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c36ae60f19..b2fae01995 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1583,11 +1583,13 @@ Advanced Codec Digital HDTV service.
 
 @item mpegts_pmt_start_pid @var{integer}
 Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0010},
-maximum is @code{0x1ffe}.
+maximum is @code{0x1ffe}. This option has no effect in m2ts mode where the PMT
+PID is fixed @code{0x0100}.
 
 @item mpegts_start_pid @var{integer}
 Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
-@code{0x0010}, maximum is @code{0x1ffe}.
+@code{0x0010}, maximum is @code{0x1ffe}. This option has no effect in m2ts mode
+where the elementary PIDs are fixed.
 
 @item mpegts_m2ts_mode @var{boolean}
 Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 726e4786ad..be41311bf7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -94,6 +94,10 @@ typedef struct MpegTSWrite {
 int pmt_start_pid;
 int start_pid;
 int m2ts_mode;
+int m2ts_video_pid;
+int m2ts_audio_pid;
+int m2ts_subtitle_pid;
+int m2ts_other_pid;
 
 int pcr_period_ms;
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
@@ -858,6 +862,14 @@ static int mpegts_init(AVFormatContext *s)
 }
 }
 
+ts->m2ts_video_pid= 0x1011;
+ts->m2ts_audio_pid= 0x1100;
+ts->m2ts_subtitle_pid = 0x1200;
+ts->m2ts_other_pid= 0x1300; // should not be needed
+
+if (ts->m2ts_mode)
+ts->pmt_start_pid = 0x0100;
+
 if (s->max_delay < 0) /* Not set by the caller */
 s->max_delay = 0;
 
@@ -921,7 +933,24 @@ static int mpegts_init(AVFormatContext *s)
 /* MPEG pid values < 16 are reserved. Applications which set st->id in
  * this range are assigned a calculated pid. */
 if (st->id < FIRST_OTHER_PID) {
-ts_st->pid = ts->start_pid + i;
+if (ts->m2ts_mode) {
+   switch (st->codecpar->codec_type) {
+   case AVMEDIA_TYPE_VIDEO:
+   ts_st->pid = ts->m2ts_video_pid++;
+   break;
+   case AVMEDIA_TYPE_AUDIO:
+   ts_st->pid = ts->m2ts_audio_pid++;
+   break;
+   case AVMEDIA_TYPE_SUBTITLE:
+   ts_st->pid = ts->m2ts_subtitle_pid++;
+   break;
+   default:
+   ts_st->pid = ts->m2ts_other_pid++;
+   break;
+   }
+} else {
+ts_st->pid = ts->start_pid + i;
+}
 } else {
 ts_st->pid = st->id;
 }
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 01/10] avformat/mpegtsenc: allow any sensible PID for elementary and pmt pids

2019-11-12 Thread Marton Balint
Also make sure that assigned PID numbers are valid and fix the error message
for the previous PID collision checks.

Signed-off-by: Marton Balint 
---
 doc/muxers.texi |  7 ---
 libavformat/mpegts.h|  4 
 libavformat/mpegtsenc.c | 21 ++---
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 09ded7d48a..c36ae60f19 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1582,11 +1582,12 @@ Advanced Codec Digital HDTV service.
 @end table
 
 @item mpegts_pmt_start_pid @var{integer}
-Set the first PID for PMT. Default is @code{0x1000}. Max is @code{0x1f00}.
+Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0010},
+maximum is @code{0x1ffe}.
 
 @item mpegts_start_pid @var{integer}
-Set the first PID for data packets. Default is @code{0x0100}. Max is
-@code{0x0f00}.
+Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
+@code{0x0010}, maximum is @code{0x1ffe}.
 
 @item mpegts_m2ts_mode @var{boolean}
 Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index ecc3d3374c..9a7f2c1d11 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -63,6 +63,10 @@
  * streams and other data tables */
 #define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth 
padding) */
 
+/* PMT and elementary stream PID range */
+#define FIRST_OTHER_PID 0x0010
+#define  LAST_OTHER_PID 0x1FFE
+
 /* table ids */
 #define PAT_TID 0x00 /* Program Association section */
 #define CAT_TID 0x01 /* Conditional Access section */
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 9f8f1715c9..fbc7305dc1 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -912,19 +912,26 @@ static int mpegts_init(AVFormatContext *s)
 
 /* MPEG pid values < 16 are reserved. Applications which set st->id in
  * this range are assigned a calculated pid. */
-if (st->id < 16) {
+if (st->id < FIRST_OTHER_PID) {
 ts_st->pid = ts->start_pid + i;
-} else if (st->id < 0x1FFF) {
-ts_st->pid = st->id;
 } else {
+ts_st->pid = st->id;
+}
+if (ts_st->pid > LAST_OTHER_PID) {
 av_log(s, AV_LOG_ERROR,
-   "Invalid stream id %d, must be less than 8191\n", st->id);
+   "Invalid stream id %d, must be less than %d\n", st->id, 
LAST_OTHER_PID + 1);
 ret = AVERROR(EINVAL);
 goto fail;
 }
 for (j = 0; j < ts->nb_services; j++) {
+if (ts->services[j]->pmt.pid > LAST_OTHER_PID) {
+av_log(s, AV_LOG_ERROR,
+   "Invalid PMT PID %d, must be less than %d\n", 
ts->services[j]->pmt.pid, LAST_OTHER_PID + 1);
+ret = AVERROR(EINVAL);
+goto fail;
+}
 if (ts_st->pid == ts->services[j]->pmt.pid) {
-av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
ts_st->pid);
+av_log(s, AV_LOG_ERROR, "PID %d cannot be both elementary and 
PMT PID\n", ts_st->pid);
 ret = AVERROR(EINVAL);
 goto fail;
 }
@@ -1888,10 +1895,10 @@ static const AVOption options[] = {
   AV_OPT_FLAG_ENCODING_PARAM, "mpegts_service_type" },
 { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
   offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
-  { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
+  { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "mpegts_start_pid", "Set the first pid.",
   offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
-  { .i64 = 0x0100 }, 0x0010, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM },
+  { .i64 = 0x0100 }, FIRST_OTHER_PID, LAST_OTHER_PID, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "mpegts_m2ts_mode", "Enable m2ts mode.",
   offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_BOOL,
   { .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 04/10] avformat/mpegtsenc: factorize writing packet

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fb2e44ba20..eac0e5ab81 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -719,7 +719,7 @@ static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext 
*pb)
ts->first_pcr;
 }
 
-static void mpegts_prefix_m2ts_header(AVFormatContext *s)
+static void write_packet(AVFormatContext *s, const uint8_t *packet)
 {
 MpegTSWrite *ts = s->priv_data;
 if (ts->m2ts_mode) {
@@ -729,13 +729,13 @@ static void mpegts_prefix_m2ts_header(AVFormatContext *s)
 avio_write(s->pb, (unsigned char *) _extra_header,
sizeof(tp_extra_header));
 }
+avio_write(s->pb, packet, TS_PACKET_SIZE);
 }
 
 static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
 {
 AVFormatContext *ctx = s->opaque;
-mpegts_prefix_m2ts_header(ctx);
-avio_write(ctx->pb, packet, TS_PACKET_SIZE);
+write_packet(ctx, packet);
 }
 
 static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
@@ -1068,8 +1068,7 @@ static void mpegts_insert_null_packet(AVFormatContext *s)
 *q++ = 0xff;
 *q++ = 0x10;
 memset(q, 0x0FF, TS_PACKET_SIZE - (q - buf));
-mpegts_prefix_m2ts_header(s);
-avio_write(s->pb, buf, TS_PACKET_SIZE);
+write_packet(s, buf);
 }
 
 /* Write a single transport stream packet with a PCR and no payload */
@@ -1098,8 +1097,7 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, 
AVStream *st)
 
 /* stuffing bytes */
 memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
-mpegts_prefix_m2ts_header(s);
-avio_write(s->pb, buf, TS_PACKET_SIZE);
+write_packet(s, buf);
 }
 
 static void write_pts(uint8_t *q, int fourbits, int64_t pts)
@@ -1441,8 +1439,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 
 payload  += len;
 payload_size -= len;
-mpegts_prefix_m2ts_header(s);
-avio_write(s->pb, buf, TS_PACKET_SIZE);
+write_packet(s, buf);
 }
 ts_st->prev_payload_key = key;
 }
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 02/10] avformat/mpegtsenc: set priority flag for AC3 codecs if writing BluRay

2019-11-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fbc7305dc1..46cfc68904 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1237,6 +1237,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream 
*st,
 q= buf;
 *q++ = 0x47;
 val  = ts_st->pid >> 8;
+if (ts->m2ts_mode && st->codecpar->codec_id == AV_CODEC_ID_AC3)
+val |= 0x20;
 if (is_start)
 val |= 0x40;
 *q++  = val;
-- 
2.16.4

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

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

Re: [FFmpeg-devel] [PATCH 5/5 v2] avformat: add an AV1 Annex B demuxer

2019-11-12 Thread Ronald S. Bultje
Hi,

On Tue, Nov 12, 2019 at 8:09 AM James Almer  wrote:

> On 11/12/2019 2:52 AM, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Mon, Nov 11, 2019 at 9:17 PM James Almer  wrote:
> >
> >> +static int leb(AVIOContext *pb, uint32_t *len) {
> >>
> >
> >  this can overflow, should be uint64_t.
> >
> >
> >> +unsigned bits;
> >>
> >
> > Same.
> >
> > Ronald
>
> I used the same method as in dav1d, it will not overflow as it will not
> try to load more than five bytes worth leb128 data, ensuring to only
> accept up to 4 bits from the last, resulting in assembled values up to
> UINT32_MAX.


Oh, you are right, I was looking at "if (++i == 8 && more)", but the line
above it ("if (i <= 3 || (i == 4 && bits < (1 << 4)))") demonstrates
quickly that this is different. It's OK here, although a bit confusing, but
I should probably fix that in dav1d first.

Rest of patchset lgtm, and thanks for adding this feature, this is
genuinely very useful for AV1 users in more complex AV1 processing
pipelines. Section5 would be nice also ;-).

Ronald
___
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/mxfenc: correctly set width values for dvcprohd

2019-11-12 Thread Baptiste Coudurier

> On Nov 11, 2019, at 3:52 PM, Baptiste Coudurier 
>  wrote:
> 
> 
>> On Nov 11, 2019, at 3:30 PM, Tomas Härdin > > wrote:
>> 
>> lör 2019-11-09 klockan 15:46 -0800 skrev Baptiste Coudurier:
>>> ---
>>> libavformat/mxfenc.c | 15 ---
>>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
>>> index b7ae5cc637..f7df9c3daf 100644
>>> --- a/libavformat/mxfenc.c
>>> +++ b/libavformat/mxfenc.c
>>> @@ -1092,7 +1092,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext 
>>> *s, AVStream *st, const UID
>>> {
>>> MXFStreamContext *sc = st->priv_data;
>>> AVIOContext *pb = s->pb;
>>> -int stored_width  = (st->codecpar->width +15)/16*16;
>>> +int stored_width = 0;
>>> int stored_height = (st->codecpar->height+15)/16*16;
>>> int display_height;
>>> int f1, f2;
>>> @@ -1101,6 +1101,15 @@ static int64_t mxf_write_cdci_common(AVFormatContext 
>>> *s, AVStream *st, const UID
>>> 
>>> get_trc(transfer_ul, st->codecpar->color_trc);
>>> 
>>> +if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) {
>>> +if (st->codecpar->height == 1080)
>>> +stored_width = 1920;
>>> +else if (st->codecpar->height == 720)
>>> +stored_width = 1280;
>> 
>> What about the other DV variants?
> 
> These get default value
> 
>>> +}
>>> +if (!stored_width)
>>> +stored_width = (st->codecpar->width+15)/16*16;
>> 
>> Shouldn't this have SAR applied?
> 
> I didn’t change this, the code was like that before
> 

Will apply

— 
Baptiste

___
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/mxfenc: simplify d-10 ul handling

2019-11-12 Thread Baptiste Coudurier

> On Nov 9, 2019, at 3:46 PM, Baptiste Coudurier  
> wrote:
> 
> ---
> libavformat/mxfenc.c | 110 ---
> 1 file changed, 41 insertions(+), 69 deletions(-)
> 

Will apply

— 
Baptiste

___
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/dvenc: support encoding dvcprohd

2019-11-12 Thread Baptiste Coudurier

> On Nov 9, 2019, at 4:11 PM, Baptiste Coudurier  
> wrote:
> 
> ---
> libavcodec/dv.h |   1 +
> libavcodec/dvenc.c  | 561 
> tests/fate/vcodec.mak   |  14 +-
> tests/ref/vsynth/vsynth1-dv-fhd |   4 +
> tests/ref/vsynth/vsynth1-dv-hd  |   4 +
> tests/ref/vsynth/vsynth2-dv-fhd |   4 +
> tests/ref/vsynth/vsynth2-dv-hd  |   4 +
> tests/ref/vsynth/vsynth3-dv-fhd |   4 +
> tests/ref/vsynth/vsynth3-dv-hd  |   4 +
> 9 files changed, 541 insertions(+), 59 deletions(-)
> create mode 100644 tests/ref/vsynth/vsynth1-dv-fhd
> create mode 100644 tests/ref/vsynth/vsynth1-dv-hd
> create mode 100644 tests/ref/vsynth/vsynth2-dv-fhd
> create mode 100644 tests/ref/vsynth/vsynth2-dv-hd
> create mode 100644 tests/ref/vsynth/vsynth3-dv-fhd
> create mode 100644 tests/ref/vsynth/vsynth3-dv-hd
> 

Will apply

— 
Baptiste

___
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] lavf/mov: initial support for reading HEIF images

2019-11-12 Thread Dale Curtis
On Tue, Nov 12, 2019 at 1:27 AM Carl Eugen Hoyos  wrote:

> > Breaks AVIFS files
> > that were previously demuxing as mp4 w/ video track,
>
> Does it only break them once above change was made or also in the existing
> patch?
> (Sorry, I am still travelling in Japan without computer.)
>

Only after I've added AV1 support. However, I suspect HEVC tracks would be
busted in a similar manner.


>
> > i.e.,
> >
> https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs
> .
> > As such might end up causing some client issues for MP4s that had
> embedded
> > pict elements, but are not HEIF/AVIF - since they'll suddenly start
> > surfacing new tracks.
>
> Can such files easily be detected?
>

Possibly, HEIF/AVIF should declare their brands up front, while a standard
MP4 w/ an embedded PICT or something, probably won't have that. Though I
don't have any samples that would trigger this.
___
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 v4] avcodec: add an AV1 frame merge bitstream filter

2019-11-12 Thread James Almer
Signed-off-by: James Almer 
---
Now using an index to swap fragments.

I noticed that the input packet containing props is not necessarily the first
in a TU, so adapted the code accordingly. This fixes warnings about missing
timestamps when trying to merge the output of av1_frame_split, where the source
had the visible frames at the end of a TU rather than at the beginning.

Not going to bother with indexes for the packets. av_packet_move_ref() is far
from expensive, unlike creating buffer references and expanding the fragment's
unit buffer.

 configure|   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/av1_frame_merge_bsf.c | 169 +++
 libavcodec/bitstream_filters.c   |   1 +
 4 files changed, 172 insertions(+)
 create mode 100644 libavcodec/av1_frame_merge_bsf.c

diff --git a/configure b/configure
index 1de90e93fd..70f60997c1 100755
--- a/configure
+++ b/configure
@@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
+av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
 eac3_core_bsf_select="ac3_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b990c6ba87..006a472a6d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
 # bitstream filters
 OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o mpeg4audio.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
+OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
 OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c
new file mode 100644
index 00..96a9e6e863
--- /dev/null
+++ b/libavcodec/av1_frame_merge_bsf.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2019 James Almer 
+ *
+ * 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 "avcodec.h"
+#include "bsf.h"
+#include "cbs.h"
+#include "cbs_av1.h"
+
+typedef struct AV1FMergeContext {
+CodedBitstreamContext *cbc;
+CodedBitstreamFragment frag[2];
+AVPacket *pkt, *in;
+int idx;
+} AV1FMergeContext;
+
+static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
+{
+AV1FMergeContext *ctx = bsf->priv_data;
+CodedBitstreamFragment *frag = >frag[ctx->idx], *tu = 
>frag[!ctx->idx];
+AVPacket *in = ctx->in, *buffer_pkt = ctx->pkt;
+int err, i;
+
+err = ff_bsf_get_packet_ref(bsf, in);
+if (err < 0) {
+if (err == AVERROR_EOF && tu->nb_units > 0)
+goto eof;
+return err;
+}
+
+err = ff_cbs_read_packet(ctx->cbc, frag, in);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+goto fail;
+}
+
+if (frag->nb_units == 0) {
+av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+if (tu->nb_units == 0 && frag->units[0].type != 
AV1_OBU_TEMPORAL_DELIMITER) {
+av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+if (tu->nb_units > 0 && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) 
{
+eof:
+err = ff_cbs_write_packet(ctx->cbc, buffer_pkt, tu);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+goto fail;
+}
+av_packet_move_ref(out, buffer_pkt);
+
+ff_cbs_fragment_reset(ctx->cbc, tu);
+
+for (i = 1; i < frag->nb_units; i++) {
+if (frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
+av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of 
a packet.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+}
+// Swap fragment index, to avoid copying fragment references.
+ctx->idx = !ctx->idx;
+
+// Buffer the packet if it has a timestamp.
+if (in->pts != AV_NOPTS_VALUE)
+

Re: [FFmpeg-devel] [PATCH 2/5 v3] avcodec: add an AV1 frame merge BSF

2019-11-12 Thread James Almer
On 11/12/2019 12:33 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer 
>> ---
>> Assorted improvements to avoid creating new references, copying packet
>> properties, etc.
>>
>>  configure|   1 +
>>  libavcodec/Makefile  |   1 +
>>  libavcodec/av1_frame_merge_bsf.c | 173 +++
>>  libavcodec/bitstream_filters.c   |   1 +
>>  4 files changed, 176 insertions(+)
>>  create mode 100644 libavcodec/av1_frame_merge_bsf.c
>>
>> diff --git a/configure b/configure
>> index 1de90e93fd..70f60997c1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
>>  
>>  # bitstream_filters
>>  aac_adtstoasc_bsf_select="adts_header"
>> +av1_frame_merge_bsf_select="cbs_av1"
>>  av1_frame_split_bsf_select="cbs_av1"
>>  av1_metadata_bsf_select="cbs_av1"
>>  eac3_core_bsf_select="ac3_parser"
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index b990c6ba87..006a472a6d 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
>>  # bitstream filters
>>  OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o 
>> mpeg4audio.o
>>  OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
>> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
>>  OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
>>  OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
>>  OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
>> diff --git a/libavcodec/av1_frame_merge_bsf.c 
>> b/libavcodec/av1_frame_merge_bsf.c
>> new file mode 100644
>> index 00..a2cb09b55e
>> --- /dev/null
>> +++ b/libavcodec/av1_frame_merge_bsf.c
>> @@ -0,0 +1,173 @@
>> +/*
>> + * Copyright (c) 2019 James Almer 
>> + *
>> + * 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 "avcodec.h"
>> +#include "bsf.h"
>> +#include "cbs.h"
>> +#include "cbs_av1.h"
>> +
>> +typedef struct AV1FMergeContext {
>> +CodedBitstreamContext *cbc;
>> +CodedBitstreamFragment *temporal_unit;
>> +CodedBitstreamFragment *frag;
> 
> I actually meant CodedBitstreamFragment frag[2] together with an index
> that tells which one is which. av1_frame_merge_filter() would then
> contain this declaration:
> 
> CodedBitstreamFragment *frag = >frag[ctx->idx], *tu =
> >frag[!ctx->idx];
> 
> And swapping the roles would simply amount to ctx->idx = !ctx->idx;

Alright, sounds good.
___
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/5 v3] avcodec: add an AV1 frame merge BSF

2019-11-12 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
> Assorted improvements to avoid creating new references, copying packet
> properties, etc.
> 
>  configure|   1 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/av1_frame_merge_bsf.c | 173 +++
>  libavcodec/bitstream_filters.c   |   1 +
>  4 files changed, 176 insertions(+)
>  create mode 100644 libavcodec/av1_frame_merge_bsf.c
> 
> diff --git a/configure b/configure
> index 1de90e93fd..70f60997c1 100755
> --- a/configure
> +++ b/configure
> @@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
>  
>  # bitstream_filters
>  aac_adtstoasc_bsf_select="adts_header"
> +av1_frame_merge_bsf_select="cbs_av1"
>  av1_frame_split_bsf_select="cbs_av1"
>  av1_metadata_bsf_select="cbs_av1"
>  eac3_core_bsf_select="ac3_parser"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index b990c6ba87..006a472a6d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
>  # bitstream filters
>  OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o mpeg4audio.o
>  OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
> +OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
>  OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
>  OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
>  OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
> diff --git a/libavcodec/av1_frame_merge_bsf.c 
> b/libavcodec/av1_frame_merge_bsf.c
> new file mode 100644
> index 00..a2cb09b55e
> --- /dev/null
> +++ b/libavcodec/av1_frame_merge_bsf.c
> @@ -0,0 +1,173 @@
> +/*
> + * Copyright (c) 2019 James Almer 
> + *
> + * 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 "avcodec.h"
> +#include "bsf.h"
> +#include "cbs.h"
> +#include "cbs_av1.h"
> +
> +typedef struct AV1FMergeContext {
> +CodedBitstreamContext *cbc;
> +CodedBitstreamFragment *temporal_unit;
> +CodedBitstreamFragment *frag;

I actually meant CodedBitstreamFragment frag[2] together with an index
that tells which one is which. av1_frame_merge_filter() would then
contain this declaration:

CodedBitstreamFragment *frag = >frag[ctx->idx], *tu =
>frag[!ctx->idx];

And swapping the roles would simply amount to ctx->idx = !ctx->idx;

> +AVPacket *buffer_pkt;
> +AVPacket *in;

Similarly, AVPacket *buffer_pkt[2] can be used to remove
av_packet_move_ref().

> +} AV1FMergeContext;
> +
> +static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
> +{
> +AV1FMergeContext *ctx = bsf->priv_data;
> +CodedBitstreamFragment *frag = ctx->frag, *tu = ctx->temporal_unit;
> +int err, i;
> +
> +err = ff_bsf_get_packet_ref(bsf, ctx->in);
> +if (err < 0) {
> +if (err == AVERROR_EOF && tu->nb_units > 0)
> +goto eof;
> +return err;
> +}
> +
> +err = ff_cbs_read_packet(ctx->cbc, frag, ctx->in);
> +if (err < 0) {
> +av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
> +goto fail;
> +}
> +
> +if (frag->nb_units == 0) {
> +av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
> +err = AVERROR_INVALIDDATA;
> +goto fail;
> +}
> +
> +if (tu->nb_units == 0) {
> +if (frag->units[0].type != AV1_OBU_TEMPORAL_DELIMITER) {
> +av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n");
> +err = AVERROR_INVALIDDATA;
> +goto fail;
> +}
> +av_packet_move_ref(ctx->buffer_pkt, ctx->in);
> +}
> +
> +if (tu->nb_units > 0 && frag->units[0].type == 
> AV1_OBU_TEMPORAL_DELIMITER) {
> +eof:
> +err = ff_cbs_write_packet(ctx->cbc, ctx->buffer_pkt, tu);
> +if (err < 0) {
> +av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
> +goto fail;
> +}
> +av_packet_move_ref(out, ctx->buffer_pkt);
> +
> +ff_cbs_fragment_reset(ctx->cbc, tu);
> +
> +for (i = 1; i < frag->nb_units; i++) {
> +if (frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
> +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle 
> of a 

Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Fu, Linjie
Hi,

> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xinpeng Sun
> Sent: Tuesday, November 12, 2019 17:00
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for
> H2S
> 
> It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> conversion
> with tone-mapping. It supports HDR10 only as input temporarily.
> 
> H2S: P010 -> NV12
> 
> An example command to use this filter with vaapi codecs:
> FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -
> hwaccel_output_format vaapi \
> -i INPUT -vf 'tonemap_vaapi=h2s,hwdownload,format=nv12' -pix_fmt nv12 \
> -f rawvideo -y OUTPUT
> 
> Signed-off-by: Xinpeng Sun 
> Signed-off-by: Zachary Zhou 
> ---
>  doc/filters.texi   |  30 
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vaapi_vpp.c|   5 +
>  libavfilter/vf_tonemap_vaapi.c | 272
> +
>  5 files changed, 309 insertions(+)
>  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6800124574..b1c466ba24 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -20754,6 +20754,36 @@ Convert HDR(PQ/HLG) video to bt2020-transfer-
> characteristic p010 format using li
>  @end example
>  @end itemize
> 
> +@section tonemap_vappi
> +
> +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range)
> conversion with tone-mapping.
> +It maps the dynamic range of HDR10 content to the SDR content.
> +It only accepts HDR10 as input temporarilly.

Typo:
temporarilly  -> temporarily 

> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item type
> +Specify the tone-mapping operator to be used.
> +
> +Possible values are:
> +@table @var
> +@item h2s
> +Perform H2S(HDR to SDR), convert from p010 to nv12
> +@end table
> +
> +@end table
> +
> +@subsection Example
> +
> +@itemize
> +@item
> +Convert HDR video to SDR video from p010 format to nv12 format.
> +@example
> +-i INPUT -vf "tonemap_vaapi=h2s" OUTPUT
> +@end example
> +@end itemize
> +
>  @section unsharp_opencl
> 
>  Sharpen or blur the input video.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fce930360d..90a0e9945e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -410,6 +410,7 @@ OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o
> framesync.o
>  OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o colorspace.o
>  OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o
> colorspace.o opencl.o \
>  opencl/tonemap.o 
> opencl/colorspace_common.o
> +OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER)  += vf_tonemap_vaapi.o
> vaapi_vpp.o
>  OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
>  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
>  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 7c1e19e1da..b2fb1f8a98 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -390,6 +390,7 @@ extern AVFilter ff_vf_tlut2;
>  extern AVFilter ff_vf_tmix;
>  extern AVFilter ff_vf_tonemap;
>  extern AVFilter ff_vf_tonemap_opencl;
> +extern AVFilter ff_vf_tonemap_vaapi;
>  extern AVFilter ff_vf_tpad;
>  extern AVFilter ff_vf_transpose;
>  extern AVFilter ff_vf_transpose_npp;
> diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> index b5b245c8af..5776243fa0 100644
> --- a/libavfilter/vaapi_vpp.c
> +++ b/libavfilter/vaapi_vpp.c
> @@ -257,6 +257,11 @@ static const VAAPIColourProperties
> vaapi_colour_standard_map[] = {
>  { VAProcColorStandardSMPTE170M,   6,  6,  6 },
>  { VAProcColorStandardSMPTE240M,   7,  7,  7 },
>  { VAProcColorStandardGenericFilm, 8,  1,  1 },
> +
> +#if VA_CHECK_VERSION(2, 3, 0)

VA-API version should be checked instead of LIBVA version, 
and I believe what you mean is (1,3,0) since the latest libva version
is (1, 6, 0).

> +{ VAProcColorStandardExplicit,9,  16, AVCOL_SPC_BT2020_NCL},
> +#endif
> +
>  #if VA_CHECK_VERSION(1, 1, 0)
>  { VAProcColorStandardSRGB,1, 13,  0 },
>  { VAProcColorStandardXVYCC601,1, 11,  5 },
> diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
> new file mode 100644
> index 00..27ee17bf00
> --- /dev/null
> +++ b/libavfilter/vf_tonemap_vaapi.c
> @@ -0,0 +1,272 @@
> +/*
> + * 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
> + * 

[FFmpeg-devel] [PATCH 2/5 v3] avcodec: add an AV1 frame merge BSF

2019-11-12 Thread James Almer
Signed-off-by: James Almer 
---
Assorted improvements to avoid creating new references, copying packet
properties, etc.

 configure|   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/av1_frame_merge_bsf.c | 173 +++
 libavcodec/bitstream_filters.c   |   1 +
 4 files changed, 176 insertions(+)
 create mode 100644 libavcodec/av1_frame_merge_bsf.c

diff --git a/configure b/configure
index 1de90e93fd..70f60997c1 100755
--- a/configure
+++ b/configure
@@ -3115,6 +3115,7 @@ vc1_parser_select="vc1dsp"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
+av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
 eac3_core_bsf_select="ac3_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b990c6ba87..006a472a6d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1075,6 +1075,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
 # bitstream filters
 OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o mpeg4audio.o
 OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
+OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= av1_frame_merge_bsf.o
 OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= av1_frame_split_bsf.o
 OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c
new file mode 100644
index 00..a2cb09b55e
--- /dev/null
+++ b/libavcodec/av1_frame_merge_bsf.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2019 James Almer 
+ *
+ * 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 "avcodec.h"
+#include "bsf.h"
+#include "cbs.h"
+#include "cbs_av1.h"
+
+typedef struct AV1FMergeContext {
+CodedBitstreamContext *cbc;
+CodedBitstreamFragment *temporal_unit;
+CodedBitstreamFragment *frag;
+AVPacket *buffer_pkt;
+AVPacket *in;
+} AV1FMergeContext;
+
+static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
+{
+AV1FMergeContext *ctx = bsf->priv_data;
+CodedBitstreamFragment *frag = ctx->frag, *tu = ctx->temporal_unit;
+int err, i;
+
+err = ff_bsf_get_packet_ref(bsf, ctx->in);
+if (err < 0) {
+if (err == AVERROR_EOF && tu->nb_units > 0)
+goto eof;
+return err;
+}
+
+err = ff_cbs_read_packet(ctx->cbc, frag, ctx->in);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
+goto fail;
+}
+
+if (frag->nb_units == 0) {
+av_log(bsf, AV_LOG_ERROR, "No OBU in packet.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+if (tu->nb_units == 0) {
+if (frag->units[0].type != AV1_OBU_TEMPORAL_DELIMITER) {
+av_log(bsf, AV_LOG_ERROR, "Missing Temporal Delimiter.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+av_packet_move_ref(ctx->buffer_pkt, ctx->in);
+}
+
+if (tu->nb_units > 0 && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) 
{
+eof:
+err = ff_cbs_write_packet(ctx->cbc, ctx->buffer_pkt, tu);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
+goto fail;
+}
+av_packet_move_ref(out, ctx->buffer_pkt);
+
+ff_cbs_fragment_reset(ctx->cbc, tu);
+
+for (i = 1; i < frag->nb_units; i++) {
+if (frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
+av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of 
a packet.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+}
+// Swap pointers to avoid copying unit content.
+ctx->temporal_unit = frag;
+ctx->frag = tu;
+
+av_packet_move_ref(ctx->buffer_pkt, ctx->in);
+
+return 0;
+}
+
+for (i = 0; i < frag->nb_units; i++) {
+if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
+av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of a 
packet.\n");
+err = AVERROR_INVALIDDATA;
+goto fail;
+}
+err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, 

Re: [FFmpeg-devel] [PATCH] avutil/eval: add function to track variable use

2019-11-12 Thread Gyan



On 09-11-2019 09:39 pm, Michael Niedermayer wrote:

On Tue, Nov 05, 2019 at 06:35:54PM +0530, Gyan wrote:


On 05-11-2019 03:55 pm, Michael Niedermayer wrote:

On Tue, Nov 05, 2019 at 10:13:52AM +0530, Gyan wrote:

On 05-11-2019 04:35 am, Michael Niedermayer wrote:

On Sun, Nov 03, 2019 at 11:14:25AM +0530, Gyan wrote:

Helps better identification of expr eval failures.

Gyan
  eval.c|   21 +
  eval.h|   10 ++
  version.h |4 ++--
  3 files changed, 33 insertions(+), 2 deletions(-)
3dd142baa0144fd324eb9da8a9932cfd7ab2cd98  
0001-avutil-eval-add-function-to-track-variable-use.patch
 From 19bce329464676f071707b99575f80e5abe1cd4c Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 2 Nov 2019 20:16:42 +0530
Subject: [PATCH] avutil/eval: add function to track variable use

Helps avoid multiple evals of cross-referenced expressions
and catch the use of non-applicable variables with respect
to eval or special mode in filters

Maybe you should provide more details of the use case of this, maybe
with an example. Because it seems not completely obvious

An example of a cross-referenced expression would be 'y=x+rand(10)'.
Normally in filters, X would be evaluated first, then Y, then X again. The
2nd eval of X will overwrite the first and can generate a different value.
With this func, we can avoid the 2nd eval.

I'm in the process of modifying the scale filter to allow 'n', 't', 'pos'
variables in frame eval mode (it already supports dynamic output based on
incoming frame changes) and I would like to catch their presence in init
mode, since av_expr_eval will fail. Now, it can also fail due to circularly
referenced expressions e.g. 'x=y+10' and 'y=x+10' and there's no way to
detect whether it's this case or if inapplicable variables have been used.

please add this (or similar information) to the commit message

Done.

Thanks,
Gyan
  eval.c|   21 +
  eval.h|   10 ++
  version.h |4 ++--
  3 files changed, 33 insertions(+), 2 deletions(-)
740f6166ddb4b1a581aee7c34edd05d328265df1  
v2-0001-avutil-eval-add-function-to-track-variable-use.patch
 From 2931fa96b8e7f80581ded280907655753e54def0 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 2 Nov 2019 20:16:42 +0530
Subject: [PATCH v2 1/2] avutil/eval: add function to track variable use

i think the patch is ok but i think nicolas wants to wait
with pushing this until there is a 2nd patch which uses the new
function


Scale patch posted -  https://patchwork.ffmpeg.org/patch/16222/

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

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

[FFmpeg-devel] [PATCH] avfilter/scale: allow dynamic output via expressions

2019-11-12 Thread Gyan
This patch relies on the proposed addition to the eval API at 
https://patchwork.ffmpeg.org/patch/16109/


FATE passes.

Gyan
From a435e1ba5455cec67df16db85d5c47f7e4cd9797 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Tue, 12 Nov 2019 19:04:54 +0530
Subject: [PATCH] avfilter/scale: allow dynamic output via expressions

At present, dynamic output can be had from scale and scale2ref
filters by sending commands or varying the resolution of the
input (in scale) or reference stream (in scale2ref). This is
unwieldy when an interpolated or otherwise animated output is
desired.

This commit introduces standard temporal variables that can be used
in width and height expressions, so dynamic output can be configured
at initialization or via commands. In order to achieve this, external
dependency on libavfilter/scale.c has been removed and equivalent
functionality introduced inline.

Such varying output ought to be sent to filters which can
accommodate them, such as the overlay filter.
---
 libavfilter/Makefile   |   4 +-
 libavfilter/scale.c|  72 +--
 libavfilter/vf_scale.c | 436 +
 3 files changed, 408 insertions(+), 104 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fce930360d..f1f6994574 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -358,12 +358,12 @@ OBJS-$(CONFIG_ROBERTS_OPENCL_FILTER) += 
vf_convolution_opencl.o opencl.o
 opencl/convolution.o
 OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o
 OBJS-$(CONFIG_SAB_FILTER)+= vf_sab.o
-OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o scale.o
+OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o
 OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o 
vf_scale_cuda.ptx.o
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o 
vaapi_vpp.o
-OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale.o
+OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o
 OBJS-$(CONFIG_SCROLL_FILTER) += vf_scroll.o
 OBJS-$(CONFIG_SELECT_FILTER) += f_select.o
 OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o
diff --git a/libavfilter/scale.c b/libavfilter/scale.c
index eaee95fac6..668aa04622 100644
--- a/libavfilter/scale.c
+++ b/libavfilter/scale.c
@@ -60,49 +60,6 @@ enum var_name {
 VARS_NB
 };
 
-/**
- * This must be kept in sync with var_names so that it is always a
- * complete list of var_names with the scale2ref specific names
- * appended. scale2ref values must appear in the order they appear
- * in the var_name_scale2ref enum but also be below all of the
- * non-scale2ref specific values.
- */
-static const char *const var_names_scale2ref[] = {
-"PI",
-"PHI",
-"E",
-"in_w",   "iw",
-"in_h",   "ih",
-"out_w",  "ow",
-"out_h",  "oh",
-"a",
-"sar",
-"dar",
-"hsub",
-"vsub",
-"ohsub",
-"ovsub",
-"main_w",
-"main_h",
-"main_a",
-"main_sar",
-"main_dar", "mdar",
-"main_hsub",
-"main_vsub",
-NULL
-};
-
-enum var_name_scale2ref {
-VAR_S2R_MAIN_W,
-VAR_S2R_MAIN_H,
-VAR_S2R_MAIN_A,
-VAR_S2R_MAIN_SAR,
-VAR_S2R_MAIN_DAR, VAR_S2R_MDAR,
-VAR_S2R_MAIN_HSUB,
-VAR_S2R_MAIN_VSUB,
-VARS_S2R_NB
-};
-
 int ff_scale_eval_dimensions(void *log_ctx,
 const char *w_expr, const char *h_expr,
 AVFilterLink *inlink, AVFilterLink *outlink,
@@ -115,16 +72,7 @@ int ff_scale_eval_dimensions(void *log_ctx,
 int factor_w, factor_h;
 int eval_w, eval_h;
 int ret;
-const char scale2ref = outlink->src->nb_inputs == 2 && 
outlink->src->inputs[1] == inlink;
-double var_values[VARS_NB + VARS_S2R_NB], res;
-const AVPixFmtDescriptor *main_desc;
-const AVFilterLink *main_link;
-const char *const *names = scale2ref ? var_names_scale2ref : var_names;
-
-if (scale2ref) {
-main_link = outlink->src->inputs[0];
-main_desc = av_pix_fmt_desc_get(main_link->format);
-}
+double var_values[VARS_NB], res;
 
 var_values[VAR_PI]= M_PI;
 var_values[VAR_PHI]   = M_PHI;
@@ -142,32 +90,20 @@ int ff_scale_eval_dimensions(void *log_ctx,
 var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
 var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
 
-if (scale2ref) {
-var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w;
-var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h;
-var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w / 
main_link->h;
-var_values[VARS_NB + VAR_S2R_MAIN_SAR] = 
main_link->sample_aspect_ratio.num ?
-(double) main_link->sample_aspect_ratio.num / 
main_link->sample_aspect_ratio.den : 1;
-var_values[VARS_NB + VAR_S2R_MAIN_DAR] = 

Re: [FFmpeg-devel] [PATCH 5/5 v2] avformat: add an AV1 Annex B demuxer

2019-11-12 Thread James Almer
On 11/12/2019 2:52 AM, Ronald S. Bultje wrote:
> Hi,
> 
> On Mon, Nov 11, 2019 at 9:17 PM James Almer  wrote:
> 
>> +static int leb(AVIOContext *pb, uint32_t *len) {
>>
> 
>  this can overflow, should be uint64_t.
> 
> 
>> +unsigned bits;
>>
> 
> Same.
> 
> Ronald

I used the same method as in dav1d, it will not overflow as it will not
try to load more than five bytes worth leb128 data, ensuring to only
accept up to 4 bits from the last, resulting in assembled values up to
UINT32_MAX.

> ___
> 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 V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Paul B Mahol
If this filter is same speed or better than boxblur, it should replace
boxblur filter, as boxblur filter is GPL.

On 11/12/19, myp...@gmail.com  wrote:
> On Tue, Nov 12, 2019 at 5:37 PM Paul B Mahol  wrote:
>>
>> Isn't this same as boxblur?
>>
> After going deep into the boxblur, I think the superfastblur same as
> the boxblur, please ignore the patch, thx.
>> On 11/12/19, Steven Liu  wrote:
>> >
>> >
>> >> 在 2019年11月12日,15:51,Jun Zhao  写道:
>> >>
>> >> From: Jun Zhao 
>> >>
>> >> add superfastblur filter
>> >>
>> >> Signed-off-by: Jun Zhao 
>> >> ---
>> >> doc/filters.texi   |   15 ++
>> >> libavfilter/Makefile   |1 +
>> >> libavfilter/allfilters.c   |1 +
>> >> libavfilter/vf_superfastblur.c |  275
>> >> 
>> >> 4 files changed, 292 insertions(+), 0 deletions(-)
>> >> create mode 100644 libavfilter/vf_superfastblur.c
>> >>
>> >> diff --git a/doc/filters.texi b/doc/filters.texi
>> >> index 6800124..c7d1893 100644
>> >> --- a/doc/filters.texi
>> >> +++ b/doc/filters.texi
>> >> @@ -17453,6 +17453,21 @@ Interpolate) pixel art scaling algorithm.
>> >>
>> >> Useful for enlarging pixel art images without reducing sharpness.
>> >>
>> >> +@section superfastblur
>> >> +
>> >> +Blur the input image with super fast blur algorithm, multiple
>> >> invocations
>> >> of this
>> >> +filter with a small radius will approximate a gaussian blur quite
>> >> well.
>> >> +
>> >> +This filter accepts the following options:
>> >> +
>> >> +@table @option
>> >> +@item radius
>> >> +@item r
>> >> +Set the blurring box radius. The option value must be a int number in
>> >> +the range [1, 10] that specifies the blur box size of the superfast
>> >> blur
>> >> filter
>> >> +used to blur the image. Default value is @code{2}..
>> >> +@end table
>> >> +
>> >> @section swaprect
>> >>
>> >> Swap two rectangular objects in video.
>> >> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> >> index fce9303..db4d5e6 100644
>> >> --- a/libavfilter/Makefile
>> >> +++ b/libavfilter/Makefile
>> >> @@ -396,6 +396,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER)   +=
>> >> vf_stereo3d.o
>> >> OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o
>> >> framesync.o
>> >> OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
>> >> OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
>> >> +OBJS-$(CONFIG_SUPEREQUALIZER_FILTER) += vf_superfastblur.o
>> >> OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
>> >> OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
>> >> OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o
>> >> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
>> >> index 7c1e19e..d507bc5 100644
>> >> --- a/libavfilter/allfilters.c
>> >> +++ b/libavfilter/allfilters.c
>> >> @@ -377,6 +377,7 @@ extern AVFilter ff_vf_stereo3d;
>> >> extern AVFilter ff_vf_streamselect;
>> >> extern AVFilter ff_vf_subtitles;
>> >> extern AVFilter ff_vf_super2xsai;
>> >> +extern AVFilter ff_vf_superfastblur;
>> >> extern AVFilter ff_vf_swaprect;
>> >> extern AVFilter ff_vf_swapuv;
>> >> extern AVFilter ff_vf_tblend;
>> >> diff --git a/libavfilter/vf_superfastblur.c
>> >> b/libavfilter/vf_superfastblur.c
>> >> new file mode 100644
>> >> index 000..a6428cf
>> >> --- /dev/null
>> >> +++ b/libavfilter/vf_superfastblur.c
>> >> @@ -0,0 +1,275 @@
>> >> +/*
>> >> + * Copyright (c) 2019 Jun Zhao
>> >> + *
>> >> + * This file is part of FFmpeg.
>> >> + *
>> >> + * FFmpeg is free software; you can redistribute it and/or
>> >> + * modify it under the terms of the GNU Lesser General Public
>> >> + * License as published by the Free Software Foundation; either
>> >> + * version 2.1 of the License, or (at your option) any later version.
>> >> + *
>> >> + * FFmpeg is distributed in the hope that it will be useful,
>> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> >> + * Lesser General Public License for more details.
>> >> + *
>> >> + * You should have received a copy of the GNU Lesser General Public
>> >> + * License along with FFmpeg; if not, write to the Free Software
>> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> >> 02110-1301 USA
>> >> + */
>> >> +
>> >> +/**
>> >> + * @file
>> >> + * Super fast blur filter
>> >> + *
>> >> + * @see http://incubator.quasimondo.com/processing/superfast_blur.php
>> >> + */
>> >> +
>> >> +#include "libavutil/avassert.h"
>> >> +#include "libavutil/imgutils.h"
>> >> +#include "libavutil/opt.h"
>> >> +#include "avfilter.h"
>> >> +#include "formats.h"
>> >> +#include "internal.h"
>> >> +#include "video.h"
>> >> +
>> >> +typedef struct SuperFastBlurContext {
>> >> +const AVClass *class;
>> >> +
>> >> +int radius;
>> >> +
>> >> +uint32_t *vMIN;
>> >> +uint32_t *vMAX;
>> >> +
>> >> +uint8_t *r;
>> >> +uint8_t *g;
>> >> +uint8_t 

Re: [FFmpeg-devel] [PATCH 2/5 V2] avcodec: add an AV1 frame merge bitstream filter

2019-11-12 Thread Andreas Rheinhardt
James Almer:
> On 11/11/2019 8:36 PM, James Almer wrote:
 +for (i = 0; i < frag->nb_units; i++) {
 +if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
 +av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle 
 of a packet.\n");
 +err = AVERROR_INVALIDDATA;
 +goto fail;
 +}
 +err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, 
 frag->units[i].type,
 + frag->units[i].content, 
 frag->units[i].content_ref);
>>> You make new references to content and then immediately thereafter
>>> unref the old ones. How about adding a function that moves a unit (or
>>> several units at once) from one fragment to another?
>> A new function that moves units sounds good. Shouldn't be hard to
>> implement either, i think.
> 
> So a unit move function would require a memcpy for the unit from one
> fragment to another, a memset to 0 on the source unit, then a call to
> ff_cbs_delete_unit() which memmoves the remaining units to fill the gap
> created by the removed one, if any. I don't know if it's that much
> better than this current implementation creating a new AVBufferRef per
> unit, then wiping the whole source fragment in one go.

On second thought I think that it's not worth the effort here. After
all, said function needs to be cbs-internal any way (it has to make
sure that there is enough space in the destination array and for this
it needs to examine and possibly modify the number of allocated units)
and therefore it should not be a simple "move a whole fragment to the
end of another fragment" (that's what I had in mind and this would be
pretty simple to implement and also pretty fast as no remaining units
needed to be moved).

But for the other place where you move units, nothing beats simply
swapping the roles of the two fragments.

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

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

Re: [FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_libvmaf: Check for av_frame_alloc failure

2019-11-12 Thread Paul B Mahol
LGTM

On 11/12/19, lance.lmw...@gmail.com  wrote:
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_libvmaf.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
> index ed3a383..14c3216 100644
> --- a/libavfilter/vf_libvmaf.c
> +++ b/libavfilter/vf_libvmaf.c
> @@ -235,6 +235,9 @@ static av_cold int init(AVFilterContext *ctx)
>
>  s->gref = av_frame_alloc();
>  s->gmain = av_frame_alloc();
> +if (!s->gref || !s->gmain)
> +return AVERROR(ENOMEM);
> +
>  s->error = 0;
>
>  s->vmaf_thread_created = 0;
> --
> 2.9.5
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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] [PATCH] avcodec: Add more kCVImageBufferColorPrimaries to videotoolboxenc

2019-11-12 Thread Nomis101
Videotoolbox currently only supports the color primaries gamut ITU R 709 and 
2020. This patch adds support for EBU 3213 (PAL video) and SMPTE C (standard 
definition video). That is importand for video
convertion applications, based on FFmpeg. Would be nice to get this reviewed.


Am 03.11.19 um 01:20 schrieb Nomis101:
> ---
>  libavcodec/videotoolboxenc.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 40a7f643e0..cc08cf6a50 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -894,6 +894,14 @@ static int get_cv_color_primaries(AVCodecContext *avctx,
>  *primaries = NULL;
>  break;
>
> +case AVCOL_PRI_BT470BG:
> +*primaries = kCVImageBufferColorPrimaries_EBU_3213;
> +break;
> +
> +case AVCOL_PRI_SMPTE170M:
> +*primaries = kCVImageBufferColorPrimaries_SMPTE_C;
> +break;
> +
>  case AVCOL_PRI_BT709:
>  *primaries = kCVImageBufferColorPrimaries_ITU_R_709_2;
>  break;
> --
> 2.21.0 (Apple Git-122)
>

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

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

[FFmpeg-devel] [PATCH v1 2/2] configure: Fix for the configure failed for vmaf

2019-11-12 Thread lance . lmwang
From: Limin Wang 

When enable-libvmaf with the vmaf master installed , it'll report below error:
ERROR: libvmaf >= 1.3.9 not found using pkg-config

In fact, after vmaf installed, the vmaf pkg-config filename is vmaf.pc,
my build system is Centos7.4.

Below is the debug info for why change libvmaf to vmaf in the patch:
$ PKG_CONFIG_PATH=$your_pkg_path pkg-config --modversion libvmaf
Package libvmaf was not found in the pkg-config search path.
Perhaps you should add the directory containing `libvmaf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libvmaf' found

$ PKG_CONFIG_PATH=$your_pkg_path pkg-config --modversion vmaf
1.3.16

$ ls ../../../3rdparty_img/lib/pkgconfig/vmaf.pc
../../../3rdparty_img/lib/pkgconfig/vmaf.pc
$ cat ../../../3rdparty_img/lib/pkgconfig/vmaf.pc
prefix=/home/lmwang/build/build_ffmpeg/../3rdparty_img
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libvmaf
Description: VMAF, Video Multimethod Assessment Fusion
Version: 1.3.16
Libs: -L${libdir} -lvmaf
Libs.private: -lpthread
Cflags: -I${includedir}

Signed-off-by: Limin Wang 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 1de90e9..308ed3c 100755
--- a/configure
+++ b/configure
@@ -6312,7 +6312,7 @@ enabled libtwolame&& require libtwolame twolame.h 
twolame_init -ltwolame
die "ERROR: libtwolame must be installed and 
version must be >= 0.3.10"; }
 enabled libv4l2   && require_pkg_config libv4l2 libv4l2 libv4l2.h 
v4l2_ioctl
 enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" 
vid.stab/libvidstab.h vsMotionDetectInit
-enabled libvmaf   && require_pkg_config libvmaf "libvmaf >= 1.3.9" 
libvmaf.h compute_vmaf
+enabled libvmaf   && require_pkg_config libvmaf "vmaf >= 1.3.9" 
libvmaf.h compute_vmaf
 enabled libvo_amrwbenc&& require libvo_amrwbenc vo-amrwbenc/enc_if.h 
E_IF_init -lvo-amrwbenc
 enabled libvorbis && require_pkg_config libvorbis vorbis 
vorbis/codec.h vorbis_info_init &&
  require_pkg_config libvorbisenc vorbisenc 
vorbis/vorbisenc.h vorbis_encode_init
-- 
2.9.5

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

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

[FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_libvmaf: Check for av_frame_alloc failure

2019-11-12 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index ed3a383..14c3216 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -235,6 +235,9 @@ static av_cold int init(AVFilterContext *ctx)
 
 s->gref = av_frame_alloc();
 s->gmain = av_frame_alloc();
+if (!s->gref || !s->gmain)
+return AVERROR(ENOMEM);
+
 s->error = 0;
 
 s->vmaf_thread_created = 0;
-- 
2.9.5

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

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread myp...@gmail.com
On Tue, Nov 12, 2019 at 4:14 PM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> add superfastblur filter
>
> Signed-off-by: Jun Zhao 
> ---
>  doc/filters.texi   |   15 ++
>  libavfilter/Makefile   |1 +
>  libavfilter/allfilters.c   |1 +
>  libavfilter/vf_superfastblur.c |  275 
> 
>  4 files changed, 292 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/vf_superfastblur.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6800124..c7d1893 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -17453,6 +17453,21 @@ Interpolate) pixel art scaling algorithm.
>
>  Useful for enlarging pixel art images without reducing sharpness.
>
> +@section superfastblur
> +
> +Blur the input image with super fast blur algorithm, multiple invocations of 
> this
> +filter with a small radius will approximate a gaussian blur quite well.
> +
> +This filter accepts the following options:
> +
> +@table @option
> +@item radius
> +@item r
> +Set the blurring box radius. The option value must be a int number in
> +the range [1, 10] that specifies the blur box size of the superfast blur 
> filter
> +used to blur the image. Default value is @code{2}..
> +@end table
> +
>  @section swaprect
>
>  Swap two rectangular objects in video.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fce9303..db4d5e6 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -396,6 +396,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER)   += 
> vf_stereo3d.o
>  OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
>  OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
>  OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
> +OBJS-$(CONFIG_SUPEREQUALIZER_FILTER) += vf_superfastblur.o
>  OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
>  OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
>  OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 7c1e19e..d507bc5 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -377,6 +377,7 @@ extern AVFilter ff_vf_stereo3d;
>  extern AVFilter ff_vf_streamselect;
>  extern AVFilter ff_vf_subtitles;
>  extern AVFilter ff_vf_super2xsai;
> +extern AVFilter ff_vf_superfastblur;
>  extern AVFilter ff_vf_swaprect;
>  extern AVFilter ff_vf_swapuv;
>  extern AVFilter ff_vf_tblend;
> diff --git a/libavfilter/vf_superfastblur.c b/libavfilter/vf_superfastblur.c
> new file mode 100644
> index 000..a6428cf
> --- /dev/null
> +++ b/libavfilter/vf_superfastblur.c
> @@ -0,0 +1,275 @@
> +/*
> + * Copyright (c) 2019 Jun Zhao
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Super fast blur filter
> + *
> + * @see http://incubator.quasimondo.com/processing/superfast_blur.php
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +typedef struct SuperFastBlurContext {
> +const AVClass *class;
> +
> +int radius;
> +
> +uint32_t *vMIN;
> +uint32_t *vMAX;
> +
> +uint8_t *r;
> +uint8_t *g;
> +uint8_t *b;
> +
> +uint8_t *dv;
> +} SuperFastBlurContext;
> +
> +#define OFFSET(x) offsetof(SuperFastBlurContext, x)
> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
> +static const AVOption superfastblur_options[] = {
> +{ "radius", "Radius of the super fast blurring box", OFFSET(radius),  
> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
> +{ "r",  "Radius of the super fast blurring box", OFFSET(radius),  
> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
> +{ NULL }
> +};
> +
> +AVFILTER_DEFINE_CLASS(superfastblur);
> +
> +static av_cold int init(AVFilterContext *ctx)
> +{
> +SuperFastBlurContext *s = ctx->priv;
> +
> +// This line precalculates a lookup table for all the possible
> +// mean values that can occur. This is to avoid costly division
> +// in the inner loop. On some systems doing the division directly
> +// 

Re: [FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Carl Eugen Hoyos
Hi!

> Am 12.11.2019 um 17:59 schrieb Xinpeng Sun :
> 
> It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion
> with tone-mapping. It supports HDR10 only as input temporarily.
> 
> H2S: P010 -> NV12

No objection here but could you tell us if you (Intel) already have a plan how 
to deal with H2H?

Thank you for your effort, 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] [PATCH 1/2] lavc/rav1e: log and doc updated for const quantizer mode

2019-11-12 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 doc/encoders.texi | 2 +-
 libavcodec/librav1e.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6cf3a74093..6b02c7798d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1395,7 +1395,7 @@ Sets the maximum quantizer to use when using bitrate mode.
 Sets the minimum quantizer to use when using bitrate mode.
 
 @item qp
-Uses quantizer mode to encode at the given quantizer.
+Uses quantizer mode to encode at the given quantizer (0-255).
 
 @item speed
 Selects the speed preset (0-10) to encode with.
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 5052cac896..f25d91bb95 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -356,7 +356,7 @@ static av_cold int librav1e_encode_init(AVCodecContext 
*avctx)
 }
 } else if (ctx->quantizer >= 0) {
 if (avctx->bit_rate)
-av_log(avctx, AV_LOG_WARNING, "Both bitrate and quantizer 
specified. Using quantizer mode.");
+av_log(avctx, AV_LOG_WARNING, "Both bitrate and quantizer 
specified. Using const quantizer mode.");
 
 rret = rav1e_config_parse_int(cfg, "quantizer", ctx->quantizer);
 if (rret < 0) {
@@ -533,7 +533,7 @@ retry:
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
 static const AVOption options[] = {
-{ "qp", "use constant quantizer mode", OFFSET(quantizer), AV_OPT_TYPE_INT, 
{ .i64 = 100 }, -1, 255, VE },
+{ "qp", "qp value of constant quantizer mode", OFFSET(quantizer), 
AV_OPT_TYPE_INT, { .i64 = 100 }, -1, 255, VE },
 { "speed", "what speed preset to use", OFFSET(speed), AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, 10, VE },
 { "tiles", "number of tiles encode with", OFFSET(tiles), AV_OPT_TYPE_INT, 
{ .i64 = 0 }, -1, INT64_MAX, VE },
 { "tile-rows", "number of tiles rows to encode with", OFFSET(tile_rows), 
AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE },
-- 
2.16.5

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

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

[FFmpeg-devel] [PATCH 2/2] lavc/rav1e: add doc for threads option

2019-11-12 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 doc/encoders.texi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6b02c7798d..8f37597999 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1394,6 +1394,9 @@ Sets the maximum quantizer to use when using bitrate mode.
 @item qmin
 Sets the minimum quantizer to use when using bitrate mode.
 
+@item threads
+Set the number of threads to use while encoding.
+
 @item qp
 Uses quantizer mode to encode at the given quantizer (0-255).
 
-- 
2.16.5

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

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Paul B Mahol
Isn't this same as boxblur?

On 11/12/19, Steven Liu  wrote:
>
>
>> 在 2019年11月12日,15:51,Jun Zhao  写道:
>>
>> From: Jun Zhao 
>>
>> add superfastblur filter
>>
>> Signed-off-by: Jun Zhao 
>> ---
>> doc/filters.texi   |   15 ++
>> libavfilter/Makefile   |1 +
>> libavfilter/allfilters.c   |1 +
>> libavfilter/vf_superfastblur.c |  275
>> 
>> 4 files changed, 292 insertions(+), 0 deletions(-)
>> create mode 100644 libavfilter/vf_superfastblur.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 6800124..c7d1893 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -17453,6 +17453,21 @@ Interpolate) pixel art scaling algorithm.
>>
>> Useful for enlarging pixel art images without reducing sharpness.
>>
>> +@section superfastblur
>> +
>> +Blur the input image with super fast blur algorithm, multiple invocations
>> of this
>> +filter with a small radius will approximate a gaussian blur quite well.
>> +
>> +This filter accepts the following options:
>> +
>> +@table @option
>> +@item radius
>> +@item r
>> +Set the blurring box radius. The option value must be a int number in
>> +the range [1, 10] that specifies the blur box size of the superfast blur
>> filter
>> +used to blur the image. Default value is @code{2}..
>> +@end table
>> +
>> @section swaprect
>>
>> Swap two rectangular objects in video.
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index fce9303..db4d5e6 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -396,6 +396,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER)   +=
>> vf_stereo3d.o
>> OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o
>> framesync.o
>> OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
>> OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
>> +OBJS-$(CONFIG_SUPEREQUALIZER_FILTER) += vf_superfastblur.o
>> OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
>> OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
>> OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o
>> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
>> index 7c1e19e..d507bc5 100644
>> --- a/libavfilter/allfilters.c
>> +++ b/libavfilter/allfilters.c
>> @@ -377,6 +377,7 @@ extern AVFilter ff_vf_stereo3d;
>> extern AVFilter ff_vf_streamselect;
>> extern AVFilter ff_vf_subtitles;
>> extern AVFilter ff_vf_super2xsai;
>> +extern AVFilter ff_vf_superfastblur;
>> extern AVFilter ff_vf_swaprect;
>> extern AVFilter ff_vf_swapuv;
>> extern AVFilter ff_vf_tblend;
>> diff --git a/libavfilter/vf_superfastblur.c
>> b/libavfilter/vf_superfastblur.c
>> new file mode 100644
>> index 000..a6428cf
>> --- /dev/null
>> +++ b/libavfilter/vf_superfastblur.c
>> @@ -0,0 +1,275 @@
>> +/*
>> + * Copyright (c) 2019 Jun Zhao
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301 USA
>> + */
>> +
>> +/**
>> + * @file
>> + * Super fast blur filter
>> + *
>> + * @see http://incubator.quasimondo.com/processing/superfast_blur.php
>> + */
>> +
>> +#include "libavutil/avassert.h"
>> +#include "libavutil/imgutils.h"
>> +#include "libavutil/opt.h"
>> +#include "avfilter.h"
>> +#include "formats.h"
>> +#include "internal.h"
>> +#include "video.h"
>> +
>> +typedef struct SuperFastBlurContext {
>> +const AVClass *class;
>> +
>> +int radius;
>> +
>> +uint32_t *vMIN;
>> +uint32_t *vMAX;
>> +
>> +uint8_t *r;
>> +uint8_t *g;
>> +uint8_t *b;
>> +
>> +uint8_t *dv;
>> +} SuperFastBlurContext;
>> +
>> +#define OFFSET(x) offsetof(SuperFastBlurContext, x)
>> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
>> +static const AVOption superfastblur_options[] = {
>> +{ "radius", "Radius of the super fast blurring box", OFFSET(radius),
>> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
>> +{ "r",  "Radius of the super fast blurring box", OFFSET(radius),
>> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
>> +{ NULL }
>> +};
>> +
>> +AVFILTER_DEFINE_CLASS(superfastblur);
>> +
>> +static av_cold int init(AVFilterContext *ctx)
>> +{
>> +SuperFastBlurContext *s = ctx->priv;
>> +
>> +// This line precalculates a lookup table for 

Re: [FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images

2019-11-12 Thread Carl Eugen Hoyos


> Am 12.11.2019 um 09:09 schrieb Dale Curtis :
> 
>> On Fri, Nov 1, 2019 at 4:46 PM Carl Eugen Hoyos  wrote:
>> 
>> Testing would be helpful.
>> 
>> 
> Works for AVIF after adding the line I proposed as well as setting
> codecpar->width/height for the stream based on ispe.

Great!

> Breaks AVIFS files
> that were previously demuxing as mp4 w/ video track,

Does it only break them once above change was made or also in the existing 
patch?
(Sorry, I am still travelling in Japan without computer.)

> i.e.,
> https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix/avifs.
> As such might end up causing some client issues for MP4s that had embedded
> pict elements, but are not HEIF/AVIF - since they'll suddenly start
> surfacing new tracks.

Can such files easily be detected?

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

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

Re: [FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Steven Liu


> 在 2019年11月12日,15:51,Jun Zhao  写道:
> 
> From: Jun Zhao 
> 
> add superfastblur filter
> 
> Signed-off-by: Jun Zhao 
> ---
> doc/filters.texi   |   15 ++
> libavfilter/Makefile   |1 +
> libavfilter/allfilters.c   |1 +
> libavfilter/vf_superfastblur.c |  275 
> 4 files changed, 292 insertions(+), 0 deletions(-)
> create mode 100644 libavfilter/vf_superfastblur.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 6800124..c7d1893 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -17453,6 +17453,21 @@ Interpolate) pixel art scaling algorithm.
> 
> Useful for enlarging pixel art images without reducing sharpness.
> 
> +@section superfastblur
> +
> +Blur the input image with super fast blur algorithm, multiple invocations of 
> this
> +filter with a small radius will approximate a gaussian blur quite well.
> +
> +This filter accepts the following options:
> +
> +@table @option
> +@item radius
> +@item r
> +Set the blurring box radius. The option value must be a int number in
> +the range [1, 10] that specifies the blur box size of the superfast blur 
> filter
> +used to blur the image. Default value is @code{2}..
> +@end table
> +
> @section swaprect
> 
> Swap two rectangular objects in video.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fce9303..db4d5e6 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -396,6 +396,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER)   += 
> vf_stereo3d.o
> OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
> OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
> OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
> +OBJS-$(CONFIG_SUPEREQUALIZER_FILTER) += vf_superfastblur.o
> OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
> OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
> OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 7c1e19e..d507bc5 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -377,6 +377,7 @@ extern AVFilter ff_vf_stereo3d;
> extern AVFilter ff_vf_streamselect;
> extern AVFilter ff_vf_subtitles;
> extern AVFilter ff_vf_super2xsai;
> +extern AVFilter ff_vf_superfastblur;
> extern AVFilter ff_vf_swaprect;
> extern AVFilter ff_vf_swapuv;
> extern AVFilter ff_vf_tblend;
> diff --git a/libavfilter/vf_superfastblur.c b/libavfilter/vf_superfastblur.c
> new file mode 100644
> index 000..a6428cf
> --- /dev/null
> +++ b/libavfilter/vf_superfastblur.c
> @@ -0,0 +1,275 @@
> +/*
> + * Copyright (c) 2019 Jun Zhao
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Super fast blur filter
> + *
> + * @see http://incubator.quasimondo.com/processing/superfast_blur.php
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +typedef struct SuperFastBlurContext {
> +const AVClass *class;
> +
> +int radius;
> +
> +uint32_t *vMIN;
> +uint32_t *vMAX;
> +
> +uint8_t *r;
> +uint8_t *g;
> +uint8_t *b;
> +
> +uint8_t *dv;
> +} SuperFastBlurContext;
> +
> +#define OFFSET(x) offsetof(SuperFastBlurContext, x)
> +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
> +static const AVOption superfastblur_options[] = {
> +{ "radius", "Radius of the super fast blurring box", OFFSET(radius),  
> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
> +{ "r",  "Radius of the super fast blurring box", OFFSET(radius),  
> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
> +{ NULL }
> +};
> +
> +AVFILTER_DEFINE_CLASS(superfastblur);
> +
> +static av_cold int init(AVFilterContext *ctx)
> +{
> +SuperFastBlurContext *s = ctx->priv;
> +
> +// This line precalculates a lookup table for all the possible
> +// mean values that can occur. This is to avoid costly division
> +// in the inner loop. On some systems doing the division directly
> +// instead of a doing an array 

[FFmpeg-devel] [PATCH v1] avfilter: Add tonemap vaapi filter for H2S

2019-11-12 Thread Xinpeng Sun
It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion
with tone-mapping. It supports HDR10 only as input temporarily.

H2S: P010 -> NV12

An example command to use this filter with vaapi codecs:
FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format 
vaapi \
-i INPUT -vf 'tonemap_vaapi=h2s,hwdownload,format=nv12' -pix_fmt nv12 \
-f rawvideo -y OUTPUT

Signed-off-by: Xinpeng Sun 
Signed-off-by: Zachary Zhou 
---
 doc/filters.texi   |  30 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vaapi_vpp.c|   5 +
 libavfilter/vf_tonemap_vaapi.c | 272 +
 5 files changed, 309 insertions(+)
 create mode 100644 libavfilter/vf_tonemap_vaapi.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 6800124574..b1c466ba24 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20754,6 +20754,36 @@ Convert HDR(PQ/HLG) video to 
bt2020-transfer-characteristic p010 format using li
 @end example
 @end itemize
 
+@section tonemap_vappi
+
+Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with 
tone-mapping.
+It maps the dynamic range of HDR10 content to the SDR content.
+It only accepts HDR10 as input temporarilly.
+
+It accepts the following parameters:
+
+@table @option
+@item type
+Specify the tone-mapping operator to be used.
+
+Possible values are:
+@table @var
+@item h2s
+Perform H2S(HDR to SDR), convert from p010 to nv12
+@end table
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Convert HDR video to SDR video from p010 format to nv12 format.
+@example
+-i INPUT -vf "tonemap_vaapi=h2s" OUTPUT
+@end example
+@end itemize
+
 @section unsharp_opencl
 
 Sharpen or blur the input video.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fce930360d..90a0e9945e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -410,6 +410,7 @@ OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o 
framesync.o
 OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o colorspace.o
 OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o 
colorspace.o opencl.o \
 opencl/tonemap.o 
opencl/colorspace_common.o
+OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER)  += vf_tonemap_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
 OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 7c1e19e1da..b2fb1f8a98 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -390,6 +390,7 @@ extern AVFilter ff_vf_tlut2;
 extern AVFilter ff_vf_tmix;
 extern AVFilter ff_vf_tonemap;
 extern AVFilter ff_vf_tonemap_opencl;
+extern AVFilter ff_vf_tonemap_vaapi;
 extern AVFilter ff_vf_tpad;
 extern AVFilter ff_vf_transpose;
 extern AVFilter ff_vf_transpose_npp;
diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index b5b245c8af..5776243fa0 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -257,6 +257,11 @@ static const VAAPIColourProperties 
vaapi_colour_standard_map[] = {
 { VAProcColorStandardSMPTE170M,   6,  6,  6 },
 { VAProcColorStandardSMPTE240M,   7,  7,  7 },
 { VAProcColorStandardGenericFilm, 8,  1,  1 },
+
+#if VA_CHECK_VERSION(2, 3, 0)
+{ VAProcColorStandardExplicit,9,  16, AVCOL_SPC_BT2020_NCL},
+#endif
+
 #if VA_CHECK_VERSION(1, 1, 0)
 { VAProcColorStandardSRGB,1, 13,  0 },
 { VAProcColorStandardXVYCC601,1, 11,  5 },
diff --git a/libavfilter/vf_tonemap_vaapi.c b/libavfilter/vf_tonemap_vaapi.c
new file mode 100644
index 00..27ee17bf00
--- /dev/null
+++ b/libavfilter/vf_tonemap_vaapi.c
@@ -0,0 +1,272 @@
+/*
+ * 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/avassert.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/mastering_display_metadata.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "vaapi_vpp.h"
+
+typedef enum {
+HDR_VAAPI_H2S,
+} HDRType;
+
+typedef struct HDRVAAPIContext {
+

[FFmpeg-devel] [PATCH V1] lavfi/superfastblur: add superfastblur filter

2019-11-12 Thread Jun Zhao
From: Jun Zhao 

add superfastblur filter

Signed-off-by: Jun Zhao 
---
 doc/filters.texi   |   15 ++
 libavfilter/Makefile   |1 +
 libavfilter/allfilters.c   |1 +
 libavfilter/vf_superfastblur.c |  275 
 4 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/vf_superfastblur.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 6800124..c7d1893 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17453,6 +17453,21 @@ Interpolate) pixel art scaling algorithm.
 
 Useful for enlarging pixel art images without reducing sharpness.
 
+@section superfastblur
+
+Blur the input image with super fast blur algorithm, multiple invocations of 
this
+filter with a small radius will approximate a gaussian blur quite well.
+
+This filter accepts the following options:
+
+@table @option
+@item radius
+@item r
+Set the blurring box radius. The option value must be a int number in
+the range [1, 10] that specifies the blur box size of the superfast blur filter
+used to blur the image. Default value is @code{2}..
+@end table
+
 @section swaprect
 
 Swap two rectangular objects in video.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fce9303..db4d5e6 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -396,6 +396,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER)   += 
vf_stereo3d.o
 OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
 OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
 OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
+OBJS-$(CONFIG_SUPEREQUALIZER_FILTER) += vf_superfastblur.o
 OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
 OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
 OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 7c1e19e..d507bc5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -377,6 +377,7 @@ extern AVFilter ff_vf_stereo3d;
 extern AVFilter ff_vf_streamselect;
 extern AVFilter ff_vf_subtitles;
 extern AVFilter ff_vf_super2xsai;
+extern AVFilter ff_vf_superfastblur;
 extern AVFilter ff_vf_swaprect;
 extern AVFilter ff_vf_swapuv;
 extern AVFilter ff_vf_tblend;
diff --git a/libavfilter/vf_superfastblur.c b/libavfilter/vf_superfastblur.c
new file mode 100644
index 000..a6428cf
--- /dev/null
+++ b/libavfilter/vf_superfastblur.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2019 Jun Zhao
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Super fast blur filter
+ *
+ * @see http://incubator.quasimondo.com/processing/superfast_blur.php
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct SuperFastBlurContext {
+const AVClass *class;
+
+int radius;
+
+uint32_t *vMIN;
+uint32_t *vMAX;
+
+uint8_t *r;
+uint8_t *g;
+uint8_t *b;
+
+uint8_t *dv;
+} SuperFastBlurContext;
+
+#define OFFSET(x) offsetof(SuperFastBlurContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption superfastblur_options[] = {
+{ "radius", "Radius of the super fast blurring box", OFFSET(radius),  
AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
+{ "r",  "Radius of the super fast blurring box", OFFSET(radius),  
AV_OPT_TYPE_INT, {.i64 = 2}, 1, 10, FLAGS },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(superfastblur);
+
+static av_cold int init(AVFilterContext *ctx)
+{
+SuperFastBlurContext *s = ctx->priv;
+
+// This line precalculates a lookup table for all the possible
+// mean values that can occur. This is to avoid costly division
+// in the inner loop. On some systems doing the division directly
+// instead of a doing an array lookup might actually be faster
+// nowadays.
+uint32_t div = 2 * s->radius + 1;
+s->dv = av_malloc(sizeof(*s->dv) * 256 * div);
+if (!s->dv)
+return AVERROR(ENOMEM);
+for (int i = 0; i < 256 * div; i++)
+s->dv[i] = (i / div);
+
+return 0;
+}
+
+static int