diff mbox

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

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

Commit Message

Cameron Cawley Aug. 8, 2019, 9:09 p.m. UTC
---
 libavformat/rpl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 6afd373810..d31c7f09ad 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
+    av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
     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;