示例#1
0
  // This finds the final sums of iR[i]
  private int findSumiRi() {
    int[] sum = new int[29];
    int length = 28;

    // Find iRi
    int[] iR = new int[29];

    for (int i = 0; i < 29; i++) iR[i] = M.myMod((i * R[i]), 29);

    // System.out.print("iRi: ");
    // for(int i = 0; i < 29; i++)
    // System.out.print(iR[i] + " ");
    // System.out.println();

    for (int i = 0; i < 29; i++) sum[i] = iR[i];

    for (int j = 0; j < 28; j++) {
      for (int i = 0; i < length; i++) {
        sum[i] = sum[i + 1] - sum[i];
        sum[i] = M.myMod(sum[i], 29);
        // System.out.print(sum[i] + " ");
      }
      length = length - 1;
      // System.out.println();
    }
    return sum[0];
  }
示例#2
0
 // Main method just calls various functions and prints messages
 public static void main(String[] args) throws IOException {
   M.getFileInput();
   M.processAllBlocks();
   M.writeFile();
   M.checkForError();
   System.out.println("\nRecieved Message: " + message);
   System.out.println("Decoded Message: " + decodedMessage);
 }
示例#3
0
    public void decode(Decoder decoder) {
      super.decode(decoder);

      int2 = decoder.decodeInt();
      string2 = decoder.decodeString();

      int length = decoder.decodeInt();
      buffer2 = decoder.decodeKnownLengthBuffer(length, true);
    }
示例#4
0
  // This finds the final sums of EiRi[] and stores it in RiEiLeading[]
  private void findSums(int[] myArray) // This is for RiEi
      {
    int[] sum = myArray;
    int length = 28;

    /*
     * System.out.print("Ri: "); // Delete Later for(int i = 0; i < 29; i++)
     * System.out.print(R[i] + ", "); System.out.println();
     *
     * System.out.print("Ei: "); // Delete Later for(int i = 0; i < 29; i++)
     * System.out.print(Ei[i] + ", "); System.out.println("\n");
     *
     * System.out.print("RiEi: "); for(int i = 0; i < 29; i++)
     * System.out.print(myArray[i] + ", "); System.out.println();
     */

    RiEiLeading[0] = myArray[0];

    for (int j = 0; j < 28; j++) {
      for (int i = 0; i < length; i++) {
        sum[i] = sum[i + 1] - sum[i];
        sum[i] = M.myMod(sum[i], 29);
        // System.out.print(sum[i] + " ");
      }
      RiEiLeading[j + 1] = sum[0];
      length--;
    }
  }
示例#5
0
  public static void fromJSON(Reader r, ConfigurationAdmin admin) throws Exception {

    Decoder decoder = codec.dec().from(r);
    Protocol p = decoder.get(Protocol.class);
    for (int i = 0; i < p.size; i++) {
      Export e = decoder.get(Export.class);
      Configuration c;
      if (e.factoryPid != null) {
        c = admin.createFactoryConfiguration(e.factoryPid, "?*");
      } else {
        c = admin.getConfiguration(e.pid, "?*");
      }

      Dictionary<String, Object> d = getDictionary(e.types, e.values);
      c.update(d);
    }
  }
示例#6
0
 public void decode(Decoder decoder) {
   int1 = decoder.decodeInt();
   float1 = decoder.decodeFloat();
   long1 = decoder.decodeLong();
   boolean1 = decoder.decodeBoolean();
   string1 = decoder.decodeString();
   date1 = decoder.decodeDate();
   bytes1 = decoder.decodeBytes();
   codable1 = decoder.decodeCodable();
 }
示例#7
0
  private void findRiandEiandEiRi() {
    // FIND EI AND RIEI
    for (int j = 0; j < 29; j++) {
      Ei[j] = (j + (alpha + 29)) % 29;
      RiEi[j] = (Ei[j] * R[j]) % 29;
    }

    // FIND LEADING COEFFECIENTs FOR ALL SUMS OF RIEI
    M.findSums(RiEi);
  }
示例#8
0
  // For each block, this finds E(t), Q(t), P(t)
  private void processAllBlocks() {
    for (int i = 0; i < message.length() / 29; i++) {
      System.out.print("\nFor block #" + i);
      M.convert();
      M.getRiAndiRi(i);
      M.findAlpha(i);
      M.findRiandEiandEiRi();
      M.alterCArray();

      M.buildQ();
      M.buildP();
      M.printP();

      start = start + 29;

      // RESET EVERYTHING
      Q = new int[28];
      P = new int[27];
      R = new int[29];
    }
  }
示例#9
0
 /** Frees all system resources, which are bounded to this object. */
 @Override
 public void close() {
   super.close();
   if (filter1 != null) {
     filter1.close();
   }
   filter1 = null;
   if (filter2 != null) {
     filter2.close();
   }
   filter2 = null;
   if (equalizer != null) {
     equalizer.close();
   }
   equalizer = null;
   if (spline != null) {
     spline.close();
   }
   spline = null;
 }
示例#10
0
  // This finds the final sums of R[i]
  private int findSumRi() {
    int[] sum = new int[29];
    int length = 28;

    for (int i = 0; i < 29; i++) sum[i] = R[i];

    // System.out.print("Ri: ");
    // for(int i = 0; i < 29; i++)
    // System.out.print(R[i] + " "); // WAS System.out.print(R[i + start] +
    // " ");

    System.out.println();

    for (int j = 0; j < 28; j++) {
      for (int i = 0; i < length; i++) {
        sum[i] = sum[i + 1] - sum[i];
        sum[i] = M.myMod(sum[i], 29);
        // System.out.print(sum[i] + " ");
      }
      length = length - 1;
      // System.out.println();
    }
    return sum[0];
  }
示例#11
0
 // This multiplies each leading sum of RiEi with each of the corresponding
 // C_K value and stores it in alteredCArrays
 private void alterCArray() {
   for (int k = 0; k < 28; k++) alteredCArrays[k] = M.multiplyArray(RiEiLeading[k], cArrays[k]);
 }
示例#12
0
 // This calls the other methods to get the finalSums of Ri and iRi
 private void getRiAndiRi(int i) {
   finalSumRi[i] = M.findSumRi();
   finalSumiRi[i] = M.findSumiRi();
 }
示例#13
0
文件: RfbProto.java 项目: mzhou/bVNC
  public void processProtocol(VncCanvas vncCanvas, boolean useLocalCursor) throws Exception {
    boolean exitforloop = false;
    int msgType = 0;

    try {
      setEncodings(useLocalCursor);
      vncCanvas.writeFullUpdateRequest(false);

      //
      // main dispatch loop
      //
      while (maintainConnection) {
        exitforloop = false;
        if (!vncCanvas.useFull) {
          vncCanvas.syncScroll();
          // Read message type from the server.
          msgType = readServerMessageType();
          vncCanvas.doneWaiting();
        } else msgType = readServerMessageType();

        // Process the message depending on its type.
        switch (msgType) {
          case RfbProto.FramebufferUpdate:
            readFramebufferUpdate();

            for (int i = 0; i < updateNRects; i++) {
              readFramebufferUpdateRectHdr();

              switch (updateRectEncoding) {
                case RfbProto.EncodingTight:
                  decoder.handleTightRect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingPointerPos:
                  vncCanvas.softCursorMove(updateRectX, updateRectY);
                  break;
                case RfbProto.EncodingXCursor:
                case RfbProto.EncodingRichCursor:
                  decoder.handleCursorShapeUpdate(
                      this, updateRectEncoding, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingLastRect:
                  exitforloop = true;
                  break;
                case RfbProto.EncodingCopyRect:
                  decoder.handleCopyRect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingNewFBSize:
                  setFramebufferSize(updateRectW, updateRectH);
                  vncCanvas.updateFBSize();
                  exitforloop = true;
                  break;
                case RfbProto.EncodingRaw:
                  decoder.handleRawRect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingRRE:
                  decoder.handleRRERect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingCoRRE:
                  decoder.handleCoRRERect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingHextile:
                  decoder.handleHextileRect(
                      this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingZRLE:
                  decoder.handleZRLERect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                case RfbProto.EncodingZlib:
                  decoder.handleZlibRect(this, updateRectX, updateRectY, updateRectW, updateRectH);
                  break;
                default:
                  Log.e(
                      TAG,
                      "Unknown RFB rectangle encoding "
                          + updateRectEncoding
                          + " (0x"
                          + Integer.toHexString(updateRectEncoding)
                          + ")");
              }

              if (exitforloop) {
                exitforloop = false;
                break;
              }
            }

            if (decoder.isChangedColorModel()) {
              decoder.setPixelFormat(this);
              // setEncodings(useLocalCursor);
              vncCanvas.writeFullUpdateRequest(false);
            } else {
              // setEncodings(useLocalCursor);
              vncCanvas.writeFullUpdateRequest(true);
            }
            break;

          case RfbProto.SetColourMapEntries:
            throw new Exception("Can't handle SetColourMapEntries message");

          case RfbProto.Bell:
            vncCanvas.displayShortToastMessage("VNC Beep");
            break;

          case RfbProto.ServerCutText:
            vncCanvas.serverJustCutText = true;
            vncCanvas.setClipboardText(readServerCutText());
            break;

          case RfbProto.TextChat:
            // UltraVNC extension
            String msg = readTextChatMsg();
            if (msg != null && msg.length() > 0) {
              // TODO implement chat interface
            }
            break;

          default:
            throw new Exception("Unknown RFB message type " + msgType);
        }
      }
    } catch (Exception e) {
      closeSocket();
      throw e;
    } finally {
      closeSocket();
      Log.v(TAG, "Closing VNC Connection");
    }
    closeSocket();
  }
示例#14
0
  /**
   * Main decoder routine Usage :Decoder bitstream_file outputspeech_file
   *
   * <p>Format for bitstream_file: One (2-byte) synchronization word One (2-byte) size word, 80
   * words (2-byte) containing 80 bits.
   *
   * <p>Format for outputspeech_file: Synthesis is written to a binary file of 16 bits data.
   *
   * @param args bitstream_file outputspeech_file
   * @throws java.io.IOException
   */
  public static void main(String[] args) throws IOException {
    OutputStream f_syn;
    InputStream f_serial;

    short[] serial = new short[SERIAL_SIZE]; /* Serial stream              */
    short[] sp16 = new short[L_FRAME]; /* Buffer to write 16 bits speech */

    int frame;

    System.out.printf("\n");
    System.out.printf("**************    G.729  8 KBIT/S SPEECH DECODER    ************\n");
    System.out.printf("\n");
    System.out.printf("----------------- Floating point C simulation ----------------\n");
    System.out.printf("\n");
    System.out.printf("------------ Version 1.01 (Release 2, November 2006) --------\n");
    System.out.printf("\n");

    /* Passed arguments */

    if (args.length != 2) {
      System.out.printf("Usage :Decoder bitstream_file  outputspeech_file\n");
      System.out.printf("\n");
      System.out.printf("Format for bitstream_file:\n");
      System.out.printf("  One (2-byte) synchronization word \n");
      System.out.printf("  One (2-byte) size word,\n");
      System.out.printf("  80 words (2-byte) containing 80 bits.\n");
      System.out.printf("\n");
      System.out.printf("Format for outputspeech_file:\n");
      System.out.printf("  Synthesis is written to a binary file of 16 bits data.\n");
      System.exit(1);
    }

    /* Open file for synthesis and packed serial stream */

    try {
      f_serial = new FileInputStream(args[0]);
    } catch (IOException ex) {
      System.out.printf("Decoder - Error opening file  %s !!\n", args[0]);
      System.exit(0);
      throw ex; // Silence the compiler.
    }

    try {
      f_syn = new FileOutputStream(args[1]);
    } catch (IOException ex) {
      System.out.printf("Decoder - Error opening file  %s !!\n", args[1]);
      System.exit(0);
      throw ex; // Silence the compiler.
    }

    System.out.printf("Input bitstream file  :   %s\n", args[0]);
    System.out.printf("Synthesis speech file :   %s\n", args[1]);

    /*-----------------------------------------------------------------*
     *           Initialization of decoder                             *
     *-----------------------------------------------------------------*/

    Decoder decoder = new Decoder();

    /*-----------------------------------------------------------------*
     *            Loop for each "L_FRAME" speech data                  *
     *-----------------------------------------------------------------*/

    frame = 0;
    while (Util.fread(serial, SERIAL_SIZE, f_serial) == SERIAL_SIZE) {
      frame++;
      System.out.printf(" Frame: %d\r", frame);

      decoder.process(serial, sp16);

      Util.fwrite(sp16, L_FRAME, f_syn);
    }

    f_syn.close();
    f_serial.close();
  }