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

2019-12-27 Thread Gyan

Hi Michael,

On 26-12-2019 02:42 pm, Gyan wrote:



On 24-12-2019 11:39 am, Gyan wrote:



On 24-12-2019 04:50 am, Michael Niedermayer wrote:

On Tue, Dec 17, 2019 at 02:55:06PM +0530, Gyan wrote:
[...]
@@ -127,6 +204,22 @@ static av_cold int init_dict(AVFilterContext 
*ctx, AVDictionary **opts)

  if (!scale->h_expr)
  av_opt_set(scale, "h", "ih", 0);
  +    ret = av_expr_parse(&scale->w_pexpr, scale->w_expr,
+    names,
+    NULL, NULL, NULL, NULL, 0, ctx);
+    if (ret < 0) {
+    av_log(ctx, AV_LOG_ERROR, "Cannot parse width expression: 
'%s'\n", scale->w_expr);

+    return ret;
+    }
+
+    ret = av_expr_parse(&scale->h_pexpr, scale->h_expr,
+    names,
+    NULL, NULL, NULL, NULL, 0, ctx);
+    if (ret < 0) {
+    av_log(ctx, AV_LOG_ERROR, "Cannot parse height expression: 
'%s'\n", scale->h_expr);

+    return ret;
+    }
+
+    if (w) {
+    ret = av_expr_parse(&scale->w_pexpr, scale->w_expr,
+    names,
+    NULL, NULL, NULL, NULL, 0, ctx);
+    if (ret < 0) {
+    av_log(ctx, AV_LOG_ERROR, "Cannot parse width 
expression: '%s'\n", scale->w_expr);

+    goto revert;
+    }
+    }
+
+    if (h) {
+    ret = av_expr_parse(&scale->h_pexpr, scale->h_expr,
+    names,
+    NULL, NULL, NULL, NULL, 0, ctx);
+    if (ret < 0) {
+    av_log(ctx, AV_LOG_ERROR, "Cannot parse height 
expression: '%s'\n", scale->h_expr);

+    goto revert;
+    }
+    }

Duplicate code


init_dict() is not called during command processing since we don't 
reset any other parameter except for one of width or height. Do you 
want me to reinit all parameters after a command?


Ping.


If you can suggest how you want me to proceed, that would be helpful.

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] avformat/matroskadec: Add webm file extension

2019-12-27 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 75f72d330c..3879a54af5 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -4193,7 +4193,7 @@ static const AVClass webm_dash_class = {
 AVInputFormat ff_matroska_demuxer = {
 .name   = "matroska,webm",
 .long_name  = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
-.extensions = "mkv,mk3d,mka,mks",
+.extensions = "mkv,mk3d,mka,mks,webm",
 .priv_data_size = sizeof(MatroskaDemuxContext),
 .read_probe = matroska_probe,
 .read_header= matroska_read_header,
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 2/2] avformat/matroskadec: Fix lzo decompression

2019-12-27 Thread Andreas Rheinhardt
When a Matroska Block is only stored in compressed form, the size of
the uncompressed block is not explicitly coded and therefore not known
before decompressing it. Therefore the demuxer uses a guess for the
uncompressed size: The first guess is three times the compressed size
and if this is not enough, it is repeatedly incremented by a factor of
three. But when this happens with lzo, the decompression is neither
resumed nor started again. Instead when av_lzo1x_decode indicates that x
bytes of input data could not be decoded, because the output buffer is
already full, the first (not the last) x bytes of the input buffer are
resent for decoding in the next try; they overwrite already decoded
data.

This commit fixes this by instead restarting the decompression anew,
just with a bigger buffer.

This seems to be a regression since 935ec5a1.

A FATE-test for this has been added.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c |  3 ++-
 tests/fate/matroska.mak   |  4 
 tests/ref/fate/matroska-lzo-decompression | 10 ++
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/matroska-lzo-decompression

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 72624dc3f1..75f72d330c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1599,6 +1599,7 @@ static int matroska_decode_buffer(uint8_t **buf, int 
*buf_size,
 #if CONFIG_LZO
 case MATROSKA_TRACK_ENCODING_COMP_LZO:
 do {
+int insize = isize;
 olen   = pkt_size *= 3;
 newpktdata = av_realloc(pkt_data, pkt_size + AV_LZO_OUTPUT_PADDING
+ 
AV_INPUT_BUFFER_PADDING_SIZE);
@@ -1607,7 +1608,7 @@ static int matroska_decode_buffer(uint8_t **buf, int 
*buf_size,
 goto failed;
 }
 pkt_data = newpktdata;
-result   = av_lzo1x_decode(pkt_data, &olen, data, &isize);
+result   = av_lzo1x_decode(pkt_data, &olen, data, &insize);
 } while (result == AV_LZO_OUTPUT_FULL && pkt_size < 1000);
 if (result) {
 result = AVERROR_INVALIDDATA;
diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index 597be7346c..4aca4dc8eb 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -22,6 +22,10 @@ fate-matroska-xiph-lacing: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/xiph_lacing.m
 FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER ZLIB) += 
fate-matroska-zlib-decompression
 fate-matroska-zlib-decompression: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/subtitle_zlib.mks -c:s copy
 
+# This tests that the matroska demuxer can decompress lzo compressed tracks.
+FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER LZO) += 
fate-matroska-lzo-decompression
+fate-matroska-lzo-decompression: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/lzo.mka -c copy
+
 # This tests that the matroska demuxer correctly propagates
 # the channel layout contained in vorbis comments in the CodecPrivate
 # of flac tracks. It also tests header removal compression.
diff --git a/tests/ref/fate/matroska-lzo-decompression 
b/tests/ref/fate/matroska-lzo-decompression
new file mode 100644
index 00..241d5adf44
--- /dev/null
+++ b/tests/ref/fate/matroska-lzo-decompression
@@ -0,0 +1,10 @@
+#tb 0: 11337/5
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0, 4096,16384, 0x
+0,   4096,   4096, 4096,16384, 0xad7eebf4
+0,   8192,   8192, 4096,16384, 0x1d1ff9d9
+0,  12288,  12288, 4097,16384, 0xf1d9e2e2
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 1/2] fate/matroska: Add test for ProRes and bz2 compression

2019-12-27 Thread Andreas Rheinhardt
This test tests that demuxing ProRes that is muxed like it should be in
Matroska (i.e. with the first header ("icpf") atom stripped away) works;
it also tests bz2 decompression as well as the handling of
unknown-length clusters.

Signed-off-by: Andreas Rheinhardt 
---
The samples have already been sent to James for uploading.

 tests/fate/matroska.mak  |  5 +
 .../fate/matroska-prores-header-insertion-bz2| 16 
 2 files changed, 21 insertions(+)
 create mode 100644 tests/ref/fate/matroska-prores-header-insertion-bz2

diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index 99145338ae..597be7346c 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -1,6 +1,11 @@
 FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER ZLIB) += 
fate-matroska-prores-zlib
 fate-matroska-prores-zlib: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/prores_zlib.mkv -c:v copy
 
+# This tests that the matroska demuxer correctly adds the icpf header atom
+# upon demuxing; it also tests bz2 decompression and unknown-length cluster.
+FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER BZLIB) += 
fate-matroska-prores-header-insertion-bz2
+fate-matroska-prores-header-insertion-bz2: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/prores_bz2.mkv -map 0 -c copy
+
 # This tests that the matroska demuxer supports modifying the colorspace
 # properties in remuxing (-c:v copy)
 # It also tests automatic insertion of the vp9_superframe bitstream filter
diff --git a/tests/ref/fate/matroska-prores-header-insertion-bz2 
b/tests/ref/fate/matroska-prores-header-insertion-bz2
new file mode 100644
index 00..63a59f9b8d
--- /dev/null
+++ b/tests/ref/fate/matroska-prores-header-insertion-bz2
@@ -0,0 +1,16 @@
+#extradata 0:4, 0x0402019c
+#extradata 1:4, 0x0402019c
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: prores
+#dimensions 0: 720x480
+#sar 0: 186/157
+#tb 1: 1/1000
+#media_type 1: video
+#codec_id 1: prores
+#dimensions 1: 720x480
+#sar 1: 186/157
+0,  0,  0,0, 4304, 0x3625b1fc
+1,  0,  0,0, 4304, 0x3625b1fc
+0, 42, 42,0, 4304, 0x3625b1fc
+1, 42, 42,0, 4304, 0x3625b1fc
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH, 4/7] lavu/hwcontext_vaapi: add vaapi_format_map support for 0YUV/Y210/Y410

2019-12-27 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Mark Thompson
> Sent: Saturday, December 28, 2019 06:41
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, 4/7] lavu/hwcontext_vaapi: add
> vaapi_format_map support for 0YUV/Y210/Y410
> 
> On 04/12/2019 14:44, Linjie Fu wrote:
> > VA_RT_FORMAT describes the desired sampling format for surface.
> >
> > When creating surface, VA_RT_FORMAT will be used firstly to choose
> > the expected fourcc/media_format for the surface. And the fourcc
> > will be revised by the value of VASurfaceAttribPixelFormat.
> >
> > Add vaapi_format_map support for new pixel_format.
> > This is fundamental for both VA-API and QSV.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavutil/hwcontext_vaapi.c | 7 +++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> > index cf11764..296234b 100644
> > --- a/libavutil/hwcontext_vaapi.c
> > +++ b/libavutil/hwcontext_vaapi.c
> > @@ -116,6 +116,13 @@ static const VAAPIFormatDescriptor
> vaapi_format_map[] = {
> >  #endif
> >  MAP(UYVY, YUV422,  UYVY422, 0),
> >  MAP(YUY2, YUV422,  YUYV422, 0),
> > +#ifdef VA_FOURCC_Y210
> > +MAP(Y210, YUV422_10, Y210, 0),
> > +#endif
> > +MAP(AYUV, YUV444,0YUV, 0),
> > +#ifdef VA_FOURCC_Y410
> > +MAP(Y410, YUV444_10, Y410, 0),
> > +#endif
> >  MAP(411P, YUV411,  YUV411P, 0),
> >  MAP(422V, YUV422,  YUV440P, 0),
> >  MAP(444P, YUV444,  YUV444P, 0),
> 
> (I've now bought an Ice Lake machine so that I can actually investigate what's
> going on here properly.)

Appreciated it.

> The real problem is that the formats advertised by the driver for H.265/VP9
> YUV 4:4:4 (AYUV and Y410) are incorrect.  There isn't any alpha support
> anywhere in the hardware (none of the multilayer stuff), so using formats
> with alpha in them is wrong and makes all of the attempts to use it extremely
> confusing.
> 
> To fix that we need to change the driver to use formats which actually reflect
> reality.  This is mostly straightforward, because the inner code in the driver
> mainly cares about layout rather than what is actually in each channel.
> 
> Some patches which kindof work (not particularly well tested):
> 
> libva:  Add-fourcc-values-for-YUV-4-4-4-formats.patch>
> iHD:  Do-not-advertise-support-for-nonexistent-alpha-chann.patch>

I got some concerns for the modifications:

1. RT FORMAT YUV444 would not be bind with VA_FOURCC_444P any more

@@ -2136,10 +2151,13 @@ DdiMedia_CreateSurfaces2(
 expected_fourcc = VA_FOURCC_Y216;
 break;
 case VA_RT_FORMAT_YUV444:
-expected_fourcc = VA_FOURCC_444P;
+expected_fourcc = VA_FOURCC_XYUV;
 break;

VAAPI decode of jpeg requires VA_RT_FORMAT_YUV444 with expected_fourcc = 
VA_FOURCC_444P.
(Though it's not used frequently), changing the expected fourcc into XYUV may 
cause a change for
media_format from Media_Format_444P to Media_Format_XYUV.

2. The changes in MediaLibvaCaps::QuerySurfaceAttributes which eliminate 
AYUV/Y410/Y416 may
affect the pipelines already implemented in MSDK and GStreamer. (If so,  there 
is a lot to be done/rework)

> I've called the non-alpha formats XYUV and XV30 to match libdrm (see
>  164>).   The 12-bit case also needs some correction - it's currently using 
> Y216
> and I think assuming that the user knows they need to ignore the alpha
> channel and the lower bits elsewhere, but we might need to have distinct
> formats to make it work properly outside the driver.
> 
> - Mark
> 
> PS:  It might help to split out the 4:2:2 case (which doesn't have these
> problems because the formats there don't have fake alpha channels or
> unknown depth) to go forward, and look separately at fixing the driver for
> the others.

Thanks, I'll split and get 4:2:2 stuffs done firstly.

- linjie

BTW, what's the plan for submit these modifications in libva/media-driver?

___
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] avcodec/h264_metadata_bsf: Fix user data failed to insert in case no SPSs NAL for global headers

2019-12-27 Thread Limin Wang
On Fri, Dec 27, 2019 at 11:30:34PM +, Mark Thompson wrote:
> On 26/12/2019 00:55, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > FLV, MP4... will enable global_header default and place SPSs headers in 
> > extradata
> > instead of every keyframe. So it'll failed to insert user data unregisted
> > for no SPSs NAL after first AU without the patch.
> > 
> > Please test it with below command:
> > ./ffmpeg -f lavfi -i testsrc -c:v libx264 -g 25 \
> > -bsf:v 
> > h264_metadata=sei_user_data=086f3693-b7b3-4f2c-9653-21492feee5b8+hello \
> > -frames:v 150 test.mp4
> > 
> > After applied the patch, you'll get the user data for every keyframe with 
> > below command:
> > ./ffmpeg -i test.mp4 -vf showinfo -frames:v 150 -f null -
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/h264_metadata_bsf.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
> > index 5de74be9d6..9690ca433b 100644
> > --- a/libavcodec/h264_metadata_bsf.c
> > +++ b/libavcodec/h264_metadata_bsf.c
> > @@ -279,7 +279,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> > AVPacket *pkt)
> >  {
> >  H264MetadataContext *ctx = bsf->priv_data;
> >  CodedBitstreamFragment *au = &ctx->access_unit;
> > -int err, i, j, has_sps;
> > +int err, i, j, has_sps, is_keyframe = 0;
> >  H264RawAUD aud;
> >  
> >  err = ff_bsf_get_packet_ref(bsf, pkt);
> > @@ -359,11 +359,13 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> > AVPacket *pkt)
> >  goto fail;
> >  has_sps = 1;
> >  }
> > +if (au->units[i].type == H264_NAL_IDR_SLICE)
> > +is_keyframe = 1;
> >  }
> >  
> >  // Only insert the SEI in access units containing SPSs, and also
> >  // unconditionally in the first access unit we ever see.
> > -if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
> > +if (ctx->sei_user_data && (has_sps || !ctx->done_first_au || 
> > is_keyframe)) {
> >  H264RawSEIPayload payload = {
> >  .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
> >  };
> > 
> 
> This was avoided originally because identifying key frames (or really, seek 
> points) in an H.264 stream is really hard.  I don't particularly like the 
> idea of having it work in some streams but not others, depending on exactly 
> how the stream was encoded - hence the original decision to only include it 
> in access units which were already distinguished as flat-file seek-points by 
> having the parameter sets in them.
> 
> I guess I'm not against this in itself, but please add more of a comment in 
> the code explaining the rationale and noting the cases which are not 
> included.  (And if you can cover more cases, such as recovery points, then 
> that would be even better.)

FFmpeg CLI can't support change the parameter on the fly, by my case, the user
data string will be updated periodically. For the stream, like rtmp, no SPSs 
header in the stream, so the user data failed to insert anymore. For IDR_SLICE
is good to cover most condition, so I did not add recovery points as the user
data don't depend on it in fact.  If you think it's needed, I'll add more 
checking.

> 
> Thanks,
> 
> - Mark
> ___
> 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,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec/h265_metadata_bsf: add option to insert a string as SEI unregistered user data

2019-12-27 Thread Limin Wang
On Fri, Dec 27, 2019 at 11:32:40PM +, Mark Thompson wrote:
> On 26/12/2019 01:01, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > update to add keyframe NAL checking as H.264 patch for global header
> 
> This case is much easier in H.265, though - the extradata can include SEI 
> which applies globally, so just put it there rather than splicing it into the 
> stream.

Mark, are you say put the user data into the extradata? For my case, the string
in the user data will be updated for every key frame runtime. 

> 
> - Mark
> ___
> 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,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/2] avdevice/xcbgrab: capture the full desktop if video_size is not specified

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/indevs.texi   |  2 +-
 libavdevice/xcbgrab.c | 12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 92bc65be41..e2a3540203 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -1532,7 +1532,7 @@ ffmpeg -f x11grab -follow_mouse centered -show_region 1 
-framerate 25 -video_siz
 @end example
 
 @item video_size
-Set the video frame size. Default value is @code{vga}.
+Set the video frame size. Default is the full desktop.
 
 @item grab_x
 @item grab_y
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 861eef07b5..113cce71a5 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -70,7 +70,6 @@ typedef struct XCBGrabContext {
 int region_border;
 int centered;
 
-const char *video_size;
 const char *framerate;
 
 int has_shm;
@@ -85,7 +84,7 @@ static const AVOption options[] = {
 { "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, D },
 { "grab_x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 
0 }, 0, INT_MAX, D },
 { "grab_y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 
0 }, 0, INT_MAX, D },
-{ "video_size", "A string describing frame size, such as 640x480 or 
hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga" }, 0, 0, D },
+{ "video_size", "A string describing frame size, such as 640x480 or 
hd720.", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL }, 0, 0, D },
 { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc" 
}, 0, 0, D },
 { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), 
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, D },
 { "follow_mouse", "Move the grabbing region when the mouse pointer reaches 
within specified amount of pixels to the edge of region.",
@@ -555,10 +554,6 @@ static int create_stream(AVFormatContext *s)
 if (!st)
 return AVERROR(ENOMEM);
 
-ret = av_parse_video_size(&c->width, &c->height, c->video_size);
-if (ret < 0)
-return ret;
-
 ret = av_parse_video_rate(&st->avg_frame_rate, c->framerate);
 if (ret < 0)
 return ret;
@@ -570,6 +565,11 @@ static int create_stream(AVFormatContext *s)
 if (!geo)
 return AVERROR_EXTERNAL;
 
+if (!c->width || !c->height) {
+c->width = geo->width;
+c->height = geo->height;
+}
+
 if (c->x + c->width > geo->width ||
 c->y + c->height > geo->height) {
 av_log(s, AV_LOG_ERROR,
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 1/2] avdevice/xcbgrab: fix packet timestamps

2019-12-27 Thread Marton Balint
Since 648b8cca6c56a4fa1760efc72dfe1363a5c6e31e and
c991e9cd91845044e93a9c89dd25b48ae707461b timestamps were not set properly.

Signed-off-by: Marton Balint 
---
 libavdevice/xcbgrab.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 82ea09ca96..861eef07b5 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -57,6 +57,7 @@ typedef struct XCBGrabContext {
 #endif
 int64_t time_frame;
 AVRational time_base;
+int64_t frame_duration;
 
 int x, y;
 int width, height;
@@ -195,13 +196,12 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket 
*pkt)
 return 0;
 }
 
-static void wait_frame(AVFormatContext *s, AVPacket *pkt)
+static int64_t wait_frame(AVFormatContext *s, AVPacket *pkt)
 {
 XCBGrabContext *c = s->priv_data;
 int64_t curtime, delay;
-int64_t frame_time = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q);
 
-c->time_frame += frame_time;
+c->time_frame += c->frame_duration;
 
 for (;;) {
 curtime = av_gettime();
@@ -211,7 +211,7 @@ static void wait_frame(AVFormatContext *s, AVPacket *pkt)
 av_usleep(delay);
 }
 
-pkt->pts = curtime;
+return curtime;
 }
 
 #if CONFIG_LIBXCB_SHM
@@ -418,8 +418,9 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 xcb_query_pointer_reply_t *p  = NULL;
 xcb_get_geometry_reply_t *geo = NULL;
 int ret = 0;
+int64_t pts;
 
-wait_frame(s, pkt);
+pts = wait_frame(s, pkt);
 
 if (c->follow_mouse || c->draw_mouse) {
 pc  = xcb_query_pointer(c->conn, c->screen->root);
@@ -442,6 +443,8 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 #endif
 if (!c->has_shm)
 ret = xcbgrab_frame(s, pkt);
+pkt->dts = pkt->pts = pts;
+pkt->duration = c->frame_duration;
 
 #if CONFIG_LIBXCB_XFIXES
 if (ret >= 0 && c->draw_mouse && p->same_screen)
@@ -581,6 +584,7 @@ static int create_stream(AVFormatContext *s)
 
 c->time_base  = (AVRational){ st->avg_frame_rate.den,
   st->avg_frame_rate.num };
+c->frame_duration = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q);
 c->time_frame = av_gettime();
 
 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-- 
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] configure: Change the configure check for tonemap_vaapi

2019-12-27 Thread Mark Thompson
On 24/12/2019 06:32, Xinpeng Sun wrote:
> "VAProcFilterParameterBufferHDRToneMapping" was defined in libva 2.4.1, which 
> will lead to
> build failure for the filter tonemap_vaapi for libva 2.3.0 with current 
> check. This patch
> is to fix this build error.
> 
> Signed-off-by: Xinpeng Sun 
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index eec43c3b06..157dc30132 100755
> --- a/configure
> +++ b/configure
> @@ -3580,7 +3580,7 @@ tinterlace_filter_deps="gpl"
>  tinterlace_merge_test_deps="tinterlace_filter"
>  tinterlace_pad_test_deps="tinterlace_filter"
>  tonemap_filter_deps="const_nan"
> -tonemap_vaapi_filter_deps="vaapi 
> VAProcPipelineParameterBuffer_output_hdr_metadata"
> +tonemap_vaapi_filter_deps="vaapi 
> VAProcFilterParameterBufferHDRToneMapping_type"

This is out of order, you could fix that at the same time.

>  tonemap_opencl_filter_deps="opencl const_nan"
>  transpose_opencl_filter_deps="opencl"
>  transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
> @@ -6585,7 +6585,7 @@ if enabled vaapi; then
>  
>  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
>  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> -check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" 
> output_hdr_metadata
> +check_struct "va/va.h va/va_vpp.h" 
> "VAProcFilterParameterBufferHDRToneMapping" type

You only want the structure itself rather than any particular member of it, 
right?  I think that means you want check_type rather than check_struct.

>  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
>  check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
>  check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
> 

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

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

Re: [FFmpeg-devel] [PATCH v3] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-27 Thread Mark Thompson
On 27/12/2019 23:38, Andriy Gelman wrote:
> 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(+)
> 
>  Changes in v3:
> - Use main encoder context for logging instead of the private one
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 474e6bef897..8059e3bb48f 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, &s);
> @@ -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(avctx, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
> desc->name);
> +return AVERROR(EINVAL);
> +}
> +
>  return v4l2_prepare_encoder(s);
>  }
>  
> 

Yep, applied.

Thank you for your patience on this :/

- Mark
___
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 8/8] avformat/img2enc: add support for specifying protocol options

2019-12-27 Thread Marton Balint



On Fri, 27 Dec 2019, Lou Logan wrote:


On Fri, Dec 27, 2019, at 12:14 PM, Marton Balint wrote:

Signed-off-by: Marton Balint 

+ffmpeg -f x11grab -r 1 -framerate 1 -video_size hd1080 -i :0.0 -qscale 
6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg


What's the reason this examples uses both -r and -framerate?


Good point... It turned out it was needed because a recent change of 
mine in xcbgrab broke timestamps... Will send fix.




Please use -qscale:v to avoid the "-qscale is ambiguous" warning.


Ok, will change.

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

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

[FFmpeg-devel] [PATCH v3] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device

2019-12-27 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(+)

 Changes in v3:
- Use main encoder context for logging instead of the private one

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 474e6bef897..8059e3bb48f 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, &s);
@@ -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(avctx, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", 
desc->name);
+return AVERROR(EINVAL);
+}
+
 return v4l2_prepare_encoder(s);
 }
 
-- 
2.24.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 v2 2/2] avcodec/h265_metadata_bsf: add option to insert a string as SEI unregistered user data

2019-12-27 Thread Mark Thompson
On 26/12/2019 01:01, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
> update to add keyframe NAL checking as H.264 patch for global header

This case is much easier in H.265, though - the extradata can include SEI which 
applies globally, so just put it there rather than splicing it into the stream.

- Mark
___
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] avcodec/h264_metadata_bsf: Fix user data failed to insert in case no SPSs NAL for global headers

2019-12-27 Thread Mark Thompson
On 26/12/2019 00:55, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> FLV, MP4... will enable global_header default and place SPSs headers in 
> extradata
> instead of every keyframe. So it'll failed to insert user data unregisted
> for no SPSs NAL after first AU without the patch.
> 
> Please test it with below command:
> ./ffmpeg -f lavfi -i testsrc -c:v libx264 -g 25 \
> -bsf:v 
> h264_metadata=sei_user_data=086f3693-b7b3-4f2c-9653-21492feee5b8+hello \
> -frames:v 150 test.mp4
> 
> After applied the patch, you'll get the user data for every keyframe with 
> below command:
> ./ffmpeg -i test.mp4 -vf showinfo -frames:v 150 -f null -
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/h264_metadata_bsf.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
> index 5de74be9d6..9690ca433b 100644
> --- a/libavcodec/h264_metadata_bsf.c
> +++ b/libavcodec/h264_metadata_bsf.c
> @@ -279,7 +279,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> AVPacket *pkt)
>  {
>  H264MetadataContext *ctx = bsf->priv_data;
>  CodedBitstreamFragment *au = &ctx->access_unit;
> -int err, i, j, has_sps;
> +int err, i, j, has_sps, is_keyframe = 0;
>  H264RawAUD aud;
>  
>  err = ff_bsf_get_packet_ref(bsf, pkt);
> @@ -359,11 +359,13 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> AVPacket *pkt)
>  goto fail;
>  has_sps = 1;
>  }
> +if (au->units[i].type == H264_NAL_IDR_SLICE)
> +is_keyframe = 1;
>  }
>  
>  // Only insert the SEI in access units containing SPSs, and also
>  // unconditionally in the first access unit we ever see.
> -if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
> +if (ctx->sei_user_data && (has_sps || !ctx->done_first_au || 
> is_keyframe)) {
>  H264RawSEIPayload payload = {
>  .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
>  };
> 

This was avoided originally because identifying key frames (or really, seek 
points) in an H.264 stream is really hard.  I don't particularly like the idea 
of having it work in some streams but not others, depending on exactly how the 
stream was encoded - hence the original decision to only include it in access 
units which were already distinguished as flat-file seek-points by having the 
parameter sets in them.

I guess I'm not against this in itself, but please add more of a comment in the 
code explaining the rationale and noting the cases which are not included.  
(And if you can cover more cases, such as recovery points, then that would be 
even better.)

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH, v3, 1/7] lavu/pixfmt: add new pixel format 0yuv/y210/y410

2019-12-27 Thread Mark Thompson
On 05/12/2019 11:55, James Darnley wrote:
> On 2019-12-04 15:43, Linjie Fu wrote:
>> Previously, media driver provided planar format(like 420 8 bit),
>> but for HEVC Range Extension (422/444 8/10 bit), the decoded image
>> is produced in packed format because Windows expects it.
>>
>> Add some packed pixel formats for hardware decode support in VAAPI
>> and QSV:
>>
>> 4:2:2 10 bit: Y210
>> 4:4:4  8 bit: 0YUV
>> 4:4:4 10 bit: Y410
>>
> 
>> +[AV_PIX_FMT_Y410LE] = {
>> +.name = "y410le",
>> +.nb_components = 4,
>> +.log2_chroma_w = 0,
>> +.log2_chroma_h = 0,
>> +.comp = {
>> +{ 0, 32, 10, 0, 10, 31, 9, 11 },/* Y */
>> +{ 0, 32,  0, 0, 10, 31, 9,  1 },/* U */
>> +{ 0, 32, 20, 0, 10, 31, 9, 21 },/* V */
>> +{ 0, 32, 30, 0,  2, 31, 1, 31 },/* A */
>> +},
>> +.flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM,
>> +},
> 
> 
> 
>> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
>> index d78e863..a163350 100644
>> --- a/libavutil/pixfmt.h
>> +++ b/libavutil/pixfmt.h
>> @@ -348,6 +348,12 @@ enum AVPixelFormat {
>>  AV_PIX_FMT_NV24,  ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 
>> plane for the UV components, which are interleaved (first byte U and the 
>> following byte V)
>>  AV_PIX_FMT_NV42,  ///< as above, but U and V bytes are swapped
>>  
>> +AV_PIX_FMT_Y210BE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
>> big-endian
>> +AV_PIX_FMT_Y210LE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, 
>> little-endian
>> +AV_PIX_FMT_0YUV,  ///< packed YUV 4:4:4, 32bpp,  X  Y Cb Cr, 
>> X=unused/undefined
>> +AV_PIX_FMT_Y410LE,///< packed YUV 4:4:4, 32bpp, Cr  Y Cb  A, 
>> little-endian
>> +AV_PIX_FMT_Y410BE,///< packed YUV 4:4:4, 32bpp, Cr  Y Cb  A, 
>> big-endian
>> +
>>  AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if 
>> you want to link with shared libav* because the number of formats might 
>> differ between versions
>>  };
>>  
> 
> I will ask again.  From
>> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245929.html
> 
>> Why am I suspicious that at least one of those is a re-ordered v210?  I
>> seem to recall that we rejected adding v210 to this list.  Either they
>> don't belong in this list or they don't belong because libavcodec has a
>> proper decoder (at least for v210).
>>
>> This might be the thread I was remembering but March seems too recent
>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/241549.html
>>
>> No real conclusion was reached there.
>>
>> Do bit-packed formats belong in an AVPixelFormat?
> 
> Despite what was said last time I do believe this is packed.  I have
> taken a little time to actually understand these magic number structs.
> 
> y410 is clearly packed like v210.  Look at the those offsets: 0, 10, 20,
> 30.  Packed into a 32-bit word.  Flagged with AV_PIX_FMT_FLAG_BITSTREAM.
> 
> How is that any different to v210?  Can you address a single sample in
> that 1 plane format without using shifts and bit-wise ands?  Isn't that
> the definition of packed?  I do not mean interleaved.
> 
> Okay, y410 is a little better in that it is 444 so the sample order does
> not change through 6 word cycle.  Is that the key difference?
> 
> 
> 
> Do bit-packed formats belong in an AVPixelFormat?
> 
> If yes then I do not object to this patch or any others like this.
> 
> If no then why is this not rejected?
> 
> 
> 
> Does the AV_PIX_FMT_FLAG_BITSTREAM flag mean they do belong?  I admit I
> haven't seen this before so maybe I should shut up and not send this email.

The current precedent would say that it doesn't belong in AVPixelFormat, but it 
is still an in-memory representation of actual pixels that we need to be able 
to refer to.  If it can't be used directly, then it should probably be added as 
an opaque format in order to be able to refer to it when using hardware codecs 
which produce exactly this (ending up with something which looks like the 
exsting hardware formats - they can't be used normally and have specific rules 
for each one, but they are still entries in AVPixelFormat).

Personally I do think that this sort of format should probably be allowed (and 
v210 similarly), but there are ways around the problem if there is consensus 
against it.

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

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

Re: [FFmpeg-devel] [PATCH, 4/7] lavu/hwcontext_vaapi: add vaapi_format_map support for 0YUV/Y210/Y410

2019-12-27 Thread Mark Thompson
On 04/12/2019 14:44, Linjie Fu wrote:
> VA_RT_FORMAT describes the desired sampling format for surface.
> 
> When creating surface, VA_RT_FORMAT will be used firstly to choose
> the expected fourcc/media_format for the surface. And the fourcc
> will be revised by the value of VASurfaceAttribPixelFormat.
> 
> Add vaapi_format_map support for new pixel_format.
> This is fundamental for both VA-API and QSV.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_vaapi.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index cf11764..296234b 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -116,6 +116,13 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = {
>  #endif
>  MAP(UYVY, YUV422,  UYVY422, 0),
>  MAP(YUY2, YUV422,  YUYV422, 0),
> +#ifdef VA_FOURCC_Y210
> +MAP(Y210, YUV422_10, Y210, 0),
> +#endif
> +MAP(AYUV, YUV444,0YUV, 0),
> +#ifdef VA_FOURCC_Y410
> +MAP(Y410, YUV444_10, Y410, 0),
> +#endif
>  MAP(411P, YUV411,  YUV411P, 0),
>  MAP(422V, YUV422,  YUV440P, 0),
>  MAP(444P, YUV444,  YUV444P, 0),

(I've now bought an Ice Lake machine so that I can actually investigate what's 
going on here properly.)

The real problem is that the formats advertised by the driver for H.265/VP9 YUV 
4:4:4 (AYUV and Y410) are incorrect.  There isn't any alpha support anywhere in 
the hardware (none of the multilayer stuff), so using formats with alpha in 
them is wrong and makes all of the attempts to use it extremely confusing.

To fix that we need to change the driver to use formats which actually reflect 
reality.  This is mostly straightforward, because the inner code in the driver 
mainly cares about layout rather than what is actually in each channel.

Some patches which kindof work (not particularly well tested):

libva: 

iHD: 


I've called the non-alpha formats XYUV and XV30 to match libdrm (see 
).   
The 12-bit case also needs some correction - it's currently using Y216 and I 
think assuming that the user knows they need to ignore the alpha channel and 
the lower bits elsewhere, but we might need to have distinct formats to make it 
work properly outside the driver.

- Mark

PS:  It might help to split out the 4:2:2 case (which doesn't have these 
problems because the formats there don't have fake alpha channels or unknown 
depth) to go forward, and look separately at fixing the driver for the others.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 3/3] avdevice/decklink: deprecate the -list_formats option

2019-12-27 Thread Marton Balint
The user should use ffmpeg -sources decklink or ffmpeg -sinks decklink instead.

Signed-off-by: Marton Balint 
---
 doc/indevs.texi  | 6 +++---
 doc/outdevs.texi | 6 +++---
 libavdevice/decklink_dec.cpp | 1 +
 libavdevice/decklink_enc.cpp | 1 +
 libavdevice/version.h| 2 +-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index d5940b8822..b40cfd8227 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -277,8 +277,8 @@ audio track.
 
 @item list_devices
 If set to @option{true}, print a list of devices and exit.
-Defaults to @option{false}. Alternatively you can use the @code{-sources}
-option of ffmpeg to list the available input devices.
+Defaults to @option{false}. This option is deprecated, please use the
+@code{-sources} option of ffmpeg to list the available input devices.
 
 @item list_formats
 If set to @option{true}, print a list of supported formats and exit.
@@ -407,7 +407,7 @@ Defaults to @option{false}.
 @item
 List input devices:
 @example
-ffmpeg -f decklink -list_devices 1 -i dummy
+ffmpeg -sources decklink
 @end example
 
 @item
diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index c96d2d0e43..27f543fa1a 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -140,8 +140,8 @@ device with @command{-list_formats 1}. Audio sample rate is 
always 48 kHz.
 
 @item list_devices
 If set to @option{true}, print a list of devices and exit.
-Defaults to @option{false}. Alternatively you can use the @code{-sinks}
-option of ffmpeg to list the available output devices.
+Defaults to @option{false}. This option is deprecated, please use the
+@code{-sinks} option of ffmpeg to list the available output devices.
 
 @item list_formats
 If set to @option{true}, print a list of supported formats and exit.
@@ -168,7 +168,7 @@ Defaults to @samp{unset}.
 @item
 List output devices:
 @example
-ffmpeg -i test.avi -f decklink -list_devices 1 dummy
+ffmpeg -sinks decklink
 @end example
 
 @item
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 0360bd16fb..1fd5adf515 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1050,6 +1050,7 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 
 /* List available devices. */
 if (ctx->list_devices) {
+av_log(avctx, AV_LOG_WARNING, "The -list_devices option is deprecated 
and will be removed. Please use ffmpeg -sources decklink instead.\n");
 ff_decklink_list_devices_legacy(avctx, 1, 0);
 return AVERROR_EXIT;
 }
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 04b06aee3a..883fdeadfb 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -568,6 +568,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
 
 /* List available devices and exit. */
 if (ctx->list_devices) {
+av_log(avctx, AV_LOG_WARNING, "The -list_devices option is deprecated 
and will be removed. Please use ffmpeg -sinks decklink instead.\n");
 ff_decklink_list_devices_legacy(avctx, 0, 1);
 return AVERROR_EXIT;
 }
diff --git a/libavdevice/version.h b/libavdevice/version.h
index 68302908cf..ec0ba776be 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVDEVICE_VERSION_MAJOR  58
 #define LIBAVDEVICE_VERSION_MINOR   9
-#define LIBAVDEVICE_VERSION_MICRO 101
+#define LIBAVDEVICE_VERSION_MICRO 102
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
LIBAVDEVICE_VERSION_MINOR, \
-- 
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 2/3] avdevice/decklink_dec: remove -bm_v210 option

2019-12-27 Thread Marton Balint
Deprecated since Sep 28, 2017.

Signed-off-by: Marton Balint 
---
 doc/indevs.texi | 7 +--
 libavdevice/decklink_common_c.h | 1 -
 libavdevice/decklink_dec.cpp| 5 -
 libavdevice/decklink_dec_c.c| 1 -
 4 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 92bc65be41..d5940b8822 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -292,11 +292,6 @@ as @option{pal} (3 letters).
 Default behavior is autodetection of the input video format, if the hardware
 supports it.
 
-@item bm_v210
-This is a deprecated option, you can use @option{raw_format} instead.
-If set to @samp{1}, video is captured in 10 bit v210 instead
-of uyvy422. Not all Blackmagic devices support this option.
-
 @item raw_format
 Set the pixel format of the captured video.
 Available values are:
@@ -430,7 +425,7 @@ ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' 
-c:a copy -c:v copy outp
 @item
 Capture video clip at 1080i50 10 bit:
 @example
-ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' 
-c:a copy -c:v copy output.avi
+ffmpeg -raw_format yuv422p10 -format_code Hi50 -f decklink -i 'UltraStudio 
Mini Recorder' -c:a copy -c:v copy output.avi
 @end example
 
 @item
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index b78630b5fc..88b1eae18d 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -42,7 +42,6 @@ struct decklink_cctx {
 int list_formats;
 int64_t teletext_lines;
 double preroll;
-int v210;
 int audio_channels;
 int audio_depth;
 int duplex_mode;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 19ea1eccad..0360bd16fb 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1054,11 +1054,6 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 return AVERROR_EXIT;
 }
 
-if (cctx->v210) {
-av_log(avctx, AV_LOG_WARNING, "The bm_v210 option is deprecated and 
will be removed. Please use the -raw_format yuv422p10.\n");
-cctx->raw_format = MKBETAG('v','2','1','0');
-}
-
 ret = ff_decklink_init_device(avctx, avctx->url);
 if (ret < 0)
 return ret;
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 99439f91ae..b59876994a 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -33,7 +33,6 @@ static const AVOption options[] = {
 { "list_devices", "list available devices"  , OFFSET(list_devices), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
 { "list_formats", "list supported formats"  , OFFSET(list_formats), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
 { "format_code",  "set format by fourcc", OFFSET(format_code),  
AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
-{ "bm_v210",  "v210 10 bit per channel" , OFFSET(v210), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, DEC },
 { "raw_format",   "pixel format to be returned by the card when capturing" 
, OFFSET(raw_format),  AV_OPT_TYPE_INT, { .i64 = MKBETAG('2','v','u','y')}, 0, 
UINT_MAX, DEC, "raw_format" },
 { "uyvy422",   NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 
MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"},
 { "yuv422p10", NULL,   0,  AV_OPT_TYPE_CONST, { .i64 = 
MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"},
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 1/3] avdevice/decklink_dec: remove the @mode syntax

2019-12-27 Thread Marton Balint
Deprecated since March 28, 2017.

Signed-off-by: Marton Balint 
---
 libavdevice/decklink_common.cpp | 11 +--
 libavdevice/decklink_common.h   |  4 ++--
 libavdevice/decklink_dec.cpp| 21 +
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 659aa9be3f..04c0f99edc 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -200,7 +200,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
int width, int height,
int tb_num, int tb_den,
enum AVFieldOrder field_order,
-   decklink_direction_t direction, int num)
+   decklink_direction_t direction)
 {
 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
@@ -214,8 +214,8 @@ int ff_decklink_set_format(AVFormatContext *avctx,
 int i = 1;
 HRESULT res;
 
-av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, 
frame timing %d/%d, field order %d, direction %d, mode number %d, format code 
%s\n",
-width, height, tb_num, tb_den, field_order, direction, num, 
(cctx->format_code) ? cctx->format_code : "(unset)");
+av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, 
frame timing %d/%d, field order %d, direction %d, format code %s\n",
+width, height, tb_num, tb_den, field_order, direction, 
cctx->format_code ? cctx->format_code : "(unset)");
 
 if (direction == DIRECTION_IN) {
 res = ctx->dli->GetDisplayModeIterator (&itermode);
@@ -248,7 +248,6 @@ int ff_decklink_set_format(AVFormatContext *avctx,
  bmd_height == height &&
  !av_cmp_q(mode_tb, target_tb) &&
  field_order_eq(field_order, bmd_field_dominance))
- || i == num
  || target_mode == bmd_mode) {
 ctx->bmd_mode   = bmd_mode;
 ctx->bmd_width  = bmd_width;
@@ -314,8 +313,8 @@ int ff_decklink_set_format(AVFormatContext *avctx,
 return -1;
 }
 
-int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t 
direction, int num) {
-return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, 
direction, num);
+int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t 
direction) {
+return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, 
direction);
 }
 
 int ff_decklink_list_devices(AVFormatContext *avctx,
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 35422a300b..8b3dbce2fb 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -197,8 +197,8 @@ static const BMDTimecodeFormat 
decklink_timecode_format_map[] = {
 };
 
 int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t 
direction);
-int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int 
tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t 
direction = DIRECTION_OUT, int num = 0);
-int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t 
direction, int num);
+int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int 
tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t 
direction = DIRECTION_OUT);
+int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t 
direction);
 int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList 
*device_list, int show_inputs, int show_outputs);
 void ff_decklink_list_devices_legacy(AVFormatContext *avctx, int show_inputs, 
int show_outputs);
 int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t 
direction = DIRECTION_OUT);
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index ab7f28112e..19ea1eccad 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1005,9 +1005,6 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 class decklink_input_callback *input_callback;
 AVStream *st;
 HRESULT result;
-char fname[1024];
-char *tmp;
-int mode_num = 0;
 int ret;
 
 ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
@@ -1062,15 +1059,7 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 cctx->raw_format = MKBETAG('v','2','1','0');
 }
 
-av_strlcpy(fname, avctx->url, sizeof(fname));
-tmp=strchr (fname, '@');
-if (tmp != NULL) {
-av_log(avctx, AV_LOG_WARNING, "The @mode syntax is deprecated and will 
be removed. Please use the -format_code option.\n");
-mode_num = atoi (tmp+1);
-*tmp = 0;
-}
-
-ret = ff_decklink_init_device(avctx, fname);
+ret = ff_decklink_init_device(avctx, avctx->url);
 if (ret < 0)
 return ret;
 
@@ -,7 +11

Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_geq: Add support for reading sample sums and means of rectangles

2019-12-27 Thread Michael Niedermayer
On Fri, Dec 06, 2019 at 05:18:18PM +0100, Michael Niedermayer wrote:
> This allows integrating box blur style filters in geq.
> 
> Without this computing the mean of an area in geq would have been excessivly 
> slow
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_geq.c | 107 +--
>  1 file changed, 103 insertions(+), 4 deletions(-)

will apply

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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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

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

Re: [FFmpeg-devel] [PATCH 2/3] avfilter/vf_geq: Add NB_PLANES

2019-12-27 Thread Michael Niedermayer
On Fri, Dec 06, 2019 at 05:18:17PM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavfilter/vf_geq.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)

will apply

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

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


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

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

Re: [FFmpeg-devel] [PATCH 1/3] avutil/eval: Add av_expr_count_func() similar to av_expr_count_vars()

2019-12-27 Thread Michael Niedermayer
On Tue, Dec 17, 2019 at 11:18:51AM +0100, Michael Niedermayer wrote:
> On Tue, Dec 17, 2019 at 01:50:37AM +0100, Marton Balint wrote:
> > 
> > 
> > On Tue, 17 Dec 2019, Michael Niedermayer wrote:
> > 
> > >On Sun, Dec 15, 2019 at 01:59:23PM +0100, Marton Balint wrote:
> > >>
> > >>
> > >>On Fri, 6 Dec 2019, Michael Niedermayer wrote:
> > >>
> > >>>Signed-off-by: Michael Niedermayer 
> > >>>---
> > >>>libavutil/eval.c | 28 
> > >>>libavutil/eval.h | 11 +++
> > >>>2 files changed, 31 insertions(+), 8 deletions(-)
> > >>>
> > >>>diff --git a/libavutil/eval.c b/libavutil/eval.c
> > >>>index 62d2ae938b..d527f6a9d0 100644
> > >>>--- a/libavutil/eval.c
> > >>>+++ b/libavutil/eval.c
> > >>>@@ -166,8 +166,8 @@ struct AVExpr {
> > >>>   e_sgn,
> > >>>   } type;
> > >>>   double value; // is sign in other types
> > >>>+int const_index;
> > >>>   union {
> > >>>-int const_index;
> > >>>   double (*func0)(double);
> > >>>   double (*func1)(void *, double);
> > >>>   double (*func2)(void *, double, double);
> > >>>@@ -185,7 +185,7 @@ static double eval_expr(Parser *p, AVExpr *e)
> > >>>{
> > >>>   switch (e->type) {
> > >>>   case e_value:  return e->value;
> > >>>-case e_const:  return e->value * 
> > >>>p->const_values[e->a.const_index];
> > >>>+case e_const:  return e->value * 
> > >>>p->const_values[e->const_index];
> > >>>   case e_func0:  return e->value * e->a.func0(eval_expr(p, 
> > >>> e->param[0]));
> > >>>   case e_func1:  return e->value * e->a.func1(p->opaque, 
> > >>> eval_expr(p, e->param[0]));
> > >>>   case e_func2:  return e->value * e->a.func2(p->opaque, 
> > >>> eval_expr(p, e->param[0]), eval_expr(p, e->param[1]));
> > >>>@@ -367,7 +367,7 @@ static int parse_primary(AVExpr **e, Parser *p)
> > >>>   if (strmatch(p->s, p->const_names[i])) {
> > >>>   p->s+= strlen(p->const_names[i]);
> > >>>   d->type = e_const;
> > >>>-d->a.const_index = i;
> > >>>+d->const_index = i;
> > >>>   *e = d;
> > >>>   return 0;
> > >>>   }
> > >>>@@ -478,6 +478,7 @@ static int parse_primary(AVExpr **e, Parser *p)
> > >>>   if (strmatch(next, p->func1_names[i])) {
> > >>>   d->a.func1 = p->funcs1[i];
> > >>>   d->type = e_func1;
> > >>>+d->const_index = i;
> > >>>   *e = d;
> > >>>   return 0;
> > >>>   }
> > >>>@@ -487,6 +488,7 @@ static int parse_primary(AVExpr **e, Parser *p)
> > >>>   if (strmatch(next, p->func2_names[i])) {
> > >>>   d->a.func2 = p->funcs2[i];
> > >>>   d->type = e_func2;
> > >>>+d->const_index = i;
> > >>>   *e = d;
> > >>>   return 0;
> > >>>   }
> > >>>@@ -735,22 +737,32 @@ end:
> > >>>   return ret;
> > >>>}
> > >>>
> > >>>-int av_expr_count_vars(AVExpr *e, unsigned *counter, int size)
> > >>>+static int expr_count(AVExpr *e, unsigned *counter, int size, int type)
> > >>>{
> > >>>   int i;
> > >>>
> > >>>   if (!e || !counter || !size)
> > >>>   return AVERROR(EINVAL);
> > >>>
> > >>>-for (i = 0; e->type != e_const && i < 3 && e->param[i]; i++)
> > >>>-av_expr_count_vars(e->param[i], counter, size);
> > >>>+for (i = 0; e->type != type && i < 3 && e->param[i]; i++)
> > >>>+expr_count(e->param[i], counter, size, type);
> > >>>
> > >>>-if (e->type == e_const && e->a.const_index < size)
> > >>>-counter[e->a.const_index]++;
> > >>>+if (e->type == type && e->const_index < size)
> > >>>+counter[e->const_index]++;
> > >>>
> > >>>   return 0;
> > >>>}
> > >>>
> > >>>+int av_expr_count_vars(AVExpr *e, unsigned *counter, int size)
> > >>>+{
> > >>>+return expr_count(e, counter, size, e_const);
> > >>>+}
> > >>>+
> > >>>+int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg)
> > >>>+{
> > >>>+return expr_count(e, counter, size, ((int[]){e_const, e_func1, 
> > >>>e_func2})[arg]);
> > >>>+}
> > >>>+
> > >>>double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
> > >>>{
> > >>>   Parser p = { 0 };
> > >>>diff --git a/libavutil/eval.h b/libavutil/eval.h
> > >>>index 9bdb10cca2..688c523fbe 100644
> > >>>--- a/libavutil/eval.h
> > >>>+++ b/libavutil/eval.h
> > >>>@@ -96,6 +96,17 @@ double av_expr_eval(AVExpr *e, const double 
> > >>>*const_values, void *opaque);
> > >>>*/
> > >>>int av_expr_count_vars(AVExpr *e, unsigned *counter, int size);
> > >>>
> > >>>+/**
> > >>>+ * Track the presence of functions and their number of occurrences in a 
> > >>>parsed expression
> > >>>+ *
> > >>>+ * @param counter a zero-initialized array where the count of each 
> > >>>function will be stored
> > >>>+ * @param size size of array
> > >>>+ * @param arg number of arguments the counted functions have
> > >>>+ * @return 0 on success, a negative value indicates that no expression 
> > >>>or array was passed
> > >>>+ * or size 

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/vc1dec: Free sprite_output_frame on error

2019-12-27 Thread Michael Niedermayer
On Tue, Dec 17, 2019 at 12:19:45AM +0100, Michael Niedermayer wrote:
> Fixes: memleaks
> Fixes: 
> 19471/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5688035714269184
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1dec.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)

will apply

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

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/vc1dec: Fix "return -1" cases

2019-12-27 Thread Michael Niedermayer
On Tue, Dec 17, 2019 at 09:10:57AM +0800, myp...@gmail.com wrote:
> On Tue, Dec 17, 2019 at 7:23 AM Michael Niedermayer
>  wrote:
> >
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/vc1dec.c | 8 
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
> > index d2f25fabec..fcc482e7eb 100644
> > --- a/libavcodec/vc1dec.c
> > +++ b/libavcodec/vc1dec.c
> > @@ -431,7 +431,7 @@ static av_cold int vc1_decode_init(AVCodecContext 
> > *avctx)
> >  v->output_height = avctx->height;
> >
> >  if (!avctx->extradata_size || !avctx->extradata)
> > -return -1;
> > +return AVERROR_INVALIDDATA;
> >  v->s.avctx = avctx;
> >
> >  if ((ret = ff_vc1_init_common(v)) < 0)
> > @@ -472,7 +472,7 @@ static av_cold int vc1_decode_init(AVCodecContext 
> > *avctx)
> >
> >  if (avctx->extradata_size < 16) {
> >  av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", 
> > avctx->extradata_size);
> > -return -1;
> > +return AVERROR_INVALIDDATA;
> >  }
> >
> >  buf2  = av_mallocz(avctx->extradata_size + 
> > AV_INPUT_BUFFER_PADDING_SIZE);
> > @@ -508,7 +508,7 @@ static av_cold int vc1_decode_init(AVCodecContext 
> > *avctx)
> >  av_free(buf2);
> >  if (!seq_initialized || !ep_initialized) {
> >  av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
> > -return -1;
> > +return AVERROR_INVALIDDATA;
> >  }
> >  v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
> >  }
> > @@ -577,7 +577,7 @@ static av_cold int vc1_decode_init(AVCodecContext 
> > *avctx)
> >  v->sprite_height > 1 << 14 ||
> >  v->output_width  > 1 << 14 ||
> >  v->output_height > 1 << 14) {
> > -ret = -1;
> > +ret = AVERROR_INVALIDDATA;
> >  goto error;
> >  }
> >
> > --
> LGTM

will apply

thx

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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

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

Re: [FFmpeg-devel] [PATCH 8/8] avformat/img2enc: add support for specifying protocol options

2019-12-27 Thread Lou Logan
On Fri, Dec 27, 2019, at 12:14 PM, Marton Balint wrote:
> Signed-off-by: Marton Balint 
>
> +ffmpeg -f x11grab -r 1 -framerate 1 -video_size hd1080 -i :0.0 -qscale 
> 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg

What's the reason this examples uses both -r and -framerate?

Please use -qscale:v to avoid the "-qscale is ambiguous" warning.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/5] avfilter/vf_geq: Relicense to LGPL

2019-12-27 Thread Michael Niedermayer
On Mon, Dec 16, 2019 at 03:40:39PM -0900, Lou Logan wrote:
> On Tue, 17 Dec 2019 01:13:15 +0100 (CET)
> Marton Balint  wrote:
> 
> > 
> > You should also remove the gpl dependency from configure.
> 
> ...and update LICENSE.md.

will apply with these changes

thx

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

Never trust a computer, one day, it may think you are the virus. -- Compn


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

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

Re: [FFmpeg-devel] [PATCH 1/8] doc/muxers: fix order of options and examples for image2 muxer

2019-12-27 Thread Lou Logan
On Fri, Dec 27, 2019, at 12:14 PM, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  doc/muxers.texi | 52 ++--
>  1 file changed, 26 insertions(+), 26 deletions(-)

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

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/atrac9dec: Clamp band_ext_data to max that can be read if skipped.

2019-12-27 Thread Michael Niedermayer
On Thu, Dec 26, 2019 at 05:24:31PM +0100, Lynne wrote:
> Dec 26, 2019, 13:57 by d...@lynne.ee:
> 
> > Dec 16, 2019, 23:19 by mich...@niedermayer.cc:
> >
> >> Fixes: out of array read
> >> Fixes: 
> >> 19327/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5679823087468544
> >>
> >> Found-by: continuous fuzzing process 
> >> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >> Signed-off-by: Michael Niedermayer  
> >>
> 
> Actually nevermind, patch is good as-is. I think a 0 len just means to reuse 
> the parameters from the previous. So clipping them should be fine.
> You should replace the FFMIN(val, (len << 1) - 1) with a av_clip_uintp2(val, 
> len) which does exactly that.

i think both the FFMIN and av_clip_uintp2 do the same thing here, unless
iam missing something. But i agree
The later is a bit prettier, and as you prefer it too, ill change it and will 
apply with that

Thanks

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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

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

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/agm: Include block size in the MV check for flags == 3

2019-12-27 Thread Michael Niedermayer
On Tue, Dec 17, 2019 at 12:19:43AM +0100, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 
> 19331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5644115983466496
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/agm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

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

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


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

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

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/wmadec: Keep track of exponent initialization per channel

2019-12-27 Thread Michael Niedermayer
On Sat, Nov 30, 2019 at 09:26:58PM +0100, Michael Niedermayer wrote:
> Fixes: division by 0
> Fixes: 
> 19123/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAV2_fuzzer-5655493121146880
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wma.h| 2 +-
>  libavcodec/wmadec.c | 9 ++---
>  2 files changed, 7 insertions(+), 4 deletions(-)

will apply

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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 8/8] avformat/img2enc: add support for specifying protocol options

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/muxers.texi   | 11 +++
 libavformat/img2enc.c | 13 -
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index fb5c9bc4c0..a1f801c28d 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1193,6 +1193,11 @@ overwritten with new images. Default value is 0.
 @item strftime
 If set to 1, expand the filename with date and time information from
 @code{strftime()}. Default value is 0.
+
+@item protocol_opts @var{options_list}
+Set protocol options as a :-separated list of key=value parameters. Values
+containing the @code{:} special character must be escaped.
+
 @end table
 
 @subsection Examples
@@ -1235,6 +1240,12 @@ You can set the file name with current frame's PTS:
 ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg"
 @end example
 
+A more complex example is to publish contents of your desktop directly to a
+WebDAV server every second:
+@example
+ffmpeg -f x11grab -r 1 -framerate 1 -video_size hd1080 -i :0.0 -qscale 6 
-update 1 -protocol_opts method=PUT http://example.com/desktop.jpg
+@end example
+
 @section matroska
 
 Matroska container muxer.
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 39398f37a3..0ad4ee11d7 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -23,6 +23,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/dict.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -44,6 +45,7 @@ typedef struct VideoMuxData {
 int frame_pts;
 const char *muxer;
 int use_rename;
+AVDictionary *protocol_opts;
 } VideoMuxData;
 
 static int write_header(AVFormatContext *s)
@@ -133,6 +135,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(par->format);
 int ret, i;
 int nb_renames = 0;
+AVDictionary *options = NULL;
 
 if (img->update) {
 av_strlcpy(filename, img->path, sizeof(filename));
@@ -161,13 +164,19 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 return AVERROR(EINVAL);
 }
 for (i = 0; i < 4; i++) {
+av_dict_copy(&options, img->protocol_opts, 0);
 snprintf(img->tmp[i], sizeof(img->tmp[i]), "%s.tmp", filename);
 av_strlcpy(img->target[i], filename, sizeof(img->target[i]));
-if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : filename, 
AVIO_FLAG_WRITE, NULL) < 0) {
+if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : filename, 
AVIO_FLAG_WRITE, &options) < 0) {
 av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", 
img->use_rename ? img->tmp[i] : filename);
 ret = AVERROR(EIO);
 goto fail;
 }
+if (options) {
+av_log(s, AV_LOG_ERROR, "Could not recognize some protocol 
options\n");
+ret = AVERROR(EINVAL);
+goto fail;
+}
 
 if (!img->split_planes || i+1 >= desc->nb_components)
 break;
@@ -211,6 +220,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 return 0;
 
 fail:
+av_dict_free(&options);
 for (i = 0; i < FF_ARRAY_ELEMS(pb); i++)
 if (pb[i])
 ff_format_io_close(s, &pb[i]);
@@ -236,6 +246,7 @@ static const AVOption muxoptions[] = {
 { "strftime", "use strftime for filename", OFFSET(use_strftime),  
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { "frame_pts","use current frame pts for filename", OFFSET(frame_pts), 
 AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { "atomic_writing", "write files atomically (using temporary files and 
renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
+{ "protocol_opts", "specify protocol options for the opened files", 
OFFSET(protocol_opts), AV_OPT_TYPE_DICT, {0}, 0, 0, ENC },
 { NULL },
 };
 
-- 
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 7/8] avformat/img2enc: fix writing multiple streams in write_muxed_file

2019-12-27 Thread Marton Balint
Maybe we should just reject multiple streams for the image2 muxer instead?

Signed-off-by: Marton Balint 
---
 libavformat/img2enc.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 718c9929f7..39398f37a3 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -74,7 +74,7 @@ static int write_header(AVFormatContext *s)
 static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
 {
 VideoMuxData *img = s->priv_data;
-AVCodecParameters *par = s->streams[0]->codecpar;
+AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
 AVStream *st;
 AVPacket pkt2 = {0};
 AVFormatContext *fmt = NULL;
@@ -93,12 +93,17 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext 
*pb, AVPacket *pkt)
 
 fmt->pb = pb;
 
-if ((ret = av_packet_ref(&pkt2, pkt))  < 0 ||
-(ret = avcodec_parameters_copy(st->codecpar, par)) < 0 ||
+ret = av_packet_ref(&pkt2, pkt);
+if (ret < 0)
+goto out;
+pkt2.stream_index = 0;
+
+if ((ret = avcodec_parameters_copy(st->codecpar, par)) < 0 ||
 (ret = avformat_write_header(fmt, NULL))   < 0 ||
 (ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
 (ret = av_write_trailer(fmt))) {}
 
+out:
 av_packet_unref(&pkt2);
 avformat_free_context(fmt);
 return ret;
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 3/8] avformat/img2enc: factorize piped write_packet

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

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 0ce8ef5bff..dfc7566dad 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -35,7 +35,6 @@
 typedef struct VideoMuxData {
 const AVClass *class;  /**< Class for private options. */
 int img_number;
-int is_pipe;
 int split_planes;   /**< use independent file for each Y, U, V plane */
 char path[1024];
 char tmp[4][1024];
@@ -55,12 +54,6 @@ static int write_header(AVFormatContext *s)
 
 av_strlcpy(img->path, s->url, sizeof(img->path));
 
-/* find format */
-if (s->oformat->flags & AVFMT_NOFILE)
-img->is_pipe = 0;
-else
-img->is_pipe = 1;
-
 if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
 img->muxer = "gif";
 } else if (st->codecpar->codec_id == AV_CODEC_ID_FITS) {
@@ -113,6 +106,21 @@ static int write_muxed_file(AVFormatContext *s, 
AVIOContext *pb, AVPacket *pkt)
 return 0;
 }
 
+static int write_packet_pipe(AVFormatContext *s, AVPacket *pkt)
+{
+VideoMuxData *img = s->priv_data;
+if (img->muxer) {
+int ret = write_muxed_file(s, s->pb, pkt);
+if (ret < 0)
+return ret;
+} else {
+avio_write(s->pb, pkt->data, pkt->size);
+avio_flush(s->pb);
+}
+img->img_number++;
+return 0;
+}
+
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 VideoMuxData *img = s->priv_data;
@@ -123,7 +131,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 int ret, i;
 int nb_renames = 0;
 
-if (!img->is_pipe) {
+{
 if (img->update) {
 av_strlcpy(filename, img->path, sizeof(filename));
 } else if (img->use_strftime) {
@@ -164,8 +172,6 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 if (img->use_rename)
 nb_renames = i + 1;
-} else {
-pb[0] = s->pb;
 }
 
 if (img->split_planes) {
@@ -192,7 +198,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 avio_write(pb[0], pkt->data, pkt->size);
 }
 avio_flush(pb[0]);
-if (!img->is_pipe) {
+{
 ff_format_io_close(s, &pb[0]);
 for (i = 0; i < nb_renames; i++) {
 int ret = ff_rename(img->tmp[i], img->target[i], s);
@@ -257,7 +263,7 @@ AVOutputFormat ff_image2pipe_muxer = {
 .priv_data_size = sizeof(VideoMuxData),
 .video_codec= AV_CODEC_ID_MJPEG,
 .write_header   = write_header,
-.write_packet   = write_packet,
+.write_packet   = write_packet_pipe,
 .query_codec= query_codec,
 .flags  = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS
 };
-- 
2.16.4

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

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

[FFmpeg-devel] [PATCH 6/8] avformat/img2enc: minor simplification

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/img2enc.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 14e6d641f9..718c9929f7 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -92,18 +92,16 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext 
*pb, AVPacket *pkt)
 st->id = pkt->stream_index;
 
 fmt->pb = pb;
+
 if ((ret = av_packet_ref(&pkt2, pkt))  < 0 ||
 (ret = avcodec_parameters_copy(st->codecpar, par)) < 0 ||
 (ret = avformat_write_header(fmt, NULL))   < 0 ||
 (ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
-(ret = av_write_trailer(fmt))  < 0) {
-av_packet_unref(&pkt2);
-avformat_free_context(fmt);
-return ret;
-}
+(ret = av_write_trailer(fmt))) {}
+
 av_packet_unref(&pkt2);
 avformat_free_context(fmt);
-return 0;
+return ret;
 }
 
 static int write_packet_pipe(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 2/8] avformat/img2enc: factorize writing fully muxed file

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/img2enc.c | 65 +--
 1 file changed, 37 insertions(+), 28 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index bec4bf81dd..0ce8ef5bff 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -78,6 +78,41 @@ static int write_header(AVFormatContext *s)
 return 0;
 }
 
+static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
+{
+VideoMuxData *img = s->priv_data;
+AVCodecParameters *par = s->streams[0]->codecpar;
+AVStream *st;
+AVPacket pkt2 = {0};
+AVFormatContext *fmt = NULL;
+int ret;
+
+/* URL is not used directly as we are overriding the IO context later. */
+ret = avformat_alloc_output_context2(&fmt, NULL, img->muxer, s->url);
+if (ret < 0)
+return ret;
+st = avformat_new_stream(fmt, NULL);
+if (!st) {
+avformat_free_context(fmt);
+return AVERROR(ENOMEM);
+}
+st->id = pkt->stream_index;
+
+fmt->pb = pb;
+if ((ret = av_packet_ref(&pkt2, pkt))  < 0 ||
+(ret = avcodec_parameters_copy(st->codecpar, par)) < 0 ||
+(ret = avformat_write_header(fmt, NULL))   < 0 ||
+(ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
+(ret = av_write_trailer(fmt))  < 0) {
+av_packet_unref(&pkt2);
+avformat_free_context(fmt);
+return ret;
+}
+av_packet_unref(&pkt2);
+avformat_free_context(fmt);
+return 0;
+}
+
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 VideoMuxData *img = s->priv_data;
@@ -85,7 +120,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 char filename[1024];
 AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(par->format);
-int i;
+int ret, i;
 int nb_renames = 0;
 
 if (!img->is_pipe) {
@@ -150,35 +185,9 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 ff_format_io_close(s, &pb[3]);
 }
 } else if (img->muxer) {
-int ret;
-AVStream *st;
-AVPacket pkt2 = {0};
-AVFormatContext *fmt = NULL;
-
-av_assert0(!img->split_planes);
-
-ret = avformat_alloc_output_context2(&fmt, NULL, img->muxer, s->url);
+ret = write_muxed_file(s, pb[0], pkt);
 if (ret < 0)
 return ret;
-st = avformat_new_stream(fmt, NULL);
-if (!st) {
-avformat_free_context(fmt);
-return AVERROR(ENOMEM);
-}
-st->id = pkt->stream_index;
-
-fmt->pb = pb[0];
-if ((ret = av_packet_ref(&pkt2, pkt)) < 0 
||
-(ret = avcodec_parameters_copy(st->codecpar, 
s->streams[0]->codecpar)) < 0 ||
-(ret = avformat_write_header(fmt, NULL))  < 0 
||
-(ret = av_interleaved_write_frame(fmt, &pkt2))< 0 
||
-(ret = av_write_trailer(fmt)) < 0) 
{
-av_packet_unref(&pkt2);
-avformat_free_context(fmt);
-return ret;
-}
-av_packet_unref(&pkt2);
-avformat_free_context(fmt);
 } else {
 avio_write(pb[0], pkt->data, pkt->size);
 }
-- 
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 4/8] avformat/img2enc: reindent after last commit

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/img2enc.c | 86 ---
 1 file changed, 41 insertions(+), 45 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index dfc7566dad..a976d07acc 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -131,48 +131,46 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 int ret, i;
 int nb_renames = 0;
 
-{
-if (img->update) {
-av_strlcpy(filename, img->path, sizeof(filename));
-} else if (img->use_strftime) {
-time_t now0;
-struct tm *tm, tmpbuf;
-time(&now0);
-tm = localtime_r(&now0, &tmpbuf);
-if (!strftime(filename, sizeof(filename), img->path, tm)) {
-av_log(s, AV_LOG_ERROR, "Could not get frame filename with 
strftime\n");
-return AVERROR(EINVAL);
-}
-} else if (img->frame_pts) {
-if (av_get_frame_filename2(filename, sizeof(filename), img->path, 
pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
-av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the 
frames.");
-return AVERROR(EINVAL);
-}
-} else if (av_get_frame_filename2(filename, sizeof(filename), 
img->path,
-  img->img_number,
-  AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 
0 &&
-   img->img_number > 1) {
-av_log(s, AV_LOG_ERROR,
-   "Could not get frame filename number %d from pattern '%s'. "
-   "Use '-frames:v 1' for a single image, or '-update' option, 
or use a pattern such as %%03d within the filename.\n",
-   img->img_number, img->path);
+if (img->update) {
+av_strlcpy(filename, img->path, sizeof(filename));
+} else if (img->use_strftime) {
+time_t now0;
+struct tm *tm, tmpbuf;
+time(&now0);
+tm = localtime_r(&now0, &tmpbuf);
+if (!strftime(filename, sizeof(filename), img->path, tm)) {
+av_log(s, AV_LOG_ERROR, "Could not get frame filename with 
strftime\n");
 return AVERROR(EINVAL);
 }
-for (i = 0; i < 4; i++) {
-snprintf(img->tmp[i], sizeof(img->tmp[i]), "%s.tmp", filename);
-av_strlcpy(img->target[i], filename, sizeof(img->target[i]));
-if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : 
filename, AVIO_FLAG_WRITE, NULL) < 0) {
-av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", 
img->use_rename ? img->tmp[i] : filename);
-return AVERROR(EIO);
-}
-
-if (!img->split_planes || i+1 >= desc->nb_components)
-break;
-filename[strlen(filename) - 1] = "UVAx"[i];
+} else if (img->frame_pts) {
+if (av_get_frame_filename2(filename, sizeof(filename), img->path, 
pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
+av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the 
frames.");
+return AVERROR(EINVAL);
+}
+} else if (av_get_frame_filename2(filename, sizeof(filename), img->path,
+  img->img_number,
+  AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
+   img->img_number > 1) {
+av_log(s, AV_LOG_ERROR,
+   "Could not get frame filename number %d from pattern '%s'. "
+   "Use '-frames:v 1' for a single image, or '-update' option, or 
use a pattern such as %%03d within the filename.\n",
+   img->img_number, img->path);
+return AVERROR(EINVAL);
+}
+for (i = 0; i < 4; i++) {
+snprintf(img->tmp[i], sizeof(img->tmp[i]), "%s.tmp", filename);
+av_strlcpy(img->target[i], filename, sizeof(img->target[i]));
+if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : filename, 
AVIO_FLAG_WRITE, NULL) < 0) {
+av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", 
img->use_rename ? img->tmp[i] : filename);
+return AVERROR(EIO);
 }
-if (img->use_rename)
-nb_renames = i + 1;
+
+if (!img->split_planes || i+1 >= desc->nb_components)
+break;
+filename[strlen(filename) - 1] = "UVAx"[i];
 }
+if (img->use_rename)
+nb_renames = i + 1;
 
 if (img->split_planes) {
 int ysize = par->width * par->height;
@@ -198,13 +196,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 avio_write(pb[0], pkt->data, pkt->size);
 }
 avio_flush(pb[0]);
-{
-ff_format_io_close(s, &pb[0]);
-for (i = 0; i < nb_renames; i++) {
-int ret = ff_rename(img->tmp[i], img->target[i], s);
-if (ret < 0)
-return ret;
-}
+ff_format_io_close(s, &pb[0]);
+for (i = 0; i < nb_renames; 

[FFmpeg-devel] [PATCH 5/8] avformat/img2enc: cleanup IO contexts on error

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/img2enc.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index a976d07acc..14e6d641f9 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -124,7 +124,7 @@ static int write_packet_pipe(AVFormatContext *s, AVPacket 
*pkt)
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 VideoMuxData *img = s->priv_data;
-AVIOContext *pb[4];
+AVIOContext *pb[4] = {0};
 char filename[1024];
 AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(par->format);
@@ -162,7 +162,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 av_strlcpy(img->target[i], filename, sizeof(img->target[i]));
 if (s->io_open(s, &pb[i], img->use_rename ? img->tmp[i] : filename, 
AVIO_FLAG_WRITE, NULL) < 0) {
 av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", 
img->use_rename ? img->tmp[i] : filename);
-return AVERROR(EIO);
+ret = AVERROR(EIO);
+goto fail;
 }
 
 if (!img->split_planes || i+1 >= desc->nb_components)
@@ -191,7 +192,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 } else if (img->muxer) {
 ret = write_muxed_file(s, pb[0], pkt);
 if (ret < 0)
-return ret;
+goto fail;
 } else {
 avio_write(pb[0], pkt->data, pkt->size);
 }
@@ -205,6 +206,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 
 img->img_number++;
 return 0;
+
+fail:
+for (i = 0; i < FF_ARRAY_ELEMS(pb); i++)
+if (pb[i])
+ff_format_io_close(s, &pb[i]);
+return ret;
 }
 
 static int query_codec(enum AVCodecID id, int std_compliance)
-- 
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 1/3] avcodec/iff: Check that video_size is large enough for the read parameters

2019-12-27 Thread Michael Niedermayer
On Sat, Nov 30, 2019 at 09:26:56PM +0100, Michael Niedermayer wrote:
> video is allocated before parameters like bpp are read.
> 
> Fixes: out of array access
> Fixes: 
> 19084/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5718556033679360
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/iff.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

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

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



signature.asc
Description: 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 1/8] doc/muxers: fix order of options and examples for image2 muxer

2019-12-27 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/muxers.texi | 52 ++--
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 5d7ff1ab3b..fb5c9bc4c0 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1169,6 +1169,32 @@ The pattern "img%%-%d.jpg" will specify a sequence of 
filenames of the
 form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
 etc.
 
+The image muxer supports the .Y.U.V image file format. This format is
+special in that that each image frame consists of three files, for
+each of the YUV420P components. To read or write this image file format,
+specify the name of the '.Y' file. The muxer will automatically open the
+'.U' and '.V' files as required.
+
+@subsection Options
+
+@table @option
+@item frame_pts
+If set to 1, expand the filename with pts from pkt->pts.
+Default value is 0.
+
+@item start_number
+Start the sequence from the specified number. Default value is 1.
+
+@item update
+If set to 1, the filename will always be interpreted as just a
+filename, not a pattern, and the corresponding file will be continuously
+overwritten with new images. Default value is 0.
+
+@item strftime
+If set to 1, expand the filename with date and time information from
+@code{strftime()}. Default value is 0.
+@end table
+
 @subsection Examples
 
 The following example shows how to use @command{ffmpeg} for creating a
@@ -1209,32 +1235,6 @@ You can set the file name with current frame's PTS:
 ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg"
 @end example
 
-@subsection Options
-
-@table @option
-@item frame_pts
-If set to 1, expand the filename with pts from pkt->pts.
-Default value is 0.
-
-@item start_number
-Start the sequence from the specified number. Default value is 1.
-
-@item update
-If set to 1, the filename will always be interpreted as just a
-filename, not a pattern, and the corresponding file will be continuously
-overwritten with new images. Default value is 0.
-
-@item strftime
-If set to 1, expand the filename with date and time information from
-@code{strftime()}. Default value is 0.
-@end table
-
-The image muxer supports the .Y.U.V image file format. This format is
-special in that that each image frame consists of three files, for
-each of the YUV420P components. To read or write this image file format,
-specify the name of the '.Y' file. The muxer will automatically open the
-'.U' and '.V' files as required.
-
 @section matroska
 
 Matroska container muxer.
-- 
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 01/13] avutil/opt: add full support for AV_OPT_TYPE_DICT

2019-12-27 Thread Marton Balint



On Thu, 26 Dec 2019, Michael Niedermayer wrote:


On Wed, Dec 25, 2019 at 10:43:02PM +0100, Marton Balint wrote:

Now it is possible to set them from a string, to serialize them and to use a
default value.

Signed-off-by: Marton Balint 
---
 libavutil/opt.c | 51 ++-
 libavutil/opt.h | 10 +++---
 2 files changed, 53 insertions(+), 8 deletions(-)


nice patch


Thanks, applied patches 1-3. Will wait a few days more for the rest.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/dashdec: propagate icy to child AVIOContexts

2019-12-27 Thread James Almer
On 12/21/2019 8:11 PM, Liu Steven wrote:
> 
> 
>> 在 2019年12月21日,下午7:03,Marvin Scholz  写道:
>>
>> On 17 Dec 2019, at 1:45, Marvin Scholz wrote:
>>
>>> When the user decides they do not want to to send the Icy-MetaData
>>> header, this should be respected for all requests, not just the first
>>> one.
>>>
>>> Fix #5578
>>> ---
>>> libavformat/dashdec.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>>> index 72ba9605f0..15e79fd51a 100644
>>> --- a/libavformat/dashdec.c
>>> +++ b/libavformat/dashdec.c
>>> @@ -1851,7 +1851,7 @@ static int save_avio_options(AVFormatContext *s)
>>> {
>>> DASHContext *c = s->priv_data;
>>> const char *opts[] = {
>>> -"headers", "user_agent", "cookies", "http_proxy", "referer", 
>>> "rw_timeout", NULL };
>>> +"headers", "user_agent", "cookies", "http_proxy", "referer", 
>>> "rw_timeout", "icy", NULL };
>>> const char **opt = opts;
>>> uint8_t *buf = NULL;
>>> int ret = 0;
>>> -- 
>>> 2.20.1 (Apple Git-117)
>>
>> ping for review, please :)
> 
> LGTM

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

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

Re: [FFmpeg-devel] [PATCH] avformat/hls: propagate icy to child AVIOContexts

2019-12-27 Thread James Almer
On 12/21/2019 8:11 PM, Liu Steven wrote:
> 
> 
>> 在 2019年12月21日,下午7:02,Marvin Scholz  写道:
>>
>> On 17 Dec 2019, at 1:17, Marvin Scholz wrote:
>>
>>> When the user decides they do not want to to send the Icy-MetaData
>>> header, this should be respected for all requests, not just the first
>>> one.
>>>
>>> Fix #5578
>>> ---
>>> libavformat/hls.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>>> index 21353bbad7..4b1bb964ae 100644
>>> --- a/libavformat/hls.c
>>> +++ b/libavformat/hls.c
>>> @@ -1663,7 +1663,7 @@ static int save_avio_options(AVFormatContext *s)
>>> {
>>> HLSContext *c = s->priv_data;
>>> static const char * const opts[] = {
>>> -"headers", "http_proxy", "user_agent", "cookies", "referer", 
>>> "rw_timeout", NULL };
>>> +"headers", "http_proxy", "user_agent", "cookies", "referer", 
>>> "rw_timeout", "icy", NULL };
>>> const char * const * opt = opts;
>>> uint8_t *buf;
>>> int ret = 0;
>>> -- 
>>> 2.20.1 (Apple Git-117)
>>
>> ping for review, please :)
> 
> LGTM

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

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

Re: [FFmpeg-devel] [PATCH] avformat/hls: propagate icy to child AVIOContexts

2019-12-27 Thread James Almer
On 12/21/2019 8:11 PM, Liu Steven wrote:
> 
> 
>> 在 2019年12月21日,下午7:02,Marvin Scholz  写道:
>>
>> On 17 Dec 2019, at 1:17, Marvin Scholz wrote:
>>
>>> When the user decides they do not want to to send the Icy-MetaData
>>> header, this should be respected for all requests, not just the first
>>> one.
>>>
>>> Fix #5578
>>> ---
>>> libavformat/hls.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>>> index 21353bbad7..4b1bb964ae 100644
>>> --- a/libavformat/hls.c
>>> +++ b/libavformat/hls.c
>>> @@ -1663,7 +1663,7 @@ static int save_avio_options(AVFormatContext *s)
>>> {
>>> HLSContext *c = s->priv_data;
>>> static const char * const opts[] = {
>>> -"headers", "http_proxy", "user_agent", "cookies", "referer", 
>>> "rw_timeout", NULL };
>>> +"headers", "http_proxy", "user_agent", "cookies", "referer", 
>>> "rw_timeout", "icy", NULL };
>>> const char * const * opt = opts;
>>> uint8_t *buf;
>>> int ret = 0;
>>> -- 
>>> 2.20.1 (Apple Git-117)
>>
>> ping for review, please :)
> 
> LGTM

Pushed.
___
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] Copying Audio

2019-12-27 Thread Lou Logan
On Fri, Dec 27, 2019, at 12:38 AM, Chris wrote:
> I have a file with audio in the format pcm_s16be. When I try to copy 
> this audio to another file using -c:a copy, it copies the audio but 
> also transcodes it to AAC.
> If it's literally a copy, shouldn't the copy be pcm_s16be as well? How 
> can I do this and wind up with a pcm copy of the original audio? I've 
> tried -c:a pcm_s16be and it fails.
> The complete command is:
> "ffmpeg.exe","-y  -i short.mp4 -c:a copy  married.mp4"
> I am writing the audio to married.mp4 and it works well except for the 
> transcoding to AAC.

This is the ffmpeg-devel mailing list which is for submitting patches.

User help can be found at the ffmpeg-user mailing list.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, Reino Wijnsma  wrote:
> On 2019-12-27T16:48:22+0100, Paul B Mahol  wrote:
>> On 12/27/19, James Almer  wrote:
>>> On 12/27/2019 12:29 PM, Paul B Mahol wrote:
 On 12/27/19, Nicolas George  wrote:
> Paul B Mahol (12019-12-27):
>> I disagree.
>>
>> And yet in the meantime somebody found a bug. This is a big patch, and
>> we have a policy.
>>
 I will not follow such policy.
>>> Paul, you got a positive review. All you have to do is wait a day or so
>>> before pushing. Why are you blowing this so hard?
>> I'm not going to wait a day or so, I gonna push this immediately.
> Why are you always such a deliberate troubleseeker?!
> Every single developer here treats the other with respect AND has respect
> for
> the mailinglist rules here. It's as if you think they don't apply to you at
> all.
> If I'm correct the official rule is to wait for at least 1 week before
> pushing
> a patch, yet you want to push it after hardly 1 day!
> Top-posting is not allowed on this list, yet of all the core developers here
> you're the only one I see doing this very thing quite often. And somehow
> you're
> getting away with it.
> I really don't understand how the other developers keep up with you and your
> childish behaviour.

Both rules being mentioned here are not useful to be strictly followed.

Top-posting is allowed on this list. Discriminating by top-posting is not OK.

The rule you mentioned is to wait for patches that no-one wants to apply/review.

Your interpretation of rule to wait for patch committing at least one
week is dangerous.

As I'm patch creator and code maintainer I'm free to apply any patches.

So to conclude: there is no rule to minimal wait for patch to be
applied after it is reviewed.

It is just that some developers want and like to block my commits, and
this is indeed childish behavior of them as you like to write.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/3] lavf/dump: use a writer.

2019-12-27 Thread Nicolas George
Andriy Gelman (12019-12-27):
> The 3/3 patch fails to apply with git:
> https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/list/?series=68

It is on top of a patch to disable deprecation warnings that was not yet
pushed. It does not matter much right now.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 3/3] lavf/dump: use a writer.

2019-12-27 Thread Andriy Gelman
On Fri, 27. Dec 14:24, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  libavformat/avformat.h |  21 +++
>  libavformat/dump.c | 297 +
>  2 files changed, 175 insertions(+), 143 deletions(-)
> 
> 
> Note: I chose flags instead of is_output because I intent do add new flags
> later, in particular AV_DUMP_FORMAT_NO_METADATA.
> 
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index d4d9a3b06e..95a2c3ca33 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -317,6 +317,7 @@
>  #include "libavcodec/avcodec.h"
>  #include "libavutil/dict.h"
>  #include "libavutil/log.h"
> +#include "libavutil/writer.h"
>  
>  #include "avio.h"
>  #include "libavformat/version.h"
> @@ -2894,6 +2895,26 @@ void av_dump_format(AVFormatContext *ic,
>  const char *url,
>  int is_output);
>  
> +/**
> + * Write detailed information about the input or output format, such as
> + * duration, bitrate, streams, container, programs, metadata, side data,
> + * codec and time base, to an AVWriter.
> + *
> + * @param wr the writer where the format should be written
> + * @param ic the context to analyze
> + * @param index  index of the stream to dump information about
> + * @param urlthe URL to print, such as source or destination file
> + * @param flags  formatting flags, see below
> + */
> +void av_dump_format_to_writer(struct AVWriter wr,
> +  AVFormatContext *ic, int index,
> +  const char *url, unsigned flags);
> +
> +/**
> + * Flag to av_dump_format_to_writer():
> + * if set, the cotext is output; if unset, the context is input.
> + */
> +#define AV_DUMP_FORMAT_IS_OUTPUT 1
>  
>  #define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d
>  
> diff --git a/libavformat/dump.c b/libavformat/dump.c
> index fcf8bad63a..46ca9428b1 100644
> --- a/libavformat/dump.c
> +++ b/libavformat/dump.c
> @@ -33,6 +33,7 @@
>  #include "libavutil/replaygain.h"
>  #include "libavutil/spherical.h"
>  #include "libavutil/stereo3d.h"
> +#include "libavutil/writer.h"
>  
>  #include "avformat.h"
>  
> @@ -117,47 +118,47 @@ void av_pkt_dump_log2(void *avcl, int level, const 
> AVPacket *pkt, int dump_paylo
>  }
>  
>  
> -static void print_fps(double d, const char *postfix)
> +static void print_fps(AVWriter wr, double d, const char *postfix)
>  {
>  uint64_t v = lrintf(d * 100);
>  if (!v)
> -av_log(NULL, AV_LOG_INFO, "%1.4f %s", d, postfix);
> +av_writer_printf(wr, "%1.4f %s", d, postfix);
>  else if (v % 100)
> -av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
> +av_writer_printf(wr, "%3.2f %s", d, postfix);
>  else if (v % (100 * 1000))
> -av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
> +av_writer_printf(wr, "%1.0f %s", d, postfix);
>  else
> -av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
> +av_writer_printf(wr, "%1.0fk %s", d / 1000, postfix);
>  }
>  
> -static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
> +static void dump_metadata(AVWriter wr, AVDictionary *m, const char *indent)
>  {
>  if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 
> 0))) {
>  AVDictionaryEntry *tag = NULL;
>  
> -av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
> +av_writer_printf(wr, "%sMetadata:\n", indent);
>  while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX)))
>  if (strcmp("language", tag->key)) {
>  const char *p = tag->value;
> -av_log(ctx, AV_LOG_INFO,
> +av_writer_printf(wr,
> "%s  %-16s: ", indent, tag->key);
>  while (*p) {
>  char tmp[256];
>  size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
>  av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
> -av_log(ctx, AV_LOG_INFO, "%s", tmp);
> +av_writer_printf(wr, "%s", tmp);
>  p += len;
> -if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
> -if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s  %-16s: ", 
> indent, "");
> +if (*p == 0xd) av_writer_printf(wr, " ");
> +if (*p == 0xa) av_writer_printf(wr, "\n%s  %-16s: ", 
> indent, "");
>  if (*p) p++;
>  }
> -av_log(ctx, AV_LOG_INFO, "\n");
> +av_writer_printf(wr, "\n");
>  }
>  }
>  }
>  
>  /* param change side data*/
> -static void dump_paramchange(void *ctx, AVPacketSideData *sd)
> +static void dump_paramchange(AVWriter wr, AVPacketSideData *sd)
>  {
>  int size = sd->size;
>  const uint8_t *data = sd->data;
> @@ -177,7 +178,7 @@ static void dump_paramchange(void *ctx, AVPacketSideData 
> *sd)
>  c

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Reino Wijnsma
On 2019-12-27T16:48:22+0100, Paul B Mahol  wrote:
> On 12/27/19, James Almer  wrote:
>> On 12/27/2019 12:29 PM, Paul B Mahol wrote:
>>> On 12/27/19, Nicolas George  wrote:
 Paul B Mahol (12019-12-27):
> I disagree.
>
> And yet in the meantime somebody found a bug. This is a big patch, and
> we have a policy.
>
>>> I will not follow such policy.
>> Paul, you got a positive review. All you have to do is wait a day or so
>> before pushing. Why are you blowing this so hard?
> I'm not going to wait a day or so, I gonna push this immediately.
Why are you always such a deliberate troubleseeker?!
Every single developer here treats the other with respect AND has respect for
the mailinglist rules here. It's as if you think they don't apply to you at all.
If I'm correct the official rule is to wait for at least 1 week before pushing
a patch, yet you want to push it after hardly 1 day!
Top-posting is not allowed on this list, yet of all the core developers here
you're the only one I see doing this very thing quite often. And somehow you're
getting away with it.
I really don't understand how the other developers keep up with you and your
childish behaviour.

-- Reino
___
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] -progress option per output

2019-12-27 Thread Nicolas George
vivien anglesio (12019-12-20):
> I would like to work on a "per output" -progress option. I will try to
> implement this myself but before putting my hands on it I wanted to discuss
> about the different solutions with the community. I have three of them in
> mind

I would not object to this, although I doubt it will be very useful.

> Proposition 1. to put all output progress feedback in the same progress
> payload

That could be dangerous: the payload will become large, possibly needing
bigger buffers, or not fitting in a single packet.

> Proposition 2.to change the behavior of the progress option. make it an
> output option instead of a global option
> Proposition 3.to create a new per output progress option in order to do not
> break the current API

Proposition 3 is clearly superior to proposition 2, and seems to be the
most reasonable.

Another possibility is to add another global option to toggle between
current behavior and new behavior.

ffmpeg -progress $address -progress-details

> I also wanted to add the duration of each output in the progress payload.
> Actually we can not infer the duration from the frame count because we are
> not always aware of the framerate.

I think the duration is already there: out_time(_us).

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v1] avcodec/mvha: fix warning: variable 'size' set but not used

2019-12-27 Thread James Almer
On 12/27/2019 1:00 PM, Paul B Mahol wrote:
> lgtm

Pushed.

> 
> On 12/27/19, lance.lmw...@gmail.com  wrote:
>> From: Limin Wang 
>>
>> Signed-off-by: Limin Wang 
>> ---
>>  libavcodec/mvha.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
>> index c270063..afe5e51 100644
>> --- a/libavcodec/mvha.c
>> +++ b/libavcodec/mvha.c
>> @@ -161,6 +161,9 @@ static int decode_frame(AVCodecContext *avctx,
>>  type = AV_RB32(avpkt->data);
>>  size = AV_RL32(avpkt->data + 4);
>>
>> +if (size < 1 || size >= avpkt->size)
>> +return AVERROR_INVALIDDATA;
>> +
>>  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
>>  return ret;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2] avfilter/formats: optimize ff_all_formats

2019-12-27 Thread Nicolas George
zhilizhao (12019-12-24):
> I get the idea. However, if lavi is built agains version A of libavutils
> and use version B at runtime, it’s not guaranteed to work with or without
> access to AV_PIX_FMT_NB:

In principle, it is.

> 1. For major version bump, AV_PIX_FMT_XXX may have different values
> in different versions of libavutils

Major bumps are precisely the time to introduce unavoidable
incompatibilities. But we will not make a major bump when adding a new
pixel format.

> 2. For minor version bump, if there is new AV_PIX_FMT_XXX appends to
> AVPixelFormat, it would be safe to use a smaller AV_PIX_FMT_NB_old.

It may be safe, but it would make ff_all_formats() return not all
formats, which is not acceptable.

> (if we don’t know what the new format is, we don’t know how to deal with it)

If we don't know what the new format is but it is relevant, then we
don't use ff_all_formats(). Look at the filters that use it: mostly
filters that do not depend on the frame data, only the frame properties.

> libavcodec, libavfilter, and libavdevice have access to AV_PIX_FMT_NB.
> 
> Can you help me figure out these contradictions?

They are bugs, they need to be fixed.

The rule is: only use AV_SOMEGHING_NB in the same library.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v2] avutil/mem: Add av_fast_realloc_array()

2019-12-27 Thread Nicolas George
Andreas Rheinhardt (12019-12-26):
> I don't understand. Do you think that callers will take this as a blank
> cheque to not check at all?

No, I mean that using the wrong type will impose limitations on us
later, that will take work to resolve.

> My intention was actually to convert the types for every user of this
> function when using this function (see e.g. the -Matroska demuxer patch).

Good. Then by all means, let us use the right type directly.

> Do we have arrays where there is a need to go beyond the range of ordinary
> integers for the number of elements?

Probably not many right now. But the power an memory of computers
increase, the needs increase too: it is becoming more and more likely to
cause an actual problem; and at the same time, the cost of using the
proper type decreases.


> I'd like not to turn the int/unsigned version of av_fast_realloc_array()
> into a wrapper until there is a real case where an array is needed that
> doesn't fit into an int (or an unsigned).

This is a public API, once it is there, we are stuck with it, including
the types, good or bad. Therefore, I insist we use the proper type from
the start.

>   And switching to size_t
> everywhere would increase the size of certain structures which I very much
> like to avoid (e.g. the size of every MatroskaIndex element would increase
> by eight bytes (for 64 bit systems)).

If you are worried about eight measly bytes, you should start by
rethinking the memory allocation strategy: having a mallocated dynamic
array costs way more than eight bytes.

But if you really need to scrimp and save, you still can, you just need
to use an intermediate variable when calling av_fast_realloc_array().

> That is certainly possible (if "alter ptr the same way nb_allocated is
> altered" means: Via a pointer to a pointer.

Yes, altering the pointer by pointer instead of returning it: that frees
the return value for an error code.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v1] avcodec/mvha: fix warning: variable 'size' set but not used

2019-12-27 Thread Paul B Mahol
lgtm

On 12/27/19, lance.lmw...@gmail.com  wrote:
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/mvha.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
> index c270063..afe5e51 100644
> --- a/libavcodec/mvha.c
> +++ b/libavcodec/mvha.c
> @@ -161,6 +161,9 @@ static int decode_frame(AVCodecContext *avctx,
>  type = AV_RB32(avpkt->data);
>  size = AV_RL32(avpkt->data + 4);
>
> +if (size < 1 || size >= avpkt->size)
> +return AVERROR_INVALIDDATA;
> +
>  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
>  return ret;
>
> --
> 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".

[FFmpeg-devel] [PATCH v1] avcodec/mvha: fix warning: variable 'size' set but not used

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

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

diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c
index c270063..afe5e51 100644
--- a/libavcodec/mvha.c
+++ b/libavcodec/mvha.c
@@ -161,6 +161,9 @@ static int decode_frame(AVCodecContext *avctx,
 type = AV_RB32(avpkt->data);
 size = AV_RL32(avpkt->data + 4);
 
+if (size < 1 || size >= avpkt->size)
+return AVERROR_INVALIDDATA;
+
 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
 return ret;
 
-- 
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] avfilter: add colorstats, colorrgbstats, coloryuvstats video filter

2019-12-27 Thread Paul B Mahol
That is because signalstats is doing more stuff.

On 12/27/19, Limin Wang  wrote:
> On Fri, Dec 27, 2019 at 03:20:19PM +0100, Paul B Mahol wrote:
>> On 12/27/19, Limin Wang  wrote:
>> > On Fri, Dec 27, 2019 at 12:35:25PM +0100, Paul B Mahol wrote:
>> >> You are duplicating some functionality of signalstats filter.
>> >>
>> > Yes, I have other function need to use the mean and stdev which is
>> > support in showinfo filter(only 8bit and don't support packed format,
>> > no multi-thread), and signalstats don't support rgb format and don't
>> > have stdev, also it have too many other function and difficult to change
>> > it, so I think it's more simple to create a new filter to do it.
>> >
>>
>> No, unacceptable. use signalstats filter.
>
> The performance is one major reason also, below is the profiling result for
> performance:
>
> ./ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf
> bench=start,signalstats,bench=stop -f null -
> [bench @ 0x3fb9080] t:0.161589 avg:0.165756 max:0.169923 min:0.161589
> [bench @ 0x3fb9080] t:0.160334 avg:0.163948 max:0.169923 min:0.160334
> [bench @ 0x3fb9080] t:0.160345 avg:0.163047 max:0.169923 min:0.160334
> [bench @ 0x3fb9080] t:0.160924 avg:0.162623 max:0.169923 min:0.160334
> [bench @ 0x3fb9080] t:0.160318 avg:0.162238 max:0.169923 min:0.160318
>
> ./ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf
> bench=start,colorstats,bench=stop -f null -
> [bench @ 0x26f6100] t:0.012596 avg:0.012612 max:0.012628 min:0.012596
> [bench @ 0x26f6100] t:0.012542 avg:0.012588 max:0.012628 min:0.012542
> [bench @ 0x26f6100] t:0.012529 avg:0.012573 max:0.012628 min:0.012529
> [bench @ 0x26f6100] t:0.012532 avg:0.012565 max:0.012628 min:0.012529
> [bench @ 0x26f6100] t:0.012527 avg:0.012559 max:0.012628 min:0.012527
> [bench @ 0x26f6100] t:0.012525 avg:0.012554 max:0.012628 min:0.012525
> [bench @ 0x26f6100] t:0.012522 avg:0.012550 max:0.012628 min:0.012522
> [bench @ 0x26f6100] t:0.012552 avg:0.012550 max:0.012628 min:0.012522
>
>
>>
>> >
>> >> On 12/27/19, lance.lmw...@gmail.com  wrote:
>> >> > From: Limin Wang 
>> >> >
>> >> > Signed-off-by: Limin Wang 
>> >> > ---
>> >> >  doc/filters.texi|  74 ++
>> >> >  libavfilter/Makefile|   1 +
>> >> >  libavfilter/allfilters.c|   3 +
>> >> >  libavfilter/vf_colorstats.c | 461
>> >> > 
>> >> >  4 files changed, 539 insertions(+)
>> >> >  create mode 100644 libavfilter/vf_colorstats.c
>> >> >
>> >> > diff --git a/doc/filters.texi b/doc/filters.texi
>> >> > index 8c5d3a5760..81968b2c17 100644
>> >> > --- a/doc/filters.texi
>> >> > +++ b/doc/filters.texi
>> >> > @@ -7695,6 +7695,80 @@ For example to convert the input to
>> >> > SMPTE-240M,
>> >> > use
>> >> > the command:
>> >> >  colorspace=smpte240m
>> >> >  @end example
>> >> >
>> >> > +@section colorstats, colorrgbstats, coloryuvstats
>> >> > +The filter provides statistical video measurements such as mean,
>> >> > minimum,
>> >> > maximum and
>> >> > +standard deviation for each frame. The user can check for
>> >> > unexpected/accidental errors
>> >> > +very quickly with them.
>> >> > +
>> >> > +@var{colorrgbstats} report the color stats for RGB input video,
>> >> > @var{coloryuvstats}
>> >> > +to an YUV input video.
>> >> > +
>> >> > +These filters accept the following parameters:
>> >> > +@table @option
>> >> > +@item planes
>> >> > +Set which planes to filter. Default is only the first plane.
>> >> > +@end table
>> >> > +
>> >> > +By default the filter will report these metadata values if the
>> >> > planes
>> >> > +are processed:
>> >> > +
>> >> > +@table @option
>> >> > +@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
>> >> > +Display the minimal Y/U/V/R/G/B/A plane value contained within the
>> >> > input
>> >> > frame.
>> >> > +Expressed in range of [0, 1<> >> > +
>> >> > +@item pmin.y, pmin.u, pmin.v, pmin.r, pmin.g, pmin.b, min.a
>> >> > +Display the minimal Y/U/V/R/G/B/A plane percentage of maximum
>> >> > contained
>> >> > within
>> >> > +the input frame. Expressed in range of [0, 1]
>> >> > +
>> >> > +@item max.y, max.u, max.v, max.r, max.g, max.b, max.a
>> >> > +Display the maximum Y/U/V/R/G/B/A plane value contained within the
>> >> > input
>> >> > frame.
>> >> > +Expressed in range of [0, 1<> >> > +
>> >> > +@item pmax.y, pmax.u, pmax.v, pmax.r, pmax.g, pmax.b, pmax.a
>> >> > +Display the maximum Y/U/V/R/G/B/A plane percentage of maximum
>> >> > contained
>> >> > within
>> >> > +the input frame. Expressed in range of [0, 1]
>> >> > +
>> >> > +@item mean.y, mean.u, mean.v, mean.r, mean.g, mean.b, mean.a
>> >> > +Display the Y/U/V/R/G/B/A plane mean value contained within the
>> >> > input
>> >> > frame.
>> >> > +Expressed in range of [0, 1<> >> > +
>> >> > +@item pmean.y, pmean.u, pmean.v, pmean.r, pmean.g, pmean.b, pmean.a
>> >> > +Display the Y/U/V/R/G/B/A plane mean value percentage of maximum
>> >> > contained
>> >> > within
>> >> > +the input frame. Expressed in range of [0, 1]
>> >> > +
>> >> > +@item stdev.y

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, James Almer  wrote:
> On 12/27/2019 12:29 PM, Paul B Mahol wrote:
>> On 12/27/19, Nicolas George  wrote:
>>> Paul B Mahol (12019-12-27):
 I disagree.
>>>
>>> And yet in the meantime somebody found a bug. This is a big patch, and
>>> we have a policy.
>>>
>>
>> I will not follow such policy.
>
> Paul, you got a positive review. All you have to do is wait a day or so
> before pushing. Why are you blowing this so hard?

I'm not going to wait a day or so, I gonna push this immediately.

>
>>
>>> --
>>>   Nicolas George
>>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>>
>
> ___
> 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 colorstats, colorrgbstats, coloryuvstats video filter

2019-12-27 Thread Limin Wang
On Fri, Dec 27, 2019 at 03:20:19PM +0100, Paul B Mahol wrote:
> On 12/27/19, Limin Wang  wrote:
> > On Fri, Dec 27, 2019 at 12:35:25PM +0100, Paul B Mahol wrote:
> >> You are duplicating some functionality of signalstats filter.
> >>
> > Yes, I have other function need to use the mean and stdev which is
> > support in showinfo filter(only 8bit and don't support packed format,
> > no multi-thread), and signalstats don't support rgb format and don't
> > have stdev, also it have too many other function and difficult to change
> > it, so I think it's more simple to create a new filter to do it.
> >
> 
> No, unacceptable. use signalstats filter.

The performance is one major reason also, below is the profiling result for
performance:

./ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf 
bench=start,signalstats,bench=stop -f null -
[bench @ 0x3fb9080] t:0.161589 avg:0.165756 max:0.169923 min:0.161589
[bench @ 0x3fb9080] t:0.160334 avg:0.163948 max:0.169923 min:0.160334
[bench @ 0x3fb9080] t:0.160345 avg:0.163047 max:0.169923 min:0.160334
[bench @ 0x3fb9080] t:0.160924 avg:0.162623 max:0.169923 min:0.160334
[bench @ 0x3fb9080] t:0.160318 avg:0.162238 max:0.169923 min:0.160318

./ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf 
bench=start,colorstats,bench=stop -f null -
[bench @ 0x26f6100] t:0.012596 avg:0.012612 max:0.012628 min:0.012596
[bench @ 0x26f6100] t:0.012542 avg:0.012588 max:0.012628 min:0.012542
[bench @ 0x26f6100] t:0.012529 avg:0.012573 max:0.012628 min:0.012529
[bench @ 0x26f6100] t:0.012532 avg:0.012565 max:0.012628 min:0.012529
[bench @ 0x26f6100] t:0.012527 avg:0.012559 max:0.012628 min:0.012527
[bench @ 0x26f6100] t:0.012525 avg:0.012554 max:0.012628 min:0.012525
[bench @ 0x26f6100] t:0.012522 avg:0.012550 max:0.012628 min:0.012522
[bench @ 0x26f6100] t:0.012552 avg:0.012550 max:0.012628 min:0.012522


> 
> >
> >> On 12/27/19, lance.lmw...@gmail.com  wrote:
> >> > From: Limin Wang 
> >> >
> >> > Signed-off-by: Limin Wang 
> >> > ---
> >> >  doc/filters.texi|  74 ++
> >> >  libavfilter/Makefile|   1 +
> >> >  libavfilter/allfilters.c|   3 +
> >> >  libavfilter/vf_colorstats.c | 461 
> >> >  4 files changed, 539 insertions(+)
> >> >  create mode 100644 libavfilter/vf_colorstats.c
> >> >
> >> > diff --git a/doc/filters.texi b/doc/filters.texi
> >> > index 8c5d3a5760..81968b2c17 100644
> >> > --- a/doc/filters.texi
> >> > +++ b/doc/filters.texi
> >> > @@ -7695,6 +7695,80 @@ For example to convert the input to SMPTE-240M,
> >> > use
> >> > the command:
> >> >  colorspace=smpte240m
> >> >  @end example
> >> >
> >> > +@section colorstats, colorrgbstats, coloryuvstats
> >> > +The filter provides statistical video measurements such as mean,
> >> > minimum,
> >> > maximum and
> >> > +standard deviation for each frame. The user can check for
> >> > unexpected/accidental errors
> >> > +very quickly with them.
> >> > +
> >> > +@var{colorrgbstats} report the color stats for RGB input video,
> >> > @var{coloryuvstats}
> >> > +to an YUV input video.
> >> > +
> >> > +These filters accept the following parameters:
> >> > +@table @option
> >> > +@item planes
> >> > +Set which planes to filter. Default is only the first plane.
> >> > +@end table
> >> > +
> >> > +By default the filter will report these metadata values if the planes
> >> > +are processed:
> >> > +
> >> > +@table @option
> >> > +@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
> >> > +Display the minimal Y/U/V/R/G/B/A plane value contained within the
> >> > input
> >> > frame.
> >> > +Expressed in range of [0, 1< >> > +
> >> > +@item pmin.y, pmin.u, pmin.v, pmin.r, pmin.g, pmin.b, min.a
> >> > +Display the minimal Y/U/V/R/G/B/A plane percentage of maximum contained
> >> > within
> >> > +the input frame. Expressed in range of [0, 1]
> >> > +
> >> > +@item max.y, max.u, max.v, max.r, max.g, max.b, max.a
> >> > +Display the maximum Y/U/V/R/G/B/A plane value contained within the
> >> > input
> >> > frame.
> >> > +Expressed in range of [0, 1< >> > +
> >> > +@item pmax.y, pmax.u, pmax.v, pmax.r, pmax.g, pmax.b, pmax.a
> >> > +Display the maximum Y/U/V/R/G/B/A plane percentage of maximum contained
> >> > within
> >> > +the input frame. Expressed in range of [0, 1]
> >> > +
> >> > +@item mean.y, mean.u, mean.v, mean.r, mean.g, mean.b, mean.a
> >> > +Display the Y/U/V/R/G/B/A plane mean value contained within the input
> >> > frame.
> >> > +Expressed in range of [0, 1< >> > +
> >> > +@item pmean.y, pmean.u, pmean.v, pmean.r, pmean.g, pmean.b, pmean.a
> >> > +Display the Y/U/V/R/G/B/A plane mean value percentage of maximum
> >> > contained
> >> > within
> >> > +the input frame. Expressed in range of [0, 1]
> >> > +
> >> > +@item stdev.y, stdev.u, stdev.v, stdev.r, stdev.g, stdev.b, stdev.a
> >> > +Display the Y/U/V/R/G/B/A plane standard deviation value contained
> >> > within
> >> > the
> >> > +input frame. Expressed in range of [0, 1< >> > +
> >> > +@item pstdev.y, pstdev.u, pstdev.v, pstdev.

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread James Almer
On 12/27/2019 12:29 PM, Paul B Mahol wrote:
> On 12/27/19, Nicolas George  wrote:
>> Paul B Mahol (12019-12-27):
>>> I disagree.
>>
>> And yet in the meantime somebody found a bug. This is a big patch, and
>> we have a policy.
>>
> 
> I will not follow such policy.

Paul, you got a positive review. All you have to do is wait a day or so
before pushing. Why are you blowing this so hard?

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

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

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

Re: [FFmpeg-devel] [PATCH] lavu/avstring: deprecate av_d2str().

2019-12-27 Thread Nicolas George
James Almer (12019-12-26):
> I guess we'll bumping in the coming months (it's been a long while since
> the last time, and some cleaning is in order), so might as well make
> this < 58 so we don't have to postpone it later.

Ok, locally changed to 58.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, Nicolas George  wrote:
> Paul B Mahol (12019-12-27):
>> I disagree.
>
> And yet in the meantime somebody found a bug. This is a big patch, and
> we have a policy.
>

I will not follow such policy.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Nicolas George
Paul B Mahol (12019-12-27):
> I disagree.

And yet in the meantime somebody found a bug. This is a big patch, and
we have a policy.

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, Nicolas George  wrote:
> Paul B Mahol (12019-12-27):
>> Will apply in 5 minutes.
>
> Too soon. Let other people time to spot problems and voice objections.

I disagree.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread James Almer
On 12/26/2019 5:25 PM, Paul B Mahol wrote:
> +if (s->thistogram)
> +return ff_filter_frame(outlink, av_frame_clone(out));

av_frame_clone() can fail to allocate an AVFrame struct and return NULL,
which will make ff_filter_frame() crash as it doesn't expect frame to be
NULL.

> +else
> +return ff_filter_frame(outlink, out);

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Nicolas George
Paul B Mahol (12019-12-27):
> Will apply in 5 minutes.

Too soon. Let other people time to spot problems and voice objections.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
Will apply in 5 minutes.
___
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 colorstats, colorrgbstats, coloryuvstats video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, Limin Wang  wrote:
> On Fri, Dec 27, 2019 at 12:35:25PM +0100, Paul B Mahol wrote:
>> You are duplicating some functionality of signalstats filter.
>>
> Yes, I have other function need to use the mean and stdev which is
> support in showinfo filter(only 8bit and don't support packed format,
> no multi-thread), and signalstats don't support rgb format and don't
> have stdev, also it have too many other function and difficult to change
> it, so I think it's more simple to create a new filter to do it.
>

No, unacceptable. use signalstats filter.

>
>> On 12/27/19, lance.lmw...@gmail.com  wrote:
>> > From: Limin Wang 
>> >
>> > Signed-off-by: Limin Wang 
>> > ---
>> >  doc/filters.texi|  74 ++
>> >  libavfilter/Makefile|   1 +
>> >  libavfilter/allfilters.c|   3 +
>> >  libavfilter/vf_colorstats.c | 461 
>> >  4 files changed, 539 insertions(+)
>> >  create mode 100644 libavfilter/vf_colorstats.c
>> >
>> > diff --git a/doc/filters.texi b/doc/filters.texi
>> > index 8c5d3a5760..81968b2c17 100644
>> > --- a/doc/filters.texi
>> > +++ b/doc/filters.texi
>> > @@ -7695,6 +7695,80 @@ For example to convert the input to SMPTE-240M,
>> > use
>> > the command:
>> >  colorspace=smpte240m
>> >  @end example
>> >
>> > +@section colorstats, colorrgbstats, coloryuvstats
>> > +The filter provides statistical video measurements such as mean,
>> > minimum,
>> > maximum and
>> > +standard deviation for each frame. The user can check for
>> > unexpected/accidental errors
>> > +very quickly with them.
>> > +
>> > +@var{colorrgbstats} report the color stats for RGB input video,
>> > @var{coloryuvstats}
>> > +to an YUV input video.
>> > +
>> > +These filters accept the following parameters:
>> > +@table @option
>> > +@item planes
>> > +Set which planes to filter. Default is only the first plane.
>> > +@end table
>> > +
>> > +By default the filter will report these metadata values if the planes
>> > +are processed:
>> > +
>> > +@table @option
>> > +@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
>> > +Display the minimal Y/U/V/R/G/B/A plane value contained within the
>> > input
>> > frame.
>> > +Expressed in range of [0, 1<> > +
>> > +@item pmin.y, pmin.u, pmin.v, pmin.r, pmin.g, pmin.b, min.a
>> > +Display the minimal Y/U/V/R/G/B/A plane percentage of maximum contained
>> > within
>> > +the input frame. Expressed in range of [0, 1]
>> > +
>> > +@item max.y, max.u, max.v, max.r, max.g, max.b, max.a
>> > +Display the maximum Y/U/V/R/G/B/A plane value contained within the
>> > input
>> > frame.
>> > +Expressed in range of [0, 1<> > +
>> > +@item pmax.y, pmax.u, pmax.v, pmax.r, pmax.g, pmax.b, pmax.a
>> > +Display the maximum Y/U/V/R/G/B/A plane percentage of maximum contained
>> > within
>> > +the input frame. Expressed in range of [0, 1]
>> > +
>> > +@item mean.y, mean.u, mean.v, mean.r, mean.g, mean.b, mean.a
>> > +Display the Y/U/V/R/G/B/A plane mean value contained within the input
>> > frame.
>> > +Expressed in range of [0, 1<> > +
>> > +@item pmean.y, pmean.u, pmean.v, pmean.r, pmean.g, pmean.b, pmean.a
>> > +Display the Y/U/V/R/G/B/A plane mean value percentage of maximum
>> > contained
>> > within
>> > +the input frame. Expressed in range of [0, 1]
>> > +
>> > +@item stdev.y, stdev.u, stdev.v, stdev.r, stdev.g, stdev.b, stdev.a
>> > +Display the Y/U/V/R/G/B/A plane standard deviation value contained
>> > within
>> > the
>> > +input frame. Expressed in range of [0, 1<> > +
>> > +@item pstdev.y, pstdev.u, pstdev.v, pstdev.r, pstdev.g, pstdev.b,
>> > pstdev.a
>> > +Display the Y/U/V/R/G/B/A plane standard deviation value percentage of
>> > maximum contained
>> > +within the input frame. Expressed in range of [0, 1]
>> > +@end table
>> > +
>> > +@subsection Examples
>> > +
>> > +@itemize
>> > +@item
>> > +Show all YUV color stats for each frame:
>> > +@example
>> > +ffprobe -f lavfi movie=example.mov,coloryuvstats=planes=0xf
>> > -show_frames
>> > +@end example
>> > +
>> > +@item
>> > +Draw graph for the pmean and pstdev value of the Y plane per frame:
>> > +@example
>> > +ffplay -i example.mov -vf
>> > coloryuvstats,drawgraph=m1=lavf.colorstats.pmean.y:m2=lavf.colorstats.pstdev.y:min=0:max=1
>> > +@end example
>> > +
>> > +@item
>> > +Print all RGB color stats for each frame:
>> > +@example
>> > +ffplay -i example.mov -vf colorrgbstats=planes=0xf,metadata=mode=print
>> > +@end example
>> > +
>> > +@end itemize
>> > +
>> >  @section convolution
>> >
>> >  Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49
>> > elements.
>> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> > index 37d4eee858..a007bd32d1 100644
>> > --- a/libavfilter/Makefile
>> > +++ b/libavfilter/Makefile
>> > @@ -182,6 +182,7 @@ OBJS-$(CONFIG_CIESCOPE_FILTER)   +=
>> > vf_ciescope.o
>> >  OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
>> >  OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
>> >  OBJS-$(CONFIG_C

Re: [FFmpeg-devel] [PATCH v1] avfilter: add colorstats, colorrgbstats, coloryuvstats video filter

2019-12-27 Thread Limin Wang
On Fri, Dec 27, 2019 at 12:35:25PM +0100, Paul B Mahol wrote:
> You are duplicating some functionality of signalstats filter.
> 
Yes, I have other function need to use the mean and stdev which is
support in showinfo filter(only 8bit and don't support packed format,
no multi-thread), and signalstats don't support rgb format and don't
have stdev, also it have too many other function and difficult to change
it, so I think it's more simple to create a new filter to do it.


> On 12/27/19, lance.lmw...@gmail.com  wrote:
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/filters.texi|  74 ++
> >  libavfilter/Makefile|   1 +
> >  libavfilter/allfilters.c|   3 +
> >  libavfilter/vf_colorstats.c | 461 
> >  4 files changed, 539 insertions(+)
> >  create mode 100644 libavfilter/vf_colorstats.c
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 8c5d3a5760..81968b2c17 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -7695,6 +7695,80 @@ For example to convert the input to SMPTE-240M, use
> > the command:
> >  colorspace=smpte240m
> >  @end example
> >
> > +@section colorstats, colorrgbstats, coloryuvstats
> > +The filter provides statistical video measurements such as mean, minimum,
> > maximum and
> > +standard deviation for each frame. The user can check for
> > unexpected/accidental errors
> > +very quickly with them.
> > +
> > +@var{colorrgbstats} report the color stats for RGB input video,
> > @var{coloryuvstats}
> > +to an YUV input video.
> > +
> > +These filters accept the following parameters:
> > +@table @option
> > +@item planes
> > +Set which planes to filter. Default is only the first plane.
> > +@end table
> > +
> > +By default the filter will report these metadata values if the planes
> > +are processed:
> > +
> > +@table @option
> > +@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
> > +Display the minimal Y/U/V/R/G/B/A plane value contained within the input
> > frame.
> > +Expressed in range of [0, 1< > +
> > +@item pmin.y, pmin.u, pmin.v, pmin.r, pmin.g, pmin.b, min.a
> > +Display the minimal Y/U/V/R/G/B/A plane percentage of maximum contained
> > within
> > +the input frame. Expressed in range of [0, 1]
> > +
> > +@item max.y, max.u, max.v, max.r, max.g, max.b, max.a
> > +Display the maximum Y/U/V/R/G/B/A plane value contained within the input
> > frame.
> > +Expressed in range of [0, 1< > +
> > +@item pmax.y, pmax.u, pmax.v, pmax.r, pmax.g, pmax.b, pmax.a
> > +Display the maximum Y/U/V/R/G/B/A plane percentage of maximum contained
> > within
> > +the input frame. Expressed in range of [0, 1]
> > +
> > +@item mean.y, mean.u, mean.v, mean.r, mean.g, mean.b, mean.a
> > +Display the Y/U/V/R/G/B/A plane mean value contained within the input
> > frame.
> > +Expressed in range of [0, 1< > +
> > +@item pmean.y, pmean.u, pmean.v, pmean.r, pmean.g, pmean.b, pmean.a
> > +Display the Y/U/V/R/G/B/A plane mean value percentage of maximum contained
> > within
> > +the input frame. Expressed in range of [0, 1]
> > +
> > +@item stdev.y, stdev.u, stdev.v, stdev.r, stdev.g, stdev.b, stdev.a
> > +Display the Y/U/V/R/G/B/A plane standard deviation value contained within
> > the
> > +input frame. Expressed in range of [0, 1< > +
> > +@item pstdev.y, pstdev.u, pstdev.v, pstdev.r, pstdev.g, pstdev.b, pstdev.a
> > +Display the Y/U/V/R/G/B/A plane standard deviation value percentage of
> > maximum contained
> > +within the input frame. Expressed in range of [0, 1]
> > +@end table
> > +
> > +@subsection Examples
> > +
> > +@itemize
> > +@item
> > +Show all YUV color stats for each frame:
> > +@example
> > +ffprobe -f lavfi movie=example.mov,coloryuvstats=planes=0xf -show_frames
> > +@end example
> > +
> > +@item
> > +Draw graph for the pmean and pstdev value of the Y plane per frame:
> > +@example
> > +ffplay -i example.mov -vf
> > coloryuvstats,drawgraph=m1=lavf.colorstats.pmean.y:m2=lavf.colorstats.pstdev.y:min=0:max=1
> > +@end example
> > +
> > +@item
> > +Print all RGB color stats for each frame:
> > +@example
> > +ffplay -i example.mov -vf colorrgbstats=planes=0xf,metadata=mode=print
> > +@end example
> > +
> > +@end itemize
> > +
> >  @section convolution
> >
> >  Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49
> > elements.
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index 37d4eee858..a007bd32d1 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -182,6 +182,7 @@ OBJS-$(CONFIG_CIESCOPE_FILTER)   +=
> > vf_ciescope.o
> >  OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
> >  OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
> >  OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
> > +OBJS-$(CONFIG_COLORSTATS_FILTER) += vf_colorstats.o
> >  OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
> >  OBJS-$(CONFIG_COLORKEY_OPENCL_FILTER)+= vf_col

[FFmpeg-devel] [PATCH 3/3] lavf/dump: use a writer.

2019-12-27 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavformat/avformat.h |  21 +++
 libavformat/dump.c | 297 +
 2 files changed, 175 insertions(+), 143 deletions(-)


Note: I chose flags instead of is_output because I intent do add new flags
later, in particular AV_DUMP_FORMAT_NO_METADATA.


diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d4d9a3b06e..95a2c3ca33 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -317,6 +317,7 @@
 #include "libavcodec/avcodec.h"
 #include "libavutil/dict.h"
 #include "libavutil/log.h"
+#include "libavutil/writer.h"
 
 #include "avio.h"
 #include "libavformat/version.h"
@@ -2894,6 +2895,26 @@ void av_dump_format(AVFormatContext *ic,
 const char *url,
 int is_output);
 
+/**
+ * Write detailed information about the input or output format, such as
+ * duration, bitrate, streams, container, programs, metadata, side data,
+ * codec and time base, to an AVWriter.
+ *
+ * @param wr the writer where the format should be written
+ * @param ic the context to analyze
+ * @param index  index of the stream to dump information about
+ * @param urlthe URL to print, such as source or destination file
+ * @param flags  formatting flags, see below
+ */
+void av_dump_format_to_writer(struct AVWriter wr,
+  AVFormatContext *ic, int index,
+  const char *url, unsigned flags);
+
+/**
+ * Flag to av_dump_format_to_writer():
+ * if set, the cotext is output; if unset, the context is input.
+ */
+#define AV_DUMP_FORMAT_IS_OUTPUT 1
 
 #define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d
 
diff --git a/libavformat/dump.c b/libavformat/dump.c
index fcf8bad63a..46ca9428b1 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -33,6 +33,7 @@
 #include "libavutil/replaygain.h"
 #include "libavutil/spherical.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/writer.h"
 
 #include "avformat.h"
 
@@ -117,47 +118,47 @@ void av_pkt_dump_log2(void *avcl, int level, const 
AVPacket *pkt, int dump_paylo
 }
 
 
-static void print_fps(double d, const char *postfix)
+static void print_fps(AVWriter wr, double d, const char *postfix)
 {
 uint64_t v = lrintf(d * 100);
 if (!v)
-av_log(NULL, AV_LOG_INFO, "%1.4f %s", d, postfix);
+av_writer_printf(wr, "%1.4f %s", d, postfix);
 else if (v % 100)
-av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
+av_writer_printf(wr, "%3.2f %s", d, postfix);
 else if (v % (100 * 1000))
-av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
+av_writer_printf(wr, "%1.0f %s", d, postfix);
 else
-av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
+av_writer_printf(wr, "%1.0fk %s", d / 1000, postfix);
 }
 
-static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
+static void dump_metadata(AVWriter wr, AVDictionary *m, const char *indent)
 {
 if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) {
 AVDictionaryEntry *tag = NULL;
 
-av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
+av_writer_printf(wr, "%sMetadata:\n", indent);
 while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX)))
 if (strcmp("language", tag->key)) {
 const char *p = tag->value;
-av_log(ctx, AV_LOG_INFO,
+av_writer_printf(wr,
"%s  %-16s: ", indent, tag->key);
 while (*p) {
 char tmp[256];
 size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
 av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
-av_log(ctx, AV_LOG_INFO, "%s", tmp);
+av_writer_printf(wr, "%s", tmp);
 p += len;
-if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
-if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s  %-16s: ", 
indent, "");
+if (*p == 0xd) av_writer_printf(wr, " ");
+if (*p == 0xa) av_writer_printf(wr, "\n%s  %-16s: ", 
indent, "");
 if (*p) p++;
 }
-av_log(ctx, AV_LOG_INFO, "\n");
+av_writer_printf(wr, "\n");
 }
 }
 }
 
 /* param change side data*/
-static void dump_paramchange(void *ctx, AVPacketSideData *sd)
+static void dump_paramchange(AVWriter wr, AVPacketSideData *sd)
 {
 int size = sd->size;
 const uint8_t *data = sd->data;
@@ -177,7 +178,7 @@ static void dump_paramchange(void *ctx, AVPacketSideData 
*sd)
 channels = AV_RL32(data);
 data += 4;
 size -= 4;
-av_log(ctx, AV_LOG_INFO, "channel count %"PRIu32", ", channels);
+av_writer_printf(wr, "channel count %"PRIu32", ", channels);
 }
 if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
 if (size < 8)
@@ -18

[FFmpeg-devel] [PATCH 2/3] lavu/writer: add test.

2019-12-27 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavutil/Makefile |   1 +
 libavutil/tests/.gitignore |   1 +
 libavutil/tests/writer.c   | 190 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/writer  |  36 +++
 5 files changed, 232 insertions(+)
 create mode 100644 libavutil/tests/writer.c
 create mode 100644 tests/ref/fate/writer

diff --git a/libavutil/Makefile b/libavutil/Makefile
index b4609cd7bf..029bc3458d 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -241,6 +241,7 @@ TESTPROGS = adler32 
\
 utf8\
 xtea\
 tea \
+writer  \
 
 TESTPROGS-$(HAVE_THREADS)+= cpu_init
 TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
index 9d90827954..0fd8026bd2 100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@ -49,3 +49,4 @@
 /twofish
 /utf8
 /xtea
+/writer
diff --git a/libavutil/tests/writer.c b/libavutil/tests/writer.c
new file mode 100644
index 00..5a5d3cf76a
--- /dev/null
+++ b/libavutil/tests/writer.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2019 Nicolas George
+ *
+ * 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/error.h"
+#include "libavutil/log.h"
+#include "libavutil/writer.h"
+
+/* see 69bd73b3ff873abb43de9db062b04425de153643 */
+
+/* AVWriter with only get_buffer/advance_buffer */
+
+static char *getbuf_get_buffer(AVWriter wr, size_t min_size, size_t *size);
+static void getbuf_advance_buffer(AVWriter wr, size_t size);
+
+AV_WRITER_DEFINE_METHODS(static, Getbuf, getbuf) {
+.self_size= sizeof(AVWriterMethods),
+.name = "Getbuf",
+.get_buffer   = getbuf_get_buffer,
+.advance_buffer   = getbuf_advance_buffer,
+};
+
+static char *getbuf_get_buffer(AVWriter wr, size_t min_size, size_t *size)
+{
+AVBufWriter *bwr = wr.obj;
+
+av_assert1(getbuf_check(wr));
+*size = bwr->size - 1 - bwr->pos;
+return bwr->buf + bwr->pos;
+}
+
+static void getbuf_advance_buffer(AVWriter wr, size_t size)
+{
+AVBufWriter *bwr = wr.obj;
+
+bwr->pos += size;
+bwr->buf[bwr->pos] = 0;
+}
+
+/* AVWriter with only write */
+
+static void write_write(AVWriter wr, const char *data, size_t size);
+
+AV_WRITER_DEFINE_METHODS(static, Write, write) {
+.self_size= sizeof(AVWriterMethods),
+.name = "Write",
+.write= write_write,
+};
+
+static void write_write(AVWriter wr, const char *data, size_t size)
+{
+AVBufWriter *bwr = wr.obj;
+
+av_assert1(write_check(wr));
+size = FFMIN(bwr->size - 1 - bwr->pos, size);
+memcpy(bwr->buf + bwr->pos, data, size);
+bwr->pos += size;
+bwr->buf[bwr->pos] = 0;
+}
+
+/* AVWriter with only vprintf */
+
+static void vprintf_vprintf(AVWriter wr, const char *fmt, va_list va);
+
+AV_WRITER_DEFINE_METHODS(static, Vprintf, vprintf) {
+.self_size= sizeof(AVWriterMethods),
+.name = "Vprintf",
+.vprintf  = vprintf_vprintf,
+};
+
+static void vprintf_vprintf(AVWriter wr, const char *fmt, va_list va)
+{
+AVBufWriter *bwr = wr.obj;
+int ret;
+
+av_assert1(vprintf_check(wr));
+ret = vsnprintf(bwr->buf + bwr->pos, bwr->size - bwr->pos, fmt, va);
+if (ret > 0)
+bwr->pos += ret;
+}
+
+/* Tests */
+
+static void stress_writer(AVWriter wr)
+{
+av_writer_add_chars(wr, '*', 72);
+av_writer_add_chars(wr, '\n', 1);
+av_writer_print(wr, "Stressing the writer\n");
+av_writer_printf(wr, "Answer: %d\n", 42);
+av_writer_printf(wr, "Question: %0600d * %0600d\n", 6, 9); /* > 
sizeof(AVBPrint) */
+av_writer_add_chars(wr, '*', 72);
+av_writer_add_chars(wr, '\n', 1);
+av_writer_write(wr, "\0Bonus track!\n", 14);
+}
+
+static void test_buf_writer_small(void)
+{
+char buf[1024];
+AVWriter wr = av_buf_writer_array(buf);
+stress_writer(wr);
+printf("

[FFmpeg-devel] [PATCH 1/3] lavu: new AVWriter API.

2019-12-27 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavutil/Makefile |   3 +-
 libavutil/writer.c | 371 
 libavutil/writer.h | 418 +
 3 files changed, 791 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/writer.c
 create mode 100644 libavutil/writer.h


I intend to continue by converting avcodec_string() and the functions it
depends on to this API, to show that it makes things a bit simpler and more
convenient, but it is already looking good.

To see what it feels like to use this API, look at the last hunk of the
third patch.


diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..b4609cd7bf 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -162,7 +162,8 @@ OBJS = adler32.o
\
tea.o\
tx.o \
tx_float.o   \
-   tx_double.o
+   tx_double.o  \
+   writer.o
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
diff --git a/libavutil/writer.c b/libavutil/writer.c
new file mode 100644
index 00..c564a4fa3b
--- /dev/null
+++ b/libavutil/writer.c
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2019 Nicolas George
+ *
+ * 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 "avassert.h"
+#include "log.h"
+#include "writer.h"
+
+/***
+ * Generic API
+ ***/
+
+#define FIELDOK(st, f) ((char *)(&(st)->f + 1) <= (char *)(st) + 
(st)->self_size)
+
+static void printf_unchecked(AVWriter wr, const char *fmt, ...)
+{
+va_list va;
+
+va_start(va, fmt);
+wr.methods->vprintf(wr, fmt, va);
+va_end(va);
+}
+
+static void write_or_discard(AVWriter wr, size_t buf_size, size_t write_size)
+{
+av_assert1(wr.methods->advance_buffer);
+wr.methods->advance_buffer(wr, FFMIN(buf_size, write_size));
+if (write_size > buf_size && wr.methods->notify_discard)
+wr.methods->notify_discard(wr, write_size - buf_size);
+}
+
+static void av_writer_impossible(AVWriter wr, const char *message)
+{
+av_assert1(FIELDOK(wr.methods, impossible));
+if (wr.methods->impossible)
+wr.methods->impossible(wr, message);
+else
+av_log(NULL, AV_LOG_ERROR, "Operation impossible with %s: %s\n",
+   wr.methods->name, message);
+}
+
+void av_writer_write(AVWriter wr, const char *data, size_t size)
+{
+av_assert1(FIELDOK(wr.methods, vprintf));
+if (wr.methods->write) {
+wr.methods->write(wr, data, size);
+} else if (wr.methods->get_buffer) {
+size_t buf_size;
+char *buf = wr.methods->get_buffer(wr, size, &buf_size);
+if (buf_size > 0)
+memcpy(buf, data, FFMIN(size, buf_size));
+write_or_discard(wr, buf_size, size);
+} else if (wr.methods->vprintf) {
+size_t i;
+for (i = 0; i < size; i++)
+printf_unchecked(wr, "%c", data[i]);
+} else {
+av_writer_impossible(wr, "av_writer_write()");
+}
+}
+
+void av_writer_print(AVWriter wr, const char *str)
+{
+av_writer_write(wr, str, strlen(str));
+}
+
+void av_writer_printf(AVWriter wr, const char *fmt, ...)
+{
+va_list va;
+
+va_start(va, fmt);
+av_writer_vprintf(wr, fmt, va);
+va_end(va);
+}
+
+void av_writer_vprintf(AVWriter wr, const char *fmt, va_list va)
+{
+av_assert1(FIELDOK(wr.methods, vprintf));
+if (wr.methods->vprintf) {
+wr.methods->vprintf(wr, fmt, va);
+} else if (wr.methods->get_buffer) {
+size_t buf_size;
+char *buf = wr.methods->get_buffer(wr, 128, &buf_size);
+va_list va2;
+int ret;
+va_copy(va2, va);
+ret = vsnprintf(buf, buf_size, fmt, va2);
+va_end(va2);
+if (ret < 0)
+return;
+if ((size_t)ret + 1 > buf_size) {
+buf = wr.methods->get_buffer(wr, ret + 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/microdvd: Use \n instead of \0 to end file header

2019-12-27 Thread Michael Niedermayer
On Fri, Dec 27, 2019 at 10:44:53AM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/microdvdenc: Use avio_w8 to write a char

2019-12-27 Thread Michael Niedermayer
On Thu, Dec 12, 2019 at 04:53:18PM +0100, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/microdvdenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

thx

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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

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

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

2019-12-27 Thread Michael Niedermayer
On Thu, Dec 19, 2019 at 11:35:51AM +0800, Ting Fu wrote:
> Tested using this command:
> ./ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \
> -vcodec rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null
> 

> The fps increase from 151 to 389 on my local machine.

Thats nice but why is there such a difference from changing the way the code
is assembled ?
This should definitly be explained more detailedly in the commit message


> 
> Signed-off-by: Ting Fu 
> ---
>  libswscale/x86/Makefile   |   1 +
>  libswscale/x86/swscale.c  |  16 +-
>  libswscale/x86/yuv2rgb.c  |  81 +++---
>  libswscale/x86/yuv2rgb_template.c | 441 ++
>  libswscale/x86/yuv_2_rgb.asm  | 270 ++
>  5 files changed, 395 insertions(+), 414 deletions(-)
>  create mode 100644 libswscale/x86/yuv_2_rgb.asm
> 
> diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile
> index f317d5dd9b..831d5359aa 100644
> --- a/libswscale/x86/Makefile
> +++ b/libswscale/x86/Makefile
> @@ -12,3 +12,4 @@ X86ASM-OBJS += x86/input.o  
> \
> x86/output.o \
> x86/scale.o  \
> x86/rgb_2_rgb.o  \
> +   x86/yuv_2_rgb.o  \
> diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
> index 0eed4f18d5..e9d474a1e8 100644
> --- a/libswscale/x86/swscale.c
> +++ b/libswscale/x86/swscale.c
> @@ -29,6 +29,14 @@
>  #include "libavutil/cpu.h"
>  #include "libavutil/pixdesc.h"
>  
> +const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
> +0x0103010301030103LL,
> +0x0200020002000200LL,};
> +
> +const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
> +0x0602060206020602LL,
> +0x0004000400040004LL,};
> +
>  #if HAVE_INLINE_ASM
>  
>  #define DITHER1XBPP
> @@ -38,14 +46,6 @@ DECLARE_ASM_CONST(8, uint64_t, bFC)=   
> 0xFCFCFCFCFCFCFCFCLL;
>  DECLARE_ASM_CONST(8, uint64_t, w10)=   0x0010001000100010LL;
>  DECLARE_ASM_CONST(8, uint64_t, w02)=   0x0002000200020002LL;
>  
> -const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
> -0x0103010301030103LL,
> -0x0200020002000200LL,};
> -
> -const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
> -0x0602060206020602LL,
> -0x0004000400040004LL,};
> -
>  DECLARE_ASM_CONST(8, uint64_t, b16Mask)=   0x001F001F001F001FLL;
>  DECLARE_ASM_CONST(8, uint64_t, g16Mask)=   0x07E007E007E007E0LL;
>  DECLARE_ASM_CONST(8, uint64_t, r16Mask)=   0xF800F800F800F800LL;
> diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
> index 5e2f77c20f..ed9b613cab 100644
> --- a/libswscale/x86/yuv2rgb.c
> +++ b/libswscale/x86/yuv2rgb.c
> @@ -37,7 +37,7 @@
>  #include "libavutil/x86/cpu.h"
>  #include "libavutil/cpu.h"
>  
> -#if HAVE_INLINE_ASM
> +#if HAVE_X86ASM
>  
>  #define DITHER1XBPP // only for MMX
>  
> @@ -50,70 +50,51 @@ DECLARE_ASM_CONST(8, uint64_t, pb_03) = 
> 0x0303030303030303ULL;
>  DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
>  
>  //MMX versions
> -#if HAVE_MMX_INLINE && HAVE_6REGS
> -#undef RENAME
> +#if HAVE_MMX
>  #undef COMPILE_TEMPLATE_MMXEXT
>  #define COMPILE_TEMPLATE_MMXEXT 0
> -#define RENAME(a) a ## _mmx
> -#include "yuv2rgb_template.c"
> -#endif /* HAVE_MMX_INLINE && HAVE_6REGS */
> +#endif /* HAVE_MMX */
>  
>  // MMXEXT versions
> -#if HAVE_MMXEXT_INLINE && HAVE_6REGS
> -#undef RENAME
> +#if HAVE_MMXEXT
>  #undef COMPILE_TEMPLATE_MMXEXT
>  #define COMPILE_TEMPLATE_MMXEXT 1
> -#define RENAME(a) a ## _mmxext
> -#include "yuv2rgb_template.c"
> -#endif /* HAVE_MMXEXT_INLINE && HAVE_6REGS */
> +#endif /* HAVE_MMXEXT */
>  
> -#endif /* HAVE_INLINE_ASM */
> +#include "yuv2rgb_template.c"
>  
>  av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
>  {
> -#if HAVE_MMX_INLINE && HAVE_6REGS
>  int cpu_flags = av_get_cpu_flags();
>  
> -#if HAVE_MMXEXT_INLINE
> -if (INLINE_MMXEXT(cpu_flags)) {
> -switch (c->dstFormat) {
> -case AV_PIX_FMT_RGB24:
> -return yuv420_rgb24_mmxext;
> -case AV_PIX_FMT_BGR24:
> -return yuv420_bgr24_mmxext;
> -}
> -}
> -#endif
> -
> -if (INLINE_MMX(cpu_flags)) {

> +if (EXTERNAL_MMX(cpu_flags) || EXTERNAL_MMXEXT(cpu_flags)) {

i would expect EXTERNAL_MMXEXT to imply EXTERNAL_MMX


[...]
> +case AV_PIX_FMT_RGB24:
> +return yuv420_rgb24;

[...]

> +static inline int yuv420_rgb24(SwsContext *c, const uint8_t *src[],
> +   int srcStride[],
> +   int srcSliceY, int srcSliceH,
> +   uint8_t *dst[], int dstStride[])
> +{

This looks a bit odd, a inline function which only use is taking a pointer
to it and returning it

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

W

Re: [FFmpeg-devel] [PATCH v1] avfilter: add colorstats, colorrgbstats, coloryuvstats video filter

2019-12-27 Thread Paul B Mahol
You are duplicating some functionality of signalstats filter.

On 12/27/19, lance.lmw...@gmail.com  wrote:
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  doc/filters.texi|  74 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   3 +
>  libavfilter/vf_colorstats.c | 461 
>  4 files changed, 539 insertions(+)
>  create mode 100644 libavfilter/vf_colorstats.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 8c5d3a5760..81968b2c17 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -7695,6 +7695,80 @@ For example to convert the input to SMPTE-240M, use
> the command:
>  colorspace=smpte240m
>  @end example
>
> +@section colorstats, colorrgbstats, coloryuvstats
> +The filter provides statistical video measurements such as mean, minimum,
> maximum and
> +standard deviation for each frame. The user can check for
> unexpected/accidental errors
> +very quickly with them.
> +
> +@var{colorrgbstats} report the color stats for RGB input video,
> @var{coloryuvstats}
> +to an YUV input video.
> +
> +These filters accept the following parameters:
> +@table @option
> +@item planes
> +Set which planes to filter. Default is only the first plane.
> +@end table
> +
> +By default the filter will report these metadata values if the planes
> +are processed:
> +
> +@table @option
> +@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
> +Display the minimal Y/U/V/R/G/B/A plane value contained within the input
> frame.
> +Expressed in range of [0, 1< +
> +@item pmin.y, pmin.u, pmin.v, pmin.r, pmin.g, pmin.b, min.a
> +Display the minimal Y/U/V/R/G/B/A plane percentage of maximum contained
> within
> +the input frame. Expressed in range of [0, 1]
> +
> +@item max.y, max.u, max.v, max.r, max.g, max.b, max.a
> +Display the maximum Y/U/V/R/G/B/A plane value contained within the input
> frame.
> +Expressed in range of [0, 1< +
> +@item pmax.y, pmax.u, pmax.v, pmax.r, pmax.g, pmax.b, pmax.a
> +Display the maximum Y/U/V/R/G/B/A plane percentage of maximum contained
> within
> +the input frame. Expressed in range of [0, 1]
> +
> +@item mean.y, mean.u, mean.v, mean.r, mean.g, mean.b, mean.a
> +Display the Y/U/V/R/G/B/A plane mean value contained within the input
> frame.
> +Expressed in range of [0, 1< +
> +@item pmean.y, pmean.u, pmean.v, pmean.r, pmean.g, pmean.b, pmean.a
> +Display the Y/U/V/R/G/B/A plane mean value percentage of maximum contained
> within
> +the input frame. Expressed in range of [0, 1]
> +
> +@item stdev.y, stdev.u, stdev.v, stdev.r, stdev.g, stdev.b, stdev.a
> +Display the Y/U/V/R/G/B/A plane standard deviation value contained within
> the
> +input frame. Expressed in range of [0, 1< +
> +@item pstdev.y, pstdev.u, pstdev.v, pstdev.r, pstdev.g, pstdev.b, pstdev.a
> +Display the Y/U/V/R/G/B/A plane standard deviation value percentage of
> maximum contained
> +within the input frame. Expressed in range of [0, 1]
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Show all YUV color stats for each frame:
> +@example
> +ffprobe -f lavfi movie=example.mov,coloryuvstats=planes=0xf -show_frames
> +@end example
> +
> +@item
> +Draw graph for the pmean and pstdev value of the Y plane per frame:
> +@example
> +ffplay -i example.mov -vf
> coloryuvstats,drawgraph=m1=lavf.colorstats.pmean.y:m2=lavf.colorstats.pstdev.y:min=0:max=1
> +@end example
> +
> +@item
> +Print all RGB color stats for each frame:
> +@example
> +ffplay -i example.mov -vf colorrgbstats=planes=0xf,metadata=mode=print
> +@end example
> +
> +@end itemize
> +
>  @section convolution
>
>  Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49
> elements.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 37d4eee858..a007bd32d1 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -182,6 +182,7 @@ OBJS-$(CONFIG_CIESCOPE_FILTER)   +=
> vf_ciescope.o
>  OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
>  OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
>  OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
> +OBJS-$(CONFIG_COLORSTATS_FILTER) += vf_colorstats.o
>  OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
>  OBJS-$(CONFIG_COLORKEY_OPENCL_FILTER)+= vf_colorkey_opencl.o
> opencl.o \
>  opencl/colorkey.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index c295f8e403..6b84a45452 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -172,6 +172,9 @@ extern AVFilter ff_vf_ciescope;
>  extern AVFilter ff_vf_codecview;
>  extern AVFilter ff_vf_colorbalance;
>  extern AVFilter ff_vf_colorchannelmixer;
> +extern AVFilter ff_vf_colorstats;
> +extern AVFilter ff_vf_colorrgbstats;
> +extern AVFilter ff_vf_coloryuvstats;
>  extern AVFilter ff_vf_colorkey;
>  extern AVFilter ff_vf_colorkey_opencl;
>  extern AVFilter ff_v

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Paul B Mahol
On 12/27/19, Nicolas George  wrote:
> Paul B Mahol (12019-12-26):
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi   |  46 ++
>>  libavfilter/Makefile   |   1 +
>>  libavfilter/allfilters.c   |   1 +
>>  libavfilter/vf_histogram.c | 127 ++---
>>  4 files changed, 151 insertions(+), 24 deletions(-)
>
> Thanks for merging them. I have no objection to this version, just a
> small remark below.
>
> I did not look at the arithmetic of the code closely, but I can do it if
> you want me to.
>
>> +if (!strcmp(ctx->filter->name, "thistogram"))
>> +s->thistogram = 1;
>
> Could you not test if s->width == 1 and have just one filter:
>
>   histogram=... -> equivalent to current histogram
>
>   histogram=width=1080:... -> equivalent to new thistogram
>
> ? It would save you the task of using a macro for common options.

Nope, as it would not be logical. It would become big mess.

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

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

[FFmpeg-devel] [PATCH v1] avfilter: add colorstats, colorrgbstats, coloryuvstats video filter

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

Signed-off-by: Limin Wang 
---
 doc/filters.texi|  74 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   3 +
 libavfilter/vf_colorstats.c | 461 
 4 files changed, 539 insertions(+)
 create mode 100644 libavfilter/vf_colorstats.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 8c5d3a5760..81968b2c17 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7695,6 +7695,80 @@ For example to convert the input to SMPTE-240M, use the 
command:
 colorspace=smpte240m
 @end example
 
+@section colorstats, colorrgbstats, coloryuvstats
+The filter provides statistical video measurements such as mean, minimum, 
maximum and
+standard deviation for each frame. The user can check for 
unexpected/accidental errors
+very quickly with them.
+
+@var{colorrgbstats} report the color stats for RGB input video, 
@var{coloryuvstats}
+to an YUV input video.
+
+These filters accept the following parameters:
+@table @option
+@item planes
+Set which planes to filter. Default is only the first plane.
+@end table
+
+By default the filter will report these metadata values if the planes
+are processed:
+
+@table @option
+@item min.y, min.u, min.v, min.r, min.g, min.b, min.a
+Display the minimal Y/U/V/R/G/B/A plane value contained within the input frame.
+Expressed in range of [0, 1force_fmt == 1 ? rgb_pix_fmts :
+ s->force_fmt == 2 ? yuv_pix_fmts :
+ all_pix_fmts;
+
+AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
+if (!fmts_list)
+return AVERROR(ENOMEM);
+return ff_set_common_formats(ctx, fmts_list);
+}
+
+#define DECLARE_STATS_PLANAR_FUNC(nbits, div)  
   \
+static int stats_slice_planar_##nbits(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)\
+{  
   \
+const ColorStatsContext *s = ctx->priv;
   \
+ThreadData *td = arg;  
   \
+const AVFrame *in = td->in;
   \
+int64_t sum[4] = { 0 }, sum2[4] = { 0 };   
   \
+int32_t count[4] = { 0 };  
   \
+double min_value[4] = { s->max };  
   \
+double max_value[4] = { 0 };   
   \
+   
   \
+for (int i = 0; i < s->nb_components; i++) {   
   \
+const int width = s->width[i]; 
   \
+const int height = s->height[i];   
   \
+const int slice_start = (height *  jobnr ) / nb_jobs;  
   \
+const int slice_end   = (height * (jobnr + 1)) / nb_jobs;  
   \
+int linesize = in->linesize[i] / div;  
   \
+uint##nbits##_t *src = (uint##nbits##_t*)in->data[i] + slice_start * 
linesize;\
+   
   \
+if (!(s->planes & (1 << i)))   
   \
+continue;  
   \
+for (int j = slice_start; j < slice_end; j++) {
   \
+for (int x = 0; x < width; x++) {  
   \
+sum[i] += src[x];  
   \
+sum2[i] += src[x] * src[x];
   \
+if (src[i] > max_value[i]) max_value[i] = src[i];  
   \
+if (src[i] < min_value[i]) min_value[i] = src[i];  
   \
+}  
   \
+count[i] += width; 
   \
+src += linesize;   
   \
+}  
   \
+   

Re: [FFmpeg-devel] [PATCH 1/2] avfilter: add thistogram video filter

2019-12-27 Thread Nicolas George
Paul B Mahol (12019-12-26):
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi   |  46 ++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_histogram.c | 127 ++---
>  4 files changed, 151 insertions(+), 24 deletions(-)

Thanks for merging them. I have no objection to this version, just a
small remark below.

I did not look at the arithmetic of the code closely, but I can do it if
you want me to.

> +if (!strcmp(ctx->filter->name, "thistogram"))
> +s->thistogram = 1;

Could you not test if s->width == 1 and have just one filter:

histogram=... -> equivalent to current histogram

histogram=width=1080:... -> equivalent to new thistogram

? It would save you the task of using a macro for common options.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 1/2] lavc/decode: re-allocate surface in ff_decode_get_hw_frames_ctx

2019-12-27 Thread Hendrik Leppkes
On Fri, Dec 27, 2019 at 9:59 AM Linjie Fu  wrote:
>
> Allow hw_frames_ctx to be recreated instead of just return if it exists.
>
> Move hw_frames_ctx check outside ff_decode_get_hw_frames_ctx, and check
> in relevant code.
>
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/decode.c | 2 +-
>  libavcodec/dxva2.c  | 8 +---
>  libavcodec/vdpau.c  | 9 +
>  3 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index cd275ba..ad046d9 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1229,7 +1229,7 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
>  return AVERROR(ENOSYS);
>
>  if (avctx->hw_frames_ctx)
> -return 0;
> +av_buffer_unref(&avctx->hw_frames_ctx);
>  if (!avctx->hw_device_ctx) {
>  av_log(avctx, AV_LOG_ERROR, "A hardware frames or device context is "
>  "required for hardware accelerated decoding.\n");


As mentioned in the other mail, this is not safe. An externally
provided hw_frames_ctx could be allocated with special requirements,
and shared with a renderer. If a user provides an external
hw_frames_ctx, then avcodec cannot just re-allocate it, instead we
would have to ask the user to do so.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vp9: support hardware decode with resolution changing on inter frame

2019-12-27 Thread Hendrik Leppkes
On Fri, Dec 27, 2019 at 9:59 AM Linjie Fu  wrote:
>
> VP9 decoder should be able to handle resolution changing on inter
> frame without re-initialization. For hardware decoder, re-allocate hardware
> frame surface.
>
> Fix #8068 for VA-API.
>
> Signed-off-by: Linjie Fu 
> ---
> Request for comments.
> This works for VA-API, however for dxva2 it didn't cover all cases.
>
> Another idea is to register a call-back function in AVHWAccel (such as
> ff_vp9_dxva2_hwaccel) to handle surface re-allocation according to
> the hardware decoder.
>
>  libavcodec/vp9.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index 0fd15ef..a7b4c6a 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -34,6 +34,7 @@
>  #include "vp9dec.h"
>  #include "libavutil/avassert.h"
>  #include "libavutil/pixdesc.h"
> +#include "decode.h"
>
>  #define VP9_SYNCCODE 0x498342
>
> @@ -220,11 +221,20 @@ static int update_size(AVCodecContext *avctx, int w, 
> int h)
>  *fmtp++ = s->pix_fmt;
>  *fmtp = AV_PIX_FMT_NONE;
>
> -ret = ff_thread_get_format(avctx, pix_fmts);
> -if (ret < 0)
> -return ret;
> +if (avctx->internal->hwaccel_priv_data && s->pix_fmt == s->gf_fmt && 
> (s->w != w || s->h != h)) {
> +const AVHWDeviceContext *device_ctx =
> +(AVHWDeviceContext*)avctx->hw_device_ctx->data;
> +ret = ff_decode_get_hw_frames_ctx(avctx, device_ctx->type);
> +if (ret < 0)
> +return ret;
> +} else {
> +ret = ff_thread_get_format(avctx, pix_fmts);
> +if (ret < 0)
> +return ret;
> +
> +avctx->pix_fmt = ret;
> +}
>
> -avctx->pix_fmt = ret;
>  s->gf_fmt  = s->pix_fmt;
>  s->w = w;
>  s->h = h;

hwaccels are not guaranteed to have a hw_frames ctx, and avcodec is
not guaranteed to manage the surfaces it decodes to at all (they could
be shared with eg. a renderer and allocated externally), as such a
decoder really can't reliably re-allocate this itself - thats what the
get_format callback is for, which informs the user that new dimensions
are required.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/microdvd: Use \n instead of \0 to end file header

2019-12-27 Thread Paul B Mahol
lgtm

On 12/27/19, Andreas Rheinhardt  wrote:
> Andreas Rheinhardt:
>> Andreas Rheinhardt:
>>> Up until now, the microdvd demuxer uses av_strdup() to allocate the
>>> extradata from a string; its length is set to strlen() + 1, i.e.
>>> including the \0 at the end. Upon remuxing, the muxer would simply copy
>>> the extradata at the beginning, including the \0.
>>>
>>> This commit changes this by not adding the \0 to the size of the
>>> extradata; the muxer now delimits extradata by inserting a \n. This
>>> required to change the subtitles-microdvd-remux FATE-test.
>>>
>>> Furthermore, the extradata is now allocated with zeroed padding.
>>>
>>> The microdvd decoder is not affected by this, as it didn't use the size
>>> of the extradata at all, but treated it as a C-string.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavformat/microdvddec.c |   9 +
>>>  libavformat/microdvdenc.c |   1 +
>>>  tests/ref/fate/sub-microdvd-remux | Bin 416 -> 416 bytes
>>>  3 files changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
>>> index ca9086afe9..08e6fca09c 100644
>>> --- a/libavformat/microdvddec.c
>>> +++ b/libavformat/microdvddec.c
>>> @@ -117,10 +117,11 @@ static int microdvd_read_header(AVFormatContext *s)
>>>  continue;
>>>  }
>>>  if (!st->codecpar->extradata && sscanf(line,
>>> "{DEFAULT}{}%c", &c) == 1) {
>>> -st->codecpar->extradata = av_strdup(line + 11);
>>> -if (!st->codecpar->extradata)
>>> -return AVERROR(ENOMEM);
>>> -st->codecpar->extradata_size =
>>> strlen(st->codecpar->extradata) + 1;
>>> +int ret, size = strlen(line + 11);
>>> +ret = ff_alloc_extradata(st->codecpar, size);
>>> +if (ret < 0)
>>> +return ret;
>>> +memcpy(st->codecpar->extradata, line + 11, size);
>>>  continue;
>>>  }
>>>  }
>>> diff --git a/libavformat/microdvdenc.c b/libavformat/microdvdenc.c
>>> index 04f475b645..6639651e02 100644
>>> --- a/libavformat/microdvdenc.c
>>> +++ b/libavformat/microdvdenc.c
>>> @@ -36,6 +36,7 @@ static int microdvd_write_header(struct AVFormatContext
>>> *s)
>>>  if (par->extradata && par->extradata_size > 0) {
>>>  avio_write(s->pb, "{DEFAULT}{}", 11);
>>>  avio_write(s->pb, par->extradata, par->extradata_size);
>>> +avio_w8(s->pb, '\n');
>>>  avio_flush(s->pb);
>>>  }
>>>
>>> diff --git a/tests/ref/fate/sub-microdvd-remux
>>> b/tests/ref/fate/sub-microdvd-remux
>>> index
>>> a71da99031fdc4bff13ea7124c046e761a650dc8..92ff233f56b6fec33d4e9e0698ec43377ea5fab7
>>> 100644
>>> GIT binary patch
>>> delta 12
>>> TcmZ3$ynuOvE+f}Qy&^^c7%l^0
>>>
>>> delta 12
>>> TcmZ3$ynuOvE+fN6y&^^c7yJWP
>>>
>> Ping.
>>
>> - Andreas
>>
> Ping.
>
> - 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".
___
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] Copying Audio

2019-12-27 Thread Chris
I have a file with audio in the format pcm_s16be. When I try to copy this audio 
to another file using -c:a copy, it copies the audio but also transcodes it to 
AAC.
If it's literally a copy, shouldn't the copy be pcm_s16be as well? How can I do 
this and wind up with a pcm copy of the original audio? I've tried -c:a 
pcm_s16be and it fails.
The complete command is:
"ffmpeg.exe","-y  -i short.mp4 -c:a copy  married.mp4"
I am writing the audio to married.mp4 and it works well except for the 
transcoding to AAC.
___
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 V4 2/2] libswscale/x86/yuv2rgb: add ssse3 version

2019-12-27 Thread Paul B Mahol
LGTM

On 12/26/19, Fu, Ting  wrote:
>
>
>> -Original Message-
>> From: ffmpeg-devel  On Behalf Of Ting Fu
>> Sent: Thursday, December 19, 2019 11:36 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH V4 2/2] libswscale/x86/yuv2rgb: add ssse3
>> version
>>
>> Tested using this command:
>> /ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \ -vcodec
>> rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null
>>
>> The fps increase from 389 to 640 on my local machine.
>>
>> Signed-off-by: Ting Fu 
>> ---
>>  libswscale/x86/yuv2rgb.c  |   8 +-
>>  libswscale/x86/yuv2rgb_template.c |  58 +++-
>>  libswscale/x86/yuv_2_rgb.asm  | 145 ++
>>  3 files changed, 192 insertions(+), 19 deletions(-)
>>
>> diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index
>> ed9b613cab..b83dd7089a 100644
>> --- a/libswscale/x86/yuv2rgb.c
>> +++ b/libswscale/x86/yuv2rgb.c
> [...]
>> +
>> +INIT_XMM ssse3
>> +yuv2rgb_fn yuv,  rgb, 24
>> +yuv2rgb_fn yuv,  bgr, 24
>> +yuv2rgb_fn yuv,  rgb, 32
>> +yuv2rgb_fn yuv,  bgr, 32
>> +yuv2rgb_fn yuva, rgb, 32
>> +yuv2rgb_fn yuva, bgr, 32
>> +yuv2rgb_fn yuv,  rgb, 15
>> +yuv2rgb_fn yuv,  rgb, 16
>> --
>> 2.17.1
>
> A kindly ping.
>
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org
>> with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow test for hevc_add_res

2019-12-27 Thread Fu, Linjie
Hi,

> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Wednesday, December 18, 2019 09:55
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>; alexan...@khirnov.net; c...@passwd.hu; Paul B Mahol
> ; jamr...@gmail.com; u...@pkh.me
> Subject: Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow test
> for hevc_add_res
> 
> Hi,
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> Fu,
> > Linjie
> > Sent: Sunday, December 15, 2019 10:02
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>; jamr...@gmail.com; u...@pkh.me; Pierre-
> > edouard.lep...@insa-rennes.fr
> > Subject: Re: [FFmpeg-devel] [PATCH 1/4] tests/checkasm: add overflow
> test
> > for hevc_add_res
> >
> > Hi,
> >
> > > -Original Message-
> > > From: Fu, Linjie 
> > > Sent: Wednesday, December 11, 2019 16:46
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie ; Xu, Guangxin
> 
> > > Subject: [PATCH 1/4] tests/checkasm: add overflow test for
> hevc_add_res
> > >
> > > Add overflow test for hevc_add_res when int16_t coeff = -32768.
> > > The result of C is good, while ASM is not.
> > >
> > > To verify:
> > > make fate-checkasm-hevc_add_res
> > > ffmpeg/tests/checkasm/checkasm --test=hevc_add_res
> > >
> > > ./checkasm --test=hevc_add_res
> > > checkasm: using random seed 679391863
> > > MMXEXT:
> > > hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
> > >   - hevc_add_res.add_residual [FAILED]
> > > SSE2:
> > > hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
> > > hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
> > > hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
> > >   - hevc_add_res.add_residual [FAILED]
> > > AVX:
> > > hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
> > > hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
> > > hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
> > >   - hevc_add_res.add_residual [FAILED]
> > > AVX2:
> > > hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
> > >   - hevc_add_res.add_residual [FAILED]
> > > checkasm: 8 of 14 tests have failed
> > >
> > > Signed-off-by: Xu Guangxin 
> > > Signed-off-by: Linjie Fu 
> > > ---
> > >  tests/checkasm/hevc_add_res.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/tests/checkasm/hevc_add_res.c
> > > b/tests/checkasm/hevc_add_res.c
> > > index e92c6b4..a6e3b8a 100644
> > > --- a/tests/checkasm/hevc_add_res.c
> > > +++ b/tests/checkasm/hevc_add_res.c
> > > @@ -58,6 +58,7 @@ static void check_add_res(HEVCDSPContext h, int
> > > bit_depth)
> > >
> > >  randomize_buffers(res0, size);
> > >  randomize_buffers2(dst0, size);
> > > +res0[0] = 0x8000;// overflow test
> > >  memcpy(res1, res0, sizeof(*res0) * size);
> > >  memcpy(dst1, dst0, sizeof(int16_t) * size);
> > >
> > > --
> > > 2.7.4
> > A kindly ping.
> > Any comments towards this?
> >
> Ping, and looking forward to any feedbacks.
> 
> This overflow does affect the decode of the clips with coeff=-32768, and
> makes it
> difficult(unless by --disbale-asm) to use software decoded result as a
> reference for
> comparation with the hardware decoder.

Ping for review.
Same issue exists in h264_idct.asm and make the decode fail.
IMHO we should get this fixed firstly.

- linjie

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

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

[FFmpeg-devel] [PATCH 2/2] lavc/vp9: support hardware decode with resolution changing on inter frame

2019-12-27 Thread Linjie Fu
VP9 decoder should be able to handle resolution changing on inter
frame without re-initialization. For hardware decoder, re-allocate hardware
frame surface.

Fix #8068 for VA-API.

Signed-off-by: Linjie Fu 
---
Request for comments.
This works for VA-API, however for dxva2 it didn't cover all cases.

Another idea is to register a call-back function in AVHWAccel (such as
ff_vp9_dxva2_hwaccel) to handle surface re-allocation according to
the hardware decoder.

 libavcodec/vp9.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 0fd15ef..a7b4c6a 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -34,6 +34,7 @@
 #include "vp9dec.h"
 #include "libavutil/avassert.h"
 #include "libavutil/pixdesc.h"
+#include "decode.h"
 
 #define VP9_SYNCCODE 0x498342
 
@@ -220,11 +221,20 @@ static int update_size(AVCodecContext *avctx, int w, int 
h)
 *fmtp++ = s->pix_fmt;
 *fmtp = AV_PIX_FMT_NONE;
 
-ret = ff_thread_get_format(avctx, pix_fmts);
-if (ret < 0)
-return ret;
+if (avctx->internal->hwaccel_priv_data && s->pix_fmt == s->gf_fmt && 
(s->w != w || s->h != h)) {
+const AVHWDeviceContext *device_ctx =
+(AVHWDeviceContext*)avctx->hw_device_ctx->data;
+ret = ff_decode_get_hw_frames_ctx(avctx, device_ctx->type);
+if (ret < 0)
+return ret;
+} else {
+ret = ff_thread_get_format(avctx, pix_fmts);
+if (ret < 0)
+return ret;
+
+avctx->pix_fmt = ret;
+}
 
-avctx->pix_fmt = ret;
 s->gf_fmt  = s->pix_fmt;
 s->w = w;
 s->h = h;
-- 
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] lavc/hevcdec: Align transform syntax with the SPEC

2019-12-27 Thread Linjie Fu
Doesn't change the logic, modify to keep it consistent with
7.3.8.8 in spec to avoid some misunderstandings.

Signed-off-by: Linjie Fu 
---
 libavcodec/hevcdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 8f1c162..fb2ee72 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1300,7 +1300,7 @@ static int hls_transform_tree(HEVCContext *s, int x0, int 
y0,
inter_split;
 }
 
-if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || 
s->ps.sps->chroma_format_idc == 3)) {
+if ((s->ps.sps->chroma_format_idc && log2_trafo_size > 2) || 
s->ps.sps->chroma_format_idc == 3) {
 if (trafo_depth == 0 || cbf_cb[0]) {
 cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth);
 if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || 
log2_trafo_size == 3)) {
-- 
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 1/2] lavc/decode: re-allocate surface in ff_decode_get_hw_frames_ctx

2019-12-27 Thread Linjie Fu
Allow hw_frames_ctx to be recreated instead of just return if it exists.

Move hw_frames_ctx check outside ff_decode_get_hw_frames_ctx, and check
in relevant code.

Signed-off-by: Linjie Fu 
---
 libavcodec/decode.c | 2 +-
 libavcodec/dxva2.c  | 8 +---
 libavcodec/vdpau.c  | 9 +
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index cd275ba..ad046d9 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1229,7 +1229,7 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,
 return AVERROR(ENOSYS);
 
 if (avctx->hw_frames_ctx)
-return 0;
+av_buffer_unref(&avctx->hw_frames_ctx);
 if (!avctx->hw_device_ctx) {
 av_log(avctx, AV_LOG_ERROR, "A hardware frames or device context is "
 "required for hardware accelerated decoding.\n");
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 3241611..0404064 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -661,9 +661,11 @@ int ff_dxva2_decode_init(AVCodecContext *avctx)
 // (avctx->pix_fmt is not updated yet at this point)
 sctx->pix_fmt = avctx->hwaccel->pix_fmt;
 
-ret = ff_decode_get_hw_frames_ctx(avctx, dev_type);
-if (ret < 0)
-return ret;
+if (!avctx->hw_frames_ctx) {
+ret = ff_decode_get_hw_frames_ctx(avctx, dev_type);
+if (ret < 0)
+return ret;
+}
 
 frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
 sctx->device_ctx = frames_ctx->device_ctx;
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 167f06d..b7a4e9c 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -178,10 +178,11 @@ int ff_vdpau_common_init(AVCodecContext *avctx, 
VdpDecoderProfile profile,
 AVHWFramesContext *frames_ctx;
 AVVDPAUDeviceContext *dev_ctx;
 
-ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VDPAU);
-if (ret < 0)
-return ret;
-
+if (!avctx->hw_frames_ctx) {
+ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VDPAU);
+if (ret < 0)
+return ret;
+}
 frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
 dev_ctx = frames_ctx->device_ctx->hwctx;
 
-- 
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] lavc/pthread_frame: Update user context in ff_frame_thread_free

2019-12-27 Thread Linjie Fu
Resolution/format changes lead to re-initialization of hardware
accelerations(vaapi/dxva2/..) with new hwaccel_priv_data in
the worker-thread. But hwaccel_priv_data in user context won't
be updated until the resolution changing frame is output.

A termination with "-vframes" just after the reinit will lead to:
1. memory leak in worker-thread.
2. double free in user-thread.

Update user context in ff_frame_thread_free with the last thread
submit_packet() was called on.

To reproduce:
ffmpeg -hwaccel vaapi(dxva2) -v verbose -i
fate-suite/h264/reinit-large_420_8-to-small_420_8.h264 -pix_fmt nv12
-f rawvideo -vsync passthrough -vframes 47 -y out.yuv

Signed-off-by: Linjie Fu 
---
 libavcodec/pthread_frame.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 36ac0ac..8bdd735 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -657,6 +657,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 
 park_frame_worker_threads(fctx, thread_count);
 
+if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
+ 
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
+if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 
0) {
+av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
+}
+}
+
 if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
 if (update_context_from_thread(fctx->threads->avctx, 
fctx->prev_thread->avctx, 0) < 0) {
 av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
-- 
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 2/2] vf_dnn_processing: add support for more formats gray8 and grayf32

2019-12-27 Thread Guo, Yejun
The following is a python script to halve the value of the gray
image. It demos how to setup and execute dnn model with python+tensorflow.
It also generates .pb file which will be used by ffmpeg.

import tensorflow as tf
import numpy as np
from skimage import color
from skimage import io
in_img = io.imread('input.jpg')
in_img = color.rgb2gray(in_img)
io.imsave('ori_gray.jpg', np.squeeze(in_img))
in_data = np.expand_dims(in_img, axis=0)
in_data = np.expand_dims(in_data, axis=3)
filter_data = np.array([0.5]).reshape(1,1,1,1).astype(np.float32)
filter = tf.Variable(filter_data)
x = tf.placeholder(tf.float32, shape=[1, None, None, 1], name='dnn_in')
y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID', 
name='dnn_out')
sess=tf.Session()
sess.run(tf.global_variables_initializer())
graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, 
['dnn_out'])
tf.train.write_graph(graph_def, '.', 'halve_gray_float.pb', as_text=False)
print("halve_gray_float.pb generated, please use \
path_to_ffmpeg/tools/python/convert.py to generate halve_gray_float.model\n")
output = sess.run(y, feed_dict={x: in_data})
output = output * 255.0
output = output.astype(np.uint8)
io.imsave("out.jpg", np.squeeze(output))

To do the same thing with ffmpeg:
- generate halve_gray_float.pb with the above script
- generate halve_gray_float.model with tools/python/convert.py
- try with following commands
  ./ffmpeg -i input.jpg -vf 
format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native
 out.native.png
  ./ffmpeg -i input.jpg -vf 
format=grayf32,dnn_processing=model=halve_gray_float.pb:input=dnn_in:output=dnn_out:dnn_backend=tensorflow
 out.tf.png

Signed-off-by: Guo, Yejun 
---
 doc/filters.texi|   6 ++
 libavfilter/vf_dnn_processing.c | 168 ++--
 2 files changed, 132 insertions(+), 42 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index f467378..57a129d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9075,6 +9075,12 @@ Halve the red channle of the frame with format rgb24:
 ffmpeg -i input.jpg -vf 
format=rgb24,dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:dnn_backend=native
 out.native.png
 @end example
 
+@item
+Halve the pixel value of the frame with format gray32f:
+@example
+ffmpeg -i input.jpg -vf 
format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native
 -y out.native.png
+@end example
+
 @end itemize
 
 @section drawbox
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index 4a6b900..13273f2 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -104,12 +104,20 @@ static int query_formats(AVFilterContext *context)
 {
 static const enum AVPixelFormat pix_fmts[] = {
 AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
+AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAYF32,
 AV_PIX_FMT_NONE
 };
 AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
 return ff_set_common_formats(context, fmts_list);
 }
 
+#define LOG_FORMAT_CHANNEL_MISMATCH()   \
+av_log(ctx, AV_LOG_ERROR,   \
+   "the frame's format %s does not match "  \
+   "the model input channel %d\n",  \
+   av_get_pix_fmt_name(fmt),\
+   model_input->channels);
+
 static int check_modelinput_inlink(const DNNData *model_input, const 
AVFilterLink *inlink)
 {
 AVFilterContext *ctx   = inlink->dst;
@@ -131,17 +139,34 @@ static int check_modelinput_inlink(const DNNData 
*model_input, const AVFilterLin
 case AV_PIX_FMT_RGB24:
 case AV_PIX_FMT_BGR24:
 if (model_input->channels != 3) {
-av_log(ctx, AV_LOG_ERROR, "the frame's input format %s does not 
match "
-   "the model input channels %d\n",
-   av_get_pix_fmt_name(fmt),
-   model_input->channels);
+LOG_FORMAT_CHANNEL_MISMATCH();
 return AVERROR(EIO);
 }
 if (model_input->dt != DNN_FLOAT && model_input->dt != DNN_UINT8) {
 av_log(ctx, AV_LOG_ERROR, "only support dnn models with input data 
type as float32 and uint8.\n");
 return AVERROR(EIO);
 }
-break;
+return 0;
+case AV_PIX_FMT_GRAY8:
+if (model_input->channels != 1) {
+LOG_FORMAT_CHANNEL_MISMATCH();
+return AVERROR(EIO);
+}
+if (model_input->dt != DNN_UINT8) {
+av_log(ctx, AV_LOG_ERROR, "only support dnn models with input data 
type uint8.\n");
+return AVERROR(EIO);
+}
+return 0;
+case AV_PIX_FMT_GRAYF32:
+if (model_input->channels != 1) {
+LOG_FORMAT_CHANNEL_MISMATCH();
+return AVERROR(EIO);
+

[FFmpeg-devel] [PATCH 1/2] vf_dnn_processing: remove parameter 'fmt'

2019-12-27 Thread Guo, Yejun
do not request AVFrame's format in vf_ddn_processing with 'fmt',
but to add another filter for the format.

command examples:
./ffmpeg -i input.jpg -vf 
format=bgr24,dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:dnn_backend=native
 -y out.native.png
./ffmpeg -i input.jpg -vf 
format=rgb24,dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:dnn_backend=native
 -y out.native.png

Signed-off-by: Guo, Yejun 
---
 doc/filters.texi| 17 +---
 libavfilter/vf_dnn_processing.c | 95 +
 2 files changed, 60 insertions(+), 52 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8c5d3a5..f467378 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9030,8 +9030,8 @@ ffmpeg -i INPUT -f lavfi -i 
nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
 
 @section dnn_processing
 
-Do image processing with deep neural networks. Currently only AVFrame with 
RGB24
-and BGR24 are supported, more formats will be added later.
+Do image processing with deep neural networks. It works together with another 
filter
+which converts the pixel format of the Frame to what the dnn network requires.
 
 The filter accepts the following options:
 
@@ -9066,12 +9066,17 @@ Set the input name of the dnn network.
 @item output
 Set the output name of the dnn network.
 
-@item fmt
-Set the pixel format for the Frame. Allowed values are 
@code{AV_PIX_FMT_RGB24}, and @code{AV_PIX_FMT_BGR24}.
-Default value is @code{AV_PIX_FMT_RGB24}.
-
 @end table
 
+@itemize
+@item
+Halve the red channle of the frame with format rgb24:
+@example
+ffmpeg -i input.jpg -vf 
format=rgb24,dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:dnn_backend=native
 out.native.png
+@end example
+
+@end itemize
+
 @section drawbox
 
 Draw a colored box on the input image.
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index ce976ec..4a6b900 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -37,7 +37,6 @@ typedef struct DnnProcessingContext {
 
 char *model_filename;
 DNNBackendType backend_type;
-enum AVPixelFormat fmt;
 char *model_inputname;
 char *model_outputname;
 
@@ -60,7 +59,6 @@ static const AVOption dnn_processing_options[] = {
 { "model",   "path to model file", OFFSET(model_filename),   
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
 { "input",   "input name of the model",OFFSET(model_inputname),  
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
 { "output",  "output name of the model",   OFFSET(model_outputname), 
AV_OPT_TYPE_STRING,{ .str = NULL }, 0, 0, FLAGS },
-{ "fmt", "AVPixelFormat of the frame", OFFSET(fmt),  
AV_OPT_TYPE_PIXEL_FMT, { .i64=AV_PIX_FMT_RGB24 }, AV_PIX_FMT_NONE, 
AV_PIX_FMT_NB - 1, FLAGS },
 { NULL }
 };
 
@@ -69,23 +67,6 @@ AVFILTER_DEFINE_CLASS(dnn_processing);
 static av_cold int init(AVFilterContext *context)
 {
 DnnProcessingContext *ctx = context->priv;
-int supported = 0;
-// as the first step, only rgb24 and bgr24 are supported
-const enum AVPixelFormat supported_pixel_fmts[] = {
-AV_PIX_FMT_RGB24,
-AV_PIX_FMT_BGR24,
-};
-for (int i = 0; i < sizeof(supported_pixel_fmts) / sizeof(enum 
AVPixelFormat); ++i) {
-if (supported_pixel_fmts[i] == ctx->fmt) {
-supported = 1;
-break;
-}
-}
-if (!supported) {
-av_log(context, AV_LOG_ERROR, "pixel fmt %s not supported yet\n",
-   av_get_pix_fmt_name(ctx->fmt));
-return AVERROR(AVERROR_INVALIDDATA);
-}
 
 if (!ctx->model_filename) {
 av_log(ctx, AV_LOG_ERROR, "model file for network is not specified\n");
@@ -121,14 +102,52 @@ static av_cold int init(AVFilterContext *context)
 
 static int query_formats(AVFilterContext *context)
 {
-AVFilterFormats *formats;
-DnnProcessingContext *ctx = context->priv;
-enum AVPixelFormat pixel_fmts[2];
-pixel_fmts[0] = ctx->fmt;
-pixel_fmts[1] = AV_PIX_FMT_NONE;
+static const enum AVPixelFormat pix_fmts[] = {
+AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
+AV_PIX_FMT_NONE
+};
+AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
+return ff_set_common_formats(context, fmts_list);
+}
+
+static int check_modelinput_inlink(const DNNData *model_input, const 
AVFilterLink *inlink)
+{
+AVFilterContext *ctx   = inlink->dst;
+enum AVPixelFormat fmt = inlink->format;
+
+// the design is to add explicit scale filter before this filter
+if (model_input->height != -1 && model_input->height != inlink->h) {
+av_log(ctx, AV_LOG_ERROR, "the model requires frame height %d but got 
%d\n",
+   model_input->height, inlink->h);
+return AVERROR(EIO);
+}
+if (model_input->width != -1 && model_input-