diff options
author | Lukasz Marek <lukasz.m.luki2@gmail.com> | 2014-05-11 08:08:08 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-24 06:48:49 +0400 |
commit | 97392553656a7f4fabde9ded4d2b7f538d98ee17 (patch) | |
tree | 941fc0caa4418f60f5b83bbcc9161da628258415 /libavfilter/src_movie.c | |
parent | 8b59ab1af0ddfe933bfa6b97745b15748c678b4c (diff) |
lavfi/src_movie: remove frame from priv context
This variable is used only inside one function.
There is no need to store it in context.
This also may prevent crush by double free frame.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/src_movie.c')
-rw-r--r-- | libavfilter/src_movie.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index bcc8e05495..dd3b516bef 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -63,7 +63,6 @@ typedef struct MovieContext { AVFormatContext *format_ctx; int eof; AVPacket pkt, pkt0; - AVFrame *frame; ///< video frame to store the decoded images in int max_stream_index; /**< max stream # actually used for output */ MovieStream *st; /**< array of all streams, one per output */ @@ -325,7 +324,6 @@ static av_cold void movie_uninit(AVFilterContext *ctx) } av_freep(&movie->st); av_freep(&movie->out_index); - av_frame_free(&movie->frame); if (movie->format_ctx) avformat_close_input(&movie->format_ctx); } @@ -453,6 +451,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) MovieStream *st; int ret, got_frame = 0, pkt_out_id; AVFilterLink *outlink; + AVFrame *frame; if (!pkt->size) { if (movie->eof) { @@ -495,17 +494,17 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) st = &movie->st[pkt_out_id]; outlink = ctx->outputs[pkt_out_id]; - movie->frame = av_frame_alloc(); - if (!movie->frame) + frame = av_frame_alloc(); + if (!frame) return AVERROR(ENOMEM); frame_type = st->st->codec->codec_type; switch (frame_type) { case AVMEDIA_TYPE_VIDEO: - ret = avcodec_decode_video2(st->st->codec, movie->frame, &got_frame, pkt); + ret = avcodec_decode_video2(st->st->codec, frame, &got_frame, pkt); break; case AVMEDIA_TYPE_AUDIO: - ret = avcodec_decode_audio4(st->st->codec, movie->frame, &got_frame, pkt); + ret = avcodec_decode_audio4(st->st->codec, frame, &got_frame, pkt); break; default: ret = AVERROR(ENOSYS); @@ -513,7 +512,7 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) } if (ret < 0) { av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret)); - av_frame_free(&movie->frame); + av_frame_free(&frame); av_free_packet(&movie->pkt0); movie->pkt.size = 0; movie->pkt.data = NULL; @@ -532,26 +531,25 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) if (!got_frame) { if (!ret) st->done = 1; - av_frame_free(&movie->frame); + av_frame_free(&frame); return 0; } - movie->frame->pts = av_frame_get_best_effort_timestamp(movie->frame); + frame->pts = av_frame_get_best_effort_timestamp(frame); av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name, - describe_frame_to_str((char[1024]){0}, 1024, movie->frame, frame_type, outlink)); + describe_frame_to_str((char[1024]){0}, 1024, frame, frame_type, outlink)); if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - if (movie->frame->format != outlink->format) { + if (frame->format != outlink->format) { av_log(ctx, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n", av_get_pix_fmt_name(outlink->format), - av_get_pix_fmt_name(movie->frame->format) + av_get_pix_fmt_name(frame->format) ); - av_frame_free(&movie->frame); + av_frame_free(&frame); return 0; } } - ret = ff_filter_frame(outlink, movie->frame); - movie->frame = NULL; + ret = ff_filter_frame(outlink, frame); if (ret < 0) return ret; |