UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
Originally committed as revision 3339 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:

committed by
Michael Niedermayer

parent
8300609b78
commit
ebb177ddef
@@ -175,7 +175,7 @@ enum CodecType {
|
|||||||
*/
|
*/
|
||||||
enum PixelFormat {
|
enum PixelFormat {
|
||||||
PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
|
PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
|
||||||
PIX_FMT_YUV422,
|
PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr
|
||||||
PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
|
PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
|
||||||
PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
|
PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
|
||||||
PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
|
PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
|
||||||
@@ -194,6 +194,7 @@ enum PixelFormat {
|
|||||||
PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
|
PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
|
||||||
PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
|
PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
|
||||||
PIX_FMT_XVMC_MPEG2_IDCT,
|
PIX_FMT_XVMC_MPEG2_IDCT,
|
||||||
|
PIX_FMT_UYVY422, ///< Packed pixel, Cb Y0 Cr Y1
|
||||||
PIX_FMT_NB,
|
PIX_FMT_NB,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -97,6 +97,14 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
|
|||||||
.depth = 8,
|
.depth = 8,
|
||||||
.x_chroma_shift = 1, .y_chroma_shift = 0,
|
.x_chroma_shift = 1, .y_chroma_shift = 0,
|
||||||
},
|
},
|
||||||
|
[PIX_FMT_UYVY422] = {
|
||||||
|
.name = "uyvy422",
|
||||||
|
.nb_channels = 1,
|
||||||
|
.color_type = FF_COLOR_YUV,
|
||||||
|
.pixel_type = FF_PIXEL_PACKED,
|
||||||
|
.depth = 8,
|
||||||
|
.x_chroma_shift = 1, .y_chroma_shift = 0,
|
||||||
|
},
|
||||||
[PIX_FMT_YUV410P] = {
|
[PIX_FMT_YUV410P] = {
|
||||||
.name = "yuv410p",
|
.name = "yuv410p",
|
||||||
.nb_channels = 3,
|
.nb_channels = 3,
|
||||||
@@ -288,6 +296,12 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
|
|||||||
picture->data[2] = NULL;
|
picture->data[2] = NULL;
|
||||||
picture->linesize[0] = width * 2;
|
picture->linesize[0] = width * 2;
|
||||||
return size * 2;
|
return size * 2;
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
|
picture->data[0] = ptr;
|
||||||
|
picture->data[1] = NULL;
|
||||||
|
picture->data[2] = NULL;
|
||||||
|
picture->linesize[0] = width * 2;
|
||||||
|
return size * 2;
|
||||||
case PIX_FMT_GRAY8:
|
case PIX_FMT_GRAY8:
|
||||||
picture->data[0] = ptr;
|
picture->data[0] = ptr;
|
||||||
picture->data[1] = NULL;
|
picture->data[1] = NULL;
|
||||||
@@ -330,9 +344,11 @@ int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
|
if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
|
||||||
if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 ||
|
if (pix_fmt == PIX_FMT_YUV422 ||
|
||||||
pix_fmt == PIX_FMT_RGB555)
|
pix_fmt == PIX_FMT_UYVY422 ||
|
||||||
w = width * 2;
|
pix_fmt == PIX_FMT_RGB565 ||
|
||||||
|
pix_fmt == PIX_FMT_RGB555)
|
||||||
|
w = width * 2;
|
||||||
else if (pix_fmt == PIX_FMT_PAL8)
|
else if (pix_fmt == PIX_FMT_PAL8)
|
||||||
w = width;
|
w = width;
|
||||||
else
|
else
|
||||||
@@ -439,6 +455,7 @@ static int avg_bits_per_pixel(int pix_fmt)
|
|||||||
case FF_PIXEL_PACKED:
|
case FF_PIXEL_PACKED:
|
||||||
switch(pix_fmt) {
|
switch(pix_fmt) {
|
||||||
case PIX_FMT_YUV422:
|
case PIX_FMT_YUV422:
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
case PIX_FMT_RGB565:
|
case PIX_FMT_RGB565:
|
||||||
case PIX_FMT_RGB555:
|
case PIX_FMT_RGB555:
|
||||||
bits = 16;
|
bits = 16;
|
||||||
@@ -551,6 +568,7 @@ void img_copy(AVPicture *dst, const AVPicture *src,
|
|||||||
case FF_PIXEL_PACKED:
|
case FF_PIXEL_PACKED:
|
||||||
switch(pix_fmt) {
|
switch(pix_fmt) {
|
||||||
case PIX_FMT_YUV422:
|
case PIX_FMT_YUV422:
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
case PIX_FMT_RGB565:
|
case PIX_FMT_RGB565:
|
||||||
case PIX_FMT_RGB555:
|
case PIX_FMT_RGB555:
|
||||||
bits = 16;
|
bits = 16;
|
||||||
@@ -649,6 +667,98 @@ static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void uyvy422_to_yuv420p(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
const uint8_t *p, *p1;
|
||||||
|
uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
p1 = src->data[0];
|
||||||
|
|
||||||
|
lum1 = dst->data[0];
|
||||||
|
cb1 = dst->data[1];
|
||||||
|
cr1 = dst->data[2];
|
||||||
|
|
||||||
|
for(;height >= 1; height -= 2) {
|
||||||
|
p = p1;
|
||||||
|
lum = lum1;
|
||||||
|
cb = cb1;
|
||||||
|
cr = cr1;
|
||||||
|
for(w = width; w >= 2; w -= 2) {
|
||||||
|
lum[0] = p[1];
|
||||||
|
cb[0] = p[0];
|
||||||
|
lum[1] = p[3];
|
||||||
|
cr[0] = p[2];
|
||||||
|
p += 4;
|
||||||
|
lum += 2;
|
||||||
|
cb++;
|
||||||
|
cr++;
|
||||||
|
}
|
||||||
|
if (w) {
|
||||||
|
lum[0] = p[1];
|
||||||
|
cb[0] = p[0];
|
||||||
|
cr[0] = p[2];
|
||||||
|
cb++;
|
||||||
|
cr++;
|
||||||
|
}
|
||||||
|
p1 += src->linesize[0];
|
||||||
|
lum1 += dst->linesize[0];
|
||||||
|
if (height>1) {
|
||||||
|
p = p1;
|
||||||
|
lum = lum1;
|
||||||
|
for(w = width; w >= 2; w -= 2) {
|
||||||
|
lum[0] = p[1];
|
||||||
|
lum[1] = p[3];
|
||||||
|
p += 4;
|
||||||
|
lum += 2;
|
||||||
|
}
|
||||||
|
if (w) {
|
||||||
|
lum[0] = p[1];
|
||||||
|
}
|
||||||
|
p1 += src->linesize[0];
|
||||||
|
lum1 += dst->linesize[0];
|
||||||
|
}
|
||||||
|
cb1 += dst->linesize[1];
|
||||||
|
cr1 += dst->linesize[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void uyvy422_to_yuv422p(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
const uint8_t *p, *p1;
|
||||||
|
uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
p1 = src->data[0];
|
||||||
|
lum1 = dst->data[0];
|
||||||
|
cb1 = dst->data[1];
|
||||||
|
cr1 = dst->data[2];
|
||||||
|
for(;height > 0; height--) {
|
||||||
|
p = p1;
|
||||||
|
lum = lum1;
|
||||||
|
cb = cb1;
|
||||||
|
cr = cr1;
|
||||||
|
for(w = width; w >= 2; w -= 2) {
|
||||||
|
lum[0] = p[1];
|
||||||
|
cb[0] = p[0];
|
||||||
|
lum[1] = p[3];
|
||||||
|
cr[0] = p[2];
|
||||||
|
p += 4;
|
||||||
|
lum += 2;
|
||||||
|
cb++;
|
||||||
|
cr++;
|
||||||
|
}
|
||||||
|
p1 += src->linesize[0];
|
||||||
|
lum1 += dst->linesize[0];
|
||||||
|
cb1 += dst->linesize[1];
|
||||||
|
cr1 += dst->linesize[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
|
static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
@@ -715,6 +825,41 @@ static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void yuv422p_to_uyvy422(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
uint8_t *p, *p1;
|
||||||
|
const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
|
||||||
|
int w;
|
||||||
|
|
||||||
|
p1 = dst->data[0];
|
||||||
|
lum1 = src->data[0];
|
||||||
|
cb1 = src->data[1];
|
||||||
|
cr1 = src->data[2];
|
||||||
|
for(;height > 0; height--) {
|
||||||
|
p = p1;
|
||||||
|
lum = lum1;
|
||||||
|
cb = cb1;
|
||||||
|
cr = cr1;
|
||||||
|
for(w = width; w >= 2; w -= 2) {
|
||||||
|
p[1] = lum[0];
|
||||||
|
p[0] = cb[0];
|
||||||
|
p[3] = lum[1];
|
||||||
|
p[2] = cr[0];
|
||||||
|
p += 4;
|
||||||
|
lum += 2;
|
||||||
|
cb++;
|
||||||
|
cr++;
|
||||||
|
}
|
||||||
|
p1 += dst->linesize[0];
|
||||||
|
lum1 += src->linesize[0];
|
||||||
|
cb1 += src->linesize[1];
|
||||||
|
cr1 += src->linesize[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SCALEBITS 10
|
#define SCALEBITS 10
|
||||||
#define ONE_HALF (1 << (SCALEBITS - 1))
|
#define ONE_HALF (1 << (SCALEBITS - 1))
|
||||||
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
|
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
|
||||||
@@ -1444,6 +1589,9 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
|
|||||||
[PIX_FMT_YUV422] = {
|
[PIX_FMT_YUV422] = {
|
||||||
.convert = yuv422p_to_yuv422,
|
.convert = yuv422p_to_yuv422,
|
||||||
},
|
},
|
||||||
|
[PIX_FMT_UYVY422] = {
|
||||||
|
.convert = yuv422p_to_uyvy422,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PIX_FMT_YUV444P] = {
|
[PIX_FMT_YUV444P] = {
|
||||||
[PIX_FMT_RGB24] = {
|
[PIX_FMT_RGB24] = {
|
||||||
@@ -1480,7 +1628,14 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
|
|||||||
.convert = yuv422_to_yuv422p,
|
.convert = yuv422_to_yuv422p,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
[PIX_FMT_UYVY422] = {
|
||||||
|
[PIX_FMT_YUV420P] = {
|
||||||
|
.convert = uyvy422_to_yuv420p,
|
||||||
|
},
|
||||||
|
[PIX_FMT_YUV422P] = {
|
||||||
|
.convert = uyvy422_to_yuv422p,
|
||||||
|
},
|
||||||
|
},
|
||||||
[PIX_FMT_RGB24] = {
|
[PIX_FMT_RGB24] = {
|
||||||
[PIX_FMT_YUV420P] = {
|
[PIX_FMT_YUV420P] = {
|
||||||
.convert = rgb24_to_yuv420p
|
.convert = rgb24_to_yuv420p
|
||||||
@@ -1683,7 +1838,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
|
|||||||
|
|
||||||
ce = &convert_table[src_pix_fmt][dst_pix_fmt];
|
ce = &convert_table[src_pix_fmt][dst_pix_fmt];
|
||||||
if (ce->convert) {
|
if (ce->convert) {
|
||||||
/* specific convertion routine */
|
/* specific conversion routine */
|
||||||
ce->convert(dst, src, dst_width, dst_height);
|
ce->convert(dst, src, dst_width, dst_height);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1838,6 +1993,10 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
|
|||||||
dst_pix_fmt == PIX_FMT_YUV422) {
|
dst_pix_fmt == PIX_FMT_YUV422) {
|
||||||
/* specific case: convert to YUV422P first */
|
/* specific case: convert to YUV422P first */
|
||||||
int_pix_fmt = PIX_FMT_YUV422P;
|
int_pix_fmt = PIX_FMT_YUV422P;
|
||||||
|
} else if (src_pix_fmt == PIX_FMT_UYVY422 ||
|
||||||
|
dst_pix_fmt == PIX_FMT_UYVY422) {
|
||||||
|
/* specific case: convert to YUV422P first */
|
||||||
|
int_pix_fmt = PIX_FMT_YUV422P;
|
||||||
} else if ((src_pix->color_type == FF_COLOR_GRAY &&
|
} else if ((src_pix->color_type == FF_COLOR_GRAY &&
|
||||||
src_pix_fmt != PIX_FMT_GRAY8) ||
|
src_pix_fmt != PIX_FMT_GRAY8) ||
|
||||||
(dst_pix->color_type == FF_COLOR_GRAY &&
|
(dst_pix->color_type == FF_COLOR_GRAY &&
|
||||||
|
@@ -141,6 +141,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
|
|||||||
switch(s->pix_fmt){
|
switch(s->pix_fmt){
|
||||||
case PIX_FMT_YUV420P:
|
case PIX_FMT_YUV420P:
|
||||||
case PIX_FMT_YUV422:
|
case PIX_FMT_YUV422:
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
case PIX_FMT_YUV422P:
|
case PIX_FMT_YUV422P:
|
||||||
case PIX_FMT_YUV444P:
|
case PIX_FMT_YUV444P:
|
||||||
case PIX_FMT_GRAY8:
|
case PIX_FMT_GRAY8:
|
||||||
@@ -218,6 +219,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
|
|||||||
case PIX_FMT_RGB555:
|
case PIX_FMT_RGB555:
|
||||||
case PIX_FMT_RGB565:
|
case PIX_FMT_RGB565:
|
||||||
case PIX_FMT_YUV422:
|
case PIX_FMT_YUV422:
|
||||||
|
case PIX_FMT_UYVY422:
|
||||||
pixel_size=2;
|
pixel_size=2;
|
||||||
break;
|
break;
|
||||||
case PIX_FMT_RGB24:
|
case PIX_FMT_RGB24:
|
||||||
|
Reference in New Issue
Block a user