Re: [FFmpeg-devel] videolan ffmpeg git issue [please dont push before reading]

2023-02-24 Thread Gyan Doshi




On 2023-02-25 06:44 am, Michael Niedermayer wrote:

Hi all

it seems videolan had a double RAID failure and was restored from backup
that caused ffmpeg developer git for master and release/5.1 to rewind by
a few commits.


git pull gives 'WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!'

Is this expected?

Regards,
Gyan

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

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


Re: [FFmpeg-devel] [PATCH 4/6] avformat/mov: parse ISO-14496-12 ChannelLayout

2023-02-24 Thread Zhao Zhili
On Fri, 2023-02-24 at 15:49 +0200, Jan Ekström wrote:
> On Fri, Feb 24, 2023 at 6:25 AM Zhao Zhili  wrote:
> > 
> > From: Zhao Zhili 
> > 
> > Signed-off-by: Zhao Zhili 
> 
> Hah, I actually happened to recently start coding uncompressed audio
> support in mp4 myself, but what this commit is handling is what
> basically killed my version off since the channel layout box is
> required.
> 
> If you're interested you can check my take over at
> https://github.com/jeeb/ffmpeg/commits/pcmc_parsing_improvements .

Sorry I didn't notice your work on this issue. I have cherry-picked
the first two patches from your branch in v2. Is it OK for you?

It's tediousFor the channel layout supports. Some of the layouts aren't
supported yet, and some of the details are unclear. Please help review
and improve this part.
 
> 
> Will comment on some things.
> 
> > ---
> >  libavformat/mov.c  |  79 +++-
> >  libavformat/mov_chan.c | 265 +
> >  libavformat/mov_chan.h |  26 
> >  3 files changed, 369 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index b125343f84..1db869aa2e 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -940,6 +940,82 @@ static int mov_read_chan(MOVContext *c, AVIOContext 
> > *pb, MOVAtom atom)
> >  return 0;
> >  }
> > 
> > +static int mov_read_chnl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> > +{
> > +int64_t end = av_sat_add64(avio_tell(pb), atom.size);
> > +int stream_structure;
> > +int ret = 0;
> > +AVStream *st;
> > +
> > +if (c->fc->nb_streams < 1)
> > +return 0;
> > +st = c->fc->streams[c->fc->nb_streams-1];
> > +
> > +/* skip version and flags */
> > +avio_skip(pb, 4);
> 
> We should really not do this any more. Various FullBoxes have multiple
> versions or depend on the flags. See how I have added FullBox things
> recently, although I would prefer us to have a generic macro/function
> setup for this where you then get the version and flags as arguments
> or whatever in the future.

I have added version and flags check, and only supports version 0 with
patch v2. Welcome to add version 1 supports :)

I agree with the idea to cleanup the handling of version and flags for
future proof.

> 
> For this specific box, there are now versions 0 and 1 defined since
> circa 2018-2019 or so (visible at least in 14496-12 2022)
> 
> Since ISO/IEC has changed the rules for free specifications (against
> the wishes of various spec authors) and all that jazz, this is how
> it's defined in what I have on hand:
> 
> 12.2.4  Channel layout
> 
> 12.2.4.1  Definition
> 
> Box Types:  'chnl'
> Container: Audio sample entry
> Mandatory: No
> Quantity: Zero or one
> 
> This box may appear in an audio sample entry to document the
> assignment of channels in the audio
> stream. It is recommended to use this box to convey the base channel
> count for the DownMixInstructions
> box and other DRC-related boxes specified in ISO/IEC 23003-4.
> The channel layout can be all or part of a standard layout (from an
> enumerated list), or a custom layout
> (which also allows a track to contribute part of an overall layout).
> A stream may contain channels, objects, neither, or both. A stream
> that is neither channel nor object
> structured can implicitly be rendered in a variety of ways.
> 
> 12.2.4.2  Syntax
> 
> aligned(8) class ChannelLayout extends FullBox('chnl', version, flags=0) {
>if (version==0) {
>   unsigned int(8) stream_structure;
>   if (stream_structure & channelStructured) {
>  unsigned int(8) definedLayout;
>   if (definedLayout==0) {
> for (i = 1 ; i <= layout_channel_count ; i++) {
>//  layout_channel_count comes from the sample entry
>unsigned int(8) speaker_position;
>if (speaker_position == 126) {   // explicit position
>   signed int (16) azimuth;
>   signed int (8)  elevation;
>}
> }
>  } else {
> unsigned int(64)   omittedChannelsMap;
>   // a ‘1’ bit indicates ‘not in this track’
>  }
>   }
>   if (stream_structure & objectStructured) {
>  unsigned int(8) object_count;
>   }
>} else {
>   unsigned int(4) stream_structure;
>   unsigned int(4) format_ordering;
>   unsigned int(8) baseChannelCount;
>   if (stream_structure & channelStructured) {
>  unsigned int(8) definedLayout;
>  if (definedLayout==0) {
> unsigned int(8) layout_channel_count;
> for (i = 1 ; i <= layout_channel_count ; i++) {
>unsigned int(8) speaker_position;
>if (speaker_position == 126) {   // explicit position
>   signed int (16) azimuth;
>   signed int (8)  elevation;
>}
> }
>  } else {
> int(4) 

[FFmpeg-devel] [PATCH] libavcodec/libfdk-aacenc: Enable writing DRC metadata

2023-02-24 Thread JonHGee
Added basic DRC options and ref levels to AV options. If any options are 
selected, metadata mode is set accordingly and metadata is added to input 
buffer per FDK encoder API.

---
 libavcodec/libfdk-aacenc.c | 72 ++
 1 file changed, 58 insertions(+), 14 deletions(-)

diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 54549de473..4e67b1ece3 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -46,6 +46,12 @@ typedef struct AACContext {
 int latm;
 int header_period;
 int vbr;
+int drc_profile;
+int drc_target_ref;
+int comp_profile;
+int comp_target_ref;
+int prog_ref;
+AACENC_MetaData metaDataSetup;
 
 AudioFrameQueue afq;
 } AACContext;
@@ -64,6 +70,11 @@ static const AVOption aac_enc_options[] = {
 { "latm", "Output LATM/LOAS encapsulated data", offsetof(AACContext, 
latm), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_ENCODING_PARAM },
 { "header_period", "StreamMuxConfig and PCE repetition period (in 
frames)", offsetof(AACContext, header_period), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 0x, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
 { "vbr", "VBR mode (1-5)", offsetof(AACContext, vbr), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, 5, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+{ "drc_profile", "The desired compression profile for AAC DRC", 
offsetof(AACContext, drc_profile), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 256, 
AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+{ "drc_target_ref", "Expected target reference level at decoder side in dB 
(for clipping prevention/limiter)", offsetof(AACContext, drc_target_ref), 
AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_ENCODING_PARAM },
+{ "comp_profile", "The desired compression profile for AAC DRC", 
offsetof(AACContext, comp_profile), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 256, 
AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+{ "comp_target_ref", "Expected target reference level at decoder side in 
dB (for clipping prevention/limiter)", offsetof(AACContext, comp_target_ref), 
AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_ENCODING_PARAM },
+{ "prog_ref", "The program reference level or dialog level in dB", 
offsetof(AACContext, prog_ref), AV_OPT_TYPE_INT, { .i64 = 0.0 }, -31.75, 0, 
AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
 FF_AAC_PROFILE_OPTS
 { NULL }
 };
@@ -127,6 +138,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
 AACENC_ERROR err;
 int aot = FF_PROFILE_AAC_LOW + 1;
 int sce = 0, cpe = 0;
+int metadata_mode = 0;
 
 if ((err = aacEncOpen(>handle, 0, avctx->ch_layout.nb_channels)) != 
AACENC_OK) {
 av_log(avctx, AV_LOG_ERROR, "Unable to open the encoder: %s\n",
@@ -319,6 +331,29 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
 }
 }
 
+if (s->prog_ref) {
+metadata_mode = 1;
+s->metaDataSetup.prog_ref_level_present = 1;
+s->metaDataSetup.prog_ref_level = s->prog_ref << 16;
+}
+if (s->drc_profile) {
+metadata_mode = 1;
+s->metaDataSetup.drc_profile = s->drc_profile;
+s->metaDataSetup.drc_TargetRefLevel = s->drc_target_ref << 16;
+if (s->comp_profile) {
+// Including the comp_profile means that we need to set the mode 
to ETSI
+metadata_mode = 2;
+s->metaDataSetup.comp_profile = s->comp_profile;
+s->metaDataSetup.comp_TargetRefLevel = s->comp_target_ref << 16;
+}
+}
+
+if ((err = aacEncoder_SetParam(s->handle, AACENC_METADATA_MODE, 
metadata_mode)) != AACENC_OK) {
+av_log(avctx, AV_LOG_ERROR, "Unable to set metadata mode to %d: %s\n",
+metadata_mode, aac_get_error(err));
+goto error;
+}
+
 if ((err = aacEncEncode(s->handle, NULL, NULL, NULL, NULL)) != AACENC_OK) {
 av_log(avctx, AV_LOG_ERROR, "Unable to initialize the encoder: %s\n",
aac_get_error(err));
@@ -363,11 +398,13 @@ static int aac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 AACENC_BufDesc in_buf   = { 0 }, out_buf = { 0 };
 AACENC_InArgs  in_args  = { 0 };
 AACENC_OutArgs out_args = { 0 };
-int in_buffer_identifier = IN_AUDIO_DATA;
-int in_buffer_size, in_buffer_element_size;
+void* inBuffer[] = { 0, >metaDataSetup };
+int in_buffer_identifiers[] = { IN_AUDIO_DATA, IN_METADATA_SETUP };
+int in_buffer_element_sizes[]   = { 2, sizeof(AACENC_MetaData) };
+int in_buffer_sizes[] = { 0 , sizeof(s->metaDataSetup) };
+void *out_ptr;
 int out_buffer_identifier = OUT_BITSTREAM_DATA;
 int out_buffer_size, out_buffer_element_size;
-void *in_ptr, *out_ptr;
 int ret;
 uint8_t dummy_buf[1];
 AACENC_ERROR err;
@@ -376,27 +413,34 @@ static int aac_encode_frame(AVCodecContext 

[FFmpeg-devel] videolan ffmpeg git issue [please dont push before reading]

2023-02-24 Thread Michael Niedermayer
Hi all

it seems videolan had a double RAID failure and was restored from backup
that caused ffmpeg developer git for master and release/5.1 to rewind by
a few commits.
It would be slightly messy if different commits are pushed on that rewond
HEADs- So if you push something (when its possible again) please make sure
that teh commits match the previous (pre restore) ones

Its not the end of the world if others are pushed, we would then need
a merge commit to reconcile these 2 histories

thx


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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] libavcodec/libfdk-aacnc: send encoder delay/padding in packet side data

2023-02-24 Thread JonHGee
---
 libavcodec/libfdk-aacenc.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 54549de473..55d10990e4 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -21,6 +21,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "audio_frame_queue.h"
@@ -46,6 +47,7 @@ typedef struct AACContext {
 int latm;
 int header_period;
 int vbr;
+int delay_sent;
 
 AudioFrameQueue afq;
 } AACContext;
@@ -368,7 +370,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket 
*avpkt,
 int out_buffer_identifier = OUT_BITSTREAM_DATA;
 int out_buffer_size, out_buffer_element_size;
 void *in_ptr, *out_ptr;
-int ret;
+int ret, discard_padding;
 uint8_t dummy_buf[1];
 AACENC_ERROR err;
 
@@ -428,6 +430,29 @@ static int aac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 ff_af_queue_remove(>afq, avctx->frame_size, >pts,
>duration);
 
+discard_padding = avctx->frame_size - avpkt->duration;
+// Check if subtraction resulted in an overflow
+if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) {
+av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n");
+av_packet_unref(avpkt);
+av_free(avpkt);
+return AVERROR(EINVAL);
+}
+if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) 
{
+uint8_t *side_data =
+av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
+if (!side_data) {
+av_packet_unref(avpkt);
+av_free(avpkt);
+return AVERROR(ENOMEM);
+}
+if (!s->delay_sent) {
+AV_WL32(side_data, avctx->initial_padding);
+s->delay_sent = 1;
+}
+AV_WL32(side_data + 4, discard_padding);
+}
+
 avpkt->size = out_args.numOutBytes;
 *got_packet_ptr = 1;
 return 0;
-- 
2.39.2.637.g21b0678d19-goog

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

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


Re: [FFmpeg-devel] [PATCH 4/6] avformat/mov: parse ISO-14496-12 ChannelLayout

2023-02-24 Thread Zhao Zhili
On Fri, 2023-02-24 at 10:42 +0100, Tomas Härdin wrote:
> fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> > +    if (!layout) {
> > +    uint8_t positions[64] = {};
> 
> Is there a maximum number of channels defined somewhere? stsd supports
> up to 65535.

AV_CHANNEL_ORDER_NATIVE supports up to 63 different channels.
Patchset v2 adds AVChannelCustom support.

> 
> > +    // stream carries objects
> > +    if (stream_structure & 2) {
> > +    int obj_count = avio_r8(pb);
> > +    av_log(c->fc, AV_LOG_TRACE, "'chnl' with object_count %d\n",
> > obj_count);
> > +    }
> > +
> > +    avio_seek(pb, end, SEEK_SET);
> 
> I feel we should complain loudly if there's bytes not accounted for, at
> least when (stream_structure & 2) == 0

Patchset v2 adds log message when skipping unknown bytes.
After a second thought, I made a mistake that unknown bytes
comes after ChannelLayout belonging to AudioSampleEntryV1,
not inside ChannelLayout. Will drop the check and seek in v3.

class AudioSampleEntryV1(codingname) extends SampleEntry (codingname){
...

ChannelLayout();
// we permit any number of DownMix or DRC boxes:
DownMixInstructions() [];
DRCCoefficientsBasic() [];
...

> 
> The rest I can't say much about
> 
> /Tomas
> 
> ___
> 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/6] avformat/movenc: add PCM in mp4 support

2023-02-24 Thread Zhao Zhili
On Fri, 2023-02-24 at 10:41 +0100, Tomas Härdin wrote:
> fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> > +static int is_mp4_pcm_codec(enum AVCodecID codec)
> > +{
> > +    static const enum AVCodecID codec_list[] = {
> > +    AV_CODEC_ID_PCM_S16BE,
> > +    AV_CODEC_ID_PCM_S16LE,
> > +    AV_CODEC_ID_PCM_S24BE,
> > +    AV_CODEC_ID_PCM_S24LE,
> > +    AV_CODEC_ID_PCM_S32BE,
> > +    AV_CODEC_ID_PCM_S32LE,
> > +
> > +    AV_CODEC_ID_PCM_F32BE,
> > +    AV_CODEC_ID_PCM_F32LE,
> > +    AV_CODEC_ID_PCM_F64BE,
> > +    AV_CODEC_ID_PCM_F64LE,
> > +    };
> > +
> > +    for (int i = 0; i < FF_ARRAY_ELEMS(codec_list); i++) {
> > +    if (codec == codec_list[i])
> > +    return 1;
> > +    }
> 
> A switch() with multiple case statements in a row would be more
> concise.

Fixed in v2.

> 
> The rest looks OK
> 
> /Tomas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


[FFmpeg-devel] [PATCH v2 8/8] fate/mov: add PCM in mp4 test

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 tests/fate/mov.mak   | 12 
 tests/filtergraphs/mov-mp4-pcm   |  5 +
 tests/ref/fate/mov-mp4-pcm   | 27 +++
 tests/ref/fate/mov-mp4-pcm-float |  7 +++
 4 files changed, 51 insertions(+)
 create mode 100644 tests/filtergraphs/mov-mp4-pcm
 create mode 100644 tests/ref/fate/mov-mp4-pcm
 create mode 100644 tests/ref/fate/mov-mp4-pcm-float

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 8a7218a215..d795445691 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -165,6 +165,18 @@ FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, 
WAV_DEMUXER PAN_FILTER) \
 fate-mov-channel-description: tests/data/asynth-44100-1.wav 
tests/data/filtergraphs/mov-channel-description
 fate-mov-channel-description: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mov "-filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/mov-channel-description -map [outFL] 
-map [outFR] -map [outFC] -map [outLFE] -map [outBL] -map [outBR] -map [outDL] 
-map [outDR] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
+# Test PCM in mp4 and channel layout
+FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
+  += fate-mov-mp4-pcm
+fate-mov-mp4-pcm: tests/data/asynth-44100-1.wav 
tests/data/filtergraphs/mov-mp4-pcm
+fate-mov-mp4-pcm: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/mov-mp4-pcm -map [mono] -map [stereo] 
-map [2.1] -map [5.1] -map [7.1] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
+
+# Test floating sample format PCM in mp4 and unusual channel layout
+FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
+  += fate-mov-mp4-pcm-float
+fate-mov-mp4-pcm-float: tests/data/asynth-44100-1.wav
+fate-mov-mp4-pcm-float: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-af 
aresample,pan=FL+LFE+BR|c0=c0|c1=c0|c2=c0 -c:a pcm_f32le" "-map 0 -c copy 
-frames:a 0"
+
 FATE_FFMPEG += $(FATE_MOV_FFMPEG-yes)
 
 fate-mov: $(FATE_MOV) $(FATE_MOV_FFMPEG-yes) $(FATE_MOV_FFPROBE) 
$(FATE_MOV_FASTSTART) $(FATE_MOV_FFMPEG_FFPROBE-yes)
diff --git a/tests/filtergraphs/mov-mp4-pcm b/tests/filtergraphs/mov-mp4-pcm
new file mode 100644
index 00..7fa25a2c3c
--- /dev/null
+++ b/tests/filtergraphs/mov-mp4-pcm
@@ -0,0 +1,5 @@
+[0:a:0]pan=mono|c0=c0[mono];
+[0:a:0]pan=stereo|c0=c0|c1=c0[stereo];
+[0:a:0]pan=2.1|c0=c0|c1=c0|c2=c0[2.1];
+[0:a:0]pan=5.1|c0=c0|c1=c0|c2=c0|c3=c0|c4=c0|c5=c0[5.1];
+[0:a:0]pan=7.1|c0=c0|c1=c0|c2=c0|c3=c0|c4=c0|c5=c0|c6=c0|c7=c0[7.1];
diff --git a/tests/ref/fate/mov-mp4-pcm b/tests/ref/fate/mov-mp4-pcm
new file mode 100644
index 00..b34f5e59e1
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-pcm
@@ -0,0 +1,27 @@
+1573ecbd24a65a6ec23ef08a861614b3 *tests/data/fate/mov-mp4-pcm.mp4
+10589277 tests/data/fate/mov-mp4-pcm.mp4
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+#tb 1: 1/44100
+#media_type 1: audio
+#codec_id 1: pcm_s16le
+#sample_rate 1: 44100
+#channel_layout_name 1: stereo
+#tb 2: 1/44100
+#media_type 2: audio
+#codec_id 2: pcm_s16le
+#sample_rate 2: 44100
+#channel_layout_name 2: 2.1
+#tb 3: 1/44100
+#media_type 3: audio
+#codec_id 3: pcm_s16le
+#sample_rate 3: 44100
+#channel_layout_name 3: 5.1
+#tb 4: 1/44100
+#media_type 4: audio
+#codec_id 4: pcm_s16le
+#sample_rate 4: 44100
+#channel_layout_name 4: 7.1
diff --git a/tests/ref/fate/mov-mp4-pcm-float b/tests/ref/fate/mov-mp4-pcm-float
new file mode 100644
index 00..bd08eb9885
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-pcm-float
@@ -0,0 +1,7 @@
+77d82e3bef652692aaab31e1de4c7082 *tests/data/fate/mov-mp4-pcm-float.mp4
+3175929 tests/data/fate/mov-mp4-pcm-float.mp4
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_f32le
+#sample_rate 0: 44100
+#channel_layout_name 0: 3 channels (FL+LFE+BR)
-- 
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".


[FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavformat/movenc.c | 48 +++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3315057b88..058d3cd6d1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1199,6 +1199,47 @@ static int is_mp4_pcm_codec(enum AVCodecID codec)
 }
 }
 
+static int mov_write_chnl_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
+{
+int64_t pos = avio_tell(pb);
+int config = 0;
+int ret;
+uint8_t *speaker_pos = NULL;
+const AVChannelLayout *layout = >par->ch_layout;
+
+ret = ff_mov_get_channel_config_from_layout(layout, );
+if (ret || !config) {
+config = 0;
+speaker_pos = av_malloc(layout->nb_channels);
+ret = ff_mov_get_channel_positions_from_layout(layout,
+speaker_pos, layout->nb_channels);
+if (ret) {
+char buf[128] = {};
+
+av_freep(_pos);
+av_channel_layout_describe(layout, buf, sizeof(buf));
+av_log(s, AV_LOG_ERROR, "unsupported channel layout %s\n", buf);
+return ret;
+}
+}
+
+avio_wb32(pb, 0); /* size */
+ffio_wfourcc(pb, "chnl");
+avio_wb32(pb, 0); /* version & flags */
+
+avio_w8(pb, 1); /* stream_structure */
+avio_w8(pb, config);
+if (config) {
+avio_wb64(pb, 0);
+} else {
+for (int i = 0; i < layout->nb_channels; i++)
+avio_w8(pb, speaker_pos[i]);
+av_freep(_pos);
+}
+
+return update_size(pb, pos);
+}
+
 static int mov_write_pcmc_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
 {
 int64_t pos = avio_tell(pb);
@@ -1349,8 +1390,13 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 ret = mov_write_dmlp_tag(s, pb, track);
 else if (track->vos_len > 0)
 ret = mov_write_glbl_tag(pb, track);
-else if (track->mode == MODE_MP4 && is_mp4_pcm_codec(track->par->codec_id))
+else if (track->mode == MODE_MP4 && 
is_mp4_pcm_codec(track->par->codec_id)) {
+if (track->par->ch_layout.nb_channels > 1)
+ret = mov_write_chnl_tag(s, pb, track);
+if (ret < 0)
+return ret;
 ret = mov_write_pcmc_tag(s, pb, track);
+}
 
 if (ret < 0)
 return ret;
-- 
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".


[FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavformat/mov.c  |  85 +++-
 libavformat/mov_chan.c | 296 +
 libavformat/mov_chan.h |  26 
 3 files changed, 406 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index e75cf2f4b7..f8b424cd7f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -940,6 +940,88 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_chnl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int64_t end = av_sat_add64(avio_tell(pb), atom.size);
+int stream_structure;
+int version, flags;
+int ret = 0;
+AVStream *st;
+
+if (c->fc->nb_streams < 1)
+return 0;
+st = c->fc->streams[c->fc->nb_streams-1];
+
+version = avio_r8(pb);
+flags   = avio_rb24(pb);
+if (version != 0 || flags != 0) {
+av_log(c->fc, AV_LOG_ERROR,
+   "Unsupported 'chnl' box with version %d, flags: %#x",
+   version, flags);
+return AVERROR_INVALIDDATA;
+}
+
+stream_structure = avio_r8(pb);
+
+// stream carries channels
+if (stream_structure & 1) {
+int layout = avio_r8(pb);
+
+av_log(c->fc, AV_LOG_TRACE, "'chnl' layout %d\n", layout);
+if (!layout) {
+uint8_t *positions = 
av_malloc(st->codecpar->ch_layout.nb_channels);
+
+if (!positions)
+return AVERROR(ENOMEM);
+for (int i = 0; i < st->codecpar->ch_layout.nb_channels; i++) {
+int speaker_pos = avio_r8(pb);
+
+av_log(c->fc, AV_LOG_TRACE, "speaker_position %d\n", 
speaker_pos);
+if (speaker_pos == 126) { // explicit position
+avpriv_request_sample(c->fc, "explicit position");
+av_freep();
+return AVERROR_PATCHWELCOME;
+} else {
+positions[i] = speaker_pos;
+}
+}
+
+ret = ff_mov_get_layout_from_channel_positions(positions,
+st->codecpar->ch_layout.nb_channels,
+>codecpar->ch_layout);
+av_freep();
+if (ret) {
+av_log(c->fc, AV_LOG_ERROR,
+"get channel layout from speaker positions failed, 
%s\n",
+av_err2str(ret));
+return ret;
+}
+} else {
+uint64_t omitted_channel_map = avio_rb64(pb);
+
+if (omitted_channel_map) {
+avpriv_request_sample(c->fc, "omitted_channel_map 0x%" PRIx64 
" != 0",
+  omitted_channel_map);
+return AVERROR_PATCHWELCOME;
+}
+ff_mov_get_channel_layout_from_config(layout, 
>codecpar->ch_layout);
+}
+}
+
+// stream carries objects
+if (stream_structure & 2) {
+int obj_count = avio_r8(pb);
+av_log(c->fc, AV_LOG_TRACE, "'chnl' with object_count %d\n", 
obj_count);
+}
+
+if (avio_tell(pb) != end) {
+av_log(c->fc, AV_LOG_WARNING, "skip %" PRId64 " bytes of unknown data 
inside chnl\n",
+end - avio_tell(pb));
+avio_seek(pb, end, SEEK_SET);
+}
+return ret;
+}
+
 static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
@@ -7815,7 +7897,8 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */
 { MKTAG('w','f','e','x'), mov_read_wfex },
 { MKTAG('c','m','o','v'), mov_read_cmov },
-{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout */
+{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout from quicktime */
+{ MKTAG('c','h','n','l'), mov_read_chnl }, /* channel layout from ISO-14496-12 
*/
 { MKTAG('d','v','c','1'), mov_read_dvc1 },
 { MKTAG('s','g','p','d'), mov_read_sgpd },
 { MKTAG('s','b','g','p'), mov_read_sbgp },
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index f66bf0df7f..df17976e59 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -551,3 +551,299 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
 
 return 0;
 }
+
+/* ISO/IEC 23001-8, 8.2 */
+static const AVChannelLayout iso_channel_configuration[] = {
+// 0: any setup
+{},
+
+// 1: centre front
+AV_CHANNEL_LAYOUT_MONO,
+
+// 2: left front, right front
+AV_CHANNEL_LAYOUT_STEREO,
+
+// 3: centre front, left front, right front
+AV_CHANNEL_LAYOUT_SURROUND,
+
+// 4: centre front, left front, right front, rear centre
+AV_CHANNEL_LAYOUT_4POINT0,
+
+// 5: centre front, left front, right front, left surround, right surround
+AV_CHANNEL_LAYOUT_5POINT0,
+
+// 6: 5 + LFE
+AV_CHANNEL_LAYOUT_5POINT1,
+
+// 7: centre front, left front centre, right front centre,
+// left front, right front, left 

[FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

ipcm is defined by ISO/IEC 23003-5, not defined by quicktime. After
adding ISO/IEC 23003-5 support, we don't need it for ticket #9219.

Signed-off-by: Zhao Zhili 
---
 libavformat/isom_tags.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..86c7272525 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -321,8 +321,6 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
 { AV_CODEC_ID_PCM_S16LE,   MKTAG('s', 'o', 'w', 't') },
 { AV_CODEC_ID_PCM_S16BE,   MKTAG('l', 'p', 'c', 'm') },
 { AV_CODEC_ID_PCM_S16LE,   MKTAG('l', 'p', 'c', 'm') },
-{ AV_CODEC_ID_PCM_S16BE,   MKTAG('i', 'p', 'c', 'm') },
-{ AV_CODEC_ID_PCM_S16LE,   MKTAG('i', 'p', 'c', 'm') },
 { AV_CODEC_ID_PCM_S24BE,   MKTAG('i', 'n', '2', '4') },
 { AV_CODEC_ID_PCM_S24LE,   MKTAG('i', 'n', '2', '4') },
 { AV_CODEC_ID_PCM_S32BE,   MKTAG('i', 'n', '3', '2') },
-- 
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".


[FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Missing floating-point formats support.

Signed-off-by: Zhao Zhili 
---
 libavformat/mov.c | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a9911c0f79..e75cf2f4b7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1591,6 +1591,10 @@ static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 int format_flags;
 int version, flags;
+int pcm_sample_size;
+AVFormatContext *fc = c->fc;
+AVStream *st;
+MOVStreamContext *sc;
 
 if (atom.size < 6) {
 av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n");
@@ -1608,6 +1612,49 @@ static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 
 format_flags = avio_r8(pb);
+pcm_sample_size = avio_r8(pb);
+
+if (fc->nb_streams < 1)
+return AVERROR_INVALIDDATA;
+
+st = fc->streams[fc->nb_streams - 1];
+sc = st->priv_data;
+
+if (sc->format == MKTAG('f', 'p', 'c', 'm')) {
+switch (pcm_sample_size) {
+case 32:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F32BE;
+break;
+case 64:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F64BE;
+break;
+default:
+av_log(fc, AV_LOG_ERROR, "invalid pcm_sample_size %d for 'fpcm'\n",
+ pcm_sample_size);
+return AVERROR_INVALIDDATA;
+}
+} else if (sc->format == MKTAG('i', 'p', 'c', 'm')) {
+switch (pcm_sample_size) {
+case 16:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
+break;
+case 24:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S24BE;
+break;
+case 32:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
+break;
+default:
+av_log(fc, AV_LOG_ERROR, "invalid pcm_sample_size %d for 'ipcm'\n",
+ pcm_sample_size);
+return AVERROR_INVALIDDATA;
+}
+} else {
+av_log(fc, AV_LOG_ERROR, "'pcmC' with invalid sample entry '%s'\n",
+av_fourcc2str(sc->format));
+return AVERROR_INVALIDDATA;
+}
+
 if (format_flags & 1) // indicates little-endian format. If not present, 
big-endian format is used
 set_last_stream_little_endian(c->fc);
 
-- 
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".


[FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB

2023-02-24 Thread Zhao Zhili
From: Jan Ekström 

As per 23003-5:2020, the rest of the bits are reserved, and thus
in the future they may be utilized for something else.

Quote:
format_flags is a field of flags that modify the default PCM sample format.
Undefined flags are reserved and shall be zero. The following flag is defined:
  0x01 indicates little-endian format. If not present, big-endian format is 
used.
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index cdd44a9e44..a9911c0f79 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1608,7 +1608,7 @@ static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 
 format_flags = avio_r8(pb);
-if (format_flags == 1) // indicates little-endian format. If not present, 
big-endian format is used
+if (format_flags & 1) // indicates little-endian format. If not present, 
big-endian format is used
 set_last_stream_little_endian(c->fc);
 
 return 0;
-- 
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".


[FFmpeg-devel] [PATCH v2 0/8] add PCM in mp4 support

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

This patchset adds support of demux/mux PCM in mp4, and related channel
layout information. PCM in mp4 is defined by ISO/IEC 23003-5. The channel
layout tag 'chn' is defined by ISO/IEC 14496-12 with reference to ISO/IEC
23001-8.

v2:
1/8: simplied with switch-case
2-3/8: cherry-picked from jeeb's work
4/8: use switch-case and add log message
5/8:
6/8: 
  a. check version and flags
  b. support number of channels >= 64 with custom layout
  c. fix some channel layout operations like assignment directly
  d. return error for unsupported channel configurations
  e. warning when skiping bytes
7/8: support number of channels >= 64
8/8: fix fate-mov-mp4-pcm-float dependency

Jan Ekström (2):
  avformat/mov: check that pcmC box is of the expected type
  avformat/mov: base the endianness on just the LSB

Zhao Zhili (6):
  avformat/movenc: add PCM in mp4 support
  avformat/mov: fix ISO/IEC 23003-5 support
  avformat/isom_tags: remove ipcm from movaudio_tags
  avformat/mov: parse ISO-14496-12 ChannelLayout
  avformat/movenc: write ChannelLayout box for PCM
  fate/mov: add PCM in mp4 test

 libavformat/isom_tags.c  |   2 -
 libavformat/mov.c| 147 ++-
 libavformat/mov_chan.c   | 296 +++
 libavformat/mov_chan.h   |  26 +++
 libavformat/movenc.c | 106 ++-
 tests/fate/mov.mak   |  12 ++
 tests/filtergraphs/mov-mp4-pcm   |   5 +
 tests/ref/fate/mov-mp4-pcm   |  27 +++
 tests/ref/fate/mov-mp4-pcm-float |   7 +
 9 files changed, 621 insertions(+), 7 deletions(-)
 create mode 100644 tests/filtergraphs/mov-mp4-pcm
 create mode 100644 tests/ref/fate/mov-mp4-pcm
 create mode 100644 tests/ref/fate/mov-mp4-pcm-float

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


[FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type

2023-02-24 Thread Zhao Zhili
From: Jan Ekström 

As per 23003-5:2020 this box is defined as
PCMConfig extends FullBox(‘pcmC’, version = 0, 0), which means
that version is 0 and flags should be zero.
---
 libavformat/mov.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8af564ed61..cdd44a9e44 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1590,14 +1590,23 @@ static int mov_read_enda(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 int format_flags;
+int version, flags;
 
 if (atom.size < 6) {
 av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n");
 return AVERROR_INVALIDDATA;
 }
 
-avio_r8(pb);// version
-avio_rb24(pb);  // flags
+version = avio_r8(pb);
+flags   = avio_rb24(pb);
+
+if (version != 0 || flags != 0) {
+av_log(c->fc, AV_LOG_ERROR,
+   "Unsupported 'pcmC' box with version %d, flags: %x",
+   version, flags);
+return AVERROR_INVALIDDATA;
+}
+
 format_flags = avio_r8(pb);
 if (format_flags == 1) // indicates little-endian format. If not present, 
big-endian format is used
 set_last_stream_little_endian(c->fc);
-- 
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".


[FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

It's defined by ISO/IEC 23003-5.

Fixes ticket #10185

Signed-off-by: Zhao Zhili 
---
 libavformat/movenc.c | 60 +++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c4fcb5f8b1..3315057b88 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1179,6 +1179,47 @@ static int mov_write_btrt_tag(AVIOContext *pb, MOVTrack 
*track)
 return update_size(pb, pos);
 }
 
+static int is_mp4_pcm_codec(enum AVCodecID codec)
+{
+switch (codec) {
+case AV_CODEC_ID_PCM_S16BE:
+case AV_CODEC_ID_PCM_S16LE:
+case AV_CODEC_ID_PCM_S24BE:
+case AV_CODEC_ID_PCM_S24LE:
+case AV_CODEC_ID_PCM_S32BE:
+case AV_CODEC_ID_PCM_S32LE:
+
+case AV_CODEC_ID_PCM_F32BE:
+case AV_CODEC_ID_PCM_F32LE:
+case AV_CODEC_ID_PCM_F64BE:
+case AV_CODEC_ID_PCM_F64LE:
+return 1;
+default:
+return 0;
+}
+}
+
+static int mov_write_pcmc_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
+{
+int64_t pos = avio_tell(pb);
+int format_flags;
+
+avio_wb32(pb, 0); /* size */
+ffio_wfourcc(pb, "pcmC");
+avio_wb32(pb, 0); /* version & flags */
+
+/* 0x01: indicates little-endian format */
+format_flags = (track->par->codec_id == AV_CODEC_ID_PCM_F32LE ||
+track->par->codec_id == AV_CODEC_ID_PCM_F64LE ||
+track->par->codec_id == AV_CODEC_ID_PCM_S16LE ||
+track->par->codec_id == AV_CODEC_ID_PCM_S24LE ||
+track->par->codec_id == AV_CODEC_ID_PCM_S32LE);
+avio_w8(pb, format_flags);
+avio_w8(pb, track->par->bits_per_raw_sample);
+
+return update_size(pb, pos);
+}
+
 static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, 
MOVMuxContext *mov, MOVTrack *track)
 {
 int64_t pos = avio_tell(pb);
@@ -1243,7 +1284,8 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 } else { /* reserved for mp4/3gp */
 avio_wb16(pb, track->par->ch_layout.nb_channels);
 if (track->par->codec_id == AV_CODEC_ID_FLAC ||
-track->par->codec_id == AV_CODEC_ID_ALAC) {
+track->par->codec_id == AV_CODEC_ID_ALAC ||
+is_mp4_pcm_codec(track->par->codec_id)) {
 avio_wb16(pb, track->par->bits_per_raw_sample);
 } else {
 avio_wb16(pb, 16);
@@ -1307,6 +1349,8 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 ret = mov_write_dmlp_tag(s, pb, track);
 else if (track->vos_len > 0)
 ret = mov_write_glbl_tag(pb, track);
+else if (track->mode == MODE_MP4 && is_mp4_pcm_codec(track->par->codec_id))
+ret = mov_write_pcmc_tag(s, pb, track);
 
 if (ret < 0)
 return ret;
@@ -7744,6 +7788,20 @@ static const AVCodecTag codec_mp4_tags[] = {
 { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') },
 { AV_CODEC_ID_TTML,MOV_MP4_TTML_TAG  },
 { AV_CODEC_ID_TTML,MOV_ISMV_TTML_TAG },
+
+/* ISO/IEC 23003-5 integer formats */
+{ AV_CODEC_ID_PCM_S16BE,   MKTAG('i', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_S16LE,   MKTAG('i', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_S24BE,   MKTAG('i', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_S24LE,   MKTAG('i', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_S32BE,   MKTAG('i', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_S32LE,   MKTAG('i', 'p', 'c', 'm') },
+/* ISO/IEC 23003-5 floating-point formats */
+{ AV_CODEC_ID_PCM_F32BE,   MKTAG('f', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_F32LE,   MKTAG('f', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_F64BE,   MKTAG('f', 'p', 'c', 'm') },
+{ AV_CODEC_ID_PCM_F64LE,   MKTAG('f', 'p', 'c', 'm') },
+
 { AV_CODEC_ID_NONE,   0 },
 };
 #if CONFIG_MP4_MUXER || CONFIG_PSP_MUXER
-- 
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] FFmpeg 6.0

2023-02-24 Thread Brad Isbell
For the release name, I vote 6.0.  ;-)

Brad Isbell // AudioPump, Inc.
b...@audiopump.co
Phone: +1 312-488-4680


On Fri, Feb 24, 2023 at 9:56 AM Niklas Haas  wrote:
>
> On Tue, 21 Feb 2023 12:38:38 +0100 Michael Niedermayer 
>  wrote:
> > On Fri, Feb 10, 2023 at 06:47:03PM +0100, Michael Niedermayer wrote:
> > > Hi all
> > >
> > > i plan to branch off release/6.0 from master in the next days
> > > If theres something blocking and i should wait, please reply here
> > >
> > > 6.0 release will be maybe 1 week after the branch point
> > > once it has branched all important fixes should be backported of course
> >
> > What name shall 6.0 bear ?
> >
> > ill pick what has the highest number of votes
> >
> > Here are some previously suggested names:
> > Darwin, De broglie, Desitter, Galois, Gauss, Heaviside, Jacobi, Maxwell, 
> > Mellin, Perelman, Poincaré, Ramanujan, Sagan, Viterbi, Voltaire, Von Neumann
> >
> > thx
> >
> > [...]
>
> +1 to Von Neumann
>
> But I would agree that proper vote 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".
___
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] Bump major version of swresample

2023-02-24 Thread Wang Bin



0001-Bump-major-version-of-swresample.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] FFmpeg 6.0

2023-02-24 Thread Niklas Haas
On Tue, 21 Feb 2023 12:38:38 +0100 Michael Niedermayer  
wrote:
> On Fri, Feb 10, 2023 at 06:47:03PM +0100, Michael Niedermayer wrote:
> > Hi all
> > 
> > i plan to branch off release/6.0 from master in the next days 
> > If theres something blocking and i should wait, please reply here
> > 
> > 6.0 release will be maybe 1 week after the branch point
> > once it has branched all important fixes should be backported of course
> 
> What name shall 6.0 bear ?
> 
> ill pick what has the highest number of votes
> 
> Here are some previously suggested names:
> Darwin, De broglie, Desitter, Galois, Gauss, Heaviside, Jacobi, Maxwell, 
> Mellin, Perelman, Poincaré, Ramanujan, Sagan, Viterbi, Voltaire, Von Neumann
> 
> thx
> 
> [...]

+1 to Von Neumann

But I would agree that proper vote 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".


[FFmpeg-devel] [PATCH v2 8/9] avcodec/dynamic_hdr_vivid: reindent after the previous commit

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 60 +-
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 7cb13cbf32..a9b6910798 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -92,42 +92,42 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
 tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
 }
-if (get_bits_left(gb) < 1)
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
+tm_params->three_Spline_enable_flag = get_bits(gb, 1);
+if (tm_params->three_Spline_enable_flag) {
+AVHDRVivid3SplineParams *three_spline;
+
+if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
+return AVERROR_INVALIDDATA;
+tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
 return AVERROR_INVALIDDATA;
-tm_params->three_Spline_enable_flag = get_bits(gb, 1);
-if (tm_params->three_Spline_enable_flag) {
-AVHDRVivid3SplineParams *three_spline;
-
-if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
-return AVERROR_INVALIDDATA;
-tm_params->three_Spline_num = get_bits(gb, 1) + 1;
-if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
-return AVERROR_INVALIDDATA;
-for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-three_spline = _params->three_spline[j];
-three_spline->th_mode = get_bits(gb, 2);
-if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
-if (get_bits_left(gb) < 8)
-return AVERROR_INVALIDDATA;
-three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
-}
-three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
-three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
+for (int j = 0; j < tm_params->three_Spline_num; j++) {
+three_spline = _params->three_spline[j];
+three_spline->th_mode = get_bits(gb, 2);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+if (get_bits_left(gb) < 8)
+return AVERROR_INVALIDDATA;
+three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
 }
+three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
+}
 #if FF_API_HDR_VIVID_THREE_SPLINE
-three_spline = _params->three_spline[0];
+three_spline = _params->three_spline[0];
 FF_DISABLE_DEPRECATION_WARNINGS
-tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
-tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
-tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
-tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
-tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
-tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
+tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
+tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
+  

[FFmpeg-devel] [PATCH v2 9/9] fftools/ffprobe: fix print_dynamic_hdr_vivid

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Don't print tone_mapping_param_num if tone_mapping_mode_flag is
disabled.

Signed-off-by: Zhao Zhili 
---
 fftools/ffprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 64883321be..fa3e4db6fd 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2221,8 +2221,8 @@ static void print_dynamic_hdr_vivid(WriterContext *w, 
const AVDynamicHDRVivid *m
 const AVHDRVividColorTransformParams *params = >params[n];
 
 print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag);
-print_int("tone_mapping_param_num", params->tone_mapping_param_num);
 if (params->tone_mapping_mode_flag) {
+print_int("tone_mapping_param_num", 
params->tone_mapping_param_num);
 for (int i = 0; i < params->tone_mapping_param_num; i++) {
 const AVHDRVividColorToneMappingParams *tm_params = 
>tm_params[i];
 
-- 
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".


[FFmpeg-devel] [PATCH v2 7/9] avcodec/dynamic_hdr_vivid: fix base_enable_flag control

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

The base_enable_flag is parallel to three_Spline_enable_flag. The
typesetting of the specification is very misleading.

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 30f7dfc71f..7cb13cbf32 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -91,7 +91,7 @@ int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid 
*s, const uint8_t
 tm_params->base_param_k3 = get_bits(gb, 4);
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
 tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
-
+}
 if (get_bits_left(gb) < 1)
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_enable_flag = get_bits(gb, 1);
@@ -128,7 +128,6 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
-}
 }
 }
 
-- 
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".


[FFmpeg-devel] [PATCH v2 6/9] avcodec/dynamic_hdr_vivid: fix base_param_Delta

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

It conflicts the comments. The operation based on Delta_enable_mode
can be applied by user during tone mapping.

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 9847b88e61..30f7dfc71f 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -90,10 +90,7 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 tm_params->base_param_k2 = get_bits(gb, 2);
 tm_params->base_param_k3 = get_bits(gb, 4);
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
-if (tm_params->base_param_Delta_enable_mode == 2 || 
tm_params->base_param_Delta_enable_mode == 6)
-tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7) * -1, base_param_Delta_den};
-else
-tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
+tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
 
 if (get_bits_left(gb) < 1)
 return AVERROR_INVALIDDATA;
-- 
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".


[FFmpeg-devel] [PATCH v2 5/9] libavcodec/dynamic_hdr_vivid: fix start code check

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index f2bc0c9059..9847b88e61 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -46,7 +46,8 @@ int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid 
*s, const uint8_t
 return AVERROR_INVALIDDATA;
 
 s->system_start_code = get_bits(gb, 8);
-if (s->system_start_code == 0x01) {
+// T/UWA 005.1-2022, table 11
+if (s->system_start_code >= 0x01 && s->system_start_code <= 0x07) {
 s->num_windows = 1;
 
 if (get_bits_left(gb) < 12 * 4 * s->num_windows)
-- 
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".


[FFmpeg-devel] [PATCH v2 3/9] avfilter/vf_showinfo: fix HDR vivid info

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavfilter/vf_showinfo.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index e55625b338..7cf71fe40c 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -354,19 +354,21 @@ static void dump_dynamic_hdr_vivid(AVFilterContext *ctx, 
AVFrameSideData *sd)
 av_log(ctx, AV_LOG_INFO, "3Spline_enable_flag[%d][%d]: %d, ",
w, i, tm_params->three_Spline_enable_flag);
 if (tm_params->three_Spline_enable_flag) {
-av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]:  %d, ", 
w, i, tm_params->three_Spline_TH_mode);
-
 for (int j = 0; j < tm_params->three_Spline_num; j++) {
-av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_enable_MB));
+const AVHDRVivid3SplineParams *three_spline = 
_params->three_spline[j];
+av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]:  
%d, ", w, i, three_spline->th_mode);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ",
+w, i, j, 
av_q2d(three_spline->th_enable_mb));
+}
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_enable));
+w, i, j, av_q2d(three_spline->th_enable));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta1[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_Delta1));
+w, i, j, av_q2d(three_spline->th_delta1));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta2[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_Delta2));
+w, i, j, av_q2d(three_spline->th_delta2));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_enable_Strength[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_enable_Strength));
+w, i, j, 
av_q2d(three_spline->enable_strength));
 }
 }
 }
-- 
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".


[FFmpeg-devel] [PATCH v2 2/9] avcodec/dynamic_hdr_vivid: fix three spline params

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index d689669dec..f2bc0c9059 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -98,26 +98,38 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_enable_flag = get_bits(gb, 1);
 if (tm_params->three_Spline_enable_flag) {
+AVHDRVivid3SplineParams *three_spline;
+
 if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
+return AVERROR_INVALIDDATA;
 for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-tm_params->three_Spline_TH_mode = get_bits(gb, 
2);
-if (tm_params->three_Spline_TH_mode == 0 || 
tm_params->three_Spline_TH_mode == 2) {
+three_spline = _params->three_spline[j];
+three_spline->th_mode = get_bits(gb, 2);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
 if (get_bits_left(gb) < 8)
 return AVERROR_INVALIDDATA;
-tm_params->three_Spline_TH_enable_MB = 
(AVRational){get_bits(gb, 8),  255};
+three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
 }
-tm_params->three_Spline_TH_enable = 
(AVRational){get_bits(gb, 12),  4095};
-tm_params->three_Spline_TH_Delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_TH_Delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_enable_Strength = 
(AVRational){get_bits(gb,  8),  255};
+three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
 }
-} else {
-tm_params->three_Spline_num = 1;
-tm_params->three_Spline_TH_mode = 0;
+#if FF_API_HDR_VIVID_THREE_SPLINE
+three_spline = _params->three_spline[0];
+FF_DISABLE_DEPRECATION_WARNINGS
+tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
+tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
+tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
+tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
+tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
+tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 }
-
 }
 }
 }
-- 
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".


[FFmpeg-devel] [PATCH v2 4/9] fftools/ffprobe: fix HDR vivid info

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 fftools/ffprobe.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index af927cb084..64883321be 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2246,14 +2246,17 @@ static void print_dynamic_hdr_vivid(WriterContext *w, 
const AVDynamicHDRVivid *m
 print_int("3Spline_enable_flag", 
tm_params->three_Spline_enable_flag);
 if (tm_params->three_Spline_enable_flag) {
 print_int("3Spline_num", tm_params->three_Spline_num);
-print_int("3Spline_TH_mode", 
tm_params->three_Spline_TH_mode);
 
 for (int j = 0; j < tm_params->three_Spline_num; j++) {
-print_q("3Spline_TH_enable_MB", 
tm_params->three_Spline_TH_enable_MB, '/');
-print_q("3Spline_TH_enable", 
tm_params->three_Spline_TH_enable, '/');
-print_q("3Spline_TH_Delta1", 
tm_params->three_Spline_TH_Delta1, '/');
-print_q("3Spline_TH_Delta2", 
tm_params->three_Spline_TH_Delta2, '/');
-print_q("3Spline_enable_Strength", 
tm_params->three_Spline_enable_Strength, '/');
+const AVHDRVivid3SplineParams *three_spline = 
_params->three_spline[j];
+print_int("3Spline_TH_mode", three_spline->th_mode);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+print_q("3Spline_TH_enable_MB", 
three_spline->th_enable_mb, '/');
+}
+print_q("3Spline_TH_enable", three_spline->th_enable, 
'/');
+print_q("3Spline_TH_Delta1", three_spline->th_delta1, 
'/');
+print_q("3Spline_TH_Delta2", three_spline->th_delta2, 
'/');
+print_q("3Spline_enable_Strength", 
three_spline->enable_strength, '/');
 }
 }
 }
-- 
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] libavfilter/x86/vf_convolution.asm- fix missing decelerator for AVX512ICL sobel

2023-02-24 Thread Felix LeClair
Disregard-found to be an issue in nasm 2.16RC, fixed with upstream 2.16.01

From: ffmpeg-devel  on behalf of Felix LeClair 

Sent: February 24, 2023 10:12 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] libavfilter/x86/vf_convolution.asm- fix missing 
decelerator for AVX512ICL sobel

Without patch I hit:

```
CC libavdevice/version.o
ARlibavdevice/libavdevice.a
CClibavfilter/version.o
X86ASM  libavfilter/x86/vf_convolution.o
libavfilter/x86/vf_convolution.asm:302: error: operation size not specified
libavfilter/x86/vf_convolution.asm:235: ... from macro `FILTER_SOBEL' defined 
here
libavfilter/x86/vf_convolution.asm:302: error: operation size not specified
libavfilter/x86/vf_convolution.asm:236: ... from macro `FILTER_SOBEL' defined 
here
make: *** [ffbuild/common.mak:103: libavfilter/x86/vf_convolution.o] Error 1

```
During compilation of commit ac6eec1fc258efce219e4fccb84312a1b13a7a23

With

make config
./configure --samples=fate-suite --enable-gpl --enable-ladspa --enable-libass 
--enable-libcodec2 --enable-libdav1d --enable-libfontconfig 
--enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm 
--enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg 
--enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq 
--enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr 
--enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame 
--enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx265 
--enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzvbi 
--enable-lv2 --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libx264 
--enable-opencl --enable-nonfree --enable-libsvtav1 --disable-stripping 
--cpu=sapphire-rapids --enable-pic


Kernel 6.2.0, NASM 2.16, GCC 12.1.1


From: ffmpeg-devel  on behalf of James Darnley 

Sent: February 24, 2023 8:51 AM
To: ffmpeg-devel@ffmpeg.org 
Subject: Re: [FFmpeg-devel] libavfilter/x86/vf_convolution.asm- fix missing 
decelerator for AVX512ICL sobel

On 2/24/23 04:00, Felix LeClair wrote:
> Fixes:  Compilation of Sobel with AVX512ICL
> Caused: Comment left without deleniator in AVX512ICL version of SOBEL
>
> Testing:Confirmed working on AVX512 Alderlake (AKA SPR without AMX)

> diff --git a/libavfilter/x86/vf_convolution.asm 
> b/libavfilter/x86/vf_convolution.asm
> index 9ac9ef5d73..8b85897819 100644
> --- a/libavfilter/x86/vf_convolution.asm
> +++ b/libavfilter/x86/vf_convolution.asm
> @@ -232,8 +232,8 @@ cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, 
> matrix, ptr, c0, c1, c2,
>  psubd m4, m5
>  vpermbm3, m6, m3
>  mova  m5, m4
> -vpdpbusd  m4, m2, [sobel_mulA] {1to16}
> -vpdpbusd  m5, m3, [sobel_mulB] {1to16}
> +vpdpbusd  m4, m2, [sobel_mulA]; {1to16}
> +vpdpbusd  m5, m3, [sobel_mulB]; {1to16}
>
>  cvtdq2ps  m4, m4
>  mulps m4, m4


Fix compilation with what?

I'm not familiar with the sobel algorith/function so I can't say whether
the code is correct.  However those constants are only dword sized and
that is how you do a memory broadcast with avx512(icl).  Furthermore
testing your change on an icl system results in a failure in checkasm.

So what program and what version fails to assemble that?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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] libavfilter/x86/vf_convolution.asm- fix missing decelerator for AVX512ICL sobel

2023-02-24 Thread Felix LeClair
Without patch I hit:

```
CC libavdevice/version.o
ARlibavdevice/libavdevice.a
CClibavfilter/version.o
X86ASM  libavfilter/x86/vf_convolution.o
libavfilter/x86/vf_convolution.asm:302: error: operation size not specified
libavfilter/x86/vf_convolution.asm:235: ... from macro `FILTER_SOBEL' defined 
here
libavfilter/x86/vf_convolution.asm:302: error: operation size not specified
libavfilter/x86/vf_convolution.asm:236: ... from macro `FILTER_SOBEL' defined 
here
make: *** [ffbuild/common.mak:103: libavfilter/x86/vf_convolution.o] Error 1

```
During compilation of commit ac6eec1fc258efce219e4fccb84312a1b13a7a23

With

make config
./configure --samples=fate-suite --enable-gpl --enable-ladspa --enable-libass 
--enable-libcodec2 --enable-libdav1d --enable-libfontconfig 
--enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm 
--enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg 
--enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq 
--enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr 
--enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame 
--enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx265 
--enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzvbi 
--enable-lv2 --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libx264 
--enable-opencl --enable-nonfree --enable-libsvtav1 --disable-stripping 
--cpu=sapphire-rapids --enable-pic


Kernel 6.2.0, NASM 2.16, GCC 12.1.1


From: ffmpeg-devel  on behalf of James Darnley 

Sent: February 24, 2023 8:51 AM
To: ffmpeg-devel@ffmpeg.org 
Subject: Re: [FFmpeg-devel] libavfilter/x86/vf_convolution.asm- fix missing 
decelerator for AVX512ICL sobel

On 2/24/23 04:00, Felix LeClair wrote:
> Fixes:  Compilation of Sobel with AVX512ICL
> Caused: Comment left without deleniator in AVX512ICL version of SOBEL
>
> Testing:Confirmed working on AVX512 Alderlake (AKA SPR without AMX)

> diff --git a/libavfilter/x86/vf_convolution.asm 
> b/libavfilter/x86/vf_convolution.asm
> index 9ac9ef5d73..8b85897819 100644
> --- a/libavfilter/x86/vf_convolution.asm
> +++ b/libavfilter/x86/vf_convolution.asm
> @@ -232,8 +232,8 @@ cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, 
> matrix, ptr, c0, c1, c2,
>  psubd m4, m5
>  vpermbm3, m6, m3
>  mova  m5, m4
> -vpdpbusd  m4, m2, [sobel_mulA] {1to16}
> -vpdpbusd  m5, m3, [sobel_mulB] {1to16}
> +vpdpbusd  m4, m2, [sobel_mulA]; {1to16}
> +vpdpbusd  m5, m3, [sobel_mulB]; {1to16}
>
>  cvtdq2ps  m4, m4
>  mulps m4, m4


Fix compilation with what?

I'm not familiar with the sobel algorith/function so I can't say whether
the code is correct.  However those constants are only dword sized and
that is how you do a memory broadcast with avx512(icl).  Furthermore
testing your change on an icl system results in a failure in checkasm.

So what program and what version fails to assemble that?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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 broken build on Android due to broken asm-generic/termbits.h include

2023-02-24 Thread copypaste
  Here's my attempt to do just that. :-)  

 
Compiled fine with:
 

 
configuration: --prefix=/data/data/com.termux/files/usr/local 
--enable-indev=alsa --enable-indev=xcbgrab --enable-libfreetype 
--enable-libfontconfig --cc=clang --cxx=clang++ --disable-libxcb-shm 
--enable-vulkan --enable-opencl --enable-opengl --enable-libass 
--enable-libopus --enable-libfribidi --enable-librsvg --disable-stripping 
--enable-logging --enable-debug --logfile=/dev/tty --enable-nonfree 
--enable-jni --enable-gpl --enable-version3 --host-os=android 
--target-os=android --enable-mediacodec
 From 44d7cfe5d10b367b289549d90fabb3b985acb128 Mon Sep 17 00:00:00 2001
From: Fredrick Brennan 
Date: Fri, 24 Feb 2023 09:51:16 -0500
Subject: [PATCH] Prevent collisions between Android's asm-generic/termbits.h
 and ffmpeg

---
 libavcodec/aaccoder.c |  5 +
 libavcodec/faandct.c  | 15 +++
 libavcodec/hevcdec.h  |  9 +
 libavcodec/opus_pvq.h |  4 
 4 files changed, 33 insertions(+)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 6291c16123..de51fa80fb 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -52,6 +52,11 @@
 
 #include "libavcodec/aaccoder_twoloop.h"
 
+#ifdef __ANDROID__
+#undef B0
+#undef B1
+#endif
+
 /* Parameter of f(x) = a*(lambda/100), defines the maximum fourier spread
  * beyond which no PNS is used (since the SFBs contain tone rather than noise) */
 #define NOISE_SPREAD_THRESHOLD 0.9f
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index 38c392bbae..923fa9beda 100644
--- a/libavcodec/faandct.c
+++ b/libavcodec/faandct.c
@@ -37,6 +37,21 @@ for this approach). Unfortunately, long double is not always available correctly
 e.g ppc has issues.
 TODO: add L suffixes when ppc and toolchains sort out their stuff.
 */
+#ifdef __ANDROID__
+#undef B0
+#undef B1
+#undef B2
+#undef B3
+#undef B4
+#undef B5
+#undef B6
+#undef B7
+#undef A1
+#undef A2
+#undef A3
+#undef A4
+#undef A5
+#endif
 #define B0 1.
 #define B1 0.720959822006947913789091890943021267 // (cos(pi*1/16)sqrt(2))^-1
 #define B2 0.765366864730179543456919968060797734 // (cos(pi*2/16)sqrt(2))^-1
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 9d3f4adbb3..4b500350c0 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -57,6 +57,15 @@
 #define L0 0
 #define L1 1
 
+#ifdef __ANDROID__
+#undef A0
+#undef A1
+#undef A2
+#undef B0
+#undef B1
+#undef B2
+#endif
+
 #define EPEL_EXTRA_BEFORE 1
 #define EPEL_EXTRA_AFTER  2
 #define EPEL_EXTRA3
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index b71bc49034..91c59f2812 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -27,6 +27,10 @@
 
 #include "opus_celt.h"
 
+#ifdef __ANDROID__
+#undef B0
+#endif
+
 #define QUANT_FN(name) uint32_t (name)(struct CeltPVQ *pvq, CeltFrame *f,\
OpusRangeCoder *rc, const int band, float *X, \
float *Y, int N, int b, uint32_t blocks,  \
-- 
2.39.2

___
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] libavfilter/x86/vf_convolution.asm- fix missing decelerator for AVX512ICL sobel

2023-02-24 Thread James Darnley

On 2/24/23 04:00, Felix LeClair wrote:

Fixes:  Compilation of Sobel with AVX512ICL
Caused: Comment left without deleniator in AVX512ICL version of SOBEL

Testing:Confirmed working on AVX512 Alderlake (AKA SPR without AMX)



diff --git a/libavfilter/x86/vf_convolution.asm 
b/libavfilter/x86/vf_convolution.asm
index 9ac9ef5d73..8b85897819 100644
--- a/libavfilter/x86/vf_convolution.asm
+++ b/libavfilter/x86/vf_convolution.asm
@@ -232,8 +232,8 @@ cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, 
matrix, ptr, c0, c1, c2,
 psubd m4, m5
 vpermbm3, m6, m3
 mova  m5, m4
-vpdpbusd  m4, m2, [sobel_mulA] {1to16}
-vpdpbusd  m5, m3, [sobel_mulB] {1to16}
+vpdpbusd  m4, m2, [sobel_mulA]; {1to16}
+vpdpbusd  m5, m3, [sobel_mulB]; {1to16}
 
 cvtdq2ps  m4, m4

 mulps m4, m4



Fix compilation with what?

I'm not familiar with the sobel algorith/function so I can't say whether 
the code is correct.  However those constants are only dword sized and 
that is how you do a memory broadcast with avx512(icl).  Furthermore 
testing your change on an icl system results in a failure in checkasm.


So what program and what version fails to assemble that?

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

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


Re: [FFmpeg-devel] [PATCH 4/6] avformat/mov: parse ISO-14496-12 ChannelLayout

2023-02-24 Thread Jan Ekström
On Fri, Feb 24, 2023 at 6:25 AM Zhao Zhili  wrote:
>
> From: Zhao Zhili 
>
> Signed-off-by: Zhao Zhili 

Hah, I actually happened to recently start coding uncompressed audio
support in mp4 myself, but what this commit is handling is what
basically killed my version off since the channel layout box is
required.

If you're interested you can check my take over at
https://github.com/jeeb/ffmpeg/commits/pcmc_parsing_improvements .

Will comment on some things.

> ---
>  libavformat/mov.c  |  79 +++-
>  libavformat/mov_chan.c | 265 +
>  libavformat/mov_chan.h |  26 
>  3 files changed, 369 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index b125343f84..1db869aa2e 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -940,6 +940,82 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, 
> MOVAtom atom)
>  return 0;
>  }
>
> +static int mov_read_chnl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +int64_t end = av_sat_add64(avio_tell(pb), atom.size);
> +int stream_structure;
> +int ret = 0;
> +AVStream *st;
> +
> +if (c->fc->nb_streams < 1)
> +return 0;
> +st = c->fc->streams[c->fc->nb_streams-1];
> +
> +/* skip version and flags */
> +avio_skip(pb, 4);

We should really not do this any more. Various FullBoxes have multiple
versions or depend on the flags. See how I have added FullBox things
recently, although I would prefer us to have a generic macro/function
setup for this where you then get the version and flags as arguments
or whatever in the future.

For this specific box, there are now versions 0 and 1 defined since
circa 2018-2019 or so (visible at least in 14496-12 2022)

Since ISO/IEC has changed the rules for free specifications (against
the wishes of various spec authors) and all that jazz, this is how
it's defined in what I have on hand:

12.2.4  Channel layout

12.2.4.1  Definition

Box Types:  'chnl'
Container: Audio sample entry
Mandatory: No
Quantity: Zero or one

This box may appear in an audio sample entry to document the
assignment of channels in the audio
stream. It is recommended to use this box to convey the base channel
count for the DownMixInstructions
box and other DRC-related boxes specified in ISO/IEC 23003-4.
The channel layout can be all or part of a standard layout (from an
enumerated list), or a custom layout
(which also allows a track to contribute part of an overall layout).
A stream may contain channels, objects, neither, or both. A stream
that is neither channel nor object
structured can implicitly be rendered in a variety of ways.

12.2.4.2  Syntax

aligned(8) class ChannelLayout extends FullBox('chnl', version, flags=0) {
   if (version==0) {
  unsigned int(8) stream_structure;
  if (stream_structure & channelStructured) {
 unsigned int(8) definedLayout;
  if (definedLayout==0) {
for (i = 1 ; i <= layout_channel_count ; i++) {
   //  layout_channel_count comes from the sample entry
   unsigned int(8) speaker_position;
   if (speaker_position == 126) {   // explicit position
  signed int (16) azimuth;
  signed int (8)  elevation;
   }
}
 } else {
unsigned int(64)   omittedChannelsMap;
  // a ‘1’ bit indicates ‘not in this track’
 }
  }
  if (stream_structure & objectStructured) {
 unsigned int(8) object_count;
  }
   } else {
  unsigned int(4) stream_structure;
  unsigned int(4) format_ordering;
  unsigned int(8) baseChannelCount;
  if (stream_structure & channelStructured) {
 unsigned int(8) definedLayout;
 if (definedLayout==0) {
unsigned int(8) layout_channel_count;
for (i = 1 ; i <= layout_channel_count ; i++) {
   unsigned int(8) speaker_position;
   if (speaker_position == 126) {   // explicit position
  signed int (16) azimuth;
  signed int (8)  elevation;
   }
}
 } else {
int(4) reserved = 0;
unsigned int(3) channel_order_definition;
unsigned int(1) omitted_channels_present;
if (omitted_channels_present == 1) {
   unsigned int(64)   omittedChannelsMap;
 // a ‘1’ bit indicates ‘not in this track’
}
 }
  }
  if (stream_structure & objectStructured) {
 // object_count is derived from baseChannelCount
  }
   }
}

12.2.4.3  Semantics

version is an integer that specifies the version of this box (0 or 1).
When authoring, version 1 should be
preferred over version 0. Version 1 conveys the channel
ordering, which is not always the case for
version 0. Version 1 should be used to convey the base channel
count for DRC.

stream_structure is a field 

Re: [FFmpeg-devel] How to use threads inside custom encoder

2023-02-24 Thread Ronald S. Bultje
Hi,

On Thu, Feb 23, 2023 at 1:28 PM Alex <3.1...@ukr.net> wrote:

> Hi!
> I write custom encoder codec and want to use threads to speed up encoding
> process. I know what ffmpeg have frame level threads and slices threads,
> but in my case best option is to use frame level threads
> with FF_CODEC_ENCODE_CB() function.
> But I have couple of questions:
>
> 1) Then I add AV_CODEC_CAP_FRAME_THREADS flag to capabilities of my
> encoder then ffmpeg call init function of my encoder for each spawned
> threads (for example 9 times because I have 8 core cpu ). How to prevent
> this and call init function only once? (I need to reuse encoder context.)
>

In frame threading, each "frame instance" has its own context. They can be
synchronized and use dependent data. See how other codecs do this, e.g.
h264 decoder (the concept is identical between encoder & decoder). You can,
for example, use avcodec->internal->is_copy for this. See
update_thread_context() for synchronization between threads.

If this design doesn't work for you, you don't have to use the frame-level
API. Just mark them as slice threads and everything can be managed inside
your codec without the frame-threading API "overhead".

2) Is it possible to request more decoded frames inside encode callback
> function?
>

Encoders can simply buffer frames and output only when ready (this is why
send/receive are separate API), see AV_CODEC_CAP_DELAY.

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

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


Re: [FFmpeg-devel] [PATCH 2/9] avcodec/dynamic_hdr_vivid: fix three spline params

2023-02-24 Thread James Almer

On 2/24/2023 6:08 PM, Zhao Zhili wrote:

From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
  libavcodec/dynamic_hdr_vivid.c | 34 +++---
  1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index d689669dec..35be6f5e2b 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -98,26 +98,38 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
  return AVERROR_INVALIDDATA;
  tm_params->three_Spline_enable_flag = get_bits(gb, 1);
  if (tm_params->three_Spline_enable_flag) {
+AVHDRVivid3SplineParams *three_spline;
+
  if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
  return AVERROR_INVALIDDATA;
  tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
+return AVERROR_INVALIDDATA;
  for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-tm_params->three_Spline_TH_mode = get_bits(gb, 
2);
-if (tm_params->three_Spline_TH_mode == 0 || 
tm_params->three_Spline_TH_mode == 2) {
+three_spline = tm_params->three_spline + j;


Preferably do:

three_spline = _params->three_spline[j];


+three_spline->th_mode = get_bits(gb, 2);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
  if (get_bits_left(gb) < 8)
  return AVERROR_INVALIDDATA;
-tm_params->three_Spline_TH_enable_MB = 
(AVRational){get_bits(gb, 8),  255};
+three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
  }
-tm_params->three_Spline_TH_enable = 
(AVRational){get_bits(gb, 12),  4095};
-tm_params->three_Spline_TH_Delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_TH_Delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_enable_Strength = 
(AVRational){get_bits(gb,  8),  255};
+three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
  }
-} else {
-tm_params->three_Spline_num = 1;
-tm_params->three_Spline_TH_mode = 0;
+#if FF_API_HDR_VIVID_THREE_SPLINE
+three_spline = tm_params->three_spline;


Also here:

three_spline = _params->three_spline[0];

Same in every other case in this patchset.


+AV_NOWARN_DEPRECATED(


This is an internal file, so use the FF_DISABLE_DEPRECATION_WARNINGS and 
FF_ENABLE_DEPRECATION_WARNINGS wrappers instead of the public one.



+tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
+tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
+tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
+tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
+tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
+tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
+)
+#endif
  }
-
  }
  }
  }

___
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 9/9] fftools/ffprobe: fix print_dynamic_hdr_vivid

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Don't print tone_mapping_param_num if tone_mapping_mode_flag is
disabled.

Signed-off-by: Zhao Zhili 
---
 fftools/ffprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 1d051a5545..df463a0ed3 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2221,8 +2221,8 @@ static void print_dynamic_hdr_vivid(WriterContext *w, 
const AVDynamicHDRVivid *m
 const AVHDRVividColorTransformParams *params = >params[n];
 
 print_int("tone_mapping_mode_flag", params->tone_mapping_mode_flag);
-print_int("tone_mapping_param_num", params->tone_mapping_param_num);
 if (params->tone_mapping_mode_flag) {
+print_int("tone_mapping_param_num", 
params->tone_mapping_param_num);
 for (int i = 0; i < params->tone_mapping_param_num; i++) {
 const AVHDRVividColorToneMappingParams *tm_params = 
>tm_params[i];
 
-- 
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 2/9] avcodec/dynamic_hdr_vivid: fix three spline params

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index d689669dec..35be6f5e2b 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -98,26 +98,38 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_enable_flag = get_bits(gb, 1);
 if (tm_params->three_Spline_enable_flag) {
+AVHDRVivid3SplineParams *three_spline;
+
 if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
+return AVERROR_INVALIDDATA;
 for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-tm_params->three_Spline_TH_mode = get_bits(gb, 
2);
-if (tm_params->three_Spline_TH_mode == 0 || 
tm_params->three_Spline_TH_mode == 2) {
+three_spline = tm_params->three_spline + j;
+three_spline->th_mode = get_bits(gb, 2);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
 if (get_bits_left(gb) < 8)
 return AVERROR_INVALIDDATA;
-tm_params->three_Spline_TH_enable_MB = 
(AVRational){get_bits(gb, 8),  255};
+three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
 }
-tm_params->three_Spline_TH_enable = 
(AVRational){get_bits(gb, 12),  4095};
-tm_params->three_Spline_TH_Delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_TH_Delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-tm_params->three_Spline_enable_Strength = 
(AVRational){get_bits(gb,  8),  255};
+three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
 }
-} else {
-tm_params->three_Spline_num = 1;
-tm_params->three_Spline_TH_mode = 0;
+#if FF_API_HDR_VIVID_THREE_SPLINE
+three_spline = tm_params->three_spline;
+AV_NOWARN_DEPRECATED(
+tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
+tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
+tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
+tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
+tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
+tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
+)
+#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] libavfilter/x86/vf_convolution.asm- fix missing decelerator for AVX512ICL sobel

2023-02-24 Thread Kieran Kunhya
On Fri, 24 Feb 2023 at 03:00, Felix LeClair 
wrote:

> Fixes:  Compilation of Sobel with AVX512ICL
> Caused: Comment left without deleniator in AVX512ICL version of SOBEL
>
> Testing:Confirmed working on AVX512 Alderlake (AKA SPR without AMX)
>

Seems fine, bit weird that FATE didn't pick it up.

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

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


[FFmpeg-devel] [PATCH 7/9] avcodec/dynamic_hdr_vivid: fix base_enable_flag control

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

The base_enable_flag is parallel to three_Spline_enable_flag. The
typesetting of the specification is very misleading.

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index f0580c498a..8fa69d87b5 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -91,7 +91,7 @@ int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid 
*s, const uint8_t
 tm_params->base_param_k3 = get_bits(gb, 4);
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
 tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
-
+}
 if (get_bits_left(gb) < 1)
 return AVERROR_INVALIDDATA;
 tm_params->three_Spline_enable_flag = get_bits(gb, 1);
@@ -128,7 +128,6 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 )
 #endif
 }
-}
 }
 }
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 8/9] avcodec/dynamic_hdr_vivid: reindent after the previous commit

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 64 +-
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 8fa69d87b5..8b5105ea12 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -92,42 +92,42 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
 tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
 }
-if (get_bits_left(gb) < 1)
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
+tm_params->three_Spline_enable_flag = get_bits(gb, 1);
+if (tm_params->three_Spline_enable_flag) {
+AVHDRVivid3SplineParams *three_spline;
+
+if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
+return AVERROR_INVALIDDATA;
+tm_params->three_Spline_num = get_bits(gb, 1) + 1;
+if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
 return AVERROR_INVALIDDATA;
-tm_params->three_Spline_enable_flag = get_bits(gb, 1);
-if (tm_params->three_Spline_enable_flag) {
-AVHDRVivid3SplineParams *three_spline;
-
-if (get_bits_left(gb) < 1 + 
tm_params->three_Spline_num * (2 + 12 + 28 + 1))
-return AVERROR_INVALIDDATA;
-tm_params->three_Spline_num = get_bits(gb, 1) + 1;
-if (tm_params->three_Spline_num > 
FF_ARRAY_ELEMS(tm_params->three_spline))
-return AVERROR_INVALIDDATA;
-for (int j = 0; j < tm_params->three_Spline_num; 
j++) {
-three_spline = tm_params->three_spline + j;
-three_spline->th_mode = get_bits(gb, 2);
-if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
-if (get_bits_left(gb) < 8)
-return AVERROR_INVALIDDATA;
-three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
-}
-three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
-three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
-three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
-three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
+for (int j = 0; j < tm_params->three_Spline_num; j++) {
+three_spline = tm_params->three_spline + j;
+three_spline->th_mode = get_bits(gb, 2);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+if (get_bits_left(gb) < 8)
+return AVERROR_INVALIDDATA;
+three_spline->th_enable_mb = 
(AVRational){get_bits(gb, 8),  255};
 }
+three_spline->th_enable = 
(AVRational){get_bits(gb, 12),  4095};
+three_spline->th_delta1 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->th_delta2 = 
(AVRational){get_bits(gb, 10),  1023};
+three_spline->enable_strength = 
(AVRational){get_bits(gb,  8),  255};
+}
 #if FF_API_HDR_VIVID_THREE_SPLINE
-three_spline = tm_params->three_spline;
-AV_NOWARN_DEPRECATED(
-tm_params->three_Spline_TH_mode = 
three_spline->th_mode;
-tm_params->three_Spline_TH_enable_MB = 
three_spline->th_enable_mb;
-tm_params->three_Spline_TH_enable = 
three_spline->th_enable;
-tm_params->three_Spline_TH_Delta1 = 
three_spline->th_delta1;
-tm_params->three_Spline_TH_Delta2 = 
three_spline->th_delta2;
-tm_params->three_Spline_enable_Strength = 
three_spline->enable_strength;
-)
+three_spline = tm_params->three_spline;
+AV_NOWARN_DEPRECATED(
+tm_params->three_Spline_TH_mode = 
three_spline->th_mode;

[FFmpeg-devel] [PATCH 6/9] avcodec/dynamic_hdr_vivid: fix base_param_Delta

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

It conflicts the comments. The operation based on Delta_enable_mode
can be applied by user during tone mapping.

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 091963146e..f0580c498a 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -90,10 +90,7 @@ int 
ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t
 tm_params->base_param_k2 = get_bits(gb, 2);
 tm_params->base_param_k3 = get_bits(gb, 4);
 tm_params->base_param_Delta_enable_mode = get_bits(gb, 
3);
-if (tm_params->base_param_Delta_enable_mode == 2 || 
tm_params->base_param_Delta_enable_mode == 6)
-tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7) * -1, base_param_Delta_den};
-else
-tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
+tm_params->base_param_Delta = 
(AVRational){get_bits(gb, 7), base_param_Delta_den};
 
 if (get_bits_left(gb) < 1)
 return AVERROR_INVALIDDATA;
-- 
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 5/9] libavcodec/dynamic_hdr_vivid: fix start code check

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavcodec/dynamic_hdr_vivid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dynamic_hdr_vivid.c b/libavcodec/dynamic_hdr_vivid.c
index 35be6f5e2b..091963146e 100644
--- a/libavcodec/dynamic_hdr_vivid.c
+++ b/libavcodec/dynamic_hdr_vivid.c
@@ -46,7 +46,8 @@ int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid 
*s, const uint8_t
 return AVERROR_INVALIDDATA;
 
 s->system_start_code = get_bits(gb, 8);
-if (s->system_start_code == 0x01) {
+// T/UWA 005.1-2022, table 11
+if (s->system_start_code >= 0x01 && s->system_start_code <= 0x07) {
 s->num_windows = 1;
 
 if (get_bits_left(gb) < 12 * 4 * s->num_windows)
-- 
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/9] libavutil/hdr_dynamic_vivid_metadata: fix three spline params

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

There are two group of three_Spline params.

Signed-off-by: Zhao Zhili 
---
 doc/APIchanges |  4 ++
 libavutil/hdr_dynamic_vivid_metadata.h | 63 +-
 libavutil/version.h|  3 +-
 3 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0ba18e8609..4739ef47e9 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-02-24 - xx - lavu 58.4.100 - hdr_dynamic_vivid_metadata.h
+  Add two group of three spline params.
+  Deprecate previous define which only supports one group of params.
+
  8< - FFmpeg 6.0 was cut here  8< -
 
 2023-02-16 - 927042b409 - lavf 60.2.100 - avformat.h
diff --git a/libavutil/hdr_dynamic_vivid_metadata.h 
b/libavutil/hdr_dynamic_vivid_metadata.h
index a34f83072c..4524a81557 100644
--- a/libavutil/hdr_dynamic_vivid_metadata.h
+++ b/libavutil/hdr_dynamic_vivid_metadata.h
@@ -24,6 +24,52 @@
 #include "frame.h"
 #include "rational.h"
 
+/**
+ * HDR Vivid three spline params.
+ */
+typedef struct AVHDRVivid3SplineParams {
+/**
+ * The mode of three Spline. the value shall be in the range
+ * of 0 to 3, inclusive.
+ */
+int th_mode;
+
+/**
+ * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
+ * and in multiples of 1.0/255.
+ *
+ */
+AVRational th_enable_mb;
+
+/**
+ * 3Spline_TH_enable of three Spline.
+ * The value shall be in the range of 0.0 to 1.0, inclusive.
+ * and in multiples of 1.0/4095.
+ */
+AVRational th_enable;
+
+/**
+ * 3Spline_TH_Delta1 of three Spline.
+ * The value shall be in the range of 0.0 to 0.25, inclusive,
+ * and in multiples of 0.25/1023.
+ */
+AVRational th_delta1;
+
+/**
+ * 3Spline_TH_Delta2 of three Spline.
+ * The value shall be in the range of 0.0 to 0.25, inclusive,
+ * and in multiples of 0.25/1023.
+ */
+AVRational th_delta2;
+
+/**
+ * 3Spline_enable_Strength of three Spline.
+ * The value shall be in the range of 0.0 to 1.0, inclusive,
+ * and in multiples of 1.0/255.
+ */
+AVRational enable_strength;
+} AVHDRVivid3SplineParams;
+
 /**
  * Color tone mapping parameters at a processing window in a dynamic metadata 
for
  * CUVA 005.1:2021.
@@ -122,46 +168,61 @@ typedef struct AVHDRVividColorToneMappingParams {
  */
 int three_Spline_num;
 
+#if FF_API_HDR_VIVID_THREE_SPLINE
 /**
  * The mode of three Spline. the value shall be in the range
  * of 0 to 3, inclusive.
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 int three_Spline_TH_mode;
 
 /**
  * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
  * and in multiples of 1.0/255.
- *
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 AVRational three_Spline_TH_enable_MB;
 
 /**
  * 3Spline_TH_enable of three Spline.
  * The value shall be in the range of 0.0 to 1.0, inclusive.
  * and in multiples of 1.0/4095.
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 AVRational three_Spline_TH_enable;
 
 /**
  * 3Spline_TH_Delta1 of three Spline.
  * The value shall be in the range of 0.0 to 0.25, inclusive,
  * and in multiples of 0.25/1023.
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 AVRational three_Spline_TH_Delta1;
 
 /**
  * 3Spline_TH_Delta2 of three Spline.
  * The value shall be in the range of 0.0 to 0.25, inclusive,
  * and in multiples of 0.25/1023.
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 AVRational three_Spline_TH_Delta2;
 
 /**
  * 3Spline_enable_Strength of three Spline.
  * The value shall be in the range of 0.0 to 1.0, inclusive,
  * and in multiples of 1.0/255.
+ * @deprecated Use three_spline instead
  */
+attribute_deprecated
 AVRational three_Spline_enable_Strength;
+#endif
+
+AVHDRVivid3SplineParams three_spline[2];
 } AVHDRVividColorToneMappingParams;
 
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 900b798971..a89a0d406f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  58
-#define LIBAVUTIL_VERSION_MINOR   3
+#define LIBAVUTIL_VERSION_MINOR   4
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -113,6 +113,7 @@
 #define FF_API_PKT_DURATION (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_REORDERED_OPAQUE (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_FRAME_PICTURE_NUMBER (LIBAVUTIL_VERSION_MAJOR < 59)
+#define FF_API_HDR_VIVID_THREE_SPLINE   

[FFmpeg-devel] [PATCH 3/9] avfilter/vf_showinfo: fix HDR vivid info

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

---
 libavfilter/vf_showinfo.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index e55625b338..74d57e75e7 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -354,19 +354,21 @@ static void dump_dynamic_hdr_vivid(AVFilterContext *ctx, 
AVFrameSideData *sd)
 av_log(ctx, AV_LOG_INFO, "3Spline_enable_flag[%d][%d]: %d, ",
w, i, tm_params->three_Spline_enable_flag);
 if (tm_params->three_Spline_enable_flag) {
-av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]:  %d, ", 
w, i, tm_params->three_Spline_TH_mode);
-
 for (int j = 0; j < tm_params->three_Spline_num; j++) {
-av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_enable_MB));
+const AVHDRVivid3SplineParams *three_spline = 
tm_params->three_spline + j;
+av_log(ctx, AV_LOG_INFO, "3Spline_TH_mode[%d][%d]:  
%d, ", w, i, three_spline->th_mode);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable_MB[%d][%d][%d]: %.4f, ",
+w, i, j, 
av_q2d(three_spline->th_enable_mb));
+}
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_enable[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_enable));
+w, i, j, av_q2d(three_spline->th_enable));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta1[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_Delta1));
+w, i, j, av_q2d(three_spline->th_delta1));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_TH_Delta2[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_TH_Delta2));
+w, i, j, av_q2d(three_spline->th_delta2));
 av_log(ctx, AV_LOG_INFO, 
"3Spline_enable_Strength[%d][%d][%d]: %.4f, ",
-w, i, j, 
av_q2d(tm_params->three_Spline_enable_Strength));
+w, i, j, 
av_q2d(three_spline->enable_strength));
 }
 }
 }
-- 
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 4/9] fftools/ffprobe: fix HDR vivid info

2023-02-24 Thread Zhao Zhili
From: Zhao Zhili 

---
 fftools/ffprobe.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index af927cb084..1d051a5545 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2246,14 +2246,17 @@ static void print_dynamic_hdr_vivid(WriterContext *w, 
const AVDynamicHDRVivid *m
 print_int("3Spline_enable_flag", 
tm_params->three_Spline_enable_flag);
 if (tm_params->three_Spline_enable_flag) {
 print_int("3Spline_num", tm_params->three_Spline_num);
-print_int("3Spline_TH_mode", 
tm_params->three_Spline_TH_mode);
 
 for (int j = 0; j < tm_params->three_Spline_num; j++) {
-print_q("3Spline_TH_enable_MB", 
tm_params->three_Spline_TH_enable_MB, '/');
-print_q("3Spline_TH_enable", 
tm_params->three_Spline_TH_enable, '/');
-print_q("3Spline_TH_Delta1", 
tm_params->three_Spline_TH_Delta1, '/');
-print_q("3Spline_TH_Delta2", 
tm_params->three_Spline_TH_Delta2, '/');
-print_q("3Spline_enable_Strength", 
tm_params->three_Spline_enable_Strength, '/');
+const AVHDRVivid3SplineParams *three_spline = 
tm_params->three_spline + j;
+print_int("3Spline_TH_mode", three_spline->th_mode);
+if (three_spline->th_mode == 0 || 
three_spline->th_mode == 2) {
+print_q("3Spline_TH_enable_MB", 
three_spline->th_enable_mb, '/');
+}
+print_q("3Spline_TH_enable", three_spline->th_enable, 
'/');
+print_q("3Spline_TH_Delta1", three_spline->th_delta1, 
'/');
+print_q("3Spline_TH_Delta2", three_spline->th_delta2, 
'/');
+print_q("3Spline_enable_Strength", 
three_spline->enable_strength, '/');
 }
 }
 }
-- 
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] libavcodec/hevc: reuse scale_store on idct32x32_neon

2023-02-24 Thread xufuji456
---
 libavcodec/arm/hevcdsp_idct_neon.S | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/libavcodec/arm/hevcdsp_idct_neon.S 
b/libavcodec/arm/hevcdsp_idct_neon.S
index 75795e6a6a..41ca3b83a8 100644
--- a/libavcodec/arm/hevcdsp_idct_neon.S
+++ b/libavcodec/arm/hevcdsp_idct_neon.S
@@ -876,28 +876,14 @@ function func_tr_32x4_\name
 movrel  r9, trans + 32
 vld1.s16{q0}, [r9, :128]!
 vld1.s16{q1}, [r9, :128]
-
-bl  tr_block1
-
 add r4, sp, #2048
-vld1.s16{q14-q15}, [r4, :128]!
-butterfly32 q14, q10, q15, q11
-scale32 d22, d23, d20, d21, q1, q14, q10, q15, \shift
-
-vld1.s16{q14-q15}, [r4, :128]!
-butterfly32 q14, q12, q15, q13
-scale32 d2, d3, d28, d29, q1, q14, q12, q15, \shift
 
-transpose8_4x4  d22, d20, d2, d28
-transpose8_4x4  d29, d3, d21, d23
+bl  tr_block1
 mov r1, r11
 mov r2, #64
 mov r8, #-64
 add r3, r11, #(56 + 3 * 64)
-store16 d22, d23, d20, d21, d2, d3, d28, d29, r8
-
-@ reload multiplication coefficiens to q1
-vld1.s16{q1}, [r9, :128]
+scale_store \shift
 
 bl  tr_block2
 add r1, r11, #8
-- 
2.32.0 (Apple Git-132)

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

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


Re: [FFmpeg-devel] [PATCH 5/6] avformat/movenc: write ChannelLayout box for PCM

2023-02-24 Thread Tomas Härdin
fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> +static int mov_write_chnl_tag(AVFormatContext *s, AVIOContext *pb,
> MOVTrack *track)
> +{
> +    int64_t pos = avio_tell(pb);
> +    int layout = 0;
> +    int ret;
> +    uint8_t speaker_pos[64] = { };

Magic 64 here too

The rest looks OK

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH 4/6] avformat/mov: parse ISO-14496-12 ChannelLayout

2023-02-24 Thread Tomas Härdin
fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> +    if (!layout) {
> +    uint8_t positions[64] = {};

Is there a maximum number of channels defined somewhere? stsd supports
up to 65535.

> +    // stream carries objects
> +    if (stream_structure & 2) {
> +    int obj_count = avio_r8(pb);
> +    av_log(c->fc, AV_LOG_TRACE, "'chnl' with object_count %d\n",
> obj_count);
> +    }
> +
> +    avio_seek(pb, end, SEEK_SET);

I feel we should complain loudly if there's bytes not accounted for, at
least when (stream_structure & 2) == 0

The rest I can't say much about

/Tomas

___
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/6] avformat/isom_tags: remove ipcm from movaudio_tags

2023-02-24 Thread Tomas Härdin
fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> From: Zhao Zhili 
> 
> ipcm is defined by ISO/IEC 23003-5, not defined by quicktime. After
> adding ISO/IEC 23003-5 support, we don't need it for ticket #9219.
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavformat/isom_tags.c | 2 --
>  1 file changed, 2 deletions(-)

Looks correct

/Tomas

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

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


Re: [FFmpeg-devel] [PATCH 2/6] avformat/mov: fix ISO/IEC 23003-5 support

2023-02-24 Thread Tomas Härdin
fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> From: Zhao Zhili 
> 
> Missing floating-point formats support.
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavformat/mov.c | 32 
>  1 file changed, 32 insertions(+)

Looks OK

/Tomas

___
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/6] avformat/movenc: add PCM in mp4 support

2023-02-24 Thread Tomas Härdin
fre 2023-02-24 klockan 20:25 +0800 skrev Zhao Zhili:
> +static int is_mp4_pcm_codec(enum AVCodecID codec)
> +{
> +    static const enum AVCodecID codec_list[] = {
> +    AV_CODEC_ID_PCM_S16BE,
> +    AV_CODEC_ID_PCM_S16LE,
> +    AV_CODEC_ID_PCM_S24BE,
> +    AV_CODEC_ID_PCM_S24LE,
> +    AV_CODEC_ID_PCM_S32BE,
> +    AV_CODEC_ID_PCM_S32LE,
> +
> +    AV_CODEC_ID_PCM_F32BE,
> +    AV_CODEC_ID_PCM_F32LE,
> +    AV_CODEC_ID_PCM_F64BE,
> +    AV_CODEC_ID_PCM_F64LE,
> +    };
> +
> +    for (int i = 0; i < FF_ARRAY_ELEMS(codec_list); i++) {
> +    if (codec == codec_list[i])
> +    return 1;
> +    }

A switch() with multiple case statements in a row would be more
concise.

The rest looks OK

/Tomas

___
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/4] lavc/mediacodecenc: List supported pixel formats on configuration error

2023-02-24 Thread Tomas Härdin
This makes the situation a bit better for users, even if we can't
reliably probe pixel formats in init_static_data. I decided to keep
this patchset separate from that probing, since printing pixel formats
this way should be reliable.

/Tomas
From eed0ed202bf8c496ab945b32e2e7fc7cad062c30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 10 Jan 2023 20:38:56 +0100
Subject: [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on
 configuration error

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodecenc.c | 46 ++
 1 file changed, 46 insertions(+)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 03c80cbf99..1b8a2837c4 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -97,6 +97,12 @@ static const enum AVPixelFormat avc_pix_fmts[] = {
 AV_PIX_FMT_NONE
 };
 
+static const int in_formats[] = {
+COLOR_FormatYUV420Planar,
+COLOR_FormatYUV420SemiPlanar,
+COLOR_FormatSurface,
+};
+
 static void mediacodec_output_format(AVCodecContext *avctx)
 {
 MediaCodecEncContext *s = avctx->priv_data;
@@ -131,6 +137,45 @@ static enum AVPixelFormat color2pix_fmt(AVCodecContext *avctx, int color_format)
 av_assert0(0);
 }
 
+// list pixel formats if the user tried to use one that isn't supported on this device
+static void list_pix_fmts(AVCodecContext *avctx, const char *mime)
+{
+MediaCodecEncContext *s = avctx->priv_data;
+int out_formats[FF_ARRAY_ELEMS(in_formats)], n;
+char *name = ff_AMediaCodec_getName(s->codec);
+
+if (!name) {
+// API level likely below 28
+return;
+}
+
+if ((n = ff_AMediaCodec_color_formats_intersect(name, mime, in_formats,
+FF_ARRAY_ELEMS(in_formats),
+out_formats, avctx)) < 0) {
+goto done;
+}
+
+for (int i = 0; i < n; i++) {
+if (color2pix_fmt(avctx, out_formats[i]) == avctx->pix_fmt) {
+// user specified a pixel format that is actually supported,
+// no need to print anything
+goto done;
+}
+}
+
+AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+av_log(avctx, AV_LOG_ERROR, "pixel format %s not supported by MediaCodec %s\n", desc->name, name);
+av_log(avctx, AV_LOG_INFO, "supported formats are:");
+for (int i = 0; i < n; i++) {
+desc = av_pix_fmt_desc_get(color2pix_fmt(avctx, out_formats[i]));
+av_log(avctx, AV_LOG_INFO, " %s", desc->name);
+}
+av_log(avctx, AV_LOG_INFO, "\n");
+
+done:
+av_free(name);
+}
+
 static int mediacodec_init_bsf(AVCodecContext *avctx)
 {
 MediaCodecEncContext *s = avctx->priv_data;
@@ -308,6 +353,7 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
 if (ret) {
 av_log(avctx, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret));
+list_pix_fmts(avctx, codec_mime);
 goto bailout;
 }
 
-- 
2.30.2

___
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/4] lavc/mediacodec_wrapper: Add function for probing supported color formats

2023-02-24 Thread Tomas Härdin

From 557f23650726af7f4881d29411de02f9f8bc78f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Wed, 11 Jan 2023 22:25:39 +0100
Subject: [PATCH 3/4] lavc/mediacodec_wrapper: Add function for probing
 supported color formats

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodec_wrapper.c | 112 
 libavcodec/mediacodec_wrapper.h |  15 +
 2 files changed, 127 insertions(+)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 82eead2833..9d2560205f 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -532,6 +532,118 @@ done:
 return name;
 }
 
+int ff_AMediaCodec_color_formats_intersect(const char *codec_name, const char *mime,
+   const int *in_formats, int nin_formats,
+   int *out_formats, void *log_ctx)
+{
+int ret, found_codec = 0;
+jstring jmime = NULL;
+JNIEnv *env = NULL;
+struct JNIAMediaCodecListFields jfields = { 0 };
+struct JNIAMediaFormatFields mediaformat_jfields = { 0 };
+
+JNI_GET_ENV_OR_RETURN(env, log_ctx, -1);
+
+if ((ret = ff_jni_init_jfields(env, , jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {
+goto done;
+}
+
+if ((ret = ff_jni_init_jfields(env, _jfields, jni_amediaformat_mapping, 0, log_ctx)) < 0) {
+goto done;
+}
+
+// convert const char* to java.lang.String
+jmime = ff_jni_utf_chars_to_jstring(env, mime, log_ctx);
+if (!jmime) {
+goto done;
+}
+
+int codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done;
+}
+
+for (int i = 0; i < codec_count && !found_codec; i++) {
+jobject info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+continue;
+}
+
+char *name = NULL;
+jboolean is_copy;
+jintArray color_formats = NULL;
+jobject capabilities = NULL;
+jobject jcodec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done_with_info;
+}
+
+if (!(name = ff_jni_jstring_to_utf_chars(env, jcodec_name, log_ctx))) {
+goto done_with_info;
+}
+
+if (strcmp(name, codec_name)) {
+goto done_with_info;
+}
+
+capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, jmime);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done_with_info;
+}
+
+color_formats = (*env)->GetObjectField(env, capabilities, jfields.color_formats_id);
+if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
+goto done_with_info;
+}
+
+int color_count = (*env)->GetArrayLength(env, color_formats);
+int *elems = (*env)->GetIntArrayElements(env, color_formats, _copy);
+ret = 0;
+found_codec = 1;
+
+// out_formats = intersect(in_formats, elems)
+for (int j = 0; j < nin_formats; j++) {
+for (int k = 0; k < color_count; k++) {
+if (elems[k] == in_formats[j]) {
+out_formats[ret++] = in_formats[j];
+break;
+}
+}
+}
+
+(*env)->ReleaseIntArrayElements(env, color_formats, elems, JNI_ABORT);
+
+done_with_info:
+if (color_formats) {
+(*env)->DeleteLocalRef(env, color_formats);
+}
+
+if (capabilities) {
+(*env)->DeleteLocalRef(env, capabilities);
+}
+
+if (jcodec_name) {
+(*env)->DeleteLocalRef(env, jcodec_name);
+}
+
+if (info) {
+(*env)->DeleteLocalRef(env, info);
+}
+
+av_freep();
+}
+
+done:
+if (jmime) {
+(*env)->DeleteLocalRef(env, jmime);
+}
+
+ff_jni_reset_jfields(env, , jni_amediacodeclist_mapping, 0, log_ctx);
+ff_jni_reset_jfields(env, _jfields, jni_amediaformat_mapping, 0, log_ctx);
+
+return found_codec ? ret : -1;
+}
+
 static FFAMediaFormat *mediaformat_jni_new(void)
 {
 JNIEnv *env = NULL;
diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h
index 1b81e6db84..7ab32c4dc7 100644
--- a/libavcodec/mediacodec_wrapper.h
+++ b/libavcodec/mediacodec_wrapper.h
@@ -2,6 +2,7 @@
  * Android MediaCodec Wrapper
  *
  * Copyright (c) 2015-2016 Matthieu Bouron 
+ * Modifications by Epic Games, Inc., 2023.
  *
  * This file is part of FFmpeg.
  *
@@ -230,6 +231,20 @@ FFAMediaCodec* ff_AMediaCodec_createCodecByName(const char *name, int ndk);
 FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime_type, int 

[FFmpeg-devel] [PATCH 2/4] lavc/mediacodec_wrapper: Refactor ff_AMediaCodecList_getCodecNameByType()

2023-02-24 Thread Tomas Härdin

From 9d4defbc92e4976f7d652149a215e2c165239e42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Wed, 11 Jan 2023 21:49:30 +0100
Subject: [PATCH 2/4] lavc/mediacodec_wrapper: Refactor
 ff_AMediaCodecList_getCodecNameByType()

A lot shorter, nested variables and keeps going in case of exceptions.
Makes use of C99 declarations.

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodec_wrapper.c | 162 +---
 1 file changed, 45 insertions(+), 117 deletions(-)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 34ec2134aa..82eead2833 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -2,6 +2,7 @@
  * Android MediaCodec Wrapper
  *
  * Copyright (c) 2015-2016 Matthieu Bouron 
+ * Modifications by Epic Games, Inc., 2023.
  *
  * This file is part of FFmpeg.
  *
@@ -365,26 +366,13 @@ int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
 char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int encoder, void *log_ctx)
 {
 int ret;
-int i;
-int codec_count;
 int found_codec = 0;
 char *name = NULL;
-char *supported_type = NULL;
 
 JNIEnv *env = NULL;
 struct JNIAMediaCodecListFields jfields = { 0 };
 struct JNIAMediaFormatFields mediaformat_jfields = { 0 };
 
-jobject codec_name = NULL;
-
-jobject info = NULL;
-jobject type = NULL;
-jobjectArray types = NULL;
-
-jobject capabilities = NULL;
-jobject profile_level = NULL;
-jobjectArray profile_levels = NULL;
-
 JNI_GET_ENV_OR_RETURN(env, log_ctx, NULL);
 
 if ((ret = ff_jni_init_jfields(env, , jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {
@@ -395,29 +383,26 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e
 goto done;
 }
 
-codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id);
+int codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
 goto done;
 }
 
-for(i = 0; i < codec_count; i++) {
-int j;
-int type_count;
-int is_encoder;
-
-info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i);
+for (int i = 0; i < codec_count && !found_codec; i++) {
+jobject info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-goto done;
+continue;
 }
 
-types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id);
+jobject codec_name = NULL;
+jobjectArray types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-goto done;
+goto done_with_info;
 }
 
-is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id);
+int is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-goto done;
+goto done_with_info;
 }
 
 if (is_encoder != encoder) {
@@ -427,7 +412,7 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e
 if (jfields.is_software_only_id) {
 int is_software_only = (*env)->CallBooleanMethod(env, info, jfields.is_software_only_id);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-goto done;
+goto done_with_info;
 }
 
 if (is_software_only) {
@@ -437,17 +422,12 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e
 
 codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);
 if (ff_jni_exception_check(env, 1, log_ctx) < 0) {
-goto done;
+goto done_with_info;
 }
 
 name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx);
 if (!name) {
-goto done;
-}
-
-if (codec_name) {
-(*env)->DeleteLocalRef(env, codec_name);
-codec_name = NULL;
+goto done_with_info;
 }
 
 /* Skip software decoders */
@@ -459,141 +439,89 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e
 goto done_with_info;
 }
 
-type_count = (*env)->GetArrayLength(env, types);
-for (j = 0; j < type_count; j++) {
-int k;
-int profile_count;
-
-type = (*env)->GetObjectArrayElement(env, types, j);
+int type_count = (*env)->GetArrayLength(env, types);
+for (int j = 0; j < type_count && 

[FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt()

2023-02-24 Thread Tomas Härdin

From 7374dab21cb37dc14d2481c72d333b435e23a76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Tue, 10 Jan 2023 20:37:18 +0100
Subject: [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and
 color2pix_fmt()

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodecenc.c | 29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index a92a8dc5a9..03c80cbf99 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -2,6 +2,7 @@
  * Android MediaCodec encoders
  *
  * Copyright (c) 2022 Zhao Zhili 
+ * Modifications by Epic Games, Inc., 2023.
  *
  * This file is part of FFmpeg.
  *
@@ -110,6 +111,26 @@ static void mediacodec_output_format(AVCodecContext *avctx)
 ff_AMediaFormat_delete(out_format);
 }
 
+static int pix2color_fmt(AVCodecContext *avctx, enum AVPixelFormat pix_fmt)
+{
+for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
+if (pix_fmt == color_formats[i].pix_fmt) {
+return color_formats[i].color_format;
+}
+}
+av_assert0(0);
+}
+
+static enum AVPixelFormat color2pix_fmt(AVCodecContext *avctx, int color_format)
+{
+for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
+if (color_format == color_formats[i].color_format) {
+return color_formats[i].pix_fmt;
+}
+}
+av_assert0(0);
+}
+
 static int mediacodec_init_bsf(AVCodecContext *avctx)
 {
 MediaCodecEncContext *s = avctx->priv_data;
@@ -235,13 +256,7 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
 }
 }
 
-for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
-if (avctx->pix_fmt == color_formats[i].pix_fmt) {
-ff_AMediaFormat_setInt32(format, "color-format",
- color_formats[i].color_format);
-break;
-}
-}
+ff_AMediaFormat_setInt32(format, "color-format", pix2color_fmt(avctx, avctx->pix_fmt));
 
 if (avctx->bit_rate)
 ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
-- 
2.30.2

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