From df51abd5f815bbbb8a66e106f554fed3ab7b05ae Mon Sep 17 00:00:00 2001 From: yeom Date: Wed, 13 Jul 2011 18:25:57 +0000 Subject: [PATCH] changes: taking decoder initilization out from ssjava loop since it is called only once. --- .../src/Tests/ssJava/mp3decoder/Decoder.java | 35 ++++++++++--------- .../src/Tests/ssJava/mp3decoder/Player.java | 19 ++++++---- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java index 19b20507..bcf918ba 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Decoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Decoder.java @@ -130,24 +130,25 @@ public class Decoder implements DecoderErrors * @return A SampleBuffer containing the decoded samples. */ public Obuffer decodeFrame(Header header, Bitstream stream) - throws DecoderException + throws DecoderException { - if (!initialized) - { - initialize(header,stream); - } - - int layer = header.layer(); - - output.clear_buffer(); - - FrameDecoder decoder = retrieveDecoder(header, stream, layer); - - decoder.decodeFrame(); - - output.write_buffer(1); - - return output; + // throw decoder initialization out of ssjava loop since it is invoked once + // if (!initialized) + // { + // initialize(header,stream); + // } + + int layer = header.layer(); + + output.clear_buffer(); + + FrameDecoder decoder = retrieveDecoder(header, stream, layer); + + decoder.decodeFrame(); + + output.write_buffer(1); + + return output; } /** diff --git a/Robust/src/Tests/ssJava/mp3decoder/Player.java b/Robust/src/Tests/ssJava/mp3decoder/Player.java index 90c4fc2c..b0f23560 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/Player.java +++ b/Robust/src/Tests/ssJava/mp3decoder/Player.java @@ -67,6 +67,8 @@ public class Player private int lastPosition = 0; + private Header header; + /** * Creates a new Player instance. */ @@ -80,6 +82,11 @@ public class Player { bitstream = new Bitstream(stream); decoder = new Decoder(); + + // decoder initialization + // taking out from ssjava loop + header = bitstream.readFrame(); + decoder.initialize(header, bitstream); // if (device!=null) // { @@ -111,7 +118,7 @@ public class Player { boolean ret = true; - SSJAVA: + SSJAVA: while (frames-- > 0 && ret) { ret = decodeFrame(); @@ -207,13 +214,13 @@ public class Player //if (out==null) // return false; - Header h = bitstream.readFrame(); - - if (h==null) - return false; +// Header h = bitstream.readFrame(); +// +// if (h==null) +// return false; // sample buffer set when decoder constructed - SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream); + SampleBuffer output = (SampleBuffer)decoder.decodeFrame(header, bitstream); //synchronized (this) //{ -- 2.34.1