diff mbox

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

Message ID CAB0OVGqb+L6RJH0CFY+zpnMwuLVQR2YbmBy7BQChkPTdQagAJA@mail.gmail.com
State Withdrawn
Headers show

Commit Message

Carl Eugen Hoyos Oct. 3, 2017, 11:07 p.m. UTC
2017-10-04 1:00 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Tue, Oct 03, 2017 at 12:02:23AM +0200, Carl Eugen Hoyos wrote:
>> 2017-10-02 23:47 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
>> > 2017-10-02 23:02 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
>> >> On Sun, Oct 01, 2017 at 06:23:50PM +0200, Carl Eugen Hoyos wrote:
>> >>> 2017-09-27 18:08 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
>> >>>
>> >>> > 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.
>> >>>
>> >>> New patch with auto-detection attached, passes probecheck.
>> >>>
>> >>> Please comment, Carl Eugen
>> >>
>> >> breaks mingw64
>> >>         libavformat/aviobu
>> >> In file included from src/libavformat/amrnb.c:26:0:
>> >> src/libavcodec/amrnbdata.h:50:5: error: expected identifier before ‘(’ token
>> >>      NO_DATA = 15                          ///< no transmission
>> >>      ^
>> >> make: *** [libavformat/amrnb.o] Error 1
>> >> make: *** Waiting for unfinished jobs....
>> >> STRIP   libavfilter/x86/vf_yadif.o
>> >> STRIP   libavfilter/x86/vf_removegrain.o
>> >> In file included from src/libavformat/amrwb.c:26:0:
>> >> src/libavcodec/amrwbdata.h:64:5: error: expected identifier before ‘(’ token
>> >>      NO_DATA                                ///< no transmission
>> >>      ^
>> >> make: *** [libavformat/amrwb.o] Error 1
>> >
>> > The errors are apparently caused by the following definitions in a mingw header:
>> > #define WSANO_DATA (WSABASEERR + 1004)
>> > #define NO_DATA WSANO_DATA
>>
>> Attached is one possible solution.
>>
>> Please comment, Carl Eugen
>
>>  amrnbdata.h |    2 +-
>>  amrnbdec.c  |    5 +++--
>>  amrwbdata.h |    2 +-
>>  3 files changed, 5 insertions(+), 4 deletions(-)
>> eb545b4abc7d2849db7be8f78abba8a1626a2ba7  0001-lavc-amr-Rename-NO_DATA-as-AMR_NO_DATA.patch
>> From 317dbccb46a02ac997c8826ef4c31b787fc8ce47 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Tue, 3 Oct 2017 00:00:29 +0200
>> Subject: [PATCH] lavc/amr: Rename NO_DATA as AMR_NO_DATA.
>>
>> mingw64 defines NO_DATA in wsa_errnos.h
>> ---
>>  libavcodec/amrnbdata.h |    2 +-
>>  libavcodec/amrnbdec.c  |    5 +++--
>>  libavcodec/amrwbdata.h |    2 +-
>>  3 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h
>> index 435fd99..b38f955 100644
>> --- a/libavcodec/amrnbdata.h
>> +++ b/libavcodec/amrnbdata.h
>> @@ -47,7 +47,7 @@ enum Mode {
>>      MODE_12k2,                            ///< 12.2 kbit/s
>>      MODE_DTX,                             ///< silent frame
>>      N_MODES,                              ///< number of modes
>> -    NO_DATA = 15                          ///< no transmission
>> +    AMR_NO_DATA = 15                      ///< no transmission
>>  };
>>
>>  #define LP_FILTER_ORDER 10        ///< linear predictive coding filter order
>> diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
>> index ea299ac..ae5be5d 100644
>> --- a/libavcodec/amrnbdec.c
>> +++ b/libavcodec/amrnbdec.c
>> @@ -214,8 +214,9 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
>>      p->bad_frame_indicator = (buf[0] & 0x4) != 0x4; // quality bit
>>
>>      if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
>> -        return NO_DATA;
>> +        return AMR_NO_DATA;
>>      }
>
>> +printf("mode: %d, size: %ld, bitmaps_per_mode: %d \n", mode, sizeof(AMRNBFrame), *amr_unpacking_bitmaps_per_mode[mode]);
>
> you missed this line in the patch

(Which crashed the decoder.)

Sorry, fixed patch attached.

Carl Eugen

Comments

Michael Niedermayer Oct. 4, 2017, 6:58 p.m. UTC | #1
On Wed, Oct 04, 2017 at 01:07:34AM +0200, Carl Eugen Hoyos wrote:
> 2017-10-04 1:00 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> > On Tue, Oct 03, 2017 at 12:02:23AM +0200, Carl Eugen Hoyos wrote:
> >> 2017-10-02 23:47 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> >> > 2017-10-02 23:02 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> >> >> On Sun, Oct 01, 2017 at 06:23:50PM +0200, Carl Eugen Hoyos wrote:
> >> >>> 2017-09-27 18:08 GMT+02:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> >> >>>
> >> >>> > 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.
> >> >>>
> >> >>> New patch with auto-detection attached, passes probecheck.
> >> >>>
> >> >>> Please comment, Carl Eugen
> >> >>
> >> >> breaks mingw64
> >> >>         libavformat/aviobu
> >> >> In file included from src/libavformat/amrnb.c:26:0:
> >> >> src/libavcodec/amrnbdata.h:50:5: error: expected identifier before ‘(’ token
> >> >>      NO_DATA = 15                          ///< no transmission
> >> >>      ^
> >> >> make: *** [libavformat/amrnb.o] Error 1
> >> >> make: *** Waiting for unfinished jobs....
> >> >> STRIP   libavfilter/x86/vf_yadif.o
> >> >> STRIP   libavfilter/x86/vf_removegrain.o
> >> >> In file included from src/libavformat/amrwb.c:26:0:
> >> >> src/libavcodec/amrwbdata.h:64:5: error: expected identifier before ‘(’ token
> >> >>      NO_DATA                                ///< no transmission
> >> >>      ^
> >> >> make: *** [libavformat/amrwb.o] Error 1
> >> >
> >> > The errors are apparently caused by the following definitions in a mingw header:
> >> > #define WSANO_DATA (WSABASEERR + 1004)
> >> > #define NO_DATA WSANO_DATA
> >>
> >> Attached is one possible solution.
> >>
> >> Please comment, Carl Eugen
> >
> >>  amrnbdata.h |    2 +-
> >>  amrnbdec.c  |    5 +++--
> >>  amrwbdata.h |    2 +-
> >>  3 files changed, 5 insertions(+), 4 deletions(-)
> >> eb545b4abc7d2849db7be8f78abba8a1626a2ba7  0001-lavc-amr-Rename-NO_DATA-as-AMR_NO_DATA.patch
> >> From 317dbccb46a02ac997c8826ef4c31b787fc8ce47 Mon Sep 17 00:00:00 2001
> >> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> >> Date: Tue, 3 Oct 2017 00:00:29 +0200
> >> Subject: [PATCH] lavc/amr: Rename NO_DATA as AMR_NO_DATA.
> >>
> >> mingw64 defines NO_DATA in wsa_errnos.h
> >> ---
> >>  libavcodec/amrnbdata.h |    2 +-
> >>  libavcodec/amrnbdec.c  |    5 +++--
> >>  libavcodec/amrwbdata.h |    2 +-
> >>  3 files changed, 5 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h
> >> index 435fd99..b38f955 100644
> >> --- a/libavcodec/amrnbdata.h
> >> +++ b/libavcodec/amrnbdata.h
> >> @@ -47,7 +47,7 @@ enum Mode {
> >>      MODE_12k2,                            ///< 12.2 kbit/s
> >>      MODE_DTX,                             ///< silent frame
> >>      N_MODES,                              ///< number of modes
> >> -    NO_DATA = 15                          ///< no transmission
> >> +    AMR_NO_DATA = 15                      ///< no transmission
> >>  };
> >>
> >>  #define LP_FILTER_ORDER 10        ///< linear predictive coding filter order
> >> diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
> >> index ea299ac..ae5be5d 100644
> >> --- a/libavcodec/amrnbdec.c
> >> +++ b/libavcodec/amrnbdec.c
> >> @@ -214,8 +214,9 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
> >>      p->bad_frame_indicator = (buf[0] & 0x4) != 0x4; // quality bit
> >>
> >>      if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
> >> -        return NO_DATA;
> >> +        return AMR_NO_DATA;
> >>      }
> >
> >> +printf("mode: %d, size: %ld, bitmaps_per_mode: %d \n", mode, sizeof(AMRNBFrame), *amr_unpacking_bitmaps_per_mode[mode]);
> >
> > you missed this line in the patch
> 
> (Which crashed the decoder.)
> 
> Sorry, fixed patch attached.
> 
> Carl Eugen

>  amrnbdata.h |    2 +-
>  amrnbdec.c  |    4 ++--
>  amrwbdata.h |    2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 6b0b3004be9dba74823874267c125f5e9557a477  0001-lavc-amr-Rename-NO_DATA-as-AMR_NO_DATA.patch
> From 317dbccb46a02ac997c8826ef4c31b787fc8ce47 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Tue, 3 Oct 2017 00:00:29 +0200
> Subject: [PATCH] lavc/amr: Rename NO_DATA as AMR_NO_DATA.
> 
> mingw64 defines NO_DATA in wsa_errnos.h

LGTM

thx

[...]
diff mbox

Patch

From 317dbccb46a02ac997c8826ef4c31b787fc8ce47 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Tue, 3 Oct 2017 00:00:29 +0200
Subject: [PATCH] lavc/amr: Rename NO_DATA as AMR_NO_DATA.

mingw64 defines NO_DATA in wsa_errnos.h
---
 libavcodec/amrnbdata.h |    2 +-
 libavcodec/amrnbdec.c  |    5 +++--
 libavcodec/amrwbdata.h |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/amrnbdata.h b/libavcodec/amrnbdata.h
index 435fd99..b38f955 100644
--- a/libavcodec/amrnbdata.h
+++ b/libavcodec/amrnbdata.h
@@ -47,7 +47,7 @@  enum Mode {
     MODE_12k2,                            ///< 12.2 kbit/s
     MODE_DTX,                             ///< silent frame
     N_MODES,                              ///< number of modes
-    NO_DATA = 15                          ///< no transmission
+    AMR_NO_DATA = 15                      ///< no transmission
 };
 
 #define LP_FILTER_ORDER 10        ///< linear predictive coding filter order
diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index ea299ac..ae5be5d 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -214,7 +214,7 @@  static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
     p->bad_frame_indicator = (buf[0] & 0x4) != 0x4; // quality bit
 
     if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
-        return NO_DATA;
+        return AMR_NO_DATA;
     }
 
     if (mode < MODE_DTX)
@@ -968,7 +968,7 @@  static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
     buf_out = (float *)frame->data[0];
 
     p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
-    if (p->cur_frame_mode == NO_DATA) {
+    if (p->cur_frame_mode == AMR_NO_DATA) {
         av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n");
         return AVERROR_INVALIDDATA;
     }
diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 8a8cbfd..3f8b26c 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -61,7 +61,7 @@  enum Mode {
     MODE_SID,                              ///< comfort noise frame
     /* 10-13:  Future use */
     SP_LOST = 14,                          ///< speech lost
-    NO_DATA                                ///< no transmission
+    AMR_NO_DATA                            ///< no transmission
 };
 
 /* All decoded parameters in these structs must be 2 bytes long
-- 
1.7.10.4