PDA

View Full Version : NicAudio ac3 decoder, bug with 44.1 KHz streams


tebasuna51
6th August 2006, 04:39
Bug detected when NicAc3Source() try decode 44.1 KHz ac3 streams.

See the more details and possible solution in:
http://forum.doom9.org/showthread.php?p=859928#post859928

Hurricane Neddy
6th August 2006, 07:50
If you already posted it in that thread why are you crossposting it here?

Rockaria
6th August 2006, 11:34
I guess it's because the DLL being used has two versions and owners : the original version->DRC decoding option enabled version.
The issue is dected in both versions that he might have wanted it notified here by the original author and anybody using the original DLL.

My suggestion for Tebasuna :
1. make your own DLL if you have any available webspace, time and any further update issues, so we can have very stable live versions
2. if we have any difficulty in maintaining the releases in different places and it's not been major updates, why not just send the update notes to the original author and have it unified and simplified..

tebasuna51
6th August 2006, 11:48
First I post in BeHappy thread because Dimzon make the last version of NicAudio.dll plugin.

After, other user say me the convenience of publish the bug also in NicAudio original forum.

Really, I only want anyone to compile a new plugin version (out of my knowledge) based in last I know NicAudio_25_dll_20060314. (http://workspaces.gotdotnet.com/behappy)

Edit: after Rockaria post.
I think is not problem off versions or owners after this Nic post. (http://forum.doom9.org/showthread.php?p=793793#post793793)

I can't make the dll myself because I don't own the appropriate compiler.

Rockaria
6th August 2006, 12:17
Oh, I see.

The first link is one of the places the downloads are truncated since some months ago.
Another problem is that the avisynth plugin page seems linking to the original version(one year old), possibly because of the above reason?
http://www.avisynth.org/warpenterprises/

Maybe you can just send the source if everybody agrees?

Rockaria
6th August 2006, 12:44
Because it's not that expensive...
http://www.freebyte.com/programming/cpp/

I personally suggest Visual C++ Express (http://lab.msdn.microsoft.com/express/visualc/) if you are using winXp.

tebasuna51
6th August 2006, 12:49
The first link is one of the places the downloads are truncated since some months ago.
Works for me, but here is a temporal link: NicAudio_25_dll_20060314 (http://www.mytempdir.com/849579)

Rockaria
6th August 2006, 13:01
OK, by your confirmation, I tried & found if I disable the download plugin for the links, it downloads without the truncations. Thanks.

So the remaining issues are complie + update the avisynth plugin page? The VS Express is free. Good for source browsing also.

Rockaria
6th August 2006, 13:19
Hmm, the latest behappy source contained AvisynthWrapper.dll(without the source) is dated 01/26/2006. So it looks older or same than the source I was mentioning.

OK. my issue is done here.

[edit]
I found it contains a zip having the mentioned cpp dated 05/09/2006. But I confirm the 'forced 16bitInt downsize' portion is unchanged.

Wilbert
6th August 2006, 22:18
Just send Nic a PM (and ask him to correct and recompile it) if he doesn't respond to this thread. I don't have time to do it myself atm.

Nic
6th August 2006, 23:15
Hmmm. I'll look into this now.

EDIT: Ok, URL REMOVED (v1.6)
That has the latest (AFAIK) dimzon code and your ac3 function. Haven't had time to test so let me know of any issues.

Cheers,
-Nic

EDIT2: Just read you haven't tested the code you posted. I'll go check it's all ok now.

EDIT3: It just occurred to me that this isn't good. The length of the stream is calculated by the filesize/framelength, if the framelength can be variable this can't work. Infact I can't understand how in a CBR stream the framelength would be variable. I'm going to have to look through the spec before making changes.

EDIT4: Just looked through the spec. Very weird that 44.1khz is different with one word less/more for some frames. Too tired to look into this right now. Will look later.

tebasuna51
7th August 2006, 19:41
Yes, ac3 need two valid FrameLength because:

With 256 samples per block and 6 blocks per frame we have always 1536 Samples/Frame. Then:
FrameLength = ByteRate * 1536 / SampleRate
With BitRate in Kb/s:

For 32 KHz: FrameLength = BitRate * 6
For 44.1 KHz: FrameLength = BitRate * 640 / 147
For 48 KHz: FrameLength = BitRate * 4

For 32, 48 KHz is exact always, but for 44.1 we need two FrameLength in order to mantain the average bitrate.

-----------------------------------
Maybe we need also at end of m2AudioAC3Source() something like:
...
// Get number of frames
FrameCount = int((StreamLength - StreamOffset) / FrameLength);

If (Samplerate == 44100)
FrameCount = int(0.5 + 147 * (StreamLength - StreamOffset) / (640 * Bitrate)));

// Get number of samples
SampleCount = __int64(FrameCount) * SAMPLES_PER_FRAME;
Info.num_audio_samples = SampleCount;

// Initialize buffers
Frame = new unsigned char[FrameLength + 2];
// more easy reserve 2 bytes than check if is needed
...
Edit: add 0.5 to round value.