cog: Add n_taps to chroma upsampling

This commit is contained in:
David Schleef 2009-10-30 15:35:36 -07:00
parent e0175a40a2
commit 5d9d693caf
6 changed files with 46 additions and 31 deletions

View File

@ -864,7 +864,7 @@ cog_frame_convert (CogFrame * dest, CogFrame * src)
} }
if ((dest_format & 3) != (frame->format & 3)) { if ((dest_format & 3) != (frame->format & 3)) {
frame = cog_virt_frame_new_subsample (frame, dest_format); frame = cog_virt_frame_new_subsample (frame, dest_format, 2);
GST_DEBUG ("subsample %p", frame); GST_DEBUG ("subsample %p", frame);
} }

View File

@ -1532,18 +1532,24 @@ convert_422_444 (CogFrame * frame, void *_dest, int component, int i)
{ {
uint8_t *dest = _dest; uint8_t *dest = _dest;
uint8_t *src; uint8_t *src;
int n_taps = frame->param1;
src = cog_virt_frame_get_line (frame->virt_frame1, component, i); src = cog_virt_frame_get_line (frame->virt_frame1, component, i);
if (component == 0) { if (component == 0) {
orc_memcpy (dest, src, frame->width); orc_memcpy (dest, src, frame->width);
} else { } else {
cogorc_upsample_horiz_cosite_1tap (dest, src, switch (n_taps) {
frame->components[component].width / 2 - 1); default:
#if 0 case 1:
cogorc_upsample_horiz_cosite (dest, src, src + 1, cogorc_upsample_horiz_cosite_1tap (dest, src,
frame->components[component].width / 2 - 1); frame->components[component].width / 2 - 1);
#endif break;
case 2:
cogorc_upsample_horiz_cosite (dest, src, src + 1,
frame->components[component].width / 2 - 1);
break;
}
dest[frame->components[component].width - 2] = dest[frame->components[component].width - 2] =
src[frame->components[component].width / 2 - 1]; src[frame->components[component].width / 2 - 1];
dest[frame->components[component].width - 1] = dest[frame->components[component].width - 1] =
@ -1556,33 +1562,38 @@ convert_420_422 (CogFrame * frame, void *_dest, int component, int i)
{ {
uint8_t *dest = _dest; uint8_t *dest = _dest;
uint8_t *src; uint8_t *src;
int n_taps = frame->param1;
if (component == 0) { if (component == 0) {
src = cog_virt_frame_get_line (frame->virt_frame1, component, i); src = cog_virt_frame_get_line (frame->virt_frame1, component, i);
orc_memcpy (dest, src, frame->components[component].width); orc_memcpy (dest, src, frame->components[component].width);
} else { } else {
#if 0 switch (n_taps) {
if ((i & 1) && i < frame->components[component].height - 1) { case 1:
uint8_t *src2; default:
src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1);
orc_memcpy (dest, src, frame->components[component].width);
break;
case 2:
if ((i & 1) && i < frame->components[component].height - 1) {
uint8_t *src2;
src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1); src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1);
src2 = cog_virt_frame_get_line (frame->virt_frame1, src2 = cog_virt_frame_get_line (frame->virt_frame1,
component, (i >> 1) + 1); component, (i >> 1) + 1);
cogorc_upsample_vert_avgub (dest, src, src2, cogorc_upsample_vert_avgub (dest, src, src2,
frame->components[component].width); frame->components[component].width);
} else { } else {
src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1); src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1);
orc_memcpy (dest, src, frame->components[component].width); orc_memcpy (dest, src, frame->components[component].width);
}
break;
} }
#else
src = cog_virt_frame_get_line (frame->virt_frame1, component, i >> 1);
orc_memcpy (dest, src, frame->components[component].width);
#endif
} }
} }
CogFrame * CogFrame *
cog_virt_frame_new_subsample (CogFrame * vf, CogFrameFormat format) cog_virt_frame_new_subsample (CogFrame * vf, CogFrameFormat format, int n_taps)
{ {
CogFrame *virt_frame; CogFrame *virt_frame;
CogFrameRenderFunc render_line; CogFrameRenderFunc render_line;
@ -1599,6 +1610,7 @@ cog_virt_frame_new_subsample (CogFrame * vf, CogFrameFormat format)
vf->width, vf->height); vf->width, vf->height);
virt_frame->virt_frame1 = vf; virt_frame->virt_frame1 = vf;
virt_frame->render_line = convert_444_422; virt_frame->render_line = convert_444_422;
virt_frame->param1 = n_taps;
vf = virt_frame; vf = virt_frame;
render_line = convert_422_420; render_line = convert_422_420;
@ -1614,6 +1626,7 @@ cog_virt_frame_new_subsample (CogFrame * vf, CogFrameFormat format)
vf->width, vf->height); vf->width, vf->height);
virt_frame->virt_frame1 = vf; virt_frame->virt_frame1 = vf;
virt_frame->render_line = convert_420_422; virt_frame->render_line = convert_420_422;
virt_frame->param1 = n_taps;
vf = virt_frame; vf = virt_frame;
render_line = convert_422_444; render_line = convert_422_444;
@ -1626,6 +1639,7 @@ cog_virt_frame_new_subsample (CogFrame * vf, CogFrameFormat format)
} }
virt_frame = cog_frame_new_virtual (NULL, format, vf->width, vf->height); virt_frame = cog_frame_new_virtual (NULL, format, vf->width, vf->height);
virt_frame->virt_frame1 = vf; virt_frame->virt_frame1 = vf;
virt_frame->param1 = n_taps;
virt_frame->render_line = render_line; virt_frame->render_line = render_line;
return virt_frame; return virt_frame;

View File

@ -29,7 +29,7 @@ CogFrame *cog_virt_frame_new_pack_v210 (CogFrame *vf);
CogFrame *cog_virt_frame_new_pack_RGB (CogFrame *vf); CogFrame *cog_virt_frame_new_pack_RGB (CogFrame *vf);
CogFrame *cog_virt_frame_new_color_matrix_YCbCr_to_RGB (CogFrame *vf, CogColorMatrix color_matrix, int coefficient_bits); CogFrame *cog_virt_frame_new_color_matrix_YCbCr_to_RGB (CogFrame *vf, CogColorMatrix color_matrix, int coefficient_bits);
CogFrame * cog_virt_frame_new_color_matrix_RGB_to_YCbCr (CogFrame * vf, CogColorMatrix color_matrix, int coefficient_bits); CogFrame * cog_virt_frame_new_color_matrix_RGB_to_YCbCr (CogFrame * vf, CogColorMatrix color_matrix, int coefficient_bits);
CogFrame *cog_virt_frame_new_subsample (CogFrame *vf, CogFrameFormat format); CogFrame *cog_virt_frame_new_subsample (CogFrame *vf, CogFrameFormat format, int n_taps);
CogFrame * cog_virt_frame_new_convert_u8 (CogFrame *vf); CogFrame * cog_virt_frame_new_convert_u8 (CogFrame *vf);
CogFrame * cog_virt_frame_new_convert_s16 (CogFrame *vf); CogFrame * cog_virt_frame_new_convert_s16 (CogFrame *vf);

View File

@ -448,7 +448,8 @@ gst_cogcolorspace_transform (GstBaseTransform * base_transform,
compress->color_matrix, 8); compress->color_matrix, 8);
} }
frame = cog_virt_frame_new_subsample (frame, new_subsample); frame = cog_virt_frame_new_subsample (frame, new_subsample,
(compress->quality >= 3) ? 2 : 1);
if (gst_video_format_is_rgb (out_format) && if (gst_video_format_is_rgb (out_format) &&
gst_video_format_is_yuv (in_format)) { gst_video_format_is_yuv (in_format)) {

View File

@ -238,18 +238,18 @@ gst_colorconvert_transform_ip (GstBaseTransform * base_transform,
li->format, li->width, li->height); li->format, li->width, li->height);
vf = cog_virt_frame_new_unpack (cog_frame_ref (frame)); vf = cog_virt_frame_new_unpack (cog_frame_ref (frame));
vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_444); vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_444, 2);
vf = cog_virt_frame_new_color_transform (vf); vf = cog_virt_frame_new_color_transform (vf);
if (frame->format == COG_FRAME_FORMAT_YUYV) { if (frame->format == COG_FRAME_FORMAT_YUYV) {
vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_422); vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_422, 2);
vf = cog_virt_frame_new_pack_YUY2 (vf); vf = cog_virt_frame_new_pack_YUY2 (vf);
} else if (frame->format == COG_FRAME_FORMAT_UYVY) { } else if (frame->format == COG_FRAME_FORMAT_UYVY) {
vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_422); vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_422, 2);
vf = cog_virt_frame_new_pack_UYVY (vf); vf = cog_virt_frame_new_pack_UYVY (vf);
} else if (frame->format == COG_FRAME_FORMAT_AYUV) { } else if (frame->format == COG_FRAME_FORMAT_AYUV) {
vf = cog_virt_frame_new_pack_AYUV (vf); vf = cog_virt_frame_new_pack_AYUV (vf);
} else if (frame->format == COG_FRAME_FORMAT_U8_420) { } else if (frame->format == COG_FRAME_FORMAT_U8_420) {
vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_420); vf = cog_virt_frame_new_subsample (vf, COG_FRAME_FORMAT_U8_420, 2);
} else { } else {
g_assert_not_reached (); g_assert_not_reached ();
} }

View File

@ -261,13 +261,13 @@ gst_logoinsert_transform_ip (GstBaseTransform * base_transform, GstBuffer * buf)
CogFrame *f; CogFrame *f;
f = cog_virt_frame_extract_alpha (cog_frame_ref (li->ayuv_frame)); f = cog_virt_frame_extract_alpha (cog_frame_ref (li->ayuv_frame));
f = cog_virt_frame_new_subsample (f, frame->format); f = cog_virt_frame_new_subsample (f, frame->format, 2);
li->alpha_frame = cog_frame_realize (f); li->alpha_frame = cog_frame_realize (f);
f = cog_virt_frame_new_unpack (cog_frame_ref (li->ayuv_frame)); f = cog_virt_frame_new_unpack (cog_frame_ref (li->ayuv_frame));
f = cog_virt_frame_new_color_matrix_RGB_to_YCbCr (f, COG_COLOR_MATRIX_SDTV, f = cog_virt_frame_new_color_matrix_RGB_to_YCbCr (f, COG_COLOR_MATRIX_SDTV,
8); 8);
f = cog_virt_frame_new_subsample (f, frame->format); f = cog_virt_frame_new_subsample (f, frame->format, 2);
li->overlay_frame = cog_frame_realize (f); li->overlay_frame = cog_frame_realize (f);
} }