2007-09-07 00:56:18 +02:00
|
|
|
// Copyright (c) 2007 Fredrik Mellbin
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
2007-07-18 15:00:15 +02:00
|
|
|
#include "ffmpegsource.h"
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
int FFmpegSource::GetTrackIndex(int Index, CodecType ATrackType, IScriptEnvironment *Env) {
|
|
|
|
if (Index == -1)
|
|
|
|
for (unsigned int i = 0; i < FormatContext->nb_streams; i++)
|
|
|
|
if (FormatContext->streams[i]->codec->codec_type == ATrackType) {
|
|
|
|
Index = i;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (Index == -1)
|
|
|
|
Env->ThrowError("FFmpegSource: No %s track found", (ATrackType == CODEC_TYPE_VIDEO) ? "video" : "audio");
|
|
|
|
if (Index <= -2)
|
|
|
|
return -2;
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (Index >= (int)FormatContext->nb_streams)
|
|
|
|
Env->ThrowError("FFmpegSource: Invalid %s track number", (ATrackType == CODEC_TYPE_VIDEO) ? "video" : "audio");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (FormatContext->streams[Index]->codec->codec_type != ATrackType)
|
|
|
|
Env->ThrowError("FFmpegSource: Selected track is not %s", (ATrackType == CODEC_TYPE_VIDEO) ? "video" : "audio");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
return Index;
|
|
|
|
}
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-09-17 20:02:24 +02:00
|
|
|
FFmpegSource::FFmpegSource(const char *ASource, int AVideoTrack, int AAudioTrack, const char *ATimecodes,
|
|
|
|
bool AVCache, const char *AVideoCache, const char *AAudioCache, int AACCompression, const char *APPString,
|
|
|
|
int AQuality, int ASeekMode, IScriptEnvironment* Env) {
|
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
CurrentFrame = 0;
|
|
|
|
SeekMode = ASeekMode;
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
AVCodecContext *AudioCodecContext = NULL;
|
|
|
|
AVCodec *AudioCodec;
|
|
|
|
AVCodec *VideoCodec;
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
FormatContext = NULL;
|
|
|
|
VideoCodecContext = NULL;
|
|
|
|
VideoCodec = NULL;
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (av_open_input_file(&FormatContext, ASource, NULL, 0, NULL) != 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Couldn't open '%s'", ASource);
|
|
|
|
|
|
|
|
if (av_find_stream_info(FormatContext) < 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Couldn't find stream information");
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
VideoTrack = GetTrackIndex(AVideoTrack, CODEC_TYPE_VIDEO, Env);
|
|
|
|
int AudioTrack = GetTrackIndex(AAudioTrack, CODEC_TYPE_AUDIO, Env);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
bool VCacheIsValid = true;
|
|
|
|
bool ACacheIsValid = true;
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (VideoTrack >= 0) {
|
2007-09-17 20:02:24 +02:00
|
|
|
if (SeekMode >= 0 && av_seek_frame(FormatContext, VideoTrack, 0, AVSEEK_FLAG_BACKWARD) < 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Video track is unseekable");
|
|
|
|
|
|
|
|
VCacheIsValid = LoadFrameInfoFromFile(AVideoCache, ASource, VideoTrack);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
VideoCodecContext = FormatContext->streams[VideoTrack]->codec;
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
VideoCodec = avcodec_find_decoder(VideoCodecContext->codec_id);
|
|
|
|
if (VideoCodec == NULL)
|
|
|
|
Env->ThrowError("FFmpegSource: Video codec not found");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (avcodec_open(VideoCodecContext, VideoCodec) < 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Could not open video codec");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
VI.image_type = VideoInfo::IT_TFF;
|
|
|
|
VI.width = VideoCodecContext->width;
|
|
|
|
VI.height = VideoCodecContext->height;
|
|
|
|
VI.fps_denominator = FormatContext->streams[VideoTrack]->time_base.num;
|
|
|
|
VI.fps_numerator = FormatContext->streams[VideoTrack]->time_base.den;
|
2007-07-29 22:49:50 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
// sanity check framerate
|
|
|
|
if (VI.fps_denominator > VI.fps_numerator || VI.fps_denominator <= 0 || VI.fps_numerator <= 0) {
|
2007-07-18 15:00:15 +02:00
|
|
|
VI.fps_denominator = 1;
|
|
|
|
VI.fps_numerator = 30;
|
2007-08-31 22:26:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetOutputFormat(VideoCodecContext->pix_fmt, Env);
|
|
|
|
InitPP(VI.width, VI.height, APPString, AQuality, VideoCodecContext->pix_fmt, Env);
|
|
|
|
}
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (AudioTrack >= 0) {
|
|
|
|
AudioCodecContext = FormatContext->streams[AudioTrack]->codec;
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
AudioCodec = avcodec_find_decoder(AudioCodecContext->codec_id);
|
|
|
|
if (AudioCodec == NULL)
|
|
|
|
Env->ThrowError("FFmpegSource: Audio codec not found");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (avcodec_open(AudioCodecContext, AudioCodec) < 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Could not open audio codec");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
switch (AudioCodecContext->sample_fmt) {
|
|
|
|
case SAMPLE_FMT_U8: VI.sample_type = SAMPLE_INT8; AACCompression = -1; break;
|
|
|
|
case SAMPLE_FMT_S16: VI.sample_type = SAMPLE_INT16; break;
|
|
|
|
case SAMPLE_FMT_S24: VI.sample_type = SAMPLE_INT24; AACCompression = -1; break;
|
|
|
|
case SAMPLE_FMT_S32: VI.sample_type = SAMPLE_INT32; AACCompression = -1; break;
|
|
|
|
case SAMPLE_FMT_FLT: VI.sample_type = SAMPLE_FLOAT; AACCompression = -1; break;
|
|
|
|
default:
|
|
|
|
Env->ThrowError("FFmpegSource: Unsupported/unknown sample format");
|
|
|
|
}
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
VI.nchannels = AudioCodecContext->channels;
|
|
|
|
VI.audio_samples_per_second = AudioCodecContext->sample_rate;
|
2007-07-18 15:00:15 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
ACacheIsValid = OpenAudioCache(AAudioCache, ASource, AudioTrack, Env);
|
|
|
|
}
|
2007-07-18 15:00:15 +02:00
|
|
|
|
2007-09-17 20:02:24 +02:00
|
|
|
if ((!ACacheIsValid || !VCacheIsValid) && SeekMode == -1)
|
|
|
|
Env->ThrowError("FFmpegSource: Unusual indexing error, report on doom9");
|
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
// Needs to be indexed?
|
|
|
|
if (!ACacheIsValid || !VCacheIsValid) {
|
2007-09-07 22:07:27 +02:00
|
|
|
#ifdef FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
FLAC__StreamEncoder *FSE = NULL;
|
2007-09-07 22:07:27 +02:00
|
|
|
#endif // FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
FILE *RawCache = NULL;
|
|
|
|
if (!ACacheIsValid)
|
|
|
|
if (AACCompression >= 0)
|
|
|
|
AudioCacheType = acFLAC;
|
|
|
|
else
|
|
|
|
AudioCacheType = acRaw;
|
2007-07-30 13:04:10 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
switch (AudioCacheType) {
|
2007-09-07 22:07:27 +02:00
|
|
|
#ifdef FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
case acFLAC: FSE = NewFLACCacheWriter(AAudioCache, ASource, AudioTrack, AACCompression, Env); break;
|
2007-09-07 22:07:27 +02:00
|
|
|
#endif // FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
case acRaw: RawCache = NewRawCacheWriter(AAudioCache, ASource, AudioTrack, Env); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
AVPacket Packet;
|
|
|
|
while (av_read_frame(FormatContext, &Packet) >= 0) {
|
|
|
|
if (Packet.stream_index == VideoTrack && !VCacheIsValid) {
|
|
|
|
FrameToDTS.push_back(FrameInfo(Packet.dts, (Packet.flags & PKT_FLAG_KEY) ? 1 : 0));
|
|
|
|
VI.num_frames++;
|
|
|
|
} else if (Packet.stream_index == AudioTrack && !ACacheIsValid) {
|
|
|
|
int Size = Packet.size;
|
|
|
|
uint8_t *Data = Packet.data;
|
2007-07-30 13:04:10 +02:00
|
|
|
|
|
|
|
while (Size > 0) {
|
|
|
|
int TempOutputBufSize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
|
|
|
int Ret = avcodec_decode_audio2(AudioCodecContext, (int16_t *)DecodingBuffer, &TempOutputBufSize, Data, Size);
|
|
|
|
if (Ret < 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Audio decoding error");
|
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
int DecodedSamples = VI.AudioSamplesFromBytes(TempOutputBufSize);
|
|
|
|
|
2007-07-30 13:04:10 +02:00
|
|
|
Size -= Ret;
|
|
|
|
Data += Ret;
|
2007-08-31 22:26:51 +02:00
|
|
|
VI.num_audio_samples += DecodedSamples;
|
|
|
|
|
2007-09-07 22:07:27 +02:00
|
|
|
if (AudioCacheType == acRaw) {
|
|
|
|
fwrite(DecodingBuffer, 1, TempOutputBufSize, RawCache);
|
|
|
|
#ifdef FLAC_CACHE
|
|
|
|
} else if (AudioCacheType == acFLAC) {
|
2007-08-31 22:26:51 +02:00
|
|
|
for (int i = 0; i < DecodedSamples * VI.nchannels; i++)
|
|
|
|
FLACBuffer[i] = ((int16_t *)DecodingBuffer)[i];
|
2007-09-07 22:07:27 +02:00
|
|
|
FLAC__stream_encoder_process_interleaved(FSE, FLACBuffer, DecodedSamples);
|
|
|
|
#endif // FLAC_CACHE
|
2007-07-18 15:00:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
av_free_packet(&Packet);
|
2007-07-18 15:00:15 +02:00
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (!ACacheIsValid) {
|
|
|
|
switch (AudioCacheType) {
|
2007-09-07 22:07:27 +02:00
|
|
|
#ifdef FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
case acFLAC: CloseFLACCacheWriter(FSE); break;
|
2007-09-07 22:07:27 +02:00
|
|
|
#endif // FLAC_CACHE
|
2007-08-31 22:26:51 +02:00
|
|
|
case acRaw: CloseRawCacheWriter(RawCache); break;
|
2007-07-02 23:36:21 +02:00
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
ACacheIsValid = OpenAudioCache(AAudioCache, ASource, AudioTrack, Env);
|
|
|
|
if (!ACacheIsValid)
|
|
|
|
Env->ThrowError("FFmpegSource: Failed to open newly created audio cache for reading");
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (VideoTrack >= 0 && VI.num_frames == 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Video track contains no frames");
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (AudioTrack >= 0 && VI.num_audio_samples == 0)
|
|
|
|
Env->ThrowError("FFmpegSource: Audio track contains no samples");
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (VideoTrack >= 0)
|
|
|
|
av_seek_frame(FormatContext, VideoTrack, FrameToDTS.front().DTS, AVSEEK_FLAG_BACKWARD);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (AVCache && !VCacheIsValid)
|
|
|
|
if (!SaveFrameInfoToFile(AVideoCache, ASource, VideoTrack))
|
|
|
|
Env->ThrowError("FFmpegSource: Failed to write video cache info");
|
2007-07-13 07:15:28 +02:00
|
|
|
}
|
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (AudioTrack >= 0)
|
|
|
|
avcodec_close(AudioCodecContext);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
if (VideoTrack >= 0) {
|
|
|
|
if (!SaveTimecodesToFile(ATimecodes, FormatContext->streams[VideoTrack]->time_base.num * 1000, FormatContext->streams[VideoTrack]->time_base.den))
|
|
|
|
Env->ThrowError("FFmpegSource: Failed to write timecodes");
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
// Adjust framerate to match the duration of the first frame
|
|
|
|
if (FrameToDTS.size() >= 2) {
|
|
|
|
int64_t DTSDiff = (double)(FrameToDTS[1].DTS - FrameToDTS[0].DTS);
|
|
|
|
VI.fps_denominator *= DTSDiff;
|
2007-07-18 15:00:15 +02:00
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
2007-08-31 22:26:51 +02:00
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-08-31 22:26:51 +02:00
|
|
|
FFmpegSource::~FFmpegSource() {
|
|
|
|
if (VideoTrack >= 0)
|
|
|
|
avcodec_close(VideoCodecContext);
|
|
|
|
av_close_input_file(FormatContext);
|
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
|
|
|
|
|
2007-07-18 15:00:15 +02:00
|
|
|
int FFmpegSource::DecodeNextFrame(AVFrame *AFrame, int64_t *AStartTime) {
|
2007-06-16 20:45:56 +02:00
|
|
|
AVPacket Packet;
|
|
|
|
int FrameFinished = 0;
|
|
|
|
int Ret = -1;
|
2007-07-18 15:00:15 +02:00
|
|
|
*AStartTime = -1;
|
2007-06-16 20:45:56 +02:00
|
|
|
|
|
|
|
while (av_read_frame(FormatContext, &Packet) >= 0) {
|
2007-07-18 15:00:15 +02:00
|
|
|
if (Packet.stream_index == VideoTrack) {
|
|
|
|
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, Packet.data, Packet.size);
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-07-18 15:00:15 +02:00
|
|
|
if (*AStartTime < 0)
|
|
|
|
*AStartTime = Packet.dts;
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
av_free_packet(&Packet);
|
|
|
|
|
|
|
|
if (FrameFinished)
|
2007-07-13 07:15:28 +02:00
|
|
|
goto Done;
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
|
|
|
|
2007-07-13 07:15:28 +02:00
|
|
|
// Flush the last frame
|
2007-07-18 15:00:15 +02:00
|
|
|
if (CurrentFrame == VI.num_frames - 1 && VideoCodecContext->has_b_frames)
|
|
|
|
Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
|
|
|
Done:
|
2007-06-16 20:45:56 +02:00
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2007-09-07 22:07:27 +02:00
|
|
|
PVideoFrame FFmpegSource::GetFrame(int n, IScriptEnvironment* Env) {
|
2007-09-17 20:02:24 +02:00
|
|
|
if (LastFrameNum == n)
|
|
|
|
return LastFrame;
|
|
|
|
|
2007-06-16 20:45:56 +02:00
|
|
|
bool HasSeeked = false;
|
|
|
|
|
2007-09-17 20:02:24 +02:00
|
|
|
if (SeekMode >= 0) {
|
|
|
|
int ClosestKF = FindClosestKeyFrame(n);
|
|
|
|
|
|
|
|
if (SeekMode == 0) {
|
|
|
|
if (n < CurrentFrame) {
|
|
|
|
av_seek_frame(FormatContext, VideoTrack, 0, AVSEEK_FLAG_BACKWARD);
|
|
|
|
avcodec_flush_buffers(VideoCodecContext);
|
|
|
|
CurrentFrame = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// 10 frames is used as a margin to prevent excessive seeking since the predicted best keyframe isn't always selected by avformat
|
|
|
|
if (n < CurrentFrame || ClosestKF > CurrentFrame + 10 || (SeekMode == 3 && n > CurrentFrame + 10)) {
|
|
|
|
av_seek_frame(FormatContext, VideoTrack, (SeekMode == 3) ? FrameToDTS[n].DTS : FrameToDTS[ClosestKF].DTS, AVSEEK_FLAG_BACKWARD);
|
|
|
|
avcodec_flush_buffers(VideoCodecContext);
|
|
|
|
HasSeeked = true;
|
|
|
|
}
|
2007-07-02 23:36:21 +02:00
|
|
|
}
|
2007-09-17 20:02:24 +02:00
|
|
|
} else if (n < CurrentFrame) {
|
|
|
|
Env->ThrowError("FFmpegSource: Non-linear access attempted");
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2007-07-18 15:00:15 +02:00
|
|
|
int64_t StartTime;
|
|
|
|
DecodeNextFrame(DecodeFrame, &StartTime);
|
2007-07-13 07:15:28 +02:00
|
|
|
|
2007-06-16 20:45:56 +02:00
|
|
|
if (HasSeeked) {
|
2007-07-02 23:36:21 +02:00
|
|
|
HasSeeked = false;
|
|
|
|
|
|
|
|
// Is the seek destination time known? Does it belong to a frame?
|
2007-07-18 15:00:15 +02:00
|
|
|
if (StartTime < 0 || (CurrentFrame = FrameFromDTS(StartTime)) < 0) {
|
2007-07-02 23:36:21 +02:00
|
|
|
switch (SeekMode) {
|
|
|
|
case 1:
|
2007-07-13 07:15:28 +02:00
|
|
|
Env->ThrowError("FFmpegSource: Frame accurate seeking is not possible in this file");
|
2007-07-02 23:36:21 +02:00
|
|
|
case 2:
|
|
|
|
case 3:
|
2007-07-18 15:00:15 +02:00
|
|
|
CurrentFrame = ClosestFrameFromDTS(StartTime);
|
2007-07-02 23:36:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Env->ThrowError("FFmpegSource: Failed assertion");
|
|
|
|
}
|
|
|
|
}
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CurrentFrame++;
|
2007-07-02 23:36:21 +02:00
|
|
|
} while (CurrentFrame <= n);
|
2007-06-16 20:45:56 +02:00
|
|
|
|
2007-09-17 20:02:24 +02:00
|
|
|
LastFrame = OutputFrame(DecodeFrame, Env);
|
|
|
|
LastFrameNum = n;
|
|
|
|
return LastFrame;
|
2007-06-16 20:45:56 +02:00
|
|
|
}
|