* [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-27 20:24 ` Jan Ekström
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type Zhao Zhili
` (6 subsequent siblings)
7 siblings, 2 replies; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
It's defined by ISO/IEC 23003-5.
Fixes ticket #10185
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB Zhao Zhili
` (5 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Jan Ekström
From: Jan Ekström <jeebjp@gmail.com>
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support Zhao Zhili
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support Zhao Zhili
` (4 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Jan Ekström
From: Jan Ekström <jeebjp@gmail.com>
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
` (2 preceding siblings ...)
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags Zhao Zhili
` (3 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Missing floating-point formats support.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
` (3 preceding siblings ...)
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout Zhao Zhili
` (2 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
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 <zhilizhao@tencent.com>
---
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
` (4 preceding siblings ...)
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM Zhao Zhili
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 8/8] fate/mov: add PCM in mp4 test Zhao Zhili
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
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(&positions);
+ return AVERROR_PATCHWELCOME;
+ } else {
+ positions[i] = speaker_pos;
+ }
+ }
+
+ ret = ff_mov_get_layout_from_channel_positions(positions,
+ st->codecpar->ch_layout.nb_channels,
+ &st->codecpar->ch_layout);
+ av_freep(&positions);
+ 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, &st->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 surround, right surround, LFE
+ AV_CHANNEL_LAYOUT_7POINT1_WIDE,
+
+ // 8: channel1, channel2
+ AV_CHANNEL_LAYOUT_STEREO_DOWNMIX,
+
+ // 9: left front, right front, rear centre
+ AV_CHANNEL_LAYOUT_2_1,
+
+ // 10: left front, right front, left surround, right surround
+ AV_CHANNEL_LAYOUT_2_2,
+
+ // 11: centre front, left front, right front, left surround, right surround, rear centre, LFE
+ AV_CHANNEL_LAYOUT_6POINT1,
+
+ // 12: centre front, left front, right front
+ // left surround, right surround
+ // rear surround left, rear surround right
+ // LFE
+ AV_CHANNEL_LAYOUT_7POINT1,
+
+ // 13:
+ AV_CHANNEL_LAYOUT_22POINT2,
+
+ // 14:
+ AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK,
+
+ // TODO: 15 - 20
+};
+
+/* ISO/IEC 23001-8, table 8 */
+static const enum AVChannel iso_channel_position[] = {
+ // 0: left front
+ AV_CHAN_FRONT_LEFT,
+
+ // 1: right front
+ AV_CHAN_FRONT_RIGHT,
+
+ // 2: centre front
+ AV_CHAN_FRONT_CENTER,
+
+ // 3: low frequence enhancement
+ AV_CHAN_LOW_FREQUENCY,
+
+ // 4: left surround
+ // TODO
+ AV_CHAN_NONE,
+
+ // 5: right surround
+ // TODO
+ AV_CHAN_NONE,
+
+ // 6: left front centre
+ AV_CHAN_FRONT_LEFT_OF_CENTER,
+
+ // 7: right front centre
+ AV_CHAN_FRONT_RIGHT_OF_CENTER,
+
+ // 8: rear surround left
+ AV_CHAN_BACK_LEFT,
+
+ // 9: rear surround right
+ AV_CHAN_BACK_RIGHT,
+
+ // 10: rear centre
+ AV_CHAN_BACK_CENTER,
+
+ // 11: left surround direct
+ AV_CHAN_SURROUND_DIRECT_LEFT,
+
+ // 12: right surround direct
+ AV_CHAN_SURROUND_DIRECT_RIGHT,
+
+ // 13: left side surround
+ AV_CHAN_SIDE_LEFT,
+
+ // 14: right side surround
+ AV_CHAN_SIDE_RIGHT,
+
+ // 15: left wide front
+ AV_CHAN_WIDE_LEFT,
+
+ // 16: right wide front
+ AV_CHAN_WIDE_RIGHT,
+
+ // 17: left front vertical height
+ AV_CHAN_TOP_FRONT_LEFT,
+
+ // 18: right front vertical height
+ AV_CHAN_TOP_FRONT_RIGHT,
+
+ // 19: centre front vertical height
+ AV_CHAN_TOP_FRONT_CENTER,
+
+ // 20: left surround vertical height rear
+ AV_CHAN_TOP_BACK_LEFT,
+
+ // 21: right surround vertical height rear
+ AV_CHAN_TOP_BACK_RIGHT,
+
+ // 22: centre vertical height rear
+ AV_CHAN_TOP_BACK_CENTER,
+
+ // 23: left vertical height side surround
+ AV_CHAN_TOP_SIDE_LEFT,
+
+ // 24: right vertical height side surround
+ AV_CHAN_TOP_SIDE_RIGHT,
+
+ // 25: top centre surround
+ AV_CHAN_TOP_CENTER,
+
+ // 26: low frequency enhancement 2
+ AV_CHAN_LOW_FREQUENCY_2,
+
+ // 27: left front vertical bottom
+ AV_CHAN_BOTTOM_FRONT_LEFT,
+
+ // 28: right front vertical bottom
+ AV_CHAN_BOTTOM_FRONT_RIGHT,
+
+ // 29: centre front vertical bottom
+ AV_CHAN_BOTTOM_FRONT_CENTER,
+
+ // 30: left vertical height surround
+ // TODO
+ AV_CHAN_NONE,
+
+ // 31: right vertical height surround
+ // TODO
+ AV_CHAN_NONE,
+
+ // 32, 33, 34, 35, reserved
+ AV_CHAN_NONE,
+ AV_CHAN_NONE,
+ AV_CHAN_NONE,
+ AV_CHAN_NONE,
+
+ // 36: low frequency enhancement 3
+ AV_CHAN_NONE,
+
+ // 37: left edge of screen
+ AV_CHAN_NONE,
+ // 38: right edge of screen
+ AV_CHAN_NONE,
+ // 39: half-way between centre of screen and left edge of screen
+ AV_CHAN_NONE,
+ // 40: half-way between centre of screen and right edge of screen
+ AV_CHAN_NONE,
+
+ // 41: left back surround
+ AV_CHAN_NONE,
+
+ // 42: right back surround
+ AV_CHAN_NONE,
+
+ // 43 - 125: reserved
+ // 126: explicit position
+ // 127: unknown /undefined
+};
+
+int ff_mov_get_channel_config_from_layout(const AVChannelLayout *layout, int *config)
+{
+ // Set default value which means any setup in 23001-8
+ *config = 0;
+ for (int i = 0; i < FF_ARRAY_ELEMS(iso_channel_configuration); i++) {
+ if (!av_channel_layout_compare(layout, iso_channel_configuration + i)) {
+ *config = i;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int ff_mov_get_channel_layout_from_config(int config, AVChannelLayout *layout)
+{
+ if (config > 0 && config < FF_ARRAY_ELEMS(iso_channel_configuration)) {
+ av_channel_layout_copy(layout, &iso_channel_configuration[config]);
+ return 0;
+ }
+
+ return -1;
+}
+
+int ff_mov_get_channel_positions_from_layout(const AVChannelLayout *layout,
+ uint8_t *position, int position_num)
+{
+ enum AVChannel channel;
+
+ if (position_num < layout->nb_channels)
+ return AVERROR(EINVAL);
+
+ for (int i = 0; i < layout->nb_channels; i++) {
+ position[i] = 127;
+ channel = av_channel_layout_channel_from_index(layout, i);
+ if (channel == AV_CHAN_NONE)
+ return AVERROR(EINVAL);
+
+ for (int j = 0; j < FF_ARRAY_ELEMS(iso_channel_position); j++) {
+ if (iso_channel_position[j] == channel) {
+ position[i] = j;
+ break;
+ }
+ }
+ if (position[i] == 127)
+ return AVERROR(EINVAL);
+ }
+
+ return 0;
+}
+
+int ff_mov_get_layout_from_channel_positions(const uint8_t *position, int position_num,
+ AVChannelLayout *layout)
+{
+ int ret;
+ enum AVChannel channel;
+
+ av_channel_layout_uninit(layout);
+
+ if (position_num <= 63) {
+ layout->order = AV_CHANNEL_ORDER_NATIVE;
+ layout->nb_channels = position_num;
+ for (int i = 0; i < position_num; i++) {
+ if (position[i] >= FF_ARRAY_ELEMS(iso_channel_position)) {
+ ret = AVERROR_PATCHWELCOME;
+ goto error;
+ }
+
+ channel = iso_channel_position[position[i]];
+ // unsupported layout
+ if (channel == AV_CHAN_NONE) {
+ ret = AVERROR_PATCHWELCOME;
+ goto error;
+ }
+
+ layout->u.mask |= 1ULL << channel;
+ }
+ } else {
+ layout->order = AV_CHANNEL_ORDER_CUSTOM;
+ layout->nb_channels = position_num;
+ layout->u.map = av_calloc(position_num, sizeof(*layout->u.map));
+ if (!layout->u.map) {
+ ret = AVERROR(ENOMEM);
+ goto error;
+ }
+
+ for (int i = 0; i < position_num; i++) {
+ if (position[i] >= FF_ARRAY_ELEMS(iso_channel_position)) {
+ ret = AVERROR_PATCHWELCOME;
+ goto error;
+ }
+
+ channel = iso_channel_position[position[i]];
+ // unsupported layout
+ if (channel == AV_CHAN_NONE) {
+ ret = AVERROR_PATCHWELCOME;
+ goto error;
+ }
+
+ layout->u.map[i].id = channel;
+ }
+ }
+
+
+ return 0;
+
+error:
+ av_channel_layout_uninit(layout);
+ return ret;
+}
diff --git a/libavformat/mov_chan.h b/libavformat/mov_chan.h
index 93d9878798..8c807798ab 100644
--- a/libavformat/mov_chan.h
+++ b/libavformat/mov_chan.h
@@ -163,4 +163,30 @@ int ff_mov_get_channel_layout_tag(const AVCodecParameters *par,
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
int64_t size);
+/**
+ * Get ISO/IEC 23001-8 ChannelConfiguration from AVChannelLayout.
+ *
+ */
+int ff_mov_get_channel_config_from_layout(const AVChannelLayout *layout, int *config);
+
+/**
+ * Get AVChannelLayout from ISO/IEC 23001-8 ChannelConfiguration.
+ *
+ * @return 0 for success, -1 for doesn't match, layout is untouched on failure
+ */
+
+int ff_mov_get_channel_layout_from_config(int config, AVChannelLayout *layout);
+
+/**
+ * Get ISO/IEC 23001-8 OutputChannelPosition from AVChannelLayout.
+ */
+int ff_mov_get_channel_positions_from_layout(const AVChannelLayout *layout,
+ uint8_t *position, int position_num);
+
+/**
+ * Get AVChannelLayout from ISO/IEC 23001-8 OutputChannelPosition.
+ */
+int ff_mov_get_layout_from_channel_positions(const uint8_t *position, int position_num,
+ AVChannelLayout *layout);
+
#endif /* AVFORMAT_MOV_CHAN_H */
--
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
` (5 preceding siblings ...)
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 8/8] fate/mov: add PCM in mp4 test Zhao Zhili
7 siblings, 1 reply; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
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 = &track->par->ch_layout;
+
+ ret = ff_mov_get_channel_config_from_layout(layout, &config);
+ 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(&speaker_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(&speaker_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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2 8/8] fate/mov: add PCM in mp4 test
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
` (6 preceding siblings ...)
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM Zhao Zhili
@ 2023-02-24 18:28 ` Zhao Zhili
7 siblings, 0 replies; 20+ messages in thread
From: Zhao Zhili @ 2023-02-24 18:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
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 0000000000..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 0000000000..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 0000000000..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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
2023-02-27 20:24 ` Jan Ekström
1 sibling, 0 replies; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> It's defined by ISO/IEC 23003-5.
>
> Fixes ticket #10185
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
> libavformat/movenc.c | 60
> +++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 59 insertions(+), 1 deletion(-)
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
2023-02-27 16:26 ` Jan Ekström
0 siblings, 1 reply; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> From: Jan Ekström <jeebjp@gmail.com>
>
> 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(-)
Probably OK, but I'm not versed i the version problems relating to this
tag. Should we also support version > 0?
/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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
2023-03-05 22:01 ` Jan Ekström
0 siblings, 1 reply; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> From: Jan Ekström <jeebjp@gmail.com>
>
> 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
Should be 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
0 siblings, 0 replies; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> Missing floating-point formats support.
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
> libavformat/mov.c | 47
> +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
Should still be 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
0 siblings, 0 replies; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> 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 <zhilizhao@tencent.com>
> ---
> libavformat/isom_tags.c | 2 --
> 1 file changed, 2 deletions(-)
Should also still be 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
0 siblings, 0 replies; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
>
> + if (!layout) {
> + uint8_t *positions = av_malloc(st->codecpar-
> >ch_layout.nb_channels);
Could be allocated on the stack, either using a fixed-size array, a VLA
or alloca(), thus avoiding a heap allocation
/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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM Zhao Zhili
@ 2023-02-27 13:36 ` Tomas Härdin
0 siblings, 0 replies; 20+ messages in thread
From: Tomas Härdin @ 2023-02-27 13:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
>
> +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;
Could also be allocated on the stack
/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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type
2023-02-27 13:36 ` Tomas Härdin
@ 2023-02-27 16:26 ` Jan Ekström
2023-03-05 22:00 ` Jan Ekström
0 siblings, 1 reply; 20+ messages in thread
From: Jan Ekström @ 2023-02-27 16:26 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 27, 2023 at 3:36 PM Tomas Härdin <git@haerdin.se> wrote:
>
> lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> > From: Jan Ekström <jeebjp@gmail.com>
> >
> > 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(-)
>
> Probably OK, but I'm not versed i the version problems relating to this
> tag. Should we also support version > 0?
>
> /Tomas
pcmC only has version 0 and flags coded to zero, thankfully
The channel layout box is where the "fun" begins with version 1 as
well as this following quote:
> 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.
Jan
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
@ 2023-02-27 20:24 ` Jan Ekström
2023-02-28 4:41 ` "zhilizhao(赵志立)"
1 sibling, 1 reply; 20+ messages in thread
From: Jan Ekström @ 2023-02-27 20:24 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, Feb 24, 2023 at 8:29 PM Zhao Zhili <quinkblack@foxmail.com> wrote:
>
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> It's defined by ISO/IEC 23003-5.
>
> Fixes ticket #10185
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Technically if you wanted to split these commits, then this
implementation would have to be limited to one audio channel streams,
as 23003-5:2020
says as follows:
- The ChannelLayout as defined in ISO/IEC 14496-12 is mandatory if the
PCM channel count is larger than one.
> ---
> 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;
> + }
> +}
This should be unnecessary if the check is switched to the codec_tags
in mov_write_audio_tag.
> +
> +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);
> +}
Generally looks good. I utilized av_get_exact_bits_per_sample, but
since mov_write_audio_tag also writes down bits_per_raw_sample, so I
think being consistent should be OK :)
> +
> 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)) {
I know why you think you should be doing this, but:
1. 14496-12:2022 still defines AudioSampleEntry::samplesize as
"template unsigned int(16) samplesize = 16;", so ISOBMFF itself only
lets you set 16 here.
2. 23003-5:2020 does not allow other values to be written (the
downstream spec should explicitly allow writing of non-template
values). This is probably because pcmC itself contains PCM_sample_size
for this same use.
So writing samplesize here is technically incorrect, even though I
know that most likely some implementations do this (technically
against these specs).
Why channelcount was made non-template yet samplesize was not? A very
good question. Most likely the channel layout v1 and DRC boxes'
changes started requiring the former, but not the latter?
> 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);
It would seem that the generic vos_data extradata writing should be
the last else if in this logic? Could be unnecessary cargo culting,
but at least so far all new codec handling went before it?
Personally I would have just based this check on the codec tag, a la
else if (tag == MOV_MP4_IPCM_TAG || tag == MOV_MP4_FPCM_TAG)
// pcmC is required for these tags as per ISO/IEC 23003-5
ret = mov_write_pcmc_tag(s, pb, track);
As that matches the specification's note:
- Mandatory: Yes, if codingname of SampleEntry is ‘ipcm’ or ‘fpcm’.
The codec tags are also only defined in codec_mp4_tags, so they would
only get utilized in MP4 and other formats which supposedly support
MP4 formats (ISMV, PSP), so no additional check for that should be
required.
They already contain stuff such as AV_CODEC_ID_MPEGH_3D_AUDIO, so I
wouldn't consider this a problem :) . Mostly in the sense that if a
more limited set of codecs is wanted for ISMV/PSP, then they should
receive their own more limited listings and not share the mp4 tag
listing :) .
If you wonder how much the codec tag listing gives you freedoms, you
can check the logic in libavformat/mux.c::validate_codec_tag.
>
> 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') },
> +
This listing seems alright. Personally I added a define for these two
identifiers, but either is fine.
> { 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-request@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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support
2023-02-27 20:24 ` Jan Ekström
@ 2023-02-28 4:41 ` "zhilizhao(赵志立)"
0 siblings, 0 replies; 20+ messages in thread
From: "zhilizhao(赵志立)" @ 2023-02-28 4:41 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On Feb 28, 2023, at 04:24, Jan Ekström <jeebjp@gmail.com> wrote:
>
> On Fri, Feb 24, 2023 at 8:29 PM Zhao Zhili <quinkblack@foxmail.com> wrote:
>>
>> From: Zhao Zhili <zhilizhao@tencent.com>
>>
>> It's defined by ISO/IEC 23003-5.
>>
>> Fixes ticket #10185
>>
>> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
>
> Technically if you wanted to split these commits, then this
> implementation would have to be limited to one audio channel streams,
> as 23003-5:2020
> says as follows:
>
> - The ChannelLayout as defined in ISO/IEC 14496-12 is mandatory if the
> PCM channel count is larger than one.
OK. Will do a ping-pong with v3.
>
>> ---
>> 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;
>> + }
>> +}
>
> This should be unnecessary if the check is switched to the codec_tags
> in mov_write_audio_tag.
>
>> +
>> +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);
>> +}
>
> Generally looks good. I utilized av_get_exact_bits_per_sample, but
> since mov_write_audio_tag also writes down bits_per_raw_sample, so I
> think being consistent should be OK :)
>
>> +
>> 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)) {
>
> I know why you think you should be doing this, but:
>
> 1. 14496-12:2022 still defines AudioSampleEntry::samplesize as
> "template unsigned int(16) samplesize = 16;", so ISOBMFF itself only
> lets you set 16 here.
> 2. 23003-5:2020 does not allow other values to be written (the
> downstream spec should explicitly allow writing of non-template
> values). This is probably because pcmC itself contains PCM_sample_size
> for this same use.
>
> So writing samplesize here is technically incorrect, even though I
> know that most likely some implementations do this (technically
> against these specs).
Technically it’s against spec. However:
1. It lets old version of libavformat able to demux PCM in mp4.
samplesize is used inside mov_parse_stsd_audio for AV_CODEC_ID_PCM.
2. samplesize is a fixed value in spec. If other mp4 demuxer implementations
ignore this field, it’s fine. If they use samplesize, it’s better to
set the real value. It’s a problem only if they reject samplesize != 16,
which is unlikely.
What do you think?
>
> Why channelcount was made non-template yet samplesize was not? A very
> good question. Most likely the channel layout v1 and DRC boxes'
> changes started requiring the former, but not the latter?
>
>> 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);
>
> It would seem that the generic vos_data extradata writing should be
> the last else if in this logic? Could be unnecessary cargo culting,
> but at least so far all new codec handling went before it?
>
> Personally I would have just based this check on the codec tag, a la
>
> else if (tag == MOV_MP4_IPCM_TAG || tag == MOV_MP4_FPCM_TAG)
> // pcmC is required for these tags as per ISO/IEC 23003-5
> ret = mov_write_pcmc_tag(s, pb, track);
Will update in v3.
>
> As that matches the specification's note:
>
> - Mandatory: Yes, if codingname of SampleEntry is ‘ipcm’ or ‘fpcm’.
>
> The codec tags are also only defined in codec_mp4_tags, so they would
> only get utilized in MP4 and other formats which supposedly support
> MP4 formats (ISMV, PSP), so no additional check for that should be
> required.
>
> They already contain stuff such as AV_CODEC_ID_MPEGH_3D_AUDIO, so I
> wouldn't consider this a problem :) . Mostly in the sense that if a
> more limited set of codecs is wanted for ISMV/PSP, then they should
> receive their own more limited listings and not share the mp4 tag
> listing :) .
>
> If you wonder how much the codec tag listing gives you freedoms, you
> can check the logic in libavformat/mux.c::validate_codec_tag.
>
>>
>> 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') },
>> +
>
> This listing seems alright. Personally I added a define for these two
> identifiers, but either is fine.
>
>> { 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-request@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-request@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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type
2023-02-27 16:26 ` Jan Ekström
@ 2023-03-05 22:00 ` Jan Ekström
0 siblings, 0 replies; 20+ messages in thread
From: Jan Ekström @ 2023-03-05 22:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 27, 2023 at 6:26 PM Jan Ekström <jeebjp@gmail.com> wrote:
>
> On Mon, Feb 27, 2023 at 3:36 PM Tomas Härdin <git@haerdin.se> wrote:
> >
> > lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> > > From: Jan Ekström <jeebjp@gmail.com>
> > >
> > > 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(-)
> >
> > Probably OK, but I'm not versed i the version problems relating to this
> > tag. Should we also support version > 0?
> >
> > /Tomas
>
> pcmC only has version 0 and flags coded to zero, thankfully
>
> The channel layout box is where the "fun" begins with version 1 as
> well as this following quote:
>
> > 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.
Applied as adca877acb930faf1a5d686af93b9f657cebf1b5 to make this set
under review shorter.
Jan
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB
2023-02-27 13:36 ` Tomas Härdin
@ 2023-03-05 22:01 ` Jan Ekström
0 siblings, 0 replies; 20+ messages in thread
From: Jan Ekström @ 2023-03-05 22:01 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 27, 2023 at 3:37 PM Tomas Härdin <git@haerdin.se> wrote:
>
> lör 2023-02-25 klockan 02:28 +0800 skrev Zhao Zhili:
> > From: Jan Ekström <jeebjp@gmail.com>
> >
> > 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
>
> Should be OK.
Applied as 912ac82a3c769792ad992534f3df9b0a549ff827 to make this set
under review shorter, with a minor improvement to the commit message
("base *pcmC* endianness on just the LSB")
Jan
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2023-03-05 22:02 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230224182849.426345-1-quinkblack@foxmail.com>
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 1/8] avformat/movenc: add PCM in mp4 support Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-27 20:24 ` Jan Ekström
2023-02-28 4:41 ` "zhilizhao(赵志立)"
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 2/8] avformat/mov: check that pcmC box is of the expected type Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-27 16:26 ` Jan Ekström
2023-03-05 22:00 ` Jan Ekström
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 3/8] avformat/mov: base the endianness on just the LSB Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-03-05 22:01 ` Jan Ekström
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 4/8] avformat/mov: fix ISO/IEC 23003-5 support Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 5/8] avformat/isom_tags: remove ipcm from movaudio_tags Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 6/8] avformat/mov: parse ISO-14496-12 ChannelLayout Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 7/8] avformat/movenc: write ChannelLayout box for PCM Zhao Zhili
2023-02-27 13:36 ` Tomas Härdin
2023-02-24 18:28 ` [FFmpeg-devel] [PATCH v2 8/8] fate/mov: add PCM in mp4 test Zhao Zhili
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git