diff options
author | Sven Gothel <[email protected]> | 2013-08-29 22:46:57 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-08-29 22:46:57 +0200 |
commit | eca6a5cb1e2beda84dfbafc31ed225e272f4f3fb (patch) | |
tree | c77750eac39a611bbc46b77f64e5ae5c123e9427 /src/jogl/native/libav/ffmpeg_tool.h | |
parent | 9bf14f3c6bf98bd86913bec6e7feb54537f9b7d3 (diff) |
Enhance GLMediaPlayer: Full FFMPeg support, 'dshow' camera support on windows, 2 more pixel formats, fail-safe data handling
- add support for ffmpeg 2 / libav 10 -> lavc55_lavf55_lavu52_lavr01
- add support for ffmpeg libswresample (similar to libavresample)
- handle BGRA (GL type) and BGR24 (texture shader)
- Change Camera URI semantics, drop 'host' and use 'path' for camera ID
and use 'query' for options.
- add support for Window's DShow camera selection
- our camera id -> index of list of video-input devices,
this gives us same behavior as w/ Linux
- requires windows libs: strmiids, uuid, ole32, oleaut32
- Compiles w/ MingW64, works w/ libav/ffmpeg
- TODO: test compilation w/ MingW 32bit !
- don't push data to texture if (linesize <= 0)
this may happen due to buggy decoder / setup ..
Tested manually on GNU/Linux x64 and Windows x64:
- GNU/Linux libav 0.8, libav 9, libav 10, ffmpeg 1.2, ffmpeg 2.0
- Windows libav 0.8, libav 9, ffmpeg 2.0
- videos and camera
Diffstat (limited to 'src/jogl/native/libav/ffmpeg_tool.h')
-rw-r--r-- | src/jogl/native/libav/ffmpeg_tool.h | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index ea9625da6..e4b10f95f 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -45,13 +45,20 @@ #include "libavformat/avformat.h" #include "libavutil/avutil.h" #if LIBAVCODEC_VERSION_MAJOR >= 54 -#include "libavresample/avresample.h" + #include "libavresample/avresample.h" + #include "libswresample/swresample.h" #endif #ifndef LIBAVRESAMPLE_VERSION_MAJOR -#define LIBAVRESAMPLE_VERSION_MAJOR 0 +#define LIBAVRESAMPLE_VERSION_MAJOR -1 +// Opaque typedef void* AVAudioResampleContext; #endif +#ifndef LIBSWRESAMPLE_VERSION_MAJOR +#define LIBSWRESAMPLE_VERSION_MAJOR -1 +// Opaque +typedef struct SwrContext SwrContext; +#endif #include <stdarg.h> #include <stdio.h> @@ -88,24 +95,27 @@ typedef void (APIENTRYP PFNGLFINISH) (void); /** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TimeFrameI.END_OF_STREAM_PTS */ #define END_OF_STREAM_PTS 0x7FFFFFFF -/** Until 55.0.0, but stopped working w/ 54 already :( */ -#define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 54) - -/** Since 55.0.0 */ -#define AV_HAS_API_REFCOUNTED_FRAMES(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) >= 55) - /** Since 54.0.0.1 */ -#define AV_HAS_API_AVRESAMPLE(pAV) (AV_VERSION_MAJOR(pAV->avresampleVersion) >= 1) +#define AV_HAS_API_AVRESAMPLE(pAV) ( pAV->avresampleVersion != 0 ) + +/** Since 55.0.0.1 */ +#define AV_HAS_API_SWRESAMPLE(pAV) ( pAV->swresampleVersion != 0 ) #define MAX_INT(a,b) ( (a >= b) ? a : b ) #define MIN_INT(a,b) ( (a <= b) ? a : b ) static inline float my_av_q2f(AVRational a){ - return a.num / (float) a.den; + return (float)a.num / (float)a.den; +} +static inline float my_av_q2f_r(AVRational a){ + return (float)a.den / (float)a.num; } static inline int32_t my_av_q2i32(int64_t snum, AVRational a){ return (int32_t) ( ( snum * (int64_t) a.num ) / (int64_t)a.den ); } +static inline int my_align(int v, int a){ + return ( v + a - 1 ) & ~( a - 1 ); +} typedef struct { void *origPtr; @@ -129,6 +139,7 @@ typedef struct { uint32_t avformatVersion; uint32_t avutilVersion; uint32_t avresampleVersion; + uint32_t swresampleVersion; int32_t useRefCountedFrames; @@ -149,8 +160,7 @@ typedef struct { enum PixelFormat vPixFmt; // native decoder fmt int32_t vPTS; // msec - overall last video PTS PTSStats vPTSStats; - int32_t vLinesize[3]; // decoded video linesize in bytes for each plane - int32_t vTexWidth[3]; // decoded video tex width in bytes for each plane + int32_t vTexWidth[AV_NUM_DATA_POINTERS]; // decoded video tex width in bytes for each plane int32_t vWidth; int32_t vHeight; @@ -167,7 +177,8 @@ typedef struct { int32_t aSampleRate; int32_t aChannels; int32_t aSinkSupport; // supported by AudioSink - AVAudioResampleContext *aResampleCtx; + AVAudioResampleContext* avResampleCtx; + struct SwrContext* swResampleCtx; uint8_t* aResampleBuffer; enum AVSampleFormat aSampleFmtOut; // out fmt int32_t aChannelsOut; |