aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord s <avxsynth-testing@gmail.com>2013-04-09 15:36:58 -0700
committerMichael Niedermayer <michaelni@gmx.at>2013-04-10 02:25:34 +0200
commitca3cef719e382b0bf44bdee1482ea89bb2d7f245 (patch)
tree8fa762263c1d7981450e47c358c2099446856e9e
parentd0073c7a0bc5a449956c2004821183fce601d321 (diff)
downloadffmpeg-ca3cef719e382b0bf44bdee1482ea89bb2d7f245.tar.gz
avformat/avisynth: Fix off-by-one error in avisynth demuxer.
Fixes ticket #2412. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/avisynth.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 2d36f6533c..61d4707a05 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -409,14 +409,14 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int dis
AVS_VideoFrame *frame;
unsigned char* dst_p;
const unsigned char* src_p;
- int i, plane, rowsize, planeheight, pitch, bits;
+ int n, i, plane, rowsize, planeheight, pitch, bits;
const char* error;
if (avs->curr_frame >= avs->vi->num_frames)
return AVERROR_EOF;
// This must happen even if the stream is discarded to prevent desync.
- avs->curr_frame++;
+ n = avs->curr_frame++;
if (discard)
return 0;
@@ -445,7 +445,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int dis
if (!pkt->data)
return AVERROR_UNKNOWN;
- frame = avs_library->avs_get_frame(avs->clip, avs->curr_frame);
+ frame = avs_library->avs_get_frame(avs->clip, n);
error = avs_library->avs_clip_get_error(avs->clip);
if (error) {
av_log(s, AV_LOG_ERROR, "%s\n", error);
@@ -480,6 +480,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int dis
AviSynthContext *avs = s->priv_data;
AVRational fps, samplerate;
int samples;
+ int64_t n;
const char* error;
if (avs->curr_sample >= avs->vi->num_audio_samples)
@@ -510,6 +511,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int dis
samples = avs->vi->num_audio_samples - avs->curr_sample;
// This must happen even if the stream is discarded to prevent desync.
+ n = avs->curr_sample;
avs->curr_sample += samples;
if (discard)
return 0;
@@ -525,7 +527,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, int dis
if (!pkt->data)
return AVERROR_UNKNOWN;
- avs_library->avs_get_audio(avs->clip, pkt->data, avs->curr_sample, samples);
+ avs_library->avs_get_audio(avs->clip, pkt->data, n, samples);
error = avs_library->avs_clip_get_error(avs->clip);
if (error) {
av_log(s, AV_LOG_ERROR, "%s\n", error);