From 4ccd9c92ae107f58e5c1e36cf4d6f24d6afef7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 10 Jul 2009 17:23:03 +0200 Subject: [PATCH] videomixer: Remove the calculate_frame_size() function and use libgstvideo instead --- gst/videomixer/blend_ayuv.c | 6 ------ gst/videomixer/blend_bgra.c | 6 ------ gst/videomixer/blend_i420.c | 7 ------- gst/videomixer/videomixer.c | 19 ++++++------------- gst/videomixer/videomixer.h | 4 +++- 5 files changed, 9 insertions(+), 33 deletions(-) diff --git a/gst/videomixer/blend_ayuv.c b/gst/videomixer/blend_ayuv.c index 7cbe154611..b81b7b4f83 100644 --- a/gst/videomixer/blend_ayuv.c +++ b/gst/videomixer/blend_ayuv.c @@ -264,9 +264,3 @@ gst_videomixer_fill_ayuv_color (guint8 * dest, gint width, gint height, } } } - -size_t -gst_videomixer_calculate_frame_size_ayuv (gint width, gint height) -{ - return GST_ROUND_UP_4 (width) * height * 4; -} diff --git a/gst/videomixer/blend_bgra.c b/gst/videomixer/blend_bgra.c index 3cf0846818..398738ed63 100644 --- a/gst/videomixer/blend_bgra.c +++ b/gst/videomixer/blend_bgra.c @@ -131,10 +131,4 @@ gst_videomixer_fill_##name##_color (guint8 * dest, gint width, gint height, \ CREATE_FUNCTIONS (argb, 0, 1, 2, 3); CREATE_FUNCTIONS (bgra, 3, 2, 1, 0); -size_t -gst_videomixer_calculate_frame_size_bgra (gint width, gint height) -{ - return GST_ROUND_UP_4 (width) * height * 4; -} - #undef BLEND_MODE diff --git a/gst/videomixer/blend_i420.c b/gst/videomixer/blend_i420.c index 015f9a10a8..46acb70e7e 100644 --- a/gst/videomixer/blend_i420.c +++ b/gst/videomixer/blend_i420.c @@ -334,10 +334,3 @@ gst_videomixer_fill_i420_color (guint8 * dest, gint width, gint height, memset (dest + VIDEO_V_OFFSET (width, height), colV, size); } - -size_t -gst_videomixer_calculate_frame_size_i420 (gint width, gint height) -{ - return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) + - 2 * (GST_ROUND_UP_8 (width) / 2) * (GST_ROUND_UP_2 (height) / 2); -} diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c index 997aa20ae4..1c9f17bc78 100644 --- a/gst/videomixer/videomixer.c +++ b/gst/videomixer/videomixer.c @@ -103,7 +103,6 @@ void gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos, void gst_videomixer_fill_ayuv_checker (guint8 * dest, gint width, gint height); void gst_videomixer_fill_ayuv_color (guint8 * dest, gint width, gint height, gint colY, gint colU, gint colV); -size_t gst_videomixer_calculate_frame_size_ayuv (gint width, gint height); /*BGRA/ARGB function definitions see file: blend_bgra*/ void gst_videomixer_blend_bgra_bgra (guint8 * src, gint xpos, gint ypos, gint src_width, gint src_height, gdouble src_alpha, @@ -117,7 +116,6 @@ void gst_videomixer_blend_argb_argb (guint8 * src, gint xpos, gint ypos, void gst_videomixer_fill_argb_checker (guint8 * dest, gint width, gint height); void gst_videomixer_fill_argb_color (guint8 * dest, gint width, gint height, gint colY, gint colU, gint colV); -size_t gst_videomixer_calculate_frame_size_bgra (gint width, gint height); /*I420 function definitions see file: blend_i420.c*/ void gst_videomixer_blend_i420_i420 (guint8 * src, gint xpos, gint ypos, gint src_width, gint src_height, gdouble src_alpha, @@ -125,7 +123,6 @@ void gst_videomixer_blend_i420_i420 (guint8 * src, gint xpos, gint ypos, void gst_videomixer_fill_i420_checker (guint8 * dest, gint width, gint height); void gst_videomixer_fill_i420_color (guint8 * dest, gint width, gint height, gint colY, gint colU, gint colV); -size_t gst_videomixer_calculate_frame_size_i420 (gint width, gint height); #define DEFAULT_PAD_ZORDER 0 #define DEFAULT_PAD_XPOS 0 @@ -904,7 +901,6 @@ static gboolean gst_videomixer_setcaps (GstPad * pad, GstCaps * caps) { GstVideoMixer *mixer = GST_VIDEO_MIXER (gst_pad_get_parent_element (pad)); - GstVideoFormat fmt; gboolean ret = FALSE; GST_INFO_OBJECT (mixer, "set src caps: %" GST_PTR_FORMAT, caps); @@ -912,38 +908,33 @@ gst_videomixer_setcaps (GstPad * pad, GstCaps * caps) mixer->blend = NULL; mixer->fill_checker = NULL; mixer->fill_color = NULL; - mixer->calculate_frame_size = NULL; - if (!gst_video_format_parse_caps (caps, &fmt, NULL, NULL)) + if (!gst_video_format_parse_caps (caps, &mixer->fmt, NULL, NULL)) goto done; - switch (fmt) { + switch (mixer->fmt) { case GST_VIDEO_FORMAT_AYUV: mixer->blend = gst_videomixer_blend_ayuv_ayuv; mixer->fill_checker = gst_videomixer_fill_ayuv_checker; mixer->fill_color = gst_videomixer_fill_ayuv_color; - mixer->calculate_frame_size = gst_videomixer_calculate_frame_size_ayuv; ret = TRUE; break; case GST_VIDEO_FORMAT_I420: mixer->blend = gst_videomixer_blend_i420_i420; mixer->fill_checker = gst_videomixer_fill_i420_checker; mixer->fill_color = gst_videomixer_fill_i420_color; - mixer->calculate_frame_size = gst_videomixer_calculate_frame_size_i420; ret = TRUE; break; case GST_VIDEO_FORMAT_BGRA: mixer->blend = gst_videomixer_blend_bgra_bgra; mixer->fill_checker = gst_videomixer_fill_bgra_checker; mixer->fill_color = gst_videomixer_fill_bgra_color; - mixer->calculate_frame_size = gst_videomixer_calculate_frame_size_bgra; ret = TRUE; break; case GST_VIDEO_FORMAT_ARGB: mixer->blend = gst_videomixer_blend_argb_argb; mixer->fill_checker = gst_videomixer_fill_argb_checker; mixer->fill_color = gst_videomixer_fill_argb_color; - mixer->calculate_frame_size = gst_videomixer_calculate_frame_size_bgra; ret = TRUE; break; default: @@ -1304,14 +1295,16 @@ gst_videomixer_collected (GstCollectPads * pads, GstVideoMixer * mix) /* Calculating out buffer size from input size */ gst_pad_set_caps (mix->srcpad, newcaps); - outsize = mix->calculate_frame_size (mix->out_width, mix->out_height); + outsize = + gst_video_format_get_size (mix->fmt, mix->out_width, mix->out_height); ret = gst_pad_alloc_buffer_and_set_caps (mix->srcpad, GST_BUFFER_OFFSET_NONE, outsize, newcaps, &outbuf); gst_caps_unref (newcaps); } else { /* Otherwise we just allocate a buffer from current caps */ /* Calculating out buffer size from input size */ - outsize = mix->calculate_frame_size (mix->out_width, mix->out_height); + outsize = + gst_video_format_get_size (mix->fmt, mix->out_width, mix->out_height); ret = gst_pad_alloc_buffer_and_set_caps (mix->srcpad, GST_BUFFER_OFFSET_NONE, outsize, GST_PAD_CAPS (mix->srcpad), &outbuf); diff --git a/gst/videomixer/videomixer.h b/gst/videomixer/videomixer.h index 7266a9af25..7985a1a040 100644 --- a/gst/videomixer/videomixer.h +++ b/gst/videomixer/videomixer.h @@ -21,6 +21,7 @@ #define __GST_VIDEO_MIXER_H__ #include +#include #include "videomixerpad.h" GST_DEBUG_CATEGORY_EXTERN (gst_videomixer_debug); @@ -84,6 +85,8 @@ struct _GstVideoMixer /* the master pad */ GstVideoMixerPad *master; + GstVideoFormat fmt; + gint in_width, in_height; gint out_width, out_height; gboolean setcaps; @@ -107,7 +110,6 @@ struct _GstVideoMixer void (*fill_checker) (guint8 * dest, gint width, gint height); void (*fill_color) (guint8 * dest, gint width, gint height, gint colY, gint colU, gint colV); - size_t (*calculate_frame_size) (gint width, gint height); }; struct _GstVideoMixerClass