aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-05-01 14:47:05 +0200
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-05-07 12:03:49 +0200
commit566666caf3a09d6254edaa99d222eddb6fe2986b (patch)
tree7570c9596cfde912b168846aa5a303d828d56089
parent18ded93ab3db5996cd86fe2f5b36ba3c4bd58711 (diff)
downloadffmpeg-566666caf3a09d6254edaa99d222eddb6fe2986b.tar.gz
lavfi: add libavfilter/avcodec.h and avfilter_copy_frame_props()
avfilter_copy_frame_props() avoids code duplication and increases robustness. The added files libavfilter/avcodec.[ch] are used for containing utilities useful for gluing togheter libavfilter and libavcodec.
-rw-r--r--doc/APIchanges4
-rw-r--r--ffmpeg.c1
-rw-r--r--ffplay.c5
-rw-r--r--libavfilter/Makefile4
-rw-r--r--libavfilter/avcodec.c42
-rw-r--r--libavfilter/avcodec.h40
-rw-r--r--libavfilter/avfilter.h2
-rw-r--r--libavfilter/vsrc_buffer.c9
-rw-r--r--libavfilter/vsrc_movie.c8
9 files changed, 99 insertions, 16 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index e46ee48e36..1f5e8aad39 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2011-04-18
API changes, most recent first:
+2011-05-07 - xxxxxxx - lavfi 2.5.0 - avcodec.h
+ Add libavfilter/avcodec.h header and avfilter_copy_frame_props()
+ function.
+
2011-05-07 - xxxxxxx - lavc 53.5.0 - AVFrame
Add format field to AVFrame.
diff --git a/ffmpeg.c b/ffmpeg.c
index bd504de7b9..0169674b9a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -50,6 +50,7 @@
#include "libavformat/ffm.h" // not public API
#if CONFIG_AVFILTER
+# include "libavfilter/avcodec.h"
# include "libavfilter/avfilter.h"
# include "libavfilter/avfiltergraph.h"
# include "libavfilter/vsrc_buffer.h"
diff --git a/ffplay.c b/ffplay.c
index e57161fc21..d76ea5b69d 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -40,6 +40,7 @@
#include "libavcodec/avfft.h"
#if CONFIG_AVFILTER
+# include "libavfilter/avcodec.h"
# include "libavfilter/avfilter.h"
# include "libavfilter/avfiltergraph.h"
#endif
@@ -1686,9 +1687,9 @@ static int input_request_frame(AVFilterLink *link)
}
av_free_packet(&pkt);
+ avfilter_copy_frame_props(picref, priv->frame);
picref->pts = pts;
- picref->pos = priv->frame->pkt_pos;
- picref->video->sample_aspect_ratio = priv->frame->sample_aspect_ratio;
+
avfilter_start_frame(link, picref);
avfilter_draw_slice(link, 0, link->h, 1);
avfilter_end_frame(link);
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index bf28f9aa54..de34089468 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -6,7 +6,7 @@ FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
FFLIBS-$(CONFIG_SCALE_FILTER) += swscale
FFLIBS-$(CONFIG_MP_FILTER) += avcodec
-HEADERS = avfilter.h avfiltergraph.h
+HEADERS = avcodec.h avfilter.h avfiltergraph.h
OBJS = allfilters.o \
avfilter.o \
@@ -16,6 +16,8 @@ OBJS = allfilters.o \
formats.o \
graphparser.o \
+OBJS-$(CONFIG_AVCODEC) += avcodec.o
+
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o
diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
new file mode 100644
index 0000000000..c2f8651106
--- /dev/null
+++ b/libavfilter/avcodec.c
@@ -0,0 +1,42 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * libavcodec/libavfilter gluing utilities
+ */
+
+#include "avcodec.h"
+
+void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
+{
+ dst->pts = src->pts;
+ dst->pos = src->pkt_pos;
+ dst->format = src->format;
+
+ switch (dst->type) {
+ case AVMEDIA_TYPE_VIDEO:
+ dst->video->w = src->width;
+ dst->video->h = src->height;
+ dst->video->sample_aspect_ratio = src->sample_aspect_ratio;
+ dst->video->interlaced = src->interlaced_frame;
+ dst->video->top_field_first = src->top_field_first;
+ dst->video->key_frame = src->key_frame;
+ dst->video->pict_type = src->pict_type;
+ }
+}
diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
new file mode 100644
index 0000000000..f438860d0b
--- /dev/null
+++ b/libavfilter/avcodec.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFILTER_AVCODEC_H
+#define AVFILTER_AVCODEC_H
+
+/**
+ * @file
+ * libavcodec/libavfilter gluing utilities
+ *
+ * This should be included in an application ONLY if the installed
+ * libavfilter has been compiled with libavcodec support, otherwise
+ * symbols defined below will not be available.
+ */
+
+#include "libavcodec/avcodec.h" // AVFrame
+#include "avfilter.h"
+
+/**
+ * Copy the frame properties of src to dst, without copying the actual
+ * image data.
+ */
+void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
+
+#endif /* AVFILTER_AVCODEC_H */
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 1a69aa397c..03a1e49a46 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -26,7 +26,7 @@
#include "libavutil/samplefmt.h"
#define LIBAVFILTER_VERSION_MAJOR 2
-#define LIBAVFILTER_VERSION_MINOR 4
+#define LIBAVFILTER_VERSION_MINOR 5
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index b094e99209..b78d979711 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -24,6 +24,7 @@
*/
#include "avfilter.h"
+#include "avcodec.h"
#include "vsrc_buffer.h"
#include "libavutil/imgutils.h"
@@ -193,13 +194,9 @@ static int request_frame(AVFilterLink *link)
av_image_copy(picref->data, picref->linesize,
c->frame.data, c->frame.linesize,
picref->format, link->w, link->h);
+ avfilter_copy_frame_props(picref, &c->frame);
+ picref->pts = c->pts;
- picref->pts = c->pts;
- picref->video->sample_aspect_ratio = c->frame.sample_aspect_ratio;
- picref->video->interlaced = c->frame.interlaced_frame;
- picref->video->top_field_first = c->frame.top_field_first;
- picref->video->key_frame = c->frame.key_frame;
- picref->video->pict_type = c->frame.pict_type;
avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
avfilter_draw_slice(link, 0, link->h, 1);
avfilter_end_frame(link);
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index e94e77d8ee..e36412f480 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -35,6 +35,7 @@
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavformat/avformat.h"
+#include "avcodec.h"
#include "avfilter.h"
typedef struct {
@@ -239,20 +240,15 @@ static int movie_get_frame(AVFilterLink *outlink)
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->pkt_pos;
if (!movie->frame->sample_aspect_ratio.num)
movie->picref->video->sample_aspect_ratio = st->sample_aspect_ratio;
- movie->picref->video->interlaced = movie->frame->interlaced_frame;
- movie->picref->video->top_field_first = movie->frame->top_field_first;
- movie->picref->video->key_frame = movie->frame->key_frame;
- movie->picref->video->pict_type = movie->frame->pict_type;
av_dlog(outlink->src,
"movie_get_frame(): file:'%s' pts:%"PRId64" time:%lf pos:%"PRId64" aspect:%d/%d\n",
movie->file_name, movie->picref->pts,