/***************************************************************************** * Render: displays previously rendered output ***************************************************************************** * This function send the currently rendered image to adjust modified image, * waits until it is displayed and switch the two rendering buffers, preparing * next frame. *****************************************************************************/ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) { picture_t *p_outpic; filter_sys_t *p_sys = p_filter->p_sys; vlc_mutex_lock( &p_sys->lock ); int i_simthres = p_sys->i_simthres; int i_satthres = p_sys->i_satthres; int i_color = p_sys->i_color; vlc_mutex_unlock( &p_sys->lock ); if( !p_pic ) return NULL; p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { picture_Release( p_pic ); return NULL; } /* Copy the Y plane */ plane_CopyPixels( &p_outpic->p[Y_PLANE], &p_pic->p[Y_PLANE] ); /* * Do the U and V planes */ int refu, refv, reflength; GetReference( &refu, &refv, &reflength, i_color ); for( int y = 0; y < p_pic->p[U_PLANE].i_visible_lines; y++ ) { uint8_t *p_src_u = &p_pic->p[U_PLANE].p_pixels[y * p_pic->p[U_PLANE].i_pitch]; uint8_t *p_src_v = &p_pic->p[V_PLANE].p_pixels[y * p_pic->p[V_PLANE].i_pitch]; uint8_t *p_dst_u = &p_outpic->p[U_PLANE].p_pixels[y * p_outpic->p[U_PLANE].i_pitch]; uint8_t *p_dst_v = &p_outpic->p[V_PLANE].p_pixels[y * p_outpic->p[V_PLANE].i_pitch]; for( int x = 0; x < p_pic->p[U_PLANE].i_visible_pitch; x++ ) { if( IsSimilar( *p_src_u - 0x80, *p_src_v - 0x80, refu, refv, reflength, i_satthres, i_simthres ) ) { *p_dst_u++ = *p_src_u; *p_dst_v++ = *p_src_v; } else { *p_dst_u++ = 0x80; *p_dst_v++ = 0x80; } p_src_u++; p_src_v++; } } return CopyInfoAndRelease( p_outpic, p_pic ); }
void Comparer::Compare(Tree *tree1, Tree *tree2) { std::multiset<Node *, NCompare> SNodes1, SNodes2; std::multiset<Node *, NCompare>::iterator SNIter1, SNIter2; std::vector<Node *> child; element e1, e2; bool delpair=false; std::pair<std::multiset<Node *, NCompare>::iterator, std::multiset<Node *, NCompare>::iterator> p; SortTree(tree1->getTRoot(), SNodes1); SortTree(tree2->getTRoot(), SNodes2); SNodes1.erase(tree1->getTRoot()); SNodes2.erase(tree2->getTRoot()); for (SNIter1 = SNodes1.begin(); SNIter1 != SNodes1.end(); SNIter1++) { p = SNodes2.equal_range(*SNIter1); //for (SNIter2 = SNodes2.begin(); SNIter2 != SNodes2.end(); SNIter2++) for (SNIter2 = p.first; SNIter2 != p.second; SNIter2++) { if (IsSimilar(*SNIter1, *SNIter2)) { delpair = true; similarnodes.push_back(std::make_pair(*SNIter1, *SNIter2)); } else continue; } //similarnodes.push_back(std::make_pair(*SNIter1, *SNIter2)); //delete children pairs child = (*SNIter1)->getChildren(); if (delpair) { for (auto first : child) DeletePair(first); delpair = false; } } }
BaseMesh* FixedPlaneMesh::ToBaseMesh() { std::vector<Point3D> pts; ListOfvertices results; BaseMesh* pMesh = new BaseMesh; pMesh->SetTransformedAABB(AABB()); //auto center = AABB().Center(); //auto scale = AABB().Diagonal(); for (int i = 0 ; i < mPolygons.size(); i++) { for (int j = 0 ; j < mPolygons[i].bplanes.size(); j++) { int prevPtIdx = j == 0? mPolygons[i].bplanes.size() -1 : j -1; Point3D pt = InexactComputePoint(mPolygons[i].splane, mPolygons[i].bplanes[prevPtIdx], mPolygons[i].bplanes[j] ); //pt = denormalize(pt, center, scale); if (!pts.size() || !IsSimilar(pt, pts.back())) pts.push_back(pt); } auto normal = normalize(mPolygons[i].splane.Normal()); TrianglatePolygon(normal, pts, results); //catch (...){ // wchar_t ch[64]; // swprintf(ch, 64, L"Error, %u", i); // OutputDebugString(ch); // results.clear(); //} for (int k = 0 ; k < results.size(); k+=3) { pMesh->Add(results[k], results[k+1], results[k+2], normal); } pts.clear(); results.clear(); } pMesh->GenID(); return pMesh; }
static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) { picture_t *p_outpic; filter_sys_t *p_sys = p_filter->p_sys; int i_simthres = atomic_load( &p_sys->i_simthres ); int i_satthres = atomic_load( &p_sys->i_satthres ); int i_color = atomic_load( &p_sys->i_color ); if( !p_pic ) return NULL; p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { picture_Release( p_pic ); return NULL; } int i_y_offset, i_u_offset, i_v_offset; int i_ret = GetPackedYuvOffsets( p_filter->fmt_in.video.i_chroma, &i_y_offset, &i_u_offset, &i_v_offset ); if( i_ret == VLC_EGENERIC ) { picture_Release( p_pic ); return NULL; } /* * Copy Y and do the U and V planes */ int refu, refv, reflength; GetReference( &refu, &refv, &reflength, i_color ); for( int y = 0; y < p_pic->p->i_visible_lines; y++ ) { uint8_t *p_src = &p_pic->p->p_pixels[y * p_pic->p->i_pitch]; uint8_t *p_dst = &p_outpic->p->p_pixels[y * p_outpic->p->i_pitch]; for( int x = 0; x < p_pic->p->i_visible_pitch / 4; x++ ) { p_dst[i_y_offset + 0] = p_src[i_y_offset + 0]; p_dst[i_y_offset + 2] = p_src[i_y_offset + 2]; if( IsSimilar( p_src[i_u_offset] - 0x80, p_src[i_v_offset] - 0x80, refu, refv, reflength, i_satthres, i_simthres ) ) { p_dst[i_u_offset] = p_src[i_u_offset]; p_dst[i_v_offset] = p_src[i_v_offset]; } else { p_dst[i_u_offset] = 0x80; p_dst[i_v_offset] = 0x80; } p_dst += 4; p_src += 4; } } return CopyInfoAndRelease( p_outpic, p_pic ); }