[FFmpeg-devel,2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

Submitted by Cameron Cawley on June 27, 2019, 7:56 p.m.

Details

Message ID 20190627195602.10889-2-ccawley2011@gmail.com
State New
Headers show

Commit Message

Cameron Cawley June 27, 2019, 7:56 p.m.
---
 libavformat/rpl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 29, 2019, 4:33 p.m.
On Thu, Jun 27, 2019 at 08:56:02PM +0100, Cameron Cawley wrote:
> ---
>  libavformat/rpl.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/rpl.c b/libavformat/rpl.c
> index dbbcd13b41..b4859320f4 100644
> --- a/libavformat/rpl.c
> +++ b/libavformat/rpl.c
> @@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
>      int error = 0;
>      const char *endptr;
>      char audio_type[RPL_LINE_LENGTH];
> +    char audio_codec[RPL_LINE_LENGTH];
>  
>      uint32_t i;
>  
> @@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
>  
>      // ARMovie supports multiple audio tracks; I don't have any
>      // samples, though. This code will ignore additional tracks.
> -    audio_format = read_line_and_int(pb, &error);  // audio format ID
> +    error |= read_line(pb, line, sizeof(line));
> +    audio_format = read_int(line, &endptr, &error);  // audio format ID

> +    strcpy(audio_codec, endptr);

This should be using a function checking the available space

[...]

thx

Patch hide | download patch | download mbox

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index dbbcd13b41..b4859320f4 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@  static int rpl_read_header(AVFormatContext *s)
     int error = 0;
     const char *endptr;
     char audio_type[RPL_LINE_LENGTH];
+    char audio_codec[RPL_LINE_LENGTH];
 
     uint32_t i;
 
@@ -189,7 +190,9 @@  static int rpl_read_header(AVFormatContext *s)
 
     // ARMovie supports multiple audio tracks; I don't have any
     // samples, though. This code will ignore additional tracks.
-    audio_format = read_line_and_int(pb, &error);  // audio format ID
+    error |= read_line(pb, line, sizeof(line));
+    audio_format = read_int(line, &endptr, &error);  // audio format ID
+    strcpy(audio_codec, endptr);
     if (audio_format) {
         ast = avformat_new_stream(s, NULL);
         if (!ast)
@@ -229,6 +232,14 @@  static int rpl_read_header(AVFormatContext *s)
                         break;
                     }
                 }
+                break;
+            case 2:
+                if (av_strcasecmp(audio_codec," adpcm") == 0) {
+                    ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+                } else {
+                    avpriv_report_missing_feature(s, "Audio format %"PRId32" (%s)",
+                                                  audio_format, audio_codec);
+                }
                 // There are some other formats listed as legal per the spec;
                 // samples needed.
                 break;