mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
ext/ffmpeg/gstffmpegdec.c: Enable direct rendering.
Original commit message from CVS: * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_setcaps), (gst_ffmpegdec_get_buffer), (get_output_buffer): Enable direct rendering. Add some more debug info about image strides.
This commit is contained in:
parent
0f96b4dfc2
commit
fe4e398482
2 changed files with 43 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_setcaps),
|
||||||
|
(gst_ffmpegdec_get_buffer), (get_output_buffer):
|
||||||
|
Enable direct rendering.
|
||||||
|
Add some more debug info about image strides.
|
||||||
|
|
||||||
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps),
|
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_pixfmt_to_caps),
|
||||||
|
|
|
@ -139,7 +139,7 @@ struct _GstFFMpegDecClassParams
|
||||||
|
|
||||||
#define DEFAULT_LOWRES 0
|
#define DEFAULT_LOWRES 0
|
||||||
#define DEFAULT_SKIPFRAME 0
|
#define DEFAULT_SKIPFRAME 0
|
||||||
#define DEFAULT_DIRECT_RENDERING FALSE
|
#define DEFAULT_DIRECT_RENDERING TRUE
|
||||||
#define DEFAULT_DO_PADDING TRUE
|
#define DEFAULT_DO_PADDING TRUE
|
||||||
#define DEFAULT_DEBUG_MV FALSE
|
#define DEFAULT_DEBUG_MV FALSE
|
||||||
|
|
||||||
|
@ -634,10 +634,14 @@ gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
ffmpegdec->ts_is_dts = FALSE;
|
ffmpegdec->ts_is_dts = FALSE;
|
||||||
ffmpegdec->has_b_frames = FALSE;
|
ffmpegdec->has_b_frames = FALSE;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width, ffmpegdec->context->height);
|
||||||
|
|
||||||
/* get size and so */
|
/* get size and so */
|
||||||
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
|
||||||
oclass->in_plugin->type, caps, ffmpegdec->context);
|
oclass->in_plugin->type, caps, ffmpegdec->context);
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width, ffmpegdec->context->height);
|
||||||
|
|
||||||
if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
|
if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
|
||||||
GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
|
GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
|
||||||
ffmpegdec->context->time_base.num = 1;
|
ffmpegdec->context->time_base.num = 1;
|
||||||
|
@ -801,6 +805,9 @@ gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
|
||||||
{
|
{
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
GstFFMpegDec *ffmpegdec;
|
GstFFMpegDec *ffmpegdec;
|
||||||
|
gint width, height;
|
||||||
|
gint coded_width, coded_height;
|
||||||
|
gint res;
|
||||||
|
|
||||||
ffmpegdec = (GstFFMpegDec *) context->opaque;
|
ffmpegdec = (GstFFMpegDec *) context->opaque;
|
||||||
|
|
||||||
|
@ -814,9 +821,23 @@ gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
|
||||||
/* make sure we don't free the buffer when it's not ours */
|
/* make sure we don't free the buffer when it's not ours */
|
||||||
picture->opaque = NULL;
|
picture->opaque = NULL;
|
||||||
|
|
||||||
|
/* take width and height before clipping */
|
||||||
|
width = context->width;
|
||||||
|
height = context->height;
|
||||||
|
coded_width = context->coded_width;
|
||||||
|
coded_height = context->coded_height;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height, coded_width, coded_height);
|
||||||
|
|
||||||
if (!ffmpegdec->current_dr) {
|
if (!ffmpegdec->current_dr) {
|
||||||
GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
|
GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
|
||||||
return avcodec_default_get_buffer (context, picture);
|
res = avcodec_default_get_buffer (context, picture);
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
|
||||||
|
picture->linesize[1], picture->linesize[2]);
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "data %d %d %d", 0, picture->data[1] - picture->data[0],
|
||||||
|
picture->data[2] - picture->data[0]);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (context->codec_type) {
|
switch (context->codec_type) {
|
||||||
|
@ -825,18 +846,16 @@ gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
|
||||||
case CODEC_TYPE_UNKNOWN:
|
case CODEC_TYPE_UNKNOWN:
|
||||||
{
|
{
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
gint width, height;
|
|
||||||
gint clip_width, clip_height;
|
gint clip_width, clip_height;
|
||||||
|
|
||||||
/* take width and height before clipping */
|
|
||||||
width = context->width;
|
|
||||||
height = context->height;
|
|
||||||
/* take final clipped output size */
|
/* take final clipped output size */
|
||||||
if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
|
if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
|
||||||
clip_width = width;
|
clip_width = width;
|
||||||
if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
|
if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
|
||||||
clip_height = height;
|
clip_height = height;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
|
||||||
|
|
||||||
/* this is the size ffmpeg needs for the buffer */
|
/* this is the size ffmpeg needs for the buffer */
|
||||||
avcodec_align_dimensions (context, &width, &height);
|
avcodec_align_dimensions (context, &width, &height);
|
||||||
|
|
||||||
|
@ -1325,7 +1344,7 @@ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
|
||||||
gst_buffer_ref (*outbuf);
|
gst_buffer_ref (*outbuf);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
AVPicture pic;
|
AVPicture pic, *outpic;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec, "get output buffer");
|
GST_LOG_OBJECT (ffmpegdec, "get output buffer");
|
||||||
|
@ -1337,6 +1356,8 @@ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
|
||||||
if ((height = ffmpegdec->format.video.clip_height) == -1)
|
if ((height = ffmpegdec->format.video.clip_height) == -1)
|
||||||
height = ffmpegdec->context->height;
|
height = ffmpegdec->context->height;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "clip width %d/ height %d", width, height);
|
||||||
|
|
||||||
ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
|
ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
goto alloc_failed;
|
goto alloc_failed;
|
||||||
|
@ -1346,7 +1367,14 @@ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
|
||||||
gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
|
gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
|
||||||
ffmpegdec->context->pix_fmt, width, height);
|
ffmpegdec->context->pix_fmt, width, height);
|
||||||
|
|
||||||
av_picture_copy (&pic, (AVPicture *) ffmpegdec->picture,
|
outpic = (AVPicture *) ffmpegdec->picture;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
|
||||||
|
outpic->linesize[1], outpic->linesize[2]);
|
||||||
|
GST_LOG_OBJECT (ffmpegdec, "data %d %d %d", 0, outpic->data[1] - outpic->data[0],
|
||||||
|
outpic->data[2] - outpic->data[0]);
|
||||||
|
|
||||||
|
av_picture_copy (&pic, outpic,
|
||||||
ffmpegdec->context->pix_fmt, width, height);
|
ffmpegdec->context->pix_fmt, width, height);
|
||||||
}
|
}
|
||||||
ffmpegdec->picture->pts = -1;
|
ffmpegdec->picture->pts = -1;
|
||||||
|
|
Loading…
Reference in a new issue