Use av_picture_copy() instead of libswscale to copy pictures. This removes the swscale dependency and is faster. Fixe...

Original commit message from CVS:
Patch by:
Hans de Goede <j dot w dot r degoede at hhs dot nl>
* configure.ac:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (get_output_buffer):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_collected):
Use av_picture_copy() instead of libswscale to copy pictures. This
removes the swscale dependency and is faster. Fixes bug #534390.
This commit is contained in:
Sebastian Dröge 2008-05-26 07:39:19 +00:00
parent a24ce03f75
commit 2b248e29ff
7 changed files with 21 additions and 49 deletions

View file

@ -1,3 +1,17 @@
2008-05-26 Sebastian Dröge <slomo@circular-chaos.org>
Patch by:
Hans de Goede <j dot w dot r degoede at hhs dot nl>
* configure.ac:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_avpicture_fill):
* ext/ffmpeg/gstffmpegcodecmap.h:
* ext/ffmpeg/gstffmpegdec.c: (get_output_buffer):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_collected):
Use av_picture_copy() instead of libswscale to copy pictures. This
removes the swscale dependency and is faster. Fixes bug #534390.
2008-05-25 Tim-Philipp Müller <tim.muller at collabora co uk>
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_type_find),

View file

@ -207,7 +207,7 @@ AC_ARG_WITH(system-ffmpeg,
[AC_HELP_STRING([--with-system-ffmpeg], [use system FFmpeg libraries])])
if test "x$with_system_ffmpeg" = "xyes"; then
PKG_CHECK_MODULES(FFMPEG, libavutil libavcodec libavformat libswscale)
PKG_CHECK_MODULES(FFMPEG, libavutil libavcodec libavformat)
PKG_CHECK_MODULES(POSTPROC, libavcodec libpostproc)
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"

View file

@ -25,9 +25,7 @@
#include <gst/gst.h>
#ifdef HAVE_FFMPEG_UNINSTALLED
#include <avcodec.h>
#include <libswscale/swscale.h>
#else
#include <ffmpeg/swscale.h>
#include <ffmpeg/avcodec.h>
#endif
#include <string.h>
@ -3287,29 +3285,3 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
return 0;
}
/**
* Convert image 'src' to 'dst'.
*
* We use this code to copy two pictures between the same
* colorspaces, so this function is not realy used to do
* colorspace conversion.
* The ffmpeg code has a bug in it where odd sized frames were
* not copied completely. We adjust the input parameters for
* the original ffmpeg img_convert function here so that it
* still does the right thing.
*/
int
gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt,
const AVPicture * src, int src_pix_fmt, int src_width, int src_height)
{
struct SwsContext *ctx;
int res;
ctx = sws_getContext (src_width, src_height, src_pix_fmt, src_width, src_height, dst_pix_fmt, 2, /* flags : bicubic */
NULL, NULL, NULL);
res = sws_scale (ctx, (uint8_t **) src->data, (int *) src->linesize,
2, src_width, dst->data, dst->linesize);
sws_freeContext (ctx);
return res;
}

View file

@ -124,15 +124,6 @@ gst_ffmpeg_avpicture_fill (AVPicture * picture,
int width,
int height);
/*
* convert an image, we only use this for copying the image, ie,
* convert between the same colorspaces.
*/
int
gst_ffmpeg_img_convert (AVPicture * dst, int dst_pix_fmt,
const AVPicture * src, int src_pix_fmt,
int src_width, int src_height);
/*
* Convert from/to a GStreamer <-> FFMpeg timestamp.
*/

View file

@ -1342,11 +1342,7 @@ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
ffmpegdec->context->pix_fmt, width, height);
/* the original convert function did not do the right thing, this
* is a patched up version that adjust widht/height so that the
* ffmpeg one works correctly. */
gst_ffmpeg_img_convert (&pic, ffmpegdec->context->pix_fmt,
(AVPicture *) ffmpegdec->picture,
av_picture_copy (&pic, (AVPicture *) ffmpegdec->picture,
ffmpegdec->context->pix_fmt, width, height);
}
ffmpegdec->picture->pts = -1;

View file

@ -737,7 +737,7 @@ gst_ffmpegdemux_src_query (GstPad * pad, GstQuery * query)
}
}
break;
case GST_QUERY_SEEKING: {
case GST_QUERY_SEEKING:{
GstFormat format;
gboolean seekable;
gint64 dur = -1;
@ -1289,9 +1289,8 @@ gst_ffmpegdemux_loop (GstPad * pad)
avstream->codec->pix_fmt, avstream->codec->width,
avstream->codec->height);
gst_ffmpeg_img_convert (&dst, avstream->codec->pix_fmt,
&src, avstream->codec->pix_fmt, avstream->codec->width,
avstream->codec->height);
av_picture_copy (&dst, &src, avstream->codec->pix_fmt,
avstream->codec->width, avstream->codec->height);
} else {
memcpy (GST_BUFFER_DATA (outbuf), pkt.data, outsize);
}

View file

@ -554,8 +554,8 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
PIX_FMT_RGB24, st->codec->width, st->codec->height);
gst_ffmpeg_img_convert (&dst, PIX_FMT_RGB24,
&src, PIX_FMT_RGB24, st->codec->width, st->codec->height);
av_picture_copy (&dst, &src, PIX_FMT_RGB24,
st->codec->width, st->codec->height);
} else {
pkt.data = GST_BUFFER_DATA (buf);
pkt.size = GST_BUFFER_SIZE (buf);