Java Code Examples for org.jcodec.common.model.Size

The following examples show how to use org.jcodec.common.model.Size. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public H264FrameEncoder(final int width, final int height, final int bitRate) {
    this.encoder = new H264Encoder(new H264FixedRateControl(bitRate));
    this.out = ByteBuffer.allocate(width * height * 6);
    this.frameNumber = 0;

    final Size size = new Size(width, height);
    sps = this.encoder.initSPS(size);
    pps = this.encoder.initPPS();

    final ByteBuffer spsBuffer = ByteBuffer.allocate(512);
    this.sps.write(spsBuffer);
    spsBuffer.flip();

    final ByteBuffer serialSps = ByteBuffer.allocate(512);
    this.sps.write(serialSps);
    serialSps.flip();
    H264Utils.escapeNALinplace(serialSps);

    final ByteBuffer serialPps = ByteBuffer.allocate(512);
    this.pps.write(serialPps);
    serialPps.flip();
    H264Utils.escapeNALinplace(serialPps);

    final ByteBuffer serialAvcc = ByteBuffer.allocate(512);
    final AvcCBox avcC = AvcCBox.createAvcCBox(this.sps.profileIdc, 0, this.sps.levelIdc, 4,
            asList(serialSps), asList(serialPps));
    avcC.doWrite(serialAvcc);
    serialAvcc.flip();
    cpd = new byte[serialAvcc.remaining()];
    serialAvcc.get(cpd);
}