gst/smpte/gstsmpte.c: Ignore previous commit, that was only valid for widths and heights that are multiples of 4.

Original commit message from CVS:
* gst/smpte/gstsmpte.c: (fill_i420), (gst_smpte_collected):
Ignore previous commit, that was only valid for widths and heights
that are multiples of 4.
Copy over size/stride macros from jpegdec. This allows the element
to work with any width,height...
... but puts in evidence that the actual transformations only work
with width/height that are multiples of 4.
This commit is contained in:
Edward Hervey 2007-01-19 10:35:13 +00:00
parent 5d45f48fca
commit 3206d6ee5e
2 changed files with 28 additions and 6 deletions

View file

@ -1,3 +1,13 @@
2007-01-19 Edward Hervey <edward@fluendo.com>
* gst/smpte/gstsmpte.c: (fill_i420), (gst_smpte_collected):
Ignore previous commit, that was only valid for widths and heights
that are multiples of 4.
Copy over size/stride macros from jpegdec. This allows the element
to work with any width,height...
... but puts in evidence that the actual transformations only work
with width/height that are multiples of 4.
2007-01-19 Edward Hervey <edward@fluendo.com>
* gst/smpte/gstsmpte.c: (gst_smpte_collected):

View file

@ -114,6 +114,17 @@ enum
PROP_LAST,
};
#define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
#define I420_U_ROWSTRIDE(width) (GST_ROUND_UP_8(width)/2)
#define I420_V_ROWSTRIDE(width) ((GST_ROUND_UP_8(I420_Y_ROWSTRIDE(width)))/2)
#define I420_Y_OFFSET(w,h) (0)
#define I420_U_OFFSET(w,h) (I420_Y_OFFSET(w,h)+(I420_Y_ROWSTRIDE(w)*GST_ROUND_UP_2(h)))
#define I420_V_OFFSET(w,h) (I420_U_OFFSET(w,h)+(I420_U_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
#define I420_SIZE(w,h) (I420_V_OFFSET(w,h)+(I420_V_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
#define GST_TYPE_SMPTE_TRANSITION_TYPE (gst_smpte_transition_type_get_type())
static GType
gst_smpte_transition_type_get_type (void)
@ -252,10 +263,11 @@ static int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
static void
fill_i420 (guint8 * data, gint width, gint height, gint color)
{
gint size = width * height, size4 = size >> 2;
gint size = I420_Y_ROWSTRIDE (width) * GST_ROUND_UP_2 (height);
gint size4 = size >> 2;
guint8 *yp = data;
guint8 *up = data + size;
guint8 *vp = data + size + size4;
guint8 *up = data + I420_U_OFFSET (width, height);
guint8 *vp = data + I420_V_OFFSET (width, height);
memset (yp, y_colors[color], size);
memset (up, u_colors[color], size4);
@ -436,17 +448,17 @@ gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
if (in1 == NULL) {
/* if no input, make picture black */
in1 = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3 / 2);
in1 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
fill_i420 (GST_BUFFER_DATA (in1), smpte->width, smpte->height, 7);
}
if (in2 == NULL) {
/* if no input, make picture white */
in2 = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3 / 2);
in2 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
fill_i420 (GST_BUFFER_DATA (in2), smpte->width, smpte->height, 0);
}
if (smpte->position < smpte->end_position) {
outbuf = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3 / 2);
outbuf = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
/* set caps if not done yet */
if (!GST_PAD_CAPS (smpte->srcpad)) {