Inheritance: global::java.nio.Buffer, global::java.lang.Comparable
Beispiel #1
0
        public override ShortBuffer Put(ShortBuffer src)
        {
            if (src is DirectShortBufferU)
            {
                if (src == this)
                {
                    throw new IllegalArgumentException();
                }
                DirectShortBufferU sb = (DirectShortBufferU)src;

                int spos = sb.Position();
                int slim = sb.Limit();
                assert(spos <= slim);
                int srem = (spos <= slim ? slim - spos : 0);

                int pos = Position();
                int lim = Limit();
                assert(pos <= lim);
                int rem = (pos <= lim ? lim - pos : 0);

                if (srem > rem)
                {
                    throw new BufferOverflowException();
                }
                @unsafe.copyMemory(sb.Ix(spos), Ix(pos), (long)srem << 1);
                sb.Position(spos + srem);
                Position(pos + srem);
            }
            else if (src.Hb != null)
            {
                int spos = src.Position();
                int slim = src.Limit();
                assert(spos <= slim);
                int srem = (spos <= slim ? slim - spos : 0);

                Put(src.Hb, src.Offset + spos, srem);
                src.Position(spos + srem);
            }
            else
            {
                base.Put(src);
            }
            return(this);
        }
            private void initTriangle()
            {
                // float has 4 bytes
                ByteBuffer vbb = ByteBuffer.allocateDirect(_nrOfVertices * 3 * 4);
                vbb.order(ByteOrder.nativeOrder());
                _vertexBuffer = vbb.asFloatBuffer();

                // short has 2 bytes
                ByteBuffer ibb = ByteBuffer.allocateDirect(_nrOfVertices * 2);
                ibb.order(ByteOrder.nativeOrder());
                _indexBuffer = ibb.asShortBuffer();

                float[] coords = {
                    -0.5f, -0.5f, 0f, // (x1, y1, z1)
                    0.5f, -0.5f, 0f, // (x2, y2, z2)
                    0f, 0.5f, 0f // (x3, y3, z3)
                };

                _vertexBuffer.put(coords);
                _indexBuffer.put(_indicesArray);

                _vertexBuffer.position(0);
                _indexBuffer.position(0);
            }
            private void initTriangle()
            {
                float[] coords = {
                        -0.5f, -0.5f, 0.5f, // 0
                        0.5f, -0.5f, 0.5f, // 1
                        0f, -0.5f, -0.5f, // 2
                        0f, 0.5f, 0f, // 3
                };
                _nrOfVertices = coords.Length;

                float[] colors = {
                        1f, 0f, 0f, 1f, // point 0 red
                        0f, 1f, 0f, 1f, // point 1 green
                        0f, 0f, 1f, 1f, // point 2 blue
                        1f, 1f, 1f, 1f, // point 3 white
                };

                short[] indices = new short[] {
                        0, 1, 3, // rwg
                        0, 2, 1, // rbg
                        0, 3, 2, // rbw
                        1, 2, 3, // bwg
                };

                // float has 4 bytes, coordinate * 4 bytes
                ByteBuffer vbb = ByteBuffer.allocateDirect(coords.Length * 4);
                vbb.order(ByteOrder.nativeOrder());
                _vertexBuffer = vbb.asFloatBuffer();

                // short has 2 bytes, indices * 2 bytes
                ByteBuffer ibb = ByteBuffer.allocateDirect(indices.Length * 2);
                ibb.order(ByteOrder.nativeOrder());
                _indexBuffer = ibb.asShortBuffer();

                // float has 4 bytes, colors (RGBA) * 4 bytes
                ByteBuffer cbb = ByteBuffer.allocateDirect(colors.Length * 4);
                cbb.order(ByteOrder.nativeOrder());
                _colorBuffer = cbb.asFloatBuffer();

                _vertexBuffer.put(coords);
                _indexBuffer.put(indices);
                _colorBuffer.put(colors);

                _vertexBuffer.position(0);
                _indexBuffer.position(0);
                _colorBuffer.position(0);
            }
 public __Uint16Array(params ushort[] array)
 {
     InternalFloatArray = array;
     InternalBuffer = ShortBuffer.wrap(
         (short[])(object)array
     );
 }
Beispiel #5
0
 public override ShortBuffer Put(ShortBuffer src)
 {
     throw new ReadOnlyBufferException();
 }
Beispiel #6
0
 public static int avcodec_encode_audio(object avcc, object bp, int i, ShortBuffer sb)
 {
   JNI.Frame frame = (JNI.Frame) null;
   if (avcodec.__\u003Cjniptr\u003Eavcodec_encode_audio\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVCodecContext\u003BLcom\u002Fgooglecode\u002Fjavacpp\u002FBytePointer\u003BILjava\u002Fnio\u002FShortBuffer\u003B\u0029I == IntPtr.Zero)
     avcodec.__\u003Cjniptr\u003Eavcodec_encode_audio\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVCodecContext\u003BLcom\u002Fgooglecode\u002Fjavacpp\u002FBytePointer\u003BILjava\u002Fnio\u002FShortBuffer\u003B\u0029I = JNI.Frame.GetFuncPtr(avcodec.__\u003CGetCallerID\u003E(), "com/googlecode/javacv/cpp/avcodec", "avcodec_encode_audio", "(Lcom/googlecode/javacv/cpp/avcodec$AVCodecContext;Lcom/googlecode/javacpp/BytePointer;ILjava/nio/ShortBuffer;)I");
   // ISSUE: explicit reference operation
   IntPtr num1 = ((JNI.Frame) @frame).Enter(avcodec.__\u003CGetCallerID\u003E());
   try
   {
     IntPtr num2 = num1;
     // ISSUE: explicit reference operation
     IntPtr num3 = ((JNI.Frame) @frame).MakeLocalRef((object) ClassLiteral<avcodec>.Value);
     // ISSUE: explicit reference operation
     IntPtr num4 = ((JNI.Frame) @frame).MakeLocalRef(avcc);
     // ISSUE: explicit reference operation
     IntPtr num5 = ((JNI.Frame) @frame).MakeLocalRef(bp);
     int num6 = i;
     // ISSUE: explicit reference operation
     IntPtr num7 = ((JNI.Frame) @frame).MakeLocalRef((object) sb);
     // ISSUE: cast to a function pointer type
     // ISSUE: function pointer call
     return __calli((__FnPtr<int (IntPtr, IntPtr, IntPtr, IntPtr, int, IntPtr)>) avcodec.__\u003Cjniptr\u003Eavcodec_encode_audio\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVCodecContext\u003BLcom\u002Fgooglecode\u002Fjavacpp\u002FBytePointer\u003BILjava\u002Fnio\u002FShortBuffer\u003B\u0029I)(num2, (int) num3, num4, num5, (IntPtr) num6, num7);
   }
   catch (object ex)
   {
     Console.WriteLine((object) "*** exception in native code ***");
     Console.WriteLine(ex);
     throw;
   }
   finally
   {
     // ISSUE: explicit reference operation
     ((JNI.Frame) @frame).Leave();
   }
 }
Beispiel #7
0
 public static int av_resample(object avrc, ShortBuffer sb1, ShortBuffer sb2, int[] iarr, int i1, int i2, int i3)
 {
   JNI.Frame frame = (JNI.Frame) null;
   if (avcodec.__\u003Cjniptr\u003Eav_resample\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVResampleContext\u003BLjava\u002Fnio\u002FShortBuffer\u003BLjava\u002Fnio\u002FShortBuffer\u003B\u005BIIII\u0029I == IntPtr.Zero)
     avcodec.__\u003Cjniptr\u003Eav_resample\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVResampleContext\u003BLjava\u002Fnio\u002FShortBuffer\u003BLjava\u002Fnio\u002FShortBuffer\u003B\u005BIIII\u0029I = JNI.Frame.GetFuncPtr(avcodec.__\u003CGetCallerID\u003E(), "com/googlecode/javacv/cpp/avcodec", "av_resample", "(Lcom/googlecode/javacv/cpp/avcodec$AVResampleContext;Ljava/nio/ShortBuffer;Ljava/nio/ShortBuffer;[IIII)I");
   // ISSUE: explicit reference operation
   IntPtr num1 = ((JNI.Frame) @frame).Enter(avcodec.__\u003CGetCallerID\u003E());
   try
   {
     IntPtr num2 = num1;
     // ISSUE: explicit reference operation
     IntPtr num3 = ((JNI.Frame) @frame).MakeLocalRef((object) ClassLiteral<avcodec>.Value);
     // ISSUE: explicit reference operation
     IntPtr num4 = ((JNI.Frame) @frame).MakeLocalRef(avrc);
     // ISSUE: explicit reference operation
     IntPtr num5 = ((JNI.Frame) @frame).MakeLocalRef((object) sb1);
     // ISSUE: explicit reference operation
     IntPtr num6 = ((JNI.Frame) @frame).MakeLocalRef((object) sb2);
     // ISSUE: explicit reference operation
     IntPtr num7 = ((JNI.Frame) @frame).MakeLocalRef((object) iarr);
     int num8 = i1;
     int num9 = i2;
     int num10 = i3;
     // ISSUE: cast to a function pointer type
     // ISSUE: function pointer call
     return __calli((__FnPtr<int (IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, int, int, int)>) avcodec.__\u003Cjniptr\u003Eav_resample\u0028Lcom\u002Fgooglecode\u002Fjavacv\u002Fcpp\u002Favcodec\u0024AVResampleContext\u003BLjava\u002Fnio\u002FShortBuffer\u003BLjava\u002Fnio\u002FShortBuffer\u003B\u005BIIII\u0029I)((int) num2, (int) num3, (int) num4, num5, num6, num7, (IntPtr) num8, (IntPtr) num9, (IntPtr) num10);
   }
   catch (object ex)
   {
     Console.WriteLine((object) "*** exception in native code ***");
     Console.WriteLine(ex);
     throw;
   }
   finally
   {
     // ISSUE: explicit reference operation
     ((JNI.Frame) @frame).Leave();
   }
 }
            private void initTriangle()
            {
                // float has 4 bytes
                ByteBuffer vbb = ByteBuffer.allocateDirect(_nrOfVertices * 3 * 4);
                vbb.order(ByteOrder.nativeOrder());
                _vertexBuffer = vbb.asFloatBuffer();

                // short has 4 bytes
                ByteBuffer ibb = ByteBuffer.allocateDirect(_nrOfVertices * 2);
                ibb.order(ByteOrder.nativeOrder());
                _indexBuffer = ibb.asShortBuffer();

                // float has 4 bytes, 4 colors (RGBA) * number of vertices * 4 bytes
                ByteBuffer cbb = ByteBuffer.allocateDirect(4 * _nrOfVertices * 4);
                cbb.order(ByteOrder.nativeOrder());
                _colorBuffer = cbb.asFloatBuffer();

                float[] coords = {
                    -0.5f, -0.5f, 0f, // (x1, y1, z1)
                    0.5f, -0.5f, 0f, // (x2, y2, z2)
                    0.5f, 0.5f, 0f // (x3, y3, z3)
                };

                float[] colors = {
                    1f, 0f, 0f, 1f, // point 1
                    0f, 1f, 0f, 1f, // point 2
                    0f, 0f, 1f, 1f, // point 3
                };

                _vertexBuffer.put(coords);
                _indexBuffer.put(_indicesArray);
                _colorBuffer.put(colors);

                _vertexBuffer.position(0);
                _indexBuffer.position(0);
                _colorBuffer.position(0);
            }