gst/ffmpegcolorspace/: More stride fixes.

Original commit message from CVS:
* 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.
This commit is contained in:
Wim Taymans 2004-11-05 14:58:50 +00:00
parent 5c31c304de
commit e40a51fa08
3 changed files with 56 additions and 8 deletions

View file

@ -1,3 +1,12 @@
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> 2004-11-05 Wim Taymans <wim@fluendo.com>
* gst/alpha/gstalpha.c: (gst_alpha_set_property), (gst_alpha_add), * gst/alpha/gstalpha.c: (gst_alpha_set_property), (gst_alpha_add),

View file

@ -671,7 +671,12 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
}, },
}; };
#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 int
gst_ffmpegcsp_avpicture_fill (AVPicture * picture, gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
@ -682,8 +687,7 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
PixFmtInfo *pinfo; PixFmtInfo *pinfo;
pinfo = &pix_fmt_info[pix_fmt]; pinfo = &pix_fmt_info[pix_fmt];
stride = ROUND_UP_4 (width);
size = stride * height;
switch (pix_fmt) { switch (pix_fmt) {
case PIX_FMT_YUV420P: case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
@ -694,10 +698,11 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
case PIX_FMT_YUVJ422P: case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ444P: case PIX_FMT_YUVJ444P:
stride = ROUND_UP_4 (width); stride = ROUND_UP_4 (width);
size = stride * height; h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift; size = stride * h2;
w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
stride2 = ROUND_UP_4 (w2); 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; size2 = stride2 * h2;
picture->data[0] = ptr; picture->data[0] = ptr;
picture->data[1] = picture->data[0] + size; picture->data[1] = picture->data[0] + size;
@ -736,6 +741,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
return size; return size;
case PIX_FMT_UYVY411: case PIX_FMT_UYVY411:
/* FIXME, probably not the right stride */ /* FIXME, probably not the right stride */
stride = ROUND_UP_4 (width);
size = stride * height;
picture->data[0] = ptr; picture->data[0] = ptr;
picture->data[1] = NULL; picture->data[1] = NULL;
picture->data[2] = NULL; picture->data[2] = NULL;

View file

@ -760,6 +760,10 @@ yuv422p_to_yuv422 (AVPicture * dst, const AVPicture * src,
cb++; cb++;
cr++; cr++;
} }
if (w) {
p[0] = lum[0];
p[1] = cb[0];
}
p1 += dst->linesize[0]; p1 += dst->linesize[0];
lum1 += src->linesize[0]; lum1 += src->linesize[0];
cb1 += src->linesize[1]; cb1 += src->linesize[1];
@ -866,12 +870,37 @@ yuv420p_to_yuv422 (AVPicture * dst, const AVPicture * src,
*line2++ = *lum2++; *line2++ = *lum2++;
*line1++ = *line2++ = *cr1++; *line1++ = *line2++ = *cr1++;
} }
/* odd width */
if (w) {
*line1++ = *lum1++;
*line2++ = *lum2++;
*line1++ = *line2++ = *cb1++;
}
linesrc += dst->linesize[0] * 2; linesrc += dst->linesize[0] * 2;
lumsrc += src->linesize[0] * 2; lumsrc += src->linesize[0] * 2;
cb2 += src->linesize[1]; cb2 += src->linesize[1];
cr2 += src->linesize[2]; 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 #define SCALEBITS 10
@ -1938,11 +1967,14 @@ img_convert (AVPicture * dst, int dst_pix_fmt,
img_copy_plane (dst->data[0], dst->linesize[0], img_copy_plane (dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], dst_width, dst_height); 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++) for (i = 1; i <= 2; i++)
resize_func (dst->data[i], dst->linesize[i], resize_func (dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i], src->data[i], src->linesize[i],
dst_width >> dst_pix->x_chroma_shift, DIV_ROUND_UP_X (dst_width, dst_pix->x_chroma_shift),
dst_height >> dst_pix->y_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 /* if yuv color space conversion is needed, we do it here on
the destination image */ the destination image */
if (dst_pix->color_type != src_pix->color_type) { if (dst_pix->color_type != src_pix->color_type) {