Opened 8 weeks ago

Last modified 6 weeks ago

#7859 reopened defect

Wrong ARMovie audio codec detection

Reported by: stohrendorf Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: rpl
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: ARMovie Audio Codec detection must not be case sensitive

Details:
The string checks at https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/rpl.c#L213 should be case-insensitive. Tomb Raider 1 has ARMovie files which contain uppercase "LINEAR" and "UNSIGNED", so libavformat falsely returns AV_CODEC_ID_PCM_VIDC instead of AV_CODEC_ID_PCM_U8.

Example:

8          bits per sample (LINEAR UNSIGNED)

Change History (7)

comment:1 follow-up: Changed 8 weeks ago by jamrial

Can you upload a sample?

comment:2 in reply to: ↑ 1 Changed 8 weeks ago by stohrendorf

Replying to jamrial:

Can you upload a sample?

Unfortunately not without copyright infringement. What I am currently doing to circumvent this is

        if(stream->codecpar->codec_id == AV_CODEC_ID_PCM_VIDC)
            stream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;

The ARMovie header is:

ARMovie
RPLFAKE movie                                                                    
Copyright unknown                                                                
No description                                                                   
124        video format
320        x size in pixels
120        y size in pixels
24         bits per pixel RGB
15         frames per second
1          sound format
44100      Hz Samples
2          channel
8          bits per sample (LINEAR UNSIGNED)
1          frames per chunk
2714       number of chunks
180068     even chunk size
180068     odd chunk size
32409868   offset to chunk cat
720        offset to sprite
60         size of sprite
0          (no keys)

Hope this helps.

comment:3 follow-up: Changed 8 weeks ago by cehoyos

  • Keywords rpl added

Please test this patch:

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index fa63576..7aec350 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -210,10 +210,10 @@ static int rpl_read_header(AVFormatContext *s)
                     ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
                     break;
                 } else if (ast->codecpar->bits_per_coded_sample == 8) {
-                    if(strstr(audio_type, "unsigned") != NULL) {
+                    if(av_strcasecmp(audio_type, "unsigned") >= 0) {
                         ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
                         break;
-                    } else if(strstr(audio_type, "linear") != NULL) {
+                    } else if(av_strcasecmp(audio_type, "linear") >= 0) {
                         ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
                         break;
                     } else {

comment:4 Changed 7 weeks ago by richardpl

You should post this patch to ML.

comment:5 in reply to: ↑ 3 Changed 6 weeks ago by stohrendorf

Replying to cehoyos:

Please test this patch:
<<<snip>>>

Thanks, seems to work.

comment:6 follow-up: Changed 6 weeks ago by cehoyos

  • Resolution set to fixed
  • Status changed from new to closed

Should be fixed in 8cf5f948f24aef163fc57c3115440ef2d9c6cfd9, thank you for the report!

comment:7 in reply to: ↑ 6 Changed 6 weeks ago by stohrendorf

  • Resolution fixed deleted
  • Status changed from closed to reopened

Replying to cehoyos:

Should be fixed in 8cf5f948f24aef163fc57c3115440ef2d9c6cfd9, thank you for the report!

I am very sorry, but I somehow forgot that I changed the comparison to av_stristr while testing it, so the current patch is wrong ("linear" and "unsigned" are contained within audio_type, not equal to it).

Note: See TracTickets for help on using tickets.