Re: [FFmpeg-devel] [PATCH 1/4] avcodec/intrax8: Remove unused IDCTDSPContext

2022-08-02 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure| 2 +-
>  libavcodec/intrax8.c | 4 +---
>  libavcodec/intrax8.h | 3 +--
>  libavcodec/vc1dec.c  | 2 +-
>  libavcodec/wmv2dec.c | 2 +-
>  5 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/configure b/configure
> index 8c7e8c9d1d..974768a663 100755
> --- a/configure
> +++ b/configure
> @@ -2733,7 +2733,7 @@ h264dsp_select="startcode"
>  hevcparse_select="atsc_a53 golomb"
>  frame_thread_encoder_deps="encoders threads"
>  inflate_wrapper_deps="zlib"
> -intrax8_select="blockdsp idctdsp"
> +intrax8_select="blockdsp"
>  iso_media_select="mpeg4audio"
>  mdct_select="fft"
>  mdct15_select="fft"
> diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
> index 73b8aeea78..b99e8590b1 100644
> --- a/libavcodec/intrax8.c
> +++ b/libavcodec/intrax8.c
> @@ -25,7 +25,6 @@
>  #include "libavutil/thread.h"
>  #include "avcodec.h"
>  #include "get_bits.h"
> -#include "idctdsp.h"
>  #include "msmpeg4data.h"
>  #include "intrax8huf.h"
>  #include "intrax8.h"
> @@ -692,7 +691,7 @@ static void x8_init_block_index(IntraX8Context *w, 
> AVFrame *frame)
>  }
>  
>  av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
> -   IntraX8Context *w, IDCTDSPContext *idsp,
> +   IntraX8Context *w,
> int16_t (*block)[64],
> int block_last_index[12],
> int mb_width, int mb_height)
> @@ -700,7 +699,6 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
>  static AVOnce init_static_once = AV_ONCE_INIT;
>  
>  w->avctx = avctx;
> -w->idsp = *idsp;
>  w->mb_width  = mb_width;
>  w->mb_height = mb_height;
>  w->block = block;
> diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
> index 5b8946ea25..3ebbf73434 100644
> --- a/libavcodec/intrax8.h
> +++ b/libavcodec/intrax8.h
> @@ -44,7 +44,6 @@ typedef struct IntraX8Context {
>  
>  // set by the caller codec
>  IntraX8DSPContext dsp;
> -IDCTDSPContext idsp;
>  BlockDSPContext bdsp;
>  int quant;
>  int dquant;
> @@ -86,7 +85,7 @@ typedef struct IntraX8Context {
>   * @return 0 on success, a negative AVERROR value on error
>   */
>  int ff_intrax8_common_init(AVCodecContext *avctx,
> -   IntraX8Context *w, IDCTDSPContext *idsp,
> +   IntraX8Context *w,
> int16_t (*block)[64],
> int block_last_index[12],
> int mb_width, int mb_height);
> diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
> index 5c5b31ad32..b53490b3ab 100644
> --- a/libavcodec/vc1dec.c
> +++ b/libavcodec/vc1dec.c
> @@ -391,7 +391,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
>  goto error;
>  }
>  
> -ret = ff_intrax8_common_init(s->avctx, >x8, >idsp,
> +ret = ff_intrax8_common_init(s->avctx, >x8,
>   s->block, s->block_last_index,
>   s->mb_width, s->mb_height);
>  if (ret < 0)
> diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
> index e61b549439..6d9b72d123 100644
> --- a/libavcodec/wmv2dec.c
> +++ b/libavcodec/wmv2dec.c
> @@ -578,7 +578,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
>  ff_init_scantable(s->idsp.idct_permutation, >abt_scantable[1],
>ff_wmv2_scantableB);
>  
> -return ff_intrax8_common_init(avctx, >x8, >s.idsp,
> +return ff_intrax8_common_init(avctx, >x8,
>w->s.block, w->s.block_last_index,
>w->s.mb_width, w->s.mb_height);
>  }

Will apply this patchset tonight unless there are objections.

- 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 v12 00/13] make QSV works with the Intel's oneVPL

2022-08-02 Thread Xiang, Haihao
On Mon, 2022-07-25 at 12:11 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang 
> 
> The oneAPI Video Processing Library (oneVPL) is a single interface for
> encode, decode and video processing[1][2]. oneVPL is a successor to Intel(R)
> Media
> SDK, but removed obsolete features. Intel(R) Media SDK lifetime comes to an
> end now, new features for new Intel Gen platforms will be supported in oneVPL
> only[3].
> 
> It is recommended to use oneVPL for new work, even for currently available
> hardwares[4]. Hence, this patchset added a new option --enable-onevpl to bring
> the support for oneVPL in QSV, new features for oneVPL will be implemented in
> other patchset, for example, we are implementing av1_qsv encoder
> (https://github.com/intel-media-ci/ffmpeg/pull/515).
> 
> option --enble-libmfx still works with Intel(R) Media SDK.
> 
> Note user can't enable onevpl and libmfx together.
> 
> oneVPL dispatcher:
> https://github.com/oneapi-src/oneVPL
> 
> oneVPL GPU runtime for new Intel Gen platforms:
> https://github.com/oneapi-src/oneVPL-intel-gpu
> 
> v12:
>   - Update some commit logs
>   - Update qsv_va_update_config() for configuration filter on Linux
> 
> Haihao Xiang (13):
>   configure: ensure --enable-libmfx uses libmfx 1.x
>   configure: fix the check for MFX_CODEC_VP9
>   qsv: remove mfx/ prefix from mfx headers
>   qsv: restrict user plugin to MFX_VERSION < 2.0
>   qsv: restrict audio related code to MFX_VERSION < 2.0
>   qsvenc: restrict multi-frame encode to MFX_VERSION < 2.0
>   qsvenc: restrict MFX_RATECONTROL_LA_EXT to MFX_VERSION < 2.0
>   qsv: restrict OPAQUE memory to MFX_VERSION < 2.0
>   lavu/hwcontext_qsv: add loader field to AVQSVDeviceContext
>   lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL
>   lavc/qsv: create mfx session using oneVPL for decoding/encoding
>   lavfi/qsv: create mfx session using oneVPL for qsv filters
>   configure: add --enable-libvpl option
> 
>  configure|  32 +-
>  doc/APIchanges   |   3 +
>  libavcodec/qsv.c | 249 +++--
>  libavcodec/qsv.h |   4 +-
>  libavcodec/qsv_internal.h|   6 +-
>  libavcodec/qsvdec.c  |  22 +-
>  libavcodec/qsvenc.c  |  25 +-
>  libavcodec/qsvenc.h  |   9 +-
>  libavcodec/qsvenc_h264.c |   3 +-
>  libavcodec/qsvenc_hevc.c |   3 +-
>  libavcodec/qsvenc_jpeg.c |   3 +-
>  libavcodec/qsvenc_mpeg2.c|   3 +-
>  libavcodec/qsvenc_vp9.c  |   3 +-
>  libavfilter/qsvvpp.c | 141 +++-
>  libavfilter/qsvvpp.h |  12 +-
>  libavfilter/vf_deinterlace_qsv.c |  72 ++--
>  libavfilter/vf_scale_qsv.c   |  87 ++---
>  libavutil/hwcontext_opencl.c |   2 +-
>  libavutil/hwcontext_qsv.c| 590 ---
>  libavutil/hwcontext_qsv.h|  13 +-
>  libavutil/version.h  |   2 +-
>  21 files changed, 1099 insertions(+), 185 deletions(-)


Are there any more comments or objections left for this patchset ? 

BRs
Haihao

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

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


Re: [FFmpeg-devel] [PATCH v4 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2022-08-02 Thread Xiang, Haihao
On Tue, 2022-08-02 at 13:29 +0200, Anton Khirnov wrote:
> Quoting Xiang, Haihao (2022-08-02 09:56:01)
> > From: Haihao Xiang 
> > 
> > Usually a HW decoder is expected when user specifies a HW acceleration
> > method via -hwaccel option, however the current implementation doesn't
> > take HW acceleration method into account, it is possible to select a SW
> > decoder.
> > 
> > For example:
> > $ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
> > $ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
> > $ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
> > [...]
> > Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))
> > 
> > libdav1d is selected in this case even if vaapi, nvdec or vdpau is
> > specified.
> > 
> > After applying this patch, the native av1 decoder (with vaapi, nvdec or
> > vdpau support) is selected for decoding(libdav1d is still used for
> > probing format).
> > $ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
> > $ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
> > $ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
> > [...]
> > Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))
> > 
> > Tested-by: Mario Roy 
> > Signed-off-by: Haihao Xiang 
> > ---
> >  fftools/ffmpeg_opt.c | 31 +++
> >  1 file changed, 27 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> > index cf0c31bdc2..db51cca66d 100644
> > --- a/fftools/ffmpeg_opt.c
> > +++ b/fftools/ffmpeg_opt.c
> > @@ -857,7 +857,9 @@ static const AVCodec *find_codec_or_die(const char
> > *name, enum AVMediaType type,
> >  return codec;
> >  }
> >  
> > -static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s,
> > AVStream *st)
> > +static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s,
> > AVStream *st,
> > + enum HWAccelID hwaccel_id, enum
> > AVHWDeviceType hwaccel_device_type)
> > +
> >  {
> >  char *codec_name = NULL;
> >  
> > @@ -868,8 +870,29 @@ static const AVCodec *choose_decoder(OptionsContext *o,
> > AVFormatContext *s, AVSt
> >  if (recast_media && st->codecpar->codec_type != codec->type)
> >  st->codecpar->codec_type = codec->type;
> >  return codec;
> > -} else
> > +} else {
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > +hwaccel_id == HWACCEL_GENERIC &&
> > +hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
> > +const AVCodec *c;
> > +void *i = NULL;
> > +
> > +while ((c = av_codec_iterate())) {
> > +const AVCodecHWConfig *config;
> > +
> > +if (c->id != st->codecpar->codec_id ||
> > +!av_codec_is_decoder(c))
> > +continue;
> > +
> > +for (int j = 0; config = avcodec_get_hw_config(c, j); j++)
> > {
> > +if (config->device_type == hwaccel_device_type)
> > +return c;
> 
> Maybe a verbose-level log message like
> 
> "Selecting decoder '%s' because of requested hwaccel method %s\n",
> c->name, av_hwdevice_get_type_name(hwaccel_device_type)
> 
> would be appropriate. No need to send a new patch, just add it (or not,
> as you like) and push.

Added log and applied patches, thx

-Haihao

> 
___
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] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Thilo Borgmann



On 2 Aug 2022, at 20:16, Thilo Borgmann wrote:


On 2 Aug 2022, at 19:34, Nicolas George wrote:


Thilo Borgman (12022-08-02):

Of course, thought it would already be there together with CC.

There’s a typo in the mail address, otherwise LGTM.


Indeed, locally fixed:

+The TC can be contacted at .
+The CC can be contacted at .


@ffmpeg.org, no?


except you want to keep spammers away of course. Anybody writing there 
knows what (s)he’s doing.


Sorry, its hot here…

-Thilo
___
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] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Thilo Borgmann


On 2 Aug 2022, at 19:34, Nicolas George wrote:

> Thilo Borgman (12022-08-02):
>> Of course, thought it would already be there together with CC.
>>
>> There’s a typo in the mail address, otherwise LGTM.
>
> Indeed, locally fixed:
>
> +The TC can be contacted at .
> +The CC can be contacted at .

@ffmpeg.org, no?

-Thilo

>
> I will wait some time and push if nobody objects.
>
> Thanks,
>
> -- 
>   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] avutil/opt: Combine multiple av_log statements

2022-08-02 Thread Thilo Borgmann
On 2 Aug 2022, at 19:28, Andreas Rheinhardt wrote:

> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavutil/opt.c | 23 ---
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index 8ffb10449b..da3a65c041 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c

LGTM

-Thilo
___
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] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Jean-Baptiste Kempf



On Tue, 2 Aug 2022, at 19:10, Nicolas George wrote:
> Jean-Baptiste Kempf (12022-07-24):
>> Have you tried tc@ffmpeg.o.. ?
>
> Thanks.
>
> Would this patch be a good idea?


Great idea

> * 0001-doc-dev_community-add-the-addresses-of-the-committee.patch
> * signature.asc

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
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/aacdec: don't force HE-AACv2 profile if no PS info is present

2022-08-02 Thread James Almer

On 7/22/2022 8:10 PM, James Almer wrote:

On 7/22/2022 8:00 PM, Alex Converse wrote:

On Fri, Jul 22, 2022 at 8:37 AM James Almer  wrote:

On 7/22/2022 12:14 PM, Andreas Rheinhardt wrote:

James Almer:

On 7/22/2022 11:56 AM, Andreas Rheinhardt wrote:

James Almer:

On 7/22/2022 11:23 AM, Andreas Rheinhardt wrote:

James Almer:

On 7/18/2022 10:57 AM, Andreas Rheinhardt wrote:

James Almer:

On 7/14/2022 9:10 AM, Andreas Rheinhardt wrote:

James Almer:

Should fix ticket #3361

Signed-off-by: James Almer 
---
This also needs an update to some fate ref samples i'll upload
before
pushing
(fate-aac-al_sbr_ps_04_ur and fate-aac-al_sbr_ps_06_ur which
are now
decoded
properly as he_aac mono, so the .s16 files need to be 
replaced).






[snip]




it seems at least for these samples the fixed decoder does not
generate
a decoded stream comparable to the float one, so I'll just 
upload a

new
raw pcm file.


When I decode both of these streams with git master, the left
channel is
pretty much identical, yet the right channel of the fixed-point 
decoder
is silent and the right channel of the floating point decoder is 
not.

With this patch applied, the result are two mono streams that are
pretty
much identical: The test sample created by the floating-point 
decoder
works with the fixed-point decoder test (if one uncomments and 
modifies
the latter). So the issue with aac-al_sbr_ps_06_ur is not a 
reason to

upload new samples.


Ok, can you suggest how to add a test that decodes with the fixed 
point

decoder then compares that with the output of the float decoder? Is
there a helper in fate.sh already for this?



There is currently no helper in fate-run.sh for this.


Yeah, figures that's the case. Can you suggest how one would work 
for this?




A new function in fate-run.sh seems to be necessary. Given that a
similar situation exists for AC-3 we should not hardcode aac; 
instead it

should have two parameters for the float and the fixed decoder. Then it
should decode the input file twice and do the same comparison that the
current tests use (they use the oneoff method, which results in
do_tiny_psnr with MAXDIFF being called).
I think the tests for the fixed-point decoder (with checksums) 
should be

separate, so that one can test this without the floating-point decoder
being present.





- Andreas

PS: libfdk-aac produces a file that looks pretty much like the 
floating

point decoder from git master. Are you sure your patch is correct?


Yes, they duplicate the single channel in the stream and output 
it as

stereo, something that should be done by a filter if that's what the
user wants. Decoding a mono sample should generate a mono stream.


Not really. The channels are different.


./ffmpeg -c:a libfdk_aac -i ../samples/aac/al_sbr_ps_04_new.mp4 -af
channelmap=channel_layout=mono:map=0 -f md5 -

has the same result as

./ffmpeg -c:a libfdk_aac -i ../samples/aac/al_sbr_ps_04_new.mp4 -af
channelmap=channel_layout=mono:map=1 -f md5 -

Same with the samples in the ticket.



This seems to be true for al_sbr_ps_04_new.mp4; but it is not true for
al_sbr_ps_06_new.mp4.


So looks like nearly a hundred samples into al_sbr_ps_06_new.mp4 frames
start containing PS info. With this patch the decoder properly decodes
the first hundred as mono, but since the decoder is locked, it will keep
decoding the stereo samples as mono.



Hey all,

I thought I should share a little bit of context about this problem,
but I don't mean to come back from nowhere and try to overrule you
all. Do what you decide is best.

An HE-AACv2 decoder treating unsignaled mono as stereo is an
intentional design trade-off that the MPEG audio committee made. It is
a tradeoff that the FFmpeg decoder has mimicked for a number of years.
If you want to revisit the trade-off (and there may very well be good
reasons to do that) that's fine, but I think treating the current
behavior as a "bug" is the wrong approach.

In fact, those fate tests are based on a Coding Technologies test
suite designed to validate a decoder conformed to the MPEG behavior.

Parametric Stereo is nested inside the SBR extension after the main
SBR payload which itself is nested inside the AAC raw data block after
the main channel elements. It takes a full bitstream parse of both the
AAC and SBR layers and finding an SBR intra-frame to even see if PS is
present.


As for why I think MPEG made this trade-off (my opinion of why they 
did this) :

- It enables cutting (or joining a stream of) audio at arbitrary
frames without losing PS content or stereo detection.
- Most devices with mono output can support downmixing from stereo.
- Down mixing stereo to mono can be ugly with regard to phase but it
doesn't have nearly the complexity of the taste/environment/judgment
factor that surround sound to stereo downmix does.
- In transcode scenarios, most output codecs can support encoding
stereo formatted audio where both channels are identical quite
efficiently (even in AAC-LC with mid-side 

Re: [FFmpeg-devel] [PATCH] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Nicolas George
Thilo Borgman (12022-08-02):
> Of course, thought it would already be there together with CC.
> 
> There’s a typo in the mail address, otherwise LGTM.

Indeed, locally fixed:

+The TC can be contacted at .
+The CC can be contacted at .

I will wait some time and push if nobody objects.

Thanks,

-- 
  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] avutil/opt: Combine multiple av_log statements

2022-08-02 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavutil/opt.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 8ffb10449b..da3a65c041 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1329,17 +1329,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
 break;
 }
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_FILTERING_PARAM)? 'F' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_EXPORT) ? 'X' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_READONLY)   ? 'R' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_BSF_PARAM)  ? 'B' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_RUNTIME_PARAM)  ? 'T' : '.');
-av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_DEPRECATED) ? 'P' : '.');
+av_log(av_log_obj, AV_LOG_INFO, "%c%c%c%c%c%c%c%c%c%c%c",
+   (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.',
+   (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.',
+   (opt->flags & AV_OPT_FLAG_FILTERING_PARAM)? 'F' : '.',
+   (opt->flags & AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.',
+   (opt->flags & AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.',
+   (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.',
+   (opt->flags & AV_OPT_FLAG_EXPORT) ? 'X' : '.',
+   (opt->flags & AV_OPT_FLAG_READONLY)   ? 'R' : '.',
+   (opt->flags & AV_OPT_FLAG_BSF_PARAM)  ? 'B' : '.',
+   (opt->flags & AV_OPT_FLAG_RUNTIME_PARAM)  ? 'T' : '.',
+   (opt->flags & AV_OPT_FLAG_DEPRECATED) ? 'P' : '.');
 
 if (opt->help)
 av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
-- 
2.34.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 1/2] ffmpeg: add display_{rotation, hflip, vflip} options

2022-08-02 Thread Thilo Borgmann



On 2 Aug 2022, at 19:10, Andreas Rheinhardt wrote:


Thilo Borgmann:

Hi,


On 2022-05-18 11:34 pm, Jan Ekström wrote:
This enables overriding the rotation as well as 
horizontal/vertical
flip state of a specific video stream on either the input or 
output

side.


Since rotation, flip and scale are stored in a single data 
structure,
how about a single option i.e. -display 
"rotate=90,flip=hv,scale=2"



I did think about that, and I even implemented AVDict based 
options
for ffmpeg.c in a branch. But then pretty much got tired of lack 
of
AVOption automation (f.ex. for the flip flagging etc), and 
decided

that since these are relatively basic and simple, the non-generic
option for this could be just three options in the initial 
submission.


In the end I did implement this with a single dict-based thing in 
a

branch but never got to posting it to this thread:
https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts


So for the positive: Now it's all in a single option so it's clear
that it's defining a single structure.
And the negative: Needs a struct definition, struct, AVOption 
list,

AVClass and actually if you already made a dict out of the options
before, as the functions will free the original after usage and
generate a new one, it destroys the life time expectations of the 
dict

and thus it is just simpler to copy the dict when entering the
function (I think there is an arguments string based API which 
might

or might not actually be simpler for this case).

So yea, not sure if I prefer this version.


Ping.

Did this stall for a reason? How can we iterate on it?


Since the rotation/flip/scale hints are stored in a single data
structure, I prefer a single user option to set those values.


attached patch allows for printing the arguments of the new
-display_rotation (or any) option.

I wrote this in jeeb's github branch [1] where it applies on-top. 
Didn't

test with FFmpeg/HEAD as this still needs cleanup anyways.
Never touched this whole options thing before, I guess there's lot to
complain about...



Indeed. I hope you don't expect us to apply this clone of opt_list 
(the
only difference I found were that you are not printing the 
AV_OPT_FLAG_*

values).


I guess not, more a proof of concept.
More differences are that it does not prefix the arguments with a 
„-“
and it does not print a header like „ AVContext arguments“ (or 
something like that)


Can either be complexified to have these controlled by more args or 
split into several sub functions…?


-Thilo





diff --git a/libavutil/opt.c b/libavutil/opt.c
index 8ffb10449b..428da2319f 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1443,6 +1443,201 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }

+static void arg_list(void *obj, void *av_log_obj, const char *unit, 
enum AVOptionType parent_type)

+{
+const AVOption *opt = NULL;
+AVOptionRanges *r;
+int i;
+
+while ((opt = av_opt_next(obj, opt))) {
+/* Don't print CONST's on level one.
+ * Don't print anything but CONST's on level two.
+ * Only print items from the requested unit.
+ */
+if (!unit && opt->type == AV_OPT_TYPE_CONST)
+continue;
+else if (unit && opt->type != AV_OPT_TYPE_CONST)
+continue;
+else if (unit && opt->type == AV_OPT_TYPE_CONST && 
strcmp(unit, opt->unit))

+continue;
+else if (unit && opt->type == AV_OPT_TYPE_CONST)
+av_log(av_log_obj, AV_LOG_INFO, " %-15s ", 
opt->name);

+else
+av_log(av_log_obj, AV_LOG_INFO, "   %-17s ", opt->name);
+
+switch (opt->type) {
+case AV_OPT_TYPE_FLAGS:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_INT:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
+break;
+case AV_OPT_TYPE_INT64:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_UINT64:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_DOUBLE:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_FLOAT:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_STRING:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_RATIONAL:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_BINARY:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_DICT:
+av_log(av_log_obj, AV_LOG_INFO, "%-12s ", 
"");

+break;
+case AV_OPT_TYPE_IMAGE_SIZE:
+

Re: [FFmpeg-devel] [PATCH] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Thilo Borgmann


On 2 Aug 2022, at 19:10, Nicolas George wrote:

> Jean-Baptiste Kempf (12022-07-24):
>> Have you tried tc@ffmpeg.o.. ?
>
> Thanks.
>
> Would this patch be a good idea?

Of course, thought it would already be there together with CC.

There’s a typo in the mail address, otherwise LGTM.

-Thilo
___
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] Document the addresses of the committees (was: Contact of the Technical Committee)

2022-08-02 Thread Nicolas George
Jean-Baptiste Kempf (12022-07-24):
> Have you tried tc@ffmpeg.o.. ?

Thanks.

Would this patch be a good idea?

Regards,

-- 
  Nicolas George
From e1912c02efa25c7e150e7b4984144ef50c6a Mon Sep 17 00:00:00 2001
From: Nicolas George 
Date: Tue, 2 Aug 2022 19:07:05 +0200
Subject: [PATCH] doc/dev_community: add the addresses of the committees

Omitting the .org from the address should be protection enough
against spam spiders.

Signed-off-by: Nicolas George 
---
 doc/dev_community/community.md | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/dev_community/community.md b/doc/dev_community/community.md
index 21e08e20e3..fdd8552f5d 100644
--- a/doc/dev_community/community.md
+++ b/doc/dev_community/community.md
@@ -55,6 +55,8 @@ Candidates for election can either be suggested or self-nominated.
 
 The conflict resolution process is detailed in the [resolution process](resolution_process.md) document.
 
+The TC can be contacted at .
+
 ## Community committee
 
 The Community Committee (CC) is here to arbitrage and make decisions when
@@ -77,3 +79,5 @@ The members of the CC can be elected from outside of the GA.
 Candidates for election can either be suggested or self-nominated.
 
 The CC is governed by and responsible for enforcing the Code of Conduct.
+
+The CC can be contacted at .
-- 
2.35.1



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

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


Re: [FFmpeg-devel] [PATCH 1/2] ffmpeg: add display_{rotation, hflip, vflip} options

2022-08-02 Thread Andreas Rheinhardt
Thilo Borgmann:
> Hi,
> 
>> On 2022-05-18 11:34 pm, Jan Ekström wrote:
>>> This enables overriding the rotation as well as horizontal/vertical
>>> flip state of a specific video stream on either the input or output
>>> side.
>>
>> Since rotation, flip and scale are stored in a single data structure,
>> how about a single option i.e. -display "rotate=90,flip=hv,scale=2"
>
>
> I did think about that, and I even implemented AVDict based options
> for ffmpeg.c in a branch. But then pretty much got tired of lack of
> AVOption automation (f.ex. for the flip flagging etc), and decided
> that since these are relatively basic and simple, the non-generic
> option for this could be just three options in the initial submission.

 In the end I did implement this with a single dict-based thing in a
 branch but never got to posting it to this thread:
 https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts


 So for the positive: Now it's all in a single option so it's clear
 that it's defining a single structure.
 And the negative: Needs a struct definition, struct, AVOption list,
 AVClass and actually if you already made a dict out of the options
 before, as the functions will free the original after usage and
 generate a new one, it destroys the life time expectations of the dict
 and thus it is just simpler to copy the dict when entering the
 function (I think there is an arguments string based API which might
 or might not actually be simpler for this case).

 So yea, not sure if I prefer this version.
>>>
>>> Ping.
>>>
>>> Did this stall for a reason? How can we iterate on it?
>>
>> Since the rotation/flip/scale hints are stored in a single data
>> structure, I prefer a single user option to set those values.
> 
> attached patch allows for printing the arguments of the new
> -display_rotation (or any) option.
> 
> I wrote this in jeeb's github branch [1] where it applies on-top. Didn't
> test with FFmpeg/HEAD as this still needs cleanup anyways.
> Never touched this whole options thing before, I guess there's lot to
> complain about...
> 

Indeed. I hope you don't expect us to apply this clone of opt_list (the
only difference I found were that you are not printing the AV_OPT_FLAG_*
values).

> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index 8ffb10449b..428da2319f 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -1443,6 +1443,201 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>  }
>  
> +static void arg_list(void *obj, void *av_log_obj, const char *unit, enum 
> AVOptionType parent_type)
> +{
> +const AVOption *opt = NULL;
> +AVOptionRanges *r;
> +int i;
> +
> +while ((opt = av_opt_next(obj, opt))) {
> +/* Don't print CONST's on level one.
> + * Don't print anything but CONST's on level two.
> + * Only print items from the requested unit.
> + */
> +if (!unit && opt->type == AV_OPT_TYPE_CONST)
> +continue;
> +else if (unit && opt->type != AV_OPT_TYPE_CONST)
> +continue;
> +else if (unit && opt->type == AV_OPT_TYPE_CONST && strcmp(unit, 
> opt->unit))
> +continue;
> +else if (unit && opt->type == AV_OPT_TYPE_CONST)
> +av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name);
> +else
> +av_log(av_log_obj, AV_LOG_INFO, "   %-17s ", opt->name);
> +
> +switch (opt->type) {
> +case AV_OPT_TYPE_FLAGS:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_INT:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_INT64:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_UINT64:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_DOUBLE:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_FLOAT:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_STRING:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_RATIONAL:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_BINARY:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_DICT:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case AV_OPT_TYPE_IMAGE_SIZE:
> +av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
> +break;
> +case 

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: Rework the AVIF parser to handle multiple items

2022-08-02 Thread James Zern
Andreas,

On Thu, Jul 28, 2022 at 11:25 AM Vignesh Venkatasubramanian
 wrote:
>
> Stores the item ids of all the items found in the file and
> processes the primary item at the end of the meta box. This patch
> does not change any behavior. It sets up the code for parsing
> alpha channel (and possibly images with 'grid') in follow up
> patches.
>
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  libavformat/isom.h |   6 ++
>  libavformat/mov.c  | 143 +++--
>  2 files changed, 92 insertions(+), 57 deletions(-)
>

Any more comments on this one?

> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index f05c2d9c28..9d8646d2ea 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -318,6 +318,12 @@ typedef struct MOVContext {
>  uint32_t max_stts_delta;
>  int is_still_picture_avif;
>  int primary_item_id;
> +struct {
> +int item_id;
> +int extent_length;
> +int64_t extent_offset;
> +} *avif_info;
> +int avif_info_size;
>  } MOVContext;
>
>  int ff_mp4_read_descr_len(AVIOContext *pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index a09a762d91..6ee6ed0950 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -4698,6 +4698,69 @@ static int mov_read_custom(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  return ret;
>  }
>
> +static int avif_add_stream(MOVContext *c, int item_id)
> +{
> +MOVStreamContext *sc;
> +AVStream *st;
> +int item_index = -1;
> +for (int i = 0; i < c->avif_info_size; i++)
> +if (c->avif_info[i].item_id == item_id) {
> +item_index = i;
> +break;
> +}
> +if (item_index < 0)
> +return AVERROR_INVALIDDATA;
> +st = avformat_new_stream(c->fc, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +st->id = c->fc->nb_streams;
> +sc = av_mallocz(sizeof(MOVStreamContext));
> +if (!sc)
> +return AVERROR(ENOMEM);
> +
> +st->priv_data = sc;
> +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> +st->codecpar->codec_id = AV_CODEC_ID_AV1;
> +sc->ffindex = st->index;
> +c->trak_index = st->index;
> +st->avg_frame_rate.num = st->avg_frame_rate.den = 1;
> +st->time_base.num = st->time_base.den = 1;
> +st->nb_frames = 1;
> +sc->time_scale = 1;
> +sc = st->priv_data;
> +sc->pb = c->fc->pb;
> +sc->pb_is_copied = 1;
> +
> +// Populate the necessary fields used by mov_build_index.
> +sc->stsc_count = 1;
> +sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data));
> +if (!sc->stsc_data)
> +return AVERROR(ENOMEM);
> +sc->stsc_data[0].first = 1;
> +sc->stsc_data[0].count = 1;
> +sc->stsc_data[0].id = 1;
> +sc->chunk_count = 1;
> +sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets));
> +if (!sc->chunk_offsets)
> +return AVERROR(ENOMEM);
> +sc->sample_count = 1;
> +sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));
> +if (!sc->sample_sizes)
> +return AVERROR(ENOMEM);
> +sc->stts_count = 1;
> +sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));
> +if (!sc->stts_data)
> +return AVERROR(ENOMEM);
> +sc->stts_data[0].count = 1;
> +// Not used for still images. But needed by mov_build_index.
> +sc->stts_data[0].duration = 0;
> +sc->sample_sizes[0] = c->avif_info[item_index].extent_length;
> +sc->chunk_offsets[0] = c->avif_info[item_index].extent_offset;
> +
> +mov_build_index(c, st);
> +return 0;
> +}
> +
>  static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>  {
>  while (atom.size > 8) {
> @@ -4707,9 +4770,23 @@ static int mov_read_meta(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  tag = avio_rl32(pb);
>  atom.size -= 4;
>  if (tag == MKTAG('h','d','l','r')) {
> +int ret;
>  avio_seek(pb, -8, SEEK_CUR);
>  atom.size += 8;
> -return mov_read_default(c, pb, atom);
> +if ((ret = mov_read_default(c, pb, atom)) < 0)
> +return ret;
> +if (c->is_still_picture_avif) {
> +int ret;
> +// Add a stream for the YUV planes (primary item).
> +if ((ret = avif_add_stream(c, c->primary_item_id)) < 0)
> +return ret;
> +// For still AVIF images, the meta box contains all the
> +// necessary information that would generally be provided by 
> the
> +// moov box. So simply mark that we have found the moov box 
> so
> +// that parsing can continue.
> +c->found_moov = 1;
> +}
> +return ret;
>  }
>  }
>  return 0;
> @@ -7478,8 +7555,6 @@ static int mov_read_iloc(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  int item_count, extent_count;
>  uint64_t base_offset, 

[FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation

2022-08-02 Thread Nicolas George
Added coverage for the video part of pick_format().

Signed-off-by: Nicolas George 
---


Only video for now, I would like to push before working on audio.
Audio is easier because there are fewer formats.
But audio is also harder because I need to test cases where format
incompatibilities detected in two places for different aspects.

Once I have good coverage, I can reorganise the negotiation process
without risking breaking cases that were previously fixed.

Note: the tests are very fast, since they only init the graph and do not
filter anything.


 tests/Makefile|  1 +
 tests/fate-run.sh |  4 +
 tests/fate/libavfilter.mak| 86 +++
 tests/ref/fate/libavfilter-negotiation-alpha  | 20 +
 ...avfilter-negotiation-alpha-over-chroma-rgb | 20 +
 ...avfilter-negotiation-alpha-over-chroma-yuv | 20 +
 .../libavfilter-negotiation-avoid-subsample   | 20 +
 .../fate/libavfilter-negotiation-chroma-rgb   | 20 +
 .../fate/libavfilter-negotiation-chroma-yuv   | 20 +
 .../libavfilter-negotiation-chroma-yuv420 | 20 +
 ...ibavfilter-negotiation-chroma1-over-depth1 | 20 +
 ...ilter-negotiation-chroma2-over-colorspace8 | 20 +
 ...libavfilter-negotiation-colorspace-rgb-yuv | 20 +
 ...libavfilter-negotiation-colorspace-yuv-rgb | 20 +
 ...vfilter-negotiation-colorspace8-over-alpha | 20 +
 .../fate/libavfilter-negotiation-depth-rgb| 20 +
 .../fate/libavfilter-negotiation-depth-yuv| 20 +
 ...libavfilter-negotiation-depth1-over-depth2 | 20 +
 .../libavfilter-negotiation-depth2-over-alpha | 20 +
 .../fate/libavfilter-negotiation-palette-rgb  | 20 +
 .../fate/libavfilter-negotiation-palette-yuv  | 20 +
 21 files changed, 451 insertions(+)
 create mode 100644 tests/fate/libavfilter.mak
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha-over-chroma-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-avoid-subsample
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma-yuv420
 create mode 100644 tests/ref/fate/libavfilter-negotiation-chroma1-over-depth1
 create mode 100644 
tests/ref/fate/libavfilter-negotiation-chroma2-over-colorspace8
 create mode 100644 tests/ref/fate/libavfilter-negotiation-colorspace-rgb-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-colorspace-yuv-rgb
 create mode 100644 
tests/ref/fate/libavfilter-negotiation-colorspace8-over-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth-yuv
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth1-over-depth2
 create mode 100644 tests/ref/fate/libavfilter-negotiation-depth2-over-alpha
 create mode 100644 tests/ref/fate/libavfilter-negotiation-palette-rgb
 create mode 100644 tests/ref/fate/libavfilter-negotiation-palette-yuv

diff --git a/tests/Makefile b/tests/Makefile
index d9c509a415..c4e01a26e9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -202,6 +202,7 @@ include $(SRC_PATH)/tests/fate/imf.mak
 include $(SRC_PATH)/tests/fate/indeo.mak
 include $(SRC_PATH)/tests/fate/libavcodec.mak
 include $(SRC_PATH)/tests/fate/libavdevice.mak
+include $(SRC_PATH)/tests/fate/libavfilter.mak
 include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 4008bcbc16..53dcbb563b 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -571,6 +571,10 @@ venc_data(){
 run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} 
${thread_type}
 }
 
+lavfi_dump(){
+run ffmpeg${PROGSUF}${EXECSUF} -lavfi_dump -lavfi "$@" -f null -
+}
+
 null(){
 :
 }
diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak
new file mode 100644
index 00..b7d3786942
--- /dev/null
+++ b/tests/fate/libavfilter.mak
@@ -0,0 +1,86 @@
+NEGO_PIXFMT = lavfi_dump  testsrc2=d=0,format=$(1),scale,format=$(2)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing 
alpha
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha
+fate-libavfilter-negotiation-alpha: CMD = $(call 
NEGO_PIXFMT,rgba,yuv444p/yuva444p)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : 
subsampling
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += 
fate-libavfilter-negotiation-avoid-subsample
+fate-libavfilter-negotiation-avoid-subsample: CMD = $(call 
NEGO_PIXFMT,yuv444p,yuv420p10le/yuva444p10le)
+
+# avfiltergraph.c : pick_format() → pixdesc.c : get_pix_fmt_score() : losing 
depth (yuv)

[FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring

2022-08-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavutil/pixdesc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 6e57a82cb6..923a61b0ab 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2866,6 +2866,7 @@ static int get_pix_fmt_score(enum AVPixelFormat 
dst_pix_fmt,
 else
 nb_components = FFMIN(src_desc->nb_components, 
dst_desc->nb_components);
 
+// Penalty for losing depth
 for (i = 0; i < nb_components; i++) {
 int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components 
: (dst_desc->comp[i].depth - 1);
 if (src_desc->comp[i].depth - 1 > depth_minus1 && (consider & 
FF_LOSS_DEPTH)) {
@@ -2874,6 +2875,7 @@ static int get_pix_fmt_score(enum AVPixelFormat 
dst_pix_fmt,
 }
 }
 
+// Penalty for subsampling
 if (consider & FF_LOSS_RESOLUTION) {
 if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
 loss |= FF_LOSS_RESOLUTION;
@@ -2890,6 +2892,7 @@ static int get_pix_fmt_score(enum AVPixelFormat 
dst_pix_fmt,
 }
 }
 
+// Penalty for changing colorspace
 if(consider & FF_LOSS_COLORSPACE)
 switch(dst_color) {
 case FF_COLOR_RGB:
@@ -2920,15 +2923,18 @@ static int get_pix_fmt_score(enum AVPixelFormat 
dst_pix_fmt,
 if(loss & FF_LOSS_COLORSPACE)
 score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, 
src_desc->comp[0].depth - 1);
 
+// Penalty for changing chroma
 if (dst_color == FF_COLOR_GRAY &&
 src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) {
 loss |= FF_LOSS_CHROMA;
 score -= 2 * 65536;
 }
+// Penalty for losing alpha
 if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && 
(consider & FF_LOSS_ALPHA))) {
 loss |= FF_LOSS_ALPHA;
 score -= 65536;
 }
+// Penalty for using a palette
 if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) &&
 (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || 
(pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA) {
 loss |= FF_LOSS_COLORQUANT;
-- 
2.35.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 5/7] lavfi/(a)format: support slash as a delimiter

2022-08-02 Thread Nicolas George
Unlike pipe, slash does not require escaping.

Signed-off-by: Nicolas George 
---
 doc/filters.texi   | 8 
 libavfilter/internal.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)


Identical to the one posted months ago.


diff --git a/doc/filters.texi b/doc/filters.texi
index 4a5412c91d..e334ac0e16 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1693,13 +1693,13 @@ It accepts the following parameters:
 @table @option
 
 @item sample_fmts, f
-A '|'-separated list of requested sample formats.
+A '|'- or '/'-separated list of requested sample formats.
 
 @item sample_rates, r
-A '|'-separated list of requested sample rates.
+A '|'- or '/'-separated list of requested sample rates.
 
 @item channel_layouts, cl
-A '|'-separated list of requested channel layouts.
+A '|'- or '/'-separated list of requested channel layouts.
 
 See @ref{channel layout syntax,,the Channel Layout section in the 
ffmpeg-utils(1) manual,ffmpeg-utils}
 for the required syntax.
@@ -13379,7 +13379,7 @@ It accepts the following parameters:
 @table @option
 
 @item pix_fmts
-A '|'-separated list of pixel format names, such as
+A '|'- or '/'-separated list of pixel format names, such as
 "pix_fmts=yuv420p|monow|rgb24".
 
 @end table
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 6dbe7ecee0..cfb748f7db 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -411,7 +411,7 @@ int ff_filter_init_hw_frames(AVFilterContext *avctx, 
AVFilterLink *link,
  */
 static inline char *ff_formats_list_find_delimiter(const char *str)
 {
-return (char *)str + strcspn(str, "|");
+return (char *)str + strcspn(str, "|/");
 }
 
 #endif /* AVFILTER_INTERNAL_H */
-- 
2.35.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 4/7] lavfi/(a)format: factor finding the delimiter

2022-08-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/af_aformat.c | 8 +---
 libavfilter/internal.h   | 9 +
 libavfilter/vf_format.c  | 9 -
 3 files changed, 18 insertions(+), 8 deletions(-)


Identical to the one posted months ago.


diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index a14e4c1240..addabafbfa 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -65,10 +65,12 @@ do {
\
 char *next, *cur = str; \
 int ret;\
 \
-while (cur) {   \
+if (!cur)   \
+break;  \
+while (*cur) {  \
 type fmt;   \
-next = strchr(cur, '|');\
-if (next)   \
+next = ff_formats_list_find_delimiter(cur); \
+if (*next)  \
 *next++ = 0;\
 \
 if ((fmt = get_fmt(cur)) == none) { \
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 0f8da367d0..6dbe7ecee0 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -405,4 +405,13 @@ int ff_filter_process_command(AVFilterContext *ctx, const 
char *cmd,
 int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
  int default_pool_size);
 
+/**
+ * Find the next delimiter in a string of formats.
+ * The delimiter is '|' or the end of the string.
+ */
+static inline char *ff_formats_list_find_delimiter(const char *str)
+{
+return (char *)str + strcspn(str, "|");
+}
+
 #endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index 24b1c9ca61..b3f168a531 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -69,10 +69,9 @@ static av_cold int init(AVFilterContext *ctx)
 
 /* count the formats */
 cur = s->pix_fmts;
-while ((cur = strchr(cur, '|'))) {
+while (*(cur = ff_formats_list_find_delimiter(cur))) {
 nb_formats++;
-if (*cur)
-cur++;
+cur++;
 }
 
 s->formats = av_malloc_array(nb_formats + 1, sizeof(*s->formats));
@@ -82,8 +81,8 @@ static av_cold int init(AVFilterContext *ctx)
 /* parse the list of formats */
 cur = s->pix_fmts;
 for (i = 0; i < nb_formats; i++) {
-sep = strchr(cur, '|');
-if (sep)
+sep = ff_formats_list_find_delimiter(cur);
+if (*sep)
 *sep++ = 0;
 
 if ((ret = ff_parse_pixel_format(>formats[i], cur, ctx)) < 0)
-- 
2.35.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/7] lavu/pixfmt: summarize yuv naming conventions

2022-08-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavutil/pixfmt.h | 17 +
 1 file changed, 17 insertions(+)


Identical to the one I posted last week.


diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2d3927cc3f..3d0f92ed4d 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -60,6 +60,23 @@
  * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
  * for pal8. This palette is filled in automatically by the function
  * allocating the picture.
+ *
+ * @par
+ * Summary of the naming conventions for YUV formats:
+ *444 422 440 420 411 410
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╂─╂─╂─╂─╂   ╂─┼─╂─┼─╂   ╋━┿━┿━┿━╋   ╂─┼─┼─┼─╂
+ * ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━╋━╋━╋━╋   ╋━┿━╋━┿━╋   ╋━┿━┿━┿━╋   ╋━┿━┿━┿━╋
+ * where
+ * ┼─┼ = luma pixel  ╋━╋ = chroma pixel
+ * ┼─┼   ╋━╋
+ *
+ * yuv4ab →
+ *  log2_chroma_w = log₂(4/a)
+ *  log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused
+ * i.e. a = horizontally, number of luma pixels for four chroma pixels
  */
 enum AVPixelFormat {
 AV_PIX_FMT_NONE = -1,
-- 
2.35.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/7] lavfi/graphdump: add plain listing output

2022-08-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.h  |  5 ++-
 libavfilter/graphdump.c | 79 +++--
 2 files changed, 80 insertions(+), 4 deletions(-)


Identical to the one posted months ago.


diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 2e8197c9a6..ad38f1bdc2 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -1163,7 +1163,10 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, 
const char *target, const
  * Dump a graph into a human-readable string representation.
  *
  * @param graphthe graph to dump
- * @param options  formatting options; currently ignored
+ * @param options  formatting options; can be NULL, empty
+ * or "f=aa" for clumsy ascii-art drawing,
+ * or "f=tech" for plain listing;
+ * other values silently ignored
  * @return  a string, or NULL in case of memory allocation failure;
  *  the string must be freed using av_free
  */
diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index 80f7bf6c98..992183a882 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -27,6 +27,9 @@
 #include "avfilter.h"
 #include "internal.h"
 
+#define FORMAT_AA 0
+#define FORMAT_TECH 1
+
 static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
 {
 const char *format;
@@ -62,7 +65,51 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
 return buf->len;
 }
 
-static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
+static inline const char *fcname(const AVFilterContext *filter)
+{
+return filter->name ? filter->name : "";
+}
+
+static void dump_tech(AVBPrint *buf, AVFilterGraph *graph)
+{
+unsigned i, j;
+
+for (i = 0; i < graph->nb_filters; i++) {
+AVFilterContext *filter = graph->filters[i];
+
+if (i)
+av_bprintf(buf, "\n");
+av_bprintf(buf, "Filter: %s (%s)\n", fcname(filter), 
filter->filter->name);
+
+for (j = 0; j < filter->nb_inputs; j++) {
+AVFilterPad *pad = >input_pads[j];
+AVFilterLink *link = filter->inputs[j];
+AVFilterPad *ppad = link->srcpad;
+AVFilterContext *peer = link->src;
+
+av_bprintf(buf, "  in %d: %s ← %s.%d:%s ",
+   j, pad->name,
+   fcname(peer), FF_OUTLINK_IDX(link), ppad->name);
+print_link_prop(buf, link);
+av_bprintf(buf, "\n");
+}
+
+for (j = 0; j < filter->nb_outputs; j++) {
+AVFilterPad *pad = >output_pads[j];
+AVFilterLink *link = filter->outputs[j];
+AVFilterPad *ppad = link->dstpad;
+AVFilterContext *peer = link->dst;
+
+av_bprintf(buf, "  out %d: %s → %s.%d:%s ",
+   j, pad->name,
+   fcname(peer), FF_INLINK_IDX(link), ppad->name);
+print_link_prop(buf, link);
+av_bprintf(buf, "\n");
+}
+}
+}
+
+static void dump_ascii_art(AVBPrint *buf, AVFilterGraph *graph)
 {
 unsigned i, j, x, e;
 
@@ -154,17 +201,43 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, 
AVFilterGraph *graph)
 }
 }
 
+static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph, 
const char *options)
+{
+unsigned format = FORMAT_AA;
+
+/* For a very long time, options was ignored.
+   Having a string for that task was a mistake, but it is not important.
+   It is not worth a proper parsing.
+ */
+if (options && *options) {
+if (!strcmp("f=aa", options)) {
+format = FORMAT_AA;
+} else if (!strcmp("f=tech", options)) {
+format = FORMAT_TECH;
+}
+/* ignore other values */
+}
+switch (format) {
+case FORMAT_AA:
+dump_ascii_art(buf, graph);
+break;
+case FORMAT_TECH:
+dump_tech(buf, graph);
+break;
+}
+}
+
 char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
 {
 AVBPrint buf;
 char *dump = NULL;
 
 av_bprint_init(, 0, AV_BPRINT_SIZE_COUNT_ONLY);
-avfilter_graph_dump_to_buf(, graph);
+avfilter_graph_dump_to_buf(, graph, options);
 dump = av_malloc(buf.len + 1);
 if (!dump)
 return NULL;
 av_bprint_init_for_buffer(, dump, buf.len + 1);
-avfilter_graph_dump_to_buf(, graph);
+avfilter_graph_dump_to_buf(, graph, options);
 return dump;
 }
-- 
2.35.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/7] fftools: add -lavfi_dump option

2022-08-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 doc/ffmpeg.texi |  4 
 fftools/ffmpeg.h|  1 +
 fftools/ffmpeg_filter.c | 14 ++
 fftools/ffmpeg_opt.c|  3 +++
 4 files changed, 22 insertions(+)


Identical to the one posted months ago.


diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 2fb0bc8ffa..1a342846c2 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1902,6 +1902,10 @@ The default is the number of available CPUs.
 Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
 outputs. Equivalent to @option{-filter_complex}.
 
+@anchor{lavfi_dump option}
+@item -lavfi_dump (@emph{global})
+Dump the filter graphs and their negotiated formats to standard output.
+
 @item -filter_complex_script @var{filename} (@emph{global})
 This option is similar to @option{-filter_complex}, the only difference is that
 its argument is the name of the file from which a complex filtergraph
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6417db03bd..d2ec8ea257 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -654,6 +654,7 @@ extern char *filter_nbthreads;
 extern int filter_complex_nbthreads;
 extern int vstats_version;
 extern int auto_conversion_filters;
+extern int dump_filtergraphs;
 
 extern const AVIOInterruptCB int_cb;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index f9ae76f76d..973de34b5f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1070,6 +1070,20 @@ int configure_filtergraph(FilterGraph *fg)
 avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
 goto fail;
+if (dump_filtergraphs) {
+char *dump = avfilter_graph_dump(fg->graph, "f=tech");
+if (!dump)
+return AVERROR(ENOMEM);
+if (simple) {
+OutputStream *ost = fg->outputs[0]->ost;
+printf("Dump of filter graph for output #%d:%d:", ost->file_index, 
ost->index);
+} else {
+printf("Dump of complex filter graph #%d:", fg->index);
+}
+printf("\n\n%s\n", dump);
+av_free(dump);
+fflush(stdout);
+}
 
 fg->is_meta = graph_is_meta(fg->graph);
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a96bcf9b8a..6404412f5a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -178,6 +178,7 @@ char *filter_nbthreads;
 int filter_complex_nbthreads = 0;
 int vstats_version = 2;
 int auto_conversion_filters = 1;
+int dump_filtergraphs = 0;
 int64_t stats_period = 50;
 
 
@@ -3947,6 +3948,8 @@ const OptionDef options[] = {
 "number of threads for -filter_complex" },
 { "lavfi",  HAS_ARG | OPT_EXPERT,{ 
.func_arg = opt_filter_complex },
 "create a complex filtergraph", "graph_description" },
+{ "lavfi_dump", OPT_BOOL | OPT_EXPERT,   { 
_filtergraphs },
+"dump filter graphs to standard output" },
 { "filter_complex_script", HAS_ARG | OPT_EXPERT, { 
.func_arg = opt_filter_complex_script },
 "read complex filtergraph description from a file", "filename" },
 { "auto_conversion_filters", OPT_BOOL | OPT_EXPERT,  { 
_conversion_filters },
-- 
2.35.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 1/2] ffmpeg: add display_{rotation, hflip, vflip} options

2022-08-02 Thread Thilo Borgmann

Am 02.08.22 um 18:48 schrieb Thilo Borgmann:

Hi,


On 2022-05-18 11:34 pm, Jan Ekström wrote:

This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on either the input or output
side.


Since rotation, flip and scale are stored in a single data structure,
how about a single option i.e. -display "rotate=90,flip=hv,scale=2"



I did think about that, and I even implemented AVDict based options for 
ffmpeg.c in a branch. But then pretty much got tired of lack of AVOption 
automation (f.ex. for the flip flagging etc), and decided that since these are 
relatively basic and simple, the non-generic option for this could be just 
three options in the initial submission.


In the end I did implement this with a single dict-based thing in a
branch but never got to posting it to this thread:
https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts

So for the positive: Now it's all in a single option so it's clear
that it's defining a single structure.
And the negative: Needs a struct definition, struct, AVOption list,
AVClass and actually if you already made a dict out of the options
before, as the functions will free the original after usage and
generate a new one, it destroys the life time expectations of the dict
and thus it is just simpler to copy the dict when entering the
function (I think there is an arguments string based API which might
or might not actually be simpler for this case).

So yea, not sure if I prefer this version.


Ping.

Did this stall for a reason? How can we iterate on it?


Since the rotation/flip/scale hints are stored in a single data structure, I 
prefer a single user option to set those values.


attached patch allows for printing the arguments of the new -display_rotation 
(or any) option.

I wrote this in jeeb's github branch [1] where it applies on-top. Didn't test 
with FFmpeg/HEAD as this still needs cleanup anyways.
Never touched this whole options thing before, I guess there's lot to complain 
about...


Produced output looks like:

-display_matrix arguments  define a display matrix with rotation and/or 
horizontal/vertical flip for stream(s)
   rotationset rotation (from -DBL_MAX to DBL_MAX) 
(default DBL_MAX)
   hflip  set hflip (default auto)
   vflip  set vflip (default auto)



-Thilo

[1] https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts

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

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


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

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


Re: [FFmpeg-devel] [PATCH 1/2] ffmpeg: add display_{rotation, hflip, vflip} options

2022-08-02 Thread Thilo Borgmann

Hi,


On 2022-05-18 11:34 pm, Jan Ekström wrote:

This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on either the input or output
side.


Since rotation, flip and scale are stored in a single data structure,
how about a single option i.e. -display "rotate=90,flip=hv,scale=2"



I did think about that, and I even implemented AVDict based options for 
ffmpeg.c in a branch. But then pretty much got tired of lack of AVOption 
automation (f.ex. for the flip flagging etc), and decided that since these are 
relatively basic and simple, the non-generic option for this could be just 
three options in the initial submission.


In the end I did implement this with a single dict-based thing in a
branch but never got to posting it to this thread:
https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts

So for the positive: Now it's all in a single option so it's clear
that it's defining a single structure.
And the negative: Needs a struct definition, struct, AVOption list,
AVClass and actually if you already made a dict out of the options
before, as the functions will free the original after usage and
generate a new one, it destroys the life time expectations of the dict
and thus it is just simpler to copy the dict when entering the
function (I think there is an arguments string based API which might
or might not actually be simpler for this case).

So yea, not sure if I prefer this version.


Ping.

Did this stall for a reason? How can we iterate on it?


Since the rotation/flip/scale hints are stored in a single data structure, I 
prefer a single user option to set those values.


attached patch allows for printing the arguments of the new -display_rotation 
(or any) option.

I wrote this in jeeb's github branch [1] where it applies on-top. Didn't test 
with FFmpeg/HEAD as this still needs cleanup anyways.
Never touched this whole options thing before, I guess there's lot to complain 
about...

-Thilo

[1] https://github.com/jeeb/ffmpeg/commits/ffmpeg_c_display_matrix_with_dicts
From 4fae59de38c93a4cdd079535cc3631f9ccadced1 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Tue, 2 Aug 2022 18:39:18 +0200
Subject: [PATCH] ffmpeg: Allow printing of option arguments in help output

---
 fftools/cmdutils.c   |   5 ++
 fftools/cmdutils.h   |   1 +
 fftools/ffmpeg_opt.c |  56 ++--
 libavutil/opt.c  | 205 +++
 libavutil/opt.h  |   7 ++
 5 files changed, 247 insertions(+), 27 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 9c475acf7f..73362e5af2 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -169,6 +169,11 @@ void show_help_options(const OptionDef *options, const 
char *msg, int req_flags,
 av_strlcat(buf, po->argname, sizeof(buf));
 }
 printf("-%-17s  %s\n", buf, po->help);
+
+if (po->args) {
+const AVClass *p = po->args;
+av_arg_show(, NULL);
+}
 }
 printf("\n");
 }
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 6a519c6546..df90cc6958 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -166,6 +166,7 @@ typedef struct OptionDef {
 } u;
 const char *help;
 const char *argname;
+const AVClass *args;
 } OptionDef;
 
 /**
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 8dffe7c225..d8db0f0681 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -114,6 +114,32 @@ static const char *const opt_name_time_bases[] 
   = {"time_base", NU
 static const char *const opt_name_enc_time_bases[]= 
{"enc_time_base", NULL};
 static const char *const opt_name_bits_per_raw_sample[]   = 
{"bits_per_raw_sample", NULL};
 
+// XXX this should probably go into a seperate file _args.c and 
#included here
+struct display_matrix_s {
+const AVClass *class;
+double  rotation;
+int hflip;
+int vflip;
+};
+#define OFFSET(x) offsetof(struct display_matrix_s, x)
+static const AVOption display_matrix_args[] = {
+{ "rotation", "set rotation", OFFSET(rotation), AV_OPT_TYPE_DOUBLE,
+{ .dbl = DBL_MAX }, -(DBL_MAX), DBL_MAX - 1.0f, 
AV_OPT_FLAG_EXPORT},
+{ "hflip","set hflip", OFFSET(hflip),AV_OPT_TYPE_BOOL,
+{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_EXPORT},
+{ "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL,
+{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_EXPORT},
+{ NULL },
+};
+static const AVClass class_display_matrix_args = {
+.class_name = "display_matrix_args",
+.item_name  = av_default_item_name,
+.option = display_matrix_args,
+.version= LIBAVUTIL_VERSION_INT,
+};
+#undef OFFSET
+// XXX
+
 #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
 {\
 char namestr[128] = "";\
@@ -755,39 +781,15 @@ static int opt_recording_timestamp(void *optctx, const 
char 

Re: [FFmpeg-devel] [PATCH] avcodec/pthread_frame: update the main avctx from the current, ThreadContext

2022-08-02 Thread Anton Khirnov
Why are you not resubmitting your original patch that stops copying
hwaccel_priv_data to the user-facing context?

It seemed more correct to me, since the user-facing context should never
see any hwaccel data. Or does it not fix the issue fully?

For a more proper fix, we probably want to bundle hwaccel+state+uninit
to a single refcounted thing.

-- 
Anton Khirnov
___
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/libaomenc: support AV_CODEC_CAP_ENCODER_RECON_FRAME

2022-08-02 Thread James Almer

On 8/2/2022 8:58 AM, Anton Khirnov wrote:

Quoting James Almer (2022-08-02 13:35:19)

Signed-off-by: James Almer 
---
  libavcodec/Makefile|  4 +-
  libavcodec/libaom.c| 49 +
  libavcodec/libaom.h| 33 ++
  libavcodec/libaomdec.c | 27 +---
  libavcodec/libaomenc.c | 97 ++
  5 files changed, 183 insertions(+), 27 deletions(-)
  create mode 100644 libavcodec/libaom.c
  create mode 100644 libavcodec/libaom.h


Not knowing anything about aomenc, this looks reasonable assuming it's
tested and works.

I have a WIP test tool in branch 'recon' in my tree in case you have
trouble testing this.


Tested with that tool and confirmed working, so applied.

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

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


Re: [FFmpeg-devel] [PATCH] swscale: add NV16 input/output

2022-08-02 Thread Matthieu Bouron
On Thu, Jul 14, 2022 at 8:10 PM Michael Niedermayer 
wrote:

> On Fri, Jul 01, 2022 at 10:08:14AM +0200, Matthieu Bouron wrote:
> > On Sat, Jun 11, 2022 at 5:35 PM Michael Niedermayer <
> mich...@niedermayer.cc>
> > wrote:
> >
> > > On Fri, Jun 10, 2022 at 04:11:10PM +0200, Matthieu Bouron wrote:
> > > > On Thu, Jun 2, 2022 at 9:13 PM Michael Niedermayer <
> > > mich...@niedermayer.cc>
> > > > wrote:
> > > >
> > > > > On Wed, Jun 01, 2022 at 10:33:37PM +0200, Matthieu Bouron wrote:
> > > > > > ---
> > > > > >  libswscale/input.c   | 1 +
> > > > > >  libswscale/utils.c   | 1 +
> > > > > >  libswscale/version.h | 2 +-
> > > > > >  tests/ref/fate/filter-pixdesc-nv16   | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-copy   | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-crop   | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-field  | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-fieldorder | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-hflip  | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-il | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-null   | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-pad| 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-scale  | 1 +
> > > > > >  tests/ref/fate/filter-pixfmts-vflip  | 1 +
> > > > > >  14 files changed, 14 insertions(+), 1 deletion(-)
> > > > > >  create mode 100644 tests/ref/fate/filter-pixdesc-nv16
> > > > >
> > > > >
> > > > Sorry for the late reply
> > > >
> > > >
> > > > > has this been tested ? (various scaled and non scaled) variants ?
> > > > >
> > > >
> > > > I only tested the non scaled variant using the command line doing
> > > multiple
> > > > round trips to/from nv16.
> > > > Is there a particular test procedure to validate every variants ?
> > >
> > > you can test manually or use something like
> > > libswscale/tests/swscale.c
> > >
> >
> > I manually tested without any issue: il, field, fieldorder, copy, crop,
> > hflip, null, pad, scale and vflip.
>
> if that included up & down scaling while changing format then it should be
> ok
>

It included up and down scaling.

[...]
___
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] ffmpeg: refactor post-decoding steps for subtitles into a function

2022-08-02 Thread Anton Khirnov
Quoting Jan Ekström (2022-07-29 15:35:36)
> From: Jan Ekström 
> 
> This enables us to later call this when generating additional
> subtitles for splitting purposes.
> 
> Co-authored-by: Andrzej Nadachowski 
> 
> Signed-off-by: Jan Ekström 
> ---
>  fftools/ffmpeg.c | 50 
>  1 file changed, 29 insertions(+), 21 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 4746742c02..adcab43a30 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2301,27 +2301,16 @@ fail:
>  return err < 0 ? err : ret;
>  }
>  
> -static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int 
> *got_output,
> -   int *decode_failed)
> +static int encode_mux_subtitles(InputStream *ist, AVSubtitle *subtitle, int 
> *got_output)

A function called 'encode_mux' should not be doing anything with an
input stream.

I also think this will spurisouly increment ist->frames_decoded after
the second patch.

-- 
Anton Khirnov
___
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/libaomenc: support AV_CODEC_CAP_ENCODER_RECON_FRAME

2022-08-02 Thread Anton Khirnov
Quoting James Almer (2022-08-02 13:35:19)
> Signed-off-by: James Almer 
> ---
>  libavcodec/Makefile|  4 +-
>  libavcodec/libaom.c| 49 +
>  libavcodec/libaom.h| 33 ++
>  libavcodec/libaomdec.c | 27 +---
>  libavcodec/libaomenc.c | 97 ++
>  5 files changed, 183 insertions(+), 27 deletions(-)
>  create mode 100644 libavcodec/libaom.c
>  create mode 100644 libavcodec/libaom.h

Not knowing anything about aomenc, this looks reasonable assuming it's
tested and works.

I have a WIP test tool in branch 'recon' in my tree in case you have
trouble testing this.

-- 
Anton Khirnov
___
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/libaomenc: support AV_CODEC_CAP_ENCODER_RECON_FRAME

2022-08-02 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/Makefile|  4 +-
 libavcodec/libaom.c| 49 +
 libavcodec/libaom.h| 33 ++
 libavcodec/libaomdec.c | 27 +---
 libavcodec/libaomenc.c | 97 ++
 5 files changed, 183 insertions(+), 27 deletions(-)
 create mode 100644 libavcodec/libaom.c
 create mode 100644 libavcodec/libaom.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index aff7752856..ca5a38bee1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1055,8 +1055,8 @@ OBJS-$(CONFIG_ALAC_AT_ENCODER)+= 
audiotoolboxenc.o
 OBJS-$(CONFIG_ILBC_AT_ENCODER)+= audiotoolboxenc.o
 OBJS-$(CONFIG_PCM_ALAW_AT_ENCODER)+= audiotoolboxenc.o
 OBJS-$(CONFIG_PCM_MULAW_AT_ENCODER)   += audiotoolboxenc.o
-OBJS-$(CONFIG_LIBAOM_AV1_DECODER) += libaomdec.o
-OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += libaomenc.o
+OBJS-$(CONFIG_LIBAOM_AV1_DECODER) += libaomdec.o libaom.o
+OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += libaomenc.o libaom.o
 OBJS-$(CONFIG_LIBARIBB24_DECODER) += libaribb24.o ass.o
 OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o
 OBJS-$(CONFIG_LIBCODEC2_DECODER)  += libcodec2.o
diff --git a/libavcodec/libaom.c b/libavcodec/libaom.c
new file mode 100644
index 00..0befaaa530
--- /dev/null
+++ b/libavcodec/libaom.c
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * AOM common functions
+ */
+
+#include "libavutil/pixdesc.h"
+#include "libaom.h"
+
+void ff_aom_image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
+int i;
+
+for (i = 0; i < desc->nb_components; i++) {
+int w = img->d_w;
+int h = img->d_h;
+int x, y;
+
+if (i) {
+w = (w + img->x_chroma_shift) >> img->x_chroma_shift;
+h = (h + img->y_chroma_shift) >> img->y_chroma_shift;
+}
+
+for (y = 0; y < h; y++) {
+uint16_t *src = (uint16_t *)(img->planes[i] + y * img->stride[i]);
+uint8_t *dst = pic->data[i] + y * pic->linesize[i];
+for (x = 0; x < w; x++)
+*dst++ = *src++;
+}
+}
+}
diff --git a/libavcodec/libaom.h b/libavcodec/libaom.h
new file mode 100644
index 00..bb495af982
--- /dev/null
+++ b/libavcodec/libaom.h
@@ -0,0 +1,33 @@
+/*
+ * 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
+ * AOM common functions
+ */
+
+#ifndef AVCODEC_LIBAOM_H
+#define AVCODEC_LIBAOM_H
+
+#include 
+
+#include "libavutil/frame.h"
+
+void ff_aom_image_copy_16_to_8(AVFrame *pic, struct aom_image *img);
+
+#endif /* AVCODEC_LIBAOM_H */
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index 3243610304..cb672b0e65 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -33,6 +33,7 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "internal.h"
+#include "libaom.h"
 #include "profiles.h"
 
 typedef struct AV1DecodeContext {
@@ -60,30 +61,6 @@ static av_cold int aom_init(AVCodecContext *avctx,
 return 0;
 }
 
-static void image_copy_16_to_8(AVFrame *pic, struct aom_image *img)
-{
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format);
-int i;
-
-for (i = 0; i < desc->nb_components; i++) {
-int w = img->d_w;
-int h = img->d_h;
-int x, y;
-
-if (i) {
-w = (w + img->x_chroma_shift) >> 

Re: [FFmpeg-devel] [PATCH v4 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2022-08-02 Thread Anton Khirnov
Quoting Xiang, Haihao (2022-08-02 09:56:01)
> From: Haihao Xiang 
> 
> Usually a HW decoder is expected when user specifies a HW acceleration
> method via -hwaccel option, however the current implementation doesn't
> take HW acceleration method into account, it is possible to select a SW
> decoder.
> 
> For example:
> $ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
> $ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
> $ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
> [...]
> Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))
> 
> libdav1d is selected in this case even if vaapi, nvdec or vdpau is
> specified.
> 
> After applying this patch, the native av1 decoder (with vaapi, nvdec or
> vdpau support) is selected for decoding(libdav1d is still used for
> probing format).
> $ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
> $ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
> $ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
> [...]
> Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))
> 
> Tested-by: Mario Roy 
> Signed-off-by: Haihao Xiang 
> ---
>  fftools/ffmpeg_opt.c | 31 +++
>  1 file changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index cf0c31bdc2..db51cca66d 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -857,7 +857,9 @@ static const AVCodec *find_codec_or_die(const char *name, 
> enum AVMediaType type,
>  return codec;
>  }
>  
> -static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, 
> AVStream *st)
> +static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, 
> AVStream *st,
> + enum HWAccelID hwaccel_id, enum 
> AVHWDeviceType hwaccel_device_type)
> +
>  {
>  char *codec_name = NULL;
>  
> @@ -868,8 +870,29 @@ static const AVCodec *choose_decoder(OptionsContext *o, 
> AVFormatContext *s, AVSt
>  if (recast_media && st->codecpar->codec_type != codec->type)
>  st->codecpar->codec_type = codec->type;
>  return codec;
> -} else
> +} else {
> +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> +hwaccel_id == HWACCEL_GENERIC &&
> +hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
> +const AVCodec *c;
> +void *i = NULL;
> +
> +while ((c = av_codec_iterate())) {
> +const AVCodecHWConfig *config;
> +
> +if (c->id != st->codecpar->codec_id ||
> +!av_codec_is_decoder(c))
> +continue;
> +
> +for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
> +if (config->device_type == hwaccel_device_type)
> +return c;

Maybe a verbose-level log message like

"Selecting decoder '%s' because of requested hwaccel method %s\n",
c->name, av_hwdevice_get_type_name(hwaccel_device_type)

would be appropriate. No need to send a new patch, just add it (or not,
as you like) and push.

-- 
Anton Khirnov
___
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 v12 11/13] lavc/qsv: create mfx session using oneVPL for decoding/encoding

2022-08-02 Thread Anton Khirnov
Quoting Xiang, Haihao (2022-08-02 10:20:16)
> Thanks for the comment. I planed to cleanup qsv code, including duplicated 
> code
> in the current qsv filters. Does it make sense to enable/merge oneVPL firstly
> then cleanup qsv in new patches?

Sure, I do not insist it's done right now, given that duplication
already exists.
It would be nice to do it at some point though.

-- 
Anton Khirnov
___
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/aacdec: print a log message when treating mono HE-AAC as stereo

2022-08-02 Thread Anton Khirnov
Quoting James Almer (2022-07-28 19:22:47)
> Since this behavior is intentional, use the VERBOSE level instead of WARNING 
> as
> it's nothing the user should worry about.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/aac.h | 1 +
>  libavcodec/aacdec_template.c | 4 
>  libavcodec/aacsbr_template.c | 2 ++
>  3 files changed, 7 insertions(+)
> 
> diff --git a/libavcodec/aac.h b/libavcodec/aac.h
> index 53be546857..c8d6b17710 100644
> --- a/libavcodec/aac.h
> +++ b/libavcodec/aac.h
> @@ -366,6 +366,7 @@ struct AACContext {
>  int warned_960_sbr;
>  unsigned warned_71_wide;
>  int warned_gain_control;
> +int warned_he_aac_mono;

I now count 6 warned_foo vars in the context, which is quite wasteful.
We might want to change those into flags.

-- 
Anton Khirnov
___
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] avdevice/v4l2: fix leak of timefilter

2022-08-02 Thread Anton Khirnov
Quoting Zhao Zhili (2022-07-26 18:32:51)
> From: Zhao Zhili 
> 
> Fixes ticket #9844.
> ---
> I don't have a camera for test. So I'm not sure if it's the only case
> of memleak in ticket #9844.
> 
>  libavdevice/v4l2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 5340382d57..be422d7c8c 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -1011,6 +1011,7 @@ static int v4l2_read_close(AVFormatContext *ctx)
>  
>  mmap_close(s);
>  
> +ff_timefilter_destroy(s->timefilter);

Tested, works, LGTM

-- 
Anton Khirnov
___
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] ffmpeg: refactor post-decoding steps for subtitles into a function

2022-08-02 Thread Anton Khirnov
Quoting Jan Ekström (2022-07-29 15:35:36)
> From: Jan Ekström 
> 
> This enables us to later call this when generating additional
> subtitles for splitting purposes.
> 
> Co-authored-by: Andrzej Nadachowski 
> 
> Signed-off-by: Jan Ekström 
> ---
>  fftools/ffmpeg.c | 50 
>  1 file changed, 29 insertions(+), 21 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 4746742c02..adcab43a30 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2301,27 +2301,16 @@ fail:
>  return err < 0 ? err : ret;
>  }
>  
> -static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int 
> *got_output,
> -   int *decode_failed)
> +static int encode_mux_subtitles(InputStream *ist, AVSubtitle *subtitle, int 
> *got_output)
>  {
> -AVSubtitle subtitle;
> +int ret = 0;
>  int free_sub = 1;
> -int i, ret = avcodec_decode_subtitle2(ist->dec_ctx,
> -  , got_output, pkt);
>  
> -check_decode_result(NULL, got_output, ret);
> -
> -if (ret < 0 || !*got_output) {
> -*decode_failed = 1;
> -if (!pkt->size)
> -sub2video_flush(ist);
> -return ret;
> -}
>  
>  if (ist->fix_sub_duration) {
>  int end = 1;
>  if (ist->prev_sub.got_output) {
> -end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,
> +end = av_rescale(subtitle->pts - ist->prev_sub.subtitle.pts,
>   1000, AV_TIME_BASE);
>  if (end < ist->prev_sub.subtitle.end_display_time) {
>  av_log(NULL, AV_LOG_DEBUG,
> @@ -2333,7 +2322,7 @@ static int transcode_subtitles(InputStream *ist, 
> AVPacket *pkt, int *got_output,
>  }
>  FFSWAP(int,*got_output, ist->prev_sub.got_output);
>  FFSWAP(int,ret, ist->prev_sub.ret);
> -FFSWAP(AVSubtitle, subtitle,ist->prev_sub.subtitle);
> +FFSWAP(AVSubtitle, *subtitle,   ist->prev_sub.subtitle);
>  if (end <= 0)
>  goto out;
>  }
> @@ -2342,40 +2331,59 @@ static int transcode_subtitles(InputStream *ist, 
> AVPacket *pkt, int *got_output,
>  return ret;
>  
>  if (ist->sub2video.frame) {
> -sub2video_update(ist, INT64_MIN, );
> +sub2video_update(ist, INT64_MIN, subtitle);
>  } else if (ist->nb_filters) {
>  if (!ist->sub2video.sub_queue)
>  ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), 
> AV_FIFO_FLAG_AUTO_GROW);
>  if (!ist->sub2video.sub_queue)
>  exit_program(1);
>  
> -ret = av_fifo_write(ist->sub2video.sub_queue, , 1);
> +ret = av_fifo_write(ist->sub2video.sub_queue, subtitle, 1);
>  if (ret < 0)
>  exit_program(1);
>  free_sub = 0;
>  }
>  
> -if (!subtitle.num_rects)
> +if (!subtitle->num_rects)
>  goto out;
>  
>  ist->frames_decoded++;
>  
> -for (i = 0; i < nb_output_streams; i++) {
> +for (int i = 0; i < nb_output_streams; i++) {
>  OutputStream *ost = output_streams[i];
>  
>  if (!check_output_constraints(ist, ost) || !ost->encoding_needed
>  || ost->enc->type != AVMEDIA_TYPE_SUBTITLE)
>  continue;
>  
> -do_subtitle_out(output_files[ost->file_index], ost, );
> +do_subtitle_out(output_files[ost->file_index], ost, subtitle);
>  }
>  
>  out:
>  if (free_sub)
> -avsubtitle_free();
> +avsubtitle_free(subtitle);
>  return ret;
>  }
>  
> +static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int 
> *got_output,
> +   int *decode_failed)
> +{
> +AVSubtitle subtitle;
> +int ret = avcodec_decode_subtitle2(ist->dec_ctx,
> +   , got_output, pkt);
> +
> +check_decode_result(NULL, got_output, ret);
> +
> +if (ret < 0 || !*got_output) {
> +*decode_failed = 1;
> +if (!pkt->size)
> +sub2video_flush(ist);
> +return ret;
> +}
> +
> +return encode_mux_subtitles(ist, , got_output);
> +}
> +
>  static int send_filter_eof(InputStream *ist)
>  {
>  int i, ret;
> -- 
> 2.37.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".

-- 
Anton Khirnov
___
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 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible

2022-08-02 Thread Anton Khirnov
Quoting Michael Niedermayer (2022-07-30 19:12:39)
> On Sat, Jul 30, 2022 at 11:55:45AM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> > >> Signed-off-by: Andreas Rheinhardt 
> > >> ---
> > >>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
> > >>  libavcodec/mips/h263dsp_mips.h |  2 +-
> > >>  libavcodec/mips/mpegvideoencdsp_msa.c  |  4 ++--
> > >>  libavcodec/mpegvideoencdsp.c   | 10 +-
> > >>  libavcodec/mpegvideoencdsp.h   | 10 +-
> > >>  libavcodec/ppc/mpegvideoencdsp.c   |  8 
> > >>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
> > >>  libavcodec/x86/mpegvideoencdsp.asm |  4 ++--
> > >>  libavcodec/x86/mpegvideoencdsp_init.c  |  6 +++---
> > >>  9 files changed, 26 insertions(+), 26 deletions(-)
> > > 
> > > LGTM, also all similar things should be ok
> > > 
> > > [...]
> > > 
> > 
> > Unfortunately, it is not so easy. The first version of this patchset
> > (this here) forgot to update the definitions of several loongarch
> > functions, leading to lots of red on patchwork. The second version fixed
> > the compilation error, but forgot some constifications due to
> > unfortunate oversights. For the third version, I wanted to actually
> > compile loongarch instead of just staring at the code; but the
> > GCC-cross-compiler does not seem to support lsx and lasx (and looking at
> > the loongarch-code in GCC makes me believe that they are just not
> > supported (yet)). Therefore I resorted to creating dummy-functions for
> > all the __lasx_* and __lsx_* functions (they show no more
> > const-warnings). I wanted to let the FATE-loongarch-box test this once
> > more (and tell me whether there are still any issues left), yet this box
> > is no longer active since a few days (for reasons unknown). Can you
> > compile the lsx and lasx code (after all, you committed all the
> > loongarch code)?
> 
> i have no easy way to test loongarch, what i can test is qemu-mips.
> i think i have said that a few times already.
> 
> I do have a loongson box that is IIRC ready to be shipped (within EU) to
> whoever volunteers to maintain that box for FFmpeg. I dont know if that
> box would help with the current code. The OS will liklely need to be updated
> and IIRC this has no normal update mechanism) I didnt touch this box for a
> really long time.

What OS is it?

I could conceivably host such a machine and give other devs SSH access
to it, if it does not require too much maintenance and/or electricity.

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

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


Re: [FFmpeg-devel] [PATCH v4 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2022-08-02 Thread Anton Khirnov
Both patches LGTM

-- 
Anton Khirnov
___
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] Encoding image

2022-08-02 Thread Marco Vianini
I have a PNG image converted to YUV 420P and I need to encode it to a specific 
RTMPS URI, with fps 10.
The encoding process is quite heavy for the CPU. 
In this specific case the frame is always the same, re-encoded at a rate basing 
on fps.
Is it necessary to call "avcodec_send_frame / avcodec_receive_packet" for each 
frame or there is a better way given that the frame to encode does not change?
Thank you 


___
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 v12 11/13] lavc/qsv: create mfx session using oneVPL for decoding/encoding

2022-08-02 Thread Xiang, Haihao
On Mon, 2022-08-01 at 15:33 +0200, Anton Khirnov wrote:
> Quoting Xiang, Haihao (2022-07-25 06:11:49)
> > From: Haihao Xiang 
> > 
> > If qsv hwdevice is available, use the mfxLoader handle in qsv hwdevice
> > to create mfx session. Otherwise create mfx session with a new mfxLoader
> > handle.
> > 
> > This is in preparation for oneVPL support
> > ---
> >  libavcodec/qsv.c  | 226 +++---
> >  libavcodec/qsv_internal.h |   1 +
> >  libavcodec/qsvdec.c   |  11 ++
> >  libavcodec/qsvenc.h   |   3 +
> >  libavcodec/qsvenc_h264.c  |   1 -
> >  libavcodec/qsvenc_hevc.c  |   1 -
> >  libavcodec/qsvenc_jpeg.c  |   1 -
> >  libavcodec/qsvenc_mpeg2.c |   1 -
> >  libavcodec/qsvenc_vp9.c   |   1 -
> >  9 files changed, 223 insertions(+), 23 deletions(-)
> > 
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > index 432675bccf..fe998c9649 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -45,6 +45,12 @@
> >  #include 
> >  #endif
> >  
> > +#if QSV_ONEVPL
> > +#include 
> > +#else
> > +#define MFXUnload(a) do { } while(0)
> > +#endif
> > +
> >  int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
> >  {
> >  switch (codec_id) {
> > @@ -419,6 +425,193 @@ static int ff_qsv_set_display_handle(AVCodecContext
> > *avctx, QSVSession *qs)
> >  }
> >  #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
> >  
> > +#if QSV_ONEVPL
> > +static int qsv_new_mfx_loader(AVCodecContext *avctx,
> > +  mfxIMPL implementation,
> > +  mfxVersion *pver,
> > +  void **ploader)
> > +{
> > +mfxStatus sts;
> > +mfxLoader loader = NULL;
> > +mfxConfig cfg;
> > +mfxVariant impl_value;
> > +
> > +loader = MFXLoad();
> > +if (!loader) {
> > +av_log(avctx, AV_LOG_ERROR, "Error creating a MFX loader\n");
> > +goto fail;
> > +}
> > +
> > +/* Create configurations for implementation */
> > +cfg = MFXCreateConfig(loader);
> > +if (!cfg) {
> > +av_log(avctx, AV_LOG_ERROR, "Error creating a MFX
> > configurations\n");
> > +goto fail;
> > +}
> > +
> > +impl_value.Type = MFX_VARIANT_TYPE_U32;
> > +impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ?
> > +MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE;
> > +sts = MFXSetConfigFilterProperty(cfg,
> > + (const mfxU8
> > *)"mfxImplDescription.Impl", impl_value);
> > +if (sts != MFX_ERR_NONE) {
> > +av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration "
> > +   "property: %d\n", sts);
> > +goto fail;
> > +}
> > +
> > +impl_value.Type = MFX_VARIANT_TYPE_U32;
> > +impl_value.Data.U32 = pver->Version;
> > +sts = MFXSetConfigFilterProperty(cfg,
> > + (const mfxU8
> > *)"mfxImplDescription.ApiVersion.Version",
> > + impl_value);
> > +if (sts != MFX_ERR_NONE) {
> > +av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration "
> > +   "property: %d\n", sts);
> > +goto fail;
> > +}
> > +
> > +*ploader = loader;
> > +
> > +return 0;
> > +
> > +fail:
> > +if (loader)
> > +MFXUnload(loader);
> > +
> > +*ploader = NULL;
> > +return AVERROR_UNKNOWN;
> > +}
> > +
> > +static int qsv_create_mfx_session_from_loader(void *ctx, mfxLoader loader,
> > mfxSession *psession)
> > +{
> > +mfxStatus sts;
> > +mfxSession session = NULL;
> > +uint32_t impl_idx = 0;
> > +
> > +while (1) {
> > +/* Enumerate all implementations */
> > +mfxImplDescription *impl_desc;
> > +
> > +sts = MFXEnumImplementations(loader, impl_idx,
> > + MFX_IMPLCAPS_IMPLDESCSTRUCTURE,
> > + (mfxHDL *)_desc);
> > +/* Failed to find an available implementation */
> > +if (sts == MFX_ERR_NOT_FOUND)
> > +break;
> > +else if (sts != MFX_ERR_NONE) {
> > +impl_idx++;
> > +continue;
> > +}
> > +
> > +sts = MFXCreateSession(loader, impl_idx, );
> > +MFXDispReleaseImplDescription(loader, impl_desc);
> > +if (sts == MFX_ERR_NONE)
> > +break;
> > +
> > +impl_idx++;
> > +}
> > +
> > +if (sts != MFX_ERR_NONE) {
> > +av_log(ctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n",
> > sts);
> > +goto fail;
> > +}
> > +
> > +*psession = session;
> > +
> > +return 0;
> > +
> > +fail:
> > +if (session)
> > +MFXClose(session);
> > +
> > +*psession = NULL;
> > +return AVERROR_UNKNOWN;
> > +}
> > +
> > +static int qsv_create_mfx_session(AVCodecContext *avctx,
> > +  mfxIMPL implementation,
> > +  mfxVersion *pver,
> > +  int gpu_copy,
> > +  

Re: [FFmpeg-devel] [PATCH v3 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2022-08-02 Thread Xiang, Haihao
On Mon, 2022-08-01 at 11:12 +0200, Anton Khirnov wrote:
> Hi,
> the concept is generally ok, but I have a few comments on the
> implementation.
> 
> Quoting Xiang, Haihao (2022-07-25 06:30:51)
> > +static const AVCodec *choose_decoder2(InputStream *ist, OptionsContext *o,
> > AVFormatContext *s, AVStream *st)
> > +{
> > +char *codec_name = NULL;
> > +
> > +MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
> > +if (codec_name) {
> > +const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar-
> > >codec_type, 0);
> > +st->codecpar->codec_id = codec->id;
> > +if (recast_media && st->codecpar->codec_type != codec->type)
> > +st->codecpar->codec_type = codec->type;
> > +return codec;
> > +} else {
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > +ist->hwaccel_id == HWACCEL_GENERIC &&
> > +ist->hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
> > +const AVCodec *p;
> 
> 'p' is a rather weird name for an AVCodec instance, I'd expect 'c' or
> 'codec' or something like that
> 
> > +void *i = 0;
> 
> NULL, it's a pointer
> 
> > +
> > +while ((p = av_codec_iterate())) {
> > +int j;
> > +
> > +if (p->id != st->codecpar->codec_id ||
> > +!av_codec_is_decoder(p) ||
> > +!avcodec_get_hw_config(p, 0))
> > +continue;
> > +
> > +for (j = 0; ;j++) {
> 
> for (int j = 0; config = avcodec_get_hw_config(p, j); j++)
> 
> gets rid of the explicit check in the loop and also
> avcodec_get_hw_config() in the condition above
> 
> > +const AVCodecHWConfig *config =
> > avcodec_get_hw_config(p, j);
> > +
> > +if (!config)
> > +break;
> > +
> > +if (config->device_type == ist->hwaccel_device_type)
> > +return p;
> > +}
> > +}
> > +}
> > +
> > +return avcodec_find_decoder(st->codecpar->codec_id);
> > +}
> > +}
> > +
> >  /* Add all the streams from the given input file to the global
> >   * list of input streams. */
> >  static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
> > @@ -973,7 +1015,7 @@ static void add_input_streams(OptionsContext *o,
> > AVFormatContext *ic)
> >  ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
> >  }
> >  
> > -ist->dec = choose_decoder(o, ic, st);
> > +ist->dec = choose_decoder2(ist, o, ic, st);
> 
> I don't like adding a new function that partially duplicates
> choose_decoder() and has a non-descriptive name. Just extend
> choose_decoder() by passing hwaccel_id and hwaccel_device_type to it.

Thanks for the comments, fixed in v4

-Haihao

___
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 v4 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2022-08-02 Thread Xiang, Haihao
From: Haihao Xiang 

Usually a HW decoder is expected when user specifies a HW acceleration
method via -hwaccel option, however the current implementation doesn't
take HW acceleration method into account, it is possible to select a SW
decoder.

For example:
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))

libdav1d is selected in this case even if vaapi, nvdec or vdpau is
specified.

After applying this patch, the native av1 decoder (with vaapi, nvdec or
vdpau support) is selected for decoding(libdav1d is still used for
probing format).
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))

Tested-by: Mario Roy 
Signed-off-by: Haihao Xiang 
---
 fftools/ffmpeg_opt.c | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index cf0c31bdc2..db51cca66d 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -857,7 +857,9 @@ static const AVCodec *find_codec_or_die(const char *name, 
enum AVMediaType type,
 return codec;
 }
 
-static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, 
AVStream *st)
+static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, 
AVStream *st,
+ enum HWAccelID hwaccel_id, enum 
AVHWDeviceType hwaccel_device_type)
+
 {
 char *codec_name = NULL;
 
@@ -868,8 +870,29 @@ static const AVCodec *choose_decoder(OptionsContext *o, 
AVFormatContext *s, AVSt
 if (recast_media && st->codecpar->codec_type != codec->type)
 st->codecpar->codec_type = codec->type;
 return codec;
-} else
+} else {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+hwaccel_id == HWACCEL_GENERIC &&
+hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
+const AVCodec *c;
+void *i = NULL;
+
+while ((c = av_codec_iterate())) {
+const AVCodecHWConfig *config;
+
+if (c->id != st->codecpar->codec_id ||
+!av_codec_is_decoder(c))
+continue;
+
+for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
+if (config->device_type == hwaccel_device_type)
+return c;
+}
+}
+}
+
 return avcodec_find_decoder(st->codecpar->codec_id);
+}
 }
 
 static int guess_input_channel_layout(InputStream *ist)
@@ -1003,7 +1026,7 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
 }
 
-ist->dec = choose_decoder(o, ic, st);
+ist->dec = choose_decoder(o, ic, st, ist->hwaccel_id, 
ist->hwaccel_device_type);
 ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
 
 ist->reinit_filters = -1;
@@ -1309,7 +1332,7 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 
 /* apply forced codec ids */
 for (i = 0; i < ic->nb_streams; i++)
-choose_decoder(o, ic, ic->streams[i]);
+choose_decoder(o, ic, ic->streams[i], HWACCEL_NONE, 
AV_HWDEVICE_TYPE_NONE);
 
 if (find_stream_info) {
 AVDictionary **opts = setup_find_stream_info_opts(ic, 
o->g->codec_opts);
-- 
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".


[FFmpeg-devel] [PATCH v4 1/2] ffmpeg_opt: select a decoder after getting values for per-stream hwdec options

2022-08-02 Thread Xiang, Haihao
From: Haihao Xiang 

After applying this patch, the desired HW acceleration method is known
before selecting decoder, so we may take HW acceleration method into
account when selecting decoder for input stream in the next commit

There should be no functional changes in this patch

Signed-off-by: Haihao Xiang 
---
 fftools/ffmpeg_opt.c | 134 ++-
 1 file changed, 68 insertions(+), 66 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a96bcf9b8a..cf0c31bdc2 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -935,72 +935,7 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 st->codecpar->codec_tag = tag;
 }
 
-ist->dec = choose_decoder(o, ic, st);
-ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
-
-ist->reinit_filters = -1;
-MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
-
-MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
-ist->user_set_discard = AVDISCARD_NONE;
-
-if ((o->video_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO) ||
-(o->audio_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
-(o->subtitle_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_SUBTITLE) ||
-(o->data_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_DATA))
-ist->user_set_discard = AVDISCARD_ALL;
-
-if (discard_str && av_opt_eval_int(, discard_opt, discard_str, 
>user_set_discard) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
-discard_str);
-exit_program(1);
-}
-
-ist->filter_in_rescale_delta_last = AV_NOPTS_VALUE;
-ist->prev_pkt_pts = AV_NOPTS_VALUE;
-
-ist->dec_ctx = avcodec_alloc_context3(ist->dec);
-if (!ist->dec_ctx) {
-av_log(NULL, AV_LOG_ERROR, "Error allocating the decoder 
context.\n");
-exit_program(1);
-}
-
-ret = avcodec_parameters_to_context(ist->dec_ctx, par);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder 
context.\n");
-exit_program(1);
-}
-
-ist->decoded_frame = av_frame_alloc();
-if (!ist->decoded_frame)
-exit_program(1);
-
-ist->pkt = av_packet_alloc();
-if (!ist->pkt)
-exit_program(1);
-
-if (o->bitexact)
-ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
-
-switch (par->codec_type) {
-case AVMEDIA_TYPE_VIDEO:
-if(!ist->dec)
-ist->dec = avcodec_find_decoder(par->codec_id);
-
-// avformat_find_stream_info() doesn't set this for us anymore.
-ist->dec_ctx->framerate = st->avg_frame_rate;
-
-MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
-if (framerate && av_parse_video_rate(>framerate,
- framerate) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error parsing framerate %s.\n",
-   framerate);
-exit_program(1);
-}
-
-ist->top_field_first = -1;
-MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, 
st);
-
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
 MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
  hwaccel_output_format, ic, st);
@@ -1066,6 +1001,73 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 }
 
 ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
+}
+
+ist->dec = choose_decoder(o, ic, st);
+ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
+
+ist->reinit_filters = -1;
+MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
+
+MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
+ist->user_set_discard = AVDISCARD_NONE;
+
+if ((o->video_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO) ||
+(o->audio_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
+(o->subtitle_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_SUBTITLE) ||
+(o->data_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_DATA))
+ist->user_set_discard = AVDISCARD_ALL;
+
+if (discard_str && av_opt_eval_int(, discard_opt, discard_str, 
>user_set_discard) < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
+discard_str);
+exit_program(1);
+}
+
+ist->filter_in_rescale_delta_last = 

[FFmpeg-devel] [PATCH] avcodec/acelp_*: Remove unnecessary headers

2022-08-02 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/acelp_filters.c | 2 +-
 libavcodec/acelp_pitch_delay.c | 2 --
 libavcodec/acelp_vectors.c | 4 ++--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c
index 9182579330..db4908f31c 100644
--- a/libavcodec/acelp_filters.c
+++ b/libavcodec/acelp_filters.c
@@ -20,8 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
 #include 
+#include 
 
 #include "config.h"
 #include "libavutil/avassert.h"
diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index 1eca97ec69..6cf880e4ac 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -23,8 +23,6 @@
 #include "libavutil/common.h"
 #include "libavutil/ffmath.h"
 #include "libavutil/float_dsp.h"
-#include "libavutil/mathematics.h"
-#include "avcodec.h"
 #include "acelp_pitch_delay.h"
 #include "celp_math.h"
 #include "audiodsp.h"
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index b8a2b50dde..04cbffd79f 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -20,12 +20,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
+#include 
 
+#include "config.h"
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
-#include "avcodec.h"
 #include "acelp_vectors.h"
 
 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
-- 
2.34.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".