Opened 2 years ago

Closed 22 months ago

#9763 closed defect (fixed)

ipcm little endian misidentified as big endian

Reported by: Dyami Caliri Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: ipcm endian
Cc: Marton Balint Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: When loading an mp4 file with ipcm audio, little endian, 24 bit, libavformat thinks it is big-endian. The resulting decoded samples are then 'static' due to the byte swapping.

We are using libavformat/libavcodec to decode media files. I will upload a sample, 'ipcm_le.mp4'. QuickTime player on macOS correctly identifies this is as little endian.

Dumping the format after loading the audio shows this format:

Audio: pcm_s24be (ipcm / 0x6D637069), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s

My own inspection into these files suggests that there is a 'pcmC' sub-atom with a flag for endianness. I am not familiar enough with ffmpeg code to try to submit a patch.

Change History (10)

comment:1 by Dyami Caliri, 2 years ago

I couldn't get your upload ftp server to work, so I am providing the sample here:
https://www.dragonframe.com/download/ipcm_le_ticket_9763.mp4

comment:2 by Aleksoid1978, 2 years ago

Can you describe the format of an atom 'pcmC' ?

comment:3 by Balling, 2 years ago

Status: newopen

Did you try forcing the byte endiness? Is this due to M1?

comment:4 by Balling, 2 years ago

can you verify ffplay.exe -acodec pcm_s24le ipcm_le_ticket_9763.mp4 works on larger samples?

in reply to:  4 comment:5 by Dyami Caliri, 2 years ago

Replying to Balling:

can you verify ffplay.exe -acodec pcm_s24le ipcm_le_ticket_9763.mp4 works on larger samples?

The sample I provided (ipcm_le_ticket_9763.mp4) just has a couple of small sounds effects in it. It works with the command you have here, as do larger samples.

in reply to:  3 comment:6 by Dyami Caliri, 2 years ago

Replying to Balling:

Did you try forcing the byte endiness? Is this due to M1?

libavformat detects it as pcm_s24be. If I override that and tell it to use pcm_s24le, the sound will be correct. It is not due to M1, as it also happens on x86_64.

It is an issue with avformat assuming that it is big-endian when it is not.

in reply to:  2 comment:7 by Dyami Caliri, 2 years ago

Replying to Aleksoid1978:

Can you describe the format of an atom 'pcmC' ?

I couldn't find a formal description anywhere, but I looked at several files, and here is what I see:

0E 70636D43 00000000 01180000 00

0x0E = Length 14 bytes
'pcmC' = identifier
0x00000000 = no idea

0x01 = 0x01 -> little endian, 0x00 -> big endian
0x18 = 24 bits per sample?

I don't know the rest.

comment:9 by Marton Balint, 22 months ago

Cc: Marton Balint added

Thanks, I have factorized out the duplicated code from your patch and simplified it a bit:

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=6849

comment:10 by Balling, 22 months ago

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