aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/av
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/av')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/CodecID.java667
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java (renamed from src/jogl/classes/com/jogamp/opengl/util/av/SubTextureEvent.java)21
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java11
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubTextEventLine.java (renamed from src/jogl/classes/com/jogamp/opengl/util/av/SubASSEventLine.java)40
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java37
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/VideoPixelFormat.java191
6 files changed, 925 insertions, 42 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/CodecID.java b/src/jogl/classes/com/jogamp/opengl/util/av/CodecID.java
new file mode 100644
index 000000000..b0c659649
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/CodecID.java
@@ -0,0 +1,667 @@
+/**
+ * Copyright 2024 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.util.av;
+
+/**
+ * FFmpeg/libAV analog {@code AVCodecID}.
+ * <p>
+ * Use {@link CodecID#fromFFmpeg(int)} to convert from FFmpeg's {@code AVCodecID}
+ * and {@link CodecID#toFFmpeg(CodecID) vice versa.
+ * </p>
+ */
+public enum CodecID {
+ NONE,
+
+ //
+ // Video Codecs
+ //
+
+ MPEG1VIDEO,
+ MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
+ H261,
+ H263,
+ RV10,
+ RV20,
+ MJPEG,
+ MJPEGB,
+ LJPEG,
+ SP5X,
+ JPEGLS,
+ MPEG4,
+ RAWVIDEO,
+ MSMPEG4V1,
+ MSMPEG4V2,
+ MSMPEG4V3,
+ WMV1,
+ WMV2,
+ H263P,
+ H263I,
+ FLV1,
+ SVQ1,
+ SVQ3,
+ DVVIDEO,
+ HUFFYUV,
+ CYUV,
+ H264,
+ INDEO3,
+ VP3,
+ THEORA,
+ ASV1,
+ ASV2,
+ FFV1,
+ ID_4XM,
+ VCR1,
+ CLJR,
+ MDEC,
+ ROQ,
+ INTERPLAY_VIDEO,
+ XAN_WC3,
+ XAN_WC4,
+ RPZA,
+ CINEPAK,
+ WS_VQA,
+ MSRLE,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X,
+ ADPCM_AICA,
+ ADPCM_IMA_DAT4,
+ ADPCM_MTAF,
+ ADPCM_AGM,
+ ADPCM_ARGO,
+ ADPCM_IMA_SSI,
+ ADPCM_ZORK,
+ ADPCM_IMA_APM,
+ ADPCM_IMA_ALP,
+ ADPCM_IMA_MTF,
+ ADPCM_IMA_CUNNING,
+ ADPCM_IMA_MOFLEX,
+ ADPCM_IMA_ACORN,
+ ADPCM_XMD,
+
+ /* AMR */
+ AMR_NB, // = 0x12000,
+ AMR_WB,
+
+ /* RealAudio codecs*/
+ RA_144, // = 0x13000,
+ RA_288,
+
+ //
+ // Various DPCM codecs
+ //
+
+ ROQ_DPCM, // = 0x14000,
+ INTERPLAY_DPCM,
+ XAN_DPCM,
+ SOL_DPCM,
+ SDX2_DPCM,
+ GREMLIN_DPCM,
+ DERF_DPCM,
+ WADY_DPCM,
+ CBD2_DPCM,
+
+ //
+ // Audio Codecs
+ //
+
+ MP2, // = 0x15000,
+ MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
+ AAC,
+ AC3,
+ DTS,
+ VORBIS,
+ DVAUDIO,
+ WMAV1,
+ WMAV2,
+ MACE3,
+ MACE6,
+ VMDAUDIO,
+ FLAC,
+ MP3ADU,
+ MP3ON4,
+ SHORTEN,
+ ALAC,
+ WESTWOOD_SND1,
+ GSM, ///< as in Berlin toast format
+ QDM2,
+ COOK,
+ TRUESPEECH,
+ TTA,
+ SMACKAUDIO,
+ QCELP,
+ WAVPACK,
+ DSICINAUDIO,
+ IMC,
+ MUSEPACK7,
+ MLP,
+ GSM_MS, /* as found in WAV */
+ ATRAC3,
+ APE,
+ NELLYMOSER,
+ MUSEPACK8,
+ SPEEX,
+ WMAVOICE,
+ WMAPRO,
+ WMALOSSLESS,
+ ATRAC3P,
+ EAC3,
+ SIPR,
+ MP1,
+ TWINVQ,
+ TRUEHD,
+ MP4ALS,
+ ATRAC1,
+ BINKAUDIO_RDFT,
+ BINKAUDIO_DCT,
+ AAC_LATM,
+ QDMC,
+ CELT,
+ G723_1,
+ G729,
+ ID_8SVX_EXP,
+ ID_8SVX_FIB,
+ BMV_AUDIO,
+ RALF,
+ IAC,
+ ILBC,
+ OPUS,
+ COMFORT_NOISE,
+ TAK,
+ METASOUND,
+ PAF_AUDIO,
+ ON2AVC,
+ DSS_SP,
+ CODEC2,
+ FFWAVESYNTH,
+ SONIC,
+ SONIC_LS,
+ EVRC,
+ SMV,
+ DSD_LSBF,
+ DSD_MSBF,
+ DSD_LSBF_PLANAR,
+ DSD_MSBF_PLANAR,
+ ID_4GV,
+ INTERPLAY_ACM,
+ XMA1,
+ XMA2,
+ DST,
+ ATRAC3AL,
+ ATRAC3PAL,
+ DOLBY_E,
+ APTX,
+ APTX_HD,
+ SBC,
+ ATRAC9,
+ HCOM,
+ ACELP_KELVIN,
+ MPEGH_3D_AUDIO,
+ SIREN,
+ HCA,
+ FASTAUDIO,
+ MSNSIREN,
+ DFPWM,
+ BONK,
+ MISC4,
+ APAC,
+ FTR,
+ WAVARC,
+ RKA,
+
+ //
+ // Subtitle Codecs
+ //
+ DVD_SUB, // = 0x17000,
+ DVB_SUB,
+ TEXT, ///< raw UTF-8 text
+ XSUB,
+ SSA,
+ MOV_TEXT,
+ HDMV_PGS,
+ DVB_TELETEXT,
+ SRT,
+ MICRODVD,
+ EIA_608,
+ JACOSUB,
+ SAMI,
+ REALTEXT,
+ STL,
+ SUBVIEWER1,
+ SUBVIEWER,
+ SUBRIP,
+ WEBVTT,
+ MPL2,
+ VPLAYER,
+ PJS,
+ ASS,
+ HDMV_TEXT,
+ TTML,
+ ARIB_CAPTION,
+
+ COUNT ///< number of codec IDs in this list
+ ;
+
+ /**
+ * Converts given FFmpeg {@code AVCodecID} to {@link CodecID} or {@code CodecID#NONE} if not matched.
+ */
+ public static CodecID fromFFmpeg(final int ffmpegID) {
+ final int ordinal;
+ if( ffmpegID >= 0x17000 ) {
+ ordinal = ffmpegID - 0x17000 + DVD_SUB.ordinal();
+ } else if( ffmpegID >= 0x15000 ) {
+ ordinal = ffmpegID - 0x15000 + MP2.ordinal();
+ } else if( ffmpegID >= 0x14000 ) {
+ ordinal = ffmpegID - 0x14000 + ROQ_DPCM.ordinal();
+ } else if( ffmpegID >= 0x13000 ) {
+ ordinal = ffmpegID - 0x13000 + RA_144.ordinal();
+ } else if( ffmpegID >= 0x12000 ) {
+ ordinal = ffmpegID - 0x12000 + AMR_NB.ordinal();
+ } else if( ffmpegID >= 0x11000 ) {
+ ordinal = ffmpegID - 0x11000 + ADPCM_IMA_QT.ordinal();
+ } else if( ffmpegID >= 0x10000 ) {
+ ordinal = ffmpegID - 0x10000 + PCM_S16LE.ordinal();
+ } else if( ffmpegID >= 0x8000 ) {
+ ordinal = ffmpegID - 0x8000 + Y41P.ordinal();
+ } else {
+ ordinal = ffmpegID;
+ }
+
+ /**
+ Y41P, // = 0x8000,
+ PCM_S16LE = 0x10000,
+ ADPCM_IMA_QT = 0x11000,
+ AMR_NB = 0x12000,
+ RA_144 = 0x13000,
+ ROQ_DPCM = 0x14000,
+ MP2 = 0x15000,
+ DVD_SUBTITLE = 0x17000,
+ */
+
+ final CodecID[] all = CodecID.values();
+ if( 0 <= ordinal && ordinal < all.length ) {
+ return all[ordinal];
+ }
+ return CodecID.NONE;
+ }
+
+ /** Converts given {@link CodecID} value into FFmpeg {@code AVCodecID} */
+ public static int toFFmpeg(final CodecID id) {
+ final int ordinal = id.ordinal();
+ final int ffmpegID;
+ if( ordinal >= DVD_SUB.ordinal() ) {
+ ffmpegID = ordinal - DVD_SUB.ordinal() + 0x17000;
+ } else if( ordinal >= MP2.ordinal() ) {
+ ffmpegID = ordinal - MP2.ordinal() + 0x15000;
+ } else if( ordinal >= ROQ_DPCM.ordinal() ) {
+ ffmpegID = ordinal - ROQ_DPCM.ordinal() + 0x14000;
+ } else if( ordinal >= RA_144.ordinal() ) {
+ ffmpegID = ordinal - RA_144.ordinal() + 0x13000;
+ } else if( ordinal >= AMR_NB.ordinal() ) {
+ ffmpegID = ordinal - AMR_NB.ordinal() + 0x12000;
+ } else if( ordinal >= ADPCM_IMA_QT.ordinal() ) {
+ ffmpegID = ordinal - ADPCM_IMA_QT.ordinal() + 0x11000;
+ } else if( ordinal >= PCM_S16LE.ordinal() ) {
+ ffmpegID = ordinal - PCM_S16LE.ordinal() + 0x10000;
+ } else if( ordinal >= Y41P.ordinal() ) {
+ ffmpegID = ordinal - Y41P.ordinal() + 0x8000;
+ } else {
+ ffmpegID = ordinal;
+ }
+ return ffmpegID;
+ }
+
+ /** Returns {@code true} if given {@link CodecID} refers to a video codec */
+ public static boolean isVideoCodec(final CodecID id) {
+ return MPEG1VIDEO.ordinal() <= id.ordinal() && id.ordinal() < PCM_S16LE.ordinal();
+ }
+ /** Returns {@code true} if given {@link CodecID} refers to an audio PCM codec */
+ public static boolean isAudioPCMCodec(final CodecID id) {
+ return PCM_S16LE.ordinal() <= id.ordinal() && id.ordinal() < MP2.ordinal();
+ }
+ /**
+ * Returns {@code true} if given {@link CodecID} refers to an audio codec.
+ * @param id the {@link CodecID}
+ * @param includePCM pass {@code true} to include {@link #isAudioPCMCodec(CodecID)}
+ */
+ public static boolean isAudioCodec(final CodecID id, final boolean includePCM) {
+ return includePCM && PCM_S16LE.ordinal() <= id.ordinal() && id.ordinal() < DVD_SUB.ordinal() ||
+ MP2.ordinal() <= id.ordinal() && id.ordinal() < DVD_SUB.ordinal();
+ }
+ /** Returns {@code true} if given {@link CodecID} refers to a subtitle codec */
+ public static boolean isSubtitleCodec(final CodecID id) {
+ return DVD_SUB.ordinal() <= id.ordinal() && id.ordinal() < COUNT.ordinal();
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubTextureEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java
index 86da736d6..68f25d046 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubTextureEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java
@@ -31,12 +31,12 @@ import com.jogamp.math.Vec2i;
import com.jogamp.opengl.util.texture.Texture;
/**
- * {@link Texture} event of {@link SubtitleEvent}
+ * Bitmap {@link Texture} event of {@link SubtitleEvent}
* <p>
* Consider {@link SubtitleEvent#pts_end} and {@link SubEmptyEvent}.
* </p>
*/
-public class SubTextureEvent extends SubtitleEvent {
+public class SubBitmapEvent extends SubtitleEvent {
/** To be implemented by the {@link Texture} owner to release the texture. */
public static interface TextureOwner {
/** The given {@link Texture} is to be released by the owner. */
@@ -52,20 +52,29 @@ public class SubTextureEvent extends SubtitleEvent {
/**
* Texture Event ctor
+ * @param codec the {@link CodecID}
* @param pos texture position
* @param dim texture dimension
* @param tex the {@link Texture} or {@code null} if unused
- * @param pts_start pts start in ms, provided for {@link SubTextureEvent.Format#ASS_FFMPEG} and {@link SubTextureEvent.Format#ASS_TEXT}
- * @param pts_end pts end in ms, provided for {@link SubTextureEvent.Format#ASS_FFMPEG} and {@link SubTextureEvent.Format#ASS_TEXT}
+ * @param pts_start pts start in ms
+ * @param pts_end pts end in ms, often {@link #isEndDefined()} for bitmap'ed types see {@link #pts_end}
* @param owner {@link Texture} owner code-stub to release the texture
*/
- public SubTextureEvent(final Vec2i pos, final Vec2i dim, final Texture tex, final int pts_start, final int pts_end, final TextureOwner owner) {
- super(Format.TEXTURE, pts_start, pts_end);
+ public SubBitmapEvent(final CodecID codec, final Vec2i pos, final Vec2i dim, final Texture tex, final int pts_start, final int pts_end, final TextureOwner owner) {
+ super(codec, pts_start, pts_end);
position = pos;
dimension = dim;
texture = tex;
this.owner = owner;
}
+
+ @Override
+ public final boolean isTextASS() { return false; }
+ @Override
+ public final boolean isBitmap() { return true; }
+ @Override
+ public final boolean isEmpty() { return false; }
+
/**
* {@inheritDoc}
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
index e97128a71..c49558c57 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
@@ -27,17 +27,24 @@
*/
package com.jogamp.opengl.util.av;
-/** Empty {@link SubtitleEvent}, used for PGS bitmap subtitle signaling end of previous {@link SubTextureEvent}. */
+/** Empty {@link SubtitleEvent}, used for bitmap subtitle signaling end of previous {@link SubBitmapEvent}, e.g. {@link CodecID#HDMV_PGS}. */
public class SubEmptyEvent extends SubtitleEvent {
/**
* Empty event ctor
*/
public SubEmptyEvent(final int pts_start, final int pts_end) {
- super(Format.EMPTY, pts_start, pts_end);
+ super(CodecID.NONE, pts_start, pts_end);
}
@Override
+ public final boolean isTextASS() { return false; }
+ @Override
+ public final boolean isBitmap() { return false; }
+ @Override
+ public final boolean isEmpty() { return true; }
+
+ @Override
public void release() {} // nothing to be released back to the owner
@Override
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubASSEventLine.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEventLine.java
index bd99122a9..c867dea9c 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubASSEventLine.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEventLine.java
@@ -28,12 +28,25 @@
package com.jogamp.opengl.util.av;
/**
- * ASS/SAA Event Line of {@link SubtitleEvent}
+ * Text Event Line including ASS/SAA of {@link SubtitleEvent}
* <p>
* See http://www.tcax.org/docs/ass-specs.htm
* </p>
*/
-public class SubASSEventLine extends SubtitleEvent {
+public class SubTextEventLine extends SubtitleEvent {
+ public enum Format {
+ /** Denoting {@link SubASSEventLine} using FFMpeg output w/o start, end:
+ * <pre>
+ 0 1 2 3 4 5 6 7 8
+ Seq, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, TEXT
+ * </pre>
+ */
+ ASS_FFMPEG,
+ /** Denoting {@link SubASSEventLine}, just the plain text part */
+ TEXT,
+ };
+ /** {@link Format} of this text subtitle event. */
+ public final Format format;
public final int seqnr;
public final int layer;
public final String style;
@@ -45,13 +58,15 @@ public class SubASSEventLine extends SubtitleEvent {
/**
* ASS/SAA Event Line ctor
- * @param fmt input format of {@code ass}, currently only {@link SubASSEventLine.Format#ASS_FFMPEG} and {@link SubASSEventLine.Format#ASS_TEXT} is supported
+ * @param codec the {@link CodecID}
+ * @param fmt input format of {@code ass}, currently only {@link SubTextEventLine.Format#ASS_FFMPEG} and {@link SubTextEventLine.Format#TEXT} is supported
* @param ass ASS/SAA compatible event line according to {@code fmt}
- * @param pts_start pts start in ms, provided for {@link SubASSEventLine.Format#ASS_FFMPEG} and {@link SubASSEventLine.Format#ASS_TEXT}
- * @param pts_end pts end in ms, provided for {@link SubASSEventLine.Format#ASS_FFMPEG} and {@link SubASSEventLine.Format#ASS_TEXT}
+ * @param pts_start pts start in ms, provided for {@link SubTextEventLine.Format#ASS_FFMPEG} and {@link SubTextEventLine.Format#TEXT}
+ * @param pts_end pts end in ms, provided for {@link SubTextEventLine.Format#ASS_FFMPEG} and {@link SubTextEventLine.Format#TEXT}
*/
- public SubASSEventLine(final Format fmt, final String ass, final int pts_start, final int pts_end) {
- super(fmt, pts_start, pts_end);
+ public SubTextEventLine(final CodecID codec, final Format fmt, final String ass, final int pts_start, final int pts_end) {
+ super(codec, pts_start, pts_end);
+ this.format = fmt;
int seqnr = 0;
int layer = 0;
String style = "Default";
@@ -87,7 +102,7 @@ public class SubASSEventLine extends SubtitleEvent {
}
++part;
}
- } else if( Format.ASS_TEXT == fmt ) {
+ } else if( Format.TEXT == fmt ) {
text = ass;
}
this.seqnr = seqnr;
@@ -111,10 +126,17 @@ public class SubASSEventLine extends SubtitleEvent {
}
@Override
+ public final boolean isTextASS() { return true; }
+ @Override
+ public final boolean isBitmap() { return false; }
+ @Override
+ public final boolean isEmpty() { return false; }
+
+ @Override
public void release() {} // nothing to be released back to the owner
@Override
public String toString() {
- return getStartString()+", #"+seqnr+", l_"+layer+", style "+style+", name '"+name+"': '"+text+"' ("+lines+")]";
+ return getStartString()+", "+format+", #"+seqnr+", l_"+layer+", style "+style+", name '"+name+"': '"+text+"' ("+lines+")]";
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
index ffae7542b..f24246a70 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
@@ -8,38 +8,22 @@ package com.jogamp.opengl.util.av;
* </p>
*/
public abstract class SubtitleEvent {
- public enum Format {
- /** Denoting an {@link SubEmptyEvent}, usually used for PGS bitmap subtitle signaling end of previous {@link SubTextureEvent}. */
- EMPTY,
- /** Denoting {@link SubASSEventLine} using FFMpeg output w/o start, end:
- * <pre>
- 0 1 2 3 4 5 6 7 8
- Seq, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, TEXT
- * </pre>
- */
- ASS_FFMPEG,
- /** Denoting {@link SubASSEventLine}, just the plain text part */
- ASS_TEXT,
- /** Denoting {@link SubTextureEvent}, a bitmap'ed subtitle requiring a texture */
- TEXTURE
- };
-
- /** {@link Format} of this subtitle event. */
- public final Format type;
+ /** {@link CodecID} of this subtitle event. */
+ public final CodecID codec;
/** PTS start time to start showing this subtitle event. */
public final int pts_start;
/**
* PTS start time to end showing this subtitle event.
* <p>
- * PGS {@link SubTextureEvent} have an infinite end-time, i.e. ({@link Integer#MAX_VALUE},
+ * {@link SubBitmapEvent} often (e.g. {@link CodecID#HDMV_PGS}) have an infinite end-time, i.e. ({@link Integer#MAX_VALUE},
* and shall be overwritten by the next one or {@link SubEmptyEvent}.
* </p>
* @see #isEndDefined()
*/
public final int pts_end;
- public SubtitleEvent(final Format fmt, final int pts_start, final int pts_end) {
- this.type = fmt;
+ public SubtitleEvent(final CodecID codec, final int pts_start, final int pts_end) {
+ this.codec = codec;
this.pts_start = pts_start;
this.pts_end = pts_end;
}
@@ -52,13 +36,16 @@ public abstract class SubtitleEvent {
/** See {@link #pts_end}. */
public final boolean isEndDefined() { return pts_end < Integer.MAX_VALUE; }
- public final boolean isASS() { return Format.ASS_FFMPEG == type || Format.ASS_TEXT == type; }
- public final boolean isTexture() { return Format.TEXTURE == type; }
- public final boolean isEmpty() { return Format.EMPTY == type; }
+ /** Returns {@code true} if Text/ASS/SAA subtitle type, o.e. {@link SubTextEvent}. */
+ public abstract boolean isTextASS();
+ /** Returns {@code true} if bitmap subtitle type, o.e. {@link SubBitmapEvent}. */
+ public abstract boolean isBitmap();
+ /** Returns {@code true} if empty subtitle type, o.e. {@link SubEmptyEvent}. */
+ public abstract boolean isEmpty();
public final String getStartString() {
final boolean ied = isEndDefined();
- return "Sub["+type+", ["+pts_start+".."+(ied?pts_end:"undef")+"] "+(ied?getDuration():"undef")+" ms";
+ return "Sub["+codec+", ["+pts_start+".."+(ied?pts_end:"undef")+"] "+(ied?getDuration():"undef")+" ms";
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/VideoPixelFormat.java b/src/jogl/classes/com/jogamp/opengl/util/av/VideoPixelFormat.java
new file mode 100644
index 000000000..a3180702a
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/VideoPixelFormat.java
@@ -0,0 +1,191 @@
+/**
+ * Copyright 2013-2024 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.util.av;
+
+/** FFmpeg/libAV compatible video pixel format */
+public enum VideoPixelFormat {
+ // NONE= -1,
+ /** planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) */
+ YUV420P,
+ /** packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr ( sharing Cb and Cr w/ 2 pixels )*/
+ YUYV422,
+ /** packed RGB 8:8:8, 24bpp, RGBRGB... */
+ RGB24,
+ /** packed RGB 8:8:8, 24bpp, BGRBGR... */
+ BGR24,
+ /** planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) */
+ YUV422P,
+ /** planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) */
+ YUV444P,
+ /** planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) */
+ YUV410P,
+ /** planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) */
+ YUV411P,
+ /** Y, 8bpp */
+ GRAY8,
+ /** Y, 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb */
+ MONOWHITE,
+ /** Y, 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb */
+ MONOBLACK,
+ /** 8 bit with RGB32 palette */
+ PAL8,
+ /** planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of YUV420P and setting color_range */
+ YUVJ420P,
+ /** planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of YUV422P and setting color_range */
+ YUVJ422P,
+ /** planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of YUV444P and setting color_range */
+ YUVJ444P,
+ /** XVideo Motion Acceleration via common packet passing */
+ XVMC_MPEG2_MC,
+ /** */
+ XVMC_MPEG2_IDCT,
+ /** packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 ( sharing Cb and Cr w/ 2 pixels ) */
+ UYVY422,
+ /** packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 */
+ UYYVYY411,
+ /** packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) */
+ BGR8,
+ /** packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */
+ BGR4,
+ /** packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) */
+ BGR4_BYTE,
+ /** packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) */
+ RGB8,
+ /** packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */
+ RGB4,
+ /** packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) */
+ RGB4_BYTE,
+ /** planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) */
+ NV12,
+ /** as above, but U and V bytes are swapped */
+ NV21,
+
+ /** packed ARGB 8:8:8:8, 32bpp, ARGBARGB... */
+ ARGB,
+ /** packed RGBA 8:8:8:8, 32bpp, RGBARGBA... */
+ RGBA,
+ /** packed ABGR 8:8:8:8, 32bpp, ABGRABGR... */
+ ABGR,
+ /** packed BGRA 8:8:8:8, 32bpp, BGRABGRA... */
+ BGRA,
+
+ /** Y, 16bpp, big-endian */
+ GRAY16BE,
+ /** Y , 16bpp, little-endian */
+ GRAY16LE,
+ /** planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) */
+ YUV440P,
+ /** planar YUV 4:4:0 full scale (JPEG), deprecated in favor of YUV440P and setting color_range */
+ YUVJ440P,
+ /** planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) */
+ YUVA420P,
+ /** H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
+ VDPAU_H264,
+ /** MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
+ VDPAU_MPEG1,
+ /** MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
+ VDPAU_MPEG2,
+ /** WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
+ VDPAU_WMV3,
+ /** VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
+ VDPAU_VC1,
+ /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian */
+ RGB48BE,
+ /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian */
+ RGB48LE,
+
+ RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
+ RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
+ RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
+ RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
+
+ BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
+ BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
+ BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
+ BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
+
+ VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
+ VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
+ VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+
+ YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
+ YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
+ YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
+ YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
+ YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
+ YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
+ VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+ DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
+
+ RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
+ RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
+ BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
+ BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
+ Y400A, ///< 8bit gray, 8bit alpha
+ BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
+ BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
+ YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
+ YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
+ YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
+ YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
+ YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
+ YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
+ YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
+ YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
+ YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
+ YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
+ YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
+ YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
+ VDA_VLD, ///< hardware decoding through VDA
+ GBRP, ///< planar GBR 4:4:4 24bpp
+ GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian
+ GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian
+ GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian
+ GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian
+ GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian
+ GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian
+ COUNT ///< number of pixel formats in this list
+ ;
+ /**
+ * Returns the matching PixelFormat value corresponding to the given PixelFormat's integer ordinal.
+ * <pre>
+ * given:
+ * ordinal = enumValue.ordinal()
+ * reverse:
+ * enumValue = EnumClass.values()[ordinal]
+ * </pre>
+ * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PixelFormat.values().length-1 ]
+ */
+ public static VideoPixelFormat valueOf(final int ordinal) throws IllegalArgumentException {
+ final VideoPixelFormat[] all = VideoPixelFormat.values();
+ if( 0 <= ordinal && ordinal < all.length ) {
+ return all[ordinal];
+ }
+ throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PixelFormat.values()[0.."+(all.length-1)+"]");
+ }
+} \ No newline at end of file