Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd July 2006, 18:16   #1  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Aften 0.0.8 is out

Just found this at HA.org...and it sounds promizing.

Quote:
Aften is a simple, open-source, A/52 (AC-3) audio encoder.

The name, Aften, is an acronym for:
A / Fifty-Two ENcoder
It is also Danish and Norwegian for 'evening'.

This program started as a simple cutting-out of the AC3 encoder from FFmpeg, but then I reworked the structure of the encoder a bit. Most of the basic code is still the same though. Here are some of the things I've changed so far.

* Implemented my own wav reader and bitwise file writer
* Converted the fixed-point algorithms to floating-point
* Rearranged the methods and structures
* Added stereo rematrixing (mid/side)
* Added short block MDCT and block switching
* Added VBR encoding mode

Future Plans

* Variable bandwidth
* Channel coupling

Changelog of the last release:
Quote:
* fixed piped input from FFmpeg
* added support for MPEG channel order remapping
* restructured audio input. enables raw pcm file support.
* bugfixes in MMX/SSE2 code
* stack align hack for x86 MinGW with threads
* API changes
* SIMD and threads usage is shown and is configurable
* screen output gets updated every 200ms to reduce load
* SIMD detection changed to compiler-independent inline assembly, thus nasm/yasm not needed anymore
So, I've made a compile for win32 OS and I added pipeline & 2 switches for CBR and VBR Mode. Could be great if somebody can test multichannel encoding also.
  • Command Line example for VBR :
    Code:
    aften -q 300 input.wav output.ac3
  • Command Line example for CBR :
    Code:
    aften -b 256 input.wav output.ac3
  • Command Line example with pipeline :
    Code:
    aften -q 320 - output.ac3

Last edited by Kurtnoise; 10th September 2007 at 08:41.
Kurtnoise is offline   Reply With Quote
Old 3rd July 2006, 06:03   #2  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
I've tested with a 6-channel WAV produced by BeSweet from an AC3 file and it worked. However I can't tell if the channels were mapped correctly because I don't have a good home theater...
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com
vmesquita is offline   Reply With Quote
Old 5th July 2006, 22:39   #3  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
Did a test using A test file and AC3Filter, and channel mapping is incorrect (relating to BeSweet output).

EDIT:
I've tried to fix this in BeSweet using this:
Code:
D:\Temp\besweet>BeSweet.exe -core( -input "D:\Temp\besweet\6ch.ac3" -output "D:\Temp\besweet\6ch.wav"  -6chwav ) -azid( -o l,c,r,sl,sr,lfe)
However the switch doesn't seem to be working, or maybe the sintax is wrong.
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com

Last edited by vmesquita; 6th July 2006 at 00:18.
vmesquita is offline   Reply With Quote
Old 6th July 2006, 10:20   #4  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Could you test this sample please ?

This is not made with BeSweet. It's just for testing channel mapping.
Kurtnoise is offline   Reply With Quote
Old 7th July 2006, 02:36   #5  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
Quote:
Originally Posted by Kurtnoise13
Could you test this sample please ?

This is not made with BeSweet. It's just for testing channel mapping.
The sample seems ok.
tebasuna51 is offline   Reply With Quote
Old 7th July 2006, 14:28   #6  |  Link
SeeMoreDigital
Life looks better in HD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 11,177
Or you could try this sample
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 8th July 2006, 17:56   #7  |  Link
danpos
BDVD Team
 
danpos's Avatar
 
Join Date: Dec 2004
Location: Rio de Janeiro - RJ/Brasil
Posts: 306
Quote:
Originally Posted by SeeMoreDigital
Or you could try this sample
Hi there! VMesquita had tried your sample out already (I sent it to him ). BTW, it's a very usefull ac3 5.1 sample for channels mapping tests. Thanks for share it.

See you,
danpos is offline   Reply With Quote
Old 9th July 2006, 02:49   #8  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
@Kurtnoise
If you want improve the aften encoder I have two suggestions

1) To make a correct channel remapping we can replace the Int to Float routine at aften.c (line 125):
Code:
for(i=0; i<A52_FRAME_SIZE*wf.channels; i++) {
    if(i < nr*wf.channels)
        fwav[i] = wav[i] / 32768.0;
    else
        fwav[i] = 0.0;
}
With this new one:
Code:
if(wf.channels == 6) {
    for(i=0; i<A52_FRAME_SIZE*6; i+=6) {
        if(i < nr*6) {
            fwav[i] = wav[i] / 32768.0;      // FL
            fwav[i+1] = wav[i+2] / 32768.0;  // C
            fwav[i+2] = wav[i+1] / 32768.0;  // FR
            fwav[i+3] = wav[i+4] / 32768.0;  // SL
            fwav[i+4] = wav[i+5] / 32768.0;  // SR
            fwav[i+5] = wav[i+3] / 32768.0;  // LFE
        }
        else
            for(j=0; j<6; j++) fwav[i+j] = 0.0;
    }
}
else {
    for(i=0; i<A52_FRAME_SIZE*wf.channels; i++) {
        if(i < nr*wf.channels)
            fwav[i] = wav[i] / 32768.0;
        else
            fwav[i] = 0.0;
    }
}

2) New parameters, valid values and default, to be passed to output_frame_header (a52enc.c):

-c 0,1,2 Default: 0 (-3,-4.5,-6 dB) Center Mix Level
-s 0,1,2 Default: 0 (-3,-6,0 dB) Surround Mix Level
-d 0,1,2 Default: 0 (Ignored,Not,Yes) Dolby Surround Mode
-n 0..31 Default: 31 (-0..-31 dB) Dialogue normalization
tebasuna51 is offline   Reply With Quote
Old 9th July 2006, 07:12   #9  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
@tebasuna51
Tested the mod and now the channels are being correctly mapped for BeSweet output
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com
vmesquita is offline   Reply With Quote
Old 9th July 2006, 15:29   #10  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Quote:
Originally Posted by tebasuna51
1) To make a correct channel remapping we can replace the Int to Float routine at aften.c
Yep...done. I'll try to make a build with ICL compiler later. Maybe this should improve the speed.

Quote:
Originally Posted by tebasuna51
2) New parameters, valid values and default, to be passed to output_frame_header (a52enc.c):

-c 0,1,2 Default: 0 (-3,-4.5,-6 dB) Center Mix Level
-s 0,1,2 Default: 0 (-3,-6,0 dB) Surround Mix Level
-d 0,1,2 Default: 0 (Ignored,Not,Yes) Dolby Surround Mode
-n 0..31 Default: 31 (-0..-31 dB) Dialogue normalization
mmh...Isn't it more useful for decoder side instead of encoder ?
Kurtnoise is offline   Reply With Quote
Old 9th July 2006, 16:13   #11  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
I did a modification to add 6-WAV support. This can be useful because sometimes we want to change AC3 duration (for framerate conversions) and SoundStretch only support Mono WAVs, while BeSweet built-in SoundTouch doesn't work well in my experience. You can download sources and binary here:
http://www.vmesquita.com/files/aften_6wav.zip
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com
vmesquita is offline   Reply With Quote
Old 9th July 2006, 16:53   #12  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
Quote:
Originally Posted by Kurtnoise13
mmh...Isn't it more useful for decoder side instead of encoder ?
Maybe for Center Mix Level and Surround Mix Level, but this values are taken from BSI when the decoder isn't instructed with another values. At least we can put the default values proposed by Dolby:
Code:
//    if ((s->acmod & 0x01) && s->acmod != 0x01) bitwriter_writebits(&s->bw, 2, 1); /* XXX -4.5 dB */
    if ((s->acmod & 0x01) && s->acmod != 0x01) bitwriter_writebits(&s->bw, 2, 0); // -3 dB (Dolby default)
//    if (s->acmod & 0x04) bitwriter_writebits(&s->bw, 2, 1); /* XXX -6 dB */
    if (s->acmod & 0x04) bitwriter_writebits(&s->bw, 2, 0); // -3 dB (Dolby default)
The Dolby Surround Mode flag is claimed by many users because, when is played by a hardware decoder, can switch automatically to DPL mode.

The Dialogue Normalization is a important parameter in ac3 encode, you can see:
GUIDE: How To Properly Encode Dolby Digital Audio (AC3)
tebasuna51 is offline   Reply With Quote
Old 9th July 2006, 21:07   #13  |  Link
Rockaria
nobody's nobody
 
Join Date: Mar 2005
Location: The Sun, somewhere around
Posts: 553
Good to see the Aften is having the correct AC3 channel order from the default wav-format order.
I believe the AC3 decoders are also responsible to restore the original wav-format channel order to play or transcode.
However :
Quote:
The Dolby Surround Mode flag is claimed by many users because, when is played by a hardware decoder, can switch automatically to DPL mode.
My h/w decoders(& probably many other decoders too) are auto/stereo/surround decoding mode manually selectable.
So as far as the mode is set to auto/surround, it decodes depending on the detected actual stream : AC3, DTS... | 5.1, 2.1,.., DPL II..
For an example, when I set the ac3 out mode in the FFDShow and change the mixer mode, it decodes all the 2.0 ch modes(DPL II, 2.0....) to DPL II mode(forced) automatically.

Probably only when the DD 2.0 contains the DPL mix, the ds meta info is used for some old decoders to be automatic to switch between DPL & STEREO mode.
__________________
u know everything in the end, or now if aligned... no right(x).right(y) pls. it's confusing... : phase-shift /Jun.2006
Rockaria is offline   Reply With Quote
Old 10th July 2006, 02:17   #14  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
At least in this thread: BeSweet + AC3Enc: Tag generated 2.0 AC3 as "surround" if downmix was used is claimed the Dolby Surround Mode flag.

I think is easy to implement, without waste resources, and why not?
I make the necessary (I hope) mods to include the four parameters in Aften_mod_sources

All parameters are optional, also when use:
aften input.wav output.ac3
is encoded CBR with 448 Kb/s for 6 channel wav or 192 Kb/s for other number of channels.

Please, if anybody can compile this sources (I don't have the appropriate compiler) I can test the result. Thanks.

Edit: @vmesquita, I can't access your links. Please use http://www.mytempdir.com/

Last edited by tebasuna51; 10th July 2006 at 02:22.
tebasuna51 is offline   Reply With Quote
Old 10th July 2006, 03:28   #15  |  Link
Rockaria
nobody's nobody
 
Join Date: Mar 2005
Location: The Sun, somewhere around
Posts: 553
Indeed, Dolby's doc contains some more :
Quote:
Originally Posted by http://web.archive.org/web/20031206104650/http://dolby.com/pro/digaudio/pa.ma.1102.Standards.S.pdf on p17
On most equipment, the consumer can, through the product's user interface, choose the appropriate downmix for their playback system. Certain metadata parameters allow the engineer to select how the stereo downmix is constructed and which downmix is preferred, although the Lt/Rt downmix is usually the default.
The downmix modes(preferred/mixed) : Lt/Rt(Yes above : DPL), Lo/Ro(No : simple stereo). If we count the DPL II, I don't know how important this tag is any more.

But I agree, reserving & setting the correct options are not wasting the space and certainly useful for certain decoders or any other uses..
__________________
u know everything in the end, or now if aligned... no right(x).right(y) pls. it's confusing... : phase-shift /Jun.2006
Rockaria is offline   Reply With Quote
Old 10th July 2006, 04:53   #16  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
@tebasuna51

EDIT:
I have merged the 6 wav mod with the mods you posted, added the usage to when aften is called with no arguments, and fixed a little typo in your mod. Binary and source:
http://www.mytempdir.com/794693

(I didn't test, I hope it's working correctly)
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com

Last edited by vmesquita; 10th July 2006 at 05:17.
vmesquita is offline   Reply With Quote
Old 10th July 2006, 09:39   #17  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
@vmesquita
Thanks, but in your .rar the aften.exe is missing.
tebasuna51 is offline   Reply With Quote
Old 10th July 2006, 10:28   #18  |  Link
Kurtnoise
Swallowed in the Sea
 
Kurtnoise's Avatar
 
Join Date: Oct 2002
Location: Aix-en-Provence, France
Posts: 5,182
Allright...I patched tebasuna stuff and merged it with the 0.01 version.

Quote:
Originally Posted by Justin Ruggles
Thanks to some improvements posted on the doom9 forum, I have done some work on Aften today and released a new version.

http://jbr.homelinux.org/aften/aften-0.01.tar.bz2

* simple configure script
* piped input and output
* corrected 6-channel mapping
* corrected defaults for mix levels
* commandline options
* quiet mode (no console output)
* per-frame or average statistics
* big-endian support (not tested though)
I had PMed Justin to this thread. Download here.
Kurtnoise is offline   Reply With Quote
Old 10th July 2006, 12:28   #19  |  Link
vmesquita
Registered User
 
Join Date: Mar 2003
Posts: 126
@tebasuna51
Sorry, here is the full package:
http://www.mytempdir.com/795181
__________________
VMesquita

My Tools:
DIKO
FreeEnc: AVS->MPEG2 Encoder
Get them here: http://www.vmesquita.com
vmesquita is offline   Reply With Quote
Old 10th July 2006, 18:27   #20  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,194
@vmesquita
Thanks for your job, but maybe there are a problem because your aften.exe never finish to encode. Stoped with Ctrl-C, the first part is ok and after a long silence. The parameters are taken ok.

@kurtnoise
Your new version works fine for me. Thanks for the patch.

In firsts tests I detected:
Aften accept any wav type, but only work with 16 bit Int wav's. With 24,32 bit Int or float the resultant ac3 is unusable. With 8 bit Int Aften abort.
Accept also WAVE_FORMAT_EXTENSIBLE (16 bit Int), then the faad output can be used directly with Aften.

Tested also the pipe issue with AviSynth based Bepipe and BeHappy.

Edit: More tests (not important because isn't frequently used)

wav_3chan, acmod used 3 (L,C,R) needed remap [0,2,1], the acmod 4 (L,R,S) is not accesible (remap not needed)

wav_4chan, acmod used 6 (L,R,SL,SR) remap not needed, the acmod 5 (L,C,R,S) is not accesible (needed remap [0,2,1,3])

wav_5chan, acmod used 7 (L,C,R,SL,SR) needed remap [0,2,1,3,4] (without LFE).

Edit 2: Work also with wav > 4GB
Test with wav 4.2 GB, 6 chan, 130 min. encoded in 12 min. in a P IV 2.4GHz

Last edited by tebasuna51; 10th July 2006 at 21:17.
tebasuna51 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.