Re: [FFmpeg-devel] [PATCH 1/2] avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support

2024-07-03 Thread asivery via ffmpeg-devel
On Sat, 15 Jun 2024 I was asked for samples by Anton Khirnov - this is why I 
wrote the test.
If the test is not necessary after all, that patch doesn't need to be applied. 
I can also shorten the test file, if it's required.

On Wednesday, July 3rd, 2024 at 4:49 PM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > I'm sending the patch again, so that it is correctly rebased on the current 
> > master.
> > Here are the two sample files required by the FATE test:
> > https://0x0.st/Xaw2.aea/boxboy333_house_music_multitrack.aea
> > https://0x0.st/Xaw_.pcm/boxboy333_house_music_multitrack.pcm
> > Please let me know if I need to provide anything else.
> 
> 
> Why such a gigantic file? And why actually a multi-channel file given
> that there are no special coding modes for multi-channel files?
> 
> - Andreas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] fate/atrac1: add test for 4-track file

2024-07-03 Thread asivery via ffmpeg-devel
Empty MessageFrom 89743ce8da188800536c78b46fc3ee43e1538fb5 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Wed, 3 Jul 2024 16:25:05 +0200
Subject: [PATCH 2/2] fate/atrac1: add test for 4-track file

Signed-off-by: asivery 
---
 tests/fate/atrac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/atrac.mak b/tests/fate/atrac.mak
index 592d1819df..d19da8d661 100644
--- a/tests/fate/atrac.mak
+++ b/tests/fate/atrac.mak
@@ -7,6 +7,10 @@ fate-atrac1-2: CMD = pcm -i $(TARGET_SAMPLES)/atrac1/chirp_tone_10-16000.aea
 fate-atrac1-2: REF = $(SAMPLES)/atrac1/chirp_tone_10-16000.pcm
 fate-atrac1-2: FUZZ = 61
 
+FATE_ATRAC1 += fate-atrac1-3
+fate-atrac1-3: CMD = pcm -i $(TARGET_SAMPLES)/atrac1/boxboy333_house_music_multitrack.aea
+fate-atrac1-3: REF = $(SAMPLES)/atrac1/boxboy333_house_music_multitrack.pcm
+
 FATE_ATRAC1-$(call DEMDEC, AEA, ATRAC1, ARESAMPLE_FILTER) += $(FATE_ATRAC1)
 
 FATE_ATRAC3 += fate-atrac3-1
-- 
2.45.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 1/2] avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support

2024-07-03 Thread asivery via ffmpeg-devel
I'm sending the patch again, so that it is correctly rebased on the current 
master.
Here are the two sample files required by the FATE test:
https://0x0.st/Xaw2.aea/boxboy333_house_music_multitrack.aea
https://0x0.st/Xaw_.pcm/boxboy333_house_music_multitrack.pcm
Please let me know if I need to provide anything else.From 22b988b046c1a1eb02033416710a3f3244f8859a Mon Sep 17 00:00:00 2001
From: asivery 
Date: Wed, 3 Jul 2024 16:24:41 +0200
Subject: [PATCH 1/2] avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel
 ATRAC1 support

Signed-off-by: asivery 
---
 libavcodec/atrac1.c  | 12 ++--
 libavformat/aeadec.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index cdcc7a669e..448bdfc7e9 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -49,7 +49,7 @@
 #define AT1_SU_SAMPLES   512///< number of samples in a sound unit
 #define AT1_FRAME_SIZE   AT1_SU_SIZE * 2
 #define AT1_SU_MAX_BITS  AT1_SU_SIZE * 8
-#define AT1_MAX_CHANNELS 2
+#define AT1_MAX_CHANNELS 8
 
 #define AT1_QMF_BANDS3
 #define IDX_LOW_BAND 0
@@ -339,7 +339,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 AVFloatDSPContext *fdsp;
 int channels = avctx->ch_layout.nb_channels;
 float scale = -1.0 / (1 << 15);
-int ret;
+int ret, ch;
 
 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
@@ -380,10 +380,10 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 q->bands[2] = q->high;
 
 /* Prepare the mdct overlap buffers */
-q->SUs[0].spectrum[0] = q->SUs[0].spec1;
-q->SUs[0].spectrum[1] = q->SUs[0].spec2;
-q->SUs[1].spectrum[0] = q->SUs[1].spec1;
-q->SUs[1].spectrum[1] = q->SUs[1].spec2;
+for (ch = 0; ch < AT1_MAX_CHANNELS; ch++) {
+q->SUs[ch].spectrum[0] = q->SUs[ch].spec1;
+q->SUs[ch].spectrum[1] = q->SUs[ch].spec2;
+}
 
 return 0;
 }
diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c
index be18e7b725..0a3d09a89d 100644
--- a/libavformat/aeadec.c
+++ b/libavformat/aeadec.c
@@ -84,7 +84,7 @@ static int aea_read_header(AVFormatContext *s)
 st->codecpar->sample_rate= 44100;
 st->codecpar->bit_rate   = 146000 * channels;
 
-if (channels != 1 && channels != 2) {
+if (channels < 1 || channels > 8) {
 av_log(s, AV_LOG_ERROR, "Channels %d not supported!\n", channels);
 return AVERROR_INVALIDDATA;
 }
-- 
2.45.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] avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support

2024-06-14 Thread asivery via ffmpeg-devel
Right now both the ATRAC1 decoder implementation, and the AEA demuxer don't 
accept 4-track and 8-track ATRAC data. This patch fixes that problem.From c42e05855a018e28159bf29b49137bb33f5e45fd Mon Sep 17 00:00:00 2001
From: asivery 
Date: Sat, 15 Jun 2024 07:47:40 +0200
Subject: [PATCH] avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support

Signed-off-by: asivery 
---
 libavcodec/atrac1.c  | 12 ++--
 libavformat/aeadec.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index cdcc7a669e..448bdfc7e9 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -49,7 +49,7 @@
 #define AT1_SU_SAMPLES   512///< number of samples in a sound unit
 #define AT1_FRAME_SIZE   AT1_SU_SIZE * 2
 #define AT1_SU_MAX_BITS  AT1_SU_SIZE * 8
-#define AT1_MAX_CHANNELS 2
+#define AT1_MAX_CHANNELS 8
 
 #define AT1_QMF_BANDS3
 #define IDX_LOW_BAND 0
@@ -339,7 +339,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 AVFloatDSPContext *fdsp;
 int channels = avctx->ch_layout.nb_channels;
 float scale = -1.0 / (1 << 15);
-int ret;
+int ret, ch;
 
 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
@@ -380,10 +380,10 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 q->bands[2] = q->high;
 
 /* Prepare the mdct overlap buffers */
-q->SUs[0].spectrum[0] = q->SUs[0].spec1;
-q->SUs[0].spectrum[1] = q->SUs[0].spec2;
-q->SUs[1].spectrum[0] = q->SUs[1].spec1;
-q->SUs[1].spectrum[1] = q->SUs[1].spec2;
+for (ch = 0; ch < AT1_MAX_CHANNELS; ch++) {
+q->SUs[ch].spectrum[0] = q->SUs[ch].spec1;
+q->SUs[ch].spectrum[1] = q->SUs[ch].spec2;
+}
 
 return 0;
 }
diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c
index be18e7b725..0a3d09a89d 100644
--- a/libavformat/aeadec.c
+++ b/libavformat/aeadec.c
@@ -84,7 +84,7 @@ static int aea_read_header(AVFormatContext *s)
 st->codecpar->sample_rate= 44100;
 st->codecpar->bit_rate   = 146000 * channels;
 
-if (channels != 1 && channels != 2) {
+if (channels < 1 || channels > 8) {
 av_log(s, AV_LOG_ERROR, "Channels %d not supported!\n", channels);
 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".


Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-12 Thread asivery via ffmpeg-devel
Thank you Stefano Sabatini and Andreas Rheinhardt - you guys have the patience 
of saints.

On Tuesday, March 12th, 2024 at 11:27 AM, Stefano Sabatini  
wrote:

> On date Sunday 2024-03-10 16:10:15 +0100, Stefano Sabatini wrote:
> 
> > On date Sunday 2024-03-10 14:20:12 +, ffmpeg-devel Mailing List wrote:
> > 
> > > Great, thank you very much!
> > > I'm attaching the (hopefully) final version of the patch.
> > 
> > > MD studio was a piece of software created by a company called "EDL",
> > > which in combination with alternative firmware for the Sony MDH-10
> > > MiniDisc recorder
> > > (https://www.minidisc.wiki/equipment/sony/misc/mdh-10) let people
> > > download raw ATRAC1 audio from their MiniDiscs onto computers, and
> > > (probably) put this audio back on their discs later. Nowadays it's
> > > used by software like Web Minidisc Pro (which I maintain) to store
> > > ATRAC1 audio, as it (until recently) was the only way to store
> > > ATRAC1 so that it would be picked up by VLC. Now we have matroska
> > > support for ATRAC1, but I wanted to write a muxer for AEA before I
> > > phase it out from new pieces of software, so that the people who
> > > would like to use AEA instead of matroska have a way to go back to
> > > it.
> > 
> > Thanks, probably part of this information could go to the doc to
> > provide some context (can be done as a separate patch), as this kind
> > of info is very difficult to retrieve otherwise (and one of the goals
> > of FFmpeg is digital preservation).
> > 
> > > From e67d2df52c65528fbbfe8d5268661c88a7ad225e Mon Sep 17 00:00:00 2001
> > > From: asivery asiv...@protonmail.com
> > > Date: Fri, 8 Mar 2024 14:45:02 +0100
> > > Subject: [PATCH] avformat/aea: Add aea muxer
> > > 
> > > Signed-off-by: asivery asiv...@protonmail.com
> > > ---
> > > Changelog | 1 +
> > > doc/muxers.texi | 10 +++
> > > libavformat/Makefile | 3 +-
> > > libavformat/{aea.c => aeadec.c} | 0
> > > libavformat/aeaenc.c | 115 
> > > libavformat/allformats.c | 1 +
> > > 6 files changed, 129 insertions(+), 1 deletion(-)
> > > rename libavformat/{aea.c => aeadec.c} (100%)
> > > create mode 100644 libavformat/aeaenc.c
> > 
> > Patch looks good to me, waiting for more feedback by Andreas.
> 
> 
> Will apply it soon, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-10 Thread asivery via ffmpeg-devel
Great, thank you very much!
I'm attaching the (hopefully) final version of the patch.

MD studio was a piece of software created by a company called "EDL", which in 
combination with alternative firmware for the Sony MDH-10 MiniDisc recorder 
(https://www.minidisc.wiki/equipment/sony/misc/mdh-10) let people download raw 
ATRAC1 audio from their MiniDiscs onto computers, and (probably) put this audio 
back on their discs later.
Nowadays it's used by software like Web Minidisc Pro (which I maintain) to 
store ATRAC1 audio, as it (until recently) was the only way to store ATRAC1 so 
that it would be picked up by VLC. Now we have matroska support for ATRAC1, but 
I wanted to write a muxer for AEA before I phase it out from new pieces of 
software, so that the people who would like to use AEA instead of matroska have 
a way to go back to it.

> On date Saturday 2024-03-09 17:20:49 +, ffmpeg-devel Mailing List wrote:
> 
> > Thank you both for the suggestions. I've updated the code as requested, and 
> > I apologize for the AV_LOG_WARNING instead of AV_LOG_ERROR - it was an 
> > oversight on my part.
> > I have also added the stream codec check, and it did get triggered when I 
> > tried to feed it audio that was not ATRAC1, so it seems it is required.
> > Regarding titles being truncated - that was my intention. However I've now 
> > added a warning if it was going to happen.
> > As for the block count in the header - none of the modern software which 
> > uses AEA reads that field, but for the older software, it will now be 
> > truncated to UINT32_MAX if needed.
> > Is there anything else that needs changes?
> 
> > From ee1d4c93c66e729d9d0456b2e8e789f3f98389e3 Mon Sep 17 00:00:00 2001
> > From: asivery asiv...@protonmail.com
> > Date: Fri, 8 Mar 2024 14:45:02 +0100
> > Subject: [PATCH] avformat/aea: Add aea muxer
> > 
> > Signed-off-by: asivery asiv...@protonmail.com
> > ---
> > doc/muxers.texi | 10 +++
> > libavformat/Makefile | 3 +-
> > libavformat/{aea.c => aeadec.c} | 0
> > libavformat/aeaenc.c | 115 
> > libavformat/allformats.c | 1 +
> > 5 files changed, 128 insertions(+), 1 deletion(-)
> > rename libavformat/{aea.c => aeadec.c} (100%)
> > create mode 100644 libavformat/aeaenc.c
> > 
> > diff --git a/doc/muxers.texi b/doc/muxers.texi
> > index 2104cc4a95..a4df8f736d 100644
> > --- a/doc/muxers.texi
> > +++ b/doc/muxers.texi
> > @@ -663,6 +663,16 @@ when enabled, write a CRC checksum for each packet to 
> > the output,
> > default is @code{false}
> > @end table
> 
> > +@anchor{aea}
> > +@section aea
> 
> 
> nit: sort order (should go after adts)
> 
> > +MD STUDIO audio muxer.
> 
> 
> out of my own curiosity, what is MD STUDIO?
> 
> [...]
> 
> You might also add an entry to the Changelog.
> Looks good to me otherwise, thanks.From e67d2df52c65528fbbfe8d5268661c88a7ad225e Mon Sep 17 00:00:00 2001
From: asivery 
Date: Fri, 8 Mar 2024 14:45:02 +0100
Subject: [PATCH] avformat/aea: Add aea muxer

Signed-off-by: asivery 
---
 Changelog   |   1 +
 doc/muxers.texi |  10 +++
 libavformat/Makefile|   3 +-
 libavformat/{aea.c => aeadec.c} |   0
 libavformat/aeaenc.c| 115 
 libavformat/allformats.c|   1 +
 6 files changed, 129 insertions(+), 1 deletion(-)
 rename libavformat/{aea.c => aeadec.c} (100%)
 create mode 100644 libavformat/aeaenc.c

diff --git a/Changelog b/Changelog
index 069b827448..641c6b7cc5 100644
--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,7 @@ version :
 - DVD-Video demuxer, powered by libdvdnav and libdvdread
 - ffprobe -show_stream_groups option
 - ffprobe (with -export_side_data film_grain) now prints film grain metadata
+- AEA muxer
 
 
 version 6.1:
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2104cc4a95..6446d868ed 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -684,6 +684,16 @@ Enable to set MPEG version bit in the ADTS frame header to 1 which
 indicates MPEG-2. Default is 0, which indicates MPEG-4.
 @end table
 
+@anchor{aea}
+@section aea
+MD STUDIO audio muxer.
+
+This muxer accepts a single ATRAC1 audio stream with either one or two channels
+and a sample rate of 44100Hz.
+
+As AEA supports storing the track title, this muxer will also write
+the title from stream's metadata to the container.
+
 @anchor{aiff}
 @section aiff
 Audio Interchange File Format muxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8811a0ffc9..70d56f391f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_ADTS_MUXER)+= adtsenc.o apetag.o img2.o \
 id3v2e

Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-09 Thread asivery via ffmpeg-devel
I see, I've changed title_length to size_t, but left the warning as is to 
inform the user in case truncation needs to take place.

On Saturday, March 9th, 2024 at 6:48 PM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > + const char *title_contents = title_entry->value;
> > + title_length = strlen(title_contents);
> > + if (title_length > 256) {
> > + av_log(s, AV_LOG_WARNING, "Title too long, truncated to 256 bytes.\n");
> > + title_length = 256;
> > + }
> 
> 
> I actually meant that you should use size_t for title_length (so that
> the output of strlen() is never truncated) instead of adding a warning
> that will likely never be triggered in practice.
> 
> - Andreas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".From 512e25ee49e30a0ac2d77cf865185cbfe92a850e Mon Sep 17 00:00:00 2001
From: asivery 
Date: Fri, 8 Mar 2024 14:45:02 +0100
Subject: [PATCH] avformat/aea: Add aea muxer

Signed-off-by: asivery 
---
 doc/muxers.texi |  10 +++
 libavformat/Makefile|   3 +-
 libavformat/{aea.c => aeadec.c} |   0
 libavformat/aeaenc.c| 115 
 libavformat/allformats.c|   1 +
 5 files changed, 128 insertions(+), 1 deletion(-)
 rename libavformat/{aea.c => aeadec.c} (100%)
 create mode 100644 libavformat/aeaenc.c

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2104cc4a95..a4df8f736d 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -663,6 +663,16 @@ when enabled, write a CRC checksum for each packet to the output,
 default is @code{false}
 @end table
 
+@anchor{aea}
+@section aea
+MD STUDIO audio muxer.
+
+This muxer accepts a single ATRAC1 audio stream with either one or two channels
+and a sample rate of 44100Hz.
+
+As AEA supports storing the track title, this muxer will also write
+the title from stream's metadata to the container.
+
 @anchor{adts}
 @section adts
 Audio Data Transport Stream muxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8811a0ffc9..70d56f391f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_ADTS_MUXER)+= adtsenc.o apetag.o img2.o \
 id3v2enc.o
 OBJS-$(CONFIG_ADX_DEMUXER)   += adxdec.o
 OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
-OBJS-$(CONFIG_AEA_DEMUXER)   += aea.o pcm.o
+OBJS-$(CONFIG_AEA_DEMUXER)   += aeadec.o pcm.o
+OBJS-$(CONFIG_AEA_MUXER) += aeaenc.o rawenc.o
 OBJS-$(CONFIG_AFC_DEMUXER)   += afc.o
 OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o aiff.o pcm.o \
 mov_chan.o replaygain.o
diff --git a/libavformat/aea.c b/libavformat/aeadec.c
similarity index 100%
rename from libavformat/aea.c
rename to libavformat/aeadec.c
diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c
new file mode 100644
index 00..f7b945b382
--- /dev/null
+++ b/libavformat/aeaenc.c
@@ -0,0 +1,115 @@
+/*
+ * MD STUDIO audio muxer
+ *
+ * Copyright (c) 2024 asivery
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "avio_internal.h"
+#include "rawenc.h"
+#include "mux.h"
+
+static int aea_write_header(AVFormatContext *s)
+{
+const AVDictionaryEntry *title_entry;
+size_t title_length = 0;
+AVStream *st;
+
+if (s->nb_streams > 1) {
+av_log(s, AV_LOG_ERROR, "Got more than one stream to encode. This is not supported.\n");
+return AVERROR(EINVAL);
+}
+
+st = s->streams[0];
+if (st->codecpar->ch_layout.nb_channels != 1 && st->codecpar->ch_layout.nb_channels != 2) {
+av_log(s, AV_LOG_ERROR, "Only maximum 2 channels are supported in the audio"
+   " stream, %d channels were found.\n", st->codecpar->ch_layout.nb_ch

Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-09 Thread asivery via ffmpeg-devel
Thank you both for the suggestions. I've updated the code as requested, and I 
apologize for the AV_LOG_WARNING instead of AV_LOG_ERROR - it was an oversight 
on my part.
I have also added the stream codec check, and it did get triggered when I tried 
to feed it audio that was not ATRAC1, so it seems it is required.
Regarding titles being truncated - that was my intention. However I've now 
added a warning if it was going to happen.
As for the block count in the header - none of the modern software which uses 
AEA reads that field, but for the older software, it will now be truncated to 
UINT32_MAX if needed.
Is there anything else that needs changes?

- asivery

On Saturday, March 9th, 2024 at 1:06 PM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > +#include "libavutil/intreadwrite.h"
> > +#include "libavutil/avstring.h"
> 
> 
> These two headers seem unused.
> 
> > +#include "avformat.h"
> > +#include "avio_internal.h"
> > +#include "rawenc.h"
> > +#include "mux.h"
> > +
> > +static int aea_write_header(AVFormatContext *s)
> > +{
> > + const AVDictionaryEntry title_entry;
> > + int title_length = 0;
> > + char title_contents;
> 
> 
> const please. Also we put the * to the variable (because "char* foo,
> bar" still only declares one pointer to char). Furthermore, the scope
> for this should be the block below.
> 
> > + AVStream st;
> > +
> > + if (s->nb_streams > 1) {
> > + av_log(s, AV_LOG_WARNING, "Got more than one stream to encode. This is 
> > not supported.\n");
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + st = s->streams[0];
> > + if (st->codecpar->ch_layout.nb_channels != 1 && 
> > st->codecpar->ch_layout.nb_channels != 2) {
> > + av_log(s, AV_LOG_ERROR, "Invalid amount of channels to mux (%d).\n", 
> > st->codecpar->ch_layout.nb_channels);
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + if (st->codecpar->sample_rate != 44100) {
> > + av_log(s, AV_LOG_ERROR, "Invalid sample rate (%d) AEA only supports 
> > 44.1kHz.\n", st->codecpar->sample_rate);
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + / Write magic /
> > + avio_wl32(s->pb, 2048);
> > +
> > + / Write AEA title */
> > + title_entry = av_dict_get(st->metadata, "title", NULL, 0);
> > + if (title_entry) {
> > + title_contents = title_entry->value;
> > + title_length = strlen(title_contents);
> 
> 
> Possible truncation here.
> 
> > + title_length = FFMIN(256, title_length);
> > + avio_write(s->pb, title_contents, title_length);
> > + }
> > +
> > + ffio_fill(s->pb, 0, 256 - title_length);
> > +
> > + /* Write number of frames (zero at header-writing time, will seek later), 
> > number of channels /
> > + avio_wl32(s->pb, 0);
> > + avio_w8(s->pb, st->codecpar->ch_layout.nb_channels);
> > + avio_w8(s->pb, 0);
> > +
> > + / Pad the header to 2048 bytes */
> > + ffio_fill(s->pb, 0, 1782);
> > +
> > + return 0;
> > +}
> > +
> > +static int aea_write_trailer(struct AVFormatContext *s)
> > +{
> > + AVIOContext *pb = s->pb;
> > + AVStream st = s->streams[0];
> > + if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
> > + / Seek to rewrite the block count. */
> > + avio_seek(pb, 260, SEEK_SET);
> > + avio_wl32(pb, st->nb_frames * st->codecpar->ch_layout.nb_channels);
> 
> 
> I don't see anything guaranteeing that the result fits into 32 bits.
> 
> > + } else {
> > + av_log(s, AV_LOG_WARNING, "unable to rewrite AEA header.\n");
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +const FFOutputFormat ff_aea_muxer = {
> > + .p.name = "aea",
> > + .p.long_name = NULL_IF_CONFIG_SMALL("MD STUDIO audio"),
> > + .p.extensions = "aea",
> > + .p.audio_codec = AV_CODEC_ID_ATRAC1,
> > +
> > + .write_header = aea_write_header,
> > + .write_packet = ff_raw_write_packet,
> > + .write_trailer = aea_write_trailer,
> > +};
> 
> 
> ___
> 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".From ee1d4c93c66e729d9d0456b2e8e789f3f98389e3 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Fri, 8 Mar 2024 14:45:02 +010

Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-08 Thread asivery via ffmpeg-devel
Thank you for your incredibly thorough and fast response. I've applied all the 
corrections you requested. Please let me know if there's anything else wrong 
with my patch, and thank you for your time.

- asivery

On Friday, March 8th, 2024 at 1:06 PM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > +typedef struct {
> > + int block_count;
> > +} AeaMuxerContext;
> > +
> > +static int aea_init(AVFormatContext *s)
> > +{
> > + AeaMuxerContext *c = s->priv_data;
> > + c->block_count = 0;
> 
> 
> Unnecessary: A muxer's priv_data is always pre-zeroed.
> 
> > +
> > + return 0;
> > +}
> > +
> > +static int aea_write_header(AVFormatContext *s)
> > +{
> > + AVDictionaryEntry *title_entry;
> 
> 
> const
> 
> > + int title_length = 0, i;
> > + char* title_contents;
> > + AVStream *st;
> > +
> > +
> > + if (s->nb_streams > 1) {
> > + av_log(s, AV_LOG_WARNING, "Got more than one stream to encode, they will 
> > be ignored.\n");
> 
> 
> We don't ignore extraneous streams, we normally error out if something
> like this happens.
> 
> > + }
> > +
> > + st = s->streams[0];
> > + if (st->codecpar->ch_layout.nb_channels != 1 && 
> > st->codecpar->ch_layout.nb_channels != 2) {
> > + av_log(s, AV_LOG_ERROR, "Invalid amount of channels to mux (%d).\n", 
> > st->codecpar->ch_layout.nb_channels);
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + if (st->codecpar->sample_rate != 44100) {
> > + av_log(s, AV_LOG_ERROR, "Invalid sample rate (%d) AEA only supports 
> > 44.1kHz.\n", st->codecpar->sample_rate);
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + /* Write magic /
> > + avio_wl32(s->pb, 2048);
> > +
> > + / Write AEA title */
> > + title_entry = av_dict_get(st->metadata, "title", NULL, 0);
> > + if (title_entry) {
> > + title_contents = title_entry->value;
> > + title_length = FFMIN(256, strlen(title_contents));
> 
> 
> Don't use strlen() in FFMIN (like many macros, it can evaluate its
> argument multiple times).
> 
> > + }
> > +
> > + if (title_length) {
> > + avio_write(s->pb, title_contents, title_length);
> > + }
> 
> 
> No need for this branch, just call this inside the "if (title_entry)"
> block above.
> 
> > +
> > + for (i = 0; i<(256 - title_length); i++) {
> > + avio_w8(s->pb, 0);
> > + }
> 
> 
> ffio_fill(). Same below.
> 
> > +
> > + /* Write number of frames (zero at header-writing time, will seek later), 
> > number of channels /
> > + avio_wl32(s->pb, 0);
> > + avio_w8(s->pb, st->codecpar->ch_layout.nb_channels);
> > + avio_w8(s->pb, 0);
> > +
> > + / Write flags (meaning unknown) /
> > + for(i = 0; i<11; i++) {
> > + avio_wl32(s->pb, 0);
> > + }
> > +
> > + / Pad the header to 2048 bytes */
> > + for(i = 0; i<1738; i++) avio_w8(s->pb, 0);
> > +
> > + return 0;
> > +}
> > +
> > +static int aea_write_packet(struct AVFormatContext *s, AVPacket *pkt)
> > +{
> > + AeaMuxerContext *c = s->priv_data;
> > + c->block_count++;
> > +
> > + avio_write(s->pb, pkt->data, pkt->size);
> > + return 0;
> 
> 
> You can avoid this and the whole muxer context by using
> ff_raw_write_packet() and relying on AVStream.nb_frames.
> 
> > +}
> > +
> > +static int aea_write_trailer(struct AVFormatContext *s)
> > +{
> > + AVIOContext *pb = s->pb;
> > + AeaMuxerContext c = s->priv_data;
> > + if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
> > + / Seek to rewrite the block count. */
> > + avio_seek(pb, 260, SEEK_SET);
> > + avio_wl32(pb, c->block_count * 
> > s->streams[0]->codecpar->ch_layout.nb_channels);
> > + } else {
> > + av_log(s, AV_LOG_WARNING, "unable to rewrite AEA header.\n");
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +const FFOutputFormat ff_aea_muxer = {
> > + .p.name = "aea",
> > + .p.long_name = NULL_IF_CONFIG_SMALL("MD STUDIO audio"),
> > + .priv_data_size = sizeof(AeaMuxerContext),
> > + .p.extensions = "aea",
> > + .p.audio_codec = AV_CODEC_ID_ATRAC1,
> > + .init = aea_init,
> > +
> > + .write_header = aea_write_header,
> > + .write_packet = aea_write_packet,
> > + .write_trailer = aea_write_trailer,
> > + .p.flags 

Re: [FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-08 Thread asivery via ffmpeg-devel
Apologies for my oversight.
I've attached the new patch. 

- asivery

On Friday, March 8th, 2024 at 12:22 PM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index b04b43cab3..1a50181447 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -46,6 +46,7 @@ extern const FFOutputFormat ff_adts_muxer;
> > extern const AVInputFormat ff_adx_demuxer;
> > extern const FFOutputFormat ff_adx_muxer;
> > extern const AVInputFormat ff_aea_demuxer;
> > +extern const FFOutputFormat ff_aea_muxer;
> > extern const AVInputFormat ff_afc_demuxer;
> > extern const AVInputFormat ff_aiff_demuxer;
> > extern const FFOutputFormat ff_aiff_muxer;
> > --
> 
> 
> Resend the patch rebased on current master.
> 
> - Andreas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".From 9323316c9f82a11211ae2e7cb9d8fde5e06772b0 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Fri, 8 Mar 2024 12:44:03 +0100
Subject: [PATCH] avformat/aea: Add aea muxer

Signed-off-by: asivery 
---
 libavformat/Makefile|   3 +-
 libavformat/{aea.c => aeadec.c} |   0
 libavformat/aeaenc.c| 134 
 libavformat/allformats.c|   1 +
 4 files changed, 137 insertions(+), 1 deletion(-)
 rename libavformat/{aea.c => aeadec.c} (100%)
 create mode 100644 libavformat/aeaenc.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8811a0ffc9..52e0b1dcad 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_ADTS_MUXER)+= adtsenc.o apetag.o img2.o \
 id3v2enc.o
 OBJS-$(CONFIG_ADX_DEMUXER)   += adxdec.o
 OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
-OBJS-$(CONFIG_AEA_DEMUXER)   += aea.o pcm.o
+OBJS-$(CONFIG_AEA_DEMUXER)   += aeadec.o pcm.o
+OBJS-$(CONFIG_AEA_MUXER) += aeaenc.o
 OBJS-$(CONFIG_AFC_DEMUXER)   += afc.o
 OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o aiff.o pcm.o \
 mov_chan.o replaygain.o
diff --git a/libavformat/aea.c b/libavformat/aeadec.c
similarity index 100%
rename from libavformat/aea.c
rename to libavformat/aeadec.c
diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c
new file mode 100644
index 000000..3ce4cec1ee
--- /dev/null
+++ b/libavformat/aeaenc.c
@@ -0,0 +1,134 @@
+/*
+ * MD STUDIO audio muxer
+ *
+ * Copyright (c) 2024 asivery
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "mux.h"
+
+typedef struct {
+int block_count;
+} AeaMuxerContext;
+
+static int aea_init(AVFormatContext *s)
+{
+AeaMuxerContext *c = s->priv_data;
+c->block_count = 0;
+
+return 0;
+}
+
+static int aea_write_header(AVFormatContext *s)
+{
+AVDictionaryEntry *title_entry;
+int title_length = 0, i;
+char* title_contents;
+AVStream *st;
+
+
+if (s->nb_streams > 1) {
+av_log(s, AV_LOG_WARNING, "Got more than one stream to encode, they will be ignored.\n");
+}
+
+st = s->streams[0];
+if (st->codecpar->ch_layout.nb_channels != 1 && st->codecpar->ch_layout.nb_channels != 2) {
+av_log(s, AV_LOG_ERROR, "Invalid amount of channels to mux (%d).\n", st->codecpar->ch_layout.nb_channels);
+return AVERROR(EINVAL);
+}
+
+if (st->codecpar->sample_rate != 44100) {
+av_log(s, AV_LOG_ERROR, "Invalid sample rate (%d) AEA only supports 44.1kHz.\n", st->codecpar->sample_rate);
+return AVERROR(EINVAL);
+}
+
+/* Write magic */
+avio_wl32

[FFmpeg-devel] [PATCH] avformat/aea: Add aea muxer

2024-03-08 Thread asivery via ffmpeg-devel
Empty MessageFrom 955fc035abbb5cfc1a52b1a5ea6900e4a21cef12 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Fri, 8 Mar 2024 11:17:51 +0100
Subject: [PATCH] avformat/aea: Add aea muxer

Signed-off-by: asivery 
---
 libavformat/Makefile|   3 +-
 libavformat/{aea.c => aeadec.c} |   0
 libavformat/aeaenc.c| 134 
 libavformat/allformats.c|   1 +
 4 files changed, 137 insertions(+), 1 deletion(-)
 rename libavformat/{aea.c => aeadec.c} (100%)
 create mode 100644 libavformat/aeaenc.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4a380668bd..9855dcc707 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_ADTS_MUXER)+= adtsenc.o apetag.o img2.o \
 id3v2enc.o
 OBJS-$(CONFIG_ADX_DEMUXER)   += adxdec.o
 OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
-OBJS-$(CONFIG_AEA_DEMUXER)   += aea.o pcm.o
+OBJS-$(CONFIG_AEA_DEMUXER)   += aeadec.o pcm.o
+OBJS-$(CONFIG_AEA_MUXER) += aeaenc.o
 OBJS-$(CONFIG_AFC_DEMUXER)   += afc.o
 OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o aiff.o pcm.o \
 mov_chan.o replaygain.o
diff --git a/libavformat/aea.c b/libavformat/aeadec.c
similarity index 100%
rename from libavformat/aea.c
rename to libavformat/aeadec.c
diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c
new file mode 100644
index 00..3ce4cec1ee
--- /dev/null
+++ b/libavformat/aeaenc.c
@@ -0,0 +1,134 @@
+/*
+ * MD STUDIO audio muxer
+ *
+ * Copyright (c) 2024 asivery
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
+#include "avformat.h"
+#include "mux.h"
+
+typedef struct {
+int block_count;
+} AeaMuxerContext;
+
+static int aea_init(AVFormatContext *s)
+{
+AeaMuxerContext *c = s->priv_data;
+c->block_count = 0;
+
+return 0;
+}
+
+static int aea_write_header(AVFormatContext *s)
+{
+AVDictionaryEntry *title_entry;
+int title_length = 0, i;
+char* title_contents;
+AVStream *st;
+
+
+if (s->nb_streams > 1) {
+av_log(s, AV_LOG_WARNING, "Got more than one stream to encode, they will be ignored.\n");
+}
+
+st = s->streams[0];
+if (st->codecpar->ch_layout.nb_channels != 1 && st->codecpar->ch_layout.nb_channels != 2) {
+av_log(s, AV_LOG_ERROR, "Invalid amount of channels to mux (%d).\n", st->codecpar->ch_layout.nb_channels);
+return AVERROR(EINVAL);
+}
+
+if (st->codecpar->sample_rate != 44100) {
+av_log(s, AV_LOG_ERROR, "Invalid sample rate (%d) AEA only supports 44.1kHz.\n", st->codecpar->sample_rate);
+return AVERROR(EINVAL);
+}
+
+/* Write magic */
+avio_wl32(s->pb, 2048);
+
+/* Write AEA title */
+title_entry = av_dict_get(st->metadata, "title", NULL, 0);
+if (title_entry) {
+title_contents = title_entry->value;
+title_length = FFMIN(256, strlen(title_contents));
+}
+
+if (title_length) {
+avio_write(s->pb, title_contents, title_length);
+}
+
+for (i = 0; i<(256 - title_length); i++) {
+avio_w8(s->pb, 0);
+}
+
+/* Write number of frames (zero at header-writing time, will seek later), number of channels */
+avio_wl32(s->pb, 0);
+avio_w8(s->pb, st->codecpar->ch_layout.nb_channels);
+avio_w8(s->pb, 0);
+
+/* Write flags (meaning unknown) */ 
+for(i = 0; i<11; i++) {
+avio_wl32(s->pb, 0);
+}
+
+/* Pad the header to 2048 bytes */
+for(i = 0; i<1738; i++) avio_w8(s->pb, 0);
+
+return 0;
+}
+
+static int aea_write_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+AeaMuxerContext *c = s->priv_data;
+c->block_count++;
+
+avio_write(s->pb, pkt->data, pkt->size);
+return 0;
+}
+
+static int aea_write_trailer(struct AVFormatContext *s)
+{
+AVIOContext *pb

Re: [FFmpeg-devel] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

2024-02-12 Thread asivery via ffmpeg-devel
I've attached the updated patch. Both new entries are now placed in an 
alphabetically correct way in their appropriate lists.

On Monday, February 12th, 2024 at 11:53 AM, Andreas Rheinhardt 
 wrote:

> asivery via ffmpeg-devel:
> 
> > I apologize for not having responded earlier.
> > I've attached the updated patch.
> > 
> > From 68c77320954e44a7f02e95537fc9a6436da7549c Mon Sep 17 00:00:00 2001
> > From: asivery asiv...@protonmail.com
> > Date: Sun, 11 Feb 2024 23:13:07 +0100
> > Subject: [PATCH] avformat/matroska: Add support for A_ATRAC/AT1
> > 
> > Signed-off-by: asivery asiv...@protonmail.com
> > ---
> 
> 
> Send your patch either via git send-email or as an attachment; if you
> have comments for your patch (that are not supposed to be part of the
> eventual commit and not its commit message), then put them here, in
> between the --- and the affected files.
> 
> > libavformat/matroska.c | 1 +
> > libavformat/matroskadec.c | 8 
> > libavformat/matroskaenc.c | 1 +
> > 3 files changed, 10 insertions(+)
> > 
> > diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> > index 5878594e68..ae9ecc8207 100644
> > --- a/libavformat/matroska.c
> > +++ b/libavformat/matroska.c
> > @@ -53,6 +53,7 @@ const CodecTags ff_mkv_codec_tags[]={
> > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
> > {"A_REAL/COOK" , AV_CODEC_ID_COOK},
> > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
> > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
> 
> 
> This audio part of this list is ordered by the Matroska CodecID (i.e.
> the string on the left). Please keep it that way.
> 
> > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
> > {"A_TTA1" , AV_CODEC_ID_TTA},
> > {"A_VORBIS" , AV_CODEC_ID_VORBIS},
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index 8f000f86be..1bb6e8605a 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -2779,6 +2779,14 @@ static int mka_parse_audio_codec(MatroskaTrack 
> > *track, AVCodecParameters par,
> > return AVERROR(ENOMEM);
> > break;
> > }
> > + case AV_CODEC_ID_ATRAC1:
> > + / ATRAC1 uses a constant frame size.
> > + * Typical ATRAC1 streams are either mono or stereo.
> > + * At most, ATRAC1 was used to store 8 channels of audio. */
> > + if (track->audio.channels > 8)
> > + return AVERROR_INVALIDDATA;
> > + par->block_align = track->audio.channels * 212;
> > + break;
> > case AV_CODEC_ID_FLAC:
> > if (track->codec_priv.size) {
> > ret = matroska_parse_flac(s, track, extradata_offset);
> > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> > index 1457a6890c..aa25657f8f 100644
> > --- a/libavformat/matroskaenc.c
> > +++ b/libavformat/matroskaenc.c
> > @@ -3483,6 +3483,7 @@ static const AVCodecTag additional_audio_tags[] = {
> > { AV_CODEC_ID_QDM2, 0x },
> > { AV_CODEC_ID_RA_144, 0x },
> > { AV_CODEC_ID_TRUEHD, 0x },
> > + { AV_CODEC_ID_ATRAC1, 0xFFFF },
> 
> 
> Please keep this list sorted alphabetically.
> 
> > { AV_CODEC_ID_NONE, 0x }
> > };
> 
> 
> ___
> 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".From a530931ebba6638b095720c222b72d2f3d5b0bd1 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Mon, 12 Feb 2024 19:01:32 +0100
Subject: [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

Signed-off-by: asivery 
---
 libavformat/matroska.c| 1 +
 libavformat/matroskadec.c | 8 
 libavformat/matroskaenc.c | 1 +
 3 files changed, 10 insertions(+)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 5878594e68..d0ecfbeb6a 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -28,6 +28,7 @@ const CodecTags ff_mkv_codec_tags[]={
 {"A_AAC", AV_CODEC_ID_AAC},
 {"A_AC3", AV_CODEC_ID_AC3},
 {"A_ALAC"   , AV_CODEC_ID_ALAC},
+{"A_ATRAC/AT1"  , AV_CODEC_ID_ATRAC1},
 {"A_DTS", AV_CODEC_ID_DTS},
 {"A_EAC3"   , AV_CODEC_ID_EAC3},
 {"A_FLAC"   , AV_CODEC_ID_FLAC},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8f000f86be..5d3d18a146 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2779,6 +2779,14 @@ static int mka_parse_audio_codec(MatroskaTrack *track

Re: [FFmpeg-devel] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

2024-02-11 Thread asivery via ffmpeg-devel
I apologize for not having responded earlier.
I've attached the updated patch.


>From 68c77320954e44a7f02e95537fc9a6436da7549c Mon Sep 17 00:00:00 2001
From: asivery 
Date: Sun, 11 Feb 2024 23:13:07 +0100
Subject: [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

Signed-off-by: asivery 
---
 libavformat/matroska.c| 1 +
 libavformat/matroskadec.c | 8 
 libavformat/matroskaenc.c | 1 +
 3 files changed, 10 insertions(+)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 5878594e68..ae9ecc8207 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -53,6 +53,7 @@ const CodecTags ff_mkv_codec_tags[]={
 {"A_REAL/ATRC"  , AV_CODEC_ID_ATRAC3},
 {"A_REAL/COOK"  , AV_CODEC_ID_COOK},
 {"A_REAL/SIPR"  , AV_CODEC_ID_SIPR},
+{"A_ATRAC/AT1"  , AV_CODEC_ID_ATRAC1},
 {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
 {"A_TTA1"   , AV_CODEC_ID_TTA},
 {"A_VORBIS" , AV_CODEC_ID_VORBIS},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8f000f86be..1bb6e8605a 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2779,6 +2779,14 @@ static int mka_parse_audio_codec(MatroskaTrack *track, 
AVCodecParameters *par,
 return AVERROR(ENOMEM);
 break;
 }
+case AV_CODEC_ID_ATRAC1:
+/* ATRAC1 uses a constant frame size.
+ * Typical ATRAC1 streams are either mono or stereo.
+ * At most, ATRAC1 was used to store 8 channels of audio. */
+if (track->audio.channels > 8)
+return AVERROR_INVALIDDATA;
+par->block_align = track->audio.channels * 212;
+break;
 case AV_CODEC_ID_FLAC:
 if (track->codec_priv.size) {
 ret = matroska_parse_flac(s, track, extradata_offset);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1457a6890c..aa25657f8f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -3483,6 +3483,7 @@ static const AVCodecTag additional_audio_tags[] = {
 { AV_CODEC_ID_QDM2,  0x },
 { AV_CODEC_ID_RA_144,0x },
 { AV_CODEC_ID_TRUEHD,0x },
+{ AV_CODEC_ID_ATRAC1,0x },
 { AV_CODEC_ID_NONE,  0x }
 };
 
-- 
2.34.1





On Friday, August 4th, 2023 at 7:30 PM, Andreas Rheinhardt 
 wrote:

> Andreas Rheinhardt:
> 
> > asivery:
> > 
> > > Signed-off-by: asivery asiv...@protonmail.com
> > > ---
> > > libavformat/matroska.c | 1 +
> > > libavformat/matroskadec.c | 2 ++
> > > 2 files changed, 3 insertions(+)
> > > 
> > > diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> > > index 90d94b65bf..37305a523c 100644
> > > --- a/libavformat/matroska.c
> > > +++ b/libavformat/matroska.c
> > > @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={
> > > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
> > > {"A_REAL/COOK" , AV_CODEC_ID_COOK},
> > > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
> > > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
> > > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
> > > {"A_TTA1" , AV_CODEC_ID_TTA},
> > > {"A_VORBIS" , AV_CODEC_ID_VORBIS},
> > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > index d582f566a2..0aa8e6f3b3 100644
> > > --- a/libavformat/matroskadec.c
> > > +++ b/libavformat/matroskadec.c
> > > @@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext s)
> > > track->audio.frame_size);
> > > if (!track->audio.buf)
> > > return AVERROR(ENOMEM);
> > > + } else if (codec_id == AV_CODEC_ID_ATRAC1) {
> > > + st->codecpar->block_align = track->audio.channels * 212; / Constant 
> > > ATRAC frame size */
> > > } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
> > > ret = matroska_parse_flac(s, track, _offset);
> > > if (ret < 0)
> > > --
> > > 2.34.1
> > 
> > This patch is broken. The indentation is off.
> > 
> > - Andreas
> 
> 
> Apart from this: The result of the multiplication may not fit into an
> int; looking at the other atrac1 code it seems that we only support mono
> and stereo files. Is this a limitation of FFmpeg or of the format?
> 
> - Andreas
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

2023-06-28 Thread asivery
Hi, it's really not a problem. Thanks and please let me know if I need to 
change anything for this to be merged.

--- Original Message ---
On Saturday, June 17th, 2023 at 3:41 AM, Andreas Rheinhardt 
 wrote:


> asivery:
> 
> > Hello, apologies for bothering you all with this, but if anyone could take 
> > a look at this patch it would be great. The only other container that 
> > supports ATRAC1 is AEA, and it's not that good of a format since it has no 
> > magic number, and therefore is easily detected incorrectly.
> > 
> > Thank you in advance.
> 
> 
> Sorry for having missed this. I will look at it tomorrow.
> 
> - Andreas
> 
> > --- Original Message ---
> > On Monday, April 17th, 2023 at 2:27 AM, asivery asiv...@protonmail.com 
> > wrote:
> > 
> > > I'd appreciate it if someone took a look at this.
> > > If there's anything I need to change to make this patch viable for 
> > > merging, please let me know.
> > > 
> > > Best regards,
> > > asivery
> > > --- Original Message ---
> > > On Monday, March 6th, 2023 at 7:51 PM, asivery asiv...@protonmail.com 
> > > wrote:
> > > 
> > > > It's been added recently. Here's the definition: 
> > > > https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md#a_atracat1
> > > > 
> > > > --- Original Message ---
> > > > On Monday, March 6th, 2023 at 7:39 PM, Paul B Mahol one...@gmail.com 
> > > > wrote:
> > > > 
> > > > > On 3/6/23, asivery asiv...@protonmail.com wrote:
> > > > > 
> > > > > > Signed-off-by: asivery asiv...@protonmail.com
> > > > > > ---
> > > > > > libavformat/matroska.c | 1 +
> > > > > > libavformat/matroskadec.c | 2 ++
> > > > > > 2 files changed, 3 insertions(+)
> > > > > 
> > > > > where is this defined?
> > > > > 
> > > > > > diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> > > > > > index 90d94b65bf..37305a523c 100644
> > > > > > --- a/libavformat/matroska.c
> > > > > > +++ b/libavformat/matroska.c
> > > > > > @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={
> > > > > > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
> > > > > > {"A_REAL/COOK" , AV_CODEC_ID_COOK},
> > > > > > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
> > > > > > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
> > > > > > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
> > > > > > {"A_TTA1" , AV_CODEC_ID_TTA},
> > > > > > {"A_VORBIS" , AV_CODEC_ID_VORBIS},
> > > > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > > > > index d582f566a2..0aa8e6f3b3 100644
> > > > > > --- a/libavformat/matroskadec.c
> > > > > > +++ b/libavformat/matroskadec.c
> > > > > > @@ -2795,6 +2795,8 @@ static int 
> > > > > > matroska_parse_tracks(AVFormatContext s)
> > > > > > track->audio.frame_size);
> > > > > > if (!track->audio.buf)
> > > > > > return AVERROR(ENOMEM);
> > > > > > + } else if (codec_id == AV_CODEC_ID_ATRAC1) {
> > > > > > + st->codecpar->block_align = track->audio.channels * 212; / 
> > > > > > Constant ATRAC
> > > > > > frame size */
> > > > > > } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
> > > > > > ret = matroska_parse_flac(s, track, _offset);
> > > > > > if (ret < 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 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] avformat/matroska: Add support for A_ATRAC/AT1

2023-06-16 Thread asivery
Hello, apologies for bothering you all with this, but if anyone could take a 
look at this patch it would be great. The only other container that supports 
ATRAC1 is AEA, and it's not that good of a format since it has no magic number, 
and therefore is easily detected incorrectly.

Thank you in advance.

--- Original Message ---
On Monday, April 17th, 2023 at 2:27 AM, asivery  wrote:


> I'd appreciate it if someone took a look at this.
> If there's anything I need to change to make this patch viable for merging, 
> please let me know.
> 
> Best regards,
> asivery
> --- Original Message ---
> On Monday, March 6th, 2023 at 7:51 PM, asivery asiv...@protonmail.com wrote:
> 
> 
> 
> > It's been added recently. Here's the definition: 
> > https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md#a_atracat1
> > 
> > --- Original Message ---
> > On Monday, March 6th, 2023 at 7:39 PM, Paul B Mahol one...@gmail.com wrote:
> > 
> > > On 3/6/23, asivery asiv...@protonmail.com wrote:
> > > 
> > > > Signed-off-by: asivery asiv...@protonmail.com
> > > > ---
> > > > libavformat/matroska.c | 1 +
> > > > libavformat/matroskadec.c | 2 ++
> > > > 2 files changed, 3 insertions(+)
> > > 
> > > where is this defined?
> > > 
> > > > diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> > > > index 90d94b65bf..37305a523c 100644
> > > > --- a/libavformat/matroska.c
> > > > +++ b/libavformat/matroska.c
> > > > @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={
> > > > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
> > > > {"A_REAL/COOK" , AV_CODEC_ID_COOK},
> > > > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
> > > > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
> > > > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
> > > > {"A_TTA1" , AV_CODEC_ID_TTA},
> > > > {"A_VORBIS" , AV_CODEC_ID_VORBIS},
> > > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > > > index d582f566a2..0aa8e6f3b3 100644
> > > > --- a/libavformat/matroskadec.c
> > > > +++ b/libavformat/matroskadec.c
> > > > @@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext 
> > > > s)
> > > > track->audio.frame_size);
> > > > if (!track->audio.buf)
> > > > return AVERROR(ENOMEM);
> > > > + } else if (codec_id == AV_CODEC_ID_ATRAC1) {
> > > > + st->codecpar->block_align = track->audio.channels * 212; / Constant 
> > > > ATRAC
> > > > frame size */
> > > > } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
> > > > ret = matroska_parse_flac(s, track, _offset);
> > > > if (ret < 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 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] libavformat/aea EOF Patch

2023-03-08 Thread asivery
Thank you very much, indeed that works as well.
Here's the updated patch.

Best regards.

---
diff --git a/libavformat/aea.c b/libavformat/aea.c
index f4b39e4f9e..d16217381b 100644
--- a/libavformat/aea.c
+++ b/libavformat/aea.c
@@ -90,13 +90,7 @@ static int aea_read_header(AVFormatContext *s)
 
 static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
-
-pkt->stream_index = 0;
-if (ret <= 0)
-return AVERROR(EIO);
-
-return ret;
+return av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
 }
 
 const AVInputFormat ff_aea_demuxer = {

--- Original Message ---
On Thursday, March 9th, 2023 at 12:28 AM, Marton Balint  wrote:


> 
> On Sat, 4 Mar 2023, asivery wrote:
> 
> > Could someone please take a look? This would improve AEA demuxing, right 
> > now every AEA file makes ffmpeg crash with an error.
> 
> 
> The way I see it, you could simply replace the whole body of
> aea_read_packet() with this single line:
> 
> return av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
> 
> 
> Regards,
> Marton
> 
> > Thank you in advance :)
> > --- Original Message ---
> > On Saturday, October 22nd, 2022 at 7:43 PM, asivery asiv...@protonmail.com 
> > wrote:
> > 
> > > Hello,
> > > This patch aims to fix a problem I've noticed while working with AEA 
> > > (Sony ATRAC1 comtainer) files.
> > > Right now FFmpeg always exits with an "Input/Output error" when dealing 
> > > with AEA files.
> > > This patch solves that issue by returning AVERROR_EOF once the end of 
> > > file is encountered, instead of always returning AVERROR(EIO).
> > > 
> > > I am sending this patch again because of an incorrect mime type of the 
> > > first one.
> > > 
> > > Best regards,Asivery
> > > ___
> > > 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] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1

2023-03-06 Thread asivery
It's been added recently. Here's the definition: 
https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md#a_atracat1


--- Original Message ---
On Monday, March 6th, 2023 at 7:39 PM, Paul B Mahol  wrote:


> On 3/6/23, asivery asiv...@protonmail.com wrote:
> 
> > Signed-off-by: asivery asiv...@protonmail.com
> > ---
> > libavformat/matroska.c | 1 +
> > libavformat/matroskadec.c | 2 ++
> > 2 files changed, 3 insertions(+)
> 
> 
> where is this defined?
> 
> > diff --git a/libavformat/matroska.c b/libavformat/matroska.c
> > index 90d94b65bf..37305a523c 100644
> > --- a/libavformat/matroska.c
> > +++ b/libavformat/matroska.c
> > @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={
> > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
> > {"A_REAL/COOK" , AV_CODEC_ID_COOK},
> > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
> > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
> > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
> > {"A_TTA1" , AV_CODEC_ID_TTA},
> > {"A_VORBIS" , AV_CODEC_ID_VORBIS},
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index d582f566a2..0aa8e6f3b3 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext s)
> > track->audio.frame_size);
> > if (!track->audio.buf)
> > return AVERROR(ENOMEM);
> > + } else if (codec_id == AV_CODEC_ID_ATRAC1) {
> > + st->codecpar->block_align = track->audio.channels * 212; / Constant ATRAC
> > frame size */
> > } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
> > ret = matroska_parse_flac(s, track, _offset);
> > if (ret < 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 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] avformat/matroska: Add support for A_ATRAC/AT1

2023-03-05 Thread asivery
Signed-off-by: asivery 
---
libavformat/matroska.c | 1 +
libavformat/matroskadec.c | 2 ++
2 files changed, 3 insertions(+)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 90d94b65bf..37305a523c 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={
{"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3},
{"A_REAL/COOK" , AV_CODEC_ID_COOK},
{"A_REAL/SIPR" , AV_CODEC_ID_SIPR},
+ {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1},
{"A_TRUEHD" , AV_CODEC_ID_TRUEHD},
{"A_TTA1" , AV_CODEC_ID_TTA},
{"A_VORBIS" , AV_CODEC_ID_VORBIS},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d582f566a2..0aa8e6f3b3 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
track->audio.frame_size);
if (!track->audio.buf)
return AVERROR(ENOMEM);
+ } else if (codec_id == AV_CODEC_ID_ATRAC1) {
+ st->codecpar->block_align = track->audio.channels * 212; /* Constant ATRAC 
frame size */
} else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
ret = matroska_parse_flac(s, track, _offset);
if (ret < 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".


Re: [FFmpeg-devel] [PATCH] libavformat/aea EOF Patch

2023-03-04 Thread asivery
Could someone please take a look? This would improve AEA demuxing, right now 
every AEA file makes ffmpeg crash with an error.
Thank you in advance :)
--- Original Message ---
On Saturday, October 22nd, 2022 at 7:43 PM, asivery  
wrote:

> Hello,
> This patch aims to fix a problem I've noticed while working with AEA (Sony 
> ATRAC1 comtainer) files.
> Right now FFmpeg always exits with an "Input/Output error" when dealing with 
> AEA files.
> This patch solves that issue by returning AVERROR_EOF once the end of file is 
> encountered, instead of always returning AVERROR(EIO).
>
> I am sending this patch again because of an incorrect mime type of the first 
> one.
>
> Best regards,Asivery
___
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] libavformat/aea EOF Patch

2022-10-22 Thread asivery
Hello,
This patch aims to fix a problem I've noticed while working with AEA (Sony 
ATRAC1 comtainer) files.
Right now FFmpeg always exits with an "Input/Output error" when dealing with 
AEA files.
This patch solves that issue by returning AVERROR_EOF once the end of file is 
encountered, instead of always returning AVERROR(EIO).

I am sending this patch again because of an incorrect mime type of the first 
one.

Best regards,AsiveryFrom cc127ff24d82a04611fac14cf4114a2262f87111 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Tue, 27 Sep 2022 00:13:10 +0200
Subject: [PATCH] avformat/aea: Make it so the AEA demuxer returns EOF at the
 end of file instead of EIO

Signed-off-by: asivery 
---
 libavformat/aea.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/aea.c b/libavformat/aea.c
index f4b39e4f9e..d721398cf5 100644
--- a/libavformat/aea.c
+++ b/libavformat/aea.c
@@ -93,8 +93,11 @@ static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
 int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
 
 pkt->stream_index = 0;
-if (ret <= 0)
-return AVERROR(EIO);
+if (ret <= 0){
+if(ret < 0)
+return ret;
+return AVERROR_EOF;
+}
 
 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".