org.jaudiotagger.audio.mp3
Class VbriFrame

java.lang.Object
  extended by org.jaudiotagger.audio.mp3.VbriFrame

public class VbriFrame
extends java.lang.Object

Vrbi Frame

In MP3s encoded using the franhofer encoder which variable bit rate the first frame in the file contains a special frame called a Vrbi Frame, instead of audio data (Other Vbr encoders use the more common Xing Frame). This is used to store additional information about the file. The most important aspect for this library is details allowing us to determine the bitrate of a Variable Bit Rate VBR file without having to process the whole file.

From http://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx#SideInfo

This header is only used by MPEG audio files encoded with the Fraunhofer Encoder as far as I know. It is different from the XING header. You find it exactly 32 bytes after the end of the first MPEG audio header in the file. (Note that the position is zero-based; position, length and example are each in byte-format.) Position Length Meaning Example 0 4 VBR header ID in 4 ASCII chars, always 'VBRI', not NULL-terminated 'VBRI' 4 2 Version ID as Big-Endian WORD 1 6 2 Delay as Big-Endian float 7344 8 2 Quality indicator 75 10 4 Number of Bytes of Audio as Big-Endian DWORD 45000 14 4 Number of Frames as Big-Endian DWORD 7344 18 2 Number of entries within TOC table as Big-Endian WORD 100 20 2 Scale factor of TOC table entries as Big-Endian DWORD 1 22 2 Size per table entry in bytes (max 4) as Big-Endian WORD 2 24 2 Frames per table entry as Big-Endian WORD 845 26 TOC entries for seeking as Big-Endian integral. From size per table entry and number of entries, you can calculate the length of this field.


Field Summary
private  int audioSize
           
private static int BYTE_1
           
private static int BYTE_2
           
private static int BYTE_3
           
private static int BYTE_4
           
private  int frameCount
           
private static java.nio.ByteBuffer header
           
private  LameFrame lameFrame
           
static int MAX_BUFFER_SIZE_NEEDED_TO_READ_VBRI
           
private  boolean vbr
           
private static int VBRI_AUDIOSIZE_BUFFER_SIZE
           
private static int VBRI_DELAY_BUFFER_SIZE
           
private static int VBRI_FRAMECOUNT_BUFFER_SIZE
           
private static int VBRI_HEADER_BUFFER_SIZE
           
private static int VBRI_IDENTIFIER_BUFFER_SIZE
           
private static int VBRI_OFFSET
           
private static int VBRI_QUALITY_BUFFER_SIZE
           
private static int VBRI_TOC_ENTRY_BUFFER_SIZE
           
private static byte[] VBRI_VBR_ID
          Identifier
 
Constructor Summary
private VbriFrame()
          Read the VBRI Properties from the buffer
 
Method Summary
 int getAudioSize()
           
 java.lang.String getEncoder()
           
 int getFrameCount()
           
 boolean isVbr()
          Is this VBRIFrame detailing a varaible bit rate MPEG
static boolean isVbriFrame(java.nio.ByteBuffer bb, MPEGFrameHeader mpegFrameHeader)
          IS this a VBRI frame
static VbriFrame parseVBRIFrame()
          Parse the VBRIFrame of an MP3File, cannot be called until we have validated that this is a VBRIFrame
private  void setAudioSize()
          Set size of AudioData
private  void setFrameCount()
          Set count of frames
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VBRI_OFFSET

private static final int VBRI_OFFSET
See Also:
Constant Field Values

VBRI_HEADER_BUFFER_SIZE

private static final int VBRI_HEADER_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_IDENTIFIER_BUFFER_SIZE

private static final int VBRI_IDENTIFIER_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_DELAY_BUFFER_SIZE

private static final int VBRI_DELAY_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_QUALITY_BUFFER_SIZE

private static final int VBRI_QUALITY_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_AUDIOSIZE_BUFFER_SIZE

private static final int VBRI_AUDIOSIZE_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_FRAMECOUNT_BUFFER_SIZE

private static final int VBRI_FRAMECOUNT_BUFFER_SIZE
See Also:
Constant Field Values

VBRI_TOC_ENTRY_BUFFER_SIZE

private static final int VBRI_TOC_ENTRY_BUFFER_SIZE
See Also:
Constant Field Values

MAX_BUFFER_SIZE_NEEDED_TO_READ_VBRI

public static final int MAX_BUFFER_SIZE_NEEDED_TO_READ_VBRI
See Also:
Constant Field Values

BYTE_1

private static final int BYTE_1
See Also:
Constant Field Values

BYTE_2

private static final int BYTE_2
See Also:
Constant Field Values

BYTE_3

private static final int BYTE_3
See Also:
Constant Field Values

BYTE_4

private static final int BYTE_4
See Also:
Constant Field Values

VBRI_VBR_ID

private static final byte[] VBRI_VBR_ID
Identifier


header

private static java.nio.ByteBuffer header

vbr

private boolean vbr

frameCount

private int frameCount

audioSize

private int audioSize

lameFrame

private LameFrame lameFrame
Constructor Detail

VbriFrame

private VbriFrame()
Read the VBRI Properties from the buffer

Method Detail

setAudioSize

private void setAudioSize()
Set size of AudioData


setFrameCount

private void setFrameCount()
Set count of frames


getFrameCount

public final int getFrameCount()
Returns:
count of frames

getAudioSize

public final int getAudioSize()
Returns:
size of audio data in bytes

parseVBRIFrame

public static VbriFrame parseVBRIFrame()
                                throws InvalidAudioFrameException
Parse the VBRIFrame of an MP3File, cannot be called until we have validated that this is a VBRIFrame

Returns:
Throws:
InvalidAudioFrameException

isVbriFrame

public static boolean isVbriFrame(java.nio.ByteBuffer bb,
                                  MPEGFrameHeader mpegFrameHeader)
IS this a VBRI frame

Parameters:
bb -
mpegFrameHeader -
Returns:
true if this is a VBRI frame

isVbr

public final boolean isVbr()
Is this VBRIFrame detailing a varaible bit rate MPEG

Returns:

getEncoder

public java.lang.String getEncoder()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string represntation