diff options
Diffstat (limited to 'chromium/third_party/ffmpeg/libavformat/avisynth.c')
-rw-r--r-- | chromium/third_party/ffmpeg/libavformat/avisynth.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/chromium/third_party/ffmpeg/libavformat/avisynth.c b/chromium/third_party/ffmpeg/libavformat/avisynth.c index 2f438d90270..c01d7e484cd 100644 --- a/chromium/third_party/ffmpeg/libavformat/avisynth.c +++ b/chromium/third_party/ffmpeg/libavformat/avisynth.c @@ -294,6 +294,7 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st) st->codec->channels = avs->vi->nchannels; st->time_base = (AVRational) { 1, avs->vi->audio_samples_per_second }; + st->duration = avs->vi->num_audio_samples; switch (avs->vi->sample_type) { case AVS_SAMPLE_INT8: @@ -401,10 +402,10 @@ static void avisynth_next_stream(AVFormatContext *s, AVStream **st, { AviSynthContext *avs = s->priv_data; - pkt->stream_index = avs->curr_stream++; + avs->curr_stream++; avs->curr_stream %= s->nb_streams; - *st = s->streams[pkt->stream_index]; + *st = s->streams[avs->curr_stream]; if ((*st)->discard == AVDISCARD_ALL) *discard = 1; else @@ -432,10 +433,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, if (discard) return 0; - pkt->pts = n; - pkt->dts = n; - pkt->duration = 1; - #ifdef USING_AVISYNTH /* Define the bpp values for the new AviSynth 2.6 colorspaces. * Since AvxSynth doesn't have these functions, special-case @@ -459,17 +456,21 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, (int64_t)avs->vi->height) * bits) / 8; if (!pkt->size) return AVERROR_UNKNOWN; - if (av_new_packet(pkt, (int)pkt->size) < 0) { - av_free(pkt); + + if (av_new_packet(pkt, pkt->size) < 0) return AVERROR(ENOMEM); - } + + pkt->pts = n; + pkt->dts = n; + pkt->duration = 1; + pkt->stream_index = avs->curr_stream; 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); avs->error = 1; - av_freep(&pkt->data); + av_packet_unref(pkt); return AVERROR_UNKNOWN; } @@ -550,24 +551,25 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, if (discard) return 0; - pkt->pts = n; - pkt->dts = n; - pkt->duration = samples; - pkt->size = avs_bytes_per_channel_sample(avs->vi) * samples * avs->vi->nchannels; if (!pkt->size) return AVERROR_UNKNOWN; - pkt->data = av_malloc(pkt->size); - if (!pkt->data) + + if (av_new_packet(pkt, pkt->size) < 0) return AVERROR(ENOMEM); + pkt->pts = n; + pkt->dts = n; + pkt->duration = samples; + pkt->stream_index = avs->curr_stream; + 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); avs->error = 1; - av_freep(&pkt->data); + av_packet_unref(pkt); return AVERROR_UNKNOWN; } return 0; @@ -600,8 +602,6 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt) if (avs->error) return AVERROR_UNKNOWN; - av_free_packet(pkt); - /* If either stream reaches EOF, try to read the other one before * giving up. */ avisynth_next_stream(s, &st, pkt, &discard); |