Exemple #1
0
 public static extern nvjpegStatus nvjpegDecodeJpeg(
     nvjpegHandle handle,
     nvjpegJpegDecoder decoder,
     nvjpegJpegState decoder_state,
     nvjpegJpegStream jpeg_bitstream,
     ref nvjpegImage destination,
     nvjpegDecodeParams decode_params,
     CUstream stream);
Exemple #2
0
 public void EncodeImage(EncoderParams encoderParams, nvjpegImage source, nvjpegInputFormat input_format, int image_width, int image_height, CudaStream stream)
 {
     res = NvJpegNativeMethods.nvjpegEncodeImage(_nvJpeg.Handle, _state, encoderParams.Params, ref source, input_format, image_width, image_height, stream.Stream);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvjpegEncodeImage", res));
     if (res != nvjpegStatus.Success)
     {
         throw new NvJpegException(res);
     }
 }
Exemple #3
0
 public static extern nvjpegStatus nvjpegEncodeImage(
     nvjpegHandle handle,
     nvjpegEncoderState encoder_state,
     nvjpegEncoderParams encoder_params,
     ref nvjpegImage source,
     nvjpegInputFormat input_format,
     int image_width,
     int image_height,
     CUstream stream);
Exemple #4
0
 public static extern nvjpegStatus nvjpegEncodeYUV(
     nvjpegHandle handle,
     nvjpegEncoderState encoder_state,
     nvjpegEncoderParams encoder_params,
     ref nvjpegImage source,
     nvjpegChromaSubsampling chroma_subsampling,
     int image_width,
     int image_height,
     CUstream stream);
Exemple #5
0
 // finishing async operations on the device
 public void DecodeJpegDevice(ref nvjpegImage destination, CudaStream cudaStream)
 {
     res = NvJpegNativeMethods.nvjpegDecodeJpegDevice(_nvJpeg.Handle, _decoder.Decoder, _state, ref destination, cudaStream.Stream);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvjpegDecodeJpegDevice", res));
     if (res != nvjpegStatus.Success)
     {
         throw new NvJpegException(res);
     }
 }
Exemple #6
0
        /// <summary>
        /// Decodes a single image, and writes the decoded image in the desired format to the output buffers. This function is asynchronous with respect to the host. All GPU tasks for this function will be submitted to the provided stream.<para/>
        /// Note: Synchronizes on stream. For async use IntPtr!
        /// </summary>
        /// <param name="data">the encoded data.</param>
        /// <param name="output_format">Format in which the decoded output will be saved.</param>
        /// <param name="destination">Pointer to the structure that describes the output destination. This structure should be on the host (CPU), but the pointers in this structure should be pointing to the device (i.e., GPU) memory.</param>
        /// <param name="stream">The CUDA stream where all of the GPU work will be submitted.</param>
        public void Decode(byte[] data, nvjpegOutputFormat output_format, ref nvjpegImage destination, CudaStream stream)
        {
            GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);

            try
            {
                IntPtr ptr = handle.AddrOfPinnedObject();
                res = NvJpegNativeMethods.nvjpegDecode(_nvJpeg.Handle, _state, ptr, data.Length, output_format, ref destination, stream.Stream);
                Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvjpegDecode", res));
                stream.Synchronize();
            }
            finally
            {
                handle.Free();
            }

            if (res != nvjpegStatus.Success)
            {
                throw new NvJpegException(res);
            }
        }
Exemple #7
0
 public static extern nvjpegStatus nvjpegDecodeJpegDevice(
     nvjpegHandle handle,
     nvjpegJpegDecoder decoder,
     nvjpegJpegState decoder_state,
     ref nvjpegImage destination,
     CUstream stream);
Exemple #8
0
 public static extern nvjpegStatus nvjpegDecode(nvjpegHandle handle, nvjpegJpegState jpeg_handle, IntPtr data,
                                                SizeT length, nvjpegOutputFormat output_format, ref nvjpegImage destination, CUstream stream);
Exemple #9
0
 /// <summary>
 /// Decodes a single image, and writes the decoded image in the desired format to the output buffers. This function is asynchronous with respect to the host. All GPU tasks for this function will be submitted to the provided stream.
 /// </summary>
 /// <param name="data">the encoded data.</param>
 /// <param name="length">Size of the encoded data in bytes.</param>
 /// <param name="output_format">Format in which the decoded output will be saved.</param>
 /// <param name="destination">Pointer to the structure that describes the output destination. This structure should be on the host (CPU), but the pointers in this structure should be pointing to the device (i.e., GPU) memory.</param>
 /// <param name="stream">The CUDA stream where all of the GPU work will be submitted.</param>
 public void Decode(IntPtr data, SizeT length, nvjpegOutputFormat output_format, ref nvjpegImage destination, CudaStream stream)
 {
     res = NvJpegNativeMethods.nvjpegDecode(_nvJpeg.Handle, _state, data, length, output_format, ref destination, stream.Stream);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvjpegDecode", res));
     if (res != nvjpegStatus.Success)
     {
         throw new NvJpegException(res);
     }
 }