ffmpegcolorspace: Add support for packed 4:4:4 YUV (format=V308)

Only conversions from/to are implemented, which
gives (indirect) support for all possible conversions.

Partially fixes bug #571147.
This commit is contained in:
Sebastian Dröge 2009-02-12 19:02:59 +01:00
parent 79d0fff231
commit 65c322edf2
4 changed files with 83 additions and 2 deletions

View file

@ -85,6 +85,7 @@ enum PixelFormat {
PIX_FMT_XVMC_MPEG2_IDCT,
PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1
PIX_FMT_UYVY411, ///< Packed pixel, Cb Y0 Y1 Cr Y2 Y3
PIX_FMT_V308, ///< Packed pixel, Y0 Cb Cr
PIX_FMT_AYUV4444, ///< Packed pixel, A0 Y0 Cb Cr
PIX_FMT_NB

View file

@ -353,6 +353,9 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context)
bpp = depth = 8;
endianness = G_BYTE_ORDER;
break;
case PIX_FMT_V308:
fmt = GST_MAKE_FOURCC ('V', '3', '0', '8');
break;
case PIX_FMT_AYUV4444:
fmt = GST_MAKE_FOURCC ('A', 'Y', 'U', 'V');
break;
@ -614,6 +617,9 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
context->pix_fmt = PIX_FMT_YVU410P;
break;
case GST_MAKE_FOURCC ('V', '3', '0', '8'):
context->pix_fmt = PIX_FMT_V308;
break;
case GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'):
context->pix_fmt = PIX_FMT_AYUV4444;
break;
@ -857,6 +863,14 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture,
picture->data[2] = NULL;
picture->linesize[0] = stride;
return size;
case PIX_FMT_V308:
stride = GST_ROUND_UP_4 (width * 3);
size = stride * height;
picture->data[0] = ptr;
picture->data[1] = NULL;
picture->data[2] = NULL;
picture->linesize[0] = stride;
return size;
case PIX_FMT_UYVY411:
/* FIXME, probably not the right stride */
stride = GST_ROUND_UP_4 (width);

View file

@ -130,6 +130,17 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
/* .y_chroma_shift = */ 0,
/* .depth = */ 8,
},
/* [PIX_FMT_V308] = */ {
/* .format = */ PIX_FMT_V308,
/* .name = */ "v308",
/* .nb_channels = */ 1,
/* .color_type = */ FF_COLOR_YUV,
/* .pixel_type = */ FF_PIXEL_PACKED,
/* .is_alpha = */ 0,
/* .x_chroma_shift = */ 0,
/* .y_chroma_shift = */ 0,
/* .depth = */ 8,
},
/* [PIX_FMT_YUV410P] = */ {
/* .format = */ PIX_FMT_YUV410P,
/* .name = */ "yuv410p",
@ -2182,6 +2193,7 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_RGB24, PIX_FMT_YUVJ420P, rgb24_to_yuvj420p},
{PIX_FMT_RGB24, PIX_FMT_YUVJ444P, rgb24_to_yuvj444p},
{PIX_FMT_RGB24, PIX_FMT_AYUV4444, rgb24_to_ayuv4444},
{PIX_FMT_RGB24, PIX_FMT_V308, rgb24_to_v308},
{PIX_FMT_RGB32, PIX_FMT_RGB24, rgb32_to_rgb24},
{PIX_FMT_RGB32, PIX_FMT_RGB555, rgba32_to_rgb555},
@ -2303,9 +2315,10 @@ static ConvertEntry convert_table[] = {
{PIX_FMT_UYVY411, PIX_FMT_YUV411P, uyvy411_to_yuv411p},
{PIX_FMT_AYUV4444, PIX_FMT_RGBA32, ayuv4444_to_rgba32},
{PIX_FMT_V308, PIX_FMT_RGB24, v308_to_rgb24},
{PIX_FMT_AYUV4444, PIX_FMT_RGB24, ayuv4444_to_rgb24}
{PIX_FMT_AYUV4444, PIX_FMT_RGBA32, ayuv4444_to_rgba32},
{PIX_FMT_AYUV4444, PIX_FMT_RGB24, ayuv4444_to_rgb24},
};
static ConvertEntry *
@ -2766,6 +2779,7 @@ deinterlace_line (uint8_t * dst,
}
#endif
}
static void
deinterlace_line_inplace (uint8_t * lum_m4, uint8_t * lum_m3, uint8_t * lum_m2,
uint8_t * lum_m1, uint8_t * lum, int size)

View file

@ -1300,6 +1300,58 @@ static void rgb24_to_ayuv4444(AVPicture *dst, const AVPicture *src,
d += dst_wrap;
}
}
static void v308_to_rgb24(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *s, *d, *d1, *s1;
int w, y, cb, cr, r_add, g_add, b_add;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
d = dst->data[0];
s = src->data[0];
for(;height > 0; height --) {
d1 = d;
s1 = s;
for(w = width; w > 0; w--) {
YUV_TO_RGB1_CCIR(s1[1], s1[2]);
YUV_TO_RGB2_CCIR(r, g, b, s1[0]);
RGB_OUT(d1, r, g, b);
d1 += BPP;
s1 += 3;
}
d += dst->linesize[0];
s += src->linesize[0];
}
}
static void rgb24_to_v308(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int src_wrap, dst_wrap, x, y;
int r, g, b;
uint8_t *d;
const uint8_t *p;
src_wrap = src->linesize[0] - width * BPP;
dst_wrap = dst->linesize[0] - width * 3;
d = dst->data[0];
p = src->data[0];
for(y=0;y<height;y++) {
for(x=0;x<width;x++) {
RGB_IN(r, g, b, p);
d[0] = RGB_TO_Y_CCIR(r, g, b);
d[1] = RGB_TO_U_CCIR(r, g, b, 0);
d[2] = RGB_TO_V_CCIR(r, g, b, 0);
p += BPP;
d += 3;
}
p += src_wrap;
d += dst_wrap;
}
}
#endif /* FMT_RGB24 */
#if defined(FMT_RGB24) || defined(FMT_RGBA32)