diff mbox series

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

Message ID 20210503201000.22816-2-ccawley2011@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Cameron Cawley May 3, 2021, 8:10 p.m. UTC
---
 libavformat/rpl.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Zane van Iperen May 4, 2021, 11:57 a.m. UTC | #1
On 4/5/21 6:10 am, Cameron Cawley wrote:

> +            case 2:
> +		if(av_stristr(audio_codec, "adpcm") != NULL) {

Nit: use spaces here. Also "if ("

> +                    ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
> +                    break;
> +                }
> +                break;

I would ask why two breaks, but then I noticed the rest of the code does the same. Never mind.

Otherwise, both this and part 1 lgtm.

Zane
diff mbox series

Patch

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index f5d2b8fe59..39e8235b48 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)
@@ -232,6 +235,12 @@  static int rpl_read_header(AVFormatContext *s)
                 // There are some other formats listed as legal per the spec;
                 // samples needed.
                 break;
+            case 2:
+		if(av_stristr(audio_codec, "adpcm") != NULL) {
+                    ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+                    break;
+                }
+                break;
             case 101:
                 if (ast->codecpar->bits_per_coded_sample == 8) {
                     // The samples with this kind of audio that I have
@@ -245,8 +254,8 @@  static int rpl_read_header(AVFormatContext *s)
                 break;
         }
         if (ast->codecpar->codec_id == AV_CODEC_ID_NONE)
-            avpriv_request_sample(s, "Audio format %"PRId32,
-                                  audio_format);
+            avpriv_request_sample(s, "Audio format %"PRId32" (%s)",
+                                  audio_format, audio_codec);
         avpriv_set_pts_info(ast, 32, 1, ast->codecpar->bit_rate);
     } else {
         for (i = 0; i < 3; i++)