Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: A problem about FAAD2 (Read 4440 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

A problem about FAAD2

It will lose a frame when I convert a ".mp4" file to ".wav" file.

It is the test data:
======================
Track infomation of shwj_001.mp4
======================
TID        Type    Size            Sample    Offset        Duration
1            vide    1130556571  180756  28            6031.225098 secs        640x480
2            hint      24961647    180756  1130554171      6031.225098 secs
5            soun    97577187    282702  1155518300      6030.976074 secs       
6            hint      11306624    70634    1253094783      6030.890625 secs       
7            odsm    33              1          1264402119      6031.225098 secs       
8            sdsm    24              1          1264402152      6031.225098 secs       

We can see the audio frame number(the Sample field): 282702

[root@download1 code]# ./wavinfo shwj_001.wav
File Size: 1157943340
Stroring format: Pulse Code Modulation(PCM)
Channels: 2    Sample Per Sec: 48000 Hz        Avg bytes Per sec:192000
Block Align: 4  Bits Per Sample: 16
chunk type: fmt        chunk size: 16
chunk type: data        chunk size: 1157943296

and the wav PCM data size is 1157943296.

We know that PCM data size = Sample * 1024 * Block Align.
but the value of the right of the equation is : 1157947392 = 1157943296 + 1024 * 4

A problem about FAAD2

Reply #1
Yes, also a known problem.

I will try to fix this for the next update.

Menno

A problem about FAAD2

Reply #2
In the frontend/main.c , I have seen the loop .

"for (sampleId = 1; sampleId <= numSamples; sampleId++)"

I can't find the reason to cause the problem.

A problem about FAAD2

Reply #3
It's the encoder that encodes too few data.

Menno

A problem about FAAD2

Reply #4
encoder? I do not understand.
I think it is the decoder, the first frame will catch the frameInfo.samples = 0, so the condition

if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            write_audio_file(aufile, sample_buffer, frameInfo.samples);
        }

fail.

and it  will lose the first frame of the audio data.

I do not know the reason.

A problem about FAAD2

Reply #5
Quote
Yes, also a known problem.

I will try to fix this for the next update.

Menno

Version 2.0 also has the problem ?

A problem about FAAD2

Reply #6
Quote
encoder? I do not understand.
I think it is the decoder, the first frame will catch the frameInfo.samples = 0, so the condition

if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            write_audio_file(aufile, sample_buffer, frameInfo.samples);
        }

fail.

and it  will lose the first frame of the audio data.

I do not know the reason.

There's no real audio data in the first frame, just silence, because of the encoder delay.

It is the encoder that does not encode enough data at the end.

Menno

A problem about FAAD2

Reply #7
Quote
Quote
encoder? I do not understand.
I think it is the decoder, the first frame will catch the frameInfo.samples = 0, so the condition

if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            write_audio_file(aufile, sample_buffer, frameInfo.samples);
        }

fail.

and it  will lose the first frame of the audio data.

I do not know the reason.

There's no real audio data in the first frame, just silence, because of the encoder delay.

It is the encoder that does not encode enough data at the end.

Menno

so when I want to decode single frame of the AAC bitstream, I must invoke faacDecDecode function twice. the very frame before and the frame .
The return data of the first frame  invoking the faacDecDecode() is not correct.
Is it ?

A problem about FAAD2

Reply #8
Quote
so when I want to decode single frame of the AAC bitstream, I must invoke faacDecDecode function twice. the very frame before and the frame .
The return data of the first frame  invoking the faacDecDecode() is not correct.
Is it ?

If the data returned by faacDecDecode() is not NULL you can simply use it. Only the very first one or two frames will return NULL data. If you want to decode just one frame in the middle of the file, you should always use the faacDecPostSeek() function first. Decoding just one frame can give some problems with the MDCT though, I'm not exactly sure if you will receive correct data.

Menno