Opened 5 years ago

Closed 5 years ago

#7859 closed defect (fixed)

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 (9)

comment:1 by James, 5 years ago

Can you upload a sample?

in reply to:  1 comment:2 by stohrendorf, 5 years ago

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 by Carl Eugen Hoyos, 5 years ago

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 by Elon Musk, 5 years ago

You should post this patch to ML.

in reply to:  3 comment:5 by stohrendorf, 5 years ago

Replying to cehoyos:

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

Thanks, seems to work.

comment:6 by Carl Eugen Hoyos, 5 years ago

Resolution: fixed
Status: newclosed

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

in reply to:  6 ; comment:7 by stohrendorf, 5 years ago

Resolution: fixed
Status: closedreopened

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).

in reply to:  7 comment:8 by Balling, 5 years ago

Replying to stohrendorf:
Should be fixed in dcf3f8b368cdab908a84ad28ec5a7e0f15f5b33d

comment:9 by Carl Eugen Hoyos, 5 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.