aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-01-18 16:30:06 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-01-18 16:30:06 +0000
commite95f320dd030e9def8174e8b173e3631f11dba25 (patch)
tree6f3256f5af5e76f6f6af97b5a2fe41e8281dde21
parent1b458d8b1f4723ce82bb74f2157982980274e79c (diff)
downloadusdx-e95f320dd030e9def8174e8b173e3631f11dba25.tar.gz
usdx-e95f320dd030e9def8174e8b173e3631f11dba25.tar.xz
usdx-e95f320dd030e9def8174e8b173e3631f11dba25.zip
added blindy's swscale support. It can be enabled with {$DEFINE UseSWScale}.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@795 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--Game/Code/Classes/UVideo.pas32
1 files changed, 32 insertions, 0 deletions
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas
index bbd03d84..c30b271e 100644
--- a/Game/Code/Classes/UVideo.pas
+++ b/Game/Code/Classes/UVideo.pas
@@ -37,6 +37,9 @@ uses SDL,
avcodec,
avformat,
avutil,
+ {$IFDEF UseSWScale}
+ swscale,
+ {$ENDIF}
math,
OpenGL12,
SysUtils,
@@ -77,6 +80,10 @@ type
AVFrameRGB: PAVFrame;
myBuffer: pByte;
+ {$IFDEF UseSWScale}
+ SoftwareScaleContext: PSwsContext;
+ {$ENDIF}
+
TexX, TexY, dataX, dataY: Cardinal;
ScaledVideoWidth, ScaledVideoHeight: Real;
@@ -312,10 +319,18 @@ begin
if Framefinished=0 then begin
Exit;
end;
+
// otherwise we convert the pixeldata from YUV to RGB
+ {$IFDEF UseSWScale}
+ errnum:=sws_scale(SoftwareScaleContext,@(AVFrame.data),@(AVFrame.linesize),
+ 0,VideoCodecContext^.Height,
+ @(AVFrameRGB.data),@(AVFrameRGB.linesize));
+ {$ELSE}
errnum:=img_convert(PAVPicture(AVFrameRGB), PIX_FMT_RGB24,
PAVPicture(AVFrame), VideoCodecContext^.pix_fmt,
VideoCodecContext^.width, VideoCodecContext^.height);
+ {$ENDIF}
+
if errnum >=0 then
begin
glBindTexture(GL_TEXTURE_2D, fVideoTex);
@@ -568,6 +583,23 @@ begin
av_close_input_file(VideoFormatContext);
Exit;
end;
+
+ {$IFDEF UseSWScale}
+ SoftwareScaleContext:=sws_getContext(VideoCodecContext^.width,VideoCodecContext^.height,integer(VideoCodecContext^.pix_fmt),
+ dataX, dataY, integer(PIX_FMT_RGB24),
+ SWS_FAST_BILINEAR, 0, 0, 0);
+ if SoftwareScaleContext <> Nil then
+ writeln('got swscale context')
+ else begin
+ writeln('ERROR: didnīt get swscale context');
+ av_free(AVFrameRGB);
+ av_free(AVFrame);
+ avcodec_close(VideoCodecContext);
+ av_close_input_file(VideoFormatContext);
+ Exit;
+ end;
+ {$ENDIF}
+
// this is the errnum from avpicture_fill
if errnum >=0 then
begin