Esempio n. 1
0
void
JDirInfo::SetWildcardFilter
	(
	const JCharacter*	filterStr,
	const JBoolean		negate,
	const JBoolean		caseSensitive
	)
{
	itsInvertNameRegexFlag = negate;

	JString regexStr;
	if (!BuildRegexFromWildcardFilter(filterStr, &regexStr))
		{
		ClearWildcardFilter();
		}
	else if (itsNameRegex == NULL || regexStr != itsNameRegex->GetPattern())
		{
		delete itsNameRegex;
		itsNameRegex = new JRegex(regexStr);
		assert( itsNameRegex != NULL );
		itsNameRegex->SetCaseSensitive(caseSensitive);

		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
	else if (itsNameRegex->IsCaseSensitive() != caseSensitive)
		{
		itsNameRegex->SetCaseSensitive(caseSensitive);

		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
Esempio n. 2
0
static int EncodeAlpha(VP8Encoder* const enc,
                       int quality, int method, int filter,
                       int effort_level,
                       uint8_t** const output, size_t* const output_size) {
  const WebPPicture* const pic = enc->pic_;
  const int width = pic->width;
  const int height = pic->height;

  uint8_t* quant_alpha = NULL;
  const size_t data_size = width * height;
  uint64_t sse = 0;
  int ok = 1;
  const int reduce_levels = (quality < 100);

  // quick sanity checks
  assert((uint64_t)data_size == (uint64_t)width * height);  // as per spec
  assert(enc != NULL && pic != NULL && pic->a != NULL);
  assert(output != NULL && output_size != NULL);
  assert(width > 0 && height > 0);
  assert(pic->a_stride >= width);
  assert(filter >= WEBP_FILTER_NONE && filter <= WEBP_FILTER_FAST);

  if (quality < 0 || quality > 100) {
    return 0;
  }

  if (method < ALPHA_NO_COMPRESSION || method > ALPHA_LOSSLESS_COMPRESSION) {
    return 0;
  }

  quant_alpha = (uint8_t*)malloc(data_size);
  if (quant_alpha == NULL) {
    return 0;
  }

  // Extract alpha data (width x height) from raw_data (stride x height).
  CopyPlane(pic->a, pic->a_stride, quant_alpha, width, width, height);

  if (reduce_levels) {  // No Quantization required for 'quality = 100'.
    // 16 alpha levels gives quite a low MSE w.r.t original alpha plane hence
    // mapped to moderate quality 70. Hence Quality:[0, 70] -> Levels:[2, 16]
    // and Quality:]70, 100] -> Levels:]16, 256].
    const int alpha_levels = (quality <= 70) ? (2 + quality / 5)
                                             : (16 + (quality - 70) * 8);
    ok = QuantizeLevels(quant_alpha, width, height, alpha_levels, &sse);
  }

  if (ok) {
    ok = ApplyFilters(quant_alpha, width, height, data_size, method, filter,
                      reduce_levels, effort_level, output, output_size,
                      pic->stats);
    if (pic->stats != NULL) {  // need stats?
      pic->stats->coded_size += (int)(*output_size);
      enc->sse_[3] = sse;
    }
  }

  free(quant_alpha);
  return ok;
}
Esempio n. 3
0
void CRemoteTreeView::OnOptionsChanged(changed_options_t const& options)
{
	if (options.test(OPTION_FILELIST_NAMESORT)) {
		UpdateSortMode();
		ApplyFilters(true);
	}
}
void
JDirInfo::SetWildcardFilter
	(
	JRegex*			filter,
	const JBoolean	dirInfoOwnsRegex,
	const JBoolean	negate
	)
{
	if (filter == NULL)
		{
		ClearWildcardFilter();
		return;
		}

	if (itsOwnsNameRegexFlag)
		{
		delete itsNameRegex;
		}

	itsNameRegex = filter;
	assert( itsNameRegex != NULL );

	itsOwnsNameRegexFlag   = dirInfoOwnsRegex;
	itsInvertNameRegexFlag = negate;

	ApplyFilters(kJTrue);
	Broadcast(SettingsChanged());
}
Esempio n. 5
0
void CRemoteTreeView::OnStateChange(CState* pState, enum t_statechange_notifications notification, const wxString&, const void* v)
{
	if (notification == STATECHANGE_REMOTE_DIR)
		SetDirectoryListing(pState->GetRemoteDir(), v ? *reinterpret_cast<bool const*>(v) : false);
	else if (notification == STATECHANGE_APPLYFILTER)
		ApplyFilters(false);
}
Esempio n. 6
0
void CRemoteTreeView::OnStateChange(CState* pState, enum t_statechange_notifications notification, const wxString& data, const void* data2)
{
	if (notification == STATECHANGE_REMOTE_DIR)
		SetDirectoryListing(pState->GetRemoteDir(), false);
	else if (notification == STATECHANGE_REMOTE_DIR_MODIFIED)
		SetDirectoryListing(pState->GetRemoteDir(), true);
	else if (notification == STATECHANGE_APPLYFILTER)
		ApplyFilters();
}
void
avtOriginalDataSpatialExtentsQuery::PerformQuery(QueryAttributes *qA)
{
    queryAtts = *qA;
    Init(); 

    std::string floatFormat = queryAtts.GetFloatFormat();
    std::string format ="";
    UpdateProgress(0, 0);

    avtDataObject_p dob = ApplyFilters(GetInput());

    SetTypedInput(dob);

    avtDataset_p input = GetTypedInput();
    double extents[6] = {0., 0., 0., 0., 0., 0.};
    char msg[1024];

    avtDatasetExaminer::GetSpatialExtents(input, extents);
    UnifyMinMax(extents, 6);
    int dim = input->GetInfo().GetAttributes().GetSpatialDimension();
    if (dim == 1)
    {
        format = "The original extents are (" + floatFormat + ", " 
                                              + floatFormat + ")";
        SNPRINTF(msg, 1024,format.c_str(), 
                extents[0], extents[1]);
    }
    else if (dim == 2)
    {
        format = "The original extents are (" + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ")";
        SNPRINTF(msg, 1024, format.c_str(), 
            extents[0], extents[1], extents[2], extents[3]);
    }
    else if (dim == 3)
    {
        format = "The original extents are (" + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ", " 
                                              + floatFormat + ")";
       SNPRINTF(msg, 1024, format.c_str(),
        extents[0], extents[1], extents[2], extents[3], extents[4], extents[5]);
    }
    doubleVector d;
    for (int i = 0 ; i < 2*dim ; i++)
        d.push_back(extents[i]);
    qA->SetResultsMessage(msg);
    qA->SetResultsValue(d);

    UpdateProgress(1, 0);
}
void
JDirInfo::ClearDirEntryFilter()
{
	if (itsPermFilter != NULL)
		{
		itsPermFilter = NULL;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
bool test_file( const TestFile &tf, int filters )
{
	const char *fn = tf.fn;
			
	LOG->Trace("Testing: %s", fn );
	CString error;
	SoundReader *s = SoundReader_FileReader::OpenFile( fn, error );
	s = ApplyFilters( s, filters );
	
	if( s == NULL )
	{
		LOG->Trace( "File '%s' failed to open: %s", fn, error.c_str() );
		return false;
	}
	//SoundReader *snd = s;
	SoundReader *snd = s->Copy();
	delete s;

	bool ret = RunTests( snd, tf );

	delete snd;

	/* Check SetPosition_Accurate consistency:
	 * 
	 * Reopen the file from scratch, seek to 100ms, read some data, do some
	 * operations that would result in the internal TOC being filled (seek
	 * to the end), then re-read the data at 100ms and make sure it's the same. */
	
	snd = SoundReader_FileReader::OpenFile( fn, error );
	snd = ApplyFilters( snd, filters );
	
	if( snd == NULL )
	{
		LOG->Trace( "File '%s' failed to open: %s", fn, error.c_str() );
		return false;
	}

	if( !CheckSetPositionAccurate( snd ) )
		ret = false;

	delete snd;
	return ret;
}
Esempio n. 10
0
void
JDirInfo::ClearWildcardFilter()
{
	if (itsNameRegex != NULL)
		{
		delete itsNameRegex;
		itsNameRegex = NULL;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
Esempio n. 11
0
void
JDirInfo::ResetCSFFilters()
{
	JBoolean apply = kJFalse, rebuild = kJFalse;

	if (!itsShowFilesFlag)
		{
		itsShowFilesFlag = kJTrue;
		apply            = kJTrue;
		}
	if (!itsShowDirsFlag)
		{
		itsShowDirsFlag = kJTrue;
		apply           = kJTrue;
		}
//	if (itsShowHiddenFlag)
//		{
//		itsShowHiddenFlag = kJFalse;
//		apply             = kJTrue;
//		}
	if (!itsShowVCSDirsFlag)
		{
		itsShowVCSDirsFlag = kJTrue;
		apply              = kJTrue;
		}
	if (itsShowOthersFlag)
		{
		itsShowOthersFlag = kJFalse;
		apply             = kJTrue;
		}

	if (itsPermFilter != NULL)
		{
		itsPermFilter = NULL;
		apply         = kJTrue;
		}
	if (itsContentRegex != NULL)
		{
		delete itsContentRegex;
		itsContentRegex = NULL;
		rebuild         = kJTrue;
		}

	if (rebuild)
		{
		ForceUpdate();
		Broadcast(SettingsChanged());
		}
	else if (apply)
		{
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
JError
JDirInfo::BuildInfo()
{
	if (!JDirectoryReadable(*itsCWD))
		{
		return JAccessDenied(*itsCWD);
		}

	const JString origDir = JGetCurrentDirectory();

	JError err = JChangeDirectory(*itsCWD);
	if (!err.OK())
		{
		return err;
		}

	// clear old information

	itsDirEntries->CleanOut();

	// update instance variables

	JStripTrailingDirSeparator(itsCWD);		// keep Windows happy

	ACE_stat stbuf;
	ACE_OS::stat(*itsCWD, &stbuf);
	itsIsValidFlag    = kJTrue;
	itsIsWritableFlag = JDirectoryWritable(*itsCWD);
	itsModTime        = stbuf.st_mtime;
	itsStatusTime     = stbuf.st_ctime;

	JAppendDirSeparator(itsCWD);

	// process files in the directory

	JLatentPG pg(itsContentRegex == NULL ? 100 : 10);
	if (itsPG != NULL)
		{
		pg.SetPG(itsPG, kJFalse);
		}
	pg.VariableLengthProcessBeginning("Scanning directory...", kJTrue, kJFalse);

	BuildInfo1(pg);

	pg.ProcessFinished();

	err = JChangeDirectory(origDir);
	assert_ok( err );

	ApplyFilters(kJFalse);
	return JNoError();
}
void
JDirInfo::ShouldApplyWildcardFilterToDirs
	(
	const JBoolean apply
	)
{
	if (apply != itsFilterDirsFlag)
		{
		itsFilterDirsFlag = apply;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
void
JDirInfo::SetDirEntryFilter
	(
	JCheckPermissions* f
	)
{
	if (f != itsPermFilter)
		{
		itsPermFilter = f;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
void
JDirInfo::ShowHidden
	(
	const JBoolean showHidden
	)
{
	if (showHidden != itsShowHiddenFlag)
		{
		itsShowHiddenFlag = showHidden;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
void
JDirInfo::ShowOthers
	(
	const JBoolean showOthers
	)
{
	if (showOthers != itsShowOthersFlag)
		{
		itsShowOthersFlag = showOthers;
		ApplyFilters(kJTrue);
		Broadcast(SettingsChanged());
		}
}
void
avtDatasetQuery::PerformQuery(QueryAttributes *qA)
{
    queryAtts = *qA;

    Init(); 

    UpdateProgress(0, 0);
    //
    // Allow derived types to apply any necessary filters.
    //
    avtDataObject_p dob = ApplyFilters(GetInput());

    //
    // Reset the input so that we have access to the data tree. 
    //
    SetTypedInput(dob);

    avtDataTree_p tree = GetInputDataTree();
    int validInputTree = 0;
    
    if (*tree != NULL && !tree->IsEmpty())
    {
        validInputTree = 1;
        totalNodes = tree->GetNumberOfLeaves();
    }
    else 
    {
        validInputTree |= 0;
        totalNodes = 0;
        debug4 << "Query encountered EMPTY InputDataTree after ApplyFilters.  "
               << "This may be a valid state if running parallel and there "
               << "are more processors than domains." << endl;
    }

    bool hadError = false;
    PreExecute();
    TRY
    {
        Execute(tree);
    }
    CATCH2(VisItException, e)
    {
        debug1 << "Exception occurred in " << GetType() << endl;
        debug1 << "Going to keep going to prevent a parallel hang." << endl;
        queryAtts.SetResultsMessage(e.Message());
        hadError = true;
    }
void
JDirInfo::CopySettings
	(
	const JDirInfo& source
	)
{
	const JBoolean rebuild = JNegate(
		itsContentRegex != NULL && source.itsContentRegex != NULL &&
		itsContentRegex->GetPattern() == (source.itsContentRegex)->GetPattern());

	PrivateCopySettings(source);

	if (rebuild)
		{
		ForceUpdate();
		}
	else
		{
		itsDirEntries->Sort();
		ApplyFilters(kJTrue);
		}

	Broadcast(SettingsChanged());
}
void
JDirInfo::CopyDirEntries
	(
	const JDirInfo& source
	)
{
	assert( itsDirEntries != NULL );
	itsDirEntries->CleanOut();

	const JSize entryCount = (source.itsDirEntries)->GetElementCount();
	for (JIndex i=1; i<=entryCount; i++)
		{
		JDirEntry* origEntry = (source.itsDirEntries)->NthElement(i);
		JDirEntry* entry     = new JDirEntry(*origEntry);
		assert( entry != NULL );
		itsDirEntries->Append(entry);
		}

	// update other file lists

	assert( itsVisEntries != NULL && itsAlphaEntries != NULL );

	ApplyFilters(kJFalse);
}
void FilterRoutesDialog::OnResetAll( wxCommandEvent& event )
{
    for(int i=0; i<NUM_FILTERS; i++)
        m_Filters[i] = _T("");
    ApplyFilters();
}
void FilterRoutesDialog::OnFilterText( wxCommandEvent& event )
{
    m_Filters[m_cCategory->GetSelection()] = m_tFilter->GetValue();
    ApplyFilters();
}