import au.notzed.jjmpeg.AVCodecParameters;
import au.notzed.jjmpeg.AVDictionary;
import au.notzed.jjmpeg.AVDiscardBits;
-import au.notzed.jjmpeg.AVError;
import au.notzed.jjmpeg.AVFormatContext;
import au.notzed.jjmpeg.AVFrame;
import au.notzed.jjmpeg.AVIOException;
import au.notzed.jjmpeg.AVStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
+import java.util.List;
import java.util.logging.Logger;
/**
switch (cp.getCodecType()) {
case AVMediaType.AVMEDIA_TYPE_VIDEO:
streams[i] = new JJReaderVideo(s, cp);
+ s.setDiscard(AVDiscardBits.AVDISCARD_NONE);
break;
case AVMediaType.AVMEDIA_TYPE_AUDIO:
streams[i] = new JJReaderAudio(s, cp);
* @throws AVIOException
*/
public <T extends JJReaderStream> T openDefaultStream(Class<T> type) throws AVIOException {
- for (JJReaderStream rs : streams) {
+ for (JJReaderStream rs: streams) {
if (type.isInstance(rs)) {
T m = type.cast(rs);
if (!m.isOpened())
return null;
}
+ public List<? extends JJReaderStream> getStreams() {
+ return List.of(streams);
+ }
+
public Iterable<? extends JJReaderStream> streams() {
return () -> {
return new Iterator<JJReaderStream>() {
}
public void release() {
- for (JJReaderStream m : streams) {
+ for (JJReaderStream m: streams) {
m.release();
}
format.release();
* e.g. after a seek.
*/
public void flushCodec() {
- for (JJReaderStream rs : streams) {
+ for (JJReaderStream rs: streams) {
rs.flushCodec();
}
}
private long currentVideoMS() {
- for (JJReaderStream r : streams) {
+ for (JJReaderStream r: streams) {
if (r instanceof JJReaderVideo) {
return r.convertPTS(getPTS());
}
*
* @return
*/
- public JJReaderStream readFrame() throws AVIOException {
+ public JJReaderStream readFrameOLD() throws AVIOException {
if (freePacket) {
packet.clear();
JJReaderStream last;
- public JJReaderStream readFrameX() throws AVIOException {
+ public JJReaderStream readFrame() throws AVIOException {
if (freePacket) {
packet.clear();
}
this.cp = cp;
// Hmm, what if i want to override CodedID?
codec = AVCodec.findDecoder(cp.getCodecID());
- if (codec == null)
- throw new AVIOException(AVError.AVERROR_DECODER_NOT_FOUND);
+ if (codec == null) {
+ frame = null;
+ return;
+ }
c = AVCodecContext.allocContext(codec);
* @return
*/
public long convertPTS(long pts) {
- return tb.rescale(pts, 1000) - startms;
+ return tb.rescale(pts - startpts, 1000);
+ }
+
+ /**
+ * Convert the 'pts' to milliseconds as presented in the stream.
+ *
+ * @param pts
+ * @return
+ */
+ public long absolutePTS(long pts) {
+ return tb.rescale(pts, 1000);
}
/**
@Override
public void open() throws AVIOException {
- throw new AVIOException(AVError.AVERROR_UNKNOWN, "Unknown stream type");
+ //throw new AVIOException(AVError.AVERROR_UNKNOWN, "Unknown stream type");
}
@Override
@Override
public void open() throws AVIOException {
- if (cp.getPixelFormat() == AVPixelFormat.AV_PIX_FMT_NONE) {
- throw new AVIOException(AVError.AVERROR_INVALIDDATA, "No decodable video present");
- }
+ //if (cp.getPixelFormat() == AVPixelFormat.AV_PIX_FMT_NONE) {
+ // throw new AVIOException(AVError.AVERROR_INVALIDDATA, "No decodable video present");
+ //}
Logger.getLogger("jjmpeg.io")
.fine(() -> {
au/notzed/jjmpeg/AVCodecIDBits.java \
au/notzed/jjmpeg/AVDiscardBits.java \
au/notzed/jjmpeg/AVErrorBits.java \
+ au/notzed/jjmpeg/AVFrameSideDataTypeBits.java \
au/notzed/jjmpeg/AVIOContextBits.java \
au/notzed/jjmpeg/AVMediaTypeBits.java \
au/notzed/jjmpeg/AVOptionsBits.java \
@install -d $(@D)
perl $(extract_enum) -I$(FFMPEG_HOME)/include AVDiscard AVDISCARD_ $(FFMPEG_HOME)/include/libavcodec/avcodec.h $@
+$(tmp)/AVFrameSideDataTypeBits-gen.c: $(extract_defines) $(dep)
+ @install -d $(@D)
+ perl $(extract_enum) -I$(FFMPEG_HOME)/include AVFrameSideDataType AV_FRAME_ $(FFMPEG_HOME)/include/libavutil/frame.h $@
+
$(tmp)/AVChannelLayoutBits-gen.c: $(extract_enum) $(dep)
@install -d $(@D)
perl $(extract_defines) -f $(FFMPEG_HOME) -interface AVChannelLayoutBits -header libavutil/channel_layout.h -type long -d AV_CH_LAYOUT_ $@
#define MAX(a, b) ((a)>(b)?(a):(b))
jint AVFrame_OnLoad(JavaVM *vmi, JNIEnv *env) {
- return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn);
+ return nativez_ResolveReferences(env, java_names, &java)
+ || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn);
}
/* ********************************************************************** */
DLCALL(av_frame_unref)(frame);
}
+JNIEXPORT jobject JNICALL Java_au_notzed_jjmpeg_AVFrame_getSideData
+(JNIEnv *env, jobject jo, jint type) {
+ AVFrame *frame = NativeZ_getP(env, jo);
+ AVFrameSideData *sd;
+
+ printf("get side data len=%d type=%d\n", frame->nb_side_data, type);
+ fflush(stdout);
+
+ sd = DLCALL(av_frame_get_side_data)(frame, type);
+ return NativeZ_refer(env, AVFrameSideData_classid, sd);
+}
+
/* ********************************************************************** */
/* FrameReader */