From 9bf14f3c6bf98bd86913bec6e7feb54537f9b7d3 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Wed, 28 Aug 2013 12:44:06 +0200
Subject: Fix libav/ffmpeg compilation; FFMPEGMediaPlayer Enahncements (More
YUV*, Use def. high camera options, cleanup symbols)
- Fix libav/ffmpeg compilation
- Split native GLContext code from JoglCommon
- JoglCommon is required for ffmpeg_* c-compile/link
- Supported versions now:
- 0.8 53.53.51
- 9.0 54.54.52
- FFMPEGMediaPlayer
- Update API doc, add compatibility .. etc
- Pixel format conversions (via shader texture lookup func):
- YUV420P, YUVJ420P
- YUV422P, YUVJ422P
- YUYV422
- Properly handle aid/vid
- In camera mode: set high default values
- TODO: Make it configurable via camera URI:
- video_size
- framerate
- ?
- FFMPEGDynamicLibraryBundleInfo
- Cleanup symbols / remove unused (pre 53)
- Add av_dict_* methods
---
.../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 38 +--
.../opengl/util/av/impl/FFMPEGMediaPlayer.java | 275 ++++++++++++++-------
.../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 127 ++++++----
3 files changed, 286 insertions(+), 154 deletions(-)
(limited to 'src/jogl/classes/jogamp/opengl/util')
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java
index 040d152f5..f327cddd4 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java
@@ -46,14 +46,7 @@ import com.jogamp.common.util.RunnableExecutor;
import com.jogamp.common.util.VersionNumber;
/**
- * FIXME: We need native structure access methods to deal with API changes
- * in the libav headers, which break binary compatibility!
- * Currently we are binary compatible w/ [0.6 ?, ] 0.7 and 0.8 but not w/ trunk.
- *
- * ChangeList for trunk:
- * Thu Jan 12 11:21:02 2012 a17479dfce67fbea2d0a1bf303010dce1e79059f major 53 -> 54
- * Mon Feb 27 22:40:11 2012 ee42df8a35c2b795f524c856834d0823dbd4e75d reorder AVStream and AVFormatContext
- * Tue Feb 28 12:07:53 2012 322537478b63c6bc01e640643550ff539864d790 minor 1 -> 2
+ * See {@link FFMPEGMediaPlayer#compatibility}.
*/
class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
private static final boolean DEBUG = FFMPEGMediaPlayer.DEBUG || DynamicLibraryBundleInfo.DEBUG;
@@ -73,7 +66,6 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
"avcodec_string",
"avcodec_find_decoder",
"avcodec_open2", // 53.6.0 (opt)
- "avcodec_open",
"avcodec_alloc_frame",
"avcodec_get_frame_defaults",
"avcodec_free_frame", // 54.28.0 (opt)
@@ -85,8 +77,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
"av_destruct_packet",
"av_free_packet",
"avcodec_decode_audio4", // 53.25.0 (opt)
- "avcodec_decode_audio3", // 52.23.0
-/* 23 */ "avcodec_decode_video2", // 52.23.0
+/* 21 */ "avcodec_decode_video2", // 52.23.0
// libavutil
"av_pix_fmt_descriptors",
@@ -96,13 +87,16 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
"av_get_bits_per_pixel",
"av_samples_get_buffer_size",
"av_get_bytes_per_sample", // 51.4.0
-/* 31 */ "av_opt_set_int", // 51.12.0
-
+ "av_opt_set_int", // 51.12.0
+ "av_dict_get",
+ "av_dict_count", // 54.* (opt)
+ "av_dict_set",
+/* 33 */ "av_dict_free",
+
// libavformat
"avformat_alloc_context",
"avformat_free_context", // 52.96.0 (opt)
"avformat_close_input", // 53.17.0 (opt)
- "av_close_input_file",
"av_register_all",
"av_find_input_format",
"avformat_open_input",
@@ -114,8 +108,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
"av_read_pause",
"avformat_network_init", // 53.13.0 (opt)
"avformat_network_deinit", // 53.13.0 (opt)
- "avformat_find_stream_info", // 53.3.0 (opt)
-/* 48 */ "av_find_stream_info",
+/* 48 */ "avformat_find_stream_info", // 53.3.0 (opt)
// libavdevice
/* 49 */ "avdevice_register_all", // ???
@@ -130,20 +123,15 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
// alternate symbol names
private static final String[][] altSymbolNames = {
- { "avcodec_open", "avcodec_open2" }, // old, 53.6.0
- { "avcodec_decode_audio3", "avcodec_decode_audio4" }, // old, 53.25.0
- { "av_close_input_file", "avformat_close_input" }, // old, 53.17.0
- { "av_find_stream_info", "avformat_find_stream_info" }, // old, 53.3.0
+ // { "av_find_stream_info", "avformat_find_stream_info" }, // old, 53.3.0
};
// optional symbol names
private static final String[] optionalSymbolNames = {
- "avformat_free_context", // 52.96.0 (opt)
- "avformat_network_init", // 53.13.0 (opt)
- "avformat_network_deinit", // 53.13.0 (opt)
"avformat_seek_file", // ??? (opt)
"avcodec_free_frame", // 54.28.0 (opt)
"av_frame_unref", // 55.0.0 (opt)
+ "av_dict_count", // 54.* (opt)
// libavdevice
"avdevice_register_all", // 53.0.0 (opt)
// libavresample
@@ -377,10 +365,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
avdevice.add("avdevice"); // default
avdevice.add("libavdevice.so.54"); // dummy future proof
- avdevice.add("libavdevice.so.53"); // 8 && 9
+ avdevice.add("libavdevice.so.53"); // 0.8 && 9
avdevice.add("avdevice-54"); // dummy future proof
- avdevice.add("avdevice-53"); // 8 && 9
+ avdevice.add("avdevice-53"); // 0.8 && 9
libsList.add(avdevice);
final List avresample = new ArrayList();
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 952587ed9..2dd60074c 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -38,6 +38,7 @@ import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLException;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionNumber;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.opengl.util.TimeFrameI;
import com.jogamp.opengl.util.GLPixelStorageModes;
@@ -55,54 +56,87 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat;
/***
* Implementation utilizes Libav
* or FFmpeg which is ubiquitous
- * available and usually pre-installed on Unix platforms. Due to legal
- * reasons we cannot deploy binaries of it, which contains patented codecs.
+ * available and usually pre-installed on Unix platforms.
+ *
+ * Due to legal reasons we cannot deploy binaries of it, which contains patented codecs.
+ *
+ *
* Besides the default BSD/Linux/.. repositories and installations,
- * precompiled binaries can be found at the listed location below.
+ * precompiled binaries can be found at the
+ * listed location below.
+ *
- * Implements YUV420P to RGB fragment shader conversion
- * and the usual packed RGB formats.
* The decoded video frame is written directly into an OpenGL texture
* on the GPU in it's native format. A custom fragment shader converts
- * the native pixelformat to a usable RGB format if required.
+ * the native pixelformat to a usable RGB format if required.
* Hence only 1 copy is required before bloating the picture
- * from YUV to RGB, for example.
+ * from YUV* to RGB, for example.
*
*
+ * Implements pixel format conversion to RGB via
+ * fragment shader texture-lookup functions:
+ *
- * http://libav.org/
+ * See http://upstream-tracker.org/versions/libav.html
*
*
* Check tag 'FIXME: Add more planar formats !'
* here and in the corresponding native code
- * jogl/src/jogl/native/ffmpeg/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
+ * jogl/src/jogl/native/libav/ffmpeg_impl_template.c
*