예제 #1
0
/* ----------------------------------------------------------------------------
   function:            pathforall_()      author:              Andrew Cave
   creation date:       22-Oct-1987        last modification:   ##-###-####
   arguments:           none .
   description:

   See PostScript reference manual page 192.

---------------------------------------------------------------------------- */
Bool pathforall_(ps_context_t *pscontext)
{
  int32 pushed = 0 ;
  PATHINFO newpath = {0} ;
  PATHFORALL *newone ;
  PATHINFO *lpath = &(thePathInfo(*gstateptr)) ;
  Bool result = FALSE ;
  OBJECT opfa = OBJECT_NOTVM_NULL ;

  UNUSED_PARAM(ps_context_t *, pscontext) ;

  if ( ( thePathInfo(*gstateptr)).protection)
    return error_handler( INVALIDACCESS ) ;

  if ( theStackSize( operandstack ) < 3 )
    return error_handler( STACKUNDERFLOW ) ;

  if ( lpath->lastline == NULL ) {
    npop( 4 , & operandstack ) ;
    return TRUE ;
  }

  for ( pushed = 0 ; pushed < 4 ; ++pushed ) {
    if ( ! push( stackindex( pushed , & operandstack ) , & executionstack )) {
      npop(pushed, &executionstack) ;
      return FALSE ;
    }
  }

  if ( NULL == ( newone = get_forallpath())) {
    npop(pushed, &executionstack) ;
    return error_handler( VMERROR ) ;
  }

  SET_SINV_SMATRIX( & thegsPageCTM(*gstateptr) , NEWCTM_ALLCOMPONENTS ) ;
  if ( SINV_NOTSET( NEWCTM_ALLCOMPONENTS )) {
    free_forallpath( newone ) ;
    npop(pushed, &executionstack) ;
    return error_handler( UNDEFINEDRESULT ) ;
  }
  MATRIX_COPY(&thePathCTM(*newone), &sinv) ;

  execStackSizeNotChanged = FALSE ;
  theLen(opfa) = ISPATHFORALL ;
  oCPointer(opfa) = newone ;

  if ( push(&opfa, &executionstack) && ++pushed > 0 &&
       path_copy_list(lpath->firstpath, &newpath.firstpath,
                      &newpath.lastpath, &newpath.lastline, mm_pool_temp) &&
       path_close(MYCLOSE, &newpath) ) {

    thePathOf(*newone) = newpath.firstpath ;
    npop(4, &operandstack) ;
    result = TRUE ;

  } else {

    free_forallpath(newone) ;
    npop(pushed, &executionstack) ;
  }

  return result ;
}
예제 #2
0
void raptor_decoder::base_process_decode(byte **erc,int *_ESIs, int rev_n, int *lost_ESIs, int *lostcount)
{//input should be blocks array erc and the index of erc ESIs, which marks all the position of sub-block of whole block, 
	//if decoding process fail, then we just give the blocks that still could be used, otherwise, we could recover all the packets
/*
input: 
	byte array: erc, encoding packets
	int array: _ESIs, ESIs marks of encoding packets
	int : rev_n, the size of _ESIs and erc 
*/	
	*lostcount=0;
	if(rev_n < N)
	{
		error = 5;
		rev_block = (byte**)erc;
		clear_fail_decode();
		ESIs = (int*)_ESIs;
		byte *flag_source_empty = new byte[K];
		memset((byte*)(flag_source_empty),0,K*sizeof(byte));
		for(int i=0;i<rev_n;++i)
		{
			if(ESIs[i]<K)
			{
				memcpy((byte*)(source_block[ESIs[i]]),(byte*)(rev_block[i]),SYMBOL_SIZE*sizeof(byte));
				add_fail_decode();
				flag_source_empty[ESIs[i]]=1;
			}
		}
		for(int i=0;i<K;++i)
		{
			if(!(flag_source_empty[i]))
			{
				lost_ESIs[*lostcount]=i;++(*lostcount);
				memset((byte*)(source_block[i]),0,SYMBOL_SIZE*sizeof(byte));
			}
		}
		SAFE_DELETE_ARR(flag_source_empty);
	}
	else
	{//attention: size of ESIs should no more than N
		rev_block = (byte**)erc;
		MATRIX_COPY(backup_block,rev_block,N,SYMBOL_SIZE,byte);
		clear_fail_decode();
		ESIs = (int*)_ESIs;
		(this->*pDecoderCalculate)(K, Lp, (long long **)B, (byte **)rev_block, N, M, L, SYMBOL_SIZE, (int**)U, (int*)ESIs, 0, (byte**)source_block);
		//dealing with the possibly that the decode is fail
		if(get_err_bit())
		{
			byte *flag_source_empty = new byte[K];
			memset((byte*)(flag_source_empty),0,K*sizeof(byte));
			for(int i=0;i<N;++i)
			{
				if(ESIs[i]<K)
				{
					memcpy((byte*)(source_block[ESIs[i]]),(byte*)(backup_block[i]),SYMBOL_SIZE*sizeof(byte));
					add_fail_decode();
					flag_source_empty[ESIs[i]]=1;
				}
			}
			for(int i=0;i<K;++i)
			{
				if(!(flag_source_empty[i]))
				{
					lost_ESIs[*lostcount]=i;++(*lostcount);
//					memset((byte*)(source_block[i]),0,SYMBOL_SIZE*sizeof(byte));
				}
			}
			SAFE_DELETE_ARR(flag_source_empty);
		}
	}
	return ;
}