예제 #1
0
void TreeItemData::Find(wxTreeCtrl* pTree, wxTreeItemId tree_id, wxListCtrl* pList, long list_id, const Omega::string_t& strFind, bool bKeys, bool bValues, bool bData, bool bMatchAll, bool bIgnoreCase)
{
	// Manually check the current list contents
	if (bValues || bData)
	{
		while ((list_id = pList->GetNextItem(list_id))!=-1)
		{
			Omega::string_t strName(pList->GetItemText(list_id).wc_str(),Omega::string_t::npos,true);

			if (MatchValue(strFind,m_ptrKey,strName,bValues,bData,bMatchAll,bIgnoreCase))
			{
				long item;
				while ((item=pList->GetNextItem(-1,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED)) != -1)
				{
					pList->SetItemState(item,0,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED );
				}

				pList->SetItemState(list_id,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
				pList->SetFocus();
				return;
			}
		}
	}

	Find2(pTree,tree_id,pList,strFind,bKeys,bValues,bData,bMatchAll,bIgnoreCase);
}
예제 #2
0
Omega::string_t TreeItemData::Find3(OTL::ObjectPtr<Omega::Registry::IKey>& ptrKey, const Omega::string_t& strFind, bool bKeys, bool bValues, bool bData, bool bMatchAll, bool bIgnoreCase, bool& bKey)
{
	// Check the current sub-keys
	std::set<Omega::string_t> keys = ptrKey->EnumSubKeys();
	for (std::set<Omega::string_t>::const_iterator i=keys.begin();i!=keys.end();++i)
	{
		// Check key name
		if (bKeys)
		{
			if (bMatchAll)
			{
				if (i->Compare(strFind,0,Omega::string_t::npos,bIgnoreCase) == 0)
				{
					// Found it!
					bKey = true;
					return *i;
				}
			}
			else if (i->Find(strFind,0,bIgnoreCase) != Omega::string_t::npos)
			{
				// Found it!
				bKey = true;
				return *i;
			}
		}

		// Check key values
		OTL::ObjectPtr<Omega::Registry::IKey> ptrSubKey = ptrKey->OpenSubKey(*i);
		std::set<Omega::string_t> values = ptrSubKey->EnumValues();
		for (std::set<Omega::string_t>::const_iterator j=values.begin();j!=values.end();++j)
		{
			if (MatchValue(strFind,ptrSubKey,*j,bValues,bData,bMatchAll,bIgnoreCase))
			{
				// Found it!
				bKey = false;
				return *i + L"/" + *j;
			}
		}

		// Recurse down...
		Omega::string_t strNext = Find3(ptrSubKey,strFind,bKeys,bValues,bData,bMatchAll,bIgnoreCase,bKey);
		if (!strNext.IsEmpty())
		{
			return *i + L"/" + strNext;
		}
	}

	return Omega::string_t();
}
예제 #3
0
bool FeedFilter::Term::Match(FeedItemInfo* pFeedItemInfo)
{
	const char* szStrValue = NULL;
	long long iIntValue = 0;

	if (!GetFieldData(m_szField, pFeedItemInfo, &szStrValue, &iIntValue))
	{
		return false;
	}

	bool bMatch = MatchValue(szStrValue, iIntValue);

	if (m_bPositive != bMatch)
	{
		return false;
	}

	return true;
}
bool ParseAVCHeader(CGolombBuffer gb, avc_hdr& h, bool fullscan)
{
    static BYTE profiles[] = {44, 66, 77, 88, 100, 110, 118, 122, 128, 144, 244};
    static BYTE levels[] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52};

    memset((void*)&h, 0, sizeof(h));

    h.profile = (BYTE)gb.BitRead(8);
    if (!MatchValue(profiles, _countof(profiles), h.profile)) {
        return false;
    }

    gb.BitRead(8);
    h.level = (BYTE)gb.BitRead(8);
    if (!MatchValue(levels, _countof(levels), h.level)) {
        return false;
    }

    UINT64 sps_id = gb.UExpGolombRead();	// seq_parameter_set_id
    if (sps_id >= 32) {
        return false;
    }

    UINT64 chroma_format_idc = 0;
    if (h.profile >= 100) {					// high profile
        chroma_format_idc = gb.UExpGolombRead();
        if (chroma_format_idc == 3) {		// chroma_format_idc
            gb.BitRead(1);					// residue_transform_flag
        }

        gb.UExpGolombRead();				// bit_depth_luma_minus8
        gb.UExpGolombRead();				// bit_depth_chroma_minus8

        gb.BitRead(1);						// qpprime_y_zero_transform_bypass_flag

        if (gb.BitRead(1)) {				// seq_scaling_matrix_present_flag
            for (int i = 0; i < 8; i++) {
                if (gb.BitRead(1)) {		// seq_scaling_list_present_flag
                    for (int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
                        next = (next + gb.SExpGolombRead() + 256) & 255;
                    }
                }
            }
        }
    }

    gb.UExpGolombRead();					// log2_max_frame_num_minus4

    UINT64 pic_order_cnt_type = gb.UExpGolombRead();

    if (pic_order_cnt_type == 0) {
        gb.UExpGolombRead();				// log2_max_pic_order_cnt_lsb_minus4
    } else if (pic_order_cnt_type == 1) {
        gb.BitRead(1);						// delta_pic_order_always_zero_flag
        gb.SExpGolombRead();				// offset_for_non_ref_pic
        gb.SExpGolombRead();				// offset_for_top_to_bottom_field
        UINT64 num_ref_frames_in_pic_order_cnt_cycle = gb.UExpGolombRead();
        if (num_ref_frames_in_pic_order_cnt_cycle >= 256) {
            return false;
        }
        for (int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
            gb.SExpGolombRead();			// offset_for_ref_frame[i]
        }
    } else if (pic_order_cnt_type != 2) {
        return false;
    }

    UINT64 ref_frame_count = gb.UExpGolombRead();	// num_ref_frames
    if (ref_frame_count > 30) {
        return false;
    }
    gb.BitRead(1);									// gaps_in_frame_num_value_allowed_flag

    UINT64 pic_width_in_mbs_minus1 = gb.UExpGolombRead();
    UINT64 pic_height_in_map_units_minus1 = gb.UExpGolombRead();
    h.interlaced = !(BYTE)gb.BitRead(1);

    if (h.interlaced) {
        gb.BitRead(1);								// mb_adaptive_frame_field_flag
    }

    BYTE direct_8x8_inference_flag = (BYTE)gb.BitRead(1); // direct_8x8_inference_flag
    if (h.interlaced && !direct_8x8_inference_flag) {
        return false;
    }

    if (gb.BitRead(1)) {									// frame_cropping_flag
        h.crop_left   = (unsigned int)gb.UExpGolombRead();	// frame_cropping_rect_left_offset
        h.crop_right  = (unsigned int)gb.UExpGolombRead();	// frame_cropping_rect_right_offset
        h.crop_top    = (unsigned int)gb.UExpGolombRead();	// frame_cropping_rect_top_offset
        h.crop_bottom = (unsigned int)gb.UExpGolombRead();	// frame_cropping_rect_bottom_offset
    }

    if (gb.BitRead(1)) {							// vui_parameters_present_flag
        if (gb.BitRead(1)) {						// aspect_ratio_info_present_flag
            BYTE aspect_ratio_idc = (BYTE)gb.BitRead(8); // aspect_ratio_idc
            if (255 == aspect_ratio_idc) {
                h.sar.num = (WORD)gb.BitRead(16);	// sar_width
                h.sar.den = (WORD)gb.BitRead(16);	// sar_height
            } else if (aspect_ratio_idc < 17) {
                h.sar.num = pixel_aspect[aspect_ratio_idc][0];
                h.sar.den = pixel_aspect[aspect_ratio_idc][1];
            } else {
                return false;
            }
        } else {
            h.sar.num = 1;
            h.sar.den = 1;
        }

        if (gb.BitRead(1)) {				// overscan_info_present_flag
            gb.BitRead(1);					// overscan_appropriate_flag
        }

        if (gb.BitRead(1)) {				// video_signal_type_present_flag
            gb.BitRead(3);					// video_format
            gb.BitRead(1);					// video_full_range_flag
            if (gb.BitRead(1)) {			// colour_description_present_flag
                gb.BitRead(8);				// colour_primaries
                gb.BitRead(8);				// transfer_characteristics
                gb.BitRead(8);				// matrix_coefficients
            }
        }
        if (gb.BitRead(1)) {				// chroma_location_info_present_flag
            gb.UExpGolombRead();			// chroma_sample_loc_type_top_field
            gb.UExpGolombRead();			// chroma_sample_loc_type_bottom_field
        }
        if (gb.BitRead(1)) {				// timing_info_present_flag
            __int64 num_units_in_tick	= gb.BitRead(32);
            __int64 time_scale			= gb.BitRead(32);
            /*long fixed_frame_rate_flag	= */gb.BitRead(1);

            // Trick for weird parameters
            if ((num_units_in_tick < 1000) || (num_units_in_tick > 1001)) {
                if ((time_scale % num_units_in_tick != 0) && ((time_scale*1001) % num_units_in_tick == 0)) {
                    time_scale			= (time_scale * 1001) / num_units_in_tick;
                    num_units_in_tick	= 1001;
                } else {
                    time_scale			= (time_scale * 1000) / num_units_in_tick;
                    num_units_in_tick	= 1000;
                }
            }
            time_scale = time_scale / 2;	// VUI consider fields even for progressive stream : divide by 2!

            if (time_scale) {
                h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
            }
        }

        if (fullscan) {
            bool nalflag = !!gb.BitRead(1);		// nal_hrd_parameters_present_flag
            if (nalflag) {
                if (HrdParameters(gb) < 0) {
                    return false;
                }
            }
            bool vlcflag = !!gb.BitRead(1);		// vlc_hrd_parameters_present_flag
            if (vlcflag) {
                if (HrdParameters(gb) < 0) {
                    return false;
                }
            }
            if (nalflag || vlcflag) {
                gb.BitRead(1);					// low_delay_hrd_flag
            }

            gb.BitRead(1);						// pic_struct_present_flag
            if (gb.BitRead(1)) {				// bitstream_restriction_flag
                gb.BitRead(1);					// motion_vectors_over_pic_boundaries_flag
                gb.UExpGolombRead();			// max_bytes_per_pic_denom
                gb.UExpGolombRead();			// max_bits_per_mb_denom
                gb.UExpGolombRead();			// log2_max_mv_length_horizontal
                gb.UExpGolombRead();			// log2_max_mv_length_vertical
                UINT64 num_reorder_frames = gb.UExpGolombRead(); // num_reorder_frames
                gb.UExpGolombRead();			// max_dec_frame_buffering

                if (gb.GetSize() < gb.GetPos()) {
                    num_reorder_frames = 0;
                }
                if (num_reorder_frames > 16U) {
                    return false;
                }
            }
        }
    }

    if (!h.sar.num) h.sar.num = 1;
    if (!h.sar.den) h.sar.den = 1;

    unsigned int mb_Width	= (unsigned int)pic_width_in_mbs_minus1 + 1;
    unsigned int mb_Height	= ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - !h.interlaced);
    BYTE CHROMA444			= (chroma_format_idc == 3);

    h.width = 16 * mb_Width - (2u>>CHROMA444) * min(h.crop_right, (8u<<CHROMA444)-1);
    if (!h.interlaced) {
        h.height = 16 * mb_Height - (2u>>CHROMA444) * min(h.crop_bottom, (8u<<CHROMA444)-1);
    } else {