Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add direct access to frame pict type in Frame Class #1730

Merged
merged 5 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ public synchronized Frame grabFrame(boolean doAudio, boolean doVideo, boolean do
done = true;
frame.timestamp = timestamp;
frame.keyFrame = picture.key_frame() != 0;
frame.pictType = (char) av_get_picture_type_char( picture.pict_type());
}
}
} else if (doAudio && audio_st != null && pkt.stream_index() == audio_st.index()) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/bytedeco/javacv/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
import org.bytedeco.javacpp.indexer.UByteIndexer;
import org.bytedeco.javacpp.indexer.UShortIndexer;

import static org.bytedeco.ffmpeg.global.avutil.AV_PICTURE_TYPE_NONE;
import static org.bytedeco.ffmpeg.global.avutil.av_get_picture_type_char;

/**
* A class to manage the data of audio and video frames. It it used by
* {@link CanvasFrame}, {@link FrameGrabber}, {@link FrameRecorder}, and their
Expand All @@ -60,6 +63,7 @@
public class Frame implements AutoCloseable, Indexable {
/** A flag set by a FrameGrabber or a FrameRecorder to indicate a key frame. */
public boolean keyFrame;
public char pictType;

/** Constants to be used for {@link #imageDepth}. */
public static final int
Expand Down Expand Up @@ -128,6 +132,7 @@ public Frame(int width, int height, int depth, int channels, int imageStride) {
this.image = new Buffer[1];
this.data = null;
this.streamIndex = -1;
this.pictType = (char) av_get_picture_type_char(AV_PICTURE_TYPE_NONE);
saudet marked this conversation as resolved.
Show resolved Hide resolved

Pointer pointer = new BytePointer(imageHeight * imageStride * pixelSize(depth));
ByteBuffer buffer = pointer.asByteBuffer();
Expand Down Expand Up @@ -217,6 +222,7 @@ public Frame clone() {
newFrame.imageStride = imageStride;
newFrame.keyFrame = keyFrame;
newFrame.streamIndex = streamIndex;
newFrame.pictType = pictType;
newFrame.opaque = new Pointer[3];
if (image != null) {
newFrame.image = new Buffer[image.length];
Expand Down