Re: [FFmpeg-devel] [PATCH] mpegvideo: remove support for libxvid's RC system

2018-05-01 Thread Rostislav Pehlivanov
On 1 May 2018 at 21:58, Carl Eugen Hoyos  wrote:

> 2018-05-01 21:00 GMT+02:00, Rostislav Pehlivanov :
> > Its a reminder of a bygone era. Less flexible than the internal RC
> > system, probably worse and most definitely broken. Drop it. No one
> > ever used it either, except for mislead people.
>
> Sorry for my bad git knowledge:
> Is the above part of the commit message?
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Yep, its part of the commit message.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread wm4
On Tue,  1 May 2018 16:46:37 -0400
Vittorio Giovara  wrote:

> --
> 
> On 5/1/2018 4:39 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  libavcodec/avcodec.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index fb0c6fae70..3a8f69243c 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
> >  uint8_t max_lowres; ///< maximum value for lowres 
> > supported by the decoder
> >  const AVClass *priv_class;  ///< AVClass for the private 
> > context
> >  const AVProfile *profiles;  ///< array of recognized 
> > profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
> > +const enum AVColorRange *color_ranges;  ///< array of supported color 
> > ranges by encoder, or NULL if unknown, array is terminated by 
> > AVCOL_RANGE_UNSPECIFIED
> >  
> >  /**
> >   * Group name of the codec implementation.
> >   
> 
> While I appreciate this effort to remove the year-long deprecated J-pixel
> format, I have a feeling that this is not the right way to do it.
> 
> I have no doubt that the code presented here works as expected, however
> adding YetAnotherField to the AVCodec structure is a slippery road. Namely
> only adding color range as an extra feature of the pixel format is incomplete.
> 
> We should add every other single color parameter in this structure, insert
> the appropriate conversion filters (which swscale is not fully able to
> produce) and handle correct format negotiation across the chain, which is
> not exactly trivial (ie. which color space should be favoured? which one has
> a larger gamut? and so on).
> 
> This creates a precedent that, I think, is bad API-wise and user-wise.
> I would rather keep the J-format around than creating a years long user-facing
> problem. Additionally having this field (or these fields if we are to include
> the other color properties) around makes the intrisic problem even harder
> to properly fix.
> 
> I am aware that the goal of this patchset is not to properly support all
> color conversion properties, and it's just to being able to drop the 
> J-formats,
> but I hope that this feedback will give a larger picture of the problem
> involved, that it will help you in making the right decision about this set.

I think the patch at hand is OK if it can finally get rid of the J
formats. To me as an API users these actually cause nothing but
annoyance, so it's really great to get rid of them.

Sure, this doesn't solve negotiating of video attributes in
libavfilter, or accurately exposing all encoder capabilities. There are
plenty of other such cases (ask if you want examples). Solving this in
a general and complete way is _hard_. It's not just about adding
missing fields. On a side note, we should think of something that
doesn't require us duplicating all these metadata fields in AVCodec,
AVCodecContext, AVFrame, avfilter buffer sink, avfilter buffer src, and
having to touch every single to "negotiate" the attribute.

So just adding support for color range for the sole purpose of removing
the J formats sounds good to me.

What do you suggest?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/cbs: use av_fast_malloc in case of unit write buffer overflow

2018-05-01 Thread James Almer
Use it instead of av_reallocp, as the contents of the existing buffer
are ultimately discarded.

Signed-off-by: James Almer 
---
Barely any speed gain in most cases, but realloc of this data is
nonetheless unnecessary.

 libavcodec/cbs_h2645.c | 13 +++--
 libavcodec/cbs_h2645.h |  2 +-
 libavcodec/cbs_mpeg2.c | 13 +++--
 libavcodec/cbs_mpeg2.h |  2 +-
 libavcodec/cbs_vp9.c   | 15 ---
 libavcodec/cbs_vp9.h   |  2 +-
 6 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 64a1a2d1ee..ccb4e5190c 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1235,19 +1235,20 @@ static int 
cbs_h2645_write_nal_unit(CodedBitstreamContext *ctx,
 CodedBitstreamH2645Context *priv = ctx->priv_data;
 enum AVCodecID codec_id = ctx->codec->codec_id;
 PutBitContext pbc;
+size_t write_buffer_size;
 int err;
 
 if (!priv->write_buffer) {
 // Initial write buffer size is 1MB.
-priv->write_buffer_size = 1024 * 1024;
+write_buffer_size = 1024 * 1024;
 
 reallocate_and_try_again:
-err = av_reallocp(>write_buffer, priv->write_buffer_size);
-if (err < 0) {
+av_fast_malloc(>write_buffer, >write_buffer_size, 
write_buffer_size);
+if (!priv->write_buffer) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a "
"sufficiently large write buffer (last attempt "
-   "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size);
-return err;
+   "%"SIZE_SPECIFIER" bytes).\n", write_buffer_size);
+return AVERROR(ENOMEM);
 }
 }
 
@@ -1260,7 +1261,7 @@ static int cbs_h2645_write_nal_unit(CodedBitstreamContext 
*ctx,
 
 if (err == AVERROR(ENOSPC)) {
 // Overflow.
-priv->write_buffer_size *= 2;
+write_buffer_size = priv->write_buffer_size * 2;
 goto reallocate_and_try_again;
 }
 // Overflow but we didn't notice.
diff --git a/libavcodec/cbs_h2645.h b/libavcodec/cbs_h2645.h
index f4cf65bdde..29630ea7b5 100644
--- a/libavcodec/cbs_h2645.h
+++ b/libavcodec/cbs_h2645.h
@@ -36,7 +36,7 @@ typedef struct CodedBitstreamH2645Context {
 
 // Write buffer
 uint8_t *write_buffer;
-size_t write_buffer_size;
+unsigned write_buffer_size;
 } CodedBitstreamH2645Context;
 
 
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 0df4234b12..c081a63737 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -298,19 +298,20 @@ static int cbs_mpeg2_write_unit(CodedBitstreamContext 
*ctx,
 {
 CodedBitstreamMPEG2Context *priv = ctx->priv_data;
 PutBitContext pbc;
+size_t write_buffer_size;
 int err;
 
 if (!priv->write_buffer) {
 // Initial write buffer size is 1MB.
-priv->write_buffer_size = 1024 * 1024;
+write_buffer_size = 1024 * 1024;
 
 reallocate_and_try_again:
-err = av_reallocp(>write_buffer, priv->write_buffer_size);
-if (err < 0) {
+av_fast_malloc(>write_buffer, >write_buffer_size, 
write_buffer_size);
+if (!priv->write_buffer) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a "
"sufficiently large write buffer (last attempt "
-   "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size);
-return err;
+   "%"SIZE_SPECIFIER" bytes).\n", write_buffer_size);
+return AVERROR(ENOMEM);
 }
 }
 
@@ -323,7 +324,7 @@ static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx,
 
 if (err == AVERROR(ENOSPC)) {
 // Overflow.
-priv->write_buffer_size *= 2;
+write_buffer_size = priv->write_buffer_size * 2;
 goto reallocate_and_try_again;
 }
 if (err < 0) {
diff --git a/libavcodec/cbs_mpeg2.h b/libavcodec/cbs_mpeg2.h
index 92caa99dc1..824e15b524 100644
--- a/libavcodec/cbs_mpeg2.h
+++ b/libavcodec/cbs_mpeg2.h
@@ -222,7 +222,7 @@ typedef struct CodedBitstreamMPEG2Context {
 
 // Write buffer.
 uint8_t *write_buffer;
-size_t write_buffer_size;
+unsigned write_buffer_size;
 } CodedBitstreamMPEG2Context;
 
 
diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index 7498be4b73..05bf2da66b 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -514,19 +514,20 @@ static int cbs_vp9_write_unit(CodedBitstreamContext *ctx,
 CodedBitstreamVP9Context *priv = ctx->priv_data;
 VP9RawFrame *frame = unit->content;
 PutBitContext pbc;
+size_t write_buffer_size;
 int err;
 
 if (!priv->write_buffer) {
 // Initial write buffer size is 1MB.
-priv->write_buffer_size = 1024 * 1024;
+write_buffer_size = 1024 * 1024;
 
 reallocate_and_try_again:
-err = av_reallocp(>write_buffer, priv->write_buffer_size);
-if (err < 0) {
+av_fast_malloc(>write_buffer, >write_buffer_size, 

Re: [FFmpeg-devel] [PATCH 4/6] lavc: Add coded bitstream read/write support for VP9

2018-05-01 Thread James Almer
On 5/1/2018 9:53 PM, Mark Thompson wrote:
> On 01/05/18 18:33, James Almer wrote:
>> On 4/30/2018 8:26 PM, Mark Thompson wrote:
>>> ---
>>> Main change since last time is including the array subscripts.  Constants 
>>> are also cleaned up a bit, but stay in the cbs header (vp9.h could probably 
>>> be taken over for this purpose, but currently it's an unnamespaced header 
>>> used by the decoder so I haven't touched it).
>>>
>>>
>>>  configure|   2 +
>>>  doc/bitstream_filters.texi   |   2 +-
>>>  libavcodec/Makefile  |   1 +
>>>  libavcodec/cbs.c |   6 +
>>>  libavcodec/cbs.h |   1 +
>>>  libavcodec/cbs_internal.h|   1 +
>>>  libavcodec/cbs_vp9.c | 679 
>>> +++
>>>  libavcodec/cbs_vp9.h | 201 +++
>>>  libavcodec/cbs_vp9_syntax_template.c | 390 
>>>  9 files changed, 1282 insertions(+), 1 deletion(-)
>>>  create mode 100644 libavcodec/cbs_vp9.c
>>>  create mode 100644 libavcodec/cbs_vp9.h
>>>  create mode 100644 libavcodec/cbs_vp9_syntax_template.c
>>
>> LGTM. No apparent data copy on any of the read methods which is very
>> promising for the AV1 implementation.
>> Only CodedBitstreamType->write_unit() still seems a tad sub-optimal with
>> the temp write_buffer, especially in this module where unlike
>> mpeg2/h2645 you memcpy the data twice.
> 
> It's copied twice in MPEG-2/H.26[45] as well - once from the write buffer to 
> the unit data buffers, then a second time to combine them into the fragment 
> data buffer (which also adds the emulation prevention in the H.26[45] case, 
> so not really a direct copy).

It's probably impossible to avoid the memcpys when assembling a fragment
out of each unit data for most codecs, so we should focus on optimizing
write_unit().

> 
> It's not very easy to do better - a possible way would be to allow the write 
> buffer to contain multiple units and make the reference point at the write 
> buffer itself, then we could avoid the first copy to a per-unit buffer.  That 
> requires somewhat more care in writing, though, because some special cases 
> become nastier to handle (re-copying previous units on overflow; allocating a 
> new write buffer if unit data needs to live beyond the reassembly).
> 
> In theory that can also elide the second copy in VP9 (because the frames are 
> just concatenated in the write buffer, and the superframe header placed at 
> the end), but in practice that isn't necessarily a benefit because you end up 
> with even more allocation if the following component ever needs to hold more 
> than one output packet at once.

One option in write_unit() could be making the unit take ownership of
the buffer as filled by the codec specific bitstream functions (what's
currently priv->write_buffer) instead of allocating a new one within
ff_cbs_alloc_unit_data and then copying data to it.
This would make priv->write_buffer something local to write_unit(),
allocated anew once per call, and then wrapped as the unit's buffer.

This could be done with a new ff_cbs_wrap_unit_data() function or similar.

> 
> So, I'm not intending to do anything with this for now, but if you want to 
> look at it (or have any other ideas you think I should pursue) then please do.
> 
> Thanks,
> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Fallback to duration if sample rate is unavailable

2018-05-01 Thread wm4
On Tue,  1 May 2018 22:44:07 +0200
Michael Niedermayer  wrote:

> Regression since: af1761f7
> Fixes: Division by 0
> Fixes: ffmpeg_crash_1
> 
> Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan 
> Caciulescu with AFLSmart
> Signed-off-by: Michael Niedermayer 
> ---
>  fftools/ffmpeg.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 5dc198f933..15fa54f24e 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2706,8 +2706,12 @@ static int process_input_packet(InputStream *ist, 
> const AVPacket *pkt, int no_eo
>  ist->dts = ist->next_dts;
>  switch (ist->dec_ctx->codec_type) {
>  case AVMEDIA_TYPE_AUDIO:
> -ist->next_dts += ((int64_t)AV_TIME_BASE * 
> ist->dec_ctx->frame_size) /
> - ist->dec_ctx->sample_rate;
> +if (ist->dec_ctx->sample_rate) {
> +ist->next_dts += ((int64_t)AV_TIME_BASE * 
> ist->dec_ctx->frame_size) /
> +  ist->dec_ctx->sample_rate;
> +} else {
> +ist->next_dts += av_rescale_q(pkt->duration, 
> ist->st->time_base, AV_TIME_BASE_Q);
> +}
>  break;
>  case AVMEDIA_TYPE_VIDEO:
>  if (ist->framerate.num) {

Wouldn't it be better to error out here, instead of using yet another
unreliable value and "hoping for the best"?

Also I'm not sure, but I think unknown durations are sometimes set to
-1 instead of 0.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/6] lavc: Add coded bitstream read/write support for VP9

2018-05-01 Thread Mark Thompson
On 01/05/18 18:33, James Almer wrote:
> On 4/30/2018 8:26 PM, Mark Thompson wrote:
>> ---
>> Main change since last time is including the array subscripts.  Constants 
>> are also cleaned up a bit, but stay in the cbs header (vp9.h could probably 
>> be taken over for this purpose, but currently it's an unnamespaced header 
>> used by the decoder so I haven't touched it).
>>
>>
>>  configure|   2 +
>>  doc/bitstream_filters.texi   |   2 +-
>>  libavcodec/Makefile  |   1 +
>>  libavcodec/cbs.c |   6 +
>>  libavcodec/cbs.h |   1 +
>>  libavcodec/cbs_internal.h|   1 +
>>  libavcodec/cbs_vp9.c | 679 
>> +++
>>  libavcodec/cbs_vp9.h | 201 +++
>>  libavcodec/cbs_vp9_syntax_template.c | 390 
>>  9 files changed, 1282 insertions(+), 1 deletion(-)
>>  create mode 100644 libavcodec/cbs_vp9.c
>>  create mode 100644 libavcodec/cbs_vp9.h
>>  create mode 100644 libavcodec/cbs_vp9_syntax_template.c
> 
> LGTM. No apparent data copy on any of the read methods which is very
> promising for the AV1 implementation.
> Only CodedBitstreamType->write_unit() still seems a tad sub-optimal with
> the temp write_buffer, especially in this module where unlike
> mpeg2/h2645 you memcpy the data twice.

It's copied twice in MPEG-2/H.26[45] as well - once from the write buffer to 
the unit data buffers, then a second time to combine them into the fragment 
data buffer (which also adds the emulation prevention in the H.26[45] case, so 
not really a direct copy).

It's not very easy to do better - a possible way would be to allow the write 
buffer to contain multiple units and make the reference point at the write 
buffer itself, then we could avoid the first copy to a per-unit buffer.  That 
requires somewhat more care in writing, though, because some special cases 
become nastier to handle (re-copying previous units on overflow; allocating a 
new write buffer if unit data needs to live beyond the reassembly).

In theory that can also elide the second copy in VP9 (because the frames are 
just concatenated in the write buffer, and the superframe header placed at the 
end), but in practice that isn't necessarily a benefit because you end up with 
even more allocation if the following component ever needs to hold more than 
one output packet at once.

So, I'm not intending to do anything with this for now, but if you want to look 
at it (or have any other ideas you think I should pursue) then please do.

Thanks,

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


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread wm4
On Tue,  1 May 2018 17:48:32 +0200
Paul B Mahol  wrote:

> This one actually works with hd1080 y4m files when seeking backwards.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/yuv4mpegdec.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> index 8662a42a4c..de3d5637fe 100644
> --- a/libavformat/yuv4mpegdec.c
> +++ b/libavformat/yuv4mpegdec.c
> @@ -317,11 +317,9 @@ static int yuv4_read_seek(AVFormatContext *s, int 
> stream_index,
>  AVStream *st = s->streams[0];
>  int64_t pos;
>  
> -pos = av_rescale_rnd(pts * s->packet_size,
> - st->time_base.num,
> - st->time_base.den * s->packet_size,
> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : 
> AV_ROUND_UP);
> -pos *= s->packet_size;
> +if (flags & AVSEEK_FLAG_BACKWARD)
> +pts -= 1;
> +pos = pts * s->packet_size;
>  
>  if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
>  return -1;

That seems questionable too. Though I'm not sure if the previous code
is correct.

In theory, you're supposed to do this:
1. Determine seek target as accurately as possible
2. If the seek target is not exact then:
2a. if AVSEEK_FLAG_FORWARD is set, then round to the next frame
2b. otherwise, round to the previous frame

But if pts is in the stream timebase, then 2. can never happen. (And
also, I have no idea what the code removed by this patch does.)

Regarding mpv, can you just send me a reproducible test case?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 6/6] lavc/cbs: Add tests for VP9

2018-05-01 Thread Mark Thompson
On 01/05/18 18:37, James Almer wrote:
> On 4/30/2018 8:26 PM, Mark Thompson wrote:
>> Uses the same mechanism as other codecs - conformance test files are
>> passed through the metadata filter (which, with no options, reads the
>> input and writes it back) and the output verified to match the input.
>> ---
>>  tests/fate/cbs.mak | 34 
>> ++
>>  tests/ref/fate/cbs-vp9-vp90-2-03-deltaq|  1 +
>>  tests/ref/fate/cbs-vp9-vp90-2-05-resize|  1 +
>>  tests/ref/fate/cbs-vp9-vp90-2-06-bilinear  |  1 +
>>  tests/ref/fate/cbs-vp9-vp90-2-09-lf_deltas |  1 +
>>  .../ref/fate/cbs-vp9-vp90-2-10-show-existing-frame |  1 +
>>  .../fate/cbs-vp9-vp90-2-10-show-existing-frame2|  1 +
>>  .../ref/fate/cbs-vp9-vp90-2-segmentation-aq-akiyo  |  1 +
>>  .../ref/fate/cbs-vp9-vp90-2-segmentation-sf-akiyo  |  1 +
>>  tests/ref/fate/cbs-vp9-vp90-2-tiling-pedestrian|  1 +
>>  tests/ref/fate/cbs-vp9-vp91-2-04-yuv440|  1 +
>>  tests/ref/fate/cbs-vp9-vp91-2-04-yuv444|  1 +
>>  tests/ref/fate/cbs-vp9-vp92-2-20-10bit-yuv420  |  1 +
>>  tests/ref/fate/cbs-vp9-vp93-2-20-10bit-yuv422  |  1 +
>>  tests/ref/fate/cbs-vp9-vp93-2-20-12bit-yuv444  |  1 +
>>  15 files changed, 43 insertions(+), 5 deletions(-)
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-03-deltaq
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-05-resize
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-06-bilinear
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-09-lf_deltas
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-10-show-existing-frame
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-10-show-existing-frame2
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-segmentation-aq-akiyo
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-segmentation-sf-akiyo
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-tiling-pedestrian
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp91-2-04-yuv440
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp91-2-04-yuv444
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp92-2-20-10bit-yuv420
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp93-2-20-10bit-yuv422
>>  create mode 100644 tests/ref/fate/cbs-vp9-vp93-2-20-12bit-yuv444
> 
> LGTM.
> 
> Unrelated to this patch, but could you add -y to the command line for
> all cbs tests? That way it will not fail/abort if the output file
> already exists (Something that can happen if the test failed previously
> as no cleanup takes place in that case).

Right, yes - I've added this as a further trivial patch and applied the rest of 
the set (subscripts + VP9).

Thank you for reviewing all of that,

- Mark

(AV1 support to follow at some point.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 11/24] avcodec/mjpegdec: replace YUVJ pixel formats

2018-05-01 Thread Michael Niedermayer
On Tue, May 01, 2018 at 09:40:00PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/mjpegdec.c| 18 +-
>  libavcodec/tdsc.c|  2 +-
>  tests/fate/vcodec.mak|  4 ++--
>  tests/ref/fate/api-mjpeg-codec-param |  4 ++--
>  tests/ref/fate/exif-image-embedded   |  2 +-
>  tests/ref/fate/exif-image-jpg|  2 +-
>  6 files changed, 16 insertions(+), 16 deletions(-)

the colors for the following look different between input and output after
this patch

./ffmpeg -i ~/tickets/3949/680.jpg -an -vcodec utvideo -t 1 -pix_fmt yuv420p 
out.avi

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

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


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


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Vittorio Giovara
-- 

On Wed May 2 01:45:47 EEST 2018 Rostislav Pehlivanov wrote:
> I agree with you, they need to be gone. The purpose of the patchset also
> isn't just to get rid of them, its to have a good api to handle color
> ranges and how it ought to be handled by filters and codecs. His only
> objection was that there's a stigma to adding more fields to avctx, which
> can't be avoided in this case _because_ the color range is an essential
> property of images.

Well no, let's step back a little.

First of all there is no stigma about adding fields to AVCodecContext,
in fact, the more, the merrier, right?

Secondly, there _is_ concern about adding a field to AVCodec (not avctx),
since is a delicate point of entry, and very sensitive to ABI (which in fact
was broken in the first iteration of this patch).

Finally, I immensely disagree that this is a good API at all, just throwing
fields to structure is rarely a good approach to anything. On a separate note
I also disagree that color_range (despite its importance) is an "essential
property of images", at least not any more than the other color propeties:
it is simply being noticed because there are special purpose enum values, but
that doesn't mean that the other properties will work "just fine". Because
they don't.
The transfer characteristics for example is a much more impactful and
delicate property that can affect the the color of the image in a much
more profund way than color range.
Similar arguments could be made for primaries and matrix.

As much as you may hate hear it, this proposed filtering system does *not*
belong to neither lavfi, lavf or lavc, but rather to the scaling library.
Unfortunately the one used by default, swscale, is a monster spaghetti code
and too difficult to work around. That however should not affect the design
of APIs used in the other libraries: if swscale is not suited anymore for
its job it should be replaced, you shouldn't be adding workarounds to AVCodec.


Paul, if warnings are what's bothering you, just drop the warnings, instead
of introducing a years long, user facing, difficult to remove API.
Since I fear this message will be ignored too, it will be my last one on this
topic as well.

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


Re: [FFmpeg-devel] [PATCH 12/24] avcodec/mjpegenc: add support for non-YUVJ formats

2018-05-01 Thread Michael Niedermayer
On Wed, May 02, 2018 at 12:22:10AM +0200, Paul B Mahol wrote:
> On 5/2/18, Michael Niedermayer  wrote:
> > Hi
> >
> > On Tue, May 01, 2018 at 09:40:01PM +0200, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavcodec/mjpegenc.c  | 5 -
> >>  libavcodec/mpegvideo_enc.c | 3 +--
> >>  tests/lavf-regression.sh   | 2 +-
> >>  3 files changed, 6 insertions(+), 4 deletions(-)
> >
> > This doesnt work
> 
> It does work, if you want full range set full range as option.


> Check visually colors.

They vissually look wrong too same as the gimp color picker would suggest


> This happens because rgb is still marked incorrectly as limited range,
> so limited is picked instead.

no, that is not the problem.
We could take a mpeg2 file as input which is limited range "always"
that takes rgb completely out of the picture
and you still should have a jpeg file that will look wrong vissually 
in many jpeg decoders.

libavcodec supports the inofficial limited range extension so that will look
correct.


> 
> >
> > first create a input file
> > ./ffmpeg -f lavfi -i testsrc=640x480 test.ppm
> > (if you like check that this has correct white and black) 0,0,0 and
> > 255,255,255
> >
> > now convert to jpeg
> > ./ffmpeg -i test.ppm test.jpg
> > gimp test.jpg
> >
> > white and black have RGB values: 16,16,16 and 235,235,235 thats not correct
> > and also looks wrong
> >
> > the strict_std_compliance check that was before this cannot be just droped
> >
> > If you want jpeg images to interoperate with all software they must be full
> >
> > range
> > the limited range is a not entirely official feature. So it should not be
> > used by default
> > (that is AFAIK, things may have changed and maybe theres a official way now
> >  but from what i remember there was not for images)
> 
> Better check actual paper.

I think whoever changes what the encoder outputs should check it
its JFIF 1.02 for images. See "Conversion to and from RGB"

"Y, Cb, and Cr are converted from R, G, and B as defined in CCIR Recommendation 
601
 but are normalized so as to occupy the full 256 levels of a 8-bit binary 
encoding."
 

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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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


Re: [FFmpeg-devel] [PATCH 25/26] lavc/h264: Add common code for level handling

2018-05-01 Thread Mark Thompson
On 27/04/18 06:42, Xiang, Haihao wrote:
> Just for curious, will you have the common code for H.265 level handling too?

I've written some matching the H.264 code, but it's not yet complete because I 
haven't come up with a clean way to deal with all of the different subprofiles.

For example, decoding code doesn't really care at all about the difference 
between all of the different YUV 4:4:4 subprofiles ("Main 4:4:4", "High 
Throughput 4:4:4", "Screen-Extended Main 4:4:4", "Screen-Extended High 
Throughput 4:4:4", "Main 4:4:4 Intra", "Main 4:4:4 Still Picture") - it only 
cares about whether it supports the individually-flagged features used by a 
stream or not (and indeed that's reflected in the current libavcodec support, 
which doesn't bother to explicitly distinguish RExt subprofiles at all).  On 
the other hand, they do all have different properties when considered for level 
constraints (notably table A.8), and so need to be fully identified in any code 
handling that properly.

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


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Rostislav Pehlivanov
On 1 May 2018 at 22:06, Paul B Mahol  wrote:

> On 5/1/18, Vittorio Giovara  wrote:
> > --
> >
> > On 5/1/2018 4:39 PM, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavcodec/avcodec.h | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index fb0c6fae70..3a8f69243c 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
> >>  uint8_t max_lowres; ///< maximum value for
> lowres
> >> supported by the decoder
> >>  const AVClass *priv_class;  ///< AVClass for the
> private
> >> context
> >>  const AVProfile *profiles;  ///< array of recognized
> >> profiles, or NULL if unknown, array is terminated by
> {FF_PROFILE_UNKNOWN}
> >> +const enum AVColorRange *color_ranges;  ///< array of supported
> color
> >> ranges by encoder, or NULL if unknown, array is terminated by
> >> AVCOL_RANGE_UNSPECIFIED
> >>
> >>  /**
> >>   * Group name of the codec implementation.
> >>
> >
> > While I appreciate this effort to remove the year-long deprecated J-pixel
> > format, I have a feeling that this is not the right way to do it.
> >
> > I have no doubt that the code presented here works as expected, however
> > adding YetAnotherField to the AVCodec structure is a slippery road.
> Namely
> > only adding color range as an extra feature of the pixel format is
> > incomplete.
> >
> > We should add every other single color parameter in this structure,
> insert
> > the appropriate conversion filters (which swscale is not fully able to
> > produce) and handle correct format negotiation across the chain, which is
> > not exactly trivial (ie. which color space should be favoured? which one
> has
> > a larger gamut? and so on).
> >
> > This creates a precedent that, I think, is bad API-wise and user-wise.
> > I would rather keep the J-format around than creating a years long
> > user-facing
> > problem. Additionally having this field (or these fields if we are to
> > include
> > the other color properties) around makes the intrisic problem even harder
> > to properly fix.
> >
> > I am aware that the goal of this patchset is not to properly support all
> > color conversion properties, and it's just to being able to drop the
> > J-formats,
> > but I hope that this feedback will give a larger picture of the problem
> > involved, that it will help you in making the right decision about this
> set.
>
> Then why are they deprecated at all?
>
> There is even warning displayed all the time.
>
> Not mentioning that color range does not work at all unless explicitly
> managed.
>
> Because you are not proposing solution, and just complaining, I will
> ignore this mail.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

I agree with you, they need to be gone. The purpose of the patchset also
isn't just to get rid of them, its to have a good api to handle color
ranges and how it ought to be handled by filters and codecs. His only
objection was that there's a stigma to adding more fields to avctx, which
can't be avoided in this case _because_ the color range is an essential
property of images.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 5/6] lavc: Add VP9 metadata bitstream filter

2018-05-01 Thread James Almer
On 4/30/2018 8:26 PM, Mark Thompson wrote:
> Can adjust the colour information.
> ---
>  configure  |   1 +
>  doc/bitstream_filters.texi |  26 +++
>  libavcodec/Makefile|   1 +
>  libavcodec/bitstream_filters.c |   1 +
>  libavcodec/vp9_metadata_bsf.c  | 162 
> +
>  5 files changed, 191 insertions(+)
>  create mode 100644 libavcodec/vp9_metadata_bsf.c
> 

[...]

> +static const AVOption vp9_metadata_options[] = {
> +{ "color_space", "Set colour space (section 7.2.2)",
> +OFFSET(color_space), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, VP9_CS_RGB, FLAGS, "cs" },
> +{ "unknown",  "Unknown/unspecified",  0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_UNKNOWN   }, .flags = FLAGS, .unit = "cs" },
> +{ "bt601","ITU-R BT.601-7",   0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_BT_601}, .flags = FLAGS, .unit = "cs" },
> +{ "bt709","ITU-R BT.709-6",   0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_BT_709}, .flags = FLAGS, .unit = "cs" },
> +{ "smpte170", "SMPTE-170",0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_SMPTE_170 }, .flags = FLAGS, .unit = "cs" },
> +{ "smpte240", "SMPTE-240",0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_SMPTE_240 }, .flags = FLAGS, .unit = "cs" },
> +{ "bt2020",   "ITU-R BT.2020-2",  0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_BT_2020   }, .flags = FLAGS, .unit = "cs" },
> +{ "rgb",  "sRGB / IEC 61966-2-1", 0, AV_OPT_TYPE_CONST,
> +{ .i64 = VP9_CS_RGB   }, .flags = FLAGS, .unit = "cs" },
> +
> +{ "color_range", "Set colour range (section 7.2.2)",
> +OFFSET(color_range), AV_OPT_TYPE_INT,
> +{ .i64 = -1 }, -1, 1, FLAGS, "cr" },
> +{ "tv", "TV (limited) range", 0, AV_OPT_TYPE_CONST,
> +{ .i64 = 0 }, .flags = FLAGS, .unit = "cr" },
> +{ "pc", "PC (full) range",0, AV_OPT_TYPE_CONST,
> +{ .i64 = 1 }, .flags = FLAGS, .unit = "cr" },
> +
> +{ NULL }

Options look great now, so LGTM.

> +};
> +
> +static const AVClass vp9_metadata_class = {
> +.class_name = "vp9_metadata_bsf",
> +.item_name  = av_default_item_name,
> +.option = vp9_metadata_options,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +
> +static const enum AVCodecID vp9_metadata_codec_ids[] = {
> +AV_CODEC_ID_VP9, AV_CODEC_ID_NONE,
> +};
> +
> +const AVBitStreamFilter ff_vp9_metadata_bsf = {
> +.name   = "vp9_metadata",
> +.priv_data_size = sizeof(VP9MetadataContext),
> +.priv_class = _metadata_class,
> +.init   = _metadata_init,
> +.close  = _metadata_close,
> +.filter = _metadata_filter,
> +.codec_ids  = vp9_metadata_codec_ids,
> +};
> 

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


Re: [FFmpeg-devel] [PATCH 12/24] avcodec/mjpegenc: add support for non-YUVJ formats

2018-05-01 Thread Rostislav Pehlivanov
On 1 May 2018 at 23:22, Paul B Mahol  wrote:

> On 5/2/18, Michael Niedermayer  wrote:
> > Hi
> >
> > On Tue, May 01, 2018 at 09:40:01PM +0200, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavcodec/mjpegenc.c  | 5 -
> >>  libavcodec/mpegvideo_enc.c | 3 +--
> >>  tests/lavf-regression.sh   | 2 +-
> >>  3 files changed, 6 insertions(+), 4 deletions(-)
> >
> > This doesnt work
>
> It does work, if you want full range set full range as option.
> Check visually colors.
> This happens because rgb is still marked incorrectly as limited range,
> so limited is picked instead.
>

Shouldn't this be part of the patchset?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/6] cbs: Fragment/unit data is always reference counted

2018-05-01 Thread Mark Thompson
On 01/05/18 16:51, James Almer wrote:
> On 4/30/2018 8:26 PM, Mark Thompson wrote:
>> Make this clear in the documentation and add some asserts to ensure
>> that it is always true.
>> ---
>> As suggested earlier :)
>>
>>
>>  libavcodec/cbs.c | 18 --
>>  libavcodec/cbs.h | 10 ++
>>  2 files changed, 18 insertions(+), 10 deletions(-)
>>
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index d81b4e03f7..0d6ffe8824 100644
>> --- a/libavcodec/cbs.c
>> +++ b/libavcodec/cbs.c
>> @@ -140,26 +140,30 @@ static int 
>> cbs_read_fragment_content(CodedBitstreamContext *ctx,
>>  int err, i, j;
>>  
>>  for (i = 0; i < frag->nb_units; i++) {
>> +CodedBitstreamUnit *unit = >units[i];
>> +
>>  if (ctx->decompose_unit_types) {
>>  for (j = 0; j < ctx->nb_decompose_unit_types; j++) {
>> -if (ctx->decompose_unit_types[j] == frag->units[i].type)
>> +if (ctx->decompose_unit_types[j] == unit->type)
>>  break;
>>  }
>>  if (j >= ctx->nb_decompose_unit_types)
>>  continue;
>>  }
>>  
>> -av_buffer_unref(>units[i].content_ref);
>> -frag->units[i].content = NULL;
>> +av_buffer_unref(>content_ref);
>> +unit->content = NULL;
>> +
>> +av_assert0(unit->data && unit->data_ref);
>>  
>> -err = ctx->codec->read_unit(ctx, >units[i]);
>> +err = ctx->codec->read_unit(ctx, unit);
>>  if (err == AVERROR(ENOSYS)) {
>>  av_log(ctx->log_ctx, AV_LOG_VERBOSE,
>> "Decomposition unimplemented for unit %d "
>> -   "(type %"PRIu32").\n", i, frag->units[i].type);
>> +   "(type %"PRIu32").\n", i, unit->type);
>>  } else if (err < 0) {
>>  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
>> -   "(type %"PRIu32").\n", i, frag->units[i].type);
>> +   "(type %"PRIu32").\n", i, unit->type);
>>  return err;
>>  }
>>  }
>> @@ -277,6 +281,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext 
>> *ctx,
>> "(type %"PRIu32").\n", i, unit->type);
>>  return err;
>>  }
>> +av_assert0(unit->data && unit->data_ref);
>>  }
>>  
>>  av_buffer_unref(>data_ref);
>> @@ -287,6 +292,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext 
>> *ctx,
>>  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to assemble 
>> fragment.\n");
>>  return err;
>>  }
>> +av_assert0(frag->data && frag->data_ref);
> 
> You can remove the assert in ff_cbs_write_packet() if you add this one.

Yes, that would be sensible - removed.

>>  
>>  return 0;
>>  }
>> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
>> index 402eb39e00..487358afaf 100644
>> --- a/libavcodec/cbs.h
>> +++ b/libavcodec/cbs.h
>> @@ -84,8 +84,9 @@ typedef struct CodedBitstreamUnit {
>>   */
>>  size_t   data_bit_padding;
>>  /**
>> - * If data is reference counted, a reference to the buffer containing
>> - * data.  Null if data is not reference counted.
>> + * A reference to the buffer containing data.
>> + *
>> + * Must be set if data is not NULL.
>>   */
>>  AVBufferRef *data_ref;
>>  
>> @@ -130,8 +131,9 @@ typedef struct CodedBitstreamFragment {
>>   */
>>  size_t data_bit_padding;
>>  /**
>> - * If data is reference counted, a reference to the buffer containing
>> - * data.  Null if data is not reference counted.
>> + * A reference to the buffer containing data.
>> + *
>> + * Must be set if data is not NULL.
>>   */
>>  AVBufferRef *data_ref;
> 
> LGTM.

And applied.

Thanks,

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


Re: [FFmpeg-devel] [PATCH 3/6] cbs: Add support for array subscripts in trace output

2018-05-01 Thread James Almer
On 4/30/2018 8:26 PM, Mark Thompson wrote:
> This makes the trace output for arrays significantly nicer.
> ---
>  libavcodec/cbs.c   |  44 ++--
>  libavcodec/cbs_h2645.c |  83 ---
>  libavcodec/cbs_h264_syntax_template.c  | 101 +--
>  libavcodec/cbs_h265_syntax_template.c  | 179 
> +
>  libavcodec/cbs_internal.h  |  10 +-
>  libavcodec/cbs_mpeg2.c |  20 ++--
>  libavcodec/cbs_mpeg2_syntax_template.c |  25 ++---
>  7 files changed, 262 insertions(+), 200 deletions(-)

LGTM, it's nice to see actual index values rather than i, j and such :p
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] fate: add aresample check to tests that needs it

2018-05-01 Thread James Almer
On 5/1/2018 6:54 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
> 
> For single FATE box and for now single test.
> 
> ---
>  tests/Makefile  | 4 
>  tests/fate/avformat.mak | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index 6074ac748e..9286e079df 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -72,6 +72,10 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER 
> $(lastword $(1))_DECODER  \
>   $(firstword $(2))_ENCODER $(lastword $(2))_DECODER  
> \
>   $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
>  
> +ENCDECF = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER  
> \
> + $(firstword $(2))_MUXER   $(lastword $(2))_DEMUXER  
> \
> + $(firstword $(3))_FILTER)

Call it FILTERENCDEC, so it's consistent with the other similar macros.

> +
>  DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
>  ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
>  
> diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
> index a12f9ccc71..5326b6236a 100644
> --- a/tests/fate/avformat.mak
> +++ b/tests/fate/avformat.mak
> @@ -42,7 +42,7 @@ FATE_LAVF-$(call ENCMUX,  RV10 AC3_FIXED,RM)
>  += rm
>  FATE_LAVF-$(call ENCDEC,  PCM_U8,RSO)+= rso
>  FATE_LAVF-$(call ENCDEC,  SGI,   IMAGE2) += sgi
>  FATE_LAVF-$(call ENCMUX,  MJPEG PCM_S16LE,   SMJPEG) += 
> smjpeg
> -FATE_LAVF-$(call ENCDEC,  PCM_S16LE, SOX)+= sox
> +FATE_LAVF-$(call ENCDECF, PCM_S16LE, SOX, ARESAMPLE) += sox
>  FATE_LAVF-$(call ENCDEC,  SUNRAST,   IMAGE2) += 
> sunrast
>  FATE_LAVF-$(call ENCDEC,  FLV,   SWF)+= swf
>  FATE_LAVF-$(call ENCDEC,  TARGA, IMAGE2) += tga
> 

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


Re: [FFmpeg-devel] [PATCH 12/24] avcodec/mjpegenc: add support for non-YUVJ formats

2018-05-01 Thread Paul B Mahol
On 5/2/18, Michael Niedermayer  wrote:
> Hi
>
> On Tue, May 01, 2018 at 09:40:01PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavcodec/mjpegenc.c  | 5 -
>>  libavcodec/mpegvideo_enc.c | 3 +--
>>  tests/lavf-regression.sh   | 2 +-
>>  3 files changed, 6 insertions(+), 4 deletions(-)
>
> This doesnt work

It does work, if you want full range set full range as option.
Check visually colors.
This happens because rgb is still marked incorrectly as limited range,
so limited is picked instead.

>
> first create a input file
> ./ffmpeg -f lavfi -i testsrc=640x480 test.ppm
> (if you like check that this has correct white and black) 0,0,0 and
> 255,255,255
>
> now convert to jpeg
> ./ffmpeg -i test.ppm test.jpg
> gimp test.jpg
>
> white and black have RGB values: 16,16,16 and 235,235,235 thats not correct
> and also looks wrong
>
> the strict_std_compliance check that was before this cannot be just droped
>
> If you want jpeg images to interoperate with all software they must be full
>
> range
> the limited range is a not entirely official feature. So it should not be
> used by default
> (that is AFAIK, things may have changed and maybe theres a official way now
>  but from what i remember there was not for images)

Better check actual paper.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 12/24] avcodec/mjpegenc: add support for non-YUVJ formats

2018-05-01 Thread Michael Niedermayer
Hi

On Tue, May 01, 2018 at 09:40:01PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/mjpegenc.c  | 5 -
>  libavcodec/mpegvideo_enc.c | 3 +--
>  tests/lavf-regression.sh   | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)

This doesnt work

first create a input file
./ffmpeg -f lavfi -i testsrc=640x480 test.ppm
(if you like check that this has correct white and black) 0,0,0 and 255,255,255

now convert to jpeg
./ffmpeg -i test.ppm test.jpg
gimp test.jpg

white and black have RGB values: 16,16,16 and 235,235,235 thats not correct
and also looks wrong

the strict_std_compliance check that was before this cannot be just droped

If you want jpeg images to interoperate with all software they must be full 
range 
the limited range is a not entirely official feature. So it should not be
used by default
(that is AFAIK, things may have changed and maybe theres a official way now
 but from what i remember there was not for images)




[...]
-- 
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
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread Paul B Mahol
On 5/1/18, Derek Buitenhuis  wrote:
> On 5/1/2018 10:15 PM, Paul B Mahol wrote:
>> If you have no other remarks, I will update reference and push patch.
>
> Is the reference change actually correct?

Yes, I tested extensively with mpv.

mpv have option to disable fix pts algo so brokeness came noticed just now.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] fate: add aresample check to tests that needs it

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---

For single FATE box and for now single test.

---
 tests/Makefile  | 4 
 tests/fate/avformat.mak | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index 6074ac748e..9286e079df 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -72,6 +72,10 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER 
$(lastword $(1))_DECODER  \
  $(firstword $(2))_ENCODER $(lastword $(2))_DECODER  \
  $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
 
+ENCDECF = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER  \
+ $(firstword $(2))_MUXER   $(lastword $(2))_DEMUXER  \
+ $(firstword $(3))_FILTER)
+
 DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
 ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
 
diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
index a12f9ccc71..5326b6236a 100644
--- a/tests/fate/avformat.mak
+++ b/tests/fate/avformat.mak
@@ -42,7 +42,7 @@ FATE_LAVF-$(call ENCMUX,  RV10 AC3_FIXED,RM)  
   += rm
 FATE_LAVF-$(call ENCDEC,  PCM_U8,RSO)+= rso
 FATE_LAVF-$(call ENCDEC,  SGI,   IMAGE2) += sgi
 FATE_LAVF-$(call ENCMUX,  MJPEG PCM_S16LE,   SMJPEG) += smjpeg
-FATE_LAVF-$(call ENCDEC,  PCM_S16LE, SOX)+= sox
+FATE_LAVF-$(call ENCDECF, PCM_S16LE, SOX, ARESAMPLE) += sox
 FATE_LAVF-$(call ENCDEC,  SUNRAST,   IMAGE2) += sunrast
 FATE_LAVF-$(call ENCDEC,  FLV,   SWF)+= swf
 FATE_LAVF-$(call ENCDEC,  TARGA, IMAGE2) += tga
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread Derek Buitenhuis
On 5/1/2018 10:15 PM, Paul B Mahol wrote:
> If you have no other remarks, I will update reference and push patch.

Is the reference change actually correct?

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


[FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread Paul B Mahol
Specifically for yuv444, yuv422, yuv420 format when main stream has no alpha, 
and alpha
is straight.

Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_overlay.c  |  75 +---
 libavfilter/vf_overlay.h  |  85 ++
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_overlay.asm| 143 ++
 libavfilter/x86/vf_overlay_init.c |  63 +
 5 files changed, 312 insertions(+), 56 deletions(-)
 create mode 100644 libavfilter/vf_overlay.h
 create mode 100644 libavfilter/x86/vf_overlay.asm
 create mode 100644 libavfilter/x86/vf_overlay_init.c

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 8c1895cca4..c4d87306f1 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -39,6 +39,7 @@
 #include "drawutils.h"
 #include "framesync.h"
 #include "video.h"
+#include "vf_overlay.h"
 
 typedef struct ThreadData {
 AVFrame *dst, *src;
@@ -59,21 +60,6 @@ static const char *const var_names[] = {
 NULL
 };
 
-enum var_name {
-VAR_MAIN_W,VAR_MW,
-VAR_MAIN_H,VAR_MH,
-VAR_OVERLAY_W, VAR_OW,
-VAR_OVERLAY_H, VAR_OH,
-VAR_HSUB,
-VAR_VSUB,
-VAR_X,
-VAR_Y,
-VAR_N,
-VAR_POS,
-VAR_T,
-VAR_VARS_NB
-};
-
 #define MAIN0
 #define OVERLAY 1
 
@@ -92,45 +78,6 @@ enum EvalMode {
 EVAL_MODE_NB
 };
 
-enum OverlayFormat {
-OVERLAY_FORMAT_YUV420,
-OVERLAY_FORMAT_YUV422,
-OVERLAY_FORMAT_YUV444,
-OVERLAY_FORMAT_RGB,
-OVERLAY_FORMAT_GBRP,
-OVERLAY_FORMAT_AUTO,
-OVERLAY_FORMAT_NB
-};
-
-typedef struct OverlayContext {
-const AVClass *class;
-int x, y;   ///< position of overlaid picture
-
-uint8_t main_is_packed_rgb;
-uint8_t main_rgba_map[4];
-uint8_t main_has_alpha;
-uint8_t overlay_is_packed_rgb;
-uint8_t overlay_rgba_map[4];
-uint8_t overlay_has_alpha;
-int format; ///< OverlayFormat
-int alpha_format;
-int eval_mode;  ///< EvalMode
-
-FFFrameSync fs;
-
-int main_pix_step[4];   ///< steps per pixel for each plane of the 
main output
-int overlay_pix_step[4];///< steps per pixel for each plane of the 
overlay
-int hsub, vsub; ///< chroma subsampling values
-const AVPixFmtDescriptor *main_desc; ///< format descriptor for main input
-
-double var_values[VAR_VARS_NB];
-char *x_expr, *y_expr;
-
-AVExpr *x_pexpr, *y_pexpr;
-
-int (*blend_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
-} OverlayContext;
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
 OverlayContext *s = ctx->priv;
@@ -509,6 +456,7 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
  int jobnr,
  int nb_jobs)
 {
+OverlayContext *octx = ctx->priv;
 int src_wp = AV_CEIL_RSHIFT(src_w, hsub);
 int src_hp = AV_CEIL_RSHIFT(src_h, vsub);
 int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub);
@@ -538,8 +486,18 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
 s = sp + k;
 a = ap + (k<blend_row[i]) {
+int c = octx->blend_row[i](d, da, s, a, kmax - k, 
src->linesize[3]);
 
-for (kmax = FFMIN(-xp + dst_wp, src_wp); k < kmax; k++) {
+s += c;
+d += dst_step * c;
+da += (1 << hsub) * c;
+a += (1 << hsub) * c;
+k += c;
+}
+for (; k < kmax; k++) {
 int alpha_v, alpha_h, alpha;
 
 // average alpha for color components, improve quality
@@ -916,7 +874,7 @@ static int config_input_main(AVFilterLink *inlink)
 }
 
 if (!s->alpha_format)
-return 0;
+goto end;
 
 switch (s->format) {
 case OVERLAY_FORMAT_YUV420:
@@ -960,6 +918,11 @@ static int config_input_main(AVFilterLink *inlink)
 }
 break;
 }
+
+end:
+if (ARCH_X86)
+ff_overlay_init_x86(s, s->format, s->alpha_format, s->main_has_alpha);
+
 return 0;
 }
 
diff --git a/libavfilter/vf_overlay.h b/libavfilter/vf_overlay.h
new file mode 100644
index 00..072ece358f
--- /dev/null
+++ b/libavfilter/vf_overlay.h
@@ -0,0 +1,85 @@
+/*
+ * 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 

Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread Paul B Mahol
On 5/1/18, Michael Niedermayer  wrote:
> On Tue, May 01, 2018 at 05:48:32PM +0200, Paul B Mahol wrote:
>> This one actually works with hd1080 y4m files when seeking backwards.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavformat/yuv4mpegdec.c | 8 +++-
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
>> index 8662a42a4c..de3d5637fe 100644
>> --- a/libavformat/yuv4mpegdec.c
>> +++ b/libavformat/yuv4mpegdec.c
>> @@ -317,11 +317,9 @@ static int yuv4_read_seek(AVFormatContext *s, int
>> stream_index,
>>  AVStream *st = s->streams[0];
>>  int64_t pos;
>>
>> -pos = av_rescale_rnd(pts * s->packet_size,
>> - st->time_base.num,
>> - st->time_base.den * s->packet_size,
>> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN :
>> AV_ROUND_UP);
>> -pos *= s->packet_size;
>> +if (flags & AVSEEK_FLAG_BACKWARD)
>> +pts -= 1;
>> +pos = pts * s->packet_size;
>>
>>  if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
>>  return -1;
>
> breaks fate-seek-lavf-yuv4mpeg
>

If you have no other remarks, I will update reference and push patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread Michael Niedermayer
On Tue, May 01, 2018 at 05:48:32PM +0200, Paul B Mahol wrote:
> This one actually works with hd1080 y4m files when seeking backwards.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/yuv4mpegdec.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> index 8662a42a4c..de3d5637fe 100644
> --- a/libavformat/yuv4mpegdec.c
> +++ b/libavformat/yuv4mpegdec.c
> @@ -317,11 +317,9 @@ static int yuv4_read_seek(AVFormatContext *s, int 
> stream_index,
>  AVStream *st = s->streams[0];
>  int64_t pos;
>  
> -pos = av_rescale_rnd(pts * s->packet_size,
> - st->time_base.num,
> - st->time_base.den * s->packet_size,
> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : 
> AV_ROUND_UP);
> -pos *= s->packet_size;
> +if (flags & AVSEEK_FLAG_BACKWARD)
> +pts -= 1;
> +pos = pts * s->packet_size;
>  
>  if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
>  return -1;

breaks fate-seek-lavf-yuv4mpeg

--- ./tests/ref/seek/lavf-yuv4mpeg  2018-05-01 18:09:16.499128665 +0200
+++ tests/data/fate/seek-lavf-yuv4mpeg  2018-05-01 23:04:43.039052762 +0200
@@ -1,48 +1,45 @@
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
 ret:-1 st:-1 flags:0  ts:-1.00
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret:-EOF
 ret: 0 st: 0 flags:0  ts: 0.80
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:3041464 
size:152064
 ret:-1 st: 0 flags:1  ts:-0.32
 ret: 0 st:-1 flags:0  ts: 2.576668
-ret: 0 st: 0 flags:1 dts: 0.12 pts: 0.12 pos: 456274 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:1  ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret:-EOF
 ret: 0 st: 0 flags:0  ts: 0.36
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1368694 
size:152064
 ret:-1 st: 0 flags:1  ts:-0.76
 ret: 0 st:-1 flags:0  ts: 2.153336
-ret: 0 st: 0 flags:1 dts: 0.12 pts: 0.12 pos: 456274 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:1  ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
-ret: 0 st: 0 flags:0  ts:-0.04
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret:-EOF
+ret:-1 st: 0 flags:0  ts:-0.04
 ret: 0 st: 0 flags:1  ts: 2.84
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:0  ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:1  ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
-ret: 0 st: 0 flags:0  ts:-0.48
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.60 pts: 0.60 pos:2281114 
size:152064
+ret:-1 st: 0 flags:0  ts:-0.48
 ret: 0 st: 0 flags:1  ts: 2.40
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:0  ts: 1.306672
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:1  ts: 0.200839
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
-ret: 0 st: 0 flags:0  ts:-0.92
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.16 pts: 0.16 pos: 608344 
size:152064
+ret:-1 st: 0 flags:0  ts:-0.92
 ret: 0 st: 0 flags:1  ts: 2.00
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:0  ts: 0.883340
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.88 pts: 0.88 pos:3345604 
size:152064
 ret:-1 st:-1 flags:1  ts:-0.222493
 ret: 0 st: 0 flags:0  ts: 2.68
-ret: 0 st: 0 flags:1 dts: 0.12 pts: 0.12 pos: 456274 
size:152064
+ret:-EOF
 ret: 0 st: 0 flags:1  ts: 1.56
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret:-EOF
 ret: 0 st:-1 flags:0  ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.48 pts: 0.48 pos:1824904 
size:152064
 ret:-1 st:-1 

Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Paul B Mahol
On 5/1/18, Vittorio Giovara  wrote:
> --
>
> On 5/1/2018 4:39 PM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavcodec/avcodec.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index fb0c6fae70..3a8f69243c 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
>>  uint8_t max_lowres; ///< maximum value for lowres
>> supported by the decoder
>>  const AVClass *priv_class;  ///< AVClass for the private
>> context
>>  const AVProfile *profiles;  ///< array of recognized
>> profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
>> +const enum AVColorRange *color_ranges;  ///< array of supported color
>> ranges by encoder, or NULL if unknown, array is terminated by
>> AVCOL_RANGE_UNSPECIFIED
>>
>>  /**
>>   * Group name of the codec implementation.
>>
>
> While I appreciate this effort to remove the year-long deprecated J-pixel
> format, I have a feeling that this is not the right way to do it.
>
> I have no doubt that the code presented here works as expected, however
> adding YetAnotherField to the AVCodec structure is a slippery road. Namely
> only adding color range as an extra feature of the pixel format is
> incomplete.
>
> We should add every other single color parameter in this structure, insert
> the appropriate conversion filters (which swscale is not fully able to
> produce) and handle correct format negotiation across the chain, which is
> not exactly trivial (ie. which color space should be favoured? which one has
> a larger gamut? and so on).
>
> This creates a precedent that, I think, is bad API-wise and user-wise.
> I would rather keep the J-format around than creating a years long
> user-facing
> problem. Additionally having this field (or these fields if we are to
> include
> the other color properties) around makes the intrisic problem even harder
> to properly fix.
>
> I am aware that the goal of this patchset is not to properly support all
> color conversion properties, and it's just to being able to drop the
> J-formats,
> but I hope that this feedback will give a larger picture of the problem
> involved, that it will help you in making the right decision about this set.

Then why are they deprecated at all?

There is even warning displayed all the time.

Not mentioning that color range does not work at all unless explicitly
managed.

Because you are not proposing solution, and just complaining, I will
ignore this mail.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] mpegvideo: remove support for libxvid's RC system

2018-05-01 Thread Carl Eugen Hoyos
2018-05-01 21:00 GMT+02:00, Rostislav Pehlivanov :
> Its a reminder of a bygone era. Less flexible than the internal RC
> system, probably worse and most definitely broken. Drop it. No one
> ever used it either, except for mislead people.

Sorry for my bad git knowledge:
Is the above part of the commit message?

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


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Vittorio Giovara
--

On 5/1/2018 4:39 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/avcodec.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index fb0c6fae70..3a8f69243c 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
>  uint8_t max_lowres; ///< maximum value for lowres 
> supported by the decoder
>  const AVClass *priv_class;  ///< AVClass for the private 
> context
>  const AVProfile *profiles;  ///< array of recognized 
> profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
> +const enum AVColorRange *color_ranges;  ///< array of supported color 
> ranges by encoder, or NULL if unknown, array is terminated by 
> AVCOL_RANGE_UNSPECIFIED
>  
>  /**
>   * Group name of the codec implementation.
> 

While I appreciate this effort to remove the year-long deprecated J-pixel
format, I have a feeling that this is not the right way to do it.

I have no doubt that the code presented here works as expected, however
adding YetAnotherField to the AVCodec structure is a slippery road. Namely
only adding color range as an extra feature of the pixel format is incomplete.

We should add every other single color parameter in this structure, insert
the appropriate conversion filters (which swscale is not fully able to
produce) and handle correct format negotiation across the chain, which is
not exactly trivial (ie. which color space should be favoured? which one has
a larger gamut? and so on).

This creates a precedent that, I think, is bad API-wise and user-wise.
I would rather keep the J-format around than creating a years long user-facing
problem. Additionally having this field (or these fields if we are to include
the other color properties) around makes the intrisic problem even harder
to properly fix.

I am aware that the goal of this patchset is not to properly support all
color conversion properties, and it's just to being able to drop the J-formats,
but I hope that this feedback will give a larger picture of the problem
involved, that it will help you in making the right decision about this set.

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


[FFmpeg-devel] [PATCH] fftools/ffmpeg: Fallback to duration if sample rate is unavailable

2018-05-01 Thread Michael Niedermayer
Regression since: af1761f7
Fixes: Division by 0
Fixes: ffmpeg_crash_1

Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan 
Caciulescu with AFLSmart
Signed-off-by: Michael Niedermayer 
---
 fftools/ffmpeg.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5dc198f933..15fa54f24e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2706,8 +2706,12 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 ist->dts = ist->next_dts;
 switch (ist->dec_ctx->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
-ist->next_dts += ((int64_t)AV_TIME_BASE * 
ist->dec_ctx->frame_size) /
- ist->dec_ctx->sample_rate;
+if (ist->dec_ctx->sample_rate) {
+ist->next_dts += ((int64_t)AV_TIME_BASE * 
ist->dec_ctx->frame_size) /
+  ist->dec_ctx->sample_rate;
+} else {
+ist->next_dts += av_rescale_q(pkt->duration, 
ist->st->time_base, AV_TIME_BASE_Q);
+}
 break;
 case AVMEDIA_TYPE_VIDEO:
 if (ist->framerate.num) {
-- 
2.17.0

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


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Paul B Mahol
On 5/1/18, James Almer  wrote:
> On 5/1/2018 4:39 PM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavcodec/avcodec.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index fb0c6fae70..3a8f69243c 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
>>  uint8_t max_lowres; ///< maximum value for lowres
>> supported by the decoder
>>  const AVClass *priv_class;  ///< AVClass for the private
>> context
>>  const AVProfile *profiles;  ///< array of recognized
>> profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
>> +const enum AVColorRange *color_ranges;  ///< array of supported color
>> ranges by encoder, or NULL if unknown, array is terminated by
>> AVCOL_RANGE_UNSPECIFIED
>
> Breaks ABI...
>
> Place it below wrapper_name, right above the notice about non public
> section.
>
>>
>>  /**
>>   * Group name of the codec implementation.
>>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH 2/2] avdevice/decklink_dec: unref packets on avpacket_queue_put error

2018-05-01 Thread Marton Balint


On Mon, 30 Apr 2018, James Almer wrote:


On 4/22/2018 6:18 PM, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 libavdevice/decklink_dec.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 10535dc388..510637676c 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -475,16 +475,19 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket 
*pkt)

 // Drop Packet if queue size is > maximum queue size
 if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) {
+av_packet_unref(pkt);
 av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
 return -1;
 }
 /* ensure the packet is reference counted */
 if (av_packet_make_refcounted(pkt) < 0) {
+av_packet_unref(pkt);
 return -1;
 }

 pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
 if (!pkt1) {
+av_packet_unref(pkt);
 return -1;
 }
 av_packet_move_ref(>pkt, pkt);


This should be backported. Strictly speaking the last unref(), since pkt
will always be reference counted at this point even before patch 1/2 of
this series because of the make_refcounted() call above.


Indeed, backported.

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


Re: [FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread James Almer
On 5/1/2018 4:39 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/avcodec.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index fb0c6fae70..3a8f69243c 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3433,6 +3433,7 @@ typedef struct AVCodec {
>  uint8_t max_lowres; ///< maximum value for lowres 
> supported by the decoder
>  const AVClass *priv_class;  ///< AVClass for the private 
> context
>  const AVProfile *profiles;  ///< array of recognized 
> profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
> +const enum AVColorRange *color_ranges;  ///< array of supported color 
> ranges by encoder, or NULL if unknown, array is terminated by 
> AVCOL_RANGE_UNSPECIFIED

Breaks ABI...

Place it below wrapper_name, right above the notice about non public
section.

>  
>  /**
>   * Group name of the codec implementation.
> 

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


Re: [FFmpeg-devel] [PATCH] mpegvideo: remove support for libxvid's RC system

2018-05-01 Thread Rostislav Pehlivanov
On 1 May 2018 at 20:00, Rostislav Pehlivanov  wrote:

>
>  {"ibias", "intra quant bias",
>  FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 =
> FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
>  {"pbias", "inter quant bias",
>  FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 =
> FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
> -{"rc_strategy", "ratecontrol method",
>  FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 =
> MPV_RC_STRATEGY_FFMPEG }, 0, NB_MPV_RC_STRATEGY-1, FF_MPV_OPT_FLAGS,
> "rc_strategy" },   \
> -{ "ffmpeg", "default native rate control", 0, AV_OPT_TYPE_CONST, {
> .i64 = MPV_RC_STRATEGY_FFMPEG }, 0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \
> -{ "xvid",   "libxvid (2 pass only)",   0, AV_OPT_TYPE_CONST, {
> .i64 = MPV_RC_STRATEGY_XVID },   0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \
> +{"rc_strategy", "ratecontrol method",
>  FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1,
> FF_MPV_OPT_FLAGS, "rc_strategy" },   \
> +{ "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64
> = 0 }, 0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \
> +{ "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64
> = 0 }, 0, 0, FF_MPV_OPT_FLAGS, "rc_strategy" }, \
>
>
Locally changed to use the new AV_OPT_FLAG_DEPRECATED flag:
+{"rc_strategy", deprecated, does nothing", FF_MPV_OFFSET(rc_strategy),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS |
AV_OPT_FLAG_DEPRECATED, "rc_strategy" },   \
+{ "ffmpeg", "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 =
0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
+{ "xvid",   "deprecated, does nothing", 0, AV_OPT_TYPE_CONST, { .i64 =
0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED, "rc_strategy" }, \
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread Henrik Gramner
On Tue, May 1, 2018 at 10:02 AM, Paul B Mahol  wrote:
> +cglobal overlay_row_22, 6, 8, 8, 0, d, da, s, a, w, al, r, x
[...]
> +movum2, [aq+2*xq]
> +pandm2, m3
> +movum6, [aq+2*xq]
> +pandm6, m7
> +psrlw   m6, 8
> +paddw   m2, m6
> +psrlw   m2, 1
> +movum6, [aq+2*xq]
> +pandm6, m3
> +paddw   m2, m6
> +psrlw   m2, 1

I believe this can be simplified to something like (untested):

movum1, [aq+2*xq]
pandn   m2, m3, m1
psllw   m1, 8
pavgw   m2, m1
pavgw   m2, m1
psrlw   m2, 8

> +cglobal overlay_row_20, 6, 8, 8, 0, d, da, s, a, w, al, r, x
[...]
> +movum2, [aq+2*xq]
> +pandm2, m3
> +movum6, [aq+2*xq]
> +pandm6, m7
> +psrlw   m6, 8
> +paddw   m2, m6
> +movum6, [daq+2*xq]
> +pandm6, m3
> +paddw   m2, m6
> +movum6, [daq+2*xq]
> +pandm6, m7
> +psrlw   m6, 8
> +paddw   m2, m6
> +psrlw   m2, 2

And this to (untested):

movam6, [pb_1]
...
movum2, [aq+2*xq]
movum1, [daq+2*xq]
pmaddubsw   m2, m6
pmaddubsw   m1, m6
paddw   m2, m1
psrlw   m2, 2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread James Almer
On 5/1/2018 5:02 AM, Paul B Mahol wrote:
> Specifically for yuv444, yuv422, yuv420 format when main stream has no alpha, 
> and alpha
> is straight.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_overlay.c  |  75 +-
>  libavfilter/vf_overlay.h  |  85 +
>  libavfilter/x86/Makefile  |   2 +
>  libavfilter/x86/vf_overlay.asm| 157 
> ++
>  libavfilter/x86/vf_overlay_init.c |  63 +++
>  5 files changed, 326 insertions(+), 56 deletions(-)
>  create mode 100644 libavfilter/vf_overlay.h
>  create mode 100644 libavfilter/x86/vf_overlay.asm
>  create mode 100644 libavfilter/x86/vf_overlay_init.c

[...]

> diff --git a/libavfilter/x86/vf_overlay.asm b/libavfilter/x86/vf_overlay.asm
> new file mode 100644
> index 00..d639cce9e5
> --- /dev/null
> +++ b/libavfilter/x86/vf_overlay.asm
> @@ -0,0 +1,157 @@
> +;*
> +;* x86-optimized functions for overlay filter
> +;*
> +;* Copyright (C) 2018 Paul B Mahol
> +;*
> +;* This file is part of FFmpeg.
> +;*
> +;* FFmpeg is free software; you can redistribute it and/or
> +;* modify it under the terms of the GNU Lesser General Public
> +;* License as published by the Free Software Foundation; either
> +;* version 2.1 of the License, or (at your option) any later version.
> +;*
> +;* FFmpeg is distributed in the hope that it will be useful,
> +;* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +;* Lesser General Public License for more details.
> +;*
> +;* You should have received a copy of the GNU Lesser General Public
> +;* License along with FFmpeg; if not, write to the Free Software
> +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> +;*
> +
> +%include "libavutil/x86/x86util.asm"
> +
> +SECTION_RODATA
> +
> +pw_128:   times 8 dw 128
> +pw_255:   times 8 dw 255
> +pw_257:   times 8 dw 257
> +pw_65280: times 8 dw 65280
> +
> +SECTION .text
> +
> +INIT_XMM sse4
> +cglobal overlay_row_44, 6, 8, 6, 0, d, da, s, a, w, alinesize, r, x

You're not using the alinesize parameter here. Make this 5, 7, 8 and use
that reg for r. That way this can work on x86_32.

Also, pointless 0 after xmm reg amount. Just remove it.

> +xor  xq, xq
> +movsxdifnidn wq, wd
> +mov  rq, wq
> +and  rq, mmsize/2 - 1
> +cmp  wq, mmsize/2
> +jl .end
> +sub  wq, rq
> +mova m3, [pw_255]
> +mova m4, [pw_128]
> +mova m5, [pw_257]
> +.loop0:
> +pmovzxbwm0, [sq+xq]
> +pmovzxbwm2, [aq+xq]
> +pmovzxbwm1, [dq+xq]
> +pmullw  m0, m2
> +pxorm2, m3
> +pmullw  m1, m2
> +paddw   m0, m4
> +paddw   m0, m1
> +pmulhuw m0, m5
> +packuswbm0, m0
> +movq   [dq+xq], m0
> +add xq, mmsize/2
> +cmp xq, wq
> +jl .loop0
> +
> +.end:
> +moveax, xd
> +RET
> +
> +INIT_XMM sse4
> +cglobal overlay_row_22, 6, 8, 8, 0, d, da, s, a, w, al, r, x

Same here with al.

> +xor  xq, xq
> +movsxdifnidn wq, wd
> +sub  wq, 1
> +mov  rq, wq
> +and  rq, mmsize/2 - 1
> +cmp  wq, mmsize/2
> +jl .end
> +sub  wq, rq
> +mova m3, [pw_255]
> +mova m4, [pw_128]
> +mova m5, [pw_257]
> +mova m7, [pw_65280]
> +.loop0:
> +pmovzxbwm0, [sq+xq]
> +movum2, [aq+2*xq]
> +pandm2, m3
> +movum6, [aq+2*xq]
> +pandm6, m7
> +psrlw   m6, 8
> +paddw   m2, m6
> +psrlw   m2, 1
> +movum6, [aq+2*xq]
> +pandm6, m3
> +paddw   m2, m6
> +psrlw   m2, 1
> +pmovzxbwm1, [dq+xq]
> +pmullw  m0, m2
> +pxorm2, m3
> +pmullw  m1, m2
> +paddw   m0, m4
> +paddw   m0, m1
> +pmulhuw m0, m5
> +packuswbm0, m0
> +movq   [dq+xq], m0
> +add xq, mmsize/2
> +cmp xq, wq
> +jl .loop0
> +
> +.end:
> +moveax, xd
> +RET
> +
> +INIT_XMM sse4
> +cglobal overlay_row_20, 6, 8, 8, 0, d, da, s, a, w, al, r, x
> +xor  xq, xq
> +movsxdifnidn wq, wd
> +sub  wq, 1
> +mov  rq, wq
> +and  rq, mmsize/2 - 1
> +cmp  wq, mmsize/2
> +jl .end
> +sub  wq, rq
> +mov daq, aq
> +add daq, alq

Use al straight from memory here, and use the gpr for r, much like above.

> +

[FFmpeg-devel] [PATCH 23/24] avformat/rtpenc_jpeg: remove usage of YUVJ formats

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/rtpenc_jpeg.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index 38eb2e68eb..e0e7afebfc 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -46,13 +46,11 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t 
*buf, int size)
 h = AV_CEIL_RSHIFT(s1->streams[0]->codecpar->height, 3);
 
 /* get the pixel format type or fail */
-if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ422P ||
-(s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
- s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV422P)) {
+if (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
+ s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV422P) {
 type = 0;
-} else if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ420P ||
-   (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
-s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV420P)) {
+} else if (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
+s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV420P) {
 type = 1;
 } else {
 av_log(s1, AV_LOG_ERROR, "Unsupported pixel format\n");
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 24/24] avfilter: remove YUVJ pixel format usage

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avf_showspectrum.c |  2 +-
 libavfilter/vaf_spectrumsynth.c|  4 +---
 libavfilter/vf_amplify.c   |  3 ---
 libavfilter/vf_atadenoise.c|  3 ---
 libavfilter/vf_avgblur.c   |  4 +---
 libavfilter/vf_bitplanenoise.c |  2 --
 libavfilter/vf_blend.c |  1 -
 libavfilter/vf_bwdif.c |  2 --
 libavfilter/vf_colorspace.c|  1 -
 libavfilter/vf_convolution.c   |  4 +---
 libavfilter/vf_convolve.c  |  4 +---
 libavfilter/vf_cover_rect.c|  3 +--
 libavfilter/vf_cropdetect.c|  6 +++---
 libavfilter/vf_deband.c|  4 +---
 libavfilter/vf_deblock.c   |  4 +---
 libavfilter/vf_deflicker.c |  3 ---
 libavfilter/vf_deshake.c   |  3 +--
 libavfilter/vf_displace.c  |  4 +---
 libavfilter/vf_drawbox.c   |  3 +--
 libavfilter/vf_entropy.c   |  2 --
 libavfilter/vf_extractplanes.c |  6 --
 libavfilter/vf_fade.c  |  3 +--
 libavfilter/vf_fftfilt.c   |  6 +++---
 libavfilter/vf_fieldmatch.c|  3 ---
 libavfilter/vf_fillborders.c   |  4 +---
 libavfilter/vf_find_rect.c |  1 -
 libavfilter/vf_framepack.c |  3 +--
 libavfilter/vf_framerate.c | 10 +-
 libavfilter/vf_fspp.c  |  2 --
 libavfilter/vf_gblur.c |  4 +---
 libavfilter/vf_histogram.c |  8 
 libavfilter/vf_hqdn3d.c|  4 
 libavfilter/vf_hysteresis.c|  4 +---
 libavfilter/vf_idet.c  |  4 
 libavfilter/vf_lenscorrection.c|  4 ++--
 libavfilter/vf_limiter.c   |  4 +---
 libavfilter/vf_lut.c   |  2 --
 libavfilter/vf_lut2.c  |  4 +---
 libavfilter/vf_maskedclamp.c   |  4 +---
 libavfilter/vf_maskedmerge.c   |  4 +---
 libavfilter/vf_mestimate.c |  3 ---
 libavfilter/vf_midequalizer.c  |  4 +---
 libavfilter/vf_minterpolate.c  |  3 ---
 libavfilter/vf_mpdecimate.c|  2 --
 libavfilter/vf_neighbor.c  |  1 -
 libavfilter/vf_nlmeans.c   |  3 ---
 libavfilter/vf_nnedi.c |  3 ---
 libavfilter/vf_ocr.c   |  3 ---
 libavfilter/vf_overlay.c   |  6 +++---
 libavfilter/vf_perspective.c   |  1 -
 libavfilter/vf_phase.c |  1 -
 libavfilter/vf_pp.c| 12 
 libavfilter/vf_pp7.c   |  2 --
 libavfilter/vf_premultiply.c   | 10 +-
 libavfilter/vf_psnr.c  |  2 --
 libavfilter/vf_pullup.c|  4 +---
 libavfilter/vf_readeia608.c|  3 ---
 libavfilter/vf_readvitc.c  |  5 -
 libavfilter/vf_remap.c |  1 -
 libavfilter/vf_removegrain.c   |  2 --
 libavfilter/vf_rotate.c|  4 ++--
 libavfilter/vf_signalstats.c   |  2 --
 libavfilter/vf_signature.c |  3 ---
 libavfilter/vf_spp.c   |  2 --
 libavfilter/vf_ssim.c  |  2 --
 libavfilter/vf_stereo3d.c  |  5 -
 libavfilter/vf_threshold.c |  4 +---
 libavfilter/vf_tinterlace.c| 11 ++-
 libavfilter/vf_unsharp.c   |  4 ++--
 libavfilter/vf_uspp.c  |  2 --
 libavfilter/vf_vaguedenoiser.c |  3 ---
 libavfilter/vf_vectorscope.c   | 10 +-
 libavfilter/vf_w3fdif.c|  3 ---
 libavfilter/vf_waveform.c  | 10 ++
 libavfilter/vf_yadif.c |  4 
 libavfilter/vf_zoompan.c   |  3 ---
 libavfilter/vf_zscale.c|  3 ---
 libavfilter/vsrc_testsrc.c |  2 +-
 tests/ref/fate/filter-pixfmts-lut  |  4 
 tests/ref/fate/filter-pixfmts-pullup   |  5 -
 tests/ref/fate/filter-pixfmts-rotate   |  2 --
 tests/ref/fate/filter-pixfmts-tinterlace_cvlpf |  4 
 tests/ref/fate/filter-pixfmts-tinterlace_merge |  4 
 tests/ref/fate/filter-pixfmts-tinterlace_pad   |  4 
 tests/ref/fate/filter-pixfmts-tinterlace_vlpf  |  4 
 85 files changed, 62 insertions(+), 

[FFmpeg-devel] [PATCH 22/24] avfilter/vf_setrange: change outlink color_range too

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_setparams.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index 8427f98ba8..98a4aa2ad3 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -56,6 +56,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 return ff_filter_frame(ctx->outputs[0], frame);
 }
 
+static int config_output(AVFilterLink *outlink)
+{
+SetParamsContext *s = outlink->src->priv;
+
+if (s->color_range >= 0)
+outlink->color_range = s->color_range;
+
+return 0;
+}
+
 static const AVFilterPad inputs[] = {
 {
 .name = "default",
@@ -69,6 +79,7 @@ static const AVFilterPad outputs[] = {
 {
 .name = "default",
 .type = AVMEDIA_TYPE_VIDEO,
+.config_props = config_output,
 },
 { NULL }
 };
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 21/24] avfilter/vf_blackdetect: use color_range from inlink

2018-05-01 Thread Paul B Mahol
Remove YUVJ pixel format usage.

Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_blackdetect.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c
index 06ef9988d1..ff4b9eebb9 100644
--- a/libavfilter/vf_blackdetect.c
+++ b/libavfilter/vf_blackdetect.c
@@ -61,13 +61,6 @@ static const AVOption blackdetect_options[] = {
 
 AVFILTER_DEFINE_CLASS(blackdetect);
 
-#define YUVJ_FORMATS \
-AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, 
AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
-
-static const enum AVPixelFormat yuvj_formats[] = {
-YUVJ_FORMATS, AV_PIX_FMT_NONE
-};
-
 static int query_formats(AVFilterContext *ctx)
 {
 static const enum AVPixelFormat pix_fmts[] = {
@@ -76,7 +69,6 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P,
 AV_PIX_FMT_NV12, AV_PIX_FMT_NV21,
-YUVJ_FORMATS,
 AV_PIX_FMT_NONE
 };
 
@@ -94,7 +86,7 @@ static int config_input(AVFilterLink *inlink)
 blackdetect->black_min_duration =
 blackdetect->black_min_duration_time / av_q2d(inlink->time_base);
 
-blackdetect->pixel_black_th_i = ff_fmt_is_in(inlink->format, yuvj_formats) 
?
+blackdetect->pixel_black_th_i = inlink->color_range == AVCOL_RANGE_JPEG ?
 // luminance_minimum_value + pixel_black_th * luminance_range_size
  blackdetect->pixel_black_th *  255 :
 16 + blackdetect->pixel_black_th * (235 - 16);
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 19/24] avcodec/roqvideoenc: do not use YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/roqvideoenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index ac05123dc6..18ceef1b2c 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -1132,7 +1132,8 @@ AVCodec ff_roq_encoder = {
 .init = roq_encode_init,
 .encode2  = roq_encode_frame,
 .close= roq_encode_end,
-.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ444P,
+.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P,
 AV_PIX_FMT_NONE },
+.color_ranges = (const enum AVColorRange[]){ AVCOL_RANGE_JPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 20/24] avcodec/hevcdec: remove usage of YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/hevcdec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index c8877626d2..13c7d8ef49 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -369,7 +369,6 @@ static enum AVPixelFormat get_format(HEVCContext *s, const 
HEVCSPS *sps)
 
 switch (sps->pix_fmt) {
 case AV_PIX_FMT_YUV420P:
-case AV_PIX_FMT_YUVJ420P:
 #if CONFIG_HEVC_DXVA2_HWACCEL
 *fmt++ = AV_PIX_FMT_DXVA2_VLD;
 #endif
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 18/24] avcodec/hevc_ps: do not use YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Color range is already set.

Signed-off-by: Paul B Mahol 
---
 libavcodec/hevc_ps.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index f877fa572c..775dd73510 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -578,8 +578,6 @@ static void decode_vui(GetBitContext *gb, AVCodecContext 
*avctx,
 vui->video_format= get_bits(gb, 3);
 vui->video_full_range_flag   = get_bits1(gb);
 vui->colour_description_present_flag = get_bits1(gb);
-if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P)
-sps->pix_fmt = AV_PIX_FMT_YUVJ420P;
 if (vui->colour_description_present_flag) {
 vui->colour_primaries= get_bits(gb, 8);
 vui->transfer_characteristic = get_bits(gb, 8);
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 16/24] avcodec/mdec: replace YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/mdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 330b761279..637158d231 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -227,7 +227,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ff_init_scantable(a->idsp.idct_permutation, >scantable,
   ff_zigzag_direct);
 
-avctx->pix_fmt  = AV_PIX_FMT_YUVJ420P;
+avctx->pix_fmt  = AV_PIX_FMT_YUV420P;
 avctx->color_range = AVCOL_RANGE_JPEG;
 
 /* init q matrix */
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 17/24] avcodec/h264_slice: do not use YUVJ pixel formats

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/h264_slice.c | 22 ++
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index d71ddbe9ba..65e2bae52a 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -820,15 +820,10 @@ static enum AVPixelFormat get_pixel_format(H264Context 
*h, int force_callback)
 if (CHROMA444(h)) {
 if (h->avctx->colorspace == AVCOL_SPC_RGB)
 *fmt++ = AV_PIX_FMT_GBRP;
-else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
-*fmt++ = AV_PIX_FMT_YUVJ444P;
 else
 *fmt++ = AV_PIX_FMT_YUV444P;
 } else if (CHROMA422(h)) {
-if (h->avctx->color_range == AVCOL_RANGE_JPEG)
-*fmt++ = AV_PIX_FMT_YUVJ422P;
-else
-*fmt++ = AV_PIX_FMT_YUV422P;
+*fmt++ = AV_PIX_FMT_YUV422P;
 } else {
 #if CONFIG_H264_DXVA2_HWACCEL
 *fmt++ = AV_PIX_FMT_DXVA2_VLD;
@@ -845,8 +840,6 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, 
int force_callback)
 #endif
 if (h->avctx->codec->pix_fmts)
 choices = h->avctx->codec->pix_fmts;
-else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
-*fmt++ = AV_PIX_FMT_YUVJ420P;
 else
 *fmt++ = AV_PIX_FMT_YUV420P;
 }
@@ -992,17 +985,6 @@ fail:
 return ret;
 }
 
-static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
-{
-switch (a) {
-case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
-case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
-case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
-default:
-return a;
-}
-}
-
 static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int 
first_slice)
 {
 const SPS *sps;
@@ -1047,7 +1029,7 @@ static int h264_init_ps(H264Context *h, const 
H264SliceContext *sl, int first_sl
  || h->mb_height != sps->mb_height
 ));
 if (h->avctx->pix_fmt == AV_PIX_FMT_NONE
-|| (non_j_pixfmt(h->avctx->pix_fmt) != 
non_j_pixfmt(get_pixel_format(h, 0
+|| (h->avctx->pix_fmt != get_pixel_format(h, 0)))
 must_reinit = 1;
 
 if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio))
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 14/24] avcodec/fraps: replace YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/fraps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index 7a7673f73f..b2025b5d3f 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -218,7 +218,7 @@ static int decode_frame(AVCodecContext *avctx,
 f->pict_type = AV_PICTURE_TYPE_I;
 f->key_frame = 1;
 
-avctx->pix_fmt = version & 1 ? is_pal ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_BGR24 
: AV_PIX_FMT_YUVJ420P;
+avctx->pix_fmt = version & 1 ? is_pal ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_BGR24 
: AV_PIX_FMT_YUV420P;
 avctx->color_range = version & 1 ? AVCOL_RANGE_UNSPECIFIED
  : AVCOL_RANGE_JPEG;
 avctx->colorspace = version & 1 ? AVCOL_SPC_UNSPECIFIED : AVCOL_SPC_BT709;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 15/24] avcodec/roqvideodec: replace YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/roqvideodec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
index 0ab7d399d6..c5b7bbe236 100644
--- a/libavcodec/roqvideodec.c
+++ b/libavcodec/roqvideodec.c
@@ -190,7 +190,7 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 }
 
-avctx->pix_fmt = AV_PIX_FMT_YUVJ444P;
+avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 avctx->color_range = AVCOL_RANGE_JPEG;
 
 return 0;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 11/24] avcodec/mjpegdec: replace YUVJ pixel formats

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/mjpegdec.c| 18 +-
 libavcodec/tdsc.c|  2 +-
 tests/fate/vcodec.mak|  4 ++--
 tests/ref/fate/api-mjpeg-codec-param |  4 ++--
 tests/ref/fate/exif-image-embedded   |  2 +-
 tests/ref/fate/exif-image-jpg|  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 22ca69f841..656cf44bbb 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -479,7 +479,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && 
s->component_id[2] == 'A') {
 s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : 
AV_PIX_FMT_GBRP16;
 } else {
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 else  s->avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
 }
@@ -521,7 +521,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 case 0x22122100:
 case 0x21211100:
 case 0x22211200:
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 else
 goto unk_pixfmt;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
@@ -529,7 +529,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 case 0x1100:
 case 0x22112200:
 case 0x1100:
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 else
 goto unk_pixfmt;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
@@ -561,7 +561,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 } else {
 if (pix_fmt_id == 0x1400)
 s->upscale_v[1] = s->upscale_v[2] = 1;
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV440P;
 else
 goto unk_pixfmt;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
@@ -574,7 +574,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 goto unk_pixfmt;
 s->upscale_h[0] = s->upscale_h[1] = 1;
 } else {
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 else  s->avctx->pix_fmt = AV_PIX_FMT_YUV422P16;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
 }
@@ -582,13 +582,13 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 case 0x3100:
 if (s->bits > 8)
 goto unk_pixfmt;
-s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : 
AV_PIX_FMT_YUVJ444P;
+s->avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
 s->upscale_h[1] = s->upscale_h[2] = 2;
 break;
 case 0x22121100:
 case 0x22111200:
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 else
 goto unk_pixfmt;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
@@ -596,7 +596,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 case 0x2200:
 case 0x4200:
 case 0x2400:
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 else  s->avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
 if (pix_fmt_id == 0x4200) {
@@ -610,7 +610,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 break;
 case 0x4100:
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV411P : AV_PIX_FMT_YUVJ411P;
+if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUV411P;
 else
 goto unk_pixfmt;
 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 4182404cf0..af92ef6ccc 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -357,7 +357,7 @@ static int 

[FFmpeg-devel] [PATCH 05/24] avfilter/vf_scale: make use of color_range from filter links

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_scale.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f741419e7e..c7f2b07f0b 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -302,9 +302,15 @@ static int config_props(AVFilterLink *outlink)
 if (scale->in_range != AVCOL_RANGE_UNSPECIFIED)
 av_opt_set_int(*s, "src_range",
scale->in_range == AVCOL_RANGE_JPEG, 0);
+else
+av_opt_set_int(*s, "src_range",
+   inlink->color_range == AVCOL_RANGE_JPEG, 0);
 if (scale->out_range != AVCOL_RANGE_UNSPECIFIED)
 av_opt_set_int(*s, "dst_range",
scale->out_range == AVCOL_RANGE_JPEG, 0);
+   else
+av_opt_set_int(*s, "dst_range",
+   outlink->color_range == AVCOL_RANGE_JPEG, 0);
 
 if (scale->opts) {
 AVDictionaryEntry *e = NULL;
@@ -415,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 if(   in->width  != link->w
|| in->height != link->h
|| in->format != link->format
+   || in->color_range != link->color_range
|| in->sample_aspect_ratio.den != link->sample_aspect_ratio.den || 
in->sample_aspect_ratio.num != link->sample_aspect_ratio.num) {
 int ret;
 
@@ -428,6 +435,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 link->dst->inputs[0]->format = in->format;
 link->dst->inputs[0]->w  = in->width;
 link->dst->inputs[0]->h  = in->height;
+link->dst->inputs[0]->color_range = in->color_range;
 
 link->dst->inputs[0]->sample_aspect_ratio.den = 
in->sample_aspect_ratio.den;
 link->dst->inputs[0]->sample_aspect_ratio.num = 
in->sample_aspect_ratio.num;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 13/24] avcodec/svq3: replace YUVJ pixel format

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/svq3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index fc17081ecf..afd246f8b8 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1158,7 +1158,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
 ff_hpeldsp_init(>hdsp, avctx->flags);
 ff_tpeldsp_init(>tdsp);
 
-avctx->pix_fmt = AV_PIX_FMT_YUVJ420P;
+avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 avctx->color_range = AVCOL_RANGE_JPEG;
 
 s->avctx = avctx;
@@ -1652,6 +1652,6 @@ AVCodec ff_svq3_decoder = {
 .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND |
   AV_CODEC_CAP_DR1 |
   AV_CODEC_CAP_DELAY,
-.pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
+.pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE},
 };
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 12/24] avcodec/mjpegenc: add support for non-YUVJ formats

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/mjpegenc.c  | 5 -
 libavcodec/mpegvideo_enc.c | 3 +--
 tests/lavf-regression.sh   | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index d2fcb8e191..c31985efd3 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -415,8 +415,10 @@ AVCodec ff_mjpeg_encoder = {
 .close  = ff_mpv_encode_end,
 .capabilities   = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS 
| AV_CODEC_CAP_INTRA_ONLY,
 .pix_fmts   = (const enum AVPixelFormat[]) {
+AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P,
 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, 
AV_PIX_FMT_NONE
 },
+.color_ranges   = (const enum AVColorRange[]){AVCOL_RANGE_JPEG, 
AVCOL_RANGE_MPEG, AVCOL_RANGE_UNSPECIFIED},
 .priv_class = _class,
 };
 #endif
@@ -439,8 +441,9 @@ AVCodec ff_amv_encoder = {
 .encode2= amv_encode_picture,
 .close  = ff_mpv_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]) {
-AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE
+AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE
 },
+.color_ranges   = (const enum AVColorRange[]){AVCOL_RANGE_JPEG, 
AVCOL_RANGE_UNSPECIFIED},
 .priv_class = _class,
 };
 #endif
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2e7950c64d..76aa675685 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -315,8 +315,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
   avctx->pix_fmt == AV_PIX_FMT_YUV444P)))
 format_supported = 1;
 /* MPEG color space */
-else if (avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL &&
- (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+else if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
   avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
   avctx->pix_fmt == AV_PIX_FMT_YUV444P))
 format_supported = 1;
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 45c877e4ac..b03d5ac2e7 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -376,7 +376,7 @@ do_audio_only rso
 fi
 
 if [ -n "$do_smjpeg" ] ; then
-do_lavf smjpeg "" "-f smjpeg"
+do_lavf smjpeg "" "-vf format=yuv420p:pc -f smjpeg"
 fi
 
 if [ -n "$do_sox" ] ; then
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 10/24] avcodec/mpeg4videoenc: mark as limited color range only

2018-05-01 Thread Paul B Mahol
lavf-mkv changes only because of metadata.

Signed-off-by: Paul B Mahol 
---
 libavcodec/mpeg4videoenc.c |  1 +
 libavcodec/mpegvideo_enc.c |  4 
 tests/ref/lavf/mkv |  8 
 tests/ref/seek/lavf-mkv| 44 ++--
 4 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 494452c938..80279bb3a2 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1396,6 +1396,7 @@ AVCodec ff_mpeg4_encoder = {
 .encode2= ff_mpv_encode_picture,
 .close  = ff_mpv_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
+.color_ranges   = (const enum AVColorRange[]) { AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
 .priv_class = _class,
 };
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 979e138b88..2e7950c64d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -4864,6 +4864,7 @@ AVCodec ff_h263p_encoder = {
 .close  = ff_mpv_encode_end,
 .capabilities   = AV_CODEC_CAP_SLICE_THREADS,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
+.color_ranges   = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
 
@@ -4884,6 +4885,7 @@ AVCodec ff_msmpeg4v2_encoder = {
 .encode2= ff_mpv_encode_picture,
 .close  = ff_mpv_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
+.color_ranges   = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
 
@@ -4904,6 +4906,7 @@ AVCodec ff_msmpeg4v3_encoder = {
 .encode2= ff_mpv_encode_picture,
 .close  = ff_mpv_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
+.color_ranges   = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
 
@@ -4924,5 +4927,6 @@ AVCodec ff_wmv1_encoder = {
 .encode2= ff_mpv_encode_picture,
 .close  = ff_mpv_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
+.color_ranges   = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv
index 0083033958..bd0302b14f 100644
--- a/tests/ref/lavf/mkv
+++ b/tests/ref/lavf/mkv
@@ -1,6 +1,6 @@
-7c8697c324e8ad79c5ea14364a6c39b8 *./tests/data/lavf/lavf.mkv
-472759 ./tests/data/lavf/lavf.mkv
+80092ba5b6833704dd04bd9f7f75366d *./tests/data/lavf/lavf.mkv
+472766 ./tests/data/lavf/lavf.mkv
 ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68
-9767a3b526d7e56d7400164cb888990c *./tests/data/lavf/lavf.mkv
-320603 ./tests/data/lavf/lavf.mkv
+b919b159a2dd7c9c7cd45cc36f204754 *./tests/data/lavf/lavf.mkv
+320610 ./tests/data/lavf/lavf.mkv
 ./tests/data/lavf/lavf.mkv CRC=0xec6c3c68
diff --git a/tests/ref/seek/lavf-mkv b/tests/ref/seek/lavf-mkv
index cea34e99ac..368e86cd14 100644
--- a/tests/ref/seek/lavf-mkv
+++ b/tests/ref/seek/lavf-mkv
@@ -1,48 +1,48 @@
-ret: 0 st: 1 flags:1 dts: 0.00 pts: 0.00 pos:834 size:   
208
+ret: 0 st: 1 flags:1 dts: 0.00 pts: 0.00 pos:841 size:   
208
 ret: 0 st:-1 flags:0  ts:-1.00
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos:   1050 size: 
27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos:   1057 size: 
27837
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 
27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292483 size: 
27834
 ret: 0 st: 0 flags:0  ts: 0.788000
-ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292476 size: 
27834
+ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292483 size: 
27834
 ret: 0 st: 0 flags:1  ts:-0.317000
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos:   1050 size: 
27837
+ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos:   1057 size: 
27837
 ret:-1 st: 1 flags:0  ts: 2.577000
 ret: 0 st: 1 flags:1  ts: 1.471000
-ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320317 size:   
209
+ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320324 size:   
209
 ret: 0 st:-1 flags:0  ts: 0.365002
-ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147023 size: 
27925
+ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 147030 size: 
27925
 ret: 0 st:-1 flags:1  ts:-0.740831
-ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos:   1050 size: 

[FFmpeg-devel] [PATCH 09/24] avcodec/proresenc: prores supports limited color range only

2018-05-01 Thread Paul B Mahol
Add .color_range field to encoder's AVCodec struct.

Signed-off-by: Paul B Mahol 
---
 libavcodec/proresenc_anatoliy.c | 2 ++
 libavcodec/proresenc_kostya.c   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 0516066163..cb86d2df44 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -611,6 +611,7 @@ AVCodec ff_prores_aw_encoder = {
 .close  = prores_encode_close,
 .encode2= prores_encode_frame,
 .pix_fmts   = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, 
AV_PIX_FMT_NONE},
+.color_ranges   = (const enum AVColorRange[]){AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED},
 .capabilities   = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
 .profiles   = profiles
 };
@@ -625,6 +626,7 @@ AVCodec ff_prores_encoder = {
 .close  = prores_encode_close,
 .encode2= prores_encode_frame,
 .pix_fmts   = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV422P10, 
AV_PIX_FMT_NONE},
+.color_ranges   = (const enum AVColorRange[]){AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED},
 .capabilities   = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
 .profiles   = profiles
 };
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 81f3865ea6..371be3ea63 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1430,5 +1430,6 @@ AVCodec ff_prores_ks_encoder = {
   AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10,
   AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE
   },
+.color_ranges   = (const enum AVColorRange[]){ AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED },
 .priv_class = _class,
 };
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 03/24] avfilter/buffersrc: recognize color_range as additonal parameter and set it to input link

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/buffersrc.c | 18 ++
 libavfilter/buffersrc.h |  5 +
 2 files changed, 23 insertions(+)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index cd56f8ca45..51a1a9fb49 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -52,6 +52,7 @@ typedef struct BufferSourceContext {
 int   w, h;
 enum AVPixelFormat  pix_fmt;
 AVRationalpixel_aspect;
+int   color_range;
 char  *sws_param;
 
 AVBufferRef *hw_frames_ctx;
@@ -109,6 +110,8 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, 
AVBufferSrcParameters *par
 s->h = param->height;
 if (param->sample_aspect_ratio.num > 0 && 
param->sample_aspect_ratio.den > 0)
 s->pixel_aspect = param->sample_aspect_ratio;
+if (param->color_range > AVCOL_RANGE_UNSPECIFIED)
+s->color_range = param->color_range;
 if (param->frame_rate.num > 0 && param->frame_rate.den > 0)
 s->frame_rate = param->frame_rate;
 if (param->hw_frames_ctx) {
@@ -279,6 +282,11 @@ static av_cold int init_video(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
+if (!av_color_range_name(c->color_range)) {
+av_log(ctx, AV_LOG_ERROR, "Invalid color_range parameter provided.\n");
+return AVERROR(EINVAL);
+}
+
 if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*
 return AVERROR(ENOMEM);
 
@@ -309,6 +317,15 @@ static const AVOption buffer_options[] = {
 { "time_base", NULL, OFFSET(time_base),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "frame_rate",NULL, OFFSET(frame_rate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 { "sws_param", NULL, OFFSET(sws_param),
AV_OPT_TYPE_STRING,.flags = V },
+{ "color_range",   NULL, OFFSET(color_range),  
AV_OPT_TYPE_INT,  { .i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX, V, 
"range" },
+{ "unspecified",   NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_UNSPECIFIED},  0, 0, V, "range"},
+{ "unknown",   NULL,   0, AV_OPT_TYPE_CONST, 
{.i64=AVCOL_RANGE_UNSPECIFIED},  0, 0, V, "range"},
+{ "limited",   NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG},  
   0, 0, V, "range"},
+{ "tv",NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG},  
   0, 0, V, "range"},
+{ "mpeg",  NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG},  
   0, 0, V, "range"},
+{ "full",  NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG},  
   0, 0, V, "range"},
+{ "pc",NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG},  
   0, 0, V, "range"},
+{ "jpeg",  NULL,   0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG},  
   0, 0, V, "range"},
 { NULL },
 };
 
@@ -434,6 +451,7 @@ static int config_props(AVFilterLink *link)
 link->w = c->w;
 link->h = c->h;
 link->sample_aspect_ratio = c->pixel_aspect;
+link->color_range = c->color_range;
 
 if (c->hw_frames_ctx) {
 link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx);
diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
index 0652113f2b..7129db6bd9 100644
--- a/libavfilter/buffersrc.h
+++ b/libavfilter/buffersrc.h
@@ -114,6 +114,11 @@ typedef struct AVBufferSrcParameters {
  * Audio only, the audio channel layout
  */
 uint64_t channel_layout;
+
+   /**
+ * Video only
+ */
+enum AVColorRange color_range;
 } AVBufferSrcParameters;
 
 /**
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 01/24] avcodec: add color_range to AVCodec struct

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/avcodec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fb0c6fae70..3a8f69243c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3433,6 +3433,7 @@ typedef struct AVCodec {
 uint8_t max_lowres; ///< maximum value for lowres 
supported by the decoder
 const AVClass *priv_class;  ///< AVClass for the private 
context
 const AVProfile *profiles;  ///< array of recognized profiles, 
or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+const enum AVColorRange *color_ranges;  ///< array of supported color 
ranges by encoder, or NULL if unknown, array is terminated by 
AVCOL_RANGE_UNSPECIFIED
 
 /**
  * Group name of the codec implementation.
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 08/24] fftools/ffplay: support only limited color range

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 fftools/ffplay.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index dcca9c26d8..86bda1a2c4 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -1822,6 +1822,7 @@ fail:
 static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const 
char *vfilters, AVFrame *frame)
 {
 enum AVPixelFormat pix_fmts[FF_ARRAY_ELEMS(sdl_texture_format_map)];
+enum AVColorRange color_ranges[2] = { AVCOL_RANGE_MPEG, 
AVCOL_RANGE_UNSPECIFIED };
 char sws_flags_str[512] = "";
 char buffersrc_args[256];
 int ret;
@@ -1876,7 +1877,10 @@ static int configure_video_filters(AVFilterGraph *graph, 
VideoState *is, const c
 if ((ret = av_opt_set_int_list(filt_out, "pix_fmts", pix_fmts,  
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN)) < 0)
 goto fail;
 
-last_filter = filt_out;
+if ((ret = av_opt_set_int_list(filt_out, "color_ranges", color_ranges, 
AVCOL_RANGE_UNSPECIFIED, AV_OPT_SEARCH_CHILDREN)) < 0)
+goto fail;
+
+ last_filter = filt_out;
 
 /* Note: this macro adds a filter before the lastly added filter, so the
  * processing order of the filters is in reverse */
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 02/24] avfilter/avfilter: add color_range to AVFilterLink struct

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avfilter.c | 2 ++
 libavfilter/avfilter.h | 2 ++
 libavfilter/video.c| 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index ed8161136c..3f0dc14d01 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -338,6 +338,8 @@ int avfilter_config_links(AVFilterContext *filter)
 link->w = inlink->w;
 if (!link->h)
 link->h = inlink->h;
+if (!link->color_range)
+link->color_range = inlink->color_range;
 } else if (!link->w || !link->h) {
 av_log(link->src, AV_LOG_ERROR,
"Video source filters must set their output link's "
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 9d70e7118b..11cd586bae 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -600,6 +600,8 @@ struct AVFilterLink {
  */
 AVBufferRef *hw_frames_ctx;
 
+enum AVColorRange color_range;///< color range type, video only
+
 #ifndef FF_INTERNAL_FIELDS
 
 /**
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7a8e587798..64d8c3b3aa 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -90,8 +90,8 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h)
 frame = ff_frame_pool_get(link->frame_pool);
 if (!frame)
 return NULL;
-
 frame->sample_aspect_ratio = link->sample_aspect_ratio;
+frame->color_range = link->color_range;
 
 return frame;
 }
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 06/24] avcodec/pngdec: set full color range only for gray formats

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/pngdec.c| 8 ++--
 tests/ref/fate/api-png-codec-param | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index f93f200bb1..dbf986de50 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -641,9 +641,11 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 } else if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 
8) &&
 s->color_type == PNG_COLOR_TYPE_GRAY) {
 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+avctx->color_range = AVCOL_RANGE_JPEG;
 } else if (s->bit_depth == 16 &&
 s->color_type == PNG_COLOR_TYPE_GRAY) {
 avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
+avctx->color_range = AVCOL_RANGE_JPEG;
 } else if (s->bit_depth == 16 &&
 s->color_type == PNG_COLOR_TYPE_RGB) {
 avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
@@ -658,9 +660,11 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 } else if (s->bit_depth == 8 &&
 s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
 avctx->pix_fmt = AV_PIX_FMT_YA8;
+avctx->color_range = AVCOL_RANGE_JPEG;
 } else if (s->bit_depth == 16 &&
 s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
 avctx->pix_fmt = AV_PIX_FMT_YA16BE;
+avctx->color_range = AVCOL_RANGE_JPEG;
 } else {
 avpriv_report_missing_feature(avctx,
   "Bit depth %d color type %d",
@@ -680,10 +684,12 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 
 case AV_PIX_FMT_GRAY8:
 avctx->pix_fmt = AV_PIX_FMT_YA8;
+avctx->color_range = AVCOL_RANGE_JPEG;
 break;
 
 case AV_PIX_FMT_GRAY16BE:
 avctx->pix_fmt = AV_PIX_FMT_YA16BE;
+avctx->color_range = AVCOL_RANGE_JPEG;
 break;
 
 default:
@@ -1575,8 +1581,6 @@ static av_cold int png_dec_init(AVCodecContext *avctx)
 {
 PNGDecContext *s = avctx->priv_data;
 
-avctx->color_range = AVCOL_RANGE_JPEG;
-
 s->avctx = avctx;
 s->previous_picture.f = av_frame_alloc();
 s->last_picture.f = av_frame_alloc();
diff --git a/tests/ref/fate/api-png-codec-param 
b/tests/ref/fate/api-png-codec-param
index f04ffa757d..a8c991270f 100644
--- a/tests/ref/fate/api-png-codec-param
+++ b/tests/ref/fate/api-png-codec-param
@@ -115,7 +115,7 @@ stream=0, decode=0
 color_primaries=2
 color_trc=2
 colorspace=2
-color_range=2
+color_range=0
 chroma_sample_location=0
 log_level_offset=0
 slices=0
@@ -255,7 +255,7 @@ stream=0, decode=1
 color_primaries=2
 color_trc=2
 colorspace=2
-color_range=2
+color_range=0
 chroma_sample_location=0
 log_level_offset=0
 slices=0
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 07/24] avfilter: negotiate color_range between filters

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 fftools/ffmpeg.c   |  2 ++
 fftools/ffmpeg.h   |  1 +
 fftools/ffmpeg_filter.c| 57 +---
 fftools/ffmpeg_opt.c   |  2 ++
 libavcodec/utils.c | 11 +++
 libavfilter/avf_abitscope.c|  4 +++
 libavfilter/avf_ahistogram.c   |  4 +++
 libavfilter/avf_aphasemeter.c  |  4 +++
 libavfilter/avf_avectorscope.c |  4 +++
 libavfilter/avf_concat.c   | 12 ++-
 libavfilter/avf_showcqt.c  |  4 +++
 libavfilter/avf_showfreqs.c|  4 +++
 libavfilter/avf_showspectrum.c |  4 +++
 libavfilter/avf_showvolume.c   |  4 +++
 libavfilter/avf_showwaves.c|  4 +++
 libavfilter/avfilter.c |  9 +++--
 libavfilter/avfilter.h |  4 ++-
 libavfilter/avfiltergraph.c| 53 +
 libavfilter/buffersink.c   | 16 +
 libavfilter/buffersink.h   |  1 +
 libavfilter/buffersrc.c|  4 +++
 libavfilter/f_drawgraph.c  |  4 +++
 libavfilter/formats.c  | 75 +++---
 libavfilter/formats.h  | 31 +
 libavfilter/internal.h | 11 +++
 libavfilter/vf_format.c| 46 +-
 libavfilter/vf_noise.c |  6 +++-
 libavfilter/vf_scale.c | 17 --
 libavfilter/vsrc_testsrc.c | 15 +++--
 tests/fate/filter-video.mak|  2 +-
 tests/fate/pixlet.mak  |  2 +-
 31 files changed, 394 insertions(+), 23 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5dc198f933..5a7d504904 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3378,6 +3378,8 @@ static int init_output_stream_encode(OutputStream *ost)
 enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
  
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
+enc_ctx->color_range = 
av_buffersink_get_color_range(ost->filter->filter);
+
 enc_ctx->framerate = ost->frame_rate;
 
 ost->st->avg_frame_rate = ost->frame_rate;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d44b7a5c72..9b09fa73bb 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -268,6 +268,7 @@ typedef struct OutputFilter {
 
 /* desired output stream properties */
 int width, height;
+enum AVColorRange color_range;
 AVRational frame_rate;
 int format;
 int sample_rate;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 068f499e0b..a6fe813f02 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -90,6 +90,28 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, 
AVCodecContext *enc_ctx, AVCod
 return target;
 }
 
+static enum AVColorRange choose_color_range(AVStream *st, AVCodecContext 
*enc_ctx, AVCodec *codec, enum AVColorRange target)
+{
+if (codec && codec->color_ranges) {
+const enum AVColorRange *p = codec->color_ranges;
+
+for (; *p != AVCOL_RANGE_UNSPECIFIED; p++) {
+if (*p == target)
+break;
+}
+if (*p == AVCOL_RANGE_UNSPECIFIED) {
+if (target != AVCOL_RANGE_UNSPECIFIED)
+av_log(NULL, AV_LOG_WARNING,
+   "Incompatible color range '%s' for codec '%s', 
auto-selecting color range '%s'\n",
+   av_color_range_name(target),
+   codec->name,
+   av_color_range_name(codec->color_ranges[0]));
+return codec->color_ranges[0];
+}
+}
+return target;
+}
+
 void choose_sample_fmt(AVStream *st, AVCodec *codec)
 {
 if (codec && codec->sample_fmts) {
@@ -128,7 +150,19 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
 return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
 }
 if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
-return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, 
ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
+AVIOContext *s = NULL;
+uint8_t *ret;
+int len;
+
+if (avio_open_dyn_buf() < 0)
+exit_program(1);
+
+avio_printf(s, "%s:%s", av_get_pix_fmt_name(choose_pixel_fmt(ost->st, 
ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)),
+
av_color_range_name(choose_color_range(ost->st, ost->enc_ctx, ost->enc, 
ost->enc_ctx->color_range)));
+
+len = avio_close_dyn_buf(s, );
+ret[len] = 0;
+return ret;
 } else if (ost->enc && ost->enc->pix_fmts) {
 const enum AVPixelFormat *p;
 AVIOContext *s = NULL;
@@ -145,7 +179,20 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
 
 for (; *p != AV_PIX_FMT_NONE; p++) {
 const char *name = av_get_pix_fmt_name(*p);
-avio_printf(s, "%s|", name);
+avio_printf(s, "%s", name);
+if (*(p + 1) != AV_PIX_FMT_NONE)
+avio_printf(s, "|");
+   

[FFmpeg-devel] [PATCH 04/24] avfilter/buffersink: export color_range from filtergraph output

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/buffersink.c | 1 +
 libavfilter/buffersink.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 0f87b5439a..897396cac4 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -194,6 +194,7 @@ MAKE_AVFILTERLINK_ACCESSOR(AVRational   , frame_rate
 )
 MAKE_AVFILTERLINK_ACCESSOR(int  , w  )
 MAKE_AVFILTERLINK_ACCESSOR(int  , h  )
 MAKE_AVFILTERLINK_ACCESSOR(AVRational   , sample_aspect_ratio)
+MAKE_AVFILTERLINK_ACCESSOR(enum AVColorRange, color_range)
 
 MAKE_AVFILTERLINK_ACCESSOR(int  , channels   )
 MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout )
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 21d6bb505b..e6d6504832 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -114,6 +114,7 @@ AVRational   av_buffersink_get_frame_rate  
(const AVFilterContext *c
 int  av_buffersink_get_w   (const AVFilterContext 
*ctx);
 int  av_buffersink_get_h   (const AVFilterContext 
*ctx);
 AVRational   av_buffersink_get_sample_aspect_ratio (const AVFilterContext 
*ctx);
+enum AVColorRange av_buffersink_get_color_range(const AVFilterContext 
*ctx);
 
 int  av_buffersink_get_channels(const AVFilterContext 
*ctx);
 uint64_t av_buffersink_get_channel_layout  (const AVFilterContext 
*ctx);
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] mpegvideo: remove support for libxvid's RC system

2018-05-01 Thread Rostislav Pehlivanov
Its a reminder of a bygone era. Less flexible than the internal RC
system, probably worse and most definitely broken. Drop it. No one
ever used it either, except for mislead people.
---
 MAINTAINERS|   1 -
 libavcodec/Makefile|   2 +-
 libavcodec/libxvid_rc.c| 164 -
 libavcodec/mpegvideo.h |  14 +---
 libavcodec/mpegvideo_enc.c |  24 +-
 5 files changed, 6 insertions(+), 199 deletions(-)
 delete mode 100644 libavcodec/libxvid_rc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b61856243c..ca3f4e5a2f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -121,7 +121,6 @@ Generic Parts:
 motion* Michael Niedermayer
   rate control:
 ratecontrol.c   Michael Niedermayer
-libxvid_rc.cMichael Niedermayer
   simple IDCT:
 simple_idct.c, simple_idct.hMichael Niedermayer
   postprocessing:
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d727b218dc..4b55875964 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -984,7 +984,7 @@ OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
-OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o libxvid_rc.o
+OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
 OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
 
 # parsers
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
deleted file mode 100644
index 076c32c413..00
--- a/libavcodec/libxvid_rc.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Xvid rate control wrapper for lavc video encoders
- *
- * Copyright (c) 2006 Michael Niedermayer 
- *
- * 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 "config.h"
-
-#if HAVE_IO_H
-#include 
-#endif
-
-#if HAVE_UNISTD_H
-#include 
-#endif
-
-#include 
-
-#include "libavutil/attributes.h"
-#include "libavutil/internal.h"
-
-#include "avcodec.h"
-#include "libxvid.h"
-#include "mpegvideo.h"
-
-av_cold int ff_xvid_rate_control_init(MpegEncContext *s)
-{
-char *tmp_name;
-int fd, i;
-xvid_plg_create_t xvid_plg_create = { 0 };
-xvid_plugin_2pass2_t xvid_2pass2  = { 0 };
-
-fd = avpriv_tempfile("xvidrc.", _name, 0, s->avctx);
-if (fd < 0) {
-av_log(s, AV_LOG_ERROR, "Can't create temporary pass2 file.\n");
-return fd;
-}
-
-for (i = 0; i < s->rc_context.num_entries; i++) {
-static const char frame_types[] = " ipbs";
-char tmp[256];
-RateControlEntry *rce;
-
-rce = >rc_context.entry[i];
-
-snprintf(tmp, sizeof(tmp), "%c %d %d %d %d %d %d\n",
- frame_types[rce->pict_type],
- (int) lrintf(rce->qscale / FF_QP2LAMBDA),
- rce->i_count, s->mb_num - rce->i_count - rce->skip_count,
- rce->skip_count,
- (rce->i_tex_bits + rce->p_tex_bits + rce->misc_bits + 7) / 8,
- (rce->header_bits + rce->mv_bits + 7) / 8);
-
-if (write(fd, tmp, strlen(tmp)) < 0) {
-int ret = AVERROR(errno);
-av_log(s, AV_LOG_ERROR, "Error %s writing 2pass logfile\n", 
av_err2str(ret));
-av_free(tmp_name);
-close(fd);
-return ret;
-}
-}
-
-close(fd);
-
-xvid_2pass2.version = XVID_MAKE_VERSION(1, 1, 0);
-xvid_2pass2.filename= tmp_name;
-xvid_2pass2.bitrate = s->avctx->bit_rate;
-xvid_2pass2.vbv_size= s->avctx->rc_buffer_size;
-xvid_2pass2.vbv_maxrate = s->avctx->rc_max_rate;
-xvid_2pass2.vbv_initial = s->avctx->rc_initial_buffer_occupancy;
-
-xvid_plg_create.version = XVID_MAKE_VERSION(1, 1, 0);
-xvid_plg_create.fbase   = s->avctx->time_base.den;
-xvid_plg_create.fincr   = s->avctx->time_base.num;
-xvid_plg_create.param   = _2pass2;
-
-if (xvid_plugin_2pass2(NULL, XVID_PLG_CREATE, _plg_create,
-   >rc_context.non_lavc_opaque) < 0) {
-av_log(s, AV_LOG_ERROR, "xvid_plugin_2pass2 failed\n");
-return -1;
-}
-return 0;
-}
-
-float 

Re: [FFmpeg-devel] [PATCH 6/6] lavc/cbs: Add tests for VP9

2018-05-01 Thread James Almer
On 4/30/2018 8:26 PM, Mark Thompson wrote:
> Uses the same mechanism as other codecs - conformance test files are
> passed through the metadata filter (which, with no options, reads the
> input and writes it back) and the output verified to match the input.
> ---
>  tests/fate/cbs.mak | 34 
> ++
>  tests/ref/fate/cbs-vp9-vp90-2-03-deltaq|  1 +
>  tests/ref/fate/cbs-vp9-vp90-2-05-resize|  1 +
>  tests/ref/fate/cbs-vp9-vp90-2-06-bilinear  |  1 +
>  tests/ref/fate/cbs-vp9-vp90-2-09-lf_deltas |  1 +
>  .../ref/fate/cbs-vp9-vp90-2-10-show-existing-frame |  1 +
>  .../fate/cbs-vp9-vp90-2-10-show-existing-frame2|  1 +
>  .../ref/fate/cbs-vp9-vp90-2-segmentation-aq-akiyo  |  1 +
>  .../ref/fate/cbs-vp9-vp90-2-segmentation-sf-akiyo  |  1 +
>  tests/ref/fate/cbs-vp9-vp90-2-tiling-pedestrian|  1 +
>  tests/ref/fate/cbs-vp9-vp91-2-04-yuv440|  1 +
>  tests/ref/fate/cbs-vp9-vp91-2-04-yuv444|  1 +
>  tests/ref/fate/cbs-vp9-vp92-2-20-10bit-yuv420  |  1 +
>  tests/ref/fate/cbs-vp9-vp93-2-20-10bit-yuv422  |  1 +
>  tests/ref/fate/cbs-vp9-vp93-2-20-12bit-yuv444  |  1 +
>  15 files changed, 43 insertions(+), 5 deletions(-)
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-03-deltaq
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-05-resize
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-06-bilinear
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-09-lf_deltas
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-10-show-existing-frame
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-10-show-existing-frame2
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-segmentation-aq-akiyo
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-segmentation-sf-akiyo
>  create mode 100644 tests/ref/fate/cbs-vp9-vp90-2-tiling-pedestrian
>  create mode 100644 tests/ref/fate/cbs-vp9-vp91-2-04-yuv440
>  create mode 100644 tests/ref/fate/cbs-vp9-vp91-2-04-yuv444
>  create mode 100644 tests/ref/fate/cbs-vp9-vp92-2-20-10bit-yuv420
>  create mode 100644 tests/ref/fate/cbs-vp9-vp93-2-20-10bit-yuv422
>  create mode 100644 tests/ref/fate/cbs-vp9-vp93-2-20-12bit-yuv444

LGTM.

Unrelated to this patch, but could you add -y to the command line for
all cbs tests? That way it will not fail/abort if the output file
already exists (Something that can happen if the test failed previously
as no cleanup takes place in that case).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/6] lavc: Add coded bitstream read/write support for VP9

2018-05-01 Thread James Almer
On 4/30/2018 8:26 PM, Mark Thompson wrote:
> ---
> Main change since last time is including the array subscripts.  Constants are 
> also cleaned up a bit, but stay in the cbs header (vp9.h could probably be 
> taken over for this purpose, but currently it's an unnamespaced header used 
> by the decoder so I haven't touched it).
> 
> 
>  configure|   2 +
>  doc/bitstream_filters.texi   |   2 +-
>  libavcodec/Makefile  |   1 +
>  libavcodec/cbs.c |   6 +
>  libavcodec/cbs.h |   1 +
>  libavcodec/cbs_internal.h|   1 +
>  libavcodec/cbs_vp9.c | 679 
> +++
>  libavcodec/cbs_vp9.h | 201 +++
>  libavcodec/cbs_vp9_syntax_template.c | 390 
>  9 files changed, 1282 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/cbs_vp9.c
>  create mode 100644 libavcodec/cbs_vp9.h
>  create mode 100644 libavcodec/cbs_vp9_syntax_template.c

LGTM. No apparent data copy on any of the read methods which is very
promising for the AV1 implementation.
Only CodedBitstreamType->write_unit() still seems a tad sub-optimal with
the temp write_buffer, especially in this module where unlike
mpeg2/h2645 you memcpy the data twice.

Can't really comment on the actual bitstream parsing code, but
trace_headers_bsf doesn't complain about any of the samples i tried.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/6] cbs_h2645: Simplify representation of fixed values

2018-05-01 Thread Michael Niedermayer
On Tue, May 01, 2018 at 12:26:01AM +0100, Mark Thompson wrote:
> ---
> Mainly to avoid messing with them in the following patch.
> 
> 
>  libavcodec/cbs_h2645.c|  5 +
>  libavcodec/cbs_h264_syntax_template.c | 30 ---
>  libavcodec/cbs_h265_syntax_template.c | 38 
> +++
>  3 files changed, 34 insertions(+), 39 deletions(-)

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH 1/6] cbs: Fragment/unit data is always reference counted

2018-05-01 Thread James Almer
On 4/30/2018 8:26 PM, Mark Thompson wrote:
> Make this clear in the documentation and add some asserts to ensure
> that it is always true.
> ---
> As suggested earlier :)
> 
> 
>  libavcodec/cbs.c | 18 --
>  libavcodec/cbs.h | 10 ++
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index d81b4e03f7..0d6ffe8824 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -140,26 +140,30 @@ static int 
> cbs_read_fragment_content(CodedBitstreamContext *ctx,
>  int err, i, j;
>  
>  for (i = 0; i < frag->nb_units; i++) {
> +CodedBitstreamUnit *unit = >units[i];
> +
>  if (ctx->decompose_unit_types) {
>  for (j = 0; j < ctx->nb_decompose_unit_types; j++) {
> -if (ctx->decompose_unit_types[j] == frag->units[i].type)
> +if (ctx->decompose_unit_types[j] == unit->type)
>  break;
>  }
>  if (j >= ctx->nb_decompose_unit_types)
>  continue;
>  }
>  
> -av_buffer_unref(>units[i].content_ref);
> -frag->units[i].content = NULL;
> +av_buffer_unref(>content_ref);
> +unit->content = NULL;
> +
> +av_assert0(unit->data && unit->data_ref);
>  
> -err = ctx->codec->read_unit(ctx, >units[i]);
> +err = ctx->codec->read_unit(ctx, unit);
>  if (err == AVERROR(ENOSYS)) {
>  av_log(ctx->log_ctx, AV_LOG_VERBOSE,
> "Decomposition unimplemented for unit %d "
> -   "(type %"PRIu32").\n", i, frag->units[i].type);
> +   "(type %"PRIu32").\n", i, unit->type);
>  } else if (err < 0) {
>  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
> -   "(type %"PRIu32").\n", i, frag->units[i].type);
> +   "(type %"PRIu32").\n", i, unit->type);
>  return err;
>  }
>  }
> @@ -277,6 +281,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,
> "(type %"PRIu32").\n", i, unit->type);
>  return err;
>  }
> +av_assert0(unit->data && unit->data_ref);
>  }
>  
>  av_buffer_unref(>data_ref);
> @@ -287,6 +292,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,
>  av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to assemble fragment.\n");
>  return err;
>  }
> +av_assert0(frag->data && frag->data_ref);

You can remove the assert in ff_cbs_write_packet() if you add this one.

>  
>  return 0;
>  }
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 402eb39e00..487358afaf 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -84,8 +84,9 @@ typedef struct CodedBitstreamUnit {
>   */
>  size_t   data_bit_padding;
>  /**
> - * If data is reference counted, a reference to the buffer containing
> - * data.  Null if data is not reference counted.
> + * A reference to the buffer containing data.
> + *
> + * Must be set if data is not NULL.
>   */
>  AVBufferRef *data_ref;
>  
> @@ -130,8 +131,9 @@ typedef struct CodedBitstreamFragment {
>   */
>  size_t data_bit_padding;
>  /**
> - * If data is reference counted, a reference to the buffer containing
> - * data.  Null if data is not reference counted.
> + * A reference to the buffer containing data.
> + *
> + * Must be set if data is not NULL.
>   */
>  AVBufferRef *data_ref;

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


[FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

2018-05-01 Thread Paul B Mahol
This one actually works with hd1080 y4m files when seeking backwards.

Signed-off-by: Paul B Mahol 
---
 libavformat/yuv4mpegdec.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index 8662a42a4c..de3d5637fe 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -317,11 +317,9 @@ static int yuv4_read_seek(AVFormatContext *s, int 
stream_index,
 AVStream *st = s->streams[0];
 int64_t pos;
 
-pos = av_rescale_rnd(pts * s->packet_size,
- st->time_base.num,
- st->time_base.den * s->packet_size,
- (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : 
AV_ROUND_UP);
-pos *= s->packet_size;
+if (flags & AVSEEK_FLAG_BACKWARD)
+pts -= 1;
+pos = pts * s->packet_size;
 
 if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
 return -1;
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: use generic code for seeking

2018-05-01 Thread wm4
On Tue, 1 May 2018 15:17:53 +0200
Paul B Mahol  wrote:

> On 5/1/18, wm4  wrote:
> > On Tue,  1 May 2018 11:47:04 +0200
> > Paul B Mahol  wrote:
> >  
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavformat/yuv4mpegdec.c| 23 
> >>  tests/ref/seek/lavf-yuv4mpeg | 52
> >> 
> >>  2 files changed, 28 insertions(+), 47 deletions(-)
> >>
> >> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> >> index 8662a42a4c..cf6da2a2ef 100644
> >> --- a/libavformat/yuv4mpegdec.c
> >> +++ b/libavformat/yuv4mpegdec.c
> >> @@ -306,28 +306,13 @@ static int yuv4_read_packet(AVFormatContext *s,
> >> AVPacket *pkt)
> >>  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
> >>  }
> >>  pkt->stream_index = 0;
> >> -pkt->pts = (off - s->internal->data_offset) / s->packet_size;
> >> +pkt->pos = off;
> >> +pkt->dts = pkt->pts = (off - s->internal->data_offset) /
> >> s->packet_size;
> >> +pkt->flags |= AV_PKT_FLAG_KEY;
> >>  pkt->duration = 1;
> >>  return 0;
> >>  }
> >>
> >> -static int yuv4_read_seek(AVFormatContext *s, int stream_index,
> >> -  int64_t pts, int flags)
> >> -{
> >> -AVStream *st = s->streams[0];
> >> -int64_t pos;
> >> -
> >> -pos = av_rescale_rnd(pts * s->packet_size,
> >> - st->time_base.num,
> >> - st->time_base.den * s->packet_size,
> >> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN :
> >> AV_ROUND_UP);
> >> -pos *= s->packet_size;
> >> -
> >> -if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
> >> -return -1;
> >> -return 0;
> >> -}
> >> -
> >>  static int yuv4_probe(AVProbeData *pd)
> >>  {
> >>  /* check file header */
> >> @@ -343,6 +328,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
> >>  .read_probe = yuv4_probe,
> >>  .read_header= yuv4_read_header,
> >>  .read_packet= yuv4_read_packet,
> >> -.read_seek  = yuv4_read_seek,
> >>  .extensions = "y4m",
> >> +.flags  = AVFMT_GENERIC_INDEX,
> >>  };
> >> diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg  
> >
> > Seems like a bad idea. This will make seeking read and skip all data
> > when seeking to the middle of the stream, instead of just seeking there.  
> 
> How do you explain that this patch makes backsteeping with mpv magnitude 
> faster?
> 
> Without it, more far you are from start of file backstepping is linearly 
> slower.

I don't know how this interacts with mpv, but obviously it's unexpected
that O(1) demuxer level seeking is slower than O(n) seeking. You
probably have some sort of overflow or something in the seek routine
or elsewhere. Maybe it's an lavf internal fallback to something worse
if the seek fails (e.g. when trying to seek before the start of the
file). Obviously you should analyze this.

(mpv seeks before the start of the file because it can't reliable know
a pts is before the start.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: use generic code for seeking

2018-05-01 Thread Paul B Mahol
On 5/1/18, wm4  wrote:
> On Tue,  1 May 2018 11:47:04 +0200
> Paul B Mahol  wrote:
>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavformat/yuv4mpegdec.c| 23 
>>  tests/ref/seek/lavf-yuv4mpeg | 52
>> 
>>  2 files changed, 28 insertions(+), 47 deletions(-)
>>
>> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
>> index 8662a42a4c..cf6da2a2ef 100644
>> --- a/libavformat/yuv4mpegdec.c
>> +++ b/libavformat/yuv4mpegdec.c
>> @@ -306,28 +306,13 @@ static int yuv4_read_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
>>  }
>>  pkt->stream_index = 0;
>> -pkt->pts = (off - s->internal->data_offset) / s->packet_size;
>> +pkt->pos = off;
>> +pkt->dts = pkt->pts = (off - s->internal->data_offset) /
>> s->packet_size;
>> +pkt->flags |= AV_PKT_FLAG_KEY;
>>  pkt->duration = 1;
>>  return 0;
>>  }
>>
>> -static int yuv4_read_seek(AVFormatContext *s, int stream_index,
>> -  int64_t pts, int flags)
>> -{
>> -AVStream *st = s->streams[0];
>> -int64_t pos;
>> -
>> -pos = av_rescale_rnd(pts * s->packet_size,
>> - st->time_base.num,
>> - st->time_base.den * s->packet_size,
>> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN :
>> AV_ROUND_UP);
>> -pos *= s->packet_size;
>> -
>> -if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
>> -return -1;
>> -return 0;
>> -}
>> -
>>  static int yuv4_probe(AVProbeData *pd)
>>  {
>>  /* check file header */
>> @@ -343,6 +328,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
>>  .read_probe = yuv4_probe,
>>  .read_header= yuv4_read_header,
>>  .read_packet= yuv4_read_packet,
>> -.read_seek  = yuv4_read_seek,
>>  .extensions = "y4m",
>> +.flags  = AVFMT_GENERIC_INDEX,
>>  };
>> diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg
>
> Seems like a bad idea. This will make seeking read and skip all data
> when seeking to the middle of the stream, instead of just seeking there.

How do you explain that this patch makes backsteeping with mpv magnitude faster?

Without it, more far you are from start of file backstepping is linearly slower.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: use generic code for seeking

2018-05-01 Thread wm4
On Tue,  1 May 2018 11:47:04 +0200
Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/yuv4mpegdec.c| 23 
>  tests/ref/seek/lavf-yuv4mpeg | 52 
> 
>  2 files changed, 28 insertions(+), 47 deletions(-)
> 
> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> index 8662a42a4c..cf6da2a2ef 100644
> --- a/libavformat/yuv4mpegdec.c
> +++ b/libavformat/yuv4mpegdec.c
> @@ -306,28 +306,13 @@ static int yuv4_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
>  }
>  pkt->stream_index = 0;
> -pkt->pts = (off - s->internal->data_offset) / s->packet_size;
> +pkt->pos = off;
> +pkt->dts = pkt->pts = (off - s->internal->data_offset) / s->packet_size;
> +pkt->flags |= AV_PKT_FLAG_KEY;
>  pkt->duration = 1;
>  return 0;
>  }
>  
> -static int yuv4_read_seek(AVFormatContext *s, int stream_index,
> -  int64_t pts, int flags)
> -{
> -AVStream *st = s->streams[0];
> -int64_t pos;
> -
> -pos = av_rescale_rnd(pts * s->packet_size,
> - st->time_base.num,
> - st->time_base.den * s->packet_size,
> - (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : 
> AV_ROUND_UP);
> -pos *= s->packet_size;
> -
> -if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
> -return -1;
> -return 0;
> -}
> -
>  static int yuv4_probe(AVProbeData *pd)
>  {
>  /* check file header */
> @@ -343,6 +328,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
>  .read_probe = yuv4_probe,
>  .read_header= yuv4_read_header,
>  .read_packet= yuv4_read_packet,
> -.read_seek  = yuv4_read_seek,
>  .extensions = "y4m",
> +.flags  = AVFMT_GENERIC_INDEX,
>  };
> diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg

Seems like a bad idea. This will make seeking read and skip all data
when seeking to the middle of the stream, instead of just seeking there.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: use generic code for seeking

2018-05-01 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/yuv4mpegdec.c| 23 
 tests/ref/seek/lavf-yuv4mpeg | 52 
 2 files changed, 28 insertions(+), 47 deletions(-)

diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index 8662a42a4c..cf6da2a2ef 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -306,28 +306,13 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
 }
 pkt->stream_index = 0;
-pkt->pts = (off - s->internal->data_offset) / s->packet_size;
+pkt->pos = off;
+pkt->dts = pkt->pts = (off - s->internal->data_offset) / s->packet_size;
+pkt->flags |= AV_PKT_FLAG_KEY;
 pkt->duration = 1;
 return 0;
 }
 
-static int yuv4_read_seek(AVFormatContext *s, int stream_index,
-  int64_t pts, int flags)
-{
-AVStream *st = s->streams[0];
-int64_t pos;
-
-pos = av_rescale_rnd(pts * s->packet_size,
- st->time_base.num,
- st->time_base.den * s->packet_size,
- (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : 
AV_ROUND_UP);
-pos *= s->packet_size;
-
-if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
-return -1;
-return 0;
-}
-
 static int yuv4_probe(AVProbeData *pd)
 {
 /* check file header */
@@ -343,6 +328,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
 .read_probe = yuv4_probe,
 .read_header= yuv4_read_header,
 .read_packet= yuv4_read_packet,
-.read_seek  = yuv4_read_seek,
 .extensions = "y4m",
+.flags  = AVFMT_GENERIC_INDEX,
 };
diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg
index 15d4d8c8c1..0f85ea5a46 100644
--- a/tests/ref/seek/lavf-yuv4mpeg
+++ b/tests/ref/seek/lavf-yuv4mpeg
@@ -1,48 +1,44 @@
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
-ret:-1 st:-1 flags:0  ts:-1.00
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 58 
size:152064
+ret: 0 st:-1 flags:0  ts:-1.00
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 58 
size:152064
 ret: 0 st:-1 flags:1  ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3649738 
size:152064
 ret: 0 st: 0 flags:0  ts: 0.80
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:3041458 
size:152064
 ret:-1 st: 0 flags:1  ts:-0.32
-ret: 0 st:-1 flags:0  ts: 2.576668
-ret: 0 st: 0 flags:1 dts: 0.12 pts: 0.12 pos: 456274 
size:152064
+ret:-1 st:-1 flags:0  ts: 2.576668
 ret: 0 st:-1 flags:1  ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3649738 
size:152064
 ret: 0 st: 0 flags:0  ts: 0.36
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1368688 
size:152064
 ret:-1 st: 0 flags:1  ts:-0.76
-ret: 0 st:-1 flags:0  ts: 2.153336
-ret: 0 st: 0 flags:1 dts: 0.12 pts: 0.12 pos: 456274 
size:152064
+ret:-1 st:-1 flags:0  ts: 2.153336
 ret: 0 st:-1 flags:1  ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3649738 
size:152064
 ret: 0 st: 0 flags:0  ts:-0.04
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 58 
size:152064
 ret: 0 st: 0 flags:1  ts: 2.84
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
-ret: 0 st:-1 flags:0  ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3649738 
size:152064
+ret:-1 st:-1 flags:0  ts: 1.730004
 ret: 0 st:-1 flags:1  ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.64 pts: 0.64 pos:2433178 
size:152064
 ret: 0 st: 0 flags:0  ts:-0.48
-ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64 
size:152064
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 58 
size:152064
 ret: 0 st: 0 flags:1  ts: 2.40
-ret: 0 st: 0 flags:1 dts: 0.08 pts: 0.08 pos: 304204 
size:152064
-ret: 0 st:-1 flags:0  ts: 1.306672
-ret: 0 st: 0 flags:1 

Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread Paul B Mahol
On 5/1/18, Michael Niedermayer  wrote:
> On Tue, May 01, 2018 at 10:02:21AM +0200, Paul B Mahol wrote:
>> Specifically for yuv444, yuv422, yuv420 format when main stream has no
>> alpha, and alpha
>> is straight.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/vf_overlay.c  |  75 +-
>>  libavfilter/vf_overlay.h  |  85 +
>>  libavfilter/x86/Makefile  |   2 +
>>  libavfilter/x86/vf_overlay.asm| 157
>> ++
>>  libavfilter/x86/vf_overlay_init.c |  63 +++
>>  5 files changed, 326 insertions(+), 56 deletions(-)
>>  create mode 100644 libavfilter/vf_overlay.h
>>  create mode 100644 libavfilter/x86/vf_overlay.asm
>>  create mode 100644 libavfilter/x86/vf_overlay_init.c
>
> breaks build on x86-32
>
> src/libavfilter/x86/vf_overlay.asm:36: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:47: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:48: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:49: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:57: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:58: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:59: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:63: error: symbol `r7d' undefined
> src/libavfilter/x86/vf_overlay.asm:68: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:81: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:82: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:84: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:89: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:93: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:101: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:102: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:103: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:107: error: symbol `r7d' undefined
> src/libavfilter/x86/vf_overlay.asm:112: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:127: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:128: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:130: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:134: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:137: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:142: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:150: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:151: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:152: error: symbol `r7q' undefined
> src/libavfilter/x86/vf_overlay.asm:156: error: symbol `r7d' undefined
> make: *** [libavfilter/x86/vf_overlay.o] Error 1
> make: *** Waiting for unfinished jobs

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread Michael Niedermayer
On Tue, May 01, 2018 at 10:02:21AM +0200, Paul B Mahol wrote:
> Specifically for yuv444, yuv422, yuv420 format when main stream has no alpha, 
> and alpha
> is straight.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_overlay.c  |  75 +-
>  libavfilter/vf_overlay.h  |  85 +
>  libavfilter/x86/Makefile  |   2 +
>  libavfilter/x86/vf_overlay.asm| 157 
> ++
>  libavfilter/x86/vf_overlay_init.c |  63 +++
>  5 files changed, 326 insertions(+), 56 deletions(-)
>  create mode 100644 libavfilter/vf_overlay.h
>  create mode 100644 libavfilter/x86/vf_overlay.asm
>  create mode 100644 libavfilter/x86/vf_overlay_init.c

breaks build on x86-32

src/libavfilter/x86/vf_overlay.asm:36: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:47: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:48: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:49: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:57: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:58: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:59: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:63: error: symbol `r7d' undefined
src/libavfilter/x86/vf_overlay.asm:68: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:81: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:82: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:84: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:89: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:93: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:101: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:102: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:103: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:107: error: symbol `r7d' undefined
src/libavfilter/x86/vf_overlay.asm:112: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:127: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:128: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:130: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:134: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:137: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:142: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:150: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:151: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:152: error: symbol `r7q' undefined
src/libavfilter/x86/vf_overlay.asm:156: error: symbol `r7d' undefined
make: *** [libavfilter/x86/vf_overlay.o] Error 1
make: *** Waiting for unfinished jobs



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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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


[FFmpeg-devel] [PATCH] avfilter/vf_overlay: add x86 SIMD

2018-05-01 Thread Paul B Mahol
Specifically for yuv444, yuv422, yuv420 format when main stream has no alpha, 
and alpha
is straight.

Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_overlay.c  |  75 +-
 libavfilter/vf_overlay.h  |  85 +
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_overlay.asm| 157 ++
 libavfilter/x86/vf_overlay_init.c |  63 +++
 5 files changed, 326 insertions(+), 56 deletions(-)
 create mode 100644 libavfilter/vf_overlay.h
 create mode 100644 libavfilter/x86/vf_overlay.asm
 create mode 100644 libavfilter/x86/vf_overlay_init.c

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 8c1895cca4..c4d87306f1 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -39,6 +39,7 @@
 #include "drawutils.h"
 #include "framesync.h"
 #include "video.h"
+#include "vf_overlay.h"
 
 typedef struct ThreadData {
 AVFrame *dst, *src;
@@ -59,21 +60,6 @@ static const char *const var_names[] = {
 NULL
 };
 
-enum var_name {
-VAR_MAIN_W,VAR_MW,
-VAR_MAIN_H,VAR_MH,
-VAR_OVERLAY_W, VAR_OW,
-VAR_OVERLAY_H, VAR_OH,
-VAR_HSUB,
-VAR_VSUB,
-VAR_X,
-VAR_Y,
-VAR_N,
-VAR_POS,
-VAR_T,
-VAR_VARS_NB
-};
-
 #define MAIN0
 #define OVERLAY 1
 
@@ -92,45 +78,6 @@ enum EvalMode {
 EVAL_MODE_NB
 };
 
-enum OverlayFormat {
-OVERLAY_FORMAT_YUV420,
-OVERLAY_FORMAT_YUV422,
-OVERLAY_FORMAT_YUV444,
-OVERLAY_FORMAT_RGB,
-OVERLAY_FORMAT_GBRP,
-OVERLAY_FORMAT_AUTO,
-OVERLAY_FORMAT_NB
-};
-
-typedef struct OverlayContext {
-const AVClass *class;
-int x, y;   ///< position of overlaid picture
-
-uint8_t main_is_packed_rgb;
-uint8_t main_rgba_map[4];
-uint8_t main_has_alpha;
-uint8_t overlay_is_packed_rgb;
-uint8_t overlay_rgba_map[4];
-uint8_t overlay_has_alpha;
-int format; ///< OverlayFormat
-int alpha_format;
-int eval_mode;  ///< EvalMode
-
-FFFrameSync fs;
-
-int main_pix_step[4];   ///< steps per pixel for each plane of the 
main output
-int overlay_pix_step[4];///< steps per pixel for each plane of the 
overlay
-int hsub, vsub; ///< chroma subsampling values
-const AVPixFmtDescriptor *main_desc; ///< format descriptor for main input
-
-double var_values[VAR_VARS_NB];
-char *x_expr, *y_expr;
-
-AVExpr *x_pexpr, *y_pexpr;
-
-int (*blend_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
-} OverlayContext;
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
 OverlayContext *s = ctx->priv;
@@ -509,6 +456,7 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
  int jobnr,
  int nb_jobs)
 {
+OverlayContext *octx = ctx->priv;
 int src_wp = AV_CEIL_RSHIFT(src_w, hsub);
 int src_hp = AV_CEIL_RSHIFT(src_h, vsub);
 int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub);
@@ -538,8 +486,18 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
 s = sp + k;
 a = ap + (k<blend_row[i]) {
+int c = octx->blend_row[i](d, da, s, a, kmax - k, 
src->linesize[3]);
 
-for (kmax = FFMIN(-xp + dst_wp, src_wp); k < kmax; k++) {
+s += c;
+d += dst_step * c;
+da += (1 << hsub) * c;
+a += (1 << hsub) * c;
+k += c;
+}
+for (; k < kmax; k++) {
 int alpha_v, alpha_h, alpha;
 
 // average alpha for color components, improve quality
@@ -916,7 +874,7 @@ static int config_input_main(AVFilterLink *inlink)
 }
 
 if (!s->alpha_format)
-return 0;
+goto end;
 
 switch (s->format) {
 case OVERLAY_FORMAT_YUV420:
@@ -960,6 +918,11 @@ static int config_input_main(AVFilterLink *inlink)
 }
 break;
 }
+
+end:
+if (ARCH_X86)
+ff_overlay_init_x86(s, s->format, s->alpha_format, s->main_has_alpha);
+
 return 0;
 }
 
diff --git a/libavfilter/vf_overlay.h b/libavfilter/vf_overlay.h
new file mode 100644
index 00..072ece358f
--- /dev/null
+++ b/libavfilter/vf_overlay.h
@@ -0,0 +1,85 @@
+/*
+ * 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