net.sf.fmj.media.codec.video.jpeg
Class RFC2035

java.lang.Object
  extended by net.sf.fmj.media.codec.video.jpeg.RFC2035

public class RFC2035
extends java.lang.Object

Code from RFC 2035 - RTP Payload Format for JPEG Video. See http://www.rfc-archive.org/getrfc.php?rfc=2035 Ported to Java from C by Ken Larson. TODO: Obsoleted by RFC2435. See http://rfc.sunsite.dk/rfc/rfc2435.html

Author:
Ken Larson, Martin Harvan

Field Summary
static short[] chm_ac_codelens
           
static short[] chm_ac_symbols
           
static short[] chm_dc_codelens
           
static short[] chm_dc_symbols
           
static int[] jpeg_chroma_quantizer_normal
          Table K.2 from JPEG spec.
static int[] jpeg_chroma_quantizer_zigzag
           
static int[] jpeg_luma_quantizer_normal
          Table K.1 from JPEG spec.
static int[] jpeg_luma_quantizer_zigzag
           
static short[] lum_ac_codelens
           
static short[] lum_ac_symbols
           
static short[] lum_dc_codelens
           
static short[] lum_dc_symbols
           
 
Constructor Summary
RFC2035()
           
 
Method Summary
static int[] createZigZag(int[] array)
          Creates ZigZag-ordered array from given regular-order array, can only be used for arrays of 64 elements, since it uses xmax=8, ymax=8
static int[] createZigZag(int[] array, int xmax, int ymax)
          Creates ZigZag-ordered array from regular-order array
static int MakeHeaders(boolean includeSOI, byte[] p, int i, int type, int q, int w, int h)
          The old MakeHeaders method.
static int MakeHeaders(boolean includeSOI, byte[] p, int i, int type, int q, int w, int h, byte[] luma, byte[] chroma, int dri)
          Given an RTP/JPEG type code, q factor, width, and height, generate a frame and scan headers that can be prepended to the RTP/JPEG data payload to produce a JPEG compressed image in interchange format (except for possible trailing garbage and absence of an EOI marker to terminate the scan).
static int MakeQuantHeader(byte[] p, int i, byte[] qt, int tableNo)
          Creates quantization header for given qtable.
static void MakeTables(int q, byte[] lum_q, byte[] chr_q, int[] jpeg_luma, int[] jpeg_chroma)
          Call MakeTables with the Q factor and two int[64] return arrays
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jpeg_luma_quantizer_zigzag

public static final int[] jpeg_luma_quantizer_zigzag

jpeg_chroma_quantizer_zigzag

public static final int[] jpeg_chroma_quantizer_zigzag

jpeg_luma_quantizer_normal

public static final int[] jpeg_luma_quantizer_normal
Table K.1 from JPEG spec.


jpeg_chroma_quantizer_normal

public static final int[] jpeg_chroma_quantizer_normal
Table K.2 from JPEG spec.


lum_dc_codelens

public static final short[] lum_dc_codelens

lum_dc_symbols

public static final short[] lum_dc_symbols

lum_ac_codelens

public static final short[] lum_ac_codelens

lum_ac_symbols

public static final short[] lum_ac_symbols

chm_dc_codelens

public static final short[] chm_dc_codelens

chm_dc_symbols

public static final short[] chm_dc_symbols

chm_ac_codelens

public static final short[] chm_ac_codelens

chm_ac_symbols

public static final short[] chm_ac_symbols
Constructor Detail

RFC2035

public RFC2035()
Method Detail

MakeTables

public static void MakeTables(int q,
                              byte[] lum_q,
                              byte[] chr_q,
                              int[] jpeg_luma,
                              int[] jpeg_chroma)
Call MakeTables with the Q factor and two int[64] return arrays

Parameters:
q - Q factor
lum_q - input luminance jpeg qtable
chr_q - input chrominance jpeg qtable
jpeg_luma - returned luminance qtable
jpeg_chroma - returned chrominance qtable

MakeQuantHeader

public static int MakeQuantHeader(byte[] p,
                                  int i,
                                  byte[] qt,
                                  int tableNo)
Creates quantization header for given qtable. Quantization table starts with bytes 0xFF and 0xDB followed by 2 bytes that specify length of the tables.

Parameters:
p - destination for the created header
i - initial offset
qt - qtable data
tableNo - qtable number
Returns:
new offset in p

MakeHeaders

public static int MakeHeaders(boolean includeSOI,
                              byte[] p,
                              int i,
                              int type,
                              int q,
                              int w,
                              int h)
The old MakeHeaders method. Can be called if we do not have custom lqt and cqt tables and we do not have dri (dri == 0).

Parameters:
includeSOI - specifies wheter SOI should be prepended
p - destination for created headers
i - initial offset of p
type - value of type parameter for the JPEG/RTP frame
q - value of Q parameter for the JPEG/RTP frame
w - width of JPEG/RTP frame (in blocks)
h - height of JPEG/RTP frame (in blocks)
Returns:
new offset value

MakeHeaders

public static int MakeHeaders(boolean includeSOI,
                              byte[] p,
                              int i,
                              int type,
                              int q,
                              int w,
                              int h,
                              byte[] luma,
                              byte[] chroma,
                              int dri)
Given an RTP/JPEG type code, q factor, width, and height, generate a frame and scan headers that can be prepended to the RTP/JPEG data payload to produce a JPEG compressed image in interchange format (except for possible trailing garbage and absence of an EOI marker to terminate the scan).

Parameters:
p - destination for the created data
i - initial offset of p
includeSOI - - kenlars99 - not in original RFC sample code, allows us to control whether to include the initial SOI marker (0xFFD8). Turn this off if there are other headers before these, such as the JFIF header. If false, caller is responsible for the initial SOI marker.
type - value of type parameter for the JPEG/RTP frame
q - value of q parameter for the JPEG/RTP frame
w - width of JPEG/RTP frame (in blocks)
h - height of JPEG/RTP frame (in blocks)
luma - - kane77 - used to specify luma table if q>127, if null then tables are computed the normal way
chroma - - kane77 - used to specify chroma table if q>127, if null then tables are computed the normal way
dri - - kane77 - used to specify restart interval, if dri==0 then no DRI header is created.
Returns:
new offset value

createZigZag

public static int[] createZigZag(int[] array)
Creates ZigZag-ordered array from given regular-order array, can only be used for arrays of 64 elements, since it uses xmax=8, ymax=8

Parameters:
array - array in normal order
Returns:
array in zigzag order

createZigZag

public static int[] createZigZag(int[] array,
                                 int xmax,
                                 int ymax)
Creates ZigZag-ordered array from regular-order array

Parameters:
array - array in normal order
xmax - maximal x dimension of array
ymax - maximal y dimension of array
Returns:
array in zigzag order