2004-11-05 Wim Taymans <wim@fluendo.com>
+ * gst/ffmpegcolorspace/gstffmpegcodecmap.c:
+ (gst_ffmpegcsp_avpicture_fill):
+ * gst/ffmpegcolorspace/imgconvert.c: (avpicture_get_size),
+ (yuv422p_to_yuv422), (yuv420p_to_yuv422), (shrink12),
+ (img_convert), (deinterlace_line), (deinterlace_line_inplace):
+ More stride fixes.
+
+2004-11-05 Wim Taymans <wim@fluendo.com>
+
* gst/alpha/gstalpha.c: (gst_alpha_set_property), (gst_alpha_add),
(gst_alpha_chroma_key), (gst_alpha_init_params), (gst_alpha_chain):
* gst/videomixer/videomixer.c: (gst_videomixer_blend_ayuv_i420),
},
};
-#define ROUND_UP_4(x) (((x) + 3) & ~3)
+#define GEN_MASK(x) ((1<<(x))-1)
+#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
+#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
+#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
+#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
+#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
int
gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
PixFmtInfo *pinfo;
pinfo = &pix_fmt_info[pix_fmt];
- stride = ROUND_UP_4 (width);
- size = stride * height;
+
switch (pix_fmt) {
case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ444P:
stride = ROUND_UP_4 (width);
- size = stride * height;
- w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
+ h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
+ size = stride * h2;
+ w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
stride2 = ROUND_UP_4 (w2);
- h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
+ h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
size2 = stride2 * h2;
picture->data[0] = ptr;
picture->data[1] = picture->data[0] + size;
return size;
case PIX_FMT_UYVY411:
/* FIXME, probably not the right stride */
+ stride = ROUND_UP_4 (width);
+ size = stride * height;
picture->data[0] = ptr;
picture->data[1] = NULL;
picture->data[2] = NULL;
cb++;
cr++;
}
+ if (w) {
+ p[0] = lum[0];
+ p[1] = cb[0];
+ }
p1 += dst->linesize[0];
lum1 += src->linesize[0];
cb1 += src->linesize[1];
*line2++ = *lum2++;
*line1++ = *line2++ = *cr1++;
}
+ /* odd width */
+ if (w) {
+ *line1++ = *lum1++;
+ *line2++ = *lum2++;
+ *line1++ = *line2++ = *cb1++;
+ }
linesrc += dst->linesize[0] * 2;
lumsrc += src->linesize[0] * 2;
cb2 += src->linesize[1];
cr2 += src->linesize[2];
}
+ /* odd height */
+ if (h) {
+ line1 = linesrc;
+ lum1 = lumsrc;
+ cb1 = cb2;
+ cr1 = cr2;
+
+ for (w = width / 2; w--;) {
+ *line1++ = *lum1++;
+ *line1++ = *cb1++;
+ *line1++ = *lum1++;
+ *line1++ = *cr1++;
+ }
+ /* odd width */
+ if (w) {
+ *line1++ = *lum1++;
+ *line1++ = *cb1++;
+ }
+ }
}
#define SCALEBITS 10
img_copy_plane (dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], dst_width, dst_height);
+#define GEN_MASK(x) ((1<<(x))-1)
+#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
+
for (i = 1; i <= 2; i++)
resize_func (dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i],
- dst_width >> dst_pix->x_chroma_shift,
- dst_height >> dst_pix->y_chroma_shift);
+ DIV_ROUND_UP_X (dst_width, dst_pix->x_chroma_shift),
+ DIV_ROUND_UP_X (dst_height, dst_pix->y_chroma_shift));
/* if yuv color space conversion is needed, we do it here on
the destination image */
if (dst_pix->color_type != src_pix->color_type) {