Codota Logo
JPEGEncoder
Code IndexAdd Codota to your IDE (free)

How to use
JPEGEncoder
in
us.ihmc.codecs.yuv

Best Java code snippets using us.ihmc.codecs.yuv.JPEGEncoder (Showing top 15 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: us.ihmc/ihmc-video-codecs

/**
* Encode JPEG to buffer
* 
* @param picture Picture to encode. 
* @param quality JPEG quality factor in 0-100 
* @return Buffer with the JPEG data. Buffer.limit() equals the compressed length. This buffer gets re-used on subsequent calls to this function
* @throws IOException 
*/
public ByteBuffer encode(YUVPicture picture, int quality) throws IOException
{
 ByteBuffer target = byteBufferProvider.getOrCreateBuffer((int) maxSize(picture));
 int size = encode(picture, target, target.capacity(), quality);
 if (size < 0)
 {
   throw new IOException("Cannot encode picture");
 }
 target.limit(size);
 return target;
}
origin: us.ihmc/IHMCVideoCodecs

  public static void main(String[] args) throws IOException
  {
   JPEGDecoder decoder = new JPEGDecoder();
   YUVPicture jpeg = decoder.readJPEG(JPEGExample.class.getClassLoader().getResource("testImage.jpg"));
   jpeg.scale(jpeg.getWidth() * 2, jpeg.getHeight() * 2, FilterModeEnum.kFilterBilinear);
   JPEGEncoder encoder = new JPEGEncoder();
   int maxSize = (int) encoder.maxSize(jpeg);
   ByteBuffer buffer = ByteBuffer.allocateDirect((int) maxSize);
   int size = encoder.encode(jpeg, buffer, maxSize, 90);
   buffer.limit(size);

   RandomAccessFile file = new RandomAccessFile("test.jpg", "rw");
   FileChannel channel = file.getChannel();
   channel.write(buffer);
   file.close();

  }
}
origin: us.ihmc/ihmc-video-codecs

@Override
public void encodeFrame(YUVPicture frame) throws IOException
{
 ByteBuffer buffer = encoder.encode(frame, quality);
 ByteBuffer heapBuffer = ByteBuffer.allocate(buffer.remaining());
 heapBuffer.put(buffer);
 heapBuffer.flip();
 encodeFrame(heapBuffer);
}
origin: us.ihmc/ihmc-video-codecs

@Override
public void close() throws IOException
{
 Size size = new Size(width, height);
 SampleEntry sampleEntry = MP4Muxer.videoSampleEntry("jpeg", size, "IHMCVideoCodecs");
 track.addSampleEntry(sampleEntry);
 muxer.writeHeader();
 channel.close();
 encoder.delete();
}
origin: us.ihmc/IHMCVideoCodecs

@Override
public void encodeFrame(YUVPicture frame) throws IOException
{
 ByteBuffer buffer = encoder.encode(frame, quality);
 ByteBuffer heapBuffer = ByteBuffer.allocate(buffer.remaining());
 heapBuffer.put(buffer);
 heapBuffer.flip();
 encodeFrame(heapBuffer);
}
origin: us.ihmc/IHMCVideoCodecs

@Override
public void close() throws IOException
{
 Size size = new Size(width, height);
 SampleEntry sampleEntry = MP4Muxer.videoSampleEntry("jpeg", size, "IHMCVideoCodecs");
 track.addSampleEntry(sampleEntry);
 muxer.writeHeader();
 channel.close();
 encoder.delete();
}
origin: us.ihmc/IHMCVideoCodecs

/**
* Encode JPEG to buffer
* 
* @param picture Picture to encode. 
* @param quality JPEG quality factor in 0-100 
* @return Buffer with the JPEG data. Buffer.limit() equals the compressed length. This buffer gets re-used on subsequent calls to this function
* @throws IOException 
*/
public ByteBuffer encode(YUVPicture picture, int quality) throws IOException
{
 ByteBuffer target = byteBufferProvider.getOrCreateBuffer((int) maxSize(picture));
 int size = encode(picture, target, target.capacity(), quality);
 if (size < 0)
 {
   throw new IOException("Cannot encode picture");
 }
 target.limit(size);
 return target;
}
origin: us.ihmc/IHMCCommunication

  public byte[] convertBufferedImageToJPEGData(BufferedImage bufferedImage)
  {
   try
   {
     YUVPicture picture = converter.fromBufferedImage(bufferedImage, YUVSubsamplingType.YUV420);
     ByteBuffer buffer = encoder.encode(picture, 75);
     byte[] data = new byte[buffer.remaining()];
     buffer.get(data);
     return data;
   }
   catch (IOException e)
   {
     e.printStackTrace();
     return null;
   }
  }
}
origin: us.ihmc/ihmc-video-codecs

  public static void main(String[] args) throws IOException
  {
   JPEGDecoder decoder = new JPEGDecoder();
   YUVPicture jpeg = decoder.readJPEG(JPEGExample.class.getClassLoader().getResource("testImage.jpg"));
   jpeg.scale(jpeg.getWidth() * 2, jpeg.getHeight() * 2, FilterModeEnum.kFilterBilinear);
   JPEGEncoder encoder = new JPEGEncoder();
   int maxSize = (int) encoder.maxSize(jpeg);
   ByteBuffer buffer = ByteBuffer.allocateDirect((int) maxSize);
   int size = encoder.encode(jpeg, buffer, maxSize, 90);
   buffer.limit(size);

   RandomAccessFile file = new RandomAccessFile("test.jpg", "rw");
   FileChannel channel = file.getChannel();
   channel.write(buffer);
   file.close();

  }
}
origin: us.ihmc/ihmc-video-codecs

  /**
  * Encode JPEG to buffer
  * 
  * @param target Bytebuffer target. Position will be set to 0 and limit to compressed data length.
  * @param picture Picture to encode. 
  * @param quality JPEG quality factor in 0-100 
  * @throws IOException 
  */
  public void encode(ByteBuffer target, YUVPicture picture, int quality) throws IOException
  {
   int maxSize = (int) maxSize(picture);
   if (!target.isDirect())
   {
     throw new RuntimeException("Buffer must be allocated direct.");
   }
   if (target.capacity() < maxSize)
   {
     throw new IOException("Buffer is not large enough. Maximum compressed data size is " + maxSize + "bits");
   }
   int size = encode(picture, target, target.capacity(), quality);
   if (size < 0)
   {
     throw new IOException("Cannot encode picture");
   }
   target.limit(size);
  }
}
origin: us.ihmc/IHMCCommunication

@Override
public void updateImage(VideoSource videoSource, BufferedImage bufferedImage, long timeStamp, Point3d cameraPosition, Quat4d cameraOrientation, IntrinsicParameters intrinsicParameters)
{
 YUVPicture picture = converter.fromBufferedImage(bufferedImage, YUVSubsamplingType.YUV420);
 try
 {
   ByteBuffer buffer;
   synchronized (hackyLockBecauseJPEGEncoderIsNotThreadsafe)
   {
    buffer = encoder.encode(picture, 75);
   }
   byte[] data =  new byte[buffer.remaining()];
   buffer.get(data);
   handler.newVideoPacketAvailable(videoSource, timeStamp, data, cameraPosition, cameraOrientation, intrinsicParameters);
 }
 catch (IOException e)
 {
   e.printStackTrace();
 }
 picture.delete();
}
origin: us.ihmc/IHMCVideoCodecs

  /**
  * Encode JPEG to buffer
  * 
  * @param target Bytebuffer target. Position will be set to 0 and limit to compressed data length.
  * @param picture Picture to encode. 
  * @param quality JPEG quality factor in 0-100 
  * @throws IOException 
  */
  public void encode(ByteBuffer target, YUVPicture picture, int quality) throws IOException
  {
   int maxSize = (int) maxSize(picture);
   if (!target.isDirect())
   {
     throw new RuntimeException("Buffer must be allocated direct.");
   }
   if (target.capacity() < maxSize)
   {
     throw new IOException("Buffer is not large enough. Maximum compressed data size is " + maxSize + "bits");
   }
   int size = encode(picture, target, target.capacity(), quality);
   if (size < 0)
   {
     throw new IOException("Cannot encode picture");
   }
   target.limit(size);
  }
}
origin: us.ihmc/ihmc-robot-data-logger

ByteBuffer buffer = encoder.encode(yuv, 90);
if(buffer.remaining() <= MAXIMUM_IMAGE_DATA_SIZE)
origin: us.ihmc/RobotDataCommunication

ByteBuffer buffer = encoder.encode(yuv, 90);
int dataLength = buffer.remaining();
ByteBuffer sendBuffer = getOrCreateBuffer(dataLength + LogDataHeader.length());
origin: us.ihmc/IHMCRobotDataLogger

ByteBuffer buffer = encoder.encode(yuv, 90);
int dataLength = buffer.remaining();
ByteBuffer sendBuffer = getOrCreateBuffer(dataLength + LogDataHeader.length());
us.ihmc.codecs.yuvJPEGEncoder

Javadoc

JPEG Encoder using libjpeg-turbo. Keeps an internal buffer for data marshalling.

Most used methods

  • encode
  • <init>
  • delete
  • maxSize

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Kernel (java.awt.image)
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now