summaryrefslogtreecommitdiff
path: root/libavfilter/vsrc_movie.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-28 08:41:07 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:37:18 +0100
commit7e350379f87e7f74420b4813170fe808e2313911 (patch)
tree031201839361d40af8b4c829f9c9f179e7d9f58d /libavfilter/vsrc_movie.c
parent77b2cd7b41d7ec8008b6fac753c04f77824c514c (diff)
lavfi: switch to AVFrame.
Deprecate AVFilterBuffer/AVFilterBufferRef and everything related to it and use AVFrame instead.
Diffstat (limited to 'libavfilter/vsrc_movie.c')
-rw-r--r--libavfilter/vsrc_movie.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index 0023d55bbc..2a893bd517 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -54,7 +54,6 @@ typedef struct {
AVFrame *frame; ///< video frame to store the decoded images in
int w, h;
- AVFilterBufferRef *picref;
} MovieContext;
#define OFFSET(x) offsetof(MovieContext, x)
@@ -142,16 +141,13 @@ static int movie_init(AVFilterContext *ctx)
return AVERROR(EINVAL);
}
+ movie->codec_ctx->refcounted_frames = 1;
+
if ((ret = avcodec_open2(movie->codec_ctx, codec, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
return ret;
}
- if (!(movie->frame = avcodec_alloc_frame()) ) {
- av_log(ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
- return AVERROR(ENOMEM);
- }
-
movie->w = movie->codec_ctx->width;
movie->h = movie->codec_ctx->height;
@@ -196,8 +192,7 @@ static av_cold void uninit(AVFilterContext *ctx)
avcodec_close(movie->codec_ctx);
if (movie->format_ctx)
avformat_close_input(&movie->format_ctx);
- avfilter_unref_buffer(movie->picref);
- avcodec_free_frame(&movie->frame);
+ av_frame_free(&movie->frame);
}
static int query_formats(AVFilterContext *ctx)
@@ -225,41 +220,29 @@ static int movie_get_frame(AVFilterLink *outlink)
MovieContext *movie = outlink->src->priv;
AVPacket pkt;
int ret, frame_decoded;
- AVStream *st = movie->format_ctx->streams[movie->stream_index];
+ AVStream av_unused *st = movie->format_ctx->streams[movie->stream_index];
if (movie->is_done == 1)
return 0;
+ movie->frame = av_frame_alloc();
+ if (!movie->frame)
+ return AVERROR(ENOMEM);
+
while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
// Is this a packet from the video stream?
if (pkt.stream_index == movie->stream_index) {
- movie->codec_ctx->reordered_opaque = pkt.pos;
avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
if (frame_decoded) {
- /* FIXME: avoid the memcpy */
- movie->picref = ff_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE |
- AV_PERM_REUSE2, outlink->w, outlink->h);
- av_image_copy(movie->picref->data, movie->picref->linesize,
- movie->frame->data, movie->frame->linesize,
- movie->picref->format, outlink->w, outlink->h);
- avfilter_copy_frame_props(movie->picref, movie->frame);
-
- /* FIXME: use a PTS correction mechanism as that in
- * ffplay.c when some API will be available for that */
- /* use pkt_dts if pkt_pts is not available */
- movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
- movie->frame->pkt_dts : movie->frame->pkt_pts;
-
- movie->picref->pos = movie->frame->reordered_opaque;
- if (!movie->frame->sample_aspect_ratio.num)
- movie->picref->video->pixel_aspect = st->sample_aspect_ratio;
+ if (movie->frame->pkt_pts != AV_NOPTS_VALUE)
+ movie->frame->pts = movie->frame->pkt_pts;
av_dlog(outlink->src,
- "movie_get_frame(): file:'%s' pts:%"PRId64" time:%f pos:%"PRId64" aspect:%d/%d\n",
- movie->file_name, movie->picref->pts,
- (double)movie->picref->pts * av_q2d(st->time_base),
- movie->picref->pos,
- movie->picref->video->pixel_aspect.num, movie->picref->video->pixel_aspect.den);
+ "movie_get_frame(): file:'%s' pts:%"PRId64" time:%f aspect:%d/%d\n",
+ movie->file_name, movie->frame->pts,
+ (double)movie->frame->pts * av_q2d(st->time_base),
+ movie->frame->sample_aspect_ratio.num,
+ movie->frame->sample_aspect_ratio.den);
// We got it. Free the packet since we are returning
av_free_packet(&pkt);
@@ -287,8 +270,8 @@ static int request_frame(AVFilterLink *outlink)
if ((ret = movie_get_frame(outlink)) < 0)
return ret;
- ret = ff_filter_frame(outlink, movie->picref);
- movie->picref = NULL;
+ ret = ff_filter_frame(outlink, movie->frame);
+ movie->frame = NULL;
return ret;
}