diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-12-22 18:21:41 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-12-22 18:21:41 +0000 |
commit | 1822c266c552a76cdbe75288515b5abfa9a41d5d (patch) | |
tree | 7c522487d3c1bdb54ec1d3fcb1220f6cc1abddd9 /mediaplugin/src/media | |
parent | 71e7b0bb663197c4bbc4aad55082dd6424e0fb33 (diff) | |
download | usdx-1822c266c552a76cdbe75288515b5abfa9a41d5d.tar.gz usdx-1822c266c552a76cdbe75288515b5abfa9a41d5d.tar.xz usdx-1822c266c552a76cdbe75288515b5abfa9a41d5d.zip |
support for video pixel format selection
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2767 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'mediaplugin/src/media')
-rw-r--r-- | mediaplugin/src/media/UMediaPlugin.pas | 13 | ||||
-rw-r--r-- | mediaplugin/src/media/UMedia_dummy.pas | 4 | ||||
-rw-r--r-- | mediaplugin/src/media/UVideo.pas | 19 | ||||
-rw-r--r-- | mediaplugin/src/media/UVideoDecoderPlugin.pas | 39 |
4 files changed, 57 insertions, 18 deletions
diff --git a/mediaplugin/src/media/UMediaPlugin.pas b/mediaplugin/src/media/UMediaPlugin.pas index cf25e033..8d4a8a7e 100644 --- a/mediaplugin/src/media/UMediaPlugin.pas +++ b/mediaplugin/src/media/UMediaPlugin.pas @@ -119,11 +119,22 @@ type getRatio: function(stream: PAudioConvertStream): double; cdecl; end; +type + TCVideoFrameFormat = cint; +const + FRAME_FORMAT_UNKNOWN = 0; + FRAME_FORMAT_RGB = 1; // packed RGB 24bpp (R:8,G:8,B:8) + FRAME_FORMAT_RGBA = 2; // packed RGBA 32bpp (R:8,G:8,B:8,A:8) + FRAME_FORMAT_BGR = 3; // packed RGB 24bpp (B:8,G:8,R:8) + FRAME_FORMAT_BGRA = 4; // packed BGRA 32bpp (B:8,G:8,R:8,A:8) + +type PVideoFrameInfo = ^TVideoFrameInfo; TVideoFrameInfo = record width: cint; height: cint; aspect: double; + format: TCVideoFrameFormat; end; PVideoDecoderInfo = ^TVideoDecoderInfo; @@ -131,7 +142,7 @@ type priority: cint; init: function(): cbool; cdecl; finalize: function(): cbool; cdecl; - open: function(filename: PAnsiChar): PVideoDecodeStream; cdecl; + open: function(filename: PAnsiChar; format: TCVideoFrameFormat): PVideoDecodeStream; cdecl; close: procedure(stream: PVideoDecodeStream); cdecl; setLoop: procedure(stream: PVideoDecodeStream; enable: cbool); cdecl; getLoop: function(stream: PVideoDecodeStream): cbool; cdecl; diff --git a/mediaplugin/src/media/UMedia_dummy.pas b/mediaplugin/src/media/UMedia_dummy.pas index d5e99aa3..fc560ce8 100644 --- a/mediaplugin/src/media/UMedia_dummy.pas +++ b/mediaplugin/src/media/UMedia_dummy.pas @@ -174,7 +174,7 @@ type function InitializeDecoder(): boolean; function FinalizeDecoder(): boolean; - function Open(const FileName: IPath): TVideoDecodeStream; + function Open(const FileName: IPath; Format: TVideoFrameFormat): TVideoDecodeStream; end; function TAudio_Dummy.GetName: string; @@ -529,7 +529,7 @@ begin Result := true; end; -function TVideoDecoder_Dummy.Open(const FileName: IPath): TVideoDecodeStream; +function TVideoDecoder_Dummy.Open(const FileName: IPath; Format: TVideoFrameFormat): TVideoDecodeStream; begin Result := nil; end; diff --git a/mediaplugin/src/media/UVideo.pas b/mediaplugin/src/media/UVideo.pas index 776d9f33..8361e2a8 100644 --- a/mediaplugin/src/media/UVideo.pas +++ b/mediaplugin/src/media/UVideo.pas @@ -60,16 +60,19 @@ uses const {$IFDEF PIXEL_FMT_BGR} - PIXEL_FMT_OPENGL = GL_BGR; - PIXEL_FMT_SIZE = 3; + PIXEL_FMT_DECODER = vffBGR; + PIXEL_FMT_OPENGL = GL_BGR; + PIXEL_FMT_SIZE = 3; // looks strange on linux: - //PIXEL_FMT_OPENGL = GL_RGBA; - //PIXEL_FMT_SIZE = 4; + //PIXEL_FMT_DECODER = vffRGBA; + //PIXEL_FMT_OPENGL = GL_RGBA; + //PIXEL_FMT_SIZE = 4; {$ELSE} // looks strange on linux: - PIXEL_FMT_OPENGL = GL_RGB; - PIXEL_FMT_SIZE = 3; + PIXEL_FMT_DECODER = vffRGB; + PIXEL_FMT_OPENGL = GL_RGB; + PIXEL_FMT_SIZE = 3; {$ENDIF} ReflectionH = 0.5; //reflection height (50%) @@ -202,14 +205,14 @@ begin Result := true; end; -function TVideoPlayback_FFmpeg.Open(const FileName : IPath): IVideo; +function TVideoPlayback_FFmpeg.Open(const FileName: IPath): IVideo; var Video: IVideo_FFmpeg; Decoder: TVideoDecodeStream; begin Result := nil; - Decoder := VideoDecoder.Open(FileName); + Decoder := VideoDecoder.Open(FileName, PIXEL_FMT_DECODER); if (Decoder = nil) then Exit; diff --git a/mediaplugin/src/media/UVideoDecoderPlugin.pas b/mediaplugin/src/media/UVideoDecoderPlugin.pas index ef411023..7ed18ded 100644 --- a/mediaplugin/src/media/UVideoDecoderPlugin.pas +++ b/mediaplugin/src/media/UVideoDecoderPlugin.pas @@ -51,7 +51,7 @@ type function InitializeDecoder(): boolean; function FinalizeDecoder: boolean; - function Open(const FileName: IPath): TVideoDecodeStream; + function Open(const FileName: IPath; Format: TVideoFrameFormat): TVideoDecodeStream; end; implementation @@ -75,7 +75,7 @@ type constructor Create(Info: PVideoDecoderInfo); destructor Destroy; override; - function Open(const FileName: IPath): boolean; override; + function Open(const FileName: IPath; Format: TVideoFrameFormat): boolean; override; procedure Close; override; procedure SetLoop(Enable: boolean); override; @@ -86,8 +86,9 @@ type function GetFrameWidth(): integer; override; function GetFrameHeight(): integer; override; - function GetFrameAspect(): real; override; + function GetFrameFormat(): TVideoFrameFormat; override; + function GetFrame(Time: Extended): PByteArray; override; end; @@ -121,14 +122,14 @@ begin Result := true; end; -function TVideoDecoderPlugin.Open(const FileName : IPath): TVideoDecodeStream; +function TVideoDecoderPlugin.Open(const FileName: IPath; Format: TVideoFrameFormat): TVideoDecodeStream; var Stream: TPluginVideoDecodeStream; begin Result := nil; Stream := TPluginVideoDecodeStream.Create(fPluginInfo.videoDecoder); - if (not Stream.Open(FileName)) then + if (not Stream.Open(FileName, Format)) then begin Stream.Free; Exit; @@ -153,13 +154,23 @@ begin inherited; end; -function TPluginVideoDecodeStream.Open(const FileName: IPath): boolean; +function TPluginVideoDecodeStream.Open(const FileName: IPath; Format: TVideoFrameFormat): boolean; +var + CFormat: TCVideoFrameFormat; begin Result := false; Close(); - fStream := fVideoDecoderInfo.open(PChar(Filename.ToUTF8())); + case Format of + vffRGB: CFormat := FRAME_FORMAT_RGB; + vffRGBA: CFormat := FRAME_FORMAT_RGBA; + vffBGR: CFormat := FRAME_FORMAT_BGR; + vffBGRA: CFormat := FRAME_FORMAT_BGRA; + else CFormat := FRAME_FORMAT_UNKNOWN; + end; + + fStream := fVideoDecoderInfo.open(PChar(Filename.ToUTF8()), CFormat); if (fStream = nil) then Exit; @@ -227,4 +238,18 @@ begin Result := FrameInfo.aspect; end; +function TPluginVideoDecodeStream.GetFrameFormat(): TVideoFrameFormat; +var + FrameInfo: TVideoFrameInfo; +begin + fVideoDecoderInfo.getFrameInfo(fStream, @FrameInfo); + case FrameInfo.format of + FRAME_FORMAT_RGB: Result := vffRGB; + FRAME_FORMAT_RGBA: Result := vffRGBA; + FRAME_FORMAT_BGR: Result := vffBGR; + FRAME_FORMAT_BGRA: Result := vffBGRA; + else Result := vffUnknown; + end; +end; + end. |