summaryrefslogtreecommitdiff
path: root/libavfilter/src_movie.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-10 01:30:30 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-10 01:40:35 +0100
commita05a44e205d6ae13d5eb1cd8d4ad2dba6ec940b3 (patch)
tree450d7173e72748db59d6cfb7107c688bc825fc9a /libavfilter/src_movie.c
parent586ae70ba78e023d16c0c812b05a26c7d423833b (diff)
parent7e350379f87e7f74420b4813170fe808e2313911 (diff)
Merge commit '7e350379f87e7f74420b4813170fe808e2313911'
* commit '7e350379f87e7f74420b4813170fe808e2313911': lavfi: switch to AVFrame. Conflicts: doc/filters.texi libavfilter/af_ashowinfo.c libavfilter/audio.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/buffersink.c libavfilter/buffersrc.c libavfilter/buffersrc.h libavfilter/f_select.c libavfilter/f_setpts.c libavfilter/fifo.c libavfilter/split.c libavfilter/src_movie.c libavfilter/version.h libavfilter/vf_aspect.c libavfilter/vf_bbox.c libavfilter/vf_blackframe.c libavfilter/vf_delogo.c libavfilter/vf_drawbox.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_fieldorder.c libavfilter/vf_fps.c libavfilter/vf_frei0r.c libavfilter/vf_gradfun.c libavfilter/vf_hqdn3d.c libavfilter/vf_lut.c libavfilter/vf_overlay.c libavfilter/vf_pad.c libavfilter/vf_scale.c libavfilter/vf_showinfo.c libavfilter/vf_transpose.c libavfilter/vf_vflip.c libavfilter/vf_yadif.c libavfilter/video.c libavfilter/vsrc_testsrc.c libavfilter/yadif.h Following are notes about the merge authorship and various technical details. Michael Niedermayer: * Main merge operation, notably avfilter.c and video.c * Switch to AVFrame: - afade - anullsrc - apad - aresample - blackframe - deshake - idet - il - mandelbrot - mptestsrc - noise - setfield - smartblur - tinterlace * various merge changes and fixes in: - ashowinfo - blackdetect - field - fps - select - testsrc - yadif Nicolas George: * Switch to AVFrame: - make rawdec work with refcounted frames. Adapted from commit 759001c534287a96dc96d1e274665feb7059145d by Anton Khirnov. Also, fix the use of || instead of | in a flags check. - make buffer sink and src, audio and video work all together Clément Bœsch: * Switch to AVFrame: - aevalsrc - alphaextract - blend - cellauto - colormatrix - concat - earwax - ebur128 - edgedetect - geq - histeq - histogram - hue - kerndeint - life - movie - mp (with the help of Michael) - overlay - pad - pan - pp - pp - removelogo - sendcmd - showspectrum - showwaves - silencedetect - stereo3d - subtitles - super2xsai - swapuv - thumbnail - tile Hendrik Leppkes: * Switch to AVFrame: - aconvert - amerge - asetnsamples - atempo - biquads Matthieu Bouron: * Switch to AVFrame - alphamerge - decimate - volumedetect Stefano Sabatini: * Switch to AVFrame: - astreamsync - flite - framestep Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Clément Bœsch <ubitux@gmail.com> Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Stefano Sabatini <stefasab@gmail.com> Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/src_movie.c')
-rw-r--r--libavfilter/src_movie.c80
1 files changed, 26 insertions, 54 deletions
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index bd45766641..75c201cd46 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -313,11 +313,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, con
}
}
- if (!(movie->frame = avcodec_alloc_frame()) ) {
- av_log(log, AV_LOG_ERROR, "Failed to alloc frame\n");
- return AVERROR(ENOMEM);
- }
-
av_log(ctx, AV_LOG_VERBOSE, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
movie->seek_point, movie->format_name, movie->file_name,
movie->stream_index);
@@ -339,7 +334,7 @@ static av_cold void movie_uninit(AVFilterContext *ctx)
av_freep(&movie->file_name);
av_freep(&movie->st);
av_freep(&movie->out_index);
- avcodec_free_frame(&movie->frame);
+ av_frame_free(&movie->frame);
if (movie->format_ctx)
avformat_close_input(&movie->format_ctx);
}
@@ -399,54 +394,34 @@ static int movie_config_output_props(AVFilterLink *outlink)
return 0;
}
-static AVFilterBufferRef *frame_to_buf(enum AVMediaType type, AVFrame *frame,
- AVFilterLink *outlink)
-{
- AVFilterBufferRef *buf, *copy;
-
- buf = avfilter_get_buffer_ref_from_frame(type, frame,
- AV_PERM_WRITE |
- AV_PERM_PRESERVE |
- AV_PERM_REUSE2);
- if (!buf)
- return NULL;
- buf->pts = av_frame_get_best_effort_timestamp(frame);
- copy = ff_copy_buffer_ref(outlink, buf);
- if (!copy)
- return NULL;
- buf->buf->data[0] = NULL; /* it belongs to the frame */
- avfilter_unref_buffer(buf);
- return copy;
-}
-
-static char *describe_bufref_to_str(char *dst, size_t dst_size,
- AVFilterBufferRef *buf,
+static char *describe_frame_to_str(char *dst, size_t dst_size,
+ AVFrame *frame,
AVFilterLink *link)
{
- switch (buf->type) {
+ switch (frame->type) {
case AVMEDIA_TYPE_VIDEO:
snprintf(dst, dst_size,
- "video pts:%s time:%s pos:%"PRId64" size:%dx%d aspect:%d/%d",
- av_ts2str(buf->pts), av_ts2timestr(buf->pts, &link->time_base),
- buf->pos, buf->video->w, buf->video->h,
- buf->video->sample_aspect_ratio.num,
- buf->video->sample_aspect_ratio.den);
+ "video pts:%s time:%s size:%dx%d aspect:%d/%d",
+ av_ts2str(frame->pts), av_ts2timestr(frame->pts, &link->time_base),
+ frame->width, frame->height,
+ frame->sample_aspect_ratio.num,
+ frame->sample_aspect_ratio.den);
break;
case AVMEDIA_TYPE_AUDIO:
snprintf(dst, dst_size,
- "audio pts:%s time:%s pos:%"PRId64" samples:%d",
- av_ts2str(buf->pts), av_ts2timestr(buf->pts, &link->time_base),
- buf->pos, buf->audio->nb_samples);
+ "audio pts:%s time:%s samples:%d",
+ av_ts2str(frame->pts), av_ts2timestr(frame->pts, &link->time_base),
+ frame->nb_samples);
break;
default:
- snprintf(dst, dst_size, "%s BUG", av_get_media_type_string(buf->type));
+ snprintf(dst, dst_size, "%s BUG", av_get_media_type_string(frame->type));
break;
}
return dst;
}
-#define describe_bufref(buf, link) \
- describe_bufref_to_str((char[1024]){0}, 1024, buf, link)
+#define describe_frameref(f, link) \
+ describe_frame_to_str((char[1024]){0}, 1024, f, link)
static int rewind_file(AVFilterContext *ctx)
{
@@ -489,7 +464,6 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
MovieStream *st;
int ret, got_frame = 0, pkt_out_id;
AVFilterLink *outlink;
- AVFilterBufferRef *buf;
if (!pkt->size) {
if (movie->eof) {
@@ -532,6 +506,10 @@ 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)
+ return AVERROR(ENOMEM);
+
switch (st->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->st->codec, movie->frame, &got_frame, pkt);
@@ -545,6 +523,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);
return 0;
}
if (!ret)
@@ -560,23 +539,16 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
if (!got_frame) {
if (!ret)
st->done = 1;
+ av_frame_free(&movie->frame);
return 0;
}
- buf = frame_to_buf(st->st->codec->codec_type, movie->frame, outlink);
- if (!buf)
- return AVERROR(ENOMEM);
av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name,
- describe_bufref(buf, outlink));
- switch (st->st->codec->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- if (!movie->frame->sample_aspect_ratio.num)
- buf->video->sample_aspect_ratio = st->st->sample_aspect_ratio;
- /* Fall through */
- case AVMEDIA_TYPE_AUDIO:
- ff_filter_frame(outlink, buf);
- break;
- }
+ describe_frameref(movie->frame, outlink));
+
+ movie->frame->pts = av_frame_get_best_effort_timestamp(movie->frame);
+ ff_filter_frame(outlink, movie->frame); // FIXME: raise error properly
+ movie->frame = NULL;
return pkt_out_id == out_id;
}