* @return A SampleBuffer containing the decoded samples.\r
*/\r
public Obuffer decodeFrame(Header header, Bitstream stream)\r
- throws DecoderException\r
+ throws DecoderException\r
{\r
- if (!initialized)\r
- {\r
- initialize(header,stream);\r
- }\r
- \r
- int layer = header.layer();\r
- \r
- output.clear_buffer();\r
- \r
- FrameDecoder decoder = retrieveDecoder(header, stream, layer);\r
- \r
- decoder.decodeFrame();\r
- \r
- output.write_buffer(1);\r
- \r
- return output; \r
+ // throw decoder initialization out of ssjava loop since it is invoked once\r
+ // if (!initialized)\r
+ // {\r
+ // initialize(header,stream);\r
+ // }\r
+\r
+ int layer = header.layer();\r
+\r
+ output.clear_buffer();\r
+\r
+ FrameDecoder decoder = retrieveDecoder(header, stream, layer);\r
+\r
+ decoder.decodeFrame();\r
+\r
+ output.write_buffer(1);\r
+\r
+ return output; \r
}\r
\r
/**\r
\r
private int lastPosition = 0;\r
\r
+ private Header header;\r
+ \r
/**\r
* Creates a new <code>Player</code> instance. \r
*/\r
{\r
bitstream = new Bitstream(stream); \r
decoder = new Decoder();\r
+ \r
+ // decoder initialization\r
+ // taking out from ssjava loop \r
+ header = bitstream.readFrame(); \r
+ decoder.initialize(header, bitstream);\r
\r
// if (device!=null)\r
// { \r
{\r
boolean ret = true;\r
\r
- SSJAVA:\r
+ SSJAVA:\r
while (frames-- > 0 && ret)\r
{\r
ret = decodeFrame(); \r
//if (out==null)\r
// return false;\r
\r
- Header h = bitstream.readFrame(); \r
- \r
- if (h==null)\r
- return false;\r
+// Header h = bitstream.readFrame(); \r
+// \r
+// if (h==null)\r
+// return false;\r
\r
// sample buffer set when decoder constructed\r
- SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream);\r
+ SampleBuffer output = (SampleBuffer)decoder.decodeFrame(header, bitstream);\r
\r
//synchronized (this)\r
//{\r