aboutsummaryrefslogtreecommitdiffstats
path: root/src/media/UVideo.pas
diff options
context:
space:
mode:
authorlotanrm <lotanrm@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-05-17 17:32:26 +0000
committerlotanrm <lotanrm@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-05-17 17:32:26 +0000
commitc03bb84ce50794bab234b1c5cbfa74f6e8e3c6f2 (patch)
tree68fb6fbb36529b0d93959072afc0adc358539b30 /src/media/UVideo.pas
parenta537d34f9306bf50391d295f87bde4fdaeccc3e6 (diff)
downloadusdx-c03bb84ce50794bab234b1c5cbfa74f6e8e3c6f2.tar.gz
usdx-c03bb84ce50794bab234b1c5cbfa74f6e8e3c6f2.tar.xz
usdx-c03bb84ce50794bab234b1c5cbfa74f6e8e3c6f2.zip
Added support for ffmpeg-0.10.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2883 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/media/UVideo.pas')
-rw-r--r--src/media/UVideo.pas38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/media/UVideo.pas b/src/media/UVideo.pas
index fe043504..eaffa9ea 100644
--- a/src/media/UVideo.pas
+++ b/src/media/UVideo.pas
@@ -322,7 +322,11 @@ begin
fPboEnabled := PboSupported;
// use custom 'ufile' protocol for UTF-8 support
+ {$IF LIBAVFORMAT_VERSION >= 53001003)}
+ errnum := avformat_open_input(@fFormatContext, PAnsiChar('ufile:'+FileName.ToUTF8), nil, nil);
+ {$ELSE}
errnum := av_open_input_file(fFormatContext, PAnsiChar('ufile:'+FileName.ToUTF8), nil, 0, nil);
+ {$IFEND}
if (errnum <> 0) then
begin
Log.LogError('Failed to open file "'+ FileName.ToNative +'" ('+FFmpegCore.GetErrorString(errnum)+')');
@@ -330,7 +334,12 @@ begin
end;
// update video info
- if (av_find_stream_info(fFormatContext) < 0) then
+ {$IF LIBAVFORMAT_VERSION >= 53002000)}
+ errnum := avformat_find_stream_info(fFormatContext, nil);
+ {$ELSE}
+ errnum := av_find_stream_info(fFormatContext);
+ {$IFEND}
+ if (errnum < 0) then
begin
Log.LogError('No stream info found', 'TVideoPlayback_ffmpeg.Open');
Close();
@@ -350,7 +359,7 @@ begin
{$IF LIBAVFORMAT_VERSION <= 52111000} // <= 52.111.0
fStream := fFormatContext^.streams[fStreamIndex];
{$ELSE}
- fStream := Pointer(fFormatContext^.streams^) + fStreamIndex;
+ fStream := (fFormatContext^.streams + fStreamIndex)^;
{$IFEND}
fCodecContext := fStream^.codec;
@@ -377,7 +386,11 @@ begin
// fail if called concurrently by different threads.
FFmpegCore.LockAVCodec();
try
+ {$IF LIBAVCODEC_VERSION >= 5300500)}
+ errnum := avcodec_open2(fCodecContext, fCodec, nil);
+ {$ELSE}
errnum := avcodec_open(fCodecContext, fCodec);
+ {$IFEND}
finally
FFmpegCore.UnlockAVCodec();
end;
@@ -570,7 +583,11 @@ begin
end;
if (fFormatContext <> nil) then
+ {$IF LIBAVFORMAT_VERSION >= 53017003)}
+ avformat_close_input(@fFormatContext);
+ {$ELSE}
av_close_input_file(fFormatContext);
+ {$IFEND}
fCodecContext := nil;
fFormatContext := nil;
@@ -616,6 +633,8 @@ var
errnum: integer;
AVPacket: TAVPacket;
pts: double;
+ fs: integer;
+ ue: integer;
begin
Result := false;
FrameFinished := 0;
@@ -645,7 +664,12 @@ begin
end;
// check for errors
- if (url_ferror(pbIOCtx) <> 0) then
+ {$IF (LIBAVFORMAT_VERSION >= 52103000)}
+ ue := pbIOCtx^.error;
+ {$ELSE}
+ ue := url_ferror(pbIOCtx);
+ {$IFEND}
+ if (ue <> 0) then
begin
Log.LogError('Video decoding file error', 'TVideoPlayback_FFmpeg.DecodeFrame');
Exit;
@@ -653,8 +677,12 @@ begin
// url_feof() does not detect an EOF for some mov-files (e.g. deluxe.mov)
// so we have to do it this way.
- if ((fFormatContext^.file_size <> 0) and
- (pbIOCtx^.pos >= fFormatContext^.file_size)) then
+ {$IF (LIBAVFORMAT_VERSION >= 53009000)}
+ fs := avio_size(fFormatContext^.pb);
+ {$ELSE}
+ fs := fFormatContext^.file_size;
+ {$IFEND}
+ if ((fs <> 0) and (pbIOCtx^.pos >= fs)) then
begin
fEOF := true;
Exit;