Re: [FFmpeg-devel] [PATCH 3/3] avformat/dashdec: avoid calling strlen multiple times

2022-01-23 Thread Steven Liu
 于2022年1月23日周日 11:52写道:
>
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  libavformat/dashdec.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 0d21989..211d77f 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -403,6 +403,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
>  DASHContext *c = s->priv_data;
>  AVDictionary *tmp = NULL;
>  const char *proto_name = NULL;
> +int proto_name_len;
>  int ret;
>
>  if (av_strstart(url, "crypto", NULL)) {
> @@ -416,6 +417,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
>  if (!proto_name)
>  return AVERROR_INVALIDDATA;
>
> +proto_name_len = strlen(proto_name);
>  // only http(s) & file are allowed
>  if (av_strstart(proto_name, "file", NULL)) {
>  if (strcmp(c->allowed_extensions, "ALL") && !av_match_ext(url, 
> c->allowed_extensions)) {
> @@ -430,9 +432,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
>  } else
>  return AVERROR_INVALIDDATA;
>
> -if (!strncmp(proto_name, url, strlen(proto_name)) && 
> url[strlen(proto_name)] == ':')
> +if (!strncmp(proto_name, url, proto_name_len) && url[proto_name_len] == 
> ':')
>  ;
> -else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 
> 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':')
> +else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 
> 7, proto_name_len) && url[7 + proto_name_len] == ':')
>  ;
>  else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
>  return AVERROR_INVALIDDATA;
> --
> 1.8.3.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".

lgtm


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


[FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter

2022-01-23 Thread Wenbin Chen
Add intra refresh support to hevc_qsv as well.
Add an new intra refresh type: "horizontal", and an new param
ref_cycle_dist. This param specify the distance between the
beginnings of the intra-refresh cycles in frames.

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi| 26 +-
 libavcodec/qsvenc.c  | 23 ++-
 libavcodec/qsvenc.h  |  1 +
 libavcodec/qsvenc_h264.c |  7 +--
 libavcodec/qsvenc_hevc.c |  9 +
 5 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6c1c4df57a..4e35e50e4d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3344,7 +3344,8 @@ Specifies intra refresh type. The major goal of intra 
refresh is improvement of
 error resilience without significant impact on encoded bitstream size caused by
 I frames. The SDK encoder achieves this by encoding part of each frame in
 refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} 
means
-vertical refresh, by column of MBs.
+vertical refresh, by column of MBs. To enable intra refresh, B frame should be
+set to 0.
 
 @item @var{int_ref_cycle_size}
 Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are
@@ -3355,6 +3356,9 @@ Specifies QP difference for inserted intra MBs. This is 
signed value in
 [-51, 51] range if target encoding bit-depth for luma samples is 8 and this
 range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively.
 
+@item @var{int_ref_cycle_dist}
+Distance between the beginnings of the intra-refresh cycles in frames.
+
 @item @var{profile}
 @table @samp
 @item unknown
@@ -3463,6 +3467,26 @@ Insert picture timing SEI with pic_struct_syntax element.
 @item @var{transform_skip}
 Turn this option ON to enable transformskip. It is supported on platform equal
 or newer than ICL.
+
+@item @var{int_ref_type}
+Specifies intra refresh type. The major goal of intra refresh is improvement of
+error resilience without significant impact on encoded bitstream size caused by
+I frames. The SDK encoder achieves this by encoding part of each frame in
+refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} 
means
+vertical refresh, by column of MBs. To enable intra refresh, B frame should be
+set to 0.
+
+@item @var{int_ref_cycle_size}
+Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are
+invalid values.
+
+@item @var{int_ref_qp_delta}
+Specifies QP difference for inserted intra MBs. This is signed value in
+[-51, 51] range if target encoding bit-depth for luma samples is 8 and this
+range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively.
+
+@item @var{int_ref_cycle_dist}
+Distance between the beginnings of the intra-refresh cycles in frames.
 @end table
 
 @subsection MPEG2 Options
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a8d876d6d9..af1529936e 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -267,8 +267,10 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 
 #if QSV_HAVE_CO2
 av_log(avctx, AV_LOG_VERBOSE,
-   "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: 
%"PRIu16"; IntRefQPDelta: %"PRId16"\n",
-   print_threestate(co->RecoveryPointSEI), co2->IntRefType, 
co2->IntRefCycleSize, co2->IntRefQPDelta);
+   "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: 
%"PRIu16
+   "; IntRefQPDelta: %"PRId16"; IntRefCycleDist: %"PRId16"\n",
+   print_threestate(co->RecoveryPointSEI), co2->IntRefType, 
co2->IntRefCycleSize,
+   co2->IntRefQPDelta, co3->IntRefCycleDist);
 
 av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize);
 #if QSV_HAVE_MAX_SLICE_SIZE
@@ -865,13 +867,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 
 #if QSV_HAVE_CO2
 if (avctx->codec_id == AV_CODEC_ID_H264) {
-if (q->int_ref_type >= 0)
-q->extco2.IntRefType = q->int_ref_type;
-if (q->int_ref_cycle_size >= 0)
-q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
-if (q->int_ref_qp_delta != INT16_MIN)
-q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
-
 if (q->bitrate_limit >= 0)
 q->extco2.BitrateLimit = q->bitrate_limit ? 
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 if (q->mbbrc >= 0)
@@ -900,6 +895,12 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 if (q->max_frame_size >= 0)
 q->extco2.MaxFrameSize = q->max_frame_size;
+if (q->int_ref_type >= 0)
+q->extco2.IntRefType = q->int_ref_type;
+if (q->int_ref_cycle_size >= 0)
+q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
+if (q->int_ref_qp_delta != INT16_MIN)
+  

[FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option to hevc_qsv

2022-01-23 Thread Wenbin Chen
Add b_strategy option to hevc_qsv. By enabling this option, encoder can
use b frames as reference.

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi   | 3 +++
 libavcodec/qsvenc.c | 6 --
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8966610263..6c1c4df57a 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3403,6 +3403,9 @@ Maximum encoded slice size in bytes.
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
+@item @var{b_strategy}
+This option controls usage of B frames as reference.
+
 @item @var{dblk_idc}
 This option disable deblocking. It has value in range 0~2.
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f311cd9ce4..a8d876d6d9 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -888,8 +888,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.LookAheadDS = q->look_ahead_downsampling;
 q->extco2.RepeatPPS   = q->repeat_pps ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 
-if (q->b_strategy >= 0)
-q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : 
MFX_B_REF_OFF;
 if (q->adaptive_i >= 0)
 q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 if (q->adaptive_b >= 0)
@@ -910,6 +908,10 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.DisableDeblockingIdc = q->dblk_idc;
 #endif
 
+#if QSV_VERSION_ATLEAST(1, 8)
+if (q->b_strategy >= 0)
+q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : 
MFX_B_REF_OFF;
+#endif
 #if QSV_VERSION_ATLEAST(1, 9)
 if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > 
avctx->qmax) {
 av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but 
invalid, please make sure min <= max\n");
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv

2022-01-23 Thread Wenbin Chen
Add max_slice_size option to hevc_qsv as well.

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi   | 3 +++
 libavcodec/qsvenc.c | 9 -
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e3adbf4325..8966610263 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3397,6 +3397,9 @@ Enable rate distortion optimization.
 @item @var{max_frame_size}
 Maximum encoded frame size in bytes.
 
+@item @var{max_slice_size}
+Maximum encoded slice size in bytes.
+
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 413e5ae8f6..f311cd9ce4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -877,11 +877,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 if (q->mbbrc >= 0)
 q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 
-#if QSV_HAVE_MAX_SLICE_SIZE
-if (q->max_slice_size >= 0)
-q->extco2.MaxSliceSize = q->max_slice_size;
-#endif
-
 #if QSV_HAVE_TRELLIS
 if (avctx->trellis >= 0)
 q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : 
(MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
@@ -907,6 +902,10 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 if (q->max_frame_size >= 0)
 q->extco2.MaxFrameSize = q->max_frame_size;
+#if QSV_HAVE_MAX_SLICE_SIZE
+if (q->max_slice_size >= 0)
+q->extco2.MaxSliceSize = q->max_slice_size;
+#endif
 #if QSV_HAVE_DISABLEDEBLOCKIDC
 q->extco2.DisableDeblockingIdc = q->dblk_idc;
 #endif
-- 
2.25.1

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

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


Re: [FFmpeg-devel] [PATCH v2] lavc/qsvenc: add tile encoding support for VP9

2022-01-23 Thread Xiang, Haihao
On Tue, 2022-01-18 at 08:08 +, Xiang, Haihao wrote:
> On Mon, 2022-01-17 at 09:12 -0300, James Almer wrote:
> > On 1/17/2022 7:57 AM, Soft Works wrote:
> > > 
> > > 
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf Of
> > > > myp...@gmail.com
> > > > Sent: Monday, January 17, 2022 11:36 AM
> > > > To: FFmpeg development discussions and patches 
> > > > Subject: Re: [FFmpeg-devel] [PATCH v2] lavc/qsvenc: add tile encoding
> > > > support
> > > > for VP9
> > > > 
> > > > On Mon, Jan 17, 2022 at 4:30 PM Xiang, Haihao
> > > >  wrote:
> > > > > 
> > > > > On Thu, 2022-01-13 at 13:45 +0800, Haihao Xiang wrote:
> > > > > > Add -tile_rows and -tile_cols options to specify the number of tile
> > > > > > rows and columns
> > > > > > 
> > > > > > Signed-off-by: Haihao Xiang 
> > > > > > ---
> > > > > > v2: add option descriptions in the doc
> > > > > > 
> > > > > >   doc/encoders.texi   |  6 ++
> > > > > >   libavcodec/qsvenc.c |  4 
> > > > > >   libavcodec/qsvenc.h |  1 +
> > > > > >   libavcodec/qsvenc_vp9.c | 10 ++
> > > > > >   4 files changed, 21 insertions(+)
> > > > > > 
> > > > > > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > > > > > index 7cc8be1209..a4176089d5 100644
> > > > > > --- a/doc/encoders.texi
> > > > > > +++ b/doc/encoders.texi
> > > > > > @@ -3457,6 +3457,12 @@ These options are used by vp9_qsv
> > > > > >   @item profile2
> > > > > >   @item profile3
> > > > > >   @end table
> > > > > > +
> > > > > > +@item @var{tile_cols}
> > > > > > +Number of columns for tiled encoding (requires libmfx >= 1.29).
> > > > > > +
> > > > > > +@item @var{tile_rows}
> > > > > > +Number of rows for tiled encoding (requires libmfx  >= 1.29).
> > > > > >   @end table
> > > > > > 
> > > > > >   @section snow
> > > > > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > > > > > index 4e7a15f060..4cbc9ff4dc 100644
> > > > > > --- a/libavcodec/qsvenc.c
> > > > > > +++ b/libavcodec/qsvenc.c
> > > > > > @@ -939,6 +939,10 @@ static int init_video_param(AVCodecContext
> > > > > > *avctx,
> > > > > > QSVEncContext *q)
> > > > > >   q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM;
> > > > > >   q->extvp9param.Header.BufferSz = sizeof(q->extvp9param);
> > > > > >   q->extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
> > > > > > +#if QSV_HAVE_EXT_VP9_TILES
> > > > > > +q->extvp9param.NumTileColumns  = q->tile_cols;
> > > > > > +q->extvp9param.NumTileRows = q->tile_rows;
> > > > > > +#endif
> > > > > >   q->extparam_internal[q->nb_extparam_internal++] =
> > > > > > (mfxExtBuffer
> > > > 
> > > > *)&q-
> > > > > > > extvp9param;
> > > > > > 
> > > > > >   }
> > > > > >   #endif
> > > > > > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> > > > > > index 31516b8e55..00ee52a5d1 100644
> > > > > > --- a/libavcodec/qsvenc.h
> > > > > > +++ b/libavcodec/qsvenc.h
> > > > > > @@ -41,6 +41,7 @@
> > > > > > 
> > > > > >   #define QSV_HAVE_EXT_HEVC_TILES QSV_VERSION_ATLEAST(1, 13)
> > > > > >   #define QSV_HAVE_EXT_VP9_PARAM QSV_VERSION_ATLEAST(1, 26)
> > > > > > +#define QSV_HAVE_EXT_VP9_TILES QSV_VERSION_ATLEAST(1, 29)
> > > > > > 
> > > > > >   #define QSV_HAVE_TRELLIS QSV_VERSION_ATLEAST(1, 8)
> > > > > >   #define QSV_HAVE_MAX_SLICE_SIZE QSV_VERSION_ATLEAST(1, 9)
> > > > > > diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
> > > > > > index 9329990d11..1168ddda0e 100644
> > > > > > --- a/libavcodec/qsvenc_vp9.c
> > > > > > +++ b/libavcodec/qsvenc_vp9.c
> > > > > > @@ -73,6 +73,16 @@ static const AVOption options[] = {
> > > > > >   { "profile2",  NULL, 0,   AV_OPT_TYPE_CONST, {
> > > > > > .i64
> > > > 
> > > > =
> > > > > > MFX_PROFILE_VP9_2   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > > > > >   { "profile3",  NULL, 0,   AV_OPT_TYPE_CONST, {
> > > > > > .i64
> > > > 
> > > > =
> > > > > > MFX_PROFILE_VP9_3   },  INT_MIN,  INT_MAX,  VE,  "profile" },
> > > > > > 
> > > > > > +#if QSV_HAVE_EXT_VP9_TILES
> > > > > > +/* The minimum tile width in luma pixels is 256, set maximum
> > > > 
> > > > tile_cols to
> > > > > > 32 for 8K video */
> > > > > > +{ "tile_cols",  "Number of columns for tiled
> > > > > > encoding",   OFFSET(qsv.tile_cols),AV_OPT_TYPE_INT, { .i64 = 0
> > > > > > },
> > > > > > 0,
> > > > 
> > > > 32,
> > > > > > VE },
> > > > > > +/* Set maximum tile_rows to 4 per VP9 spec */
> > > > > > +{ "tile_rows",  "Number of rows for tiled
> > > > > > encoding",  OFFSET(qsv.tile_rows),AV_OPT_TYPE_INT, { .i64 =
> > > > > > 0
> > > > > > },
> > > > 
> > > > 0, 4,
> > > > > > VE },
> > > > > > +#else
> > > > > > +{ "tile_cols",  "(not
> > > > > > supported)",OFFSET(qsv.tile_cols),
> > > > 
> > > > AV_OPT_TYPE_INT,
> > > > > > { .i64 = 0 }, 0, 0, VE },
> > > > > > +{ "tile_rows",  "(not
> > > > > > supported)",OFFSET(qsv.tile_rows),
> > > > 
> > > > 

Re: [FFmpeg-devel] [PATCH 001/293 v7] Add a new channel layout API

2022-01-23 Thread James Almer

On 1/23/2022 8:32 PM, Marton Balint wrote:



On Thu, 20 Jan 2022, James Almer wrote:


From: Anton Khirnov 

The new API is more extensible and allows for custom layouts.
More accurate information is exported, eg for decoders that do not
set a channel layout, lavc will not make one up for them.

Deprecate the old API working with just uint64_t bitmasks.

Expanded and completed by Vittorio Giovara 
and James Almer .
Signed-off-by: Vittorio Giovara 
Signed-off-by: James Almer 
---
Changes since last version:

*Implemented Marton's suggestion for 
av_channel_layout_index_from_string()

and av_channel_layout_channel_from_string(), to not mix designation and
custom name namespaces.


Thanks.

[...]


+enum AVChannel
+av_channel_layout_channel_from_string(const AVChannelLayout 
*channel_layout,

+  const char *str)
+{


As far as I see this function equvivalent to

     int index = av_channel_layout_index_from_string(channel_layout, str);
     if (index < 0)
     return AV_CHAN_NONE;
     return av_channel_layout_channel_from_index(channel_layout, index);

This would avoid code duplication.


Funny how i even mentioned this much but then duplicated all this code...



[...]

+int av_channel_layout_index_from_string(const AVChannelLayout 
*channel_layout,

+    const char *str)
+{
+    char *chname, buf[16];
+    enum AVChannel ch = AV_CHAN_NONE;
+
+    switch (channel_layout->order) {
+    case AV_CHANNEL_ORDER_CUSTOM:
+    chname = strstr(str, "@");
+    if (chname) {
+    char buf[16];
+    chname++;
+    av_strlcpy(buf, str, FFMIN(sizeof(buf), chname - str));
+    if (!*chname)
+    chname = NULL;
+    ch = av_channel_from_string(buf);


If designation is present but invalid we should return error, e.g:

    if (ch == AV_CHAN_NONE && *buf)
    return AVERROR(EINVAL);


Good catch, will fix.



[...]


diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index d39ae1177a..2efac9046a 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -23,6 +23,10 @@
#define AVUTIL_CHANNEL_LAYOUT_H

#include 
+#include 
+
+#include "version.h"
+#include "attributes.h"

/**
 * @file
@@ -34,6 +38,71 @@
 * @{
 */

+enum AVChannel {
+    ///< Invalid channel index
+    AV_CHAN_NONE = -1,
+    AV_CHAN_FRONT_LEFT,
+    AV_CHAN_FRONT_RIGHT,
+    AV_CHAN_FRONT_CENTER,
+    AV_CHAN_LOW_FREQUENCY,
+    AV_CHAN_BACK_LEFT,
+    AV_CHAN_BACK_RIGHT,
+    AV_CHAN_FRONT_LEFT_OF_CENTER,
+    AV_CHAN_FRONT_RIGHT_OF_CENTER,
+    AV_CHAN_BACK_CENTER,
+    AV_CHAN_SIDE_LEFT,
+    AV_CHAN_SIDE_RIGHT,
+    AV_CHAN_TOP_CENTER,
+    AV_CHAN_TOP_FRONT_LEFT,
+    AV_CHAN_TOP_FRONT_CENTER,
+    AV_CHAN_TOP_FRONT_RIGHT,
+    AV_CHAN_TOP_BACK_LEFT,
+    AV_CHAN_TOP_BACK_CENTER,
+    AV_CHAN_TOP_BACK_RIGHT,
+    /** Stereo downmix. */
+    AV_CHAN_STEREO_LEFT = 29,
+    /** See above. */
+    AV_CHAN_STEREO_RIGHT,
+    AV_CHAN_WIDE_LEFT,
+    AV_CHAN_WIDE_RIGHT,
+    AV_CHAN_SURROUND_DIRECT_LEFT,
+    AV_CHAN_SURROUND_DIRECT_RIGHT,
+    AV_CHAN_LOW_FREQUENCY_2,
+    AV_CHAN_TOP_SIDE_LEFT,
+    AV_CHAN_TOP_SIDE_RIGHT,
+    AV_CHAN_BOTTOM_FRONT_CENTER,
+    AV_CHAN_BOTTOM_FRONT_LEFT,
+    AV_CHAN_BOTTOM_FRONT_RIGHT,
+
+    /** Channel is empty can be safely skipped. */
+    AV_CHAN_UNUSED = 64,
+
+    /** Channel contains data, but its position is unknown. */
+    AV_CHAN_UNKWNOWN = 128,


typo: UNKNOWN


Will fix.



No more comments for me, thanks.

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

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

___
ffmpeg-devel 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 001/293 v7] Add a new channel layout API

2022-01-23 Thread Marton Balint




On Thu, 20 Jan 2022, James Almer wrote:


From: Anton Khirnov 

The new API is more extensible and allows for custom layouts.
More accurate information is exported, eg for decoders that do not
set a channel layout, lavc will not make one up for them.

Deprecate the old API working with just uint64_t bitmasks.

Expanded and completed by Vittorio Giovara 
and James Almer .
Signed-off-by: Vittorio Giovara 
Signed-off-by: James Almer 
---
Changes since last version:

*Implemented Marton's suggestion for av_channel_layout_index_from_string()
and av_channel_layout_channel_from_string(), to not mix designation and
custom name namespaces.


Thanks.

[...]


+enum AVChannel
+av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout,
+  const char *str)
+{


As far as I see this function equvivalent to

int index = av_channel_layout_index_from_string(channel_layout, str);
if (index < 0)
return AV_CHAN_NONE;
return av_channel_layout_channel_from_index(channel_layout, index);

This would avoid code duplication.

[...]


+int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,
+const char *str)
+{
+char *chname, buf[16];
+enum AVChannel ch = AV_CHAN_NONE;
+
+switch (channel_layout->order) {
+case AV_CHANNEL_ORDER_CUSTOM:
+chname = strstr(str, "@");
+if (chname) {
+char buf[16];
+chname++;
+av_strlcpy(buf, str, FFMIN(sizeof(buf), chname - str));
+if (!*chname)
+chname = NULL;
+ch = av_channel_from_string(buf);


If designation is present but invalid we should return error, e.g:

   if (ch == AV_CHAN_NONE && *buf)
   return AVERROR(EINVAL);

[...]


diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index d39ae1177a..2efac9046a 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -23,6 +23,10 @@
#define AVUTIL_CHANNEL_LAYOUT_H

#include 
+#include 
+
+#include "version.h"
+#include "attributes.h"

/**
 * @file
@@ -34,6 +38,71 @@
 * @{
 */

+enum AVChannel {
+///< Invalid channel index
+AV_CHAN_NONE = -1,
+AV_CHAN_FRONT_LEFT,
+AV_CHAN_FRONT_RIGHT,
+AV_CHAN_FRONT_CENTER,
+AV_CHAN_LOW_FREQUENCY,
+AV_CHAN_BACK_LEFT,
+AV_CHAN_BACK_RIGHT,
+AV_CHAN_FRONT_LEFT_OF_CENTER,
+AV_CHAN_FRONT_RIGHT_OF_CENTER,
+AV_CHAN_BACK_CENTER,
+AV_CHAN_SIDE_LEFT,
+AV_CHAN_SIDE_RIGHT,
+AV_CHAN_TOP_CENTER,
+AV_CHAN_TOP_FRONT_LEFT,
+AV_CHAN_TOP_FRONT_CENTER,
+AV_CHAN_TOP_FRONT_RIGHT,
+AV_CHAN_TOP_BACK_LEFT,
+AV_CHAN_TOP_BACK_CENTER,
+AV_CHAN_TOP_BACK_RIGHT,
+/** Stereo downmix. */
+AV_CHAN_STEREO_LEFT = 29,
+/** See above. */
+AV_CHAN_STEREO_RIGHT,
+AV_CHAN_WIDE_LEFT,
+AV_CHAN_WIDE_RIGHT,
+AV_CHAN_SURROUND_DIRECT_LEFT,
+AV_CHAN_SURROUND_DIRECT_RIGHT,
+AV_CHAN_LOW_FREQUENCY_2,
+AV_CHAN_TOP_SIDE_LEFT,
+AV_CHAN_TOP_SIDE_RIGHT,
+AV_CHAN_BOTTOM_FRONT_CENTER,
+AV_CHAN_BOTTOM_FRONT_LEFT,
+AV_CHAN_BOTTOM_FRONT_RIGHT,
+
+/** Channel is empty can be safely skipped. */
+AV_CHAN_UNUSED = 64,
+
+/** Channel contains data, but its position is unknown. */
+AV_CHAN_UNKWNOWN = 128,


typo: UNKNOWN

No more comments for me, thanks.

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

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_libvmaf: update filter for libvmaf v2.0.0

2022-01-23 Thread Kyle Swanson
Hi,

On Thu, Jan 20, 2022 at 1:06 PM Kyle Swanson  wrote:
>
> Hi,
>
> On Wed, Jan 19, 2022 at 10:23 AM Kyle Swanson  wrote:
> >
> > Hi,
> >
> > On Thu, Jan 13, 2022 at 6:38 PM Kyle Swanson  wrote:
> > >
> > > Hi,
> > >
> > > On Mon, Jan 10, 2022 at 10:22 AM Andreas Rheinhardt
> > >  wrote:
> > > > 1. FFmpeg uses the ancient C90 rule that only allows variable
> > > > declarations at the beginning of a block (before all statements). You
> > > > should actually have received a compiler warning because of the above
> > > > code (unless you use Clang, which claims to support this type of
> > > > warning, yet doesn't).
> > > > 2. You jump over the initializion of str_copy if the dict allocation
> > > > fails and consequently you free an uninitialized string.
> > >
> > > New patch attached. Fixes all of the GCC -Wdeclaration-after-statement
> > > warnings. You're right, I didn't notice because I was building with
> > > Clang. Andreas, I will just wait for your LGTM before merging.
> > >
> > > Thanks,
> > > Kyle
> >
> > Updated patch attached. Thank you to mkver for the mini review on IRC.
> > The `delimited_dict_parse` multi-delimiter corner case should be
> > sorted now.
> >
> > Thanks,
> > Kyle
>
> Will push this soon.
>
> Thanks,
> Kyle

Pushed.

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

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


Re: [FFmpeg-devel] [PATCH 3/3] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

2022-01-23 Thread Anton Khirnov
Quoting Martijn van Beurden (2022-01-23 14:15:53)
> I think this patch shouldn't be applied. Without it 32 bit audio is
> transcoded to 24 bit audio, which is not lossless. However, with this patch
> 24 bit audio is transcoded to 32 bit audio which is lossless, but the
> resulting files are understood by few software decoder and probably no
> hardware decoders.

Do you know which decoders do not support 32bit audio and how widely
used they are? I'm not very familiar with wavpack, but 24bit and 32bit
decoding don't seem significantly different in the decoder.

> Perhaps adding a warning instead of setting a default would be better?

IMO the encoder should strive to be lossless, so it should not encode as
24bit unless it was explicitly told the input data is 24bit.
bits_per_raw_sample=0 is not a meaningful value, so the encoder should
not treat it as 24bit.

-- 
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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-23 Thread Brad Smith

On 1/23/2022 6:57 AM, Michael Niedermayer wrote:


On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:

Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
type should be an unsigned char on anything but Linux.


diff --git a/libavformat/udp.c b/libavformat/udp.c
index 180d96a988..29aa865fff 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
  {
  #ifdef IP_MULTICAST_TTL
  if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, 
sizeof(mcastTTL)) < 0) {
+#ifdef __linux__
+int ttl = mcastTTL;
+#else
+unsigned char ttl = mcastTTL;
+#endif

this "ifdef __linux__" feels like the wrong thing to check, dont you agree ?


Not sure what you mean.

But as I said in one of my other posts..

"FreeBSD, NetBSD, OpenBSD, DragonFlyBSD, macOS, Solaris, AIX, IRIX, 
HP-UX, QNX, Minix3 and a few
others define the ttl parameter to IP_MULTICAST_TTL as an unsigned char. 
Linux has it as an integer."


I looked for various examples of IP_MULTICAST_TTL usage in whatever 
projects I could find and most
of the examples I found used only unsigned char, with BIRD (routing 
daemon) being one of few that
use an int for Linux and unsigned char for *BSD's. It does not have 
support for any other OS's.


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

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


Re: [FFmpeg-devel] [PATCH] configure: link to libatomic when it's present

2022-01-23 Thread Brad Smith

On 1/22/2022 4:00 AM, Hendrik Leppkes wrote:


On Sat, Jan 22, 2022 at 7:43 AM Brad Smith
  wrote:

On 1/19/2022 10:23 AM, James Almer wrote:


On 1/19/2022 10:48 AM, Anton Khirnov wrote:

C11 atomics in some configurations (e.g. 64bit operations on ppc64 with
GCC) require linking to libatomic.

Fixes #9275
---
   configure | 25 -
   1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 1413122d87..3059c154df 100755
--- a/configure
+++ b/configure
@@ -3794,20 +3794,20 @@ cws2fws_extralibs="zlib_extralibs"
 # libraries, in any order
   avcodec_deps="avutil"
-avcodec_suggest="libm"
+avcodec_suggest="libm stdatomic"
   avdevice_deps="avformat avcodec avutil"
-avdevice_suggest="libm"
+avdevice_suggest="libm stdatomic"
   avfilter_deps="avutil"
-avfilter_suggest="libm"
+avfilter_suggest="libm stdatomic"
   avformat_deps="avcodec avutil"
-avformat_suggest="libm network zlib"
-avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl
user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia
bcrypt"
+avformat_suggest="libm network zlib stdatomic"
+avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl
user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia
bcrypt stdatomic"
   postproc_deps="avutil gpl"
-postproc_suggest="libm"
+postproc_suggest="libm stdatomic"
   swresample_deps="avutil"
-swresample_suggest="libm libsoxr"
+swresample_suggest="libm libsoxr stdatomic"
   swscale_deps="avutil"
-swscale_suggest="libm"
+swscale_suggest="libm stdatomic"
 avcodec_extralibs="pthreads_extralibs iconv_extralibs
dxva2_extralibs"
   avfilter_extralibs="pthreads_extralibs"
@@ -6324,7 +6324,14 @@ check_headers asm/types.h
   # it seems there are versions of clang in some distros that try to
use the
   # gcc headers, which explodes for stdatomic
   # so we also check that atomics actually work here
-check_builtin stdatomic stdatomic.h "atomic_int foo, bar =
ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar"
+#
+# some configurations also require linking to libatomic, so try
+# both with -latomic and without
+for LATOMIC in "-latomic" ""; do
+check_builtin stdatomic
stdatomic.h \
+"atomic_int foo, bar = ATOMIC_VAR_INIT(-1);
atomic_store(&foo, 0); foo += bar"  \
+$LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
+done

LGTM now, thanks.


 check_lib advapi32 "windows.h"RegCloseKey
-ladvapi32
   check_lib bcrypt   "windows.h bcrypt.h"   BCryptGenRandom -lbcrypt &&

Wait, this should be checking without first then with, if the first test
without fails.


This was covered earlier in the thread for the reason it is not - its
deliberate, because exhaustive functionality checks would be very
complicated.


Testing this commit out it does as I had suspected and even with --as-needed
causes a false positive on OpenBSD / FreeBSD.  Now erroneously tries to link
against libatomic and unlike the other project (haproxy) I ran across an 
overly
simplistic test (doesn't even involve linking, just checking compiler 
predefined

macros) I don't see any options to disable the broken test either.
___
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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-23 Thread Marton Balint




On Sun, 23 Jan 2022, Michael Niedermayer wrote:


On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:

Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
type should be an unsigned char on anything but Linux.


diff --git a/libavformat/udp.c b/libavformat/udp.c
index 180d96a988..29aa865fff 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 {
 #ifdef IP_MULTICAST_TTL
 if (addr->sa_family == AF_INET) {
-if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, 
sizeof(mcastTTL)) < 0) {
+#ifdef __linux__
+int ttl = mcastTTL;
+#else
+unsigned char ttl = mcastTTL;
+#endif


this "ifdef __linux__" feels like the wrong thing to check, dont you agree ?


As far as I remember linux supports both sizes. So maybe just remove the 
check entirely?


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

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


Re: [FFmpeg-devel] [PATCH 3/3] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

2022-01-23 Thread Martijn van Beurden
Op do 20 jan. 2022 22:18 schreef Anton Khirnov :

> Quoting Martijn van Beurden (2022-01-20 19:58:54)
> > Op do 20 jan. 2022 om 17:05 schreef Anton Khirnov :
> >
> > > Fixes #9563.
> > > ---
> > >  libavcodec/encode.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/libavcodec/encode.c b/libavcodec/encode.c
> > > index b6f81d1458..44ab81af3f 100644
> > > --- a/libavcodec/encode.c
> > > +++ b/libavcodec/encode.c
> > > @@ -535,6 +535,9 @@ static int encode_preinit_audio(AVCodecContext
> *avctx)
> > >  return AVERROR(EINVAL);
> > >  }
> > >
> > > +if (!avctx->bits_per_raw_sample)
> > > +avctx->bits_per_raw_sample = 8 *
> > > av_get_bytes_per_sample(avctx->sample_fmt);
> > > +
> > >  return 0;
> > >  }
> > >
> >
> > This creates a new regression: now 24-bit WAV files are converted to
> 32-bit
> > WavPack files. I think I found the cause of the problem though: the issue
> > is that wavpack uses sample format s32p and 24-bit wav files use s32.
> > Therefore, a aresample filter is auto-inserted to convert s32p to s32,
> > which causes ost->filter->graph->is_meta to be false.
>
> You can work around this by using the -bits_per_raw_sample option.
> Handling this in a more automagic manner would be complicated - we could
> propagate bits_per_raw_sample through lavfi or add it to AVFrame.
>

I think this patch shouldn't be applied. Without it 32 bit audio is
transcoded to 24 bit audio, which is not lossless. However, with this patch
24 bit audio is transcoded to 32 bit audio which is lossless, but the
resulting files are understood by few software decoder and probably no
hardware decoders.

Perhaps adding a warning instead of setting a default would be better?

>
___
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] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-23 Thread Michael Niedermayer
On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:
> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
> type should be an unsigned char on anything but Linux.
> 
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 180d96a988..29aa865fff 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int 
> mcastTTL,
>  {
>  #ifdef IP_MULTICAST_TTL
>  if (addr->sa_family == AF_INET) {
> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, 
> sizeof(mcastTTL)) < 0) {
> +#ifdef __linux__
> +int ttl = mcastTTL;
> +#else
> +unsigned char ttl = mcastTTL;
> +#endif

this "ifdef __linux__" feels like the wrong thing to check, dont you agree ?

thx

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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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/tests/adler32: Remove unnecessary volatile

2022-01-23 Thread Andreas Rheinhardt
And use an ordinary stack variable.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/tests/adler32.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavutil/tests/adler32.c b/libavutil/tests/adler32.c
index 13f760b477..356e1a97e7 100644
--- a/libavutil/tests/adler32.c
+++ b/libavutil/tests/adler32.c
@@ -27,12 +27,11 @@
 
 #define LEN 7001
 
-static volatile int checksum;
-
 int main(int argc, char **argv)
 {
 int i;
 uint8_t data[LEN];
+AVAdler checksum;
 
 av_log_set_level(AV_LOG_DEBUG);
 
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH] avformat/wavenc: allow WAVEFORMATEXTENSIBLE to be suppressed

2022-01-23 Thread Tom Yan
While WAVEFORMATEX sort of mandates WAVEFORMATEXTENSIBLE to be
used for audio with sample size other than 8 or 16,
PCMWAVEFORMAT does not practically have any limitation in
supporting higher sample size that is a multiple of 8 (or sample
rate higher than 48000).

In terms of sample size, the only real reason that the extension
exists is that it allows both an actual sample size and a
multiple-of-8 container size to be stored. However, such facility
is of no use when the actual sample size is a multiple of 8, let
alone that muxer never made use of it (since it never actually
supported sample size like 20 anyway; at least not in the way it
is supposed to.)

Although WAVEFORMATEXTENSIBLE has been around for more than two
decades, apparently programs and libraries that do not support
the format still exist.

Therefore, adding an option that allows the WAVEFORMATEXTENSIBLE
"extensions" to be suppressed and the format tag field to be set
to WAVE_FORMAT_PCM (0x0001) for audio with sample size higher than
16 (or sample rate higher than 48000).

Signed-off-by: Tom Yan 
---
 libavformat/riff.h| 5 +
 libavformat/riffenc.c | 4 ++--
 libavformat/wavenc.c  | 5 -
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/riff.h b/libavformat/riff.h
index 85d6786663..5794857f53 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -57,6 +57,11 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters 
*par, int for_asf, int
  */
 #define FF_PUT_WAV_HEADER_SKIP_CHANNELMASK  0x0002
 
+/**
+ * Tell ff_put_wav_header() not to write WAVEFORMATEXTENSIBLE extensions if 
possible.
+ */
+#define FF_PUT_WAV_HEADER_FORCE_PCMWAVEFORMAT  0x0004
+
 /**
  * Write WAVEFORMAT header structure.
  *
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index ffccfa3d48..4dc8ca6e0f 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -80,9 +80,9 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
 waveformatextensible = (par->channels > 2 && par->channel_layout) ||
par->channels == 1 && par->channel_layout && 
par->channel_layout != AV_CH_LAYOUT_MONO ||
par->channels == 2 && par->channel_layout && 
par->channel_layout != AV_CH_LAYOUT_STEREO ||
-   par->sample_rate > 48000 ||
par->codec_id == AV_CODEC_ID_EAC3 ||
-   av_get_bits_per_sample(par->codec_id) > 16;
+   ((par->sample_rate > 48000 || 
av_get_bits_per_sample(par->codec_id) > 16) &&
+!(flags & FF_PUT_WAV_HEADER_FORCE_PCMWAVEFORMAT));
 
 if (waveformatextensible)
 avio_wl16(pb, 0xfffe);
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 2317700be1..bd41d6eeb3 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -83,6 +83,7 @@ typedef struct WAVMuxContext {
 int peak_block_pos;
 int peak_ppv;
 int peak_bps;
+int extensible;
 } WAVMuxContext;
 
 #if CONFIG_WAV_MUXER
@@ -324,9 +325,10 @@ static int wav_write_header(AVFormatContext *s)
 }
 
 if (wav->write_peak != PEAK_ONLY) {
+int flags = !wav->extensible ? FF_PUT_WAV_HEADER_FORCE_PCMWAVEFORMAT : 
0;
 /* format header */
 fmt = ff_start_tag(pb, "fmt ");
-if (ff_put_wav_header(s, pb, s->streams[0]->codecpar, 0) < 0) {
+if (ff_put_wav_header(s, pb, s->streams[0]->codecpar, flags) < 0) {
 av_log(s, AV_LOG_ERROR, "Codec %s not supported in WAVE format\n",
avcodec_get_name(s->streams[0]->codecpar->codec_id));
 return AVERROR(ENOSYS);
@@ -494,6 +496,7 @@ static const AVOption options[] = {
 { "peak_block_size", "Number of audio samples used to generate each peak 
frame.",   OFFSET(peak_block_size), AV_OPT_TYPE_INT, { .i64 = 256 }, 0, 65536, 
ENC },
 { "peak_format", "The format of the peak envelope data (1: uint8, 2: 
uint16).", OFFSET(peak_format), AV_OPT_TYPE_INT, { .i64 = 
PEAK_FORMAT_UINT16 }, PEAK_FORMAT_UINT8, PEAK_FORMAT_UINT16, ENC },
 { "peak_ppv","Number of peak points per peak value (1 or 2).", 
 OFFSET(peak_ppv), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 2, ENC },
+{ "extensible",  "Write WAVEFORMATEXTENSIBLE extensions.", 
 OFFSET(extensible), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, ENC },
 { NULL },
 };
 
-- 
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".