static void gst_deinterlace_simple_method_interpolate_scanline_planar_v (GstDeinterlaceSimpleMethod * self, guint8 * out, const GstDeinterlaceScanlineData * scanlines) { oil_memcpy (out, scanlines->m1, self->parent.row_stride[2]); }
static void gst_deinterlace_simple_method_copy_scanline (GstDeinterlaceMethod * self, GstDeinterlace2 * parent, guint8 * out, GstDeinterlaceScanlineData * scanlines, gint width) { oil_memcpy (out, scanlines->m0, parent->line_length); }
static void deinterlace_scanline_weave (GstDeinterlaceMethod * self, GstDeinterlace2 * parent, guint8 * out, GstDeinterlaceScanlineData * scanlines, gint width) { oil_memcpy (out, scanlines->m1, parent->line_length); }
static void deinterlace_scanline_scaler_bob (GstDeinterlaceMethod * self, GstDeinterlace * parent, guint8 * out, GstDeinterlaceScanlineData * scanlines, gint width) { oil_memcpy (out, scanlines->t0, parent->row_stride); }
static int Fieldcopy (void *dest, const void *src, size_t count, int rows, int dst_pitch, int src_pitch) { unsigned char *pDest = (unsigned char *) dest; unsigned char *pSrc = (unsigned char *) src; int i; for (i = 0; i < rows; i++) { oil_memcpy (pDest, pSrc, count); pSrc += src_pitch; pDest += dst_pitch; } return 0; }
static void deinterlace_scanline_scaler_bob_planar_v (GstDeinterlaceSimpleMethod * self, guint8 * out, const GstDeinterlaceScanlineData * scanlines) { oil_memcpy (out, scanlines->t0, self->parent.row_stride[2]); }
static void gst_deinterlace_simple_method_deinterlace_frame_planar_plane (GstDeinterlaceSimpleMethod * self, guint8 * out, const guint8 * field0, const guint8 * field1, const guint8 * field2, const guint8 * field3, guint cur_field_flags, gint plane, GstDeinterlaceSimpleMethodFunction copy_scanline, GstDeinterlaceSimpleMethodFunction interpolate_scanline) { GstDeinterlaceScanlineData scanlines; gint line; gint field_height = self->parent.height[plane] / 2; gint row_stride = self->parent.row_stride[plane]; gint field_stride = self->parent.row_stride[plane] * 2; g_assert (interpolate_scanline != NULL); g_assert (copy_scanline != NULL); if (cur_field_flags == PICTURE_INTERLACED_BOTTOM) { /* double the first scanline of the bottom field */ oil_memcpy (out, field0, row_stride); out += row_stride; } oil_memcpy (out, field0, row_stride); out += row_stride; for (line = 2; line <= field_height; line++) { memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* interp. scanline */ scanlines.t0 = field0; scanlines.b0 = field0 + field_stride; if (field1 != NULL) { scanlines.tt1 = field1; scanlines.m1 = field1 + field_stride; scanlines.bb1 = field1 + field_stride * 2; field1 += field_stride; } if (field2 != NULL) { scanlines.t2 = field2; scanlines.b2 = field2 + field_stride; } if (field3 != NULL) { scanlines.tt3 = field3; scanlines.m3 = field3 + field_stride; scanlines.bb3 = field3 + field_stride * 2; field3 += field_stride; } /* set valid data for corner cases */ if (line == 2) { scanlines.tt1 = scanlines.bb1; scanlines.tt3 = scanlines.bb3; } else if (line == field_height) { scanlines.bb1 = scanlines.tt1; scanlines.bb3 = scanlines.tt3; } interpolate_scanline (self, out, &scanlines); out += row_stride; memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* copy a scanline */ scanlines.tt0 = field0; scanlines.m0 = field0 + field_stride; scanlines.bb0 = field0 + field_stride * 2; field0 += field_stride; if (field1 != NULL) { scanlines.t1 = field1; scanlines.b1 = field1 + field_stride; } if (field2 != NULL) { scanlines.tt2 = field2; scanlines.m2 = field2 + field_stride; scanlines.bb2 = field2 + field_stride * 2; field2 += field_stride; } if (field3 != NULL) { scanlines.t3 = field3; scanlines.b3 = field3 + field_stride; } /* set valid data for corner cases */ if (line == field_height) { scanlines.bb0 = scanlines.tt0; scanlines.b1 = scanlines.t1; scanlines.bb2 = scanlines.tt2; scanlines.b3 = scanlines.t3; } copy_scanline (self, out, &scanlines); out += row_stride; } if (cur_field_flags == PICTURE_INTERLACED_TOP) { /* double the last scanline of the top field */ oil_memcpy (out, field0, row_stride); } }
static void gst_deinterlace_simple_method_deinterlace_frame_packed (GstDeinterlaceMethod * method, const GstDeinterlaceField * history, guint history_count, GstBuffer * outbuf) { GstDeinterlaceSimpleMethod *self = GST_DEINTERLACE_SIMPLE_METHOD (method); GstDeinterlaceMethodClass *dm_class = GST_DEINTERLACE_METHOD_GET_CLASS (self); GstDeinterlaceScanlineData scanlines; guint8 *out = GST_BUFFER_DATA (outbuf); const guint8 *field0 = NULL, *field1 = NULL, *field2 = NULL, *field3 = NULL; gint cur_field_idx = history_count - dm_class->fields_required; guint cur_field_flags = history[cur_field_idx].flags; gint line; gint field_height = self->parent.frame_height / 2; gint row_stride = self->parent.row_stride[0]; gint field_stride = self->parent.row_stride[0] * 2; g_assert (self->interpolate_scanline_packed != NULL); g_assert (self->copy_scanline_packed != NULL); field0 = GST_BUFFER_DATA (history[cur_field_idx].buf); if (history[cur_field_idx].flags & PICTURE_INTERLACED_BOTTOM) field0 += row_stride; g_assert (dm_class->fields_required <= 4); if (dm_class->fields_required >= 2) { field1 = GST_BUFFER_DATA (history[cur_field_idx + 1].buf); if (history[cur_field_idx + 1].flags & PICTURE_INTERLACED_BOTTOM) field1 += row_stride; } if (dm_class->fields_required >= 3) { field2 = GST_BUFFER_DATA (history[cur_field_idx + 2].buf); if (history[cur_field_idx + 2].flags & PICTURE_INTERLACED_BOTTOM) field2 += row_stride; } if (dm_class->fields_required >= 4) { field3 = GST_BUFFER_DATA (history[cur_field_idx + 3].buf); if (history[cur_field_idx + 3].flags & PICTURE_INTERLACED_BOTTOM) field3 += row_stride; } if (cur_field_flags == PICTURE_INTERLACED_BOTTOM) { /* double the first scanline of the bottom field */ oil_memcpy (out, field0, row_stride); out += row_stride; } oil_memcpy (out, field0, row_stride); out += row_stride; for (line = 2; line <= field_height; line++) { memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* interp. scanline */ scanlines.t0 = field0; scanlines.b0 = field0 + field_stride; if (field1 != NULL) { scanlines.tt1 = field1; scanlines.m1 = field1 + field_stride; scanlines.bb1 = field1 + field_stride * 2; field1 += field_stride; } if (field2 != NULL) { scanlines.t2 = field2; scanlines.b2 = field2 + field_stride; } if (field3 != NULL) { scanlines.tt3 = field3; scanlines.m3 = field3 + field_stride; scanlines.bb3 = field3 + field_stride * 2; field3 += field_stride; } /* set valid data for corner cases */ if (line == 2) { scanlines.tt1 = scanlines.bb1; scanlines.tt3 = scanlines.bb3; } else if (line == field_height) { scanlines.bb1 = scanlines.tt1; scanlines.bb3 = scanlines.tt3; } self->interpolate_scanline_packed (self, out, &scanlines); out += row_stride; memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* copy a scanline */ scanlines.tt0 = field0; scanlines.m0 = field0 + field_stride; scanlines.bb0 = field0 + field_stride * 2; field0 += field_stride; if (field1 != NULL) { scanlines.t1 = field1; scanlines.b1 = field1 + field_stride; } if (field2 != NULL) { scanlines.tt2 = field2; scanlines.m2 = field2 + field_stride; scanlines.bb2 = field2 + field_stride * 2; field2 += field_stride; } if (field3 != NULL) { scanlines.t3 = field3; scanlines.b3 = field3 + field_stride; } /* set valid data for corner cases */ if (line == field_height) { scanlines.bb0 = scanlines.tt0; scanlines.b1 = scanlines.t1; scanlines.bb2 = scanlines.tt2; scanlines.b3 = scanlines.t3; } self->copy_scanline_packed (self, out, &scanlines); out += row_stride; } if (cur_field_flags == PICTURE_INTERLACED_TOP) { /* double the last scanline of the top field */ oil_memcpy (out, field0, row_stride); } }
static void gst_deinterlace_simple_method_copy_scanline_packed (GstDeinterlaceSimpleMethod * self, guint8 * out, const GstDeinterlaceScanlineData * scanlines) { oil_memcpy (out, scanlines->m0, self->parent.row_stride[0]); }
static void gst_deinterlace_simple_method_deinterlace_frame (GstDeinterlaceMethod * self, GstDeinterlace2 * parent) { GstDeinterlaceSimpleMethodClass *dsm_class = GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS (self); GstDeinterlaceMethodClass *dm_class = GST_DEINTERLACE_METHOD_GET_CLASS (self); GstDeinterlaceScanlineData scanlines; guint8 *out = GST_BUFFER_DATA (parent->out_buf); guint8 *field0 = NULL, *field1 = NULL, *field2 = NULL, *field3 = NULL; gint cur_field_idx = parent->history_count - dm_class->fields_required; guint cur_field_flags = parent->field_history[cur_field_idx].flags; gint line; field0 = GST_BUFFER_DATA (parent->field_history[cur_field_idx].buf); g_assert (dm_class->fields_required <= 4); if (dm_class->fields_required >= 2) field1 = GST_BUFFER_DATA (parent->field_history[cur_field_idx + 1].buf); if (dm_class->fields_required >= 3) field2 = GST_BUFFER_DATA (parent->field_history[cur_field_idx + 2].buf); if (dm_class->fields_required >= 4) field3 = GST_BUFFER_DATA (parent->field_history[cur_field_idx + 3].buf); if (cur_field_flags == PICTURE_INTERLACED_BOTTOM) { /* double the first scanline of the bottom field */ oil_memcpy (out, field0, parent->line_length); out += parent->output_stride; } oil_memcpy (out, field0, parent->line_length); out += parent->output_stride; for (line = 2; line <= parent->field_height; line++) { memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* interp. scanline */ scanlines.t0 = field0; scanlines.b0 = field0 + parent->field_stride; if (field1 != NULL) { scanlines.tt1 = field1; scanlines.m1 = field1 + parent->field_stride; scanlines.bb1 = field1 + parent->field_stride * 2; field1 += parent->field_stride; } if (field2 != NULL) { scanlines.t2 = field2; scanlines.b2 = field2 + parent->field_stride; } if (field3 != NULL) { scanlines.tt3 = field3; scanlines.m3 = field3 + parent->field_stride; scanlines.bb3 = field3 + parent->field_stride * 2; field3 += parent->field_stride; } /* set valid data for corner cases */ if (line == 2) { scanlines.tt1 = scanlines.bb1; scanlines.tt3 = scanlines.bb3; } else if (line == parent->field_height) { scanlines.bb1 = scanlines.tt1; scanlines.bb3 = scanlines.tt3; } dsm_class->interpolate_scanline (self, parent, out, &scanlines, parent->frame_width); out += parent->output_stride; memset (&scanlines, 0, sizeof (scanlines)); scanlines.bottom_field = (cur_field_flags == PICTURE_INTERLACED_BOTTOM); /* copy a scanline */ scanlines.tt0 = field0; scanlines.m0 = field0 + parent->field_stride; scanlines.bb0 = field0 + parent->field_stride * 2; field0 += parent->field_stride; if (field1 != NULL) { scanlines.t1 = field1; scanlines.b1 = field1 + parent->field_stride; } if (field2 != NULL) { scanlines.tt2 = field2; scanlines.m2 = field2 + parent->field_stride; scanlines.bb2 = field2 + parent->field_stride * 2; field2 += parent->field_stride; } if (field3 != NULL) { scanlines.t3 = field3; scanlines.b3 = field3 + parent->field_stride; } /* set valid data for corner cases */ if (line == parent->field_height) { scanlines.bb0 = scanlines.tt0; scanlines.b1 = scanlines.t1; scanlines.bb2 = scanlines.tt2; scanlines.b3 = scanlines.t3; } dsm_class->copy_scanline (self, parent, out, &scanlines, parent->frame_width); out += parent->output_stride; } if (cur_field_flags == PICTURE_INTERLACED_TOP) { /* double the last scanline of the top field */ oil_memcpy (out, field0, parent->line_length); } }
int main(int argc, char *argv[]) { char *s=NULL, *d=NULL; uint32_t *src, *dest; int16_t res=0; OilProfile prof; double ave, std; int i,j, cnt; double cpufreq; OilFunctionClass *klass; OilFunctionImpl *impl; int the_class; std_log(LOG_FILENAME_LINE,"Test Started memcpy-speed"); oil_init (); s = malloc(512*1024+1024); d = malloc(512*1024+1024); // src = ((void *)((unsigned long)(s) | 0xFF )); //dest = ((void *)((unsigned long)(d) | 0xFF )); src = ((void *)((unsigned long)(s) )); dest = ((void *)((unsigned long)(d) )); for(the_class=0; the_class<3; the_class++) { cpufreq = 1788e6; switch(the_class) { case 0: klass = oil_class_get ("splat_u32_ns"); break; case 1: klass = oil_class_get ("copy_u8"); break; case 2: klass = oil_class_get ("sum_s16"); break; } for(impl=klass->first_impl;impl;impl=impl->next) { std_log(LOG_FILENAME_LINE,"impl %s\n", impl->name); if (!oil_impl_is_usable(impl)) { std_log(LOG_FILENAME_LINE," not usable\n"); continue; } oil_class_choose_by_name (klass, impl->name); for(i=10;i<20;i++){ oil_profile_init (&prof); for(j=0;j<10;j++){ switch(the_class) { case 0: oil_profile_start(&prof); oil_splat_u32_ns (dest, src, 1<<(i-2)); oil_profile_stop(&prof); for(cnt=0; cnt<(1<<(i-2)); cnt++){ if(dest[cnt]!=*src){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); assert_failed =1; } } break; case 1: oil_profile_start(&prof); oil_memcpy (dest, src, 1<<i); oil_profile_stop(&prof); for(cnt=0; cnt<(1<<(i-2)); cnt++){ //cnt is checked with 1<<(i-2) because dest & src are of type uint32_t* if(dest[cnt]!=src[cnt]){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); assert_failed =1; } } break; case 2: { int16_t* src1 = (int16_t*)src; int16_t* dest1 = (int16_t*)dest; oil_profile_start(&prof); oil_sum_s16 (dest1, src1, 1<<(i-1)); oil_profile_stop(&prof); res=0; for(cnt=0; cnt<(1<<(i-1)); cnt++){ res += src1[cnt]; } if(*dest1 != res){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, impl->name=%s\n", the_class, impl->name); assert_failed =1; } } break; } } oil_profile_get_ave_std (&prof, &ave, &std); std_log(LOG_FILENAME_LINE,"%d: %10.4g %10.4g %10.4g\n", i, ave, std, ave/(1<<i)); } } } free(s); free(d); if(!assert_failed) std_log(LOG_FILENAME_LINE, "Test Passed"); else std_log(LOG_FILENAME_LINE, "Test Failed"); create_xml(0); return 0; }