www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,84 @@
|
|||
package org.jcodec.api.specific;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import org.jcodec.api.MediaInfo;
|
||||
import org.jcodec.codecs.h264.H264Decoder;
|
||||
import org.jcodec.codecs.h264.H264Utils;
|
||||
import org.jcodec.codecs.h264.io.model.NALUnit;
|
||||
import org.jcodec.codecs.h264.io.model.NALUnitType;
|
||||
import org.jcodec.codecs.h264.io.model.SeqParameterSet;
|
||||
import org.jcodec.common.DemuxerTrackMeta;
|
||||
import org.jcodec.common.model.ColorSpace;
|
||||
import org.jcodec.common.model.Packet;
|
||||
import org.jcodec.common.model.Picture;
|
||||
import org.jcodec.common.model.Rational;
|
||||
import org.jcodec.common.model.Size;
|
||||
import org.jcodec.containers.mp4.MP4Packet;
|
||||
|
||||
public class AVCMP4Adaptor implements ContainerAdaptor {
|
||||
private H264Decoder decoder;
|
||||
|
||||
private int curENo;
|
||||
|
||||
private Size size;
|
||||
|
||||
private DemuxerTrackMeta meta;
|
||||
|
||||
public AVCMP4Adaptor(DemuxerTrackMeta meta) {
|
||||
this.meta = meta;
|
||||
this.curENo = -1;
|
||||
calcBufferSize();
|
||||
}
|
||||
|
||||
private void calcBufferSize() {
|
||||
int w = Integer.MIN_VALUE, h = Integer.MIN_VALUE;
|
||||
ByteBuffer bb = this.meta.getCodecPrivate().duplicate();
|
||||
ByteBuffer b;
|
||||
while ((b = H264Utils.nextNALUnit(bb)) != null) {
|
||||
NALUnit nu = NALUnit.read(b);
|
||||
if (nu.type != NALUnitType.SPS)
|
||||
continue;
|
||||
SeqParameterSet sps = H264Utils.readSPS(b);
|
||||
int ww = sps.picWidthInMbsMinus1 + 1;
|
||||
if (ww > w)
|
||||
w = ww;
|
||||
int hh = SeqParameterSet.getPicHeightInMbs(sps);
|
||||
if (hh > h)
|
||||
h = hh;
|
||||
}
|
||||
this.size = new Size(w << 4, h << 4);
|
||||
}
|
||||
|
||||
public Picture decodeFrame(Packet packet, byte[][] data) {
|
||||
updateState(packet);
|
||||
Picture pic = this.decoder.decodeFrame(packet.getData(), data);
|
||||
Rational pasp = this.meta.getVideoCodecMeta().getPixelAspectRatio();
|
||||
if (pasp != null);
|
||||
return pic;
|
||||
}
|
||||
|
||||
private void updateState(Packet packet) {
|
||||
int eNo = ((MP4Packet)packet).getEntryNo();
|
||||
if (eNo != this.curENo)
|
||||
this.curENo = eNo;
|
||||
if (this.decoder == null)
|
||||
this.decoder = H264Decoder.createH264DecoderFromCodecPrivate(this.meta.getCodecPrivate());
|
||||
}
|
||||
|
||||
public boolean canSeek(Packet pkt) {
|
||||
updateState(pkt);
|
||||
return H264Utils.idrSlice(H264Utils.splitFrame(pkt.getData()));
|
||||
}
|
||||
|
||||
public byte[][] allocatePicture() {
|
||||
return Picture.create(this.size.getWidth(), this.size.getHeight(), ColorSpace.YUV444).getData();
|
||||
}
|
||||
|
||||
public MediaInfo getMediaInfo() {
|
||||
return new MediaInfo(this.size);
|
||||
}
|
||||
|
||||
public void shutdownThreadPool() {
|
||||
this.decoder.shutdownThreadPool();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.jcodec.api.specific;
|
||||
|
||||
import org.jcodec.api.MediaInfo;
|
||||
import org.jcodec.common.model.Packet;
|
||||
import org.jcodec.common.model.Picture;
|
||||
|
||||
public interface ContainerAdaptor {
|
||||
Picture decodeFrame(Packet paramPacket, byte[][] paramArrayOfbyte);
|
||||
|
||||
boolean canSeek(Packet paramPacket);
|
||||
|
||||
byte[][] allocatePicture();
|
||||
|
||||
MediaInfo getMediaInfo();
|
||||
|
||||
void shutdownThreadPool();
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package org.jcodec.api.specific;
|
||||
|
||||
import org.jcodec.api.MediaInfo;
|
||||
import org.jcodec.common.VideoDecoder;
|
||||
import org.jcodec.common.model.ColorSpace;
|
||||
import org.jcodec.common.model.Packet;
|
||||
import org.jcodec.common.model.Picture;
|
||||
import org.jcodec.common.model.Size;
|
||||
|
||||
public class GenericAdaptor implements ContainerAdaptor {
|
||||
private VideoDecoder decoder;
|
||||
|
||||
public GenericAdaptor(VideoDecoder detect) {
|
||||
this.decoder = detect;
|
||||
}
|
||||
|
||||
public Picture decodeFrame(Packet packet, byte[][] data) {
|
||||
return this.decoder.decodeFrame(packet.getData(), data);
|
||||
}
|
||||
|
||||
public boolean canSeek(Packet data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public MediaInfo getMediaInfo() {
|
||||
return new MediaInfo(new Size(0, 0));
|
||||
}
|
||||
|
||||
public byte[][] allocatePicture() {
|
||||
return Picture.create(1920, 1088, ColorSpace.YUV444).getData();
|
||||
}
|
||||
|
||||
public void shutdownThreadPool() {
|
||||
this.decoder.shutdownThreadPool();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue