IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
help in mp2 gain (scalefactor)!, help in mp2 gain (scalefactor)!!
alonsag
post Sep 14 2005, 15:40
Post #1





Group: Members
Posts: 7
Joined: 31-July 05
Member No.: 23622



Hey
How r u?
I'm trying to change the volume to mpeg 1 layer 2 file in transport stream format
I need some code that helps me change the scale factor of each sub band.
so please if you can send me the formula or code to review.
(The main problem is to understand how to change the scale factor in bits from the iso table)
Thank you.

alon
smile.gif
Go to the top of the page
+Quote Post
timcupery
post Sep 14 2005, 16:42
Post #2





Group: Members
Posts: 780
Joined: 19-December 01
From: Tar Heel country
Member No.: 683



If I remember correctly, I've never been able to change the volume of an mp2 file with any mp3 utilities. (With mp1 files, you can change the volume using mp3gain and other programs if you "trick" the program by changing the extension to .mp3, then altering the volume, then change the extension back to mp1.)

What I do with thew few mp2 files I have is write replaygain tags using foobar, and then just play them in an mp3gain-compatible player (e.g., foobar).

But if there's a good answer to your question, I'd like to know it.


--------------------
God kills a kitten every time you encode with CBR 320
Go to the top of the page
+Quote Post
Sunhillow
post Sep 14 2005, 20:10
Post #3





Group: Members (Donating)
Posts: 483
Joined: 13-October 01
From: Stuttgart
Member No.: 286



You could ask DSPguru if he gives his code to you. Otherwise you will have to read the Layer II section of ISO11172-3.

see here
Edit: ouch! this is a thread started by you!

I also have very old code that reads MP2 and decodes it down until the scalefactors. It is for IBM C for OS/2, written 1993 so I will not give you any help (because everything is forgotten now!). It is not optimized in any way and comments are in german laugh.gif

This post has been edited by Sunhillow: Sep 14 2005, 20:21
Go to the top of the page
+Quote Post
alonsag
post Sep 15 2005, 09:29
Post #4





Group: Members
Posts: 7
Joined: 31-July 05
Member No.: 23622



I asked DSPguru but did not get any reply from him.

I read the ISO file but did not understand how 6 bit can contain the numbers that the

ISO11172-3. table of scalefactor have .

Please help!!!

Alon
sad.gif
Go to the top of the page
+Quote Post
Sunhillow
post Sep 15 2005, 11:24
Post #5





Group: Members (Donating)
Posts: 483
Joined: 13-October 01
From: Stuttgart
Member No.: 286



QUOTE (alonsag @ Sep 15 2005, 10:29 AM)
I read the ISO file but did not understand how 6 bit can contain the numbers that the
ISO11172-3. table of scalefactor have .
*


Hi!

you have to calculate the values.

Here is how I did it:
CODE

double Tbl_ScalFact[63]; /* Skalenfaktoren Layer I und II */

void init_ScalFact()
{
int i;
double Wurzel;

Wurzel = pow (2.0, (1.0/3.0)); /* die dritte Wurzel aus zwei (1.2599210 usw. ) */
Tbl_ScalFact[0] = 2.0;
for (i=1; i<63; i++)
{
Tbl_ScalFact[i] = Tbl_ScalFact[i-1] / Wurzel;
}

} /* init_Scalfact */
Go to the top of the page
+Quote Post
smack
post Sep 15 2005, 14:19
Post #6





Group: Members
Posts: 183
Joined: 16-January 02
Member No.: 1046



QUOTE (alonsag @ Sep 15 2005, 09:29 AM)
I read the ISO file but did not understand how 6 bit can contain the numbers that the ISO11172-3. table of scalefactor have .

The answer is:
QUOTE (ISO11172-3 Chapter 2.4.3.3 Layer II)
Scalefactor decoding
For every subband with a nonzero bit allocation the coded scalefactor for that subband are read from the bitstream. The number of coded scalefactors and the part of the subband samples they refer to is defined by scfsi[sb]. The 6 bits of a coded scalefactor should be interpreted as an unsigned integer index to 3-Annex B, Table 3-B.1 "LAYER I, II SCALEFACTORS". This table gives the scalefactor by which the relevant subband samples should be multiplied after requantization.

So, if you write a program that modifies the coded (6bit) scalefactors in the bitstream you have to keep in mind that table of scalefactors which is part of the decoder.

The conclusions for your program are:

-all scalefactors of a frame must be modified (added or subtracted) by the same amount
-to increase the volume of the decoded samples, you have to decrease the coded (6bit) scalefactors (and vice versa)
-the changes can be applied in discrete steps only (integer n), which result in a factor of 2^(-n/3)

-example: add n=1 -> factor=2^(-1/3)=0,7937 (volume decrease)
-example: add n=-1 -> factor=2^(1/3)=1,2599 (volume increase)
-example: add n=-4 -> factor=2^(4/3)=2,5198 (volume increase)

Hope this helps a bit. wink.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 31st July 2014 - 15:18