Re: [FFmpeg-devel] [PATCH v2 1/4] avformat/argo_asf: don't check or probe file version

2020-08-09 Thread Paul B Mahol
This is really bad practice.

On 8/8/20, Zane van Iperen  wrote:
> All files I've seen are identical, irregardless of version.
> Until shown otherwise, assume unknown ones are too.
>
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/argo_asf.c | 37 +++--
>  1 file changed, 7 insertions(+), 30 deletions(-)
>
> diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
> index 671b7482f9..beec46a0d4 100644
> --- a/libavformat/argo_asf.c
> +++ b/libavformat/argo_asf.c
> @@ -29,6 +29,12 @@
>  #define ASF_CHUNK_HEADER_SIZE   20
>  #define ASF_SAMPLE_COUNT32
>
> +/*
> + * Known versions:
> + * 1.1: The sample files in /game-formats/brender/part2.zip
> + * 1.2: Croc! Legend of the Gobbos
> + * 2.1: Croc 2
> + */
>  typedef struct ArgoASFFileHeader {
>  uint32_tmagic;  /*< Magic Number, {'A', 'S', 'F', '\0'} */
>  uint16_tversion_major;  /*< File Major Version. */
> @@ -85,33 +91,11 @@ static void
> argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *
>  hdr->flags  = AV_RL32(buf + 16);
>  }
>
> -/*
> - * Known versions:
> - * 1.1: The sample files in /game-formats/brender/part2.zip
> - * 1.2: Croc! Legend of the Gobbos
> - * 2.1: Croc 2
> - */
> -static int argo_asf_is_known_version(const ArgoASFFileHeader *hdr)
> -{
> -return (hdr->version_major == 1 && hdr->version_minor == 1) ||
> -   (hdr->version_major == 1 && hdr->version_minor == 2) ||
> -   (hdr->version_major == 2 && hdr->version_minor == 1);
> -}
> -
>  static int argo_asf_probe(const AVProbeData *p)
>  {
> -ArgoASFFileHeader hdr;
> -
> -av_assert0(AVPROBE_PADDING_SIZE >= ASF_FILE_HEADER_SIZE);
> -
> -argo_asf_parse_file_header(&hdr, p->buf);
> -
> -if (hdr.magic != ASF_TAG)
> +if (AV_RL32(p->buf) != ASF_TAG)
>  return 0;
>
> -if (!argo_asf_is_known_version(&hdr))
> -return AVPROBE_SCORE_EXTENSION / 2;
> -
>  return AVPROBE_SCORE_EXTENSION + 1;
>  }
>
> @@ -133,13 +117,6 @@ static int argo_asf_read_header(AVFormatContext *s)
>
>  argo_asf_parse_file_header(&asf->fhdr, buf);
>
> -if (!argo_asf_is_known_version(&asf->fhdr)) {
> -avpriv_request_sample(s, "Version %hu.%hu",
> -asf->fhdr.version_major, asf->fhdr.version_minor
> -);
> -return AVERROR_PATCHWELCOME;
> -}
> -
>  if (asf->fhdr.num_chunks == 0) {
>  return AVERROR_INVALIDDATA;
>  } else if (asf->fhdr.num_chunks > 1) {
> --
> 2.25.1
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/options: Add options for inputing HDR10-related metadata

2020-08-09 Thread Andreas Rheinhardt
Kenny McClive:
> Hi,
> 
> Would someone be willing to help me with this?  This is the first patch I’ve 
> submitted.  Patchwork shows that two tests are failing.  However, when I run 
> “make fate” locally, I don’t see any failures.  Is there some other make or 
> configure command that I can run to make my results match those in Patchwork? 
>  Is there something else I’m missing?  Any help would be appreciated.
> 
> Thanks,
> Kenny
> 
>> On Aug 8, 2020, at 5:53 PM, Patchwork  wrote:
>>
>> Hello, 
>>
>> Thank you for submitting a patch to ffmpeg-devel.
>>
>> An error occurred during an automated build/fate test. Please review the 
>> following link for more details:
>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/a384b59e-32e4-459a-af0c-47bc551e0...@me.com/
>>
>> Thank you, 
>> ffmpeg-devel
> 

You are probably running fate without samples. See
https://ffmpeg.org/fate.html#Using-FATE-from-your-FFmpeg-source-directory
for more.

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

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

[FFmpeg-devel] [PATCH 1/2] lavfi/avf_concat: add some doxy.

2020-08-09 Thread Nicolas George
The semantic of delta_pts is not obvious.

Signed-off-by: Nicolas George 
---
 libavfilter/avf_concat.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 28bd5407ad..246628498a 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -224,6 +224,12 @@ static void close_input(AVFilterContext *ctx, unsigned 
in_no)
ctx->input_pads[in_no].name, cat->nb_in_active);
 }
 
+/**
+ * Compute the delta_ts of the next segment.
+ *
+ * If everything starts at 0 as expected, it is the timestamp where the
+ * next segment begins in the output.
+ */
 static void find_next_delta_ts(AVFilterContext *ctx, int64_t *seg_delta)
 {
 ConcatContext *cat = ctx->priv;
@@ -238,6 +244,14 @@ static void find_next_delta_ts(AVFilterContext *ctx, 
int64_t *seg_delta)
 *seg_delta = pts;
 }
 
+/**
+ * Send silence to pad audio streams to the duration of video streams
+ *
+ * @param ctxcodec context
+ * @param in_no  input number
+ * @param out_no output number
+ * @param seg_delta  segment delta, i.e. output timestamp to reach.
+ */
 static int send_silence(AVFilterContext *ctx, unsigned in_no, unsigned out_no,
 int64_t seg_delta)
 {
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 2/2] lavfi/avf_concat: check input timestamp.

2020-08-09 Thread Nicolas George
If an input has an undefined timestamp, the computation
for silence at stitches can overflow.

Partial fix for trac ticket #8843.

Signed-off-by: Nicolas George 
---
 libavfilter/avf_concat.c | 4 
 1 file changed, 4 insertions(+)


"Partial fix" means it does not segfault and exits with an error instead.

The actual problem in this ticket is amix sending a frame with no PTS.


diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 246628498a..f376f72754 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -179,6 +179,10 @@ static int push_frame(AVFilterContext *ctx, unsigned 
in_no, AVFrame *buf)
 AVFilterLink *outlink = ctx->outputs[out_no];
 struct concat_in *in = &cat->in[in_no];
 
+if (buf->pts == AV_NOPTS_VALUE) {
+av_log(ctx, AV_LOG_ERROR, "Frame without timestamp on input %d\n", 
in_no);
+return AVERROR(EINVAL);
+}
 buf->pts = av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
 in->pts = buf->pts;
 in->nb_frames++;
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH 2/2] lavc/ratecontrol: Fix error logging for parsing and evaluation of rc_eq

2020-08-09 Thread Michael Niedermayer
On Fri, Aug 07, 2020 at 11:26:58PM +0200, Alexander Strasser wrote:
> Don't pass a potential NULL pointer to av_log, instead use a default
> in the rc_eq AVOption definitions. Now the context variable always
> holds a string; even if it's the default expression.
> 
> Note this also fixes the evaluation error path, where a similar
> av_log call references the rc_eq string from the context too.
> 
> Signed-off-by: Alexander Strasser 
> ---
>  libavcodec/mpegvideo.h   | 2 +-
>  libavcodec/ratecontrol.c | 3 +--
>  libavcodec/snowenc.c | 2 +-
>  3 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
> index 29e692f245..d2515a3bbf 100644
> --- a/libavcodec/mpegvideo.h
> +++ b/libavcodec/mpegvideo.h
> @@ -637,7 +637,7 @@ FF_MPV_OPT_CMP_FUNC, \
>"defined in the section 'Expression Evaluation', the following 
> functions are available: "
>  \
>"bits2qp(bits), qp2bits(qp). Also the following constants are 
> available: iTex pTex tex mv " 
>   \
>"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex 
> avgPPTex avgBPTex avgTex.",   
>   \
> -
> FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING,   .flags = 
> FF_MPV_OPT_FLAGS },\
> +
> FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = "tex^qComp" },.flags = 
> FF_MPV_OPT_FLAGS },\
>  {"rc_init_cplx", "initial complexity for 1-pass encoding",  
> FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, 
> FLT_MAX, FF_MPV_OPT_FLAGS},   \
>  {"rc_buf_aggressivity", "currently useless",
> FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 
> -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
>  {"border_mask", "increase the quantizer for macroblocks close to borders", 
> FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, 
> FLT_MAX, FF_MPV_OPT_FLAGS},\
> diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
> index 6b77ccd006..03513177f7 100644
> --- a/libavcodec/ratecontrol.c
> +++ b/libavcodec/ratecontrol.c
> @@ -515,8 +515,7 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
>  s->avctx->rc_max_available_vbv_use = 1.0;
>  }
> 
> -res = av_expr_parse(&rcc->rc_eq_eval,
> -s->rc_eq ? s->rc_eq : "tex^qComp",
> +res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq,
>  const_names, func1_names, func1,
>  NULL, NULL, 0, s->avctx);

what happens if the user sets rc_eq explicitly to NULL ?

thx

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

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or concluded 
you do not care. Either case is a failure of leadership. - Colin Powell


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

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

Re: [FFmpeg-devel] [PATCH] fate: remove "-v 0" from ffprobe tests.

2020-08-09 Thread Nicolas George
Nicolas George (12016-05-05):
> The FATE scripts separate stdout from stderr.
> Having a first idea about what went wrong in the log file
> is more convenient.
> 
> Signed-off-by: Nicolas George 
> ---
>  tests/fate-run.sh | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)

Ping? Will apply next time I think about it if nobody objects.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 2/2] lavf/dump: hide a few deprecation warnings.

2020-08-09 Thread Nicolas George
Nicolas George (12019-12-08):
> Signed-off-by: Nicolas George 
> ---
>  libavformat/dump.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
Ping? Will apply next time I think about it if nobody objects.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] lavf/tee: pass options to protocol.

2020-08-09 Thread Nicolas George
Nicolas George (12020-06-02):
> Fix trac ticket #8705.
> 
> Signed-off-by: Nicolas George 
> ---
>  libavformat/tee.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> Not tested, I have no icecast server at hand. I will ask the reporter to
> test.

Ping? Will apply next time I think about it if nobody objects.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v2] doc/developer: origin of tables should be documented.

2020-08-09 Thread Alexander Strasser


Hi Nicolas!

Am 8. August 2020 23:26:02 MESZ schrieb Mark Thompson :
>On 08/08/2020 18:57, Nicolas George wrote:

[...]

>> Andreas:

I'm sure the following was addressed at me.


>>> Not sure I agree with your definition of Libre Software and your
>exact
>> 
>> I was more trying to express the difference between Libre Software
>and
>> Open Source, which is minute in legal terms but huge in terms of
>> mentality. Anyway, this part is only explanatory, it does not go into
>> the tree.

Yes, that's fine.

IMHO we don't actually need ideology for this matter.


>>> wording of the patch.
>> 
>> Have you suggestions to make it better?

At least the aspect Mark mentioned below.

In general I think it could be worded a bit clearer and easier to grasp. 
Basically it should ask for a short comment in front of non-obvious data 
definitions.

I can try to write something later or tomorrow. Not sure if I can really come 
up with something much better, so I would be OK with your wording if Mark's 
comment is addresed.


  Alexander

>>> I agree that leaving a hint of where the data comes from, directly
>where
>>> the data is defined in the source code, is a good thing and probably
>not
>>> to much to ask for.
>> 
>> Thanks.
>> 
>> 
>> diff --git a/doc/developer.texi b/doc/developer.texi
>> index b33cab0fc7..c3103f31dc 100644
>> --- a/doc/developer.texi
>> +++ b/doc/developer.texi
>> @@ -216,6 +216,14 @@ please use av_log() instead.
>>   @item
>>   Casts should be used only when necessary. Unneeded parentheses
>>   should also be avoided if they don't make the code easier to
>understand.
>> +
>> +@item
>> +If the code contains tables of numbers or other data, their origin
>should be
>> +documented in a comment, so that other developers can rebuild them
>if
>> +necessary. If they were taken from a reference, include the URL of
>that
>> +reference. If they were computed by a tool, include the code of the
>tool.
>> +If they were reverse-engineered, include an honest attempt at
>explaining the
>> +methods used.
>
>Also: if they were taken from a written specification, include the
>section or table number within that specification.
>
>(A reference to "H.264 table A-1" is more useful than one to
>"".)
>
>>   @end itemize
>>   
>>   @section Editor configuration
>> 
>
>Thanks,
>
>- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2] doc/developer: origin of tables should be documented.

2020-08-09 Thread Nicolas George
Alexander Strasser (12020-08-09):
> >> Andreas:
> 
> I'm sure the following was addressed at me.

Yes, sorry to both of you.

> IMHO we don't actually need ideology for this matter.

I hope so.

> At least the aspect Mark mentioned below.
> 
> In general I think it could be worded a bit clearer and easier to grasp. 
> Basically it should ask for a short comment in front of non-obvious data 
> definitions.
> 
> I can try to write something later or tomorrow. Not sure if I can really come 
> up with something much better, so I would be OK with your wording if Mark's 
> comment is addresed.

Thanks. I will wait for your proposal, and in the meantime see if I can
come up with a better way of saying it myself.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v2] doc/developer: origin of tables should be documented.

2020-08-09 Thread Nicolas George
Zane van Iperen (12020-08-09):
> I'm apprehensive about this, especially in the case of
> reverse-engineered tables. It should definitely be encouraged, but not
> necessarily hard-required.
> 
> If you explicitly say "Reverse Engineered from so-and-so", that seems
> essentially like putting a target on FFmpeg's back.
> 
> Case-in-point: No reference decoder/encoder exists, and the tables had
> to be dumped from the application binary.

I would say that the tables themselves put a target our back, and the
comment mitigates it, since dumping tables from a binary is legal
(tables of numbers contain no creativity and therefore create no
copyright).

But anyway, the patch says "should", and such improbable cases, if they
arise, can be discussed on a case by case basis, possibly even in
private.

Regards,

-- 
  Nicolas George


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

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

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

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

I never pushed this. I will next time I think about it.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] lavc/avpacket: forward av_buffer_realloc() error code.

2020-08-09 Thread Nicolas George
Nicolas George (12020-01-04):
> Fix CID 1457229.
> 
> Signed-off-by: Nicolas George 
> ---
>  libavcodec/avpacket.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Ping? Will apply next time I think about it if nobody objects and it
still applies.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] lavu/buffer: forward av_buffer_realloc() error code.

2020-08-09 Thread Nicolas George
Nicolas George (12020-01-04):
> From 8ef49a7c86e108ed9e6981d482ae892e6f62c0f5 Mon Sep 17 00:00:00 2001
> From: Nicolas George 
> Date: Sat, 4 Jan 2020 19:52:08 +0100
> Subject: [PATCH 1/2] lavu/buffer: forward av_buffer_realloc() error code.
> 
> Fix CID 1457235.
> 
> Signed-off-by: Nicolas George 
> ---
>  libavutil/buffer.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Ping? Will apply next time I think about it if nobody objects and it
still applies.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] lavc/avpacket: forward av_buffer_realloc() error code.

2020-08-09 Thread Nicolas George
Nicolas George (12020-08-09):
> Ping? Will apply next time I think about it if nobody objects and it
> still applies.

Sorry, I missed Andreas comment in another mailbox.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH] avcodec/cfhd: small cleanups

2020-08-09 Thread Paul B Mahol
Hi,

patches attached.


0001-avcodec-cfhd-check-if-band-encoding-is-valid.patch
Description: Binary data


0002-avcodec-cfhd-reindent.patch
Description: Binary data


0003-avcodec-cfhd-use-init_get_bits8.patch
Description: Binary data


0004-avcodec-cfhd-read-prescale-table-tag.patch
Description: Binary data


0005-avcodec-cfhd-log-version-tags-too.patch
Description: Binary data


0006-avcodec-cfhd-improve-SampleIndex-tag-output.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] web/documentation: Updated list of FFmpeg books

2020-08-09 Thread FFmpegQuickHacks

Hi,

It has been three months after I submitted this patch. (In the meantime, 
FFmpeg.org released a new version and updated the website without 
requiring any patches.) Lou Logan says somebody else needs to support 
the patch. Please let me know if anything further needs to be done 
before it can be accepted.




FFmpegQuickHacks wrote:

---
 src/documentation |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/documentation b/src/documentation
index 060ef06..f6d5535 100644
--- a/src/documentation
+++ b/src/documentation
@@ -126,10 +126,12 @@
   
   Books about FFmpeg


--
V. Subhash
Writer/Programmer
www.VSubhash.com 
INDIA
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] lavc/ratecontrol: Fix error logging for parsing and evaluation of rc_eq

2020-08-09 Thread Alexander Strasser


Am 9. August 2020 12:56:53 MESZ schrieb Michael Niedermayer 
:
>On Fri, Aug 07, 2020 at 11:26:58PM +0200, Alexander Strasser wrote:
>> Don't pass a potential NULL pointer to av_log, instead use a default
>> in the rc_eq AVOption definitions. Now the context variable always
>> holds a string; even if it's the default expression.
>> 
>> Note this also fixes the evaluation error path, where a similar
>> av_log call references the rc_eq string from the context too.
>> 
>> Signed-off-by: Alexander Strasser 
>> ---
>>  libavcodec/mpegvideo.h   | 2 +-
>>  libavcodec/ratecontrol.c | 3 +--
>>  libavcodec/snowenc.c | 2 +-
>>  3 files changed, 3 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
>> index 29e692f245..d2515a3bbf 100644
>> --- a/libavcodec/mpegvideo.h
>> +++ b/libavcodec/mpegvideo.h
>> @@ -637,7 +637,7 @@ FF_MPV_OPT_CMP_FUNC, \
>>"defined in the section 'Expression Evaluation', the
>following functions are available: "   
> \
>>"bits2qp(bits), qp2bits(qp). Also the following constants
>are available: iTex pTex tex mv "  
>\
>>"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex
>avgPITex avgPPTex avgBPTex avgTex.",   
> \
>> -   
>FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING,  
>.flags = FF_MPV_OPT_FLAGS },\
>> +   
>FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = "tex^qComp" },   
>.flags = FF_MPV_OPT_FLAGS },\
>>  {"rc_init_cplx", "initial complexity for 1-pass encoding", 
>FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 },
>-FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS},   \
>>  {"rc_buf_aggressivity", "currently useless",   
>FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0
>}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
>>  {"border_mask", "increase the quantizer for macroblocks close to
>borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0
>}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS},\
>> diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
>> index 6b77ccd006..03513177f7 100644
>> --- a/libavcodec/ratecontrol.c
>> +++ b/libavcodec/ratecontrol.c
>> @@ -515,8 +515,7 @@ av_cold int ff_rate_control_init(MpegEncContext
>*s)
>>  s->avctx->rc_max_available_vbv_use = 1.0;
>>  }
>> 
>> -res = av_expr_parse(&rcc->rc_eq_eval,
>> -s->rc_eq ? s->rc_eq : "tex^qComp",
>> +res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq,
>>  const_names, func1_names, func1,
>>  NULL, NULL, 0, s->avctx);
>
>what happens if the user sets rc_eq explicitly to NULL ?

Not sure which user you mean.

If I'm not mistaken, a library user should not set it to NULL. Is it even 
possible while respecting public API?

If an internal user like an encoder sets rc_eq explicitly to NULL it will of 
course crash like in Snow without my previous patch

I guess I don't know what you prefer. Thus I'm waiting for a reply before 
attempting a new patch set if it's needed.


  Alexander

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

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

Re: [FFmpeg-devel] [PATCH] lavf/tee: pass options to protocol.

2020-08-09 Thread Paul B Mahol
On 8/9/20, Nicolas George  wrote:
> Nicolas George (12020-06-02):
>> Fix trac ticket #8705.
>>
>> Signed-off-by: Nicolas George 
>> ---
>>  libavformat/tee.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>
>> Not tested, I have no icecast server at hand. I will ask the reporter to
>> test.
>
> Ping? Will apply next time I think about it if nobody objects.

No way, you need at least one other developer to support your patch(es).

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

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

Re: [FFmpeg-devel] [PATCH v2 1/4] avformat/argo_asf: don't check or probe file version

2020-08-09 Thread Zane van Iperen
On Sun, 9 Aug 2020 09:29:16 +0200
"Paul B Mahol"  wrote:

> 
> This is really bad practice.
> 

Usually I'd agree. However (and I've just checked this) all file
versions are identical.

Since this is an Argonaut Games format, I checked the version of all the
ASF files in their most recent games. The only two versions found were
1.2 and 2.1, both of which are already supported.

Because this format is looong-dead, I see no harm in ignoring file
version (especially if the muxer allows specifying arbitrary versions).

I shall update the commit message accordingly.

$ for i in ~/Desktop/staging/asf_music/*/*; do ./asfdump.py $i | jq ._version; 
done | sort -u
"1.2"
"2.1"

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

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

Re: [FFmpeg-devel] [PATCH] web/documentation: Updated list of FFmpeg books

2020-08-09 Thread FFmpegQuickHacks

Hi,

The original patch is archived at:
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262634.html

Here it is again:

---
 src/documentation |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/documentation b/src/documentation
index 060ef06..f6d5535 100644
--- a/src/documentation
+++ b/src/documentation
@@ -126,10 +126,12 @@
   
   Books about FFmpeg
   
-http://ffmpeg.tv";>FFmpeg Basics by Frantisek Korbel,
-  describes various FFmpeg features and common tasks.
-http://book.chinaffmpeg.com";>FFmpeg Beginner's handbook Chinese 
Version by Steven Liu,
-describes FFmpeg common use method in Chinese, from command line to API 
usage.
+http://ffmpeg.tv";>FFmpeg Basics by Frantisek Korbel [2012]: 
Describes various FFmpeg features and common tasks.
+http://book.chinaffmpeg.com";>FFmpeg Beginner's handbook Chinese 
Version by Steven Liu [2018]: Describes FFmpeg common use method in Chinese, from command line to API 
usage.
+https://www.amazon.com/Learn-Produce-Videos-FFmpeg-Minutes/dp/0998453013/"; title="In Thirty Minutes 
or Less (2018 Edition)">Learn to Produce Videos with FFmpeg by https://www.amazon.com/Books-Jan-Lee-Ozer/s?rh=n%3A283155%2Cp_27%3AJan+Lee+Ozer";>Jan Ozer [2018]
+https://www.amazon.com/Introduction-FFmpeg-Encode-Mobile-Devices-ebook/dp/B07PBYS324/"; 
title="Encode Video for the Web and Mobile Devices">Introduction to FFmpeg by https://www.goodreads.com/author/show/8445243.Chris_Weed";>Chris Weed [2019]
+https://www.amazon.com/FFmpeg-Beginners-Audio-Youtube-Social-ebook/dp/B087GYV15Y/"; title="Edit 
Audio and Video Like a Pro for Youtube and Social Media">FFmpeg For Beginners by http://johnriselvato.com/";>John Riselvato [2020]
+https://www.amazon.com/FFMPEG-Quick-Hacks-collection-quick-reference-ebook/dp/B087VZMFVK/"; 
title="An FFMPEG tutorial, hack collection and quick-reference">FFMPEG Quick Hacks by http://www.vsubhash.com/ffmpeg-quick-hacks-book.html";>V Subhash [2020]
   
 

--
1.7.1




FFmpegQuickHacks wrote:

Hi,

It has been three months after I submitted this patch. (In the meantime,
FFmpeg.org released a new version and updated the website without
requiring any patches.) Lou Logan says somebody else needs to support
the patch. Please let me know if anything further needs to be done
before it can be accepted.



FFmpegQuickHacks wrote:

---
 src/documentation |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/documentation b/src/documentation
index 060ef06..f6d5535 100644
--- a/src/documentation
+++ b/src/documentation
@@ -126,10 +126,12 @@
   
   Books about FFmpeg




--
V. Subhash
Writer/Programmer
www.VSubhash.com 
INDIA

edi...@outlook.in   +91 9916493095
𝓥. 𝓢𝓾𝓫𝓱𝓪𝓼𝓱 is not the editor of Outlook magazine.
? 



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

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

Re: [FFmpeg-devel] [PATCH 1/2] lavc/snowenc: Expose an option to set the rc_eq expression

2020-08-09 Thread Michael Niedermayer
On Fri, Aug 07, 2020 at 11:26:17PM +0200, Alexander Strasser wrote:
> Snow uses the ratecontrol module, but does not expose a way to set
> the rc_eq expression. The default expression, set in the ratecontrol
> module, will always be used.
> 
> Make it possible to set rc_eq by adding an AVOption to snowenc.
> 
> The option definition is mostly a copy from the mpegvideo common
> options definition of rc_eq (libavcodec/mpegvideo.h), with some
> minor style adjustments to be closer to the other snowenc option
> initializer expressions.
> 
> Signed-off-by: Alexander Strasser 
> ---
>  libavcodec/snowenc.c | 5 +
>  1 file changed, 5 insertions(+)

should be ok

thx

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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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

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

Re: [FFmpeg-devel] [PATCH 2/2] lavc/ratecontrol: Fix error logging for parsing and evaluation of rc_eq

2020-08-09 Thread Michael Niedermayer
On Sun, Aug 09, 2020 at 02:24:34PM +0200, Alexander Strasser wrote:
> 
> 
> Am 9. August 2020 12:56:53 MESZ schrieb Michael Niedermayer 
> :
> >On Fri, Aug 07, 2020 at 11:26:58PM +0200, Alexander Strasser wrote:
> >> Don't pass a potential NULL pointer to av_log, instead use a default
> >> in the rc_eq AVOption definitions. Now the context variable always
> >> holds a string; even if it's the default expression.
> >> 
> >> Note this also fixes the evaluation error path, where a similar
> >> av_log call references the rc_eq string from the context too.
> >> 
> >> Signed-off-by: Alexander Strasser 
> >> ---
> >>  libavcodec/mpegvideo.h   | 2 +-
> >>  libavcodec/ratecontrol.c | 3 +--
> >>  libavcodec/snowenc.c | 2 +-
> >>  3 files changed, 3 insertions(+), 4 deletions(-)
> >> 
> >> diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
> >> index 29e692f245..d2515a3bbf 100644
> >> --- a/libavcodec/mpegvideo.h
> >> +++ b/libavcodec/mpegvideo.h
> >> @@ -637,7 +637,7 @@ FF_MPV_OPT_CMP_FUNC, \
> >>"defined in the section 'Expression Evaluation', the
> >following functions are available: "   
> > \
> >>"bits2qp(bits), qp2bits(qp). Also the following constants
> >are available: iTex pTex tex mv "  
> >\
> >>"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex
> >avgPITex avgPPTex avgBPTex avgTex.",   
> > \
> >> -   
> >FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING,  
> >.flags = FF_MPV_OPT_FLAGS },\
> >> +   
> >FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = "tex^qComp" },   
> >.flags = FF_MPV_OPT_FLAGS },\
> >>  {"rc_init_cplx", "initial complexity for 1-pass encoding", 
> >FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 },
> >-FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS},   \
> >>  {"rc_buf_aggressivity", "currently useless",   
> >FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0
> >}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
> >>  {"border_mask", "increase the quantizer for macroblocks close to
> >borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0
> >}, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS},\
> >> diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
> >> index 6b77ccd006..03513177f7 100644
> >> --- a/libavcodec/ratecontrol.c
> >> +++ b/libavcodec/ratecontrol.c
> >> @@ -515,8 +515,7 @@ av_cold int ff_rate_control_init(MpegEncContext
> >*s)
> >>  s->avctx->rc_max_available_vbv_use = 1.0;
> >>  }
> >> 
> >> -res = av_expr_parse(&rcc->rc_eq_eval,
> >> -s->rc_eq ? s->rc_eq : "tex^qComp",
> >> +res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq,
> >>  const_names, func1_names, func1,
> >>  NULL, NULL, 0, s->avctx);
> >
> >what happens if the user sets rc_eq explicitly to NULL ?
> 
> Not sure which user you mean.

lib user


> 
> If I'm not mistaken, a library user should not set it to NULL. Is it even 
> possible while respecting public API?

if its not possible then the patch should be fine. I was just asking becasue
thats the thing that would change if it can be set

thx

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

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

Re: [FFmpeg-devel] [PATCH] lavf/tee: pass options to protocol.

2020-08-09 Thread Marvin Scholz
On 9 Aug 2020, at 13:06, Nicolas George wrote:

> Nicolas George (12020-06-02):
>> Fix trac ticket #8705.
>>
>> Signed-off-by: Nicolas George 
>> ---
>>  libavformat/tee.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>
>> Not tested, I have no icecast server at hand. I will ask the reporter to
>> test.
>
> Ping? Will apply next time I think about it if nobody objects.
>

I think I already wrote this back when the patch was proposed,
but I tested it and it works fine.
I dont think it can cause any issues in other cases either,
so LGTM.



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

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: small cleanups

2020-08-09 Thread Kieran Kunhya
On Sun, 9 Aug 2020 at 13:20, Paul B Mahol  wrote:

> Hi,
>
> patches attached.
>

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

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

Re: [FFmpeg-devel] [PATCH] libavcodec/j2kenc: Support for all Progression orders

2020-08-09 Thread Michael Niedermayer
On Thu, Aug 06, 2020 at 11:09:32PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> This patch allows for selecting the progression order
> in the j2k encoder. However, all components and resolution
> levels will use the same progression order and will not
> feature the use of progression order change markers.
> ---
>  libavcodec/j2kenc.c | 223 +++-
>  1 file changed, 222 insertions(+), 1 deletion(-)

will apply

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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

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

Re: [FFmpeg-devel] [PATCH] lavf/tee: pass options to protocol.

2020-08-09 Thread Nicolas George
Marvin Scholz (12020-08-09):
> I think I already wrote this back when the patch was proposed,
> but I tested it and it works fine.
> I dont think it can cause any issues in other cases either,
> so LGTM.

Sorry, I fumbled my mailbox search, I had already applied this.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH] lavc/avpacket: forward av_buffer_realloc() error code.

2020-08-09 Thread James Almer
On 1/4/2020 4:00 PM, Nicolas George wrote:
> Fix CID 1457229.
> 
> Signed-off-by: Nicolas George 
> ---
>  libavcodec/avpacket.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index 858f827a0a..4da832c53c 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -170,7 +170,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  #define ALLOC_MALLOC(data, size) data = av_malloc(size)
>  #define ALLOC_BUF(data, size)\
>  do { \
> -av_buffer_realloc(&pkt->buf, size);  \
> +ret = av_buffer_realloc(&pkt->buf, size);  \
>  data = pkt->buf ? pkt->buf->data : NULL; \
>  } while (0)
>  
> @@ -197,6 +197,8 @@ do { \
>  /* Makes duplicates of data, side_data, but does not copy any other fields */
>  static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
>  {
> +int ret = AVERROR_BUG;
> +
>  pkt->data  = NULL;
>  pkt->side_data = NULL;
>  pkt->side_data_elems = 0;
> @@ -220,7 +222,8 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket 
> *src, int dup)
>  
>  failed_alloc:
>  av_packet_unref(pkt);
> -return AVERROR(ENOMEM);
> +av_assert1(ret != AVERROR_BUG);
> +return ret;
>  }
>  
>  int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)

This code is deprecated and will be removed in the next major bump, so
IMO it's worth trying to fix it, and especially if it's just to silence
a static analyzer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/6] avformat/argo_asf: add version_major and version_minor options

2020-08-09 Thread Alexander Strasser


Am 8. August 2020 14:52:02 MESZ schrieb Zane van Iperen 
:
>On Sat, 08 Aug 2020 13:05:28 +0200
>"Alexander Strasser"  wrote:
>
>> >@@ -296,8 +298,7 @@ static int argo_asf_write_header(AVFormatContext
>> >*s)
>> > ArgoASFContext  *ctx = s->priv_data;
>> >
>> > ctx->fhdr.magic  = ASF_TAG;
>> >-ctx->fhdr.version_major  = 2;
>> >-ctx->fhdr.version_minor  = 1;
>> >+/* version_{major,minor} set by options. */
>> 
>> Stupid question: Why are you adding options to override the file
>format version?
>> 
>> Normally those versions have implications on  the syntax and/or
>semantics of the files they are embedded in.
>> 
>> Am I misreading or misunderstanding something?
>> 
>
>You're right to think that, that's what I originally thought too.
>When researching the file format, I investigated several different file
>versions and their structure was identical.
>
>I think it's really only used as some kind of psuedo-identifier that
>tells which game the file came from, and I'm pretty sure some of the
>games check the version too (hence the options).
>
>I'd be happy to be proven wrong, but until other files surface I think
>allowing the user to specify the version is fine.

I see. Maybe it's not the version of the format, but has implications of what 
can be inside. Anyway I didn't look at any files, so just some wild guessing.

I would advise to use the verb override instead of set in the option 
description. I think it's less ambiguous. Like more expectations "you are doing 
this on your own" and less "FFmpeg will use Version 2.4 of the format now".


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add 3d transform support

2020-08-09 Thread Reto Kromer
Kieran Kunhya wrote:

>On Thu, 6 Aug 2020 at 17:28, Paul B Mahol 
>wrote:
>
>> patches attached.
>>
>
>Seems ok if tested on various samples.

Tested with a few samples only, LGTM. Best regards, Reto

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

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

[FFmpeg-devel] [PATCH 09/21] avfilter/vf_vpp_qsv: Fix leak of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The vpp_qsv's query_formats function allocated two AVFilterFormats,
before storing them permanently. If storing the first of them fails,
the function simply returns and the second leaks. This has been fixed by
only allocating the second AVFilterFormats structure after the first one
has been successfully stored.

Fixes Coverity issue #1422231.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_vpp_qsv.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 3194295f5f..12023af2d7 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -489,7 +489,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 static int query_formats(AVFilterContext *ctx)
 {
 int ret;
-AVFilterFormats *in_fmts, *out_fmts;
 static const enum AVPixelFormat in_pix_fmts[] = {
 AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_NV12,
@@ -505,16 +504,12 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 
-in_fmts  = ff_make_format_list(in_pix_fmts);
-out_fmts = ff_make_format_list(out_pix_fmts);
-ret = ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);
+ret = ff_formats_ref(ff_make_format_list(in_pix_fmts),
+ &ctx->inputs[0]->out_formats);
 if (ret < 0)
 return ret;
-ret = ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);
-if (ret < 0)
-return ret;
-
-return 0;
+return ff_formats_ref(ff_make_format_list(out_pix_fmts),
+  &ctx->outputs[0]->in_formats);
 }
 
 static av_cold void vpp_uninit(AVFilterContext *ctx)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 07/21] avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error

2020-08-09 Thread Andreas Rheinhardt
If an error happens between the allocation of an AVFilterChannelLayout
and its usage (which involves attaching said object to a more permanent
object), the channel layout array leaks. This can simply be fixed by
making sure that nothing is between the allocation and the
aforementioned usage.

Fixes Coverity issue #1250334.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_afir.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 5ba880f10b..6cbc7a00a1 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx)
 } else {
 AVFilterChannelLayouts *mono = NULL;
 
-ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO);
-if (ret)
-return ret;
-
 if ((ret = ff_channel_layouts_ref(layouts, 
&ctx->inputs[0]->out_channel_layouts)) < 0)
 return ret;
 if ((ret = ff_channel_layouts_ref(layouts, 
&ctx->outputs[0]->in_channel_layouts)) < 0)
 return ret;
+
+ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO);
+if (ret)
+return ret;
 for (int i = 1; i < ctx->nb_inputs; i++) {
 if ((ret = ff_channel_layouts_ref(mono, 
&ctx->inputs[i]->out_channel_layouts)) < 0)
 return ret;
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 08/21] avfilter/vf_paletteuse: Fix leaks of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The paletteuse's query_formats function allocated three AVFilterFormats
before storing them permanently. If allocating one of them failed, the
three AVFilterFormats structures would be freed with av_freep() which
does not free separately allocated subelements (namely the formats
array) which leak.

Furthermore, if storing one of the first two fails, the function simply
returns and the ones not yet stored leak.

These leaks have been fixed by only creating a new AVFilterFormats after
the last one has already been permanently stored. Furthermore, it is
enough to check whether the elements have been properly stored as
ff_formats_ref() by design returns AVERROR(ENOMEM) if it is provided a
NULL AVFilterFormats *.

Fixes Coverity issues #1270818 and #1270819.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_paletteuse.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
index b32ff817d0..80e2ba583a 100644
--- a/libavfilter/vf_paletteuse.c
+++ b/libavfilter/vf_paletteuse.c
@@ -142,18 +142,12 @@ static int query_formats(AVFilterContext *ctx)
 static const enum AVPixelFormat inpal_fmts[] = {AV_PIX_FMT_RGB32, 
AV_PIX_FMT_NONE};
 static const enum AVPixelFormat out_fmts[]   = {AV_PIX_FMT_PAL8,  
AV_PIX_FMT_NONE};
 int ret;
-AVFilterFormats *in= ff_make_format_list(in_fmts);
-AVFilterFormats *inpal = ff_make_format_list(inpal_fmts);
-AVFilterFormats *out   = ff_make_format_list(out_fmts);
-if (!in || !inpal || !out) {
-av_freep(&in);
-av_freep(&inpal);
-av_freep(&out);
-return AVERROR(ENOMEM);
-}
-if ((ret = ff_formats_ref(in   , &ctx->inputs[0]->out_formats)) < 0 ||
-(ret = ff_formats_ref(inpal, &ctx->inputs[1]->out_formats)) < 0 ||
-(ret = ff_formats_ref(out  , &ctx->outputs[0]->in_formats)) < 0)
+if ((ret = ff_formats_ref(ff_make_format_list(in_fmts),
+  &ctx->inputs[0]->out_formats)) < 0 ||
+(ret = ff_formats_ref(ff_make_format_list(inpal_fmts),
+  &ctx->inputs[1]->out_formats)) < 0 ||
+(ret = ff_formats_ref(ff_make_format_list(out_fmts),
+  &ctx->outputs[0]->in_formats)) < 0)
 return ret;
 return 0;
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 11/21] avfilter/af_amix: Fix double-free of AVFilterChannelLayouts on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the amix filter tries to allocate a list
of channel layouts which are attached to more permanent objects
(an AVFilter's links) for storage afterwards on success. If attaching
a list to a link succeeds, the link becomes one of the common owners
of the list. Yet if a list has been successfully attached to links (or if
there were no links to attach it to in which case
ff_set_common_channel_layouts() already frees the list) and an error
happens lateron, the list was manually freed, which is wrong, because
the list has either already been freed or it is owned by its links in
which case these links' pointers to their list will become dangling and
there will be double-frees/uses-after-free when these links are cleaned
up automatically.

This commit fixes this by removing the custom freeing code; this is made
possible by using the list in ff_set_common_channel_layouts() directly
after its allocation (without anything that can fail in between).

Notice that ff_set_common_channel_layouts() is buggy itself which can
lead to double-frees on error. This is not fixed in this commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_amix.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 6a4ef8d944..cae9d4585a 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -593,25 +593,13 @@ static int query_formats(AVFilterContext *ctx)
 AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
 AV_SAMPLE_FMT_NONE
 };
-AVFilterChannelLayouts *layouts;
 int ret;
 
-layouts = ff_all_channel_counts();
-if (!layouts) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-
 if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 
0 ||
-(ret = ff_set_common_channel_layouts(ctx, layouts))  < 0 ||
 (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
-goto fail;
-return 0;
-fail:
-if (layouts)
-av_freep(&layouts->channel_layouts);
-av_freep(&layouts);
-return ret;
+return ret;
+
+return ff_set_common_channel_layouts(ctx, ff_all_channel_counts());
 }
 
 static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 10/21] avfilter/af_amix: Don't needlessly reallocate table

2020-08-09 Thread Andreas Rheinhardt
Replace using ff_add_format() repeatedly by a single call to
ff_make_format_list(). (Right now this also fixes a memleak: If the
first ff_add_format() succeeds and a subsequent call fails, the list
leaks.)

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_amix.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 0826fc118c..6a4ef8d944 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx)
 
 static int query_formats(AVFilterContext *ctx)
 {
-AVFilterFormats *formats = NULL;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
+AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
+AV_SAMPLE_FMT_NONE
+};
 AVFilterChannelLayouts *layouts;
 int ret;
 
@@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx)
 goto fail;
 }
 
-if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT ))  < 0 ||
-(ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP))  < 0 ||
-(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL ))  < 0 ||
-(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP))  < 0 ||
-(ret = ff_set_common_formats(ctx, formats))  < 0 ||
+if ((ret = ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))) < 
0 ||
 (ret = ff_set_common_channel_layouts(ctx, layouts))  < 0 ||
 (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
 goto fail;
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 17/21] avfilter/formats: Fix double frees and memleaks on error

2020-08-09 Thread Andreas Rheinhardt
The formats API deals with lists of channel layouts, sample rates,
pixel formats and sample formats. These lists are refcounted in a way in
which the list structure itself contains pointers to all of its owners.
Furthermore, it is possible for a list to be not owned by anyone yet;
this status is temporary until the list has been attached to an owner.
Adding an owner to a list involves reallocating the list's list of
owners and can therefore fail.

In order to reduce the amount of checks and cleanup code for the users
of this API, the API is supposed to be lenient when faced with input
lists that are NULL and it is supposed to clean up if adding an owner
to a list fails, so that a simple use case like

list = ff_make_format_list(foo_fmts);
if ((ret = ff_formats_ref(list, &ctx->inputs[0]->out_formats)) < 0)
return ret;

needn't check whether list could be successfully allocated
(ff_formats_ref() return AVERROR(ENOMEM) if it couldn't) and it also
needn't free list if ff_formats_ref() couldn't add an owner for it.

But the cleaning up after itself was broken. The root cause was that
the refcount was decremented during unreferencing whether or not the
element to be unreferenced was actually an owner of the list or not.
This means that if the above sample code is continued by

if ((ret = ff_formats_ref(list, &ctx->inputs[1]->out_formats)) < 0)
return ret;

and that if an error happens at the second ff_formats_ref() call, the
automatic cleaning of list will decrement the refcount from 1 (the sole
owner of list at this moment is ctx->input[0]->out_formats) to 0 and so
the list will be freed; yet ctx->input[0]->out_formats still points to
the list and this will lead to a double free/use-after-free when
ctx->input[0] is freed later.

Presumably in order to work around such an issue, commit
93afb338a405eac0f9e7b092bc26603378bfcca6 restricted unreferencing to
lists with owners. This does not solve the root cause (the above example
is not fixed by this) at all, but it solves some crashs.

This commit fixes the API: The list's refcount is only decremented if
an owner is removed from the list of owners and not if the
unref-function is called with a pointer that is not among the owners of
the list. Furtermore, the requirement for the list to have owners is
dropped.

This implies that if the first call to ff_formats_ref() in the above
example fails, the refcount which is initially zero during unreferencing
is not modified, so that the list will be freed automatically in said
call to ff_formats_ref() as every list whose refcount reaches zero is.

If on the other hand, the second call to ff_formats_ref() is the first
to fail, the refcount would stay at one during the automatic
unreferencing in ff_formats_ref(). The list would later be freed when
its last (and in this case sole) owner (namely
ctx->inputs[0]->out_formats) gets unreferenced.

The issues described here for ff_formats_ref() also affected the other
functions of this API. E.g. ff_add_format() failed to clean up after
itself if adding an entry to an already existing list failed (the case
of a freshly allocated list was handled specially and this commit also
removes said code). E.g. ff_all_formats() inherited the flaw.

Signed-off-by: Andreas Rheinhardt 
---
The count variable in SET_COMMON_FORMATS is now btw unnecessary; it
would be safe to always unref fmt in this macro (which does nothing
except when fmt has no owner in which case it frees fmt). 

 libavfilter/formats.c | 32 ++--
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 3118aa0925..2379be1518 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -327,7 +327,6 @@ AVFilterChannelLayouts *avfilter_make_format64_list(const 
int64_t *fmts)
 #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb)\
 do {\
 type *fmts; \
-void *oldf = *f;\
 \
 if (!(*f) && !(*f = av_mallocz(sizeof(**f { \
 return AVERROR(ENOMEM); \
@@ -337,8 +336,6 @@ do {
\
 sizeof(*(*f)->list));   \
 if (!fmts) {\
 unref_fn(f);\
-if (!oldf)  \
-av_freep(f);\
 return AVERROR(ENOMEM); \
 }   \
 \
@@ -499,16 +496,17 @@ do {\
 do {   \
 int idx =

[FFmpeg-devel] [PATCH 12/21] avfilter/vf_showpalette: Fix double-free of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the showpalette filter tries to allocate
two lists of formats which on success are attached to more permanent objects
(AVFilterLinks) for storage afterwards. If attaching a list to an
AVFilterLink succeeds, the link becomes one (in this case the only one)
of the owners of the list. Yet if attaching the first list to its link
succeeds and attaching the second list fails, both lists were manually
freed, which means that the first link's pointer to the first list
becomes dangling and there will be a double-free when the first link is
cleaned up automatically.

This commit fixes this by removing the custom free code; this will
temporarily add a leaking codepath (if attaching a list to a link fails,
the list will leak), but this will be fixed shortly by making sure that
an AVFilterFormats without owner will be automatically freed when
attaching it to an AVFilterLink fails. Notice at most one list leaks
because as of this commit a new list is only allocated after the old list
has been successfully attached to a link.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_showpalette.c | 25 ++---
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_showpalette.c b/libavfilter/vf_showpalette.c
index f715d6bc2c..c32dbd5b5d 100644
--- a/libavfilter/vf_showpalette.c
+++ b/libavfilter/vf_showpalette.c
@@ -46,26 +46,13 @@ static int query_formats(AVFilterContext *ctx)
 {
 static const enum AVPixelFormat in_fmts[]  = {AV_PIX_FMT_PAL8,  
AV_PIX_FMT_NONE};
 static const enum AVPixelFormat out_fmts[] = {AV_PIX_FMT_RGB32, 
AV_PIX_FMT_NONE};
-int ret;
-AVFilterFormats *in  = ff_make_format_list(in_fmts);
-AVFilterFormats *out = ff_make_format_list(out_fmts);
-if (!in || !out) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+int ret = ff_formats_ref(ff_make_format_list(in_fmts),
+ &ctx->inputs[0]->out_formats);
+if (ret < 0)
+return ret;
 
-if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 ||
-(ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0)
-goto fail;
-return 0;
-fail:
-if (in)
-av_freep(&in->formats);
-av_freep(&in);
-if (out)
-av_freep(&out->formats);
-av_freep(&out);
-return ret;
+return ff_formats_ref(ff_make_format_list(out_fmts),
+  &ctx->outputs[0]->in_formats);
 }
 
 static int config_output(AVFilterLink *outlink)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 13/21] avfilter/vf_remap: Fix double-free of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the remap filter tries to allocate
two lists of formats which on success are attached to more permanent objects
(AVFilterLinks) for storage afterwards. If attaching a list to an
AVFilterLink succeeds, it is in turn owned by the AVFilterLink (or more
exactly, the AVFilterLink becomes one of the common owners of the list).
Yet if attaching a list to one of its links succeeds and an error happens
lateron, both lists were manually freed, which means that is wrong if the
list is already owned by one or more links; these links' pointers to
their lists will become dangling and there will be a double-free/use-after-
free when these links are cleaned up automatically.

This commit fixes this by removing the custom free code; this will
temporarily add a leaking codepath (if attaching a list not already
owned by a link to a link fails, the list will leak), but this will
be fixed soon by making sure that an AVFilterFormats without owner will
be automatically freed when attaching it to an AVFilterLink fails.
Notice at most one list leaks because a new list is only allocated
after the old list has been successfully attached to a link.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_remap.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c
index 6d5d75225b..41a2409f21 100644
--- a/libavfilter/vf_remap.c
+++ b/libavfilter/vf_remap.c
@@ -115,25 +115,15 @@ static int query_formats(AVFilterContext *ctx)
 AVFilterFormats *pix_formats = NULL, *map_formats = NULL;
 int ret;
 
-if (!(pix_formats = ff_make_format_list(s->format ? gray_pix_fmts : 
pix_fmts)) ||
-!(map_formats = ff_make_format_list(map_fmts))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+pix_formats = ff_make_format_list(s->format ? gray_pix_fmts : pix_fmts);
 if ((ret = ff_formats_ref(pix_formats, &ctx->inputs[0]->out_formats)) < 0 
||
-(ret = ff_formats_ref(map_formats, &ctx->inputs[1]->out_formats)) < 0 
||
-(ret = ff_formats_ref(map_formats, &ctx->inputs[2]->out_formats)) < 0 
||
 (ret = ff_formats_ref(pix_formats, &ctx->outputs[0]->in_formats)) < 0)
-goto fail;
-return 0;
-fail:
-if (pix_formats)
-av_freep(&pix_formats->formats);
-av_freep(&pix_formats);
-if (map_formats)
-av_freep(&map_formats->formats);
-av_freep(&map_formats);
-return ret;
+return ret;
+
+map_formats = ff_make_format_list(map_fmts);
+if ((ret = ff_formats_ref(map_formats, &ctx->inputs[1]->out_formats)) < 0)
+return ret;
+return ff_formats_ref(map_formats, &ctx->inputs[2]->out_formats);
 }
 
 /**
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 18/21] avfilter/vf_hwdownload: Fix leak of formats list upon error

2020-08-09 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_hwdownload.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_hwdownload.c b/libavfilter/vf_hwdownload.c
index 33af30cf40..ce10b60e59 100644
--- a/libavfilter/vf_hwdownload.c
+++ b/libavfilter/vf_hwdownload.c
@@ -55,11 +55,11 @@ static int hwdownload_query_formats(AVFilterContext *avctx)
 }
 }
 
-if ((err = ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats)) < 0 ||
-(err = ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats)) < 0)
+if ((err = ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats)) < 0) {
+ff_formats_unref(&outfmts);
 return err;
-
-return 0;
+}
+return ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);
 }
 
 static int hwdownload_config_input(AVFilterLink *inlink)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 14/21] avfilter/vf_overlay: Fix double-free of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the overlay filter tries to allocate
two lists (only one in a special case) of formats which on success
are attached to more permanent objects (AVFilterLinks) for storage
afterwards. If attaching a list to an AVFilterLink succeeds, it is
in turn owned by the AVFilterLink (or more exactly, the AVFilterLink
becomes one of the common owners of the list). Yet if attaching a list
to one of its links succeeds and an error happens lateron, both lists
were manually freed, whic is wrong if the list is already owned by one
or more links; these links' pointers to their lists will become dangling
and there will be a double-free/use-after-free when these links are
cleaned up automatically.

This commit fixes this by removing the custom freeing code; this will
temporarily add a leaking codepath (if attaching a list not already
owned by a link to a link fails, the list will leak), but this will
be fixed soon by making sure that an AVFilterFormats without owner will
be automatically freed when attaching it to an AVFilterLink fails.
Notice that at most one list leaks because a new list is only allocated
after the old list has been successfully attached to a link.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_overlay.c | 84 +++-
 1 file changed, 23 insertions(+), 61 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index b3a1ac1a09..324738635d 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -221,90 +221,52 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 
-AVFilterFormats *main_formats = NULL;
-AVFilterFormats *overlay_formats = NULL;
+const enum AVPixelFormat *main_formats, *overlay_formats;
+AVFilterFormats *formats;
 int ret;
 
 switch (s->format) {
 case OVERLAY_FORMAT_YUV420:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv420)) ||
-!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv420))) 
{
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_yuv420;
+overlay_formats = overlay_pix_fmts_yuv420;
 break;
 case OVERLAY_FORMAT_YUV420P10:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv420p10)) 
||
-!(overlay_formats = 
ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_yuv420p10;
+overlay_formats = overlay_pix_fmts_yuv420p10;
 break;
 case OVERLAY_FORMAT_YUV422:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422)) ||
-!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422))) 
{
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_yuv422;
+overlay_formats = overlay_pix_fmts_yuv422;
 break;
 case OVERLAY_FORMAT_YUV422P10:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422p10)) 
||
-!(overlay_formats = 
ff_make_format_list(overlay_pix_fmts_yuv422p10))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_yuv422p10;
+overlay_formats = overlay_pix_fmts_yuv422p10;
 break;
 case OVERLAY_FORMAT_YUV444:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv444)) ||
-!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444))) 
{
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_yuv444;
+overlay_formats = overlay_pix_fmts_yuv444;
 break;
 case OVERLAY_FORMAT_RGB:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_rgb)) ||
-!(overlay_formats = ff_make_format_list(overlay_pix_fmts_rgb))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_rgb;
+overlay_formats = overlay_pix_fmts_rgb;
 break;
 case OVERLAY_FORMAT_GBRP:
-if (!(main_formats= ff_make_format_list(main_pix_fmts_gbrp)) ||
-!(overlay_formats = ff_make_format_list(overlay_pix_fmts_gbrp))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+main_formats= main_pix_fmts_gbrp;
+overlay_formats = overlay_pix_fmts_gbrp;
 break;
 case OVERLAY_FORMAT_AUTO:
-if (!(main_formats= ff_make_format_list(alpha_pix_fmts))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-break;
+return ff_set_common_formats(ctx, ff_make_format_list(alpha_pix_fmts));
 default:
 av_assert0(0);
 }
 
-if (s->format == OVERLAY_FORMAT_AUTO) {
-ret =

[FFmpeg-devel] [PATCH 15/21] avfilter/vf_alphamerge: Fix double-free of AVFilterFormats on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the alphamerge filter tries to allocate
two lists of formats which on success are attached to more permanent
objects (AVFilterLinks) for storage afterwards. If attaching a list
to an AVFilterLink succeeds, the link becomes one of the owners of
the list. Yet if attaching a list to one of its links succeeds and
an error happens lateron, both lists were manually freed, which is wrong
if the list is already owned by one or more links; these links' pointers
to their lists will become dangling and there will be a double-free/use-
after-free when these links are cleaned up automatically.

This commit fixes this by removing the custom freeing code; this will
temporarily add a leaking codepath (if attaching a list not already
owned by a link to a link fails, the list will leak), but this will
be fixed soon by making sure that an AVFilterFormats without owner will
be automatically freed when attaching it to an AVFilterLink fails.
At most one list leaks because as of this commit a new list is only
allocated after the old list has been successfully attached to a link.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_alphamerge.c | 26 +++---
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c
index 85b6d9b61a..a509f10103 100644
--- a/libavfilter/vf_alphamerge.c
+++ b/libavfilter/vf_alphamerge.c
@@ -55,27 +55,15 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_NONE
 };
 static const enum AVPixelFormat alpha_fmts[] = { AV_PIX_FMT_GRAY8, 
AV_PIX_FMT_NONE };
-AVFilterFormats *main_formats = NULL, *alpha_formats = NULL;
+AVFilterFormats *main_formats = ff_make_format_list(main_fmts);
 int ret;
 
-if (!(main_formats = ff_make_format_list(main_fmts)) ||
-!(alpha_formats = ff_make_format_list(alpha_fmts))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-if ((ret = ff_formats_ref(main_formats , &ctx->inputs[0]->out_formats)) < 
0 ||
-(ret = ff_formats_ref(alpha_formats, &ctx->inputs[1]->out_formats)) < 
0 ||
-(ret = ff_formats_ref(main_formats , &ctx->outputs[0]->in_formats)) < 
0)
-goto fail;
-return 0;
-fail:
-if (main_formats)
-av_freep(&main_formats->formats);
-av_freep(&main_formats);
-if (alpha_formats)
-av_freep(&alpha_formats->formats);
-av_freep(&alpha_formats);
-return ret;
+if ((ret = ff_formats_ref(main_formats, &ctx->inputs[0]->out_formats)) < 0 
||
+(ret = ff_formats_ref(main_formats, &ctx->outputs[0]->in_formats)) < 0)
+return ret;
+
+return ff_formats_ref(ff_make_format_list(alpha_fmts),
+  &ctx->inputs[1]->out_formats);
 }
 
 static int config_input_main(AVFilterLink *inlink)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 19/21] avfilter: Remove redundant ff_formats/channel_layouts_unref()

2020-08-09 Thread Andreas Rheinhardt
ff_add_format() and ff_add_channel_layout() already unref the list upon
error.

Signed-off-by: Andreas Rheinhardt 
---
These ff_formats/channel_layouts_unref() also didn't do anything before
this patchset, as none of these lists has any owner.

 libavfilter/af_aformat.c   | 9 -
 libavfilter/vf_shuffleplanes.c | 1 -
 libavfilter/vf_weave.c | 1 -
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 1a702778c3..0ea470014c 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -60,7 +60,7 @@ static const AVOption aformat_options[] = {
 
 AVFILTER_DEFINE_CLASS(aformat);
 
-#define PARSE_FORMATS(str, type, list, add_to_list, unref_fn, get_fmt, none, 
desc)\
+#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)\
 do {\
 char *next, *cur = str, sep;\
 int ret;\
@@ -83,7 +83,6 @@ do {  
  \
 return AVERROR(EINVAL); \
 }   \
 if ((ret = add_to_list(&list, fmt)) < 0) {  \
-unref_fn(&list);\
 return ret; \
 }   \
 \
@@ -102,11 +101,11 @@ static av_cold int init(AVFilterContext *ctx)
 AFormatContext *s = ctx->priv;
 
 PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
-  ff_add_format, ff_formats_unref, av_get_sample_fmt, 
AV_SAMPLE_FMT_NONE, "sample format");
-PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, 
ff_formats_unref,
+  ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, 
"sample format");
+PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format,
   get_sample_rate, 0, "sample rate");
 PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts,
-  ff_add_channel_layout, ff_channel_layouts_unref, 
av_get_channel_layout, 0,
+  ff_add_channel_layout, av_get_channel_layout, 0,
   "channel layout");
 
 return 0;
diff --git a/libavfilter/vf_shuffleplanes.c b/libavfilter/vf_shuffleplanes.c
index 6c718893ce..c5a376d50b 100644
--- a/libavfilter/vf_shuffleplanes.c
+++ b/libavfilter/vf_shuffleplanes.c
@@ -64,7 +64,6 @@ static int query_formats(AVFilterContext *ctx)
 if (i != 4)
 continue;
 if ((ret = ff_add_format(&formats, fmt)) < 0) {
-ff_formats_unref(&formats);
 return ret;
 }
 }
diff --git a/libavfilter/vf_weave.c b/libavfilter/vf_weave.c
index 8951b09095..8d4eb3d5a4 100644
--- a/libavfilter/vf_weave.c
+++ b/libavfilter/vf_weave.c
@@ -60,7 +60,6 @@ static int query_formats(AVFilterContext *ctx)
 if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) &&
 !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
 if ((ret = ff_add_format(&formats, fmt)) < 0) {
-ff_formats_unref(&formats);
 return ret;
 }
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 21/21] avfilter/af_aformat: Add uninit function

2020-08-09 Thread Andreas Rheinhardt
Fixes memleaks in case init fails (e.g. because of invalid parameters
like 'aformat=sample_fmts=s16:cl=wtf') or also if query_formats is never
called.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_aformat.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 0ea470014c..e669f2de83 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -111,6 +111,15 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
+static av_cold void uninit(AVFilterContext *ctx)
+{
+AFormatContext *s = ctx->priv;
+
+ff_formats_unref(&s->formats);
+ff_formats_unref(&s->sample_rates);
+ff_channel_layouts_unref(&s->channel_layouts);
+}
+
 static int query_formats(AVFilterContext *ctx)
 {
 AFormatContext *s = ctx->priv;
@@ -118,14 +127,18 @@ static int query_formats(AVFilterContext *ctx)
 
 ret = ff_set_common_formats(ctx, s->formats ? s->formats :
 
ff_all_formats(AVMEDIA_TYPE_AUDIO));
+s->formats = NULL;
 if (ret < 0)
 return ret;
 ret = ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates :
  ff_all_samplerates());
+s->sample_rates = NULL;
 if (ret < 0)
 return ret;
-return ff_set_common_channel_layouts(ctx, s->channel_layouts ? 
s->channel_layouts :
+ret = ff_set_common_channel_layouts(ctx, s->channel_layouts ? 
s->channel_layouts :
 
ff_all_channel_counts());
+s->channel_layouts = NULL;
+return ret;
 }
 
 static const AVFilterPad avfilter_af_aformat_inputs[] = {
@@ -148,6 +161,7 @@ AVFilter ff_af_aformat = {
 .name  = "aformat",
 .description   = NULL_IF_CONFIG_SMALL("Convert the input audio to one of 
the specified formats."),
 .init  = init,
+.uninit= uninit,
 .query_formats = query_formats,
 .priv_size = sizeof(AFormatContext),
 .priv_class= &aformat_class,
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 20/21] avfilter/avfiltergraph: Remove unused macro parameter

2020-08-09 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfiltergraph.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index a149f8fb6d..681c519ef0 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -748,7 +748,7 @@ static int pick_format(AVFilterLink *link, AVFilterLink 
*ref)
 return 0;
 }
 
-#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format, 
unref_format) \
+#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
 do {   \
 for (i = 0; i < filter->nb_inputs; i++) {  \
 AVFilterLink *link = filter->inputs[i];\
@@ -790,9 +790,9 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
 int i, j, k, ret = 0;
 
 REDUCE_FORMATS(int,  AVFilterFormats,formats, formats,
-   nb_formats, ff_add_format, ff_formats_unref);
+   nb_formats, ff_add_format);
 REDUCE_FORMATS(int,  AVFilterFormats,samplerates, formats,
-   nb_formats, ff_add_format, ff_formats_unref);
+   nb_formats, ff_add_format);
 
 /* reduce channel layouts */
 for (i = 0; i < filter->nb_inputs; i++) {
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 16/21] avfilter/af_channelmap: Fix double-free of AVFilterChannelLayouts on error

2020-08-09 Thread Andreas Rheinhardt
The query_formats function of the channelmap filter tries to allocate
a list of channel layouts which on success are attached to more permanent
objects (an AVFilterLink) for storage afterwards. If attaching succeeds,
the link becomes one of the common owners (in this case, the only owner)
of the list. Yet if the list has been successfully attached to the link
and an error happens lateron, the list was manually freed, which is wrong,
because it is owned by its link so that the link's pointer to the list will
become dangling and there will be a double-free/use-after-free when the link
is later cleaned up automatically.

This commit fixes this by removing the custom freeing code; this will
temporarily add a leaking codepath (if attaching the list fails, the list
will leak), but this will be fixed soon by making sure that an
AVFilterChannelLayouts without owner will be automatically freed when
attaching it to an AVFilterLink fails.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_channelmap.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 285d76a3ef..1f79f89ce3 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -280,28 +280,18 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 static int channelmap_query_formats(AVFilterContext *ctx)
 {
 ChannelMapContext *s = ctx->priv;
-AVFilterChannelLayouts *layouts;
 AVFilterChannelLayouts *channel_layouts = NULL;
 int ret;
 
-layouts = ff_all_channel_counts();
-if (!layouts) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-if ((ret = ff_add_channel_layout (&channel_layouts, s->output_layout   
 )) < 0 ||
-(ret = ff_set_common_formats (ctx , 
ff_planar_sample_fmts() )) < 0 ||
+if ((ret = ff_set_common_formats(ctx,  ff_planar_sample_fmts()))  < 0 
||
 (ret = ff_set_common_samplerates (ctx , 
ff_all_samplerates())) < 0 ||
-(ret = ff_channel_layouts_ref(layouts , 
&ctx->inputs[0]->out_channel_layouts)) < 0 ||
-(ret = ff_channel_layouts_ref(channel_layouts , 
&ctx->outputs[0]->in_channel_layouts)) < 0)
-goto fail;
+(ret = ff_add_channel_layout(&channel_layouts, s->output_layout)) < 0 
||
+(ret = ff_channel_layouts_ref(channel_layouts,
+  &ctx->outputs[0]->in_channel_layouts)) < 
0)
+return ret;
 
-return 0;
-fail:
-if (layouts)
-av_freep(&layouts->channel_layouts);
-av_freep(&layouts);
-return ret;
+return ff_channel_layouts_ref(ff_all_channel_counts(),
+  &ctx->inputs[0]->out_channel_layouts);
 }
 
 static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH V7 1/2] dnn/native: add native support for avg_pool

2020-08-09 Thread Ting Fu
Not support pooling strides in channel dimension yet.

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/Makefile  |   1 +
 libavfilter/dnn/dnn_backend_native.h  |   2 +
 .../dnn/dnn_backend_native_layer_avgpool.c| 141 ++
 .../dnn/dnn_backend_native_layer_avgpool.h|  40 +
 .../dnn/dnn_backend_native_layer_conv2d.h |   3 +-
 libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
 tools/python/convert_from_tensorflow.py   |  37 -
 7 files changed, 223 insertions(+), 3 deletions(-)
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.c
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.h

diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index d90137ec42..e0957073ee 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -1,6 +1,7 @@
 OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native_layers.o
+OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_avgpool.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_pad.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_conv2d.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_depth2space.o
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 62191ffe88..26e9a33387 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -43,10 +43,12 @@ typedef enum {
 DLT_MAXIMUM = 4,
 DLT_MATH_BINARY = 5,
 DLT_MATH_UNARY = 6,
+DLT_AVG_POOL = 7,
 DLT_COUNT
 } DNNLayerType;
 
 typedef enum {DOT_INPUT = 1, DOT_OUTPUT = 2, DOT_INTERMEDIATE = DOT_INPUT | 
DOT_OUTPUT} DNNOperandType;
+typedef enum {VALID, SAME, SAME_CLAMP_TO_EDGE} DNNPaddingParam;
 
 typedef struct Layer{
 DNNLayerType type;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c 
b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
new file mode 100644
index 00..d745c35b4a
--- /dev/null
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2020
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * DNN native backend implementation.
+ */
+
+#include "libavutil/avassert.h"
+#include "dnn_backend_native_layer_avgpool.h"
+
+int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
+{
+AvgPoolParams *avgpool_params;
+int dnn_size = 0;
+avgpool_params = av_malloc(sizeof(*avgpool_params));
+if(!avgpool_params)
+return 0;
+
+avgpool_params->strides = (int32_t)avio_rl32(model_file_context);
+avgpool_params->padding_method = (int32_t)avio_rl32(model_file_context);
+avgpool_params->kernel_size = (int32_t)avio_rl32(model_file_context);
+dnn_size += 12;
+
+if (dnn_size > file_size || avgpool_params->kernel_size <= 0 || 
avgpool_params->strides <=0){
+av_freep(&avgpool_params);
+return 0;
+}
+
+layer->params = avgpool_params;
+layer->input_operand_indexes[0] = (int32_t)avio_rl32(model_file_context);
+layer->output_operand_index = (int32_t)avio_rl32(model_file_context);
+dnn_size += 8;
+
+if (layer->input_operand_indexes[0] >= operands_num || 
layer->output_operand_index >= operands_num) {
+return 0;
+}
+return dnn_size;
+}
+
+int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t 
*input_operand_indexes,
+ int32_t output_operand_index, const void 
*parameters)
+{
+float *output;
+int height_end, width_end, height_radius, width_radius, output_height, 
output_width, kernel_area;
+int32_t input_operand_index = input_operand_indexes[0];
+int number = operands[input_operand_index].dims[0];
+int height = operands[input_operand_index].dims[1];
+int width = operands[input_operand_index].dims[2];
+int channel = operands[input_operand_index].dims[3];
+const float *input = operands[input_operand_index].data;
+const AvgPoolParams *avg

[FFmpeg-devel] [PATCH V7 2/2] FATE/dnn: add unit test for dnn avgpool layer

2020-08-09 Thread Ting Fu
'make fate-dnn-layer-avgpool' to run the test

Signed-off-by: Ting Fu 
---
 tests/dnn/.gitignore   |   1 +
 tests/dnn/Makefile |   1 +
 tests/dnn/dnn-layer-avgpool-test.c | 197 +
 tests/fate/dnn.mak |   5 +
 4 files changed, 204 insertions(+)
 create mode 100644 tests/dnn/dnn-layer-avgpool-test.c

diff --git a/tests/dnn/.gitignore b/tests/dnn/.gitignore
index 1fcd2410b4..b847a01177 100644
--- a/tests/dnn/.gitignore
+++ b/tests/dnn/.gitignore
@@ -4,3 +4,4 @@
 /dnn-layer-pad-test
 /dnn-layer-mathbinary-test
 /dnn-layer-mathunary-test
+/dnn-layer-avgpool-test
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index 64591b7851..8afdfab5d3 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -4,6 +4,7 @@ DNNTESTPROGS += dnn-layer-depth2space
 DNNTESTPROGS += dnn-layer-mathbinary
 DNNTESTPROGS += dnn-layer-maximum
 DNNTESTPROGS += dnn-layer-mathunary
+DNNTESTPROGS += dnn-layer-avgpool
 
 DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
 DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
diff --git a/tests/dnn/dnn-layer-avgpool-test.c 
b/tests/dnn/dnn-layer-avgpool-test.c
new file mode 100644
index 00..d7c33a0e88
--- /dev/null
+++ b/tests/dnn/dnn-layer-avgpool-test.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2020
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavfilter/dnn/dnn_backend_native_layer_avgpool.h"
+
+#define EPSON 0.1
+
+static int test_with_same(void)
+{
+// the input data and expected data are generated with below python code.
+/*
+import tensorflow as tf
+import numpy as np
+
+x = tf.placeholder(tf.float32, shape=[1, None, None, 3])
+y = tf.layers.average_pooling2d(x, pool_size=[2,2], strides=[1,1], 
padding='VALID')
+data = np.random.rand(1, 5, 6, 3);
+
+sess=tf.Session()
+sess.run(tf.global_variables_initializer())
+
+output = sess.run(y, feed_dict={x: data})
+
+print("input:")
+print(data.shape)
+print(list(data.flatten()))
+
+print("output:")
+print(output.shape)
+print(list(output.flatten()))
+*/
+
+AvgPoolParams params;
+DnnOperand operands[2];
+int32_t input_indexes[1];
+float input[1*5*6*3] = {
+0.7461309859908424, 0.7567538372797069, 0.07662743569678687, 
0.8882112610336333, 0.9720443314026668, 0.3337200343220823, 0.4421032129780248,
+0.14940809044964876, 0.6773177061961277, 0.9778844630669781, 
0.6522650522626998, 0.0317651530878591, 0.31259897552911364, 0.6235936821891896,
+0.40016094349542775, 0.4599222930032276, 0.7893807222960093, 
0.8475986363538283, 0.5058802717647394, 0.7827005363222633, 0.3032188123727916,
+0.8983728631302361, 0.20622408444965523, 0.22966072303869878, 
0.09535751273161308, 0.8760709100995375, 0.9982324154558745, 0.7904595468621013,
+0.13883671508879347, 0.9332751439533138, 0.0010861680752152214, 
0.3607210449251048, 0.6600652759586171, 0.7629572058138805, 0.29441975810476106,
+0.2683471432889405, 0.22574580829831536, 0.8893251976212904, 
0.3907737043801005, 0.6421829842863968, 0.6670373870457297, 0.9383850793160277,
+0.4120458907436003, 0.3589847212711481, 0.48047736550128983, 
0.6428192648418949, 0.0313661686292348, 0.429357100401472, 0.5123413386514056,
+0.8492446404097114, 0.9045286128486804, 0.8123708563814285, 
0.3943245008451698, 0.9576713003177785, 0.5985610965938726, 0.9350833279543561,
+0.8010079897491659, 0.45882114217642866, 0.35275037908941487, 
0.4555844661432271, 0.12352455940255314, 0.37801756635035544, 
0.2824056214573083,
+0.6229462823245029, 0.7235305681391472, 0.5408259266122064, 
0.12142224381781208, 0.34431198802873686, 0.7112823816321276, 
0.6307144385115417,
+0.8136734589018082, 0.842095618140585, 0.8602767724004784, 
0.6649236853766185, 0.5184782829419623, 0.9119607270982825, 0.3084111974561645,
+0.39460705638161364, 0.17710447526170836, 0.1715485945814199, 
0.17277563576521882, 0.40188232428735704, 0.22847985411491878, 
0.4135361701550696,
+0.24621846601980057, 0.6576588108454774, 0.6063336087333997, 
0.6452342242996931, 0.7071689702737508, 0.1973416063225648
+};

Re: [FFmpeg-devel] [PATCH 10/21] avfilter/af_amix: Don't needlessly reallocate table

2020-08-09 Thread Paul B Mahol
LGTM

On 8/9/20, Andreas Rheinhardt  wrote:
> Replace using ff_add_format() repeatedly by a single call to
> ff_make_format_list(). (Right now this also fixes a memleak: If the
> first ff_add_format() succeeds and a subsequent call fails, the list
> leaks.)
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/af_amix.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
> index 0826fc118c..6a4ef8d944 100644
> --- a/libavfilter/af_amix.c
> +++ b/libavfilter/af_amix.c
> @@ -588,7 +588,11 @@ static av_cold void uninit(AVFilterContext *ctx)
>
>  static int query_formats(AVFilterContext *ctx)
>  {
> -AVFilterFormats *formats = NULL;
> +static const enum AVSampleFormat sample_fmts[] = {
> +AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
> +AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
> +AV_SAMPLE_FMT_NONE
> +};
>  AVFilterChannelLayouts *layouts;
>  int ret;
>
> @@ -598,11 +602,7 @@ static int query_formats(AVFilterContext *ctx)
>  goto fail;
>  }
>
> -if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT ))  < 0 ||
> -(ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP))  < 0 ||
> -(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBL ))  < 0 ||
> -(ret = ff_add_format(&formats, AV_SAMPLE_FMT_DBLP))  < 0 ||
> -(ret = ff_set_common_formats(ctx, formats))  < 0 ||
> +if ((ret = ff_set_common_formats(ctx,
> ff_make_format_list(sample_fmts))) < 0 ||
>  (ret = ff_set_common_channel_layouts(ctx, layouts))  < 0 ||
>  (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
>  goto fail;
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 19/21] avfilter: Remove redundant ff_formats/channel_layouts_unref()

2020-08-09 Thread Nicolas George
Andreas Rheinhardt (12020-08-09):
> ff_add_format() and ff_add_channel_layout() already unref the list upon
> error.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> These ff_formats/channel_layouts_unref() also didn't do anything before
> this patchset, as none of these lists has any owner.

LGTM, good catch.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 20/21] avfilter/avfiltergraph: Remove unused macro parameter

2020-08-09 Thread Nicolas George
Andreas Rheinhardt (12020-08-09):
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/avfiltergraph.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Ok, of course. Thanks.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 21/21] avfilter/af_aformat: Add uninit function

2020-08-09 Thread Nicolas George
Andreas Rheinhardt (12020-08-09):
> Fixes memleaks in case init fails (e.g. because of invalid parameters
> like 'aformat=sample_fmts=s16:cl=wtf') or also if query_formats is never
> called.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/af_aformat.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)

LGTM.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH] avcodec/cfhd: prepare for SIMD addition

2020-08-09 Thread Paul B Mahol
Hi,

patch attached.


0001-avcodec-cfhd-prepare-for-SIMD-addition.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: prepare for SIMD addition

2020-08-09 Thread James Almer
On 8/9/2020 1:57 PM, Paul B Mahol wrote:
> Hi,
> 
> patch attached.

[...]

>  libavcodec/Makefile |  2 +-
>  libavcodec/cfhd.c   | 60 +++-
>  libavcodec/cfhd.h   |  3 ++
>  libavcodec/cfhddsp.c| 62 ++
>  libavcodec/cfhddsp.h| 34 +
>  libavcodec/cfhdfilter.h | 67 +
>  6 files changed, 185 insertions(+), 43 deletions(-)
>  create mode 100644 libavcodec/cfhddsp.c
>  create mode 100644 libavcodec/cfhddsp.h
>  create mode 100644 libavcodec/cfhdfilter.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index fc4294816e..26038e96d3 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -254,7 +254,7 @@ OBJS-$(CONFIG_CCAPTION_DECODER)+= ccaption_dec.o 
> ass.o
>  OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
>  OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
>  OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
> -OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o
> +OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o cfhddsp.o
>  OBJS-$(CONFIG_CFHD_ENCODER)+= cfhdenc.o cfhddata.o
>  OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
>  OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 1d7f964e34..e0503c1fa1 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -190,7 +190,7 @@ static inline void process_bayer(AVFrame *frame, int bpc)
>  }
>  }
>  
> -static inline void filter(int16_t *output, ptrdiff_t out_stride,
> +static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride,

Shouldn't you remove this function and include cfhdfilter.h instead?

>int16_t *low, ptrdiff_t low_stride,
>int16_t *high, ptrdiff_t high_stride,

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: prepare for SIMD addition

2020-08-09 Thread Paul B Mahol
On 8/9/20, James Almer  wrote:
> On 8/9/2020 1:57 PM, Paul B Mahol wrote:
>> Hi,
>>
>> patch attached.
>
> [...]
>
>>  libavcodec/Makefile |  2 +-
>>  libavcodec/cfhd.c   | 60 +++-
>>  libavcodec/cfhd.h   |  3 ++
>>  libavcodec/cfhddsp.c| 62 ++
>>  libavcodec/cfhddsp.h| 34 +
>>  libavcodec/cfhdfilter.h | 67 +
>>  6 files changed, 185 insertions(+), 43 deletions(-)
>>  create mode 100644 libavcodec/cfhddsp.c
>>  create mode 100644 libavcodec/cfhddsp.h
>>  create mode 100644 libavcodec/cfhdfilter.h
>>
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index fc4294816e..26038e96d3 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -254,7 +254,7 @@ OBJS-$(CONFIG_CCAPTION_DECODER)+=
>> ccaption_dec.o ass.o
>>  OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
>>  OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
>>  OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
>> -OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o
>> +OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o cfhddsp.o
>>  OBJS-$(CONFIG_CFHD_ENCODER)+= cfhdenc.o cfhddata.o
>>  OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
>>  OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
>> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
>> index 1d7f964e34..e0503c1fa1 100644
>> --- a/libavcodec/cfhd.c
>> +++ b/libavcodec/cfhd.c
>> @@ -190,7 +190,7 @@ static inline void process_bayer(AVFrame *frame, int
>> bpc)
>>  }
>>  }
>>
>> -static inline void filter(int16_t *output, ptrdiff_t out_stride,
>> +static av_always_inline void filter(int16_t *output, ptrdiff_t
>> out_stride,
>
> Shouldn't you remove this function and include cfhdfilter.h instead?

LOL, yes.

>
>>int16_t *low, ptrdiff_t low_stride,
>>int16_t *high, ptrdiff_t high_stride,
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: prepare for SIMD addition

2020-08-09 Thread Paul B Mahol
On 8/9/20, Paul B Mahol  wrote:
> Hi,
>
> patch attached.
>

Fixed patch attached.


0001-avcodec-cfhd-prepare-for-SIMD-addition.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] lavf/dump: hide a few deprecation warnings.

2020-08-09 Thread Andreas Rheinhardt
Nicolas George:
> Nicolas George (12019-12-08):
>> Signed-off-by: Nicolas George 
>> ---
>>  libavformat/dump.c | 6 ++
>>  1 file changed, 6 insertions(+)
>>
> Ping? Will apply next time I think about it if nobody objects.
> 
> Regards,
> 
Too late. See 202e06870eb4bbc4636aff5f461c1a0654ec2435.

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

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

[FFmpeg-devel] [PATCH] doc/encoders: Add all options for JPEG2000 encoder

2020-08-09 Thread gautamramk
From: Gautam Ramakrishnan 

This patch updates the documentation by adding all options
for JPEG2000 encoder.
---
 doc/encoders.texi | 20 
 1 file changed, 20 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index de0472e225..aaac026709 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1369,6 +1369,26 @@ can be selected with @code{-pred 1}.
 Can be set to either @code{j2k} or @code{jp2} (the default) that
 makes it possible to store non-rgb pix_fmts.
 
+@item tile_width/tile_height
+Allows setting of tile width and height.
+
+@item pred
+Allows setting the DWT type, i.e lossy
+DWT 97 (@code{dwt97int}) or lossless DWT 53 (@code{dwt53}).
+
+@item sop
+Setting this to 1 will make the encoder to use SOP marker at the
+start of every packet. Set to 0 by default.
+
+@item eph
+Setting this to 1 will make the encoder to use the EPH flag at the
+end of every packet header. Set to 0 by default.
+
+@item prog
+Sets the progression order to be used by the encoder.
+Possible values are @code{lrcp}, @code{rlcp}, @code{rpcl},
+@code{pcrl} and @code{cprl}. Set to @code{lrcp} by default.
+
 @end table
 
 @section librav1e
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] doc/encoders: Add all options for JPEG2000 encoder

2020-08-09 Thread Gyan Doshi



On 09-08-2020 11:13 pm, gautamr...@gmail.com wrote:

From: Gautam Ramakrishnan 

This patch updates the documentation by adding all options
for JPEG2000 encoder.
---
  doc/encoders.texi | 20 
  1 file changed, 20 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index de0472e225..aaac026709 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1369,6 +1369,26 @@ can be selected with @code{-pred 1}.
  Can be set to either @code{j2k} or @code{jp2} (the default) that
  makes it possible to store non-rgb pix_fmts.
  
+@item tile_width/tile_height

+Allows setting of tile width and height.


Make these separate items.


+
+@item pred
+Allows setting the DWT type, i.e lossy
+DWT 97 (@code{dwt97int}) or lossless DWT 53 (@code{dwt53}).
+
+@item sop
+Setting this to 1 will make the encoder to use SOP marker at the
+start of every packet. Set to 0 by default.


Not related to this patch, but make these boolean options 
AV_OPT_TYPE_BOOL. It allows users to also set them to string values 
true/false or on/off.



+@item eph
+Setting this to 1 will make the encoder to use the EPH flag at the
+end of every packet header. Set to 0 by default.
+
+@item prog
+Sets the progression order to be used by the encoder.
+Possible values are @code{lrcp}, @code{rlcp}, @code{rpcl},
+@code{pcrl} and @code{cprl}. Set to @code{lrcp} by default.


One value per line, please. Also add option type for each option. See 
Hap encoder entry above this one. Some elaboration will be nice as well 
unless users are expected to know what the differences are between these 
values.


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

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

Re: [FFmpeg-devel] [PATCH v2 1/4] avformat/argo_asf: don't check or probe file version

2020-08-09 Thread Alexander Strasser


Am 9. August 2020 14:33:26 MESZ schrieb Zane van Iperen 
:
>On Sun, 9 Aug 2020 09:29:16 +0200
>"Paul B Mahol"  wrote:
>
>> 
>> This is really bad practice.
>> 
>
>Usually I'd agree. However (and I've just checked this) all file
>versions are identical.
>
>Since this is an Argonaut Games format, I checked the version of all
>the
>ASF files in their most recent games. The only two versions found were
>1.2 and 2.1, both of which are already supported.
>
>Because this format is looong-dead, I see no harm in ignoring file
>version (especially if the muxer allows specifying arbitrary versions).

IMHO ignoring version in read_header might be OK in this case.

Another way would be erroring out and say use ignore_version option. Don't 
think it's necessary here, but would maybe be a bit more honest and we could 
ask for samples at the same time.

Probably more problematic is the part completely removing the check for known 
version from the probe function. Shouldn't that stay?


  Alexander

>I shall update the commit message accordingly.
>
>$ for i in ~/Desktop/staging/asf_music/*/*; do ./asfdump.py $i | jq
>._version; done | sort -u
>"1.2"
>"2.1"
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/options: Add options for inputing HDR10-related metadata

2020-08-09 Thread Andreas Rheinhardt
Kenny McClive:
> Thanks, Andreas. When I fix it, do I submit a patch for this patch or a whole 
> new patch with the combined changes?
> 
The latter.

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

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: add 10-bit RGB support for QSV

2020-08-09 Thread Mark Thompson

On 09/08/2020 06:11, Linjie Fu wrote:

After adding a copy pass through path inside MSDK, x2rgb10 is now
available as an output of VPP.

Command line for CSC:
ffmpeg -hwaccel qsv -v verbose -c:v hevc_qsv -i
 p010.h265 -vf scale_qsv=format=x2rgb10,hwdownload,format=x2rgb10
 -vframes 1 out.yuv

Signed-off-by: Linjie Fu 
---
[1]Issue:
https://github.com/Intel-Media-SDK/MediaSDK/issues/1654
[2]Adding copy passthrou:
https://github.com/AntonGrishin/MediaSDK/commit/20058c0e1dbd521e2571e14f6246c48fea996094
[3]Still in need to be fixed:
https://github.com/Intel-Media-SDK/MediaSDK/pull/2268

This patch would be ready to merge after [3] is handled decently.

  libavutil/hwcontext_qsv.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 35a944f8f8..64cb1663d8 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -110,6 +110,10 @@ static const struct {
  #if CONFIG_VAAPI
  { AV_PIX_FMT_YUYV422,
 MFX_FOURCC_YUY2 },
+#if QSV_VERSION_ATLEAST(1, 9)
+{ AV_PIX_FMT_X2RGB10,
+MFX_FOURCC_A2RGB10 },
+#endif
  #if QSV_VERSION_ATLEAST(1, 27)
  { AV_PIX_FMT_Y210,
 MFX_FOURCC_Y210 },
@@ -798,6 +802,10 @@ static int map_frame_to_surface(const AVFrame *frame, 
mfxFrameSurface1 *surface)
  surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
  break;
  #endif
+case AV_PIX_FMT_X2RGB10:
+surface->Data.A2RGB10 = (mfxA2RGB10 *)frame->data[0];
+break;
+
  default:
  return MFX_ERR_UNSUPPORTED;
  }



What happens to the alpha information here?  We don't specify what is in the 
unused bits of X2RGB10, so saying that it has an alpha component seems likely 
to do something ugly in cases where that is used (e.g. overlay).

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

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

Re: [FFmpeg-devel] [PATCH 1/4] kmsgrab: Refactor and clean error cases

2020-08-09 Thread Mark Thompson

On 05/07/2020 16:49, Mark Thompson wrote:

---
  libavdevice/kmsgrab.c | 151 ++
  1 file changed, 93 insertions(+), 58 deletions(-)


Thanks to Lynne on IRC for looking at this set.

Applied with some minor fixups to error logging.

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/options: Add options for inputing HDR10-related metadata

2020-08-09 Thread Kenny McClive
Thanks, Andreas. When I fix it, do I submit a patch for this patch or a whole 
new patch with the combined changes?

Thanks,
Kenny

> On Aug 9, 2020, at 4:00 AM, Andreas Rheinhardt  
> wrote:
> 
> Kenny McClive:
>> Hi,
>> 
>> Would someone be willing to help me with this?  This is the first patch I’ve 
>> submitted.  Patchwork shows that two tests are failing.  However, when I run 
>> “make fate” locally, I don’t see any failures.  Is there some other make or 
>> configure command that I can run to make my results match those in 
>> Patchwork?  Is there something else I’m missing?  Any help would be 
>> appreciated.
>> 
>> Thanks,
>> Kenny
>> 
 On Aug 8, 2020, at 5:53 PM, Patchwork  wrote:
>>> 
>>> Hello, 
>>> 
>>> Thank you for submitting a patch to ffmpeg-devel.
>>> 
>>> An error occurred during an automated build/fate test. Please review the 
>>> following link for more details:
>>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/a384b59e-32e4-459a-af0c-47bc551e0...@me.com/
>>> 
>>> Thank you, 
>>> ffmpeg-devel
>> 
> 
> You are probably running fate without samples. See
> https://ffmpeg.org/fate.html#Using-FATE-from-your-FFmpeg-source-directory
> for more.
> 
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v3 5/5] avformat/argo_asf: strip file extension from name

2020-08-09 Thread Zane van Iperen
Only when the user hasn't manually specified one.
Matches the original files more closely.

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 577b9d9c01..37ad2bf5e9 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -329,10 +329,24 @@ static int argo_asf_write_header(AVFormatContext *s)
 fhdr.version_minor = (uint16_t)ctx->version_minor;
 fhdr.num_chunks= 1;
 fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
-if (ctx->name)
+/*
+ * If the user specified a name, use it as is. Otherwise take the
+ * basename and lop off the extension (if any).
+ */
+if (ctx->name) {
 strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
-else
-strncpy(fhdr.name, av_basename(s->url), sizeof(fhdr.name));
+} else {
+const char *start = av_basename(s->url);
+const char *end   = strrchr(start, '.');
+size_t  len;
+
+if(end)
+len = end - start;
+else
+len = strlen(start);
+
+memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name)));
+}
 
 chdr.num_blocks= 0;
 chdr.num_samples   = ASF_SAMPLE_COUNT;
-- 
2.25.1


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

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

[FFmpeg-devel] [PATCH v3 1/5] avformat/argo_asf: add games to version list

2020-08-09 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 671b7482f9..94d3ae3e09 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -87,9 +87,12 @@ static void argo_asf_parse_chunk_header(ArgoASFChunkHeader 
*hdr, const uint8_t *
 
 /*
  * Known versions:
- * 1.1: The sample files in /game-formats/brender/part2.zip
+ * 1.1: https://samples.ffmpeg.org/game-formats/brender/part2.zip
+ *  FX Fighter
  * 1.2: Croc! Legend of the Gobbos
  * 2.1: Croc 2
+ *  The Emperor's New Groove
+ *  Disney's Aladdin in Nasira's Revenge
  */
 static int argo_asf_is_known_version(const ArgoASFFileHeader *hdr)
 {
-- 
2.25.1


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

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

[FFmpeg-devel] [PATCH v3 3/5] avformat/argo_asf: add version_major and version_minor options

2020-08-09 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 47 +++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index bb69b01ff4..d25a5de37f 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 
 #define ASF_TAG MKTAG('A', 'S', 'F', '\0')
 #define ASF_FILE_HEADER_SIZE24
@@ -63,6 +64,12 @@ typedef struct ArgoASFDemuxContext {
 uint32_tblocks_read;
 } ArgoASFDemuxContext;
 
+typedef struct ArgoASFMuxContext {
+const AVClass *class;
+intversion_major;
+intversion_minor;
+} ArgoASFMuxContext;
+
 #if CONFIG_ARGO_ASF_DEMUXER
 static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t 
*buf)
 {
@@ -312,12 +319,13 @@ static void argo_asf_write_chunk_header(const 
ArgoASFChunkHeader *ckhdr, AVIOCon
 static int argo_asf_write_header(AVFormatContext *s)
 {
 const AVCodecParameters  *par = s->streams[0]->codecpar;
+ArgoASFMuxContext*ctx = s->priv_data;
 ArgoASFFileHeader  fhdr;
 ArgoASFChunkHeader chdr;
 
 fhdr.magic = ASF_TAG;
-fhdr.version_major = 2;
-fhdr.version_minor = 1;
+fhdr.version_major = (uint16_t)ctx->version_major;
+fhdr.version_minor = (uint16_t)ctx->version_minor;
 fhdr.num_chunks= 1;
 fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
 strncpy(fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(fhdr.name));
@@ -360,6 +368,37 @@ static int argo_asf_write_trailer(AVFormatContext *s)
 return 0;
 }
 
+static const AVOption argo_asf_options[] = {
+{
+.name= "version_major",
+.help= "override file major version",
+.offset  = offsetof(ArgoASFMuxContext, version_major),
+.type= AV_OPT_TYPE_INT,
+.default_val = {.i64 = 2},
+.min = 0,
+.max = UINT16_MAX,
+.flags   = AV_OPT_FLAG_ENCODING_PARAM
+},
+{
+.name= "version_minor",
+.help= "override file minor version",
+.offset  = offsetof(ArgoASFMuxContext, version_minor),
+.type= AV_OPT_TYPE_INT,
+.default_val = {.i64 = 1},
+.min = 0,
+.max = UINT16_MAX,
+.flags   = AV_OPT_FLAG_ENCODING_PARAM
+},
+{ NULL }
+};
+
+static const AVClass argo_asf_muxer_class = {
+.class_name = "argo_asf_muxer",
+.item_name  = av_default_item_name,
+.option = argo_asf_options,
+.version= LIBAVUTIL_VERSION_INT
+};
+
 AVOutputFormat ff_argo_asf_muxer = {
 .name   = "argo_asf",
 .long_name  = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"),
@@ -372,6 +411,8 @@ AVOutputFormat ff_argo_asf_muxer = {
 .init   = argo_asf_write_init,
 .write_header   = argo_asf_write_header,
 .write_packet   = argo_asf_write_packet,
-.write_trailer  = argo_asf_write_trailer
+.write_trailer  = argo_asf_write_trailer,
+.priv_class = &argo_asf_muxer_class,
+.priv_data_size = sizeof(ArgoASFMuxContext)
 };
 #endif
-- 
2.25.1


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

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

[FFmpeg-devel] [PATCH v3 2/5] avformat/argo_asf: don't check file version

2020-08-09 Thread Zane van Iperen
It has no bearing on structure. Determined by looking at the ASF
files from several Argonaut games:
  - FX Fighter,
  - Croc,
  - Croc 2,
  - The Emperor's New Groove, and
  - Disney's Aladdin in Nasira's Revenge

The only versions that appear are 1.1, 1.2, and 2.1, and their
structure is identical.

Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 94d3ae3e09..bb69b01ff4 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -136,13 +136,6 @@ static int argo_asf_read_header(AVFormatContext *s)
 
 argo_asf_parse_file_header(&asf->fhdr, buf);
 
-if (!argo_asf_is_known_version(&asf->fhdr)) {
-avpriv_request_sample(s, "Version %hu.%hu",
-asf->fhdr.version_major, asf->fhdr.version_minor
-);
-return AVERROR_PATCHWELCOME;
-}
-
 if (asf->fhdr.num_chunks == 0) {
 return AVERROR_INVALIDDATA;
 } else if (asf->fhdr.num_chunks > 1) {
-- 
2.25.1


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

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

[FFmpeg-devel] [PATCH v3 4/5] avformat/argo_asf: add name option

2020-08-09 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_asf.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index d25a5de37f..577b9d9c01 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -68,6 +68,7 @@ typedef struct ArgoASFMuxContext {
 const AVClass *class;
 intversion_major;
 intversion_minor;
+const char*name;
 } ArgoASFMuxContext;
 
 #if CONFIG_ARGO_ASF_DEMUXER
@@ -328,7 +329,10 @@ static int argo_asf_write_header(AVFormatContext *s)
 fhdr.version_minor = (uint16_t)ctx->version_minor;
 fhdr.num_chunks= 1;
 fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
-strncpy(fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(fhdr.name));
+if (ctx->name)
+strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
+else
+strncpy(fhdr.name, av_basename(s->url), sizeof(fhdr.name));
 
 chdr.num_blocks= 0;
 chdr.num_samples   = ASF_SAMPLE_COUNT;
@@ -389,6 +393,14 @@ static const AVOption argo_asf_options[] = {
 .max = UINT16_MAX,
 .flags   = AV_OPT_FLAG_ENCODING_PARAM
 },
+{
+.name= "name",
+.help= "embedded file name (max 8 characters)",
+.offset  = offsetof(ArgoASFMuxContext, name),
+.type= AV_OPT_TYPE_STRING,
+.default_val = {.str = NULL},
+.flags   = AV_OPT_FLAG_ENCODING_PARAM
+},
 { NULL }
 };
 
-- 
2.25.1


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

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

[FFmpeg-devel] [PATCH 1/3] avformat/mlvdec: Check for existence of AVIOContext before using it

2020-08-09 Thread Andreas Rheinhardt
The mlv demuxer supports input split into multiple files; if invalid
data is encountered when parsing one of the subsequent files, that file
is closed. But at this point some index entries belonging to this file
might already have been added. In this case, the read_packet function
might try to use the AVIOContext (which is NULL) to read data which will
of course crash. This commit fixes this.

Signed-off-by: Andreas Rheinhardt 
---
As an alternative to patches 1 and 3 one could also just error out if
one of the subsequent files is bad.

 libavformat/mlvdec.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index 03aed71024..7c7ced7f76 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -411,6 +411,10 @@ static int read_packet(AVFormatContext *avctx, AVPacket 
*pkt)
 }
 
 pb = mlv->pb[st->index_entries[index].size];
+if (!pb) {
+ret = FFERROR_REDO;
+goto next_packet;
+}
 avio_seek(pb, st->index_entries[index].pos, SEEK_SET);
 
 avio_skip(pb, 4); // blockType
@@ -439,12 +443,14 @@ static int read_packet(AVFormatContext *avctx, AVPacket 
*pkt)
 pkt->stream_index = mlv->stream_index;
 pkt->pts = mlv->pts;
 
+ret = 0;
+next_packet:
 mlv->stream_index++;
 if (mlv->stream_index == avctx->nb_streams) {
 mlv->stream_index = 0;
 mlv->pts++;
 }
-return 0;
+return ret;
 }
 
 static int read_seek(AVFormatContext *avctx, int stream_index, int64_t 
timestamp, int flags)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 2/3] avformat/mlvdec: Don't leak open AVIOContexts on error

2020-08-09 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mlvdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index 7c7ced7f76..50913fa685 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -52,6 +52,8 @@ typedef struct {
 uint64_t pts;
 } MlvContext;
 
+static int read_close(AVFormatContext *s);
+
 static int probe(const AVProbeData *p)
 {
 if (AV_RL32(p->buf) == MKTAG('M','L','V','I') &&
@@ -376,6 +378,7 @@ static int read_header(AVFormatContext *avctx)
 
 if ((vst && !vst->nb_index_entries) || (ast && !ast->nb_index_entries)) {
 av_log(avctx, AV_LOG_ERROR, "no index entries found\n");
+read_close(avctx);
 return AVERROR_INVALIDDATA;
 }
 
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 3/3] avformat/mlvdec: Only store dimensions after having validated them

2020-08-09 Thread Andreas Rheinhardt
Otherwise it might happen that invalid dimensions are used when reading
a video packet; this might lead to undefined overflow.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mlvdec.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index 50913fa685..f08aabf4e0 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -132,23 +132,25 @@ static int scan_file(AVFormatContext *avctx, AVStream 
*vst, AVStream *ast, int f
 break;
 size -= 16;
 if (vst && type == MKTAG('R','A','W','I') && size >= 164) {
-vst->codecpar->width  = avio_rl16(pb);
-vst->codecpar->height = avio_rl16(pb);
-ret = av_image_check_size(vst->codecpar->width, 
vst->codecpar->height, 0, avctx);
+unsigned width  = avio_rl16(pb);
+unsigned height = avio_rl16(pb);
+unsigned bits_per_coded_sample;
+ret = av_image_check_size(width, height, 0, avctx);
 if (ret < 0)
 return ret;
 if (avio_rl32(pb) != 1)
 avpriv_request_sample(avctx, "raw api version");
 avio_skip(pb, 20); // pointer, width, height, pitch, frame_size
-vst->codecpar->bits_per_coded_sample = avio_rl32(pb);
-if (vst->codecpar->bits_per_coded_sample < 0 ||
-vst->codecpar->bits_per_coded_sample > (INT_MAX - 7) / 
(vst->codecpar->width * vst->codecpar->height)) {
+bits_per_coded_sample = avio_rl32(pb);
+if (bits_per_coded_sample > (INT_MAX - 7) / (width * height)) {
 av_log(avctx, AV_LOG_ERROR,
-   "invalid bits_per_coded_sample %d (size: %dx%d)\n",
-   vst->codecpar->bits_per_coded_sample,
-   vst->codecpar->width, vst->codecpar->height);
+   "invalid bits_per_coded_sample %u (size: %ux%u)\n",
+   bits_per_coded_sample, width, height);
 return AVERROR_INVALIDDATA;
 }
+vst->codecpar->width  = width;
+vst->codecpar->height = height;
+vst->codecpar->bits_per_coded_sample = bits_per_coded_sample;
 avio_skip(pb, 8 + 16 + 24); // black_level, white_level, xywh, 
active_area, exposure_bias
 if (avio_rl32(pb) != 0x2010100) /* RGGB */
 avpriv_request_sample(avctx, "cfa_pattern");
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH] doc/encoders: Add all options for JPEG2000 encoder

2020-08-09 Thread Gautam Ramakrishnan
On Mon, Aug 10, 2020 at 12:07 AM Gyan Doshi  wrote:
>
>
>
> On 09-08-2020 11:13 pm, gautamr...@gmail.com wrote:
> > From: Gautam Ramakrishnan 
> >
> > This patch updates the documentation by adding all options
> > for JPEG2000 encoder.
> > ---
> >   doc/encoders.texi | 20 
> >   1 file changed, 20 insertions(+)
> >
> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index de0472e225..aaac026709 100644
> > --- a/doc/encoders.texi
> > +++ b/doc/encoders.texi
> > @@ -1369,6 +1369,26 @@ can be selected with @code{-pred 1}.
> >   Can be set to either @code{j2k} or @code{jp2} (the default) that
> >   makes it possible to store non-rgb pix_fmts.
> >
> > +@item tile_width/tile_height
> > +Allows setting of tile width and height.
>
> Make these separate items.
Shall do this
>
> > +
> > +@item pred
> > +Allows setting the DWT type, i.e lossy
> > +DWT 97 (@code{dwt97int}) or lossless DWT 53 (@code{dwt53}).
> > +
> > +@item sop
> > +Setting this to 1 will make the encoder to use SOP marker at the
> > +start of every packet. Set to 0 by default.
>
> Not related to this patch, but make these boolean options
> AV_OPT_TYPE_BOOL. It allows users to also set them to string values
> true/false or on/off.
>
> > +@item eph
> > +Setting this to 1 will make the encoder to use the EPH flag at the
> > +end of every packet header. Set to 0 by default.
> > +
> > +@item prog
> > +Sets the progression order to be used by the encoder.
> > +Possible values are @code{lrcp}, @code{rlcp}, @code{rpcl},
> > +@code{pcrl} and @code{cprl}. Set to @code{lrcp} by default.
>
> One value per line, please. Also add option type for each option. See
> Hap encoder entry above this one. Some elaboration will be nice as well
> unless users are expected to know what the differences are between these
> values.
>
I'll make these 1 value per line. However, I am not sure if
elaboration is possible
as the user is expected to know the difference between these values.
> Thanks,
> Gyan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



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

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: add 10-bit RGB support for QSV

2020-08-09 Thread Linjie Fu
On Mon, Aug 10, 2020 at 4:31 AM Mark Thompson  wrote:
>
> On 09/08/2020 06:11, Linjie Fu wrote:
> > After adding a copy pass through path inside MSDK, x2rgb10 is now
> > available as an output of VPP.
> >
> > Command line for CSC:
> > ffmpeg -hwaccel qsv -v verbose -c:v hevc_qsv -i
> >  p010.h265 -vf scale_qsv=format=x2rgb10,hwdownload,format=x2rgb10
> >  -vframes 1 out.yuv
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > [1]Issue:
> > https://github.com/Intel-Media-SDK/MediaSDK/issues/1654
> > [2]Adding copy passthrou:
> > https://github.com/AntonGrishin/MediaSDK/commit/20058c0e1dbd521e2571e14f6246c48fea996094
> > [3]Still in need to be fixed:
> > https://github.com/Intel-Media-SDK/MediaSDK/pull/2268
> >
> > This patch would be ready to merge after [3] is handled decently.
> >
> >   libavutil/hwcontext_qsv.c | 8 
> >   1 file changed, 8 insertions(+)
> >
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> > index 35a944f8f8..64cb1663d8 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -110,6 +110,10 @@ static const struct {
> >   #if CONFIG_VAAPI
> >   { AV_PIX_FMT_YUYV422,
> >  MFX_FOURCC_YUY2 },
> > +#if QSV_VERSION_ATLEAST(1, 9)
> > +{ AV_PIX_FMT_X2RGB10,
> > +MFX_FOURCC_A2RGB10 },
> > +#endif
> >   #if QSV_VERSION_ATLEAST(1, 27)
> >   { AV_PIX_FMT_Y210,
> >  MFX_FOURCC_Y210 },
> > @@ -798,6 +802,10 @@ static int map_frame_to_surface(const AVFrame *frame, 
> > mfxFrameSurface1 *surface)
> >   surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> >   break;
> >   #endif
> > +case AV_PIX_FMT_X2RGB10:
> > +surface->Data.A2RGB10 = (mfxA2RGB10 *)frame->data[0];
> > +break;
> > +
> >   default:
> >   return MFX_ERR_UNSUPPORTED;
> >   }
> >
>
> What happens to the alpha information here?  We don't specify what is in the 
> unused bits of X2RGB10, so saying that it has an alpha component seems likely 
> to do something ugly in cases where that is used (e.g. overlay).

Yep, and as discussed previously, this patch is to add support for
x2rgb10(instead of pixel format a2rgb10) in ffmpeg level, which didn't
say it has the alpha component.
So I think this would be fine, since we don't care about the unused 2
bits for x2rgb10 (no matter whether it contains alpha information or
not).

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

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

Re: [FFmpeg-devel] [PATCH v3 1/2] dxva: wait until D3D11 buffer copies are done before submitting them

2020-08-09 Thread Steve Lhomme

On 2020-08-08 8:24, Soft Works wrote:




-Original Message-
From: ffmpeg-devel  On Behalf Of
Steve Lhomme
Sent: Saturday, August 8, 2020 7:10 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] dxva: wait until D3D11 buffer
copies are done before submitting them


[...]



Hi Steven,


Hi,


A while ago I had extended D3D11VA implementation to support single
(non-array textures) for interoperability with Intel QSV+DX11.


Looking at your code, it seems you are copying from an array texture to a
single slice texture to achieve this. With double the amount of RAM.
It may be a design issue with the new D3D11 API, which forces you to do


With D3D11, it's mandatory to use a staging texture, which is not only done
in my code but also in the original implementation (hwcontext_d3d11va.c)
https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext_d3d11va.c


that, but I'm not using that API. I'm using the old API.


I'm not sure whether I understand what you mean by this. To my knowledge
there are two DX hw context implementations in ffmpeg:

- DXVA2
- D3D11VA

I'm not aware of a variant like "D3D11 with old API". Could you please 
elaborate?


There is AV_PIX_FMT_D3D11VA_VLD (old) and AV_PIX_FMT_D3D11 (new).




Hence, I don't think that your patch is the best possible way .


Removing locks and saying "it works for me" is neither a correct solution.


How did you come to the conclusion that I might be working like this?


The commented out "hwctx->lock" lines in your code.


the very least the locks are needed inside libavcodec to avoid setting DXVA
buffers concurrently from different threads. It will most likely result in very
bad distortions if not crashes. Maybe you're only using 1 decoding thread
with DXVA (which a lot of people do) so you don't have this issue, but this is
not my case.


I see no point in employing multiple threads for hw accelerated decoding.
To be honest I never looked into or tried whether ffmpeg even supports
multiple threads with dva2 or d3d11va hw acceleration.


Maybe you're in an ideal situation where all the files you play through 
libavcodec are hardware accelerated (so also with matching hardware). In 
this case you don't need to care about the case where it will fallback 
to software decoding. Using a single thread in that case would have 
terrible performance.


Even then, there's still a chance using multiple threads might improve 
performance. All the code that is run to prepare the buffers that are 
fed into the hardware decoder can be run in parallel for multiple 
frames. If you have an insanely fast hardware decoder that would be the 
bottleneck. In a transcoding scenario that could have an impact.



Also ID3D10Multithread::SetMultithreadProtected means that the resources
can be accessed from multiple threads. It doesn't mean that calls to
ID3D11DeviceContext are safe from multithreading. And my experience
shows that it is not. In fact if you have the Windows SDK installed and you
have concurrent accesses, you'll get a big warning in your debug logs that you
are doing something fishy. On WindowsPhone it would even crash. This is
how I ended up adding the mutex to the old API
(e3d4784eb31b3ea4a97f2d4c698a75fab9bf3d86).

The documentation for ID3D11DeviceContext is very clear about that [1]:
"Because each ID3D11DeviceContext is single threaded, only one thread can
call a ID3D11DeviceContext at a time. If multiple threads must access a single
ID3D11DeviceContext, they must use some synchronization mechanism,
such as critical sections, to synchronize access to that ID3D11DeviceContext."


Yes, but this doesn't apply to accessing staging textures IIRC.


It does. To copy to a staging texture you need to use 
ID3D11DeviceContext::CopySubresourceRegion().


You probably don't have any synchronization issues in your pipeline 
because it seems you copy from GPU to CPU. In that case it forces the 
ID3D11DeviceContext::GetData() internally to make sure all the commands 
to produce your source texture on that video context are finished 
processing. You may not see it, but there's a wait happening there. In 
my case there's nothing happening between the decoder and the rendering 
of the texture.



In fact, I had researched this in-depth, but I can't tell much more without
looking into it again.

The patch I referenced is working in production on thousands of installations
and tested with many different hardware and driver versions from Nvidia,
Intel and AMD.


And I added the lock before, as the specs say, it's necessary. That 
solved some issues on the hundred of millions of VLC running on Windows 
on all the hardware you can think of.


Decoding 8K 60 fps HEVC was also a good stress test of the code. The 
ID3D11DeviceContext::GetData() in the rendering side ensured that we had 
the frames displayed in the right time and not whenever the pipeline is 
done processing the device context commands.


Now I realize the same thing should be done on th

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: add 10-bit RGB support for QSV

2020-08-09 Thread Hendrik Leppkes
On Mon, Aug 10, 2020 at 6:07 AM Linjie Fu  wrote:
>
> On Mon, Aug 10, 2020 at 4:31 AM Mark Thompson  wrote:
> >
> > On 09/08/2020 06:11, Linjie Fu wrote:
> > > After adding a copy pass through path inside MSDK, x2rgb10 is now
> > > available as an output of VPP.
> > >
> > > Command line for CSC:
> > > ffmpeg -hwaccel qsv -v verbose -c:v hevc_qsv -i
> > >  p010.h265 -vf scale_qsv=format=x2rgb10,hwdownload,format=x2rgb10
> > >  -vframes 1 out.yuv
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > [1]Issue:
> > > https://github.com/Intel-Media-SDK/MediaSDK/issues/1654
> > > [2]Adding copy passthrou:
> > > https://github.com/AntonGrishin/MediaSDK/commit/20058c0e1dbd521e2571e14f6246c48fea996094
> > > [3]Still in need to be fixed:
> > > https://github.com/Intel-Media-SDK/MediaSDK/pull/2268
> > >
> > > This patch would be ready to merge after [3] is handled decently.
> > >
> > >   libavutil/hwcontext_qsv.c | 8 
> > >   1 file changed, 8 insertions(+)
> > >
> > > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> > > index 35a944f8f8..64cb1663d8 100644
> > > --- a/libavutil/hwcontext_qsv.c
> > > +++ b/libavutil/hwcontext_qsv.c
> > > @@ -110,6 +110,10 @@ static const struct {
> > >   #if CONFIG_VAAPI
> > >   { AV_PIX_FMT_YUYV422,
> > >  MFX_FOURCC_YUY2 },
> > > +#if QSV_VERSION_ATLEAST(1, 9)
> > > +{ AV_PIX_FMT_X2RGB10,
> > > +MFX_FOURCC_A2RGB10 },
> > > +#endif
> > >   #if QSV_VERSION_ATLEAST(1, 27)
> > >   { AV_PIX_FMT_Y210,
> > >  MFX_FOURCC_Y210 },
> > > @@ -798,6 +802,10 @@ static int map_frame_to_surface(const AVFrame 
> > > *frame, mfxFrameSurface1 *surface)
> > >   surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> > >   break;
> > >   #endif
> > > +case AV_PIX_FMT_X2RGB10:
> > > +surface->Data.A2RGB10 = (mfxA2RGB10 *)frame->data[0];
> > > +break;
> > > +
> > >   default:
> > >   return MFX_ERR_UNSUPPORTED;
> > >   }
> > >
> >
> > What happens to the alpha information here?  We don't specify what is in 
> > the unused bits of X2RGB10, so saying that it has an alpha component seems 
> > likely to do something ugly in cases where that is used (e.g. overlay).
>
> Yep, and as discussed previously, this patch is to add support for
> x2rgb10(instead of pixel format a2rgb10) in ffmpeg level, which didn't
> say it has the alpha component.
> So I think this would be fine, since we don't care about the unused 2
> bits for x2rgb10 (no matter whether it contains alpha information or
> not).

I think Marks point is that the QSV format is called
MFX_FOURCC_A2RGB10, eg. A2RGB10, not X2RGB10. It sounds like the QSV
format expects alpha to be valid.

It should be clarified what happens with the alpha, and made sure that
it doesnt produce files with an alpha channel full of nonsense.

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

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