diff mbox

[FFmpeg-devel] lavf/amr: Add amrnb and amrwb demuxers

Message ID CAB0OVGoKhgxkMXku4ScJpHA=ABD9uP-q_aG-N+X8A2arFCNCRQ@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos Sept. 27, 2017, 4:08 p.m. UTC
Hi!

The existing amr demuxer does not allow reading streams, it requires
the 3GPP-conforming file header.
Attached patch allows reading amrnb and amrwb from (live) streams,
fixes ticket #6678.

Please comment, Carl Eugen

Comments

wm4 Sept. 27, 2017, 4:40 p.m. UTC | #1
On Wed, 27 Sep 2017 18:08:19 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> Hi!
> 
> The existing amr demuxer does not allow reading streams, it requires
> the 3GPP-conforming file header.
> Attached patch allows reading amrnb and amrwb from (live) streams,
> fixes ticket #6678.
> 
> Please comment, Carl Eugen

That seems particularly pointless, since the user has to force the
demuxers. I don't know what that ticket is, all information should be
in the commit message anyway.
Carl Eugen Hoyos Sept. 27, 2017, 4:47 p.m. UTC | #2
2017-09-27 18:40 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> On Wed, 27 Sep 2017 18:08:19 +0200
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> Hi!
>>
>> The existing amr demuxer does not allow reading streams, it requires
>> the 3GPP-conforming file header.
>> Attached patch allows reading amrnb and amrwb from (live) streams,
>> fixes ticket #6678.
>>
>> Please comment, Carl Eugen
>
> That seems particularly pointless, since the user has to force the
> demuxers.

Like for any other demuxer without auto-detection?

I wasn't able to "force" reading such a stream without this patch,
am I missing something?

> I don't know what that ticket is

Then it may be better not to comment.

Carl Eugen
wm4 Sept. 27, 2017, 4:58 p.m. UTC | #3
On Wed, 27 Sep 2017 18:47:16 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2017-09-27 18:40 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> > On Wed, 27 Sep 2017 18:08:19 +0200
> > Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >  
> >> Hi!
> >>
> >> The existing amr demuxer does not allow reading streams, it requires
> >> the 3GPP-conforming file header.
> >> Attached patch allows reading amrnb and amrwb from (live) streams,
> >> fixes ticket #6678.
> >>
> >> Please comment, Carl Eugen  
> >
> > That seems particularly pointless, since the user has to force the
> > demuxers.  
> 
> Like for any other demuxer without auto-detection?

Actually no.

> I wasn't able to "force" reading such a stream without this patch,
> am I missing something?

Then maybe there should be a mechanism to force stream parameters, just
like they obviously exist for raw audio/video.

> > I don't know what that ticket is  
> 
> Then it may be better not to comment.

It may be better for you not committing anything if you don't know what
commit messages are.
Carl Eugen Hoyos Sept. 27, 2017, 5 p.m. UTC | #4
2017-09-27 18:58 GMT+02:00 wm4 <nfxjfg@googlemail.com>:

> It may be better for you not committing anything if you don't know what
> commit messages are.

I assume this is how you interpret our code-of-conduct
to which you agreed?

Watch your tongue, Carl Eugen
wm4 Sept. 27, 2017, 5:02 p.m. UTC | #5
On Wed, 27 Sep 2017 19:00:04 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2017-09-27 18:58 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> 
> > It may be better for you not committing anything if you don't know what
> > commit messages are.  
> 
> I assume this is how you interpret our code-of-conduct
> to which you agreed?
> 
> Watch your tongue, Carl Eugen

I don't know, you started with this. I only replied with the equivalent.
Carl Eugen Hoyos Sept. 27, 2017, 5:04 p.m. UTC | #6
2017-09-27 19:02 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> On Wed, 27 Sep 2017 19:00:04 +0200
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> 2017-09-27 18:58 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
>>
>> > It may be better for you not committing anything if you don't know what
>> > commit messages are.
>>
>> I assume this is how you interpret our code-of-conduct
>> to which you agreed?
>>
>> Watch your tongue, Carl Eugen
>
> I don't know, you started with this. I only replied with the equivalent.

While this does not sound true to me, I wonder how it is related.

Carl Eugen
wm4 Sept. 27, 2017, 5:08 p.m. UTC | #7
On Wed, 27 Sep 2017 19:04:26 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2017-09-27 19:02 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> > On Wed, 27 Sep 2017 19:00:04 +0200
> > Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> >  
> >> 2017-09-27 18:58 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> >>  
> >> > It may be better for you not committing anything if you don't know what
> >> > commit messages are.  
> >>
> >> I assume this is how you interpret our code-of-conduct
> >> to which you agreed?
> >>
> >> Watch your tongue, Carl Eugen  
> >
> > I don't know, you started with this. I only replied with the equivalent.  
> 
> While this does not sound true to me, 

> I wonder how it is related.

So do I. Maybe you could get back to the technical discussion instead
of this weird nonsense?
Carl Eugen Hoyos Sept. 27, 2017, 5:22 p.m. UTC | #8
2017-09-27 19:08 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
>  Maybe you could get back to the technical discussion

I wish this were so easy with you:

You first wrote:
> That seems particularly pointless, since the user has
> to force the demuxers.

If I understand this sentence correctly, you agree with me
that it should be as easy as possible for users to receive
amrnb and amrwb streams.

It should be added here that the demuxer always has to be
forced - I don't know if auto-detecting amrnb and amrwb
could be done but it is not part of the patch. (But the patch
is a necessary prerequisite for this hypothetical auto-detection).
The question for the user is though: How to force the codec?

Then you wrote:
> Then maybe there should be a mechanism to force
> stream parameters

How does this not contradict your first statement?
It is probably (I did not immediately succeed) possible
to allow users to first force the amr demuxer and - in
addition - force a codec.
But as we - seemingly - agree above that users should
not have to force everything, I considered that actual
patch much more useful.

When you add the fact that you wrote that you refuse
to read a user report to the contradiction, you will
hopefully understand how futile it appears to have
this technical discussion with you.

> instead of this weird nonsense?

Adding personal insults to every single one of your
emails of course significantly strengthen above
reasoning.

Carl Eugen
wm4 Sept. 27, 2017, 5:32 p.m. UTC | #9
On Wed, 27 Sep 2017 19:22:37 +0200
Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2017-09-27 19:08 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> >  Maybe you could get back to the technical discussion  
> 
> I wish this were so easy with you:

Well, it certainly isn't with you.
Ronald S. Bultje Sept. 27, 2017, 5:46 p.m. UTC | #10
Hi guys,

On Wed, Sep 27, 2017 at 1:32 PM, wm4 <nfxjfg@googlemail.com> wrote:

> On Wed, 27 Sep 2017 19:22:37 +0200
> Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
> > 2017-09-27 19:08 GMT+02:00 wm4 <nfxjfg@googlemail.com>:
> > >  Maybe you could get back to the technical discussion
> >
> > I wish this were so easy with you:
>
> Well, it certainly isn't with you.


OK, this discussion is over between you two, please stop it.

@Carl Eugen: I've read the bug report. It's intruiging that the existing
demuxer (as you mentioned, it expects a prefix) works with unicast but not
multicast input. Do you know what's causing this difference?

Ronald
Carl Eugen Hoyos Sept. 27, 2017, 6:09 p.m. UTC | #11
2017-09-27 19:46 GMT+02:00 Ronald S. Bultje <rsbultje@gmail.com>:

> @Carl Eugen: I've read the bug report.

Thank you; sorry that imo, this cannot help in this case;-(
The relevant issue is that live streams or truncated
amr files cannot be handled by the existing demuxer
although they work if the properties are forced with
the new demuxers.

The alternative is to allow forcing properties for the
existing demuxer, this has the disadvantage that it is
more difficult to use (and it would make hypothetical
auto-detection more messy).

> It's intruiging that the existing demuxer (as you mentioned,
> it expects a prefix) works with unicast but not
> multicast input.

I don't think this is correct (as in: "This is impossible") but
I may of course miss something ;-)

Carl Eugen
Carl Eugen Hoyos Sept. 27, 2017, 6:10 p.m. UTC | #12
2017-09-27 20:09 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> 2017-09-27 19:46 GMT+02:00 Ronald S. Bultje <rsbultje@gmail.com>:

>> It's intruiging that the existing demuxer (as you mentioned,
>> it expects a prefix) works with unicast but not
>> multicast input.
>
> I don't think this is correct (as in: "This is impossible") but
> I may of course miss something ;-)

It of course works if you start the listener first but this
doesn't count imo.

Carl Eugen
Ronald S. Bultje Sept. 27, 2017, 6:14 p.m. UTC | #13
Hi,

On Wed, Sep 27, 2017 at 2:10 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com>
wrote:

> 2017-09-27 20:09 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> > 2017-09-27 19:46 GMT+02:00 Ronald S. Bultje <rsbultje@gmail.com>:
>
> >> It's intruiging that the existing demuxer (as you mentioned,
> >> it expects a prefix) works with unicast but not
> >> multicast input.
> >
> > I don't think this is correct (as in: "This is impossible") but
> > I may of course miss something ;-)
>
> It of course works if you start the listener first but this
> doesn't count imo.


Ah, that indeed explains anything, thank you. (In terms of whether to
update the existing demuxer or add a new one, I have no preference.)

Ronald
diff mbox

Patch

From 1b548fbd47f521d0c2a7b443ac2b1f2925e8bb41 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 27 Sep 2017 18:04:39 +0200
Subject: [PATCH] lavf/amr: Add amrnb and amrwb demuxers.

Fixes ticket #6678.
---
 libavformat/Makefile     |    2 ++
 libavformat/allformats.c |    2 ++
 libavformat/amr.c        |   54 ++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/version.h    |    4 ++--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index df709c29..c4c8713 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -87,6 +87,8 @@  OBJS-$(CONFIG_AIFF_MUXER)                += aiffenc.o id3v2enc.o
 OBJS-$(CONFIG_AIX_DEMUXER)               += aixdec.o
 OBJS-$(CONFIG_AMR_DEMUXER)               += amr.o
 OBJS-$(CONFIG_AMR_MUXER)                 += amr.o
+OBJS-$(CONFIG_AMRNB_DEMUXER)             += amr.o
+OBJS-$(CONFIG_AMRWB_DEMUXER)             += amr.o
 OBJS-$(CONFIG_ANM_DEMUXER)               += anm.o
 OBJS-$(CONFIG_APC_DEMUXER)               += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)               += ape.o apetag.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 405ddb5..dc8984e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -63,6 +63,8 @@  static void register_all(void)
     REGISTER_MUXDEMUX(AIFF,             aiff);
     REGISTER_DEMUXER (AIX,              aix);
     REGISTER_MUXDEMUX(AMR,              amr);
+    REGISTER_DEMUXER (AMRNB,            amrnb);
+    REGISTER_DEMUXER (AMRWB,            amrwb);
     REGISTER_DEMUXER (ANM,              anm);
     REGISTER_DEMUXER (APC,              apc);
     REGISTER_DEMUXER (APE,              ape);
diff --git a/libavformat/amr.c b/libavformat/amr.c
index b5194a2..07f2315 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -176,6 +176,60 @@  AVInputFormat ff_amr_demuxer = {
 };
 #endif
 
+#if CONFIG_AMRNB_DEMUXER
+static int amrnb_read_header(AVFormatContext *s)
+{
+    AVStream *st = avformat_new_stream(s, NULL);
+    if (!st)
+        return AVERROR(ENOMEM);
+    st->codecpar->codec_tag      = MKTAG('s', 'a', 'm', 'r');
+    st->codecpar->codec_id       = AV_CODEC_ID_AMR_NB;
+    st->codecpar->sample_rate    = 8000;
+    st->codecpar->channels       = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
+    avpriv_set_pts_info(st, 64, 1, 8000);
+
+    return 0;
+}
+
+AVInputFormat ff_amrnb_demuxer = {
+    .name           = "amrnb",
+    .long_name      = NULL_IF_CONFIG_SMALL("raw AMR-NB"),
+    .priv_data_size = sizeof(AMRContext),
+    .read_header    = amrnb_read_header,
+    .read_packet    = amr_read_packet,
+    .flags          = AVFMT_GENERIC_INDEX,
+};
+#endif
+
+#if CONFIG_AMRWB_DEMUXER
+static int amrwb_read_header(AVFormatContext *s)
+{
+    AVStream *st = avformat_new_stream(s, NULL);
+    if (!st)
+        return AVERROR(ENOMEM);
+    st->codecpar->codec_tag      = MKTAG('s', 'a', 'w', 'b');
+    st->codecpar->codec_id       = AV_CODEC_ID_AMR_WB;
+    st->codecpar->sample_rate    = 16000;
+    st->codecpar->channels       = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
+    avpriv_set_pts_info(st, 64, 1, 16000);
+
+    return 0;
+}
+
+AVInputFormat ff_amrwb_demuxer = {
+    .name           = "amrwb",
+    .long_name      = NULL_IF_CONFIG_SMALL("raw AMR-WB"),
+    .priv_data_size = sizeof(AMRContext),
+    .read_header    = amrwb_read_header,
+    .read_packet    = amr_read_packet,
+    .flags          = AVFMT_GENERIC_INDEX,
+};
+#endif
+
 #if CONFIG_AMR_MUXER
 AVOutputFormat ff_amr_muxer = {
     .name              = "amr",
diff --git a/libavformat/version.h b/libavformat/version.h
index ac6edf7..878917d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,8 +32,8 @@ 
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
-#define LIBAVFORMAT_VERSION_MINOR  82
-#define LIBAVFORMAT_VERSION_MICRO 102
+#define LIBAVFORMAT_VERSION_MINOR  83
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
-- 
1.7.10.4