repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
nickmain/swipl-devel
src/os/pl-buffer.c
/* Part of SWI-Prolog Author: <NAME> E-mail: <EMAIL> WWW: http://www.swi-prolog.org Copyright (c) 2011-2020, University of Amsterdam CWI, Amsterdam All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "pl-incl.h" #include "os/pl-cstack.h" int growBuffer(Buffer b, size_t minfree) { size_t osz = b->max - b->base, sz = osz; size_t top = b->top - b->base; char *new; if ( b->top + minfree <= b->max ) return TRUE; if ( sz < 512 ) sz = 512; /* minimum reasonable size */ while( top + minfree > sz ) sz *= 2; if ( b->base == b->static_buffer ) { sz = tmp_nalloc(sz); if ( !(new = tmp_malloc(sz)) ) return FALSE; memcpy(new, b->static_buffer, osz); } else { sz = tmp_nrealloc(b->base, sz); if ( !(new = tmp_realloc(b->base, sz)) ) return FALSE; } b->base = new; b->top = b->base + top; b->max = b->base + sz; return TRUE; } /******************************* * STACK * *******************************/ void initStringStack(string_stack *stack) { memset(stack, 0, sizeof(*stack)); } void discardStringStack(string_stack *stack) { unsigned int i; for(i=stack->allocated; i>0;i--) { string_buffer *sb = &stack->buffers[MSB(i)][i]; if ( sb ) discardBuffer(&sb->buf); else break; } for(i=0; stack->buffers[i]; i++) { unsigned int nelem = 1<<i; string_buffer *ptr = stack->buffers[i]+nelem; free(ptr); } } static string_buffer * allocNewStringBuffer(string_stack *stack) { int k = MSB(stack->allocated+1); if ( !stack->buffers[k] ) { if ( k == MAX_LG_STACKED_STRINGS ) { fatalError("Too many stacked strings"); assert(0); } else { unsigned int nelem = 1<<k; string_buffer *buffers = malloc(nelem*sizeof(*buffers)); stack->buffers[k] = buffers - nelem; } } stack->top = ++stack->allocated; return &stack->buffers[k][stack->allocated]; } string_buffer * allocStringBuffer(string_stack *stack) { string_buffer *b; if ( stack->top < stack->allocated ) { unsigned int i = ++stack->top; b = &stack->buffers[MSB(i)][i]; } else { b = allocNewStringBuffer(stack); initBuffer(&b->buf); } if ( stack->top == stack->tripwire ) { Sdprintf("String stack reached tripwire at %d. C-Stack:\n", stack->tripwire); print_c_backtrace("stacked strings"); } return b; } static string_buffer * currentBuffer(string_stack *stack) { if ( stack->top ) { unsigned int i = stack->top; return &stack->buffers[MSB(i)][i]; } return NULL; } unsigned int popStringBuffer(string_stack *stack) { assert(stack->top); if ( __builtin_popcount(stack->top) == 1 && stack->top > 4 ) { unsigned int i; unsigned int k = MSB(stack->allocated); string_buffer *ptr = stack->buffers[k]+(1<<k); DEBUG(MSG_STRING_BUFFER, Sdprintf("Discarding string buffers %d..%d\n", stack->top, stack->allocated)); assert(k == MSB(stack->top)); for(i=stack->allocated; i>=stack->top; i--) { string_buffer *sb = &stack->buffers[k][i]; if ( sb ) discardBuffer(&sb->buf); else break; } free(ptr); stack->buffers[k] = NULL; stack->allocated = --stack->top; } else { unsigned int i = stack->top--; string_buffer *b = &stack->buffers[MSB(i)][i]; emptyBuffer(&b->buf, BUFFER_DISCARD_ABOVE>>i); } return stack->top; } /******************************* * STRING BUFFER * *******************************/ #define discardable_buffer (LD->fli._discardable_buffer) #define sTop (LD->fli._string_buffer) Buffer findBuffer(int flags) { GET_LD Buffer b; if ( flags & BUF_STACK ) { string_buffer *sb = allocStringBuffer(&LD->fli.string_buffers); sb->frame = environment_frame ? consTermRef(environment_frame) : 0x0; b = (Buffer)&sb->buf; DEBUG(MSG_STRING_BUFFER, Sdprintf("Added string buffer entry %p with level %zd\n", sb, (size_t)sb->frame)); LD->alerted |= ALERT_BUFFER; } else { b = &discardable_buffer; if ( !b->base ) initBuffer(b); else emptyBuffer(b, BUFFER_DISCARD_ABOVE); } return b; } char * buffer_string(const char *s, int flags) { Buffer b = findBuffer(flags); size_t l = strlen(s) + 1; addMultipleBuffer(b, s, l, char); return baseBuffer(b, char); } int unfindBuffer(Buffer b, int flags) { if ( flags & BUF_STACK ) { GET_LD StringBuffer sb = currentBuffer(&LD->fli.string_buffers); DEBUG(MSG_STRING_BUFFER, { StringBuffer sb = currentBuffer(&LD->fli.string_buffers); Sdprintf("Deleting top string buffer %p\n", sb); }); if ( b == (Buffer)&sb->buf ) popStringBuffer(&LD->fli.string_buffers); else Sdprintf("OOPS: unfindBuffer(): not top buffer\n"); return TRUE; } return FALSE; } void PL_mark_string_buffers__LD(buf_mark_t *mark ARG_LD) { *mark = LD->fli.string_buffers.top; } void PL_release_string_buffers_from_mark__LD(buf_mark_t mark ARG_LD) { while(LD->fli.string_buffers.top > mark) popStringBuffer(&LD->fli.string_buffers); } #undef PL_mark_string_buffers void PL_mark_string_buffers(buf_mark_t *mark) { GET_LD PL_mark_string_buffers__LD(mark PASS_LD); } #undef PL_release_string_buffers_from_mark void PL_release_string_buffers_from_mark(buf_mark_t mark) { GET_LD PL_release_string_buffers_from_mark__LD(mark PASS_LD); } void release_string_buffers_from_frame(LocalFrame fr ARG_LD) { word offset = consTermRef(fr); for(;;) { StringBuffer sb = currentBuffer(&LD->fli.string_buffers); if ( sb && sb->frame >= offset ) popStringBuffer(&LD->fli.string_buffers); else break; } }
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TakePictures/DFImageUnitView.h
<filename>LZEasemob3/Classes/View/Discover/Moments/TakePictures/DFImageUnitView.h // // DFImageUnitView.h // DFTimelineView // // Created by <NAME> on 15/9/27. // Copyright (c) 2015年 Datafans, Inc. All rights reserved. // #import <UIKit/UIKit.h> @interface DFImageUnitView : UIView @property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIButton *imageButton; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/Category/UIImageView+HeadImage.h
<filename>LZEasemob3/Classes/View/Common/Category/UIImageView+HeadImage.h /************************************************************ * * Hyphenate CONFIDENTIAL * __________________ * Copyright (C) 2016 Hyphenate Inc. All rights reserved. * * NOTICE: All information contained herein is, and remains * the property of Hyphenate Inc. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Hyphenate Inc. */ #import <UIKit/UIKit.h> @interface UIImageView (HeadImage) - (void)imageWithUsername:(NSString*)username placeholderImage:(UIImage*)placeholderImage; @end @interface UILabel (Prase) - (void)setTextWithUsername:(NSString *)username; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/CommentView/LZMomentsCellCommentViewCell.h
<reponame>tianqin0414/ios1 // // LZMomentsCellCommentViewCell.h // LZEasemob // // Created by nacker on 16/4/5. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsCellCommentItemModel; @interface LZMomentsCellCommentViewCell : UITableViewCell @property (nonatomic, strong) LZMomentsCellCommentItemModel *status; //@property (nonatomic, assign ) CGFloat cellHeight; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/PhotoContainer/LZPhotoContainerView.h
// // LZPhotoContainerView.h // LZEasemob // // Created by nacker on 16/3/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZPhotoContainerView : UICollectionView @property (nonatomic, strong) NSArray *urls; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/Contacts/ContactListViewController.h
/************************************************************ * * Hyphenate CONFIDENTIAL * __________________ * Copyright (C) 2016 Hyphenate Inc. All rights reserved. * * NOTICE: All information contained herein is, and remains * the property of Hyphenate Inc. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Hyphenate Inc. */ #import "GroupListViewController.h" @interface ContactListViewController : EaseUsersListViewController @property (strong, nonatomic) GroupListViewController *groupController; //好友请求变化时,更新好友请求未处理的个数 - (void)reloadApplyView; //群组变化时,更新群组页面 - (void)reloadGroupView; //好友个数变化时,重新获取数据 - (void)reloadDataSource; //添加好友的操作被触发 - (void)addFriendAction; @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Tools/LZUIHelper.h
// // LZUIHelper.h // LZEasemob // // Created by nacker on 16/4/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> #import "LZContactsGrounp.h" @interface LZUIHelper : NSObject + (NSMutableArray *)getFriensListItemsGroup; @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Category/UIImage+Extension.h
// // UIImage+Extension.h // // // Created by nacker on 15-3-9. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface UIImage (Extension) + (UIImage *)imageWithName:(NSString *)name; + (UIImage *)resizedImage:(NSString *)name; + (UIImage *)resizedImage:(NSString *)name left:(CGFloat)left top:(CGFloat)top; /* 裁剪圆形图片 */ + (UIImage *)clipImage:(UIImage *)image; - (UIImage *)imageByScalingAndCroppingForSize:(CGSize)targetSize; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/HeadView/LZMomentsHeaderView.h
// // LZMomentsHeaderView.h // LZEasemob // // Created by nacker on 16/3/11. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMomentsHeaderView : UIView @property (nonatomic, copy) void (^iconButtonClick)(); - (void)updateHeight:(CGFloat)height; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TakePictures/DFPlainGridImageView.h
// // DFPlainGridImageView.h // DFTimelineView // // Created by <NAME> on 16/2/15. // Copyright © 2016年 Datafans, Inc. All rights reserved. // #import <UIKit/UIKit.h> @protocol DFPlainGridImageViewDelegate <NSObject> @optional -(void) onClick:(NSUInteger) index; -(void) onLongPress:(NSUInteger) index; @end @interface DFPlainGridImageView : UIView @property (nonatomic, weak) id<DFPlainGridImageViewDelegate> delegate; +(CGFloat)getHeight:(NSMutableArray *)images maxWidth:(CGFloat)maxWidth; -(void)updateWithImages:(NSMutableArray *)images; @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Tools/LZTimeTool.h
// // LZTimeTool.h // testhuanxin // // Created by nacker on 15-3-9. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> @interface LZTimeTool : NSObject /** * 时间戳返回时间 */ +(NSString *)timeStr:(long long)timestamp; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/RedacketSDK/RedpacketStaticLib/RedpacketLib.h
<reponame>tianqin0414/ios1 // // RedpacketLib.h // RedpacketLib // // Created by Mr.Yang on 16/9/20. // Copyright © 2016年 Mr.Yang. All rights reserved. // #ifndef RedpacketLib_h #define RedpacketLib_h #import <Foundation/Foundation.h> #if TARGET_OS_IPHONE #import "YZHRedpacketBridge.h" #import "YZHRedpacketBridgeProtocol.h" #import "RedpacketOpenConst.h" #import "RedpacketMessageModel.h" #import "RedpacketErrorCode.h" #import "RedpacketViewControl.h" #else #import <RedpacketLib/YZHRedpacketBridge.h> #import <RedpacketLib/YZHRedpacketBridgeProtocol.h> #import <RedpacketLib/RedpacketOpenConst.h> #import <RedpacketLib/RedpacketMessageModel.h> #import <RedpacketLib/RedpacketErrorCode.h> #import <RedpacketLib/RedpacketViewControl.h> #endif #endif /* RedpacketLib_h */
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TimeLine/LZMomentsTimeLineViewController.h
// // LZMomentsTimeLineViewController.h // LZEasemob // // Created by nacker on 16/4/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMomentsTimeLineViewController : UITableViewController @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Tools/LZContactsDataHelper.h
<filename>LZEasemob3/Classes/Other/Tools/LZContactsDataHelper.h // // LZContactsDataHelper.h // LZEasemob // // Created by nacker on 16/4/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> @interface LZContactsDataHelper : NSObject /** * 格式化好友列表 */ + (NSMutableArray *) getFriendListDataBy:(NSMutableArray *)array; + (NSMutableArray *) getFriendListSectionBy:(NSMutableArray *)array; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Conversation/LZConversationViewController.h
<gh_stars>1-10 // // LZConversationViewController.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> #import "ConversationListController.h" @interface LZConversationViewController : ConversationListController @end
tianqin0414/ios1
LZEasemob3/Classes/UI/RedacketSDK/RedpacketStaticLib/RedpacketViewControl.h
<filename>LZEasemob3/Classes/UI/RedacketSDK/RedpacketStaticLib/RedpacketViewControl.h<gh_stars>1-10 // // RedpacketViewControl.h // ChatDemo-UI3.0 // // Created by Mr.Yang on 16/3/8. // Copyright © 2016年 Mr.Yang. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "RedpacketMessageModel.h" typedef NS_ENUM(NSInteger,RPSendRedPacketViewControllerType){ RPSendRedPacketViewControllerSingle, //点对点红包 RPSendRedPacketViewControllerGroup, //普通群红包 RPSendRedPacketViewControllerMember, //包含专属红包的群红包 }; @protocol RedpacketViewControlDelegate <NSObject> @optional - (NSArray<RedpacketUserInfo *> *)groupMemberList __attribute__((deprecated("请用getGroupMemberListCompletionHandle:方法替换"))); - (void)getGroupMemberListCompletionHandle:(void (^)(NSArray<RedpacketUserInfo *> * groupMemberList))completionHandle; @end // 抢红包成功回调 typedef void(^RedpacketGrabBlock)(RedpacketMessageModel *messageModel); // 环信接口发送红包消息回调 typedef void(^RedpacketSendBlock)(RedpacketMessageModel *model); /** * 发红包的控制器 */ @interface RedpacketViewControl : NSObject /** * 当前窗口的会话信息,个人或者群组 */ @property (nonatomic, strong) RedpacketUserInfo *converstationInfo; /** * 当前的聊天窗口 */ @property (nonatomic, weak) UIViewController *conversationController; /** * 定向红包返回时的代理 */ @property (nonatomic, weak) id <RedpacketViewControlDelegate> delegate; /** * 用户抢红包触发事件 * * @param messageModel 消息Model */ - (void)redpacketCellTouchedWithMessageModel:(RedpacketMessageModel *)messageModel; /** * 设置发送红包,抢红包成功回调 * * @param grabTouch 抢红包回调 * @param sendBlock 发红包回调 */ - (void)setRedpacketGrabBlock:(RedpacketGrabBlock)grabTouch andRedpacketBlock:(RedpacketSendBlock)sendBlock; #pragma mark - Controllers - (UIViewController *)redpacketViewController __attribute__((deprecated("请用presentRedPacketViewControllerWithType: memberCount:替换"))); - (UIViewController *)redPacketMoreViewControllerWithGroupMembers:(NSArray *)groupMemberArray __attribute__((deprecated("请用presentRedPacketViewControllerWithType: memberCount:替换"))); - (void)presentRedPacketMoreViewControllerWithGroupMembers:(NSArray *)groupMemberArray __attribute__((deprecated("请用presentRedPacketViewControllerWithType: memberCount:替换"))); - (void)presentRedPacketViewController __attribute__((deprecated("请用presentRedPacketViewControllerWithType: memberCount:替换"))); /** * 弹出红包控制器 * * @param rpType 红包页面类型 * @param count 群红包群人数 */ - (void)presentRedPacketViewControllerWithType:(RPSendRedPacketViewControllerType)rpType memberCount:(NSInteger)count; /** * 生成红包Controller * * @param rpType 红包页面类型 * @param count 群红包群人数 * * @return 红包Controller */ - (UIViewController *)redPacketViewControllerWithType:(RPSendRedPacketViewControllerType)rpType memberCount:(NSInteger)count; /** * 生成转账Controller * * @param userInfo 用户相关属性 * * @return 转账Controller */ - (void)presentTransferViewControllerWithReceiver:(RedpacketUserInfo *)userInfo; /** * 生成转账DetailController * * * * @return 转账Controller */ - (void)presentTransferDetailViewController:(RedpacketMessageModel *)model; /** * 零钱页面 * * @return 零钱页面,App可以放在需要的位置 */ + (UIViewController *)changeMoneyController; /** * 零钱明细页面 * * @return 零钱明细页面,App可以放在需要的位置 */ + (UIViewController *)changeMoneyListController; #pragma mark - ShowViewControllers /** * Present的方式显示零钱页面 */ - (void)presentChangeMoneyViewController; /** * 零钱接口返回零钱 * * @param amount 零钱金额 */ + (void)getChangeMoney:(void (^)(NSString *amount))amount; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/View/EMRemarkImageView.h
/************************************************************ * * Hyphenate CONFIDENTIAL * __________________ * Copyright (C) 2016 Hyphenate Inc. All rights reserved. * * NOTICE: All information contained herein is, and remains * the property of Hyphenate Inc. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Hyphenate Inc. */ #import <UIKit/UIKit.h> @interface EMRemarkImageView : UIView { UILabel *_remarkLabel; UIImageView *_imageView; NSInteger _index; BOOL _editing; } @property (nonatomic) NSInteger index; @property (nonatomic) BOOL editing; @property (strong, nonatomic) NSString *remark; @property (strong, nonatomic) UIImage *image; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/LZMomentsCell.h
<gh_stars>1-10 // // LZMomentsCell.h // LZEasemob // // Created by nacker on 16/3/11. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> #import "LZMomentsOriginalView.h" @class LZMomentsViewModel,LZMomentsCell; @protocol LZMomentsCellDelegate <NSObject> - (void)didClickLickButtonInCell:(LZMomentsCell *)cell; - (void)didClickcCommentButtonInCell:(LZMomentsCell *)cell; @end @interface LZMomentsCell : UITableViewCell @property (nonatomic, weak) id<LZMomentsCellDelegate> delegate; // 原创 @property (nonatomic, strong) LZMomentsOriginalView *originalView; @property (nonatomic, strong) LZMomentsViewModel *viewModel; @property (nonatomic, strong) NSIndexPath *indexPath; @property (nonatomic, copy) void (^operationButtonClick)(NSIndexPath *indexPath); @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/Refresh/SDTimeLineRefreshHeader.h
// // SDTimeLineRefreshHeader.h // GSD_WeiXin(wechat) // // Created by gsd on 16/3/5. // Copyright © 2016年 GSD. All rights reserved. // /* ********************************************************************************* * * GSD_WeiXin * * QQ交流群: 362419100(2群) 459274049(1群已满) * Email : <EMAIL> * GitHub: https://github.com/gsdios/GSD_WeiXin * 新浪微博:GSD_iOS * * 此“高仿微信”用到了很高效方便的自动布局库SDAutoLayout(一行代码搞定自动布局) * SDAutoLayout地址:https://github.com/gsdios/SDAutoLayout * SDAutoLayout视频教程:http://www.letv.com/ptv/vplay/24038772.html * SDAutoLayout用法示例:https://github.com/gsdios/SDAutoLayout/blob/master/README.md * ********************************************************************************* */ #import <UIKit/UIKit.h> #import "SDBaseRefreshView.h" @interface SDTimeLineRefreshHeader : SDBaseRefreshView + (instancetype)refreshHeaderWithCenter:(CGPoint)center; @property (nonatomic, copy) void(^refreshingBlock)(); @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Shake/LZFoundationMacro.h
<gh_stars>1-10 #define kVoiceRecorderTotalTime 60.0 // iPad #define kIsiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define kIs_iPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define kIs_iPhone_6 (kIs_iPhone && MDK_SCREEN_HEIGHT == 667.0) #define kIs_iPhone_6P (kIs_iPhone && MDK_SCREEN_HEIGHT == 736.0)
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/CommentView/LZMomentsCellCommentBgView.h
<filename>LZEasemob3/Classes/View/Discover/Moments/CommentView/LZMomentsCellCommentBgView.h // // LZMomentsCellCommentBgView.h // LZEasemob // // Created by nacker on 16/4/8. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsViewModel; @interface LZMomentsCellCommentBgView : UIImageView @property (nonatomic, strong) LZMomentsViewModel *viewModel; @end
tianqin0414/ios1
LZEasemob3/Classes/Model/LZApplyUserModel.h
<reponame>tianqin0414/ios1 // // LZApplyUserModel.h // LZEasemob3 // // Created by nacker on 16/7/19. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> #import "JKDBModel.h" @interface LZApplyUserModel : JKDBModel @property (nonatomic, copy) NSString *name; @property (nonatomic, assign) int apply; @end
tianqin0414/ios1
LZEasemob3/LZNotificationWorkstation.h
<gh_stars>1-10 //=============================================================== /** * ━━━━━━神兽出没━━━━━━ *    ┏┓   ┏┓ *   ┏┛┻━━━┛┻┓ *   ┃       ┃ *   ┃   ━   ┃ *   ┃ ┳┛ ┗┳ ┃ *   ┃       ┃ *   ┃   ┻   ┃ *   ┃       ┃ *   ┗━┓   ┏━┛Code is far away from bug with the animal protecting *     ┃   ┃ 神兽保佑,代码无bug *     ┃   ┃ *     ┃   ┗━━━┓ *     ┃       ┣┓ *     ┃       ┏┛ *     ┗┓┓┏━┳┓┏┛ *      ┃┫┫ ┃┫┫ *      ┗┻┛ ┗┻┛ * * ━━━━━━感觉萌萌哒━━━━━━ */ // LZNotificationWorkstation.h // HXClient // // Created by nacker on 16/1/7. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // //extern NSString *const KSwitchRootViewControllerNotification; // //extern NSString *const KGoToLoginViewControllerNotification; // //// 到修改密码去了 //extern NSString *const KGotoChangePasswordViewControllerNotification; //extern NSString *const KGotoWriteCompanyInfoViewControllerNotification; // // //#pragma mark - LZEditCollectionViewController //extern NSString *const KEditCollectionViewControllerBackNotification; // // // //#pragma mark - LZMallsGoodsView //extern NSString *const KMallsGoodsViewControllerIndividualCommercialNotification; //extern NSString *const KMallsGoodsViewControllerIndividualCommercialKey; //extern NSString *const KMallsGoodsViewControllerIndividualIndexPathKey; // //#pragma mark - LZBillingDetailsContainerView //extern NSString *const KBillingDetailsContainerViewDidSelectBtnTypeNotification; //extern NSString *const KBillingDetailsContainerViewDidSelectBtnKey; #pragma mark -Contacts extern NSString *const KRefurbishContactsViewControllerNotification; extern NSString *const PhotoPickerPhotoTakeDoneNotification; /** 点击朋友圈全文的通知 */ extern NSString * const LZMoreButtonClickedNotification; extern NSString * const LZMoreButtonClickedNotificationKey;
tianqin0414/ios1
LZEasemob3/AppDelegate.h
// // AppDelegate.h // LZEasemob3 /** * ━━━━━━神兽出没━━━━━━ *    ┏┓   ┏┓ *   ┏┛┻━━━┛┻┓ *   ┃       ┃ *   ┃   ━   ┃ *   ┃ ┳┛ ┗┳ ┃ *   ┃       ┃ *   ┃   ┻   ┃ *   ┃       ┃ *   ┗━┓   ┏━┛Code is far away from bug with the animal protecting *     ┃   ┃ 神兽保佑,代码无bug *     ┃   ┃ *     ┃   ┗━━━┓ *     ┃       ┣┓ *     ┃       ┏┛ *     ┗┓┓┏━┳┓┏┛ *      ┃┫┫ ┃┫┫ *      ┗┻┛ ┗┻┛ * * ━━━━━━感觉萌萌哒━━━━━━ */ // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> #import "LZTabBarController.h" #import "ApplyViewController.h" @interface AppDelegate : UIResponder <UIApplicationDelegate,EMChatManagerDelegate> { EMConnectionState _connectionState; } @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) LZTabBarController *mainController; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Contacts/LZContactsViewController.h
<gh_stars>1-10 // // LZContactsViewController.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> #import "ContactListViewController.h" @interface LZContactsViewController : ContactListViewController @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/BadgeView/LZBadgeView.h
// // LZBadgeView.h // HXClient // // Created by nacker on 16/6/3. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZBadgeView : UIButton @property (nonatomic, copy) NSString *badgeValue; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/ActionSheet/LZActionSheet.h
<gh_stars>1-10 // // LZActionSheet.h // HXClient // // Created by nacker on 16/2/29. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZActionSheet; typedef void(^LZActionSheetBlock)(NSInteger buttonIndex); @protocol LZActionSheetDelegate <NSObject> @optional - (void)actionSheet:(LZActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex; @end @interface LZActionSheet : UIView @property (nonatomic, copy) NSString *title; @property (nonatomic, assign) NSInteger redButtonIndex; @property (nonatomic, copy) LZActionSheetBlock clickedBlock; @property (nonatomic, strong) NSString *cancelText; @property (nonatomic, strong) UIColor *cancelTextColor; @property (nonatomic, strong) UIFont *textFont; @property (nonatomic, strong) UIColor *textColor; @property (nonatomic, assign) CGFloat animationDuration; @property (nonatomic, assign) CGFloat backgroundOpacity; #pragma mark - Delegate Way /** * 返回一个 ActionSheet 对象, 实例方法 * * @param title 提示标题 * @param buttonTitles 所有按钮的标题 * @param redButtonIndex 红色按钮的 index * @param delegate 代理 * * Tip: 如果没有红色按钮, redButtonIndex 给 `-1` 即可 */ - (instancetype)initWithTitle:(NSString *)title buttonTitles:(NSArray *)buttonTitles redButtonIndex:(NSInteger)redButtonIndex delegate:(id<LZActionSheetDelegate>)delegate; #pragma mark - Block Way /** * 返回一个 ActionSheet 对象, 实例方法 * * @param title 提示标题 * @param buttonTitles 所有按钮的标题 * @param redButtonIndex 红色按钮的 index * @param clicked 点击按钮的 block 回调 * * Tip: 如果没有红色按钮, redButtonIndex 给 `-1` 即可 */ - (instancetype)initWithTitle:(NSString *)title buttonTitles:(NSArray *)buttonTitles redButtonIndex:(NSInteger)redButtonIndex clicked:(LZActionSheetBlock)clicked; - (instancetype)initWithTitle:(NSString *)title buttonTitles:(NSArray *)buttonTitles redButtonIndex:(NSInteger)redButtonIndex cancelTextColor:(UIColor *)cancelTextColor clicked:(LZActionSheetBlock)clicked; #pragma mark - Custom Way /** * Add a button with callback block * * @param button * @param block */ - (void)addButtonTitle:(NSString *)button; #pragma mark - Show /** * 显示 ActionSheet */ - (void)show; @property (nonatomic, weak) id<LZActionSheetDelegate> delegate; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Shake/LZShakeBottomView.h
<reponame>tianqin0414/ios1 // // LZShakeBottomView.h // Easemob // // Created by nacker on 15/12/24. // Copyright © 2015年 帶頭二哥. All rights reserved. // typedef enum { LZShakePeopleButton, LZShakeMusicButton, LZShakeTvButton } LZShakeButtonType; #import <UIKit/UIKit.h> @interface LZShakeBottomView : UIView @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/View/GettingMoreFooterView.h
<filename>LZEasemob3/Classes/View/Common/View/GettingMoreFooterView.h // // GettingMoreFooterView.h // ChatDemo-UI3.0 // // Created by jiangwei on 2016/10/31. // Copyright © 2016年 jiangwei. All rights reserved. // #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, GettingMoreFooterViewState){ eGettingMoreFooterViewStateInitial, eGettingMoreFooterViewStateIdle, eGettingMoreFooterViewStateGetting, eGettingMoreFooterViewStateComplete, eGettingMoreFooterViewStateFailed }; @interface GettingMoreFooterView : UIView @property (nonatomic) GettingMoreFooterViewState state; @property (strong, nonatomic) UIActivityIndicatorView *activity; @property (strong, nonatomic) UILabel *label; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/Call/plugin/EMPluginVideoRecorder.h
<reponame>tianqin0414/ios1 // // EMPluginVideoRecorder.h // HyphenateSDK // // Created by XieYajie on 23/09/2016. // Copyright © 2016 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @class EMError; @interface EMPluginVideoRecorder : NSObject /*! * \~chinese * 获取插件实例 * * \~english * Get plugin singleton instance */ + (instancetype)sharedInstance; /*! * \~chinese * 获取视频快照,只支持JPEG格式 * * @param aPath 图片存储路径 * * \~english * Get a snapshot of current video screen as jpeg picture and save to the local file system. * * @param aPath Saved path of picture */ - (void)screenCaptureToFilePath:(NSString *)aPath error:(EMError**)pError; /*! * \~chinese * 开始录制视频 * * @param aPath 文件保存路径 * @param aError 错误 * * \~english * Start recording video * * @param aPath File saved path * @param aError Error * */ - (void)startVideoRecordingToFilePath:(NSString*)aPath error:(EMError**)aError; /*! * \~chinese * 停止录制视频 * * @param aError 错误 * * \~english * Stop recording video * * @param aError Error * */ - (NSString *)stopVideoRecording:(EMError**)aError; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TakePictures/LZMomentsSendViewController.h
<filename>LZEasemob3/Classes/View/Discover/Moments/TakePictures/LZMomentsSendViewController.h // // LZMomentsSendViewController.h // LZEasemob // // Created by nacker on 16/4/1. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsSendViewModel; //@protocol LZMomentsSendViewControllerDelegate <NSObject> // //@optional // //-(void)onSendTextImage:(NSString *)text images:(NSArray *)images; // //@end @interface LZMomentsSendViewController : UITableViewController //@property (nonatomic, weak) id<LZMomentsSendViewControllerDelegate> delegate; - (instancetype)initWithImages:(NSArray *)images; @property (nonatomic, copy) void (^sendButtonClickedBlock)(NSString *text, NSArray *images); @property (nonatomic, strong) LZMomentsSendViewModel *viewModel; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/ViewController/EMSearchDisplayController.h
/************************************************************ * * Hyphenate CONFIDENTIAL * __________________ * Copyright (C) 2016 Hyphenate Inc. All rights reserved. * * NOTICE: All information contained herein is, and remains * the property of Hyphenate Inc. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Hyphenate Inc. */ #import <UIKit/UIKit.h> #import "BaseTableViewCell.h" @interface EMSearchDisplayController : UISearchDisplayController<UITableViewDataSource, UITableViewDelegate, UISearchDisplayDelegate> @property (strong, nonatomic) NSMutableArray *resultsSource; //编辑cell时显示的风格,默认为UITableViewCellEditingStyleDelete;会将值付给[tableView:editingStyleForRowAtIndexPath:] @property (nonatomic) UITableViewCellEditingStyle editingStyle; @property (copy) UITableViewCell * (^cellForRowAtIndexPathCompletion)(UITableView *tableView, NSIndexPath *indexPath); @property (copy) BOOL (^canEditRowAtIndexPath)(UITableView *tableView, NSIndexPath *indexPath); @property (copy) CGFloat (^heightForRowAtIndexPathCompletion)(UITableView *tableView, NSIndexPath *indexPath); @property (copy) void (^didSelectRowAtIndexPathCompletion)(UITableView *tableView, NSIndexPath *indexPath); @property (copy) void (^didDeselectRowAtIndexPathCompletion)(UITableView *tableView, NSIndexPath *indexPath); @property (copy) NSInteger (^numberOfSectionsInTableViewCompletion)(UITableView *tableView); @property (copy) NSInteger (^numberOfRowsInSectionCompletion)(UITableView *tableView, NSInteger section); @end
tianqin0414/ios1
LZEasemob3/Classes/View/Login/LZLoginViewController.h
// // LZLoginViewController.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZLoginViewController : UIViewController @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/PhotoContainer/LZMomentsPictureCell.h
<reponame>tianqin0414/ios1 // // LZMomentsPictureCell.h // LZEasemob // // Created by nacker on 16/3/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMomentsPictureCell : UICollectionViewCell /// 图片 URL @property (nonatomic, strong) NSString *imageURL; @property (nonatomic, strong) UIImageView *imageView; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Chat/LZChatViewController.h
// // LZChatViewController.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #define KNOTIFICATIONNAME_DELETEALLMESSAGE @"RemoveAllMessages" #import <UIKit/UIKit.h> @interface LZChatViewController : EaseMessageViewController <EaseMessageViewControllerDelegate, EaseMessageViewControllerDataSource> @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TakePictures/MomentsPublishPictureCell.h
// // MomentsPublishPictureCell.h // Moments // // Created by Thomson on 16/2/18. // Copyright © 2016年 Thomson. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsSendViewModel; @protocol MomentsPublishPictureCellDelegate; @interface MomentsPublishPictureCell : UITableViewCell + (instancetype)cellWithTableView:(UITableView *)tableView; @property (nonatomic, weak) id<MomentsPublishPictureCellDelegate> delegate; @property (nonatomic, strong) LZMomentsSendViewModel *viewModel; + (CGFloat)estimatedHeightWithViewModel:(LZMomentsSendViewModel *)viewModel; @end @protocol MomentsPublishPictureCellDelegate <NSObject> - (void)didSelectAddItem; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Shake/LZShakeViewController.h
// // LZShakeViewController.h // Easemob // // Created by nacker on 15/12/24. // Copyright © 2015年 帶頭二哥. All rights reserved. // #import <UIKit/UIKit.h> @interface LZShakeViewController : UIViewController @end
tianqin0414/ios1
LZEasemob3/Classes/UI/Call/CallViewController.h
/************************************************************ * * Hyphenate CONFIDENTIAL * __________________ * Copyright (C) 2016 Hyphenate Inc. All rights reserved. * * NOTICE: All information contained herein is, and remains * the property of Hyphenate Inc. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Hyphenate Inc. */ #import <AVFoundation/AVFoundation.h> #import <UIKit/UIKit.h> @class EMCallSession; @interface CallViewController : UIViewController { NSTimer *_timeTimer; AVAudioPlayer *_ringPlayer; UIView *_topView; UILabel *_statusLabel; UILabel *_timeLabel; UILabel *_nameLabel; UIImageView *_headerImageView; //操作按钮显示 UIView *_actionView; UIButton *_silenceButton; UILabel *_silenceLabel; UIButton *_speakerOutButton; UILabel *_speakerOutLabel; UIButton *_rejectButton; UIButton *_answerButton; UIButton *_cancelButton; UIButton *_videoButton; UIButton *_voiceButton; // UIButton *_recordButton; UIButton *_switchCameraButton; } @property (strong, nonatomic) UILabel *statusLabel; @property (strong, nonatomic) UILabel *timeLabel; @property (strong, nonatomic) UIButton *rejectButton; @property (strong, nonatomic) UIButton *answerButton; @property (strong, nonatomic) UIButton *cancelButton; @property (nonatomic) BOOL isDismissing; - (instancetype)initWithSession:(EMCallSession *)session isCaller:(BOOL)isCaller status:(NSString *)statusString; + (BOOL)canVideo; - (void)stateToConnected; - (void)stateToAnswered; - (void)setNetwork:(EMCallNetworkStatus)status; - (void)clear; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/Settings/CallResolutionViewController.h
<reponame>tianqin0414/ios1 // // CallResolutionViewController.h // ChatDemo-UI3.0 // // Created by XieYajie on 9/19/16. // Copyright © 2016 XieYajie. All rights reserved. // #import <UIKit/UIKit.h> @interface CallResolutionViewController : UITableViewController @end
tianqin0414/ios1
LZEasemob3/Classes/ViewModel/LZMomentsViewModel.h
<filename>LZEasemob3/Classes/ViewModel/LZMomentsViewModel.h // // LZMomentsViewModel.h // LZEasemob // // Created by nacker on 16/3/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> #import "LZMoments.h" @interface LZMomentsViewModel : NSObject /// 微博模型 @property (nonatomic, strong) LZMoments *status; /// 用户头像 @property (nonatomic, readonly) NSString *iconName; /// 用户名字 @property (nonatomic, readonly) NSString *name; /// 内容 @property (nonatomic, copy) NSString *msgContent; /// 配图 @property (nonatomic, strong) NSArray *picNamesArray; /// 时间 @property (nonatomic, readonly) NSString *time; + (instancetype)viewModelWithStatus:(LZMoments *)status; /// 是否展开 @property (nonatomic, assign) BOOL isOpening; @property (nonatomic, assign, readonly) BOOL shouldShowMoreButton; @property (nonatomic, assign, readonly) CGRect iconViewF; @property (nonatomic, assign, readonly) CGRect nameLableF; @property (nonatomic, assign, readonly) CGRect contentLabelF; @property (nonatomic, assign, readonly) CGRect moreButtonF; @property (nonatomic, assign, readonly) CGRect photoContainerViewF; @property (nonatomic, assign, readonly) CGRect originalViewF; @property (nonatomic, assign, readonly) CGRect timeLabelF; @property (nonatomic, assign, readonly) CGRect operationButtonF; @property (nonatomic, assign, readonly) CGRect commentBgViewF; @property (nonatomic, assign, readonly) CGRect dividerF; /* 此次cell最新高度 */ @property (nonatomic, assign) CGFloat cellHeight; /* 上一次高度 */ @property (nonatomic, assign) CGFloat lastCellHeight; - (CGSize)getCommentViewSize; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/RedacketSDK/RedpacketOpen/Redpacket.h
// // Redpacket.h // ChatDemo-UI3.0 // // Created by Mr.Yang on 16/3/17. // Copyright © 2016年 Mr.Yang. All rights reserved. // #import "RedpacketOpenConst.h" #import "RedPacketUserConfig.h" #import "ChatWithRedPacketViewController.h" #import "EaseBubbleView+RedPacket.h" #import "EaseRedBagCell.h" #import "RedpacketMessageCell.h"
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/LZMomentsOriginalView.h
<reponame>tianqin0414/ios1 // // LZMomentsOriginalView.h // LZEasemob // // Created by nacker on 16/3/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsViewModel; @interface LZMomentsOriginalView : UIView @property (nonatomic, strong) LZMomentsViewModel *viewModel; @property (nonatomic, strong) NSIndexPath *indexPath; @property (nonatomic, copy) void (^moreButtonClickedBlock)(NSIndexPath *indexPath); @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/TakePictures/LZMomentsDefaultsCell.h
<reponame>tianqin0414/ios1 // // LZMomentsDefaultsCell.h // LZEasemob // // Created by nacker on 16/4/6. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMomentsDefaultsCell : UITableViewCell + (instancetype)cellWithTableView:(UITableView *)tableView; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Me/LZMeViewController.h
// // LZMeViewController.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMeViewController : UIViewController @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Category/UIImageView+Extension.h
<gh_stars>1-10 // // UIImageView+Extension.h // LZEasemob3 // // Created by nacker on 16/7/18. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface UIImageView (Extension) - (void)getImageWithURL:(NSString *)url placeholder:(NSString *)placeholder; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Common/TextView/EMTextView.h
// // LZTextView.h // 黑马微博 // // Created by nacker on 15/1/4. // Copyright (c) 2015年 nacker. All rights reserved. // #import <UIKit/UIKit.h> @interface EMTextView : UITextView { UIColor *_contentColor; BOOL _editing; } @property(strong, nonatomic) NSString *placeholder; @property(strong, nonatomic) UIColor *placeholderColor; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/RedacketSDK/RedpacketOpen/RedpacketCell/TransferCell.h
// // TransferCell.h // ChatDemo-UI3.0 // // Created by Mr.Yan on 16/8/25. // Copyright © 2016年 Mr.Yan. All rights reserved. // #import "EaseBaseMessageCell.h" @interface TransferCell : EaseBaseMessageCell @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Category/UIView+Extension.h
// // UIView+Extension.h // MJRefreshExample // // Created by nacker on 15-3-9. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface UIView (Extension) @property (assign, nonatomic) CGFloat x; @property (assign, nonatomic) CGFloat y; @property (assign, nonatomic) CGFloat width; @property (assign, nonatomic) CGFloat height; @property (assign, nonatomic) CGSize size; @property (assign, nonatomic) CGPoint origin; @property (nonatomic, assign) CGFloat centerY; @end
tianqin0414/ios1
LZEasemob3/Classes/ViewModel/LZMomentsSendViewModel.h
// // LZMomentsSendViewModel.h // LZEasemob // // Created by nacker on 16/4/6. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // 发送朋友圈 #import <Foundation/Foundation.h> @interface LZMomentsSendViewModel : NSObject @property (nonatomic, strong) NSArray *assets; @property (nonatomic, copy) NSString *textPlain; - (RACSignal *)publish; - (RACSignal *)publishContent; @end
tianqin0414/ios1
LZEasemob3/Classes/UI/RedacketSDK/RedpacketOpen/RedpacketCell/RedpacketMessageCell.h
// // RedpacketMessageCell.h // ChatDemo-UI3.0 // // Created by Mr.Yang on 16/2/28. // #import <UIKit/UIKit.h> /** * 红包消息的显示Cell */ @interface RedpacketMessageCell : UITableViewCell /** * 聊天消息Model */ @property (nonatomic, assign) id<IMessageModel> model; /** * 红包Cell被单击了的事件 */ @property (nonatomic, copy) void(^redpacketMesageCellTaped)(id <IMessageModel> model); @end
tianqin0414/ios1
LZEasemob3/Classes/Model/LZContactsGrounp.h
// // LZContactsGrounp.h // LZEasemob // // Created by nacker on 16/4/14. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <Foundation/Foundation.h> @interface LZContactsGrounp : NSObject /* * 组头部标题 */ @property (nonatomic, strong) NSString *headerTitle; /* * 组尾部说明 */ @property (nonatomic, strong) NSString *footerTitle; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *icon; @end
tianqin0414/ios1
LZEasemob3/Classes/Other/Category/UILabel+Extension.h
<reponame>tianqin0414/ios1<gh_stars>1-10 // // UILabel+Extension.h // HXClient // // Created by nacker on 16/1/11. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface UILabel (Extension) + (UILabel *)labelWithText:(NSString *)text sizeFont:(UIFont *)sizeFont textColor:(UIColor *)textColor; + (instancetype)labelWithTitle:(NSString *)title color:(UIColor *)color fontSize:(CGFloat)fontSize alignment:(NSTextAlignment)alignment; + (CGFloat)heightForExpressionText:(NSAttributedString *)expressionText width:(CGFloat)width; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/LZMomentsViewController.h
// // LZMomentsViewController.h // LZEasemob // // Created by nacker on 16/3/11. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @interface LZMomentsViewController : UITableViewController @end
tianqin0414/ios1
LZEasemob3/Classes/View/Conversation/LZConversationCell.h
// // LZConversationCell.h // HXClient // // Created by nacker on 16/6/3. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class EMConversation; @interface LZConversationCell : UITableViewCell + (instancetype)cellWithTableView:(UITableView *)tableView; @property (nonatomic, strong) EMConversation *conversaion; @end
tianqin0414/ios1
LZEasemob3/Classes/View/Discover/Moments/CommentView/LZMomentsCellCommentTableView.h
// // LZMomentsCellCommentView.h // LZEasemob // // Created by nacker on 16/3/30. // Copyright © 2016年 帶頭二哥 QQ:648959. All rights reserved. // #import <UIKit/UIKit.h> @class LZMomentsViewModel; @interface LZMomentsCellCommentTableView : UITableView @property (nonatomic, strong) LZMomentsViewModel *viewModel; @end
azinman/CoreWebSocket
CoreWebSocket/CoreWebSocketTypes.h
// // CoreWebSocketTypes.h // CoreWebSocketCore // // Created by <NAME> on 07/03/2011. // Copyright 2011 Inteliv Ltd. All rights reserved. // #ifndef __CORE_WEB_SOCKET_TYPES__ #define __CORE_WEB_SOCKET_TYPES__ 1 #import "CoreWebSocketLib.h" #include <CoreFoundation/CoreFoundation.h> #define CoreWebSocketLog(fmt, ...) printf(fmt, __VA_ARGS__) #define kCoreWebSocketHostAny CFSTR("0.0.0.0") #define kCoreWebSocketHostLoopBack CFSTR("127.0.0.1") #define kCoreWebSocketPortAny 0 typedef struct CoreWebSocket CoreWebSocket; typedef CoreWebSocket *CoreWebSocketRef; typedef struct CoreWebSocketClient CoreWebSocketClient; typedef CoreWebSocketClient *CoreWebSocketClientRef; #pragma mark CoreWebSocket Protocol typedef enum CoreWebSocketProtocol CoreWebSocketProtocol; enum CoreWebSocketProtocol { kCoreWebSocketProtocolUnknown = -1, kCoreWebSocketProtocolDraftIETF_HYBI_00 = 0, kCoreWebSocketProtocolDraftIETF_HYBI_06 = 6 }; #pragma mark CoreWebSocket Callbacks //typedef void (*CoreWebSocketDidAddClientCallback) (CoreWebSocketRef webSocket, CoreWebSocketClientRef client); //typedef void (*CoreWebSocketWillRemoveClientCallback) (CoreWebSocketRef webSocket, CoreWebSocketClientRef client); //typedef void (*CoreWebSocketDidClientReadCallback) (CoreWebSocketRef webSocket, CoreWebSocketClientRef client, CFStringRef value); typedef void (^CoreWebSocketDidAddClientCallback) (CoreWebSocketRef, CoreWebSocketClientRef); typedef void (^CoreWebSocketWillRemoveClientCallback) (CoreWebSocketRef, CoreWebSocketClientRef); typedef void (^CoreWebSocketDidClientReadCallback) (CoreWebSocketRef, CoreWebSocketClientRef, CFStringRef); typedef struct CoreWebSocketCallbacks CoreWebSocketCallbacks; struct CoreWebSocketCallbacks { __unsafe_unretained CoreWebSocketDidAddClientCallback didAddClientCallback; __unsafe_unretained CoreWebSocketWillRemoveClientCallback willRemoveClientCallback; __unsafe_unretained CoreWebSocketDidClientReadCallback didClientReadCallback; }; #pragma mark CoreWebSocket Client enum CoreWebSocketClientState { kCoreWebSocketClientInitialized, kCoreWebSocketClientReadStreamOpened, kCoreWebSocketClientWriteStreamOpened, kCoreWebSocketClientHandShakeError, kCoreWebSocketClientHandShakeRead, kCoreWebSocketClientHandShakeSent, kCoreWebSocketClientReady }; struct CoreWebSocketClient { CFUUIDRef uuid; CFAllocatorRef allocator; CFIndex retainCount; CoreWebSocketRef webSocket; CFSocketNativeHandle handle; CFReadStreamRef read; CFWriteStreamRef write; CFMutableArrayRef writeQueue; CFHTTPMessageRef handShakeRequestHTTPMessage; CoreWebSocketProtocol protocol; // Linked list of clients CoreWebSocketClientRef previousClient; CoreWebSocketClientRef nextClient; CFStreamClientContext context; bool didReadHandShake; bool didWriteHandShake; }; struct CoreWebSocket { CFAllocatorRef allocator; CFIndex retainCount; void *userInfo; struct sockaddr_in addr; CFSocketRef socket; CFReadStreamRef read; CFWriteStreamRef write; CFIndex clientsUsedLength; CFIndex clientsLength; CoreWebSocketClientRef *clients; CFSocketContext context; CoreWebSocketCallbacks callbacks; }; #endif
azinman/CoreWebSocket
CoreWebSocket/CoreWebSocketClient.h
// // CoreWebSocketClient.h // CoreWebSocketCore // // Created by <NAME> on 07/03/2011. // Copyright 2011 Inteliv Ltd. All rights reserved. // #ifndef __CORE_WEB_SOCKET_CLIENT__ #define __CORE_WEB_SOCKET_CLIENT__ 1 #include "CoreWebSocket.h" #include "cuEnc64.h" #include <CommonCrypto/CommonDigest.h> #pragma mark Lifecycle CoreWebSocketClientRef CoreWebSocketClientCreate (CoreWebSocketRef webSocket, CFSocketNativeHandle handle); CoreWebSocketClientRef CoreWebSocketClientRetain (CoreWebSocketClientRef client); CoreWebSocketClientRef CoreWebSocketClientRelease (CoreWebSocketClientRef client); #pragma mark Write CFIndex CoreWebSocketClientWriteWithData (CoreWebSocketClientRef client, CFDataRef value); CFIndex CoreWebSocketClientWriteWithString (CoreWebSocketClientRef client, CFStringRef value); #pragma mark Handshake (internal) uint32_t __CoreWebSocketGetMagicNumberWithKeyValueString (CFStringRef string); bool __CoreWebSocketDataAppendMagickNumberWithKeyValueString (CFMutableDataRef data, CFStringRef string); CFDataRef __CoreWebSocketCreateMD5Data (CFAllocatorRef allocator, CFDataRef value) CF_RETURNS_RETAINED; CFDataRef __CoreWebSocketCreateSHA1DataWithData (CFAllocatorRef allocator, CFDataRef value) CF_RETURNS_RETAINED; CFDataRef __CoreWebSocketCreateSHA1DataWithString (CFAllocatorRef allocator, CFStringRef value, CFStringEncoding encoding) CF_RETURNS_RETAINED; bool __CoreWebSocketClientReadHandShake (CoreWebSocketClientRef client); bool __CoreWebSocketClientWriteWithHTTPMessage (CoreWebSocketClientRef client, CFHTTPMessageRef message); #endif
azinman/CoreWebSocket
CoreWebSocket/CoreWebSocket.h
// // CoreWebSocket.h // CoreWebSocketCore // // Created by <NAME> on 07/03/2011. // Copyright 2011 Inteliv Ltd. All rights reserved. // #ifndef __CORE_WEB_SOCKET_WEB_SOCKET__ #define __CORE_WEB_SOCKET_WEB_SOCKET__ 1 #include "CoreWebSocketTypes.h" #define __CoreWebSocketMaxHeaderKeyLength 4096 #pragma mark Lifecycle CoreWebSocketRef CoreWebSocketCreate (CFAllocatorRef allocator, CFStringRef host, UInt16 port, void *userInfo); // Create CoreWebSocketRef using any host and any available port. CoreWebSocketRef CoreWebSocketCreateWithUserInfo(CFAllocatorRef allocator, void *userInfo); CoreWebSocketRef CoreWebSocketRetain (CoreWebSocketRef webSocket); CoreWebSocketRef CoreWebSocketRelease (CoreWebSocketRef webSocket); UInt16 CoreWebSocketGetPort(CoreWebSocketRef webSocket); void CoreWebSocketWriteWithString (CoreWebSocketRef webSocket, CFStringRef value); CFIndex CoreWebSocketWriteWithStringAndClientIndex (CoreWebSocketRef webSocket, CFStringRef value, CFIndex index); #pragma mark Callbacks void CoreWebSocketSetClientReadCallback(CoreWebSocketRef webSocket, CoreWebSocketDidClientReadCallback callback); void CoreWebSocketSetDidAddClientCallback(CoreWebSocketRef webSocket, CoreWebSocketDidAddClientCallback callback); void CoreWebSocketSetWillRemoveClientCallback(CoreWebSocketRef webSocket, CoreWebSocketWillRemoveClientCallback callback); #pragma mark Internal, client management CFIndex __CoreWebSocketAppendClient (CoreWebSocketRef webSocket, CoreWebSocketClientRef client); CFIndex __CoreWebSocketRemoveClient (CoreWebSocketRef webSocket, CoreWebSocketClientRef client); #pragma mark Internal, socket callback void __CoreWebSocketAcceptCallBack(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *data, void *info); #endif
azinman/CoreWebSocket
CoreWebSocket/main.c
// // main.c // WebSocketCore // // Created by <NAME> on 07/03/2011. // Copyright 2011 Inteliv Ltd. All rights reserved. // #include "WebSocket.h" void myread(WebSocketRef webSocket, WebSocketClientRef client, CFDataRef data) { CFStringRef string = CFStringCreateWithBytes(NULL, CFDataGetBytePtr(data), CFDataGetLength(data), kCFStringEncodingUTF8, 0); // printf("callback beg\n"); if (string) { CFShow(string); CFRelease(string); } else { // printf("buu\n"); } // printf("callback end\n"); } int main (int argc, const char * argv[]) { // WebSocketRef webSocket = WebSocketCreate(NULL, kWebSocketHostAny, 6001); // if (webSocket) { // webSocket->callbacks.didClientReadCallback = myread; // CFRunLoopRun(); // WebSocketRelease(webSocket); // } // CFDataRef key3 = CFDataCreate(NULL, (const void *)"<KEY>", 8); // CFDataRef data = __WebSocketCreateMD5Data(NULL, CFSTR("18x 6]8vM;54 *(5: { U1]8 z [ 8"), CFSTR("1_ tx7X d < nw 334J702) 7]o}` 0"), key3); // // printf("\n"); // for (int i = 0; i < CFDataGetLength(data); i++) { // printf("%02x", *(uint8_t *)(CFDataGetBytePtr(data) + i)); // } // printf("\n"); // 1868545188, 12: 09 47 fa 63 00 // 1733470270, 10: 0a 55 10 d3 00 // all 09 47 fa 63 0a 55 10 d3 54 6d 5b 4b 20 54 32 75 // 66514a2c664e2f344634217e4b7e4d48 // CFRelease(data); // insert code here... CFShow(CFSTR("Hello, World!\n")); return 0; }
azinman/CoreWebSocket
CoreWebSocket/CoreWebSocketLib.h
// // WebSocket.h // WebSocketCore // // Created by <NAME> on 07/03/2011. // Copyright 2011 Inteliv Ltd. All rights reserved. // #ifndef __CORE_WEB_SOCKET__ #define __CORE_WEB_SOCKET__ 1 #include <CoreFoundation/CoreFoundation.h> #include <unistd.h> #include <netdb.h> #import <CommonCrypto/CommonDigest.h> #if (TARGET_OS_IPHONE) #include <CFNetwork/CFNetwork.h> #else #include <CoreServices/CoreServices.h> //#include <openssl/evp.h> //#include <openssl/err.h> #endif #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #include "CoreWebSocketTypes.h" #include "CoreWebSocket.h" #include "CoreWebSocketClient.h" #include "cuEnc64.h" #endif
vpadi/MH
P2/software/AGG_QAP/src/modulo_io.h
#include <iostream> #include <fstream> #include <string> #include <stdlib.h> #include <vector> using namespace std; /* Realiza la lectura de las matrices, las guarda en vectores de vectores de la stl y devuelve el tamaño del problema. */ int lecturaMatrices(vector<vector<int> > &m1, vector<vector<int> > &m2, fstream & file){ string cad; getline(file, cad); int tam = atoi( cad.c_str()); m1.resize(tam); m2.resize(tam); for(int i=0; i < tam; ++i){ m1[i].resize(tam); m2[i].resize(tam); } for(int i = 0; i < tam && !file.eof(); ++i){ for(int j = 0; j < tam && !file.eof(); ++j){ file >> cad; m1[i][j] = atoi( cad.c_str()); } } for(int i = 0; i < tam && !file.eof(); ++i){ for(int j = 0; j < tam && !file.eof() && cad != "\n"; ++j){ file >> cad; m2[i][j] = atoi( cad.c_str()); } } return tam; }
cutbm2015/NTUSTOOP_WKTai_Project3
Project_3/User.h
<gh_stars>0 #include <vector> #include <iostream> using namespace std; class User { public: User(); User createAccount(string username, string password,int permission); User createAccount(); User guestIn(); int userLogin(string username); int userLogin(); bool isUserExist(string); bool isUserExist(string, string &pswd); vector<int> postsID; //req //private data process void setUserName(string); string getUserName(); void setUserPswd(string); string getUserPswd(); void setUserPermission(int); int getUserPermission(); virtual bool isGuest() { return false; }; virtual bool isUser() { return false; }; virtual bool isAdmin() { return false; }; protected: string userName; string userPswd; int userPermission; //req vector<int> postID; //req }; class Adiministrator : public User { public: Adiministrator(string username, string password, int permission) { this->userName = username; this->userPswd = password; this->userPermission = permission; } bool isAdmin() { return true; }; }; class Member : public User { public: Member(string username, string password, int permission) { this->userName = username; this->userPswd = password; this->userPermission = permission; } bool isUser() { return true; }; }; class Guest : public User { public: Guest(string username, string password, int permission) { this->userName = username; this->userPswd = password; this->userPermission = permission; } bool isGuest(){ return true; }; };
cutbm2015/NTUSTOOP_WKTai_Project3
Project_3/Viewer.h
#include <string> #include <vector> #include "Board.h" using namespace std; class Viewer { public: void homepage(); void askLoginPassword(); void askRegUsername(); void askRegPassword(); void askRegPasswordAgain(); void askRegPermission(); void askBoardName(); void askBoardIntroduction(); void askPostTitle(); void displayPost(Post); void askDeleteFloor(); void askDeleteReason(int); void askComment(string); void editorForMail(string); void showMailContent(string, string, string, string); void showMailBox(vector<string>, vector<string>, vector<string>, int); void editorForEdit(string title); void editor(string title); void showBoardList(int, const vector<Board>); void game1(int, int, int); void game2(int, int, int,int[],int,int,int); void game3Init(int, double[]); void game3askMoney(); void game3askTarget(); void game3Win(vector<int>, int); void game3Lose(vector<int>, int); void game3Field(int[],int); void mailLobby(int); void gameLobby(int); void askTo(); void askMailTitle(); void lobby(int, int); void showPostList(int, int, vector<Board>); //index of selected board void error(string message); void successful(string message); void setCursor(short x, short y); void clearRow(short x, short y); void clearRow(short x, short y,int xCnt); void clearRowWhite(short x, short y); void askMailSelect(); void showMailboxList(string currentUserName); };
cutbm2015/NTUSTOOP_WKTai_Project3
Project_3/BoardManager.h
#include <iostream> #include <string> #include <cstdlib> #include <ctime> #include <Windows.h> #include <vector> #include "Post.h" #include "Board.h" #include "User.h" #include "Viewer.h" using namespace std; enum BoardState { CREATE_POST, DELETE_POST, DELETE_BOARD, MENU, //default LOBBY, SELECT_BOARD, //default BOARD, //default POST, //default MAIL, GAME, INBOX, SEND, SEND_MAIL, READ_MAIL, CREATE_BOARD, EDIT_POST, GAME_1, GAME_2, GAME_3, }; class BoardManager { public: BoardManager(); void getUser(); void getBoard(); void createBoard(); void startBoard(); vector <User*> users; //req vector <Board> boards; //req int current_user; //req BoardState state; //req Viewer viewer; //req private: int selected_board = 0; int post_num = 0; };
cutbm2015/NTUSTOOP_WKTai_Project3
Project_3/Post.h
<filename>Project_3/Post.h #pragma once #include <vector> #include <string> #include <iostream> #include <fstream> #include <Windows.h> using namespace std; class Post { public: Post() {}; Post(int postID, int status, string boardName,string deleteReason, string author, string title,string timestamp, string content); bool doPost(Post myPost); void setPostID(int); void setTitle(string); void setStatus(int); void doDelete(string reason); void setAuthor(string); void setContent(string content); void setTimestamp(string timestamp); void setBoardName(string); void setDeleteReason(string); void setLike(int); void setDislike(int); void setComment(int); bool isCommentAuthor(int, string); bool isLikeOrDislikeAvailable(string username); bool fileUpdate(); bool isDelete(); bool doComment(string username, string type, string content); bool doDeleteComment(int floor, string reason); int getPostID(); int getLike(); int getDislike(); int getComment(); string getBoardName(); string getDeleteReason(); string getAuthor(); string getTitle(); string getTimestamp(); string getContent(); private: int postID; int like; int dislike; int comment; int status; string boardName; string deleteReason; string author; string title; string timestamp; string content; };
cutbm2015/NTUSTOOP_WKTai_Project3
Project_3/Board.h
<gh_stars>0 #pragma once #include <iostream> #include <string> #include <vector> #include <Windows.h> #include <fstream> #include "Post.h" using namespace std; class Board { public: Board(); Board(string filename); static bool isValidBoardName(string name); static Board createBoard(string name, string intro); string getName(); string getIntroduction(); void setName(string); void setIntroduction(string); int getPopularity(); void increaseViewAmount(); void setPopularity(int); int getViewAmount(); void setViewAmount(int); void doDelete(vector<Board>); //static int getBoardAmount(); //static void setBoardAmount(int); vector<Post> posts; private: //static int boardAmount; string name; string introduction; int popularity; int viewAmount; };
melonshell/trafficserver
plugins/experimental/fastcgi/src/Profiler.h
<gh_stars>0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <thread> #include <mutex> #include <vector> #include <string> #include <chrono> #include <sys/types.h> #include <unistd.h> namespace ats_plugin { // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(TypeName &) = delete; \ void operator=(TypeName) = delete; // A single profile, stores data of a taken profile class Profile { public: // Computes the start time and sets the thread id // The duration of the profiles is in microseconds void ComputeStartTime() { this->start_time_ = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); this->thread_id_ = std::hash<std::thread::id>()(std::this_thread::get_id()); this->process_id_ = getpid(); } // Computes the end time void ComputeEndTime() { this->end_time_ = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); } // Gettors std::size_t start_time() const { return this->start_time_; } std::size_t end_time() const { return this->end_time_; } std::size_t thread_id() const { return this->thread_id_; } std::size_t process_id() const { return this->process_id_; } std::size_t object_id() const { return this->object_id_; } void set_object_id(std::size_t objId) { object_id_ = objId; } const std::string & task_name() const { return this->task_name_; } // Settors void set_task_name(const std::string &task_name) { this->task_name_ = task_name; } const std::string & obj_stage() const { return this->obj_stage_; } void set_obj_stage(const std::string &obj_stage) { this->obj_stage_ = obj_stage; } private: // The time the profile started std::chrono::high_resolution_clock::rep start_time_; // The time the profile ended std::chrono::high_resolution_clock::rep end_time_; // The id of the thread std::size_t thread_id_; std::size_t process_id_; std::size_t object_id_; // The name of the task of the profile std::string task_name_; std::string obj_stage_; }; // Keeps tracks of the taken profiles and saves the data to a JSON. // In order to take profiles use the embedded class profile taker // The duration is in microseconds class Profiler { public: // The storage of profiles typedef std::vector<Profile> ProfileContainer; // Empty constructor Profiler() : record_enabled_(false) {} // Submits a new profile void SubmitProfile(const Profile &profile) { // Ignore if not enabled if (!this->record_enabled_) return; std::unique_lock<std::mutex> lock(this->profiles_mutex_); this->profiles_.push_back(profile); } // Removes all the profiles void Clear() { std::unique_lock<std::mutex> lock(this->profiles_mutex_); this->profiles_.clear(); } // Gettors bool record_enabled() const { return this->record_enabled_; } const ProfileContainer & profiles() const { return this->profiles_; } void printProfileLength() { std::cout << "Profile Length: " << this->profiles_.size() << std::endl; } // Settors void set_record_enabled(bool enabled) { this->record_enabled_ = enabled; if (!this->record_enabled_) this->Clear(); } private: // The profiles ProfileContainer profiles_; // If true, enabled bool record_enabled_; // The mutex for safe access mutable std::mutex profiles_mutex_; // DISALLOW_COPY_AND_ASSIGN(Profiler); }; // Takes a profile during its life time class ProfileTaker { public: // Initializes a profile ProfileTaker(Profiler *owner, const std::string &task_name, std::size_t objId, const std::string &phase) : owner_(owner) { profile_.ComputeStartTime(); profile_.set_task_name(task_name); profile_.set_obj_stage(phase); profile_.set_object_id(objId); } // Releases a profile and submits it ~ProfileTaker() { // profile_.ComputeEndTime(); owner_->SubmitProfile(this->profile_); // profile_.set_task_name(this->profile_.task_name()); // profile_.set_obj_stage("E"); Profile endProf; endProf.ComputeStartTime(); endProf.set_obj_stage("E"); endProf.set_task_name(this->profile_.task_name()); endProf.set_object_id(this->profile_.object_id()); owner_->SubmitProfile(endProf); } private: // The profile to take care of Profile profile_; // The owner profiler Profiler *owner_; // DISALLOW_COPY_AND_ASSIGN(ProfileTaker); }; } // namespace ats_plugin
licl19/encryptAndDecrypt
AES_ios/AES/AES.h
<gh_stars>1-10 // // DES3Util.h // DES3 // // Created by lichanglai on 16/7/1. // Copyright © 2016年 lichanglai. All rights reserved. // #import <Foundation/Foundation.h> @interface AES : NSObject // 加密方法 + (NSString*)encrypt:(NSString*)plainText; // 解密方法 + (NSString*)decrypt:(NSString*)encryptText; // 加密方法 + (NSString*)encryptData:(NSData*)plainText; // 解密方法 + (NSData*)decryptData:(NSString*)encryptText; @end
licl19/encryptAndDecrypt
sha256_ios/NSString+SHA256.h
<gh_stars>1-10 // // NSString+SHA256.h // cloud_business // // Created by lichanglai on 16/5/9. // Copyright © 2016年 lichanglai. All rights reserved. // #import <Foundation/Foundation.h> @interface NSString (SHA256) + (NSString *)sha256:(NSString *)str; @end
harrain/XC
XC/ViewController.h
// // ViewController.h // XC // // Created by iron on 2017/11/25. // Copyright © 2017年 wangzhengang. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController - (NSString *)md5HexDigest:(NSString*)input; - (void)performanceExample; ////网络请求 + (void)networkRequestWithAPI:(NSString *)api requestMethod:(NSString *)method cachePolicy:(NSURLRequestCachePolicy)cachePolicy requestParamer:(NSDictionary *)paramer Completion:(void(^)(NSDictionary * _Nullable result, NSURLResponse * _Nullable response, NSError * _Nullable error))completion; @end
lirui34/acrn-hypervisor
hypervisor/include/public/acrn_common.h
/* * common definition * * Copyright (C) 2017 Intel Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /** * @file acrn_common.h * * @brief acrn common data structure for hypercall or ioctl */ #ifndef ACRN_COMMON_H #define ACRN_COMMON_H #include <types.h> /* * Common structures for ACRN/VHM/DM */ /* * IO request */ #define VHM_REQUEST_MAX 16U #define REQ_STATE_FREE 3U #define REQ_STATE_PENDING 0U #define REQ_STATE_COMPLETE 1U #define REQ_STATE_PROCESSING 2U #define REQ_PORTIO 0U #define REQ_MMIO 1U #define REQ_PCICFG 2U #define REQ_WP 3U #define REQUEST_READ 0U #define REQUEST_WRITE 1U /* IOAPIC device model info */ #define VIOAPIC_RTE_NUM 48U /* vioapic pins */ #if VIOAPIC_RTE_NUM < 24U #error "VIOAPIC_RTE_NUM must be larger than 23" #endif /* Generic VM flags from guest OS */ #define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */ #define LAPIC_PASSTHROUGH (1UL << 1U) /* Whether LAPIC is passed through */ #define IO_COMPLETION_POLLING (1UL << 2U) /* Whether need hypervisor poll IO completion */ #define CLOS_REQUIRED (1UL << 3U) /* Whether CLOS is required */ /** * @brief Hypercall * * @addtogroup acrn_hypercall ACRN Hypercall * @{ */ /** * @brief Representation of a MMIO request */ struct mmio_request { /** * @brief Direction of the access * * Either \p REQUEST_READ or \p REQUEST_WRITE. */ uint32_t direction; /** * @brief reserved */ uint32_t reserved; /** * @brief Address of the I/O access */ uint64_t address; /** * @brief Width of the I/O access in byte */ uint64_t size; /** * @brief The value read for I/O reads or to be written for I/O writes */ uint64_t value; } __aligned(8); /** * @brief Representation of a port I/O request */ struct pio_request { /** * @brief Direction of the access * * Either \p REQUEST_READ or \p REQUEST_WRITE. */ uint32_t direction; /** * @brief reserved */ uint32_t reserved; /** * @brief Port address of the I/O access */ uint64_t address; /** * @brief Width of the I/O access in byte */ uint64_t size; /** * @brief The value read for I/O reads or to be written for I/O writes */ uint32_t value; } __aligned(8); /** * @brief Representation of a PCI configuration space access */ struct pci_request { /** * @brief Direction of the access * * Either \p REQUEST_READ or \p REQUEST_WRITE. */ uint32_t direction; /** * @brief Reserved */ uint32_t reserved[3];/* need keep same header fields with pio_request */ /** * @brief Width of the I/O access in byte */ int64_t size; /** * @brief The value read for I/O reads or to be written for I/O writes */ int32_t value; /** * @brief The \p bus part of the BDF of the device */ int32_t bus; /** * @brief The \p device part of the BDF of the device */ int32_t dev; /** * @brief The \p function part of the BDF of the device */ int32_t func; /** * @brief The register to be accessed in the configuration space */ int32_t reg; } __aligned(8); union vhm_io_request { struct pio_request pio; struct pci_request pci; struct mmio_request mmio; int64_t reserved1[8]; }; /** * @brief 256-byte VHM requests * * The state transitions of a VHM request are: * * FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ... * * When a request is in COMPLETE or FREE state, the request is owned by the * hypervisor. SOS (VHM or DM) shall not read or write the internals of the * request except the state. * * When a request is in PENDING or PROCESSING state, the request is owned by * SOS. The hypervisor shall not read or write the request other than the state. * * Based on the rules above, a typical VHM request lifecycle should looks like * the following. * * @verbatim embed:rst:leading-asterisk * * +-----------------------+-------------------------+----------------------+ * | SOS vCPU 0 | SOS vCPU x | UOS vCPU y | * +=======================+=========================+======================+ * | | | Hypervisor: | * | | | | * | | | - Fill in type, | * | | | addr, etc. | * | | | - Pause UOS vCPU y | * | | | - Set state to | * | | | PENDING (a) | * | | | - Fire upcall to | * | | | SOS vCPU 0 | * | | | | * +-----------------------+-------------------------+----------------------+ * | VHM: | | | * | | | | * | - Scan for pending | | | * | requests | | | * | - Set state to | | | * | PROCESSING (b) | | | * | - Assign requests to | | | * | clients (c) | | | * | | | | * +-----------------------+-------------------------+----------------------+ * | | Client: | | * | | | | * | | - Scan for assigned | | * | | requests | | * | | - Handle the | | * | | requests (d) | | * | | - Set state to COMPLETE | | * | | - Notify the hypervisor | | * | | | | * +-----------------------+-------------------------+----------------------+ * | | Hypervisor: | | * | | | | * | | - resume UOS vCPU y | | * | | (e) | | * | | | | * +-----------------------+-------------------------+----------------------+ * | | | Hypervisor: | * | | | | * | | | - Post-work (f) | * | | | - set state to FREE | * | | | | * +-----------------------+-------------------------+----------------------+ * * @endverbatim * * Note that the following shall hold. * * 1. (a) happens before (b) * 2. (c) happens before (d) * 3. (e) happens before (f) * 4. One vCPU cannot trigger another I/O request before the previous one has * completed (i.e. the state switched to FREE) * * Accesses to the state of a vhm_request shall be atomic and proper barriers * are needed to ensure that: * * 1. Setting state to PENDING is the last operation when issuing a request in * the hypervisor, as the hypervisor shall not access the request any more. * * 2. Due to similar reasons, setting state to COMPLETE is the last operation * of request handling in VHM or clients in SOS. */ struct vhm_request { /** * @brief Type of this request. * * Byte offset: 0. */ uint32_t type; /** * @brief Hypervisor will poll completion if set. * * Byte offset: 4. */ uint32_t completion_polling; /** * @brief Reserved. * * Byte offset: 8. */ uint32_t reserved0[14]; /** * @brief Details about this request. * * For REQ_PORTIO, this has type * pio_request. For REQ_MMIO and REQ_WP, this has type mmio_request. For * REQ_PCICFG, this has type pci_request. * * Byte offset: 64. */ union vhm_io_request reqs; /** * @brief Reserved. * * Byte offset: 128. */ uint32_t reserved1; /** * @brief The client which is distributed to handle this request. * * Accessed by VHM only. * * Byte offset: 132. */ int32_t client; /** * @brief The status of this request. * * Taking REQ_STATE_xxx as values. * * Byte offset: 136. */ uint32_t processed; } __aligned(256); union vhm_request_buffer { struct vhm_request req_queue[VHM_REQUEST_MAX]; int8_t reserved[4096]; } __aligned(4096); /** * @brief Info to create a VM, the parameter for HC_CREATE_VM hypercall */ struct acrn_create_vm { /** created vmid return to VHM. Keep it first field */ uint16_t vmid; /** Reserved */ uint16_t reserved0; /** VCPU numbers this VM want to create */ uint16_t vcpu_num; /** Reserved */ uint16_t reserved1; /** the GUID of this VM */ uint8_t GUID[16]; /* VM flag bits from Guest OS, now used * SECURE_WORLD_ENABLED (1UL<<0) */ uint64_t vm_flag; /** Reserved for future use*/ uint8_t reserved2[24]; } __aligned(8); /** * @brief Info to create a VCPU * * the parameter for HC_CREATE_VCPU hypercall */ struct acrn_create_vcpu { /** the virtual CPU ID for the VCPU created */ uint16_t vcpu_id; /** the physical CPU ID for the VCPU created */ uint16_t pcpu_id; } __aligned(8); /* General-purpose register layout aligned with the general-purpose register idx * when vmexit, such as vmexit due to CR access, refer to SMD Vol.3C 27-6. */ struct acrn_gp_regs { uint64_t rax; uint64_t rcx; uint64_t rdx; uint64_t rbx; uint64_t rsp; uint64_t rbp; uint64_t rsi; uint64_t rdi; uint64_t r8; uint64_t r9; uint64_t r10; uint64_t r11; uint64_t r12; uint64_t r13; uint64_t r14; uint64_t r15; }; /* struct to define how the descriptor stored in memory. * Refer SDM Vol3 3.5.1 "Segment Descriptor Tables" * Figure 3-11 */ struct acrn_descriptor_ptr { uint16_t limit; uint64_t base; uint16_t reserved[3]; /* align struct size to 64bit */ } __packed; /** * @brief registers info for vcpu. */ struct acrn_vcpu_regs { struct acrn_gp_regs gprs; struct acrn_descriptor_ptr gdt; struct acrn_descriptor_ptr idt; uint64_t rip; uint64_t cs_base; uint64_t cr0; uint64_t cr4; uint64_t cr3; uint64_t ia32_efer; uint64_t rflags; uint64_t reserved_64[4]; uint32_t cs_ar; uint32_t cs_limit; uint32_t reserved_32[3]; /* don't change the order of following sel */ uint16_t cs_sel; uint16_t ss_sel; uint16_t ds_sel; uint16_t es_sel; uint16_t fs_sel; uint16_t gs_sel; uint16_t ldt_sel; uint16_t tr_sel; uint16_t reserved_16[4]; }; /** * @brief Info to set vcpu state * * the pamameter for HC_SET_VCPU_STATE */ struct acrn_set_vcpu_regs { /** the virtual CPU ID for the VCPU to set state */ uint16_t vcpu_id; /** reserved space to make cpu_state aligned to 8 bytes */ uint16_t reserved0[3]; /** the structure to hold vcpu state */ struct acrn_vcpu_regs vcpu_regs; } __aligned(8); /** * @brief Info to set ioreq buffer for a created VM * * the parameter for HC_SET_IOREQ_BUFFER hypercall */ struct acrn_set_ioreq_buffer { /** guest physical address of VM request_buffer */ uint64_t req_buf; } __aligned(8); /** Operation types for setting IRQ line */ #define GSI_SET_HIGH 0U #define GSI_SET_LOW 1U #define GSI_RAISING_PULSE 2U #define GSI_FALLING_PULSE 3U /** * @brief Info to Set/Clear/Pulse a virtual IRQ line for a VM * * the parameter for HC_SET_IRQLINE hypercall */ struct acrn_irqline_ops { uint32_t gsi; uint32_t op; } __aligned(8); /** * @brief Info to inject a MSI interrupt to VM * * the parameter for HC_INJECT_MSI hypercall */ struct acrn_msi_entry { /** MSI addr[19:12] with dest VCPU ID */ uint64_t msi_addr; /** MSI data[7:0] with vector */ uint64_t msi_data; } __aligned(8); /** * @brief Info to inject a NMI interrupt for a VM */ struct acrn_nmi_entry { /** virtual CPU ID to inject */ uint16_t vcpu_id; /** Reserved */ uint16_t reserved0; /** Reserved */ uint32_t reserved1; } __aligned(8); /** * @brief Info to remap pass-through PCI MSI for a VM * * the parameter for HC_VM_PCI_MSIX_REMAP hypercall */ struct acrn_vm_pci_msix_remap { /** pass-through PCI device virtual BDF# */ uint16_t virt_bdf; /** pass-through PCI device physical BDF# */ uint16_t phys_bdf; /** pass-through PCI device MSI/MSI-X cap control data */ uint16_t msi_ctl; /** reserved for alignment padding */ uint16_t reserved; /** pass-through PCI device MSI address to remap, which will * return the caller after remapping */ uint64_t msi_addr; /* IN/OUT: msi address to fix */ /** pass-through PCI device MSI data to remap, which will * return the caller after remapping */ uint32_t msi_data; /** pass-through PCI device is MSI or MSI-X * 0 - MSI, 1 - MSI-X */ int32_t msix; /** if the pass-through PCI device is MSI-X, this field contains * the MSI-X entry table index */ uint32_t msix_entry_index; /** if the pass-through PCI device is MSI-X, this field contains * Vector Control for MSI-X Entry, field defined in MSI-X spec */ uint32_t vector_ctl; } __aligned(8); /** * @brief Info The power state data of a VCPU. * */ #define SPACE_SYSTEM_MEMORY 0U #define SPACE_SYSTEM_IO 1U #define SPACE_PCI_CONFIG 2U #define SPACE_Embedded_Control 3U #define SPACE_SMBUS 4U #define SPACE_PLATFORM_COMM 10U #define SPACE_FFixedHW 0x7FU struct acpi_generic_address { uint8_t space_id; uint8_t bit_width; uint8_t bit_offset; uint8_t access_size; uint64_t address; } __aligned(8); struct cpu_cx_data { struct acpi_generic_address cx_reg; uint8_t type; uint32_t latency; uint64_t power; } __aligned(8); struct cpu_px_data { uint64_t core_frequency; /* megahertz */ uint64_t power; /* milliWatts */ uint64_t transition_latency; /* microseconds */ uint64_t bus_master_latency; /* microseconds */ uint64_t control; /* control value */ uint64_t status; /* success indicator */ } __aligned(8); struct acpi_sx_pkg { uint8_t val_pm1a; uint8_t val_pm1b; uint16_t reserved; } __aligned(8); struct pm_s_state_data { struct acpi_generic_address pm1a_evt; struct acpi_generic_address pm1b_evt; struct acpi_generic_address pm1a_cnt; struct acpi_generic_address pm1b_cnt; struct acpi_sx_pkg s3_pkg; struct acpi_sx_pkg s5_pkg; uint32_t *wake_vector_32; uint64_t *wake_vector_64; } __aligned(8); /** * @brief Info PM command from DM/VHM. * * The command would specify request type(e.g. get px count or data) for * specific VM and specific VCPU with specific state number. * For Px, PMCMD_STATE_NUM means Px number from 0 to (MAX_PSTATE - 1), * For Cx, PMCMD_STATE_NUM means Cx entry index from 1 to MAX_CX_ENTRY. */ #define PMCMD_VMID_MASK 0xff000000U #define PMCMD_VCPUID_MASK 0x00ff0000U #define PMCMD_STATE_NUM_MASK 0x0000ff00U #define PMCMD_TYPE_MASK 0x000000ffU #define PMCMD_VMID_SHIFT 24U #define PMCMD_VCPUID_SHIFT 16U #define PMCMD_STATE_NUM_SHIFT 8U enum pm_cmd_type { PMCMD_GET_PX_CNT, PMCMD_GET_PX_DATA, PMCMD_GET_CX_CNT, PMCMD_GET_CX_DATA, }; /** * @brief Info to get a VM interrupt count data * * the parameter for HC_VM_INTR_MONITOR hypercall */ #define MAX_PTDEV_NUM 24U struct acrn_intr_monitor { /** sub command for intr monitor */ uint32_t cmd; /** the count of this buffer to save */ uint32_t buf_cnt; /** the buffer which save each interrupt count */ uint64_t buffer[MAX_PTDEV_NUM * 2]; } __aligned(8); /** cmd for intr monitor **/ #define INTR_CMD_GET_DATA 0U #define INTR_CMD_DELAY_INT 1U /** * @} */ #endif /* ACRN_COMMON_H */
lirui34/acrn-hypervisor
hypervisor/include/arch/x86/abl_seed_parse.h
<reponame>lirui34/acrn-hypervisor /* * Copyright (C) 2018 Intel Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef ABL_SEED_PARSE_H_ #define ABL_SEED_PARSE_H_ bool abl_seed_parse(char *cmdline, char *out_arg, uint32_t out_len); #endif /* ABL_SEED_PARSE_H_ */
lirui34/acrn-hypervisor
hypervisor/include/arch/x86/sbl_seed_parse.h
<reponame>lirui34/acrn-hypervisor /* * Copyright (C) 2018 Intel Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef SBL_SEED_PARSE_H_ #define SBL_SEED_PARSE_H_ bool sbl_seed_parse(bool vm_is_sos, char *cmdline, char *out_arg, uint32_t out_len); #endif /* SBL_SEED_PARSE_H_ */
Leont/rakudo
t/04-nativecall/07-writebarrier.c
<reponame>Leont/rakudo #include <stdlib.h> #include <string.h> #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif typedef struct { long *ptr; } Structy; static Structy *saved = NULL; DLLEXPORT long _deref(long *ptr) { return *ptr; } DLLEXPORT long *make_ptr() { long *ptr = (long *) malloc(sizeof(long)); *ptr = 32; return ptr; } DLLEXPORT void struct_twiddle(Structy *s) { s->ptr = (long *) malloc(sizeof(long)); *(s->ptr) = 9; } DLLEXPORT void array_twiddle(long **arr) { arr[0] = (long *) malloc(sizeof(long)); arr[1] = (long *) malloc(sizeof(long)); arr[2] = (long *) malloc(sizeof(long)); *arr[0] = 1; *arr[1] = 2; *arr[2] = 3; } DLLEXPORT void dummy(void **arr) { /* dummy */ } DLLEXPORT void save_ref(Structy *s) { saved = s; } DLLEXPORT void atadistance(void) { saved->ptr = (long *) malloc(sizeof(long)); *(saved->ptr) = 42; }
Leont/rakudo
t/04-nativecall/12-sizeof.c
#ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif typedef struct { char foo1; int foo2; short foo3; short foo4; } Foo; typedef struct { char bar1; short bar2; char bar3; int bar4; short bar5; } Bar; typedef struct { char bar1; short bar2; char bar3; int bar4; short bar5; long baz6; int bar7; } Baz; typedef struct { char buz1; } Buz; DLLEXPORT int SizeofFoo() { return sizeof(Foo); } DLLEXPORT int SizeofBar() { return sizeof(Bar); } DLLEXPORT int SizeofBaz() { return sizeof(Baz); } DLLEXPORT int SizeofBuz() { return sizeof(Buz); } DLLEXPORT int SizeofInt() { return sizeof(int); } DLLEXPORT int SizeofLng() { return sizeof(long); } DLLEXPORT int SizeofPtr() { return sizeof(void *); }
Leont/rakudo
t/04-nativecall/10-cglobals.c
#include <stdio.h> #include <string.h> #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif DLLEXPORT int GlobalInt; int GlobalInt = 101; DLLEXPORT short GlobalShort; short GlobalShort = 102; DLLEXPORT char GlobalByte; char GlobalByte = -103; DLLEXPORT double GlobalDouble; double GlobalDouble = 99.9; DLLEXPORT float GlobalFloat; float GlobalFloat = (float)-4.5; DLLEXPORT char * GlobalString; char * GlobalString = "epic cuteness"; DLLEXPORT char * GlobalNullString; char * GlobalNullString = NULL;
Leont/rakudo
t/04-nativecall/15-rw-args.c
<filename>t/04-nativecall/15-rw-args.c #ifdef _WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif DLLEXPORT void SetChar(signed char *chr) { *chr = 97; } DLLEXPORT void SetShort(short *sht) { *sht = 387; } DLLEXPORT void SetLong(long *lng) { *lng = 777; } DLLEXPORT void SetLongLong(long long *llg) { *llg = 15324; } DLLEXPORT void SetFloat(float *flt) { *flt = 6.66; } DLLEXPORT void SetDouble(double *dbl) { *dbl = 12.12; } DLLEXPORT void SetUChar(unsigned char *chr) { *chr = 153; } DLLEXPORT void SetUShort(unsigned short *sht) { *sht = 387; } DLLEXPORT void SetULong(unsigned long *lng) { *lng = 777; } DLLEXPORT void SetULongLong(unsigned long long *llg) { *llg = 15324; }
Leont/rakudo
t/04-nativecall/04-pointers.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #ifdef WIN32 #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT extern #endif DLLEXPORT void * ReturnSomePointer() { return strdup("Got passed back the pointer I returned"); } DLLEXPORT int CompareSomePointer(void *ptr) { int x = strcmp("Got passed back the pointer I returned", ptr) == 0; free(ptr); return x; } DLLEXPORT void * ReturnNullPointer() { return NULL; } DLLEXPORT void * TakeTwoPointersToInt(int *ptr1, int *ptr2) { return NULL; } DLLEXPORT void * TakeCArrayToInt8(int array[]) { return NULL; }
Nakazona/operating_systems
ps.c
<reponame>Nakazona/operating_systems<filename>ps.c #ifdef CS333_P2 #include "types.h" #include "user.h" #include "uproc.h" int main(void) { struct uproc * table; int max = 30; int ret; table = malloc(sizeof(struct uproc)* max); ret = getprocs(max, table); printf(1, "\nPID\tName\t\tUID\tGID\tPPID\tElapsed\tCPU\tState\tSize\n"); for(int i = 0; i < ret && i < 64; ++i) { int el_remainder = table[i].elapsed_ticks % 1000; int elapsed = table[i].elapsed_ticks / 1000; char *el_char; if(el_remainder < 10) el_char = "00"; else if(el_remainder < 100) el_char = "0"; else el_char = ""; int cpu_remainder = table[i].CPU_total_ticks % 1000; int cpu_total = table[i].CPU_total_ticks / 1000; char *cpu_char; if(cpu_remainder == 0) cpu_char = "000"; else if(cpu_remainder < 10) cpu_char = "00"; else if(cpu_remainder < 100) cpu_char = "0"; else cpu_char = ""; printf(1, "%d\t%s\t\t%d\t%d\t%d\t%d.%s%d\t%d.%s%d\t%s\t%d\t\n", table[i].pid, table[i].name, table[i].uid, table[i].gid, table[i].ppid, elapsed, el_char, el_remainder, cpu_total, cpu_char, cpu_remainder, table[i].state, table[i].size); } free(table); exit(); } #endif
Nakazona/operating_systems
time.c
<reponame>Nakazona/operating_systems #ifdef CS333_P2 #include "types.h" #include "user.h" int main(int argc, char *argv[]) { --argc; if(argc >= 1) { int to_combine = argc; char * a; char * b; b = malloc(sizeof(argv[to_combine])); int size = strlen(argv[to_combine]); int i = 0; while(i < size) { b[i] = argv[to_combine][i]; ++i; } --to_combine; while(to_combine != 1) { a = malloc(sizeof(b)+sizeof(argv[to_combine])+sizeof(char)); size = strlen(b); i = 0; while(i < size) { a[i] = b[i]; ++i; } int v_size = strlen(argv[to_combine]); a[i] = ' '; ++i; while((i-size)-1 < v_size) { a[i] = argv[to_combine][i]; ++i; } free(b); b = malloc(sizeof(a)); strcpy(b, a); free(a); --to_combine; } uint start_ticks = uptime(); exec(argv[1], &b); uint end_ticks = uptime(); uint total_ticks = end_ticks - start_ticks; int remainder = total_ticks % 1000; int elapsed = total_ticks / 1000; char *el_char; if(remainder < 10) el_char = "0"; else el_char = ""; printf(1, "%s ran in %d.%s%d seconds\n", argv[1], elapsed, el_char, remainder); } else { char ** args = malloc(sizeof(char**)); uint start_ticks = uptime(); exec(argv[1], args); uint end_ticks = uptime(); uint total_ticks = end_ticks - start_ticks; int remainder = total_ticks % 1000; int elapsed = total_ticks / 1000; char *el_char; if(remainder < 10) el_char = "0"; else el_char = ""; printf(1, "%s ran in %d.%s%d seconds\n", argv[0], elapsed, el_char, remainder); } exit(); } #endif
zhaoruic-intel/pytorch
aten/src/ATen/cpu/vec/vec256/functional.h
<gh_stars>1-10 #pragma once #include <ATen/cpu/vec/vec256/functional_base.h> #if !defined(__VSX__) || !defined(CPU_CAPABILITY_VSX) #include <ATen/cpu/vec/vec256/functional_bfloat16.h> #endif
snosov1/opencv
3rdparty/libwebp/utils/huffman_encode.c
<filename>3rdparty/libwebp/utils/huffman_encode.c // Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Author: <NAME> (<EMAIL>) // // Entropy encoding (Huffman) for webp lossless. #include <assert.h> #include <stdlib.h> #include <string.h> #include "./huffman_encode.h" #include "../utils/utils.h" #include "../webp/format_constants.h" // ----------------------------------------------------------------------------- // Util function to optimize the symbol map for RLE coding // Heuristics for selecting the stride ranges to collapse. static int ValuesShouldBeCollapsedToStrideAverage(int a, int b) { return abs(a - b) < 4; } // Change the population counts in a way that the consequent // Hufmann tree compression, especially its RLE-part, give smaller output. static int OptimizeHuffmanForRle(int length, int* const counts) { uint8_t* good_for_rle; // 1) Let's make the Huffman code more compatible with rle encoding. int i; for (; length >= 0; --length) { if (length == 0) { return 1; // All zeros. } if (counts[length - 1] != 0) { // Now counts[0..length - 1] does not have trailing zeros. break; } } // 2) Let's mark all population counts that already can be encoded // with an rle code. good_for_rle = (uint8_t*)calloc(length, 1); if (good_for_rle == NULL) { return 0; } { // Let's not spoil any of the existing good rle codes. // Mark any seq of 0's that is longer as 5 as a good_for_rle. // Mark any seq of non-0's that is longer as 7 as a good_for_rle. int symbol = counts[0]; int stride = 0; for (i = 0; i < length + 1; ++i) { if (i == length || counts[i] != symbol) { if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) { int k; for (k = 0; k < stride; ++k) { good_for_rle[i - k - 1] = 1; } } stride = 1; if (i != length) { symbol = counts[i]; } } else { ++stride; } } } // 3) Let's replace those population counts that lead to more rle codes. { int stride = 0; int limit = counts[0]; int sum = 0; for (i = 0; i < length + 1; ++i) { if (i == length || good_for_rle[i] || (i != 0 && good_for_rle[i - 1]) || !ValuesShouldBeCollapsedToStrideAverage(counts[i], limit)) { if (stride >= 4 || (stride >= 3 && sum == 0)) { int k; // The stride must end, collapse what we have, if we have enough (4). int count = (sum + stride / 2) / stride; if (count < 1) { count = 1; } if (sum == 0) { // Don't make an all zeros stride to be upgraded to ones. count = 0; } for (k = 0; k < stride; ++k) { // We don't want to change value at counts[i], // that is already belonging to the next stride. Thus - 1. counts[i - k - 1] = count; } } stride = 0; sum = 0; if (i < length - 3) { // All interesting strides have a count of at least 4, // at least when non-zeros. limit = (counts[i] + counts[i + 1] + counts[i + 2] + counts[i + 3] + 2) / 4; } else if (i < length) { limit = counts[i]; } else { limit = 0; } } ++stride; if (i != length) { sum += counts[i]; if (stride >= 4) { limit = (sum + stride / 2) / stride; } } } } free(good_for_rle); return 1; } typedef struct { int total_count_; int value_; int pool_index_left_; int pool_index_right_; } HuffmanTree; // A comparer function for two Huffman trees: sorts first by 'total count' // (more comes first), and then by 'value' (more comes first). static int CompareHuffmanTrees(const void* ptr1, const void* ptr2) { const HuffmanTree* const t1 = (const HuffmanTree*)ptr1; const HuffmanTree* const t2 = (const HuffmanTree*)ptr2; if (t1->total_count_ > t2->total_count_) { return -1; } else if (t1->total_count_ < t2->total_count_) { return 1; } else { assert(t1->value_ != t2->value_); return (t1->value_ < t2->value_) ? -1 : 1; } } static void SetBitDepths(const HuffmanTree* const tree, const HuffmanTree* const pool, uint8_t* const bit_depths, int level) { if (tree->pool_index_left_ >= 0) { SetBitDepths(&pool[tree->pool_index_left_], pool, bit_depths, level + 1); SetBitDepths(&pool[tree->pool_index_right_], pool, bit_depths, level + 1); } else { bit_depths[tree->value_] = level; } } // Create an optimal Huffman tree. // // (data,length): population counts. // tree_limit: maximum bit depth (inclusive) of the codes. // bit_depths[]: how many bits are used for the symbol. // // Returns 0 when an error has occurred. // // The catch here is that the tree cannot be arbitrarily deep // // count_limit is the value that is to be faked as the minimum value // and this minimum value is raised until the tree matches the // maximum length requirement. // // This algorithm is not of excellent performance for very long data blocks, // especially when population counts are longer than 2**tree_limit, but // we are not planning to use this with extremely long blocks. // // See http://en.wikipedia.org/wiki/Huffman_coding static int GenerateOptimalTree(const int* const histogram, int histogram_size, int tree_depth_limit, uint8_t* const bit_depths) { int count_min; HuffmanTree* tree_pool; HuffmanTree* tree; int tree_size_orig = 0; int i; for (i = 0; i < histogram_size; ++i) { if (histogram[i] != 0) { ++tree_size_orig; } } if (tree_size_orig == 0) { // pretty optimal already! return 1; } // 3 * tree_size is enough to cover all the nodes representing a // population and all the inserted nodes combining two existing nodes. // The tree pool needs 2 * (tree_size_orig - 1) entities, and the // tree needs exactly tree_size_orig entities. tree = (HuffmanTree*)WebPSafeMalloc(3ULL * tree_size_orig, sizeof(*tree)); if (tree == NULL) return 0; tree_pool = tree + tree_size_orig; // For block sizes with less than 64k symbols we never need to do a // second iteration of this loop. // If we actually start running inside this loop a lot, we would perhaps // be better off with the Katajainen algorithm. assert(tree_size_orig <= (1 << (tree_depth_limit - 1))); for (count_min = 1; ; count_min *= 2) { int tree_size = tree_size_orig; // We need to pack the Huffman tree in tree_depth_limit bits. // So, we try by faking histogram entries to be at least 'count_min'. int idx = 0; int j; for (j = 0; j < histogram_size; ++j) { if (histogram[j] != 0) { const int count = (histogram[j] < count_min) ? count_min : histogram[j]; tree[idx].total_count_ = count; tree[idx].value_ = j; tree[idx].pool_index_left_ = -1; tree[idx].pool_index_right_ = -1; ++idx; } } // Build the Huffman tree. qsort(tree, tree_size, sizeof(*tree), CompareHuffmanTrees); if (tree_size > 1) { // Normal case. int tree_pool_size = 0; while (tree_size > 1) { // Finish when we have only one root. int count; tree_pool[tree_pool_size++] = tree[tree_size - 1]; tree_pool[tree_pool_size++] = tree[tree_size - 2]; count = tree_pool[tree_pool_size - 1].total_count_ + tree_pool[tree_pool_size - 2].total_count_; tree_size -= 2; { // Search for the insertion point. int k; for (k = 0; k < tree_size; ++k) { if (tree[k].total_count_ <= count) { break; } } memmove(tree + (k + 1), tree + k, (tree_size - k) * sizeof(*tree)); tree[k].total_count_ = count; tree[k].value_ = -1; tree[k].pool_index_left_ = tree_pool_size - 1; tree[k].pool_index_right_ = tree_pool_size - 2; tree_size = tree_size + 1; } } SetBitDepths(&tree[0], tree_pool, bit_depths, 0); } else if (tree_size == 1) { // Trivial case: only one element. bit_depths[tree[0].value_] = 1; } { // Test if this Huffman tree satisfies our 'tree_depth_limit' criteria. int max_depth = bit_depths[0]; for (j = 1; j < histogram_size; ++j) { if (max_depth < bit_depths[j]) { max_depth = bit_depths[j]; } } if (max_depth <= tree_depth_limit) { break; } } } free(tree); return 1; } // ----------------------------------------------------------------------------- // Coding of the Huffman tree values static HuffmanTreeToken* CodeRepeatedValues(int repetitions, HuffmanTreeToken* tokens, int value, int prev_value) { assert(value <= MAX_ALLOWED_CODE_LENGTH); if (value != prev_value) { tokens->code = value; tokens->extra_bits = 0; ++tokens; --repetitions; } while (repetitions >= 1) { if (repetitions < 3) { int i; for (i = 0; i < repetitions; ++i) { tokens->code = value; tokens->extra_bits = 0; ++tokens; } break; } else if (repetitions < 7) { tokens->code = 16; tokens->extra_bits = repetitions - 3; ++tokens; break; } else { tokens->code = 16; tokens->extra_bits = 3; ++tokens; repetitions -= 6; } } return tokens; } static HuffmanTreeToken* CodeRepeatedZeros(int repetitions, HuffmanTreeToken* tokens) { while (repetitions >= 1) { if (repetitions < 3) { int i; for (i = 0; i < repetitions; ++i) { tokens->code = 0; // 0-value tokens->extra_bits = 0; ++tokens; } break; } else if (repetitions < 11) { tokens->code = 17; tokens->extra_bits = repetitions - 3; ++tokens; break; } else if (repetitions < 139) { tokens->code = 18; tokens->extra_bits = repetitions - 11; ++tokens; break; } else { tokens->code = 18; tokens->extra_bits = 0x7f; // 138 repeated 0s ++tokens; repetitions -= 138; } } return tokens; } int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree, HuffmanTreeToken* tokens, int max_tokens) { HuffmanTreeToken* const starting_token = tokens; HuffmanTreeToken* const ending_token = tokens + max_tokens; const int depth_size = tree->num_symbols; int prev_value = 8; // 8 is the initial value for rle. int i = 0; assert(tokens != NULL); while (i < depth_size) { const int value = tree->code_lengths[i]; int k = i + 1; int runs; while (k < depth_size && tree->code_lengths[k] == value) ++k; runs = k - i; if (value == 0) { tokens = CodeRepeatedZeros(runs, tokens); } else { tokens = CodeRepeatedValues(runs, tokens, value, prev_value); prev_value = value; } i += runs; assert(tokens <= ending_token); } (void)ending_token; // suppress 'unused variable' warning return (int)(tokens - starting_token); } // ----------------------------------------------------------------------------- // Pre-reversed 4-bit values. static const uint8_t kReversedBits[16] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf }; static uint32_t ReverseBits(int num_bits, uint32_t bits) { uint32_t retval = 0; int i = 0; while (i < num_bits) { i += 4; retval |= kReversedBits[bits & 0xf] << (MAX_ALLOWED_CODE_LENGTH + 1 - i); bits >>= 4; } retval >>= (MAX_ALLOWED_CODE_LENGTH + 1 - num_bits); return retval; } // Get the actual bit values for a tree of bit depths. static void ConvertBitDepthsToSymbols(HuffmanTreeCode* const tree) { // 0 bit-depth means that the symbol does not exist. int i; int len; uint32_t next_code[MAX_ALLOWED_CODE_LENGTH + 1]; int depth_count[MAX_ALLOWED_CODE_LENGTH + 1] = { 0 }; assert(tree != NULL); len = tree->num_symbols; for (i = 0; i < len; ++i) { const int code_length = tree->code_lengths[i]; assert(code_length <= MAX_ALLOWED_CODE_LENGTH); ++depth_count[code_length]; } depth_count[0] = 0; // ignore unused symbol next_code[0] = 0; { uint32_t code = 0; for (i = 1; i <= MAX_ALLOWED_CODE_LENGTH; ++i) { code = (code + depth_count[i - 1]) << 1; next_code[i] = code; } } for (i = 0; i < len; ++i) { const int code_length = tree->code_lengths[i]; tree->codes[i] = ReverseBits(code_length, next_code[code_length]++); } } // ----------------------------------------------------------------------------- // Main entry point int VP8LCreateHuffmanTree(int* const histogram, int tree_depth_limit, HuffmanTreeCode* const tree) { const int num_symbols = tree->num_symbols; if (!OptimizeHuffmanForRle(num_symbols, histogram)) { return 0; } if (!GenerateOptimalTree(histogram, num_symbols, tree_depth_limit, tree->code_lengths)) { return 0; } // Create the actual bit codes for the bit lengths. ConvertBitDepthsToSymbols(tree); return 1; }
snosov1/opencv
3rdparty/libwebp/dec/layer.c
<filename>3rdparty/libwebp/dec/layer.c // Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Enhancement layer (for YUV444/422) // // Author: Skal (<EMAIL>) #include <assert.h> #include <stdlib.h> #include "./vp8i.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif //------------------------------------------------------------------------------ int VP8DecodeLayer(VP8Decoder* const dec) { assert(dec); assert(dec->layer_data_size_ > 0); (void)dec; // TODO: handle enhancement layer here. return 1; } #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif
snosov1/opencv
3rdparty/libwebp/dsp/cpu.c
<reponame>snosov1/opencv // Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // CPU detection // // Author: <NAME> (<EMAIL>) #include "./dsp.h" #if defined(__ANDROID__) #include <cpu-features.h> #endif #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif //------------------------------------------------------------------------------ // SSE2 detection. // // apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC. #if (defined(__pic__) || defined(__PIC__)) && defined(__i386__) static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) { __asm__ volatile ( "mov %%ebx, %%edi\n" "cpuid\n" "xchg %%edi, %%ebx\n" : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "a"(info_type)); } #elif defined(__i386__) || defined(__x86_64__) static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) { __asm__ volatile ( "cpuid\n" : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "a"(info_type)); } #elif defined(WEBP_MSC_SSE2) #define GetCPUInfo __cpuid #endif #if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2) static int x86CPUInfo(CPUFeature feature) { int cpu_info[4]; GetCPUInfo(cpu_info, 1); if (feature == kSSE2) { return 0 != (cpu_info[3] & 0x04000000); } if (feature == kSSE3) { return 0 != (cpu_info[2] & 0x00000001); } return 0; } VP8CPUInfo VP8GetCPUInfo = x86CPUInfo; #elif defined(WEBP_ANDROID_NEON) static int AndroidCPUInfo(CPUFeature feature) { const AndroidCpuFamily cpu_family = android_getCpuFamily(); const uint64_t cpu_features = android_getCpuFeatures(); if (feature == kNEON) { return (cpu_family == ANDROID_CPU_FAMILY_ARM && 0 != (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON)); } return 0; } VP8CPUInfo VP8GetCPUInfo = AndroidCPUInfo; #elif defined(__ARM_NEON__) // define a dummy function to enable turning off NEON at runtime by setting // VP8DecGetCPUInfo = NULL static int armCPUInfo(CPUFeature feature) { (void)feature; return 1; } VP8CPUInfo VP8GetCPUInfo = armCPUInfo; #else VP8CPUInfo VP8GetCPUInfo = NULL; #endif #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif
snosov1/opencv
3rdparty/tbb/android_additional.h
#include <cstdio> static inline int getPossibleCPUs() { FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r"); if(!cpuPossible) return 1; char buf[2000]; //big enough for 1000 CPUs in worst possible configuration char* pbuf = fgets(buf, sizeof(buf), cpuPossible); fclose(cpuPossible); if(!pbuf) return 1; //parse string of form "0-1,3,5-7,10,13-15" int cpusAvailable = 0; while(*pbuf) { const char* pos = pbuf; bool range = false; while(*pbuf && *pbuf != ',') { if(*pbuf == '-') range = true; ++pbuf; } if(*pbuf) *pbuf++ = 0; if(!range) ++cpusAvailable; else { int rstart = 0, rend = 0; sscanf(pos, "%d-%d", &rstart, &rend); cpusAvailable += rend - rstart + 1; } } return cpusAvailable ? cpusAvailable : 1; } #define __TBB_HardwareConcurrency() getPossibleCPUs()
snosov1/opencv
3rdparty/include/dshow/evcode.h
#ifndef _EVCODE_H #define _EVCODE_H #if __GNUC__ >=3 #pragma GCC system_header #endif #ifdef __cplusplus extern "C" { #endif /*--- DirectShow Reference - Constants and GUIDs - Event Notification Codes */ #define EC_ACTIVATE 0x0013 #define EC_BUFFERING_DATA 0x0011 #define EC_BUILT 0x0300 #define EC_CLOCK_CHANGED 0x000D #define EC_CLOCK_UNSET 0x0051 #define EC_CODECAPI_EVENT 0x0057 #define EC_COMPLETE 0x0001 #define EC_DEVICE_LOST 0x001F #define EC_DISPLAY_CHANGED 0x0016 #define EC_END_OF_SEGMENT 0x001C #define EC_ERROR_STILLPLAYING 0x0008 #define EC_ERRORABORT 0x0003 #define EC_EXTDEVICE_MODE_CHANGE 0x0031 #define EC_FULLSCREEN_LOST 0x0012 #define EC_GRAPH_CHANGED 0x0050 #define EC_LENGTH_CHANGED 0x001E #define EC_NEED_RESTART 0x0014 #define EC_NOTIFY_WINDOW 0x0019 #define EC_OLE_EVENT 0x0018 #define EC_OPENING_FILE 0x0010 #define EC_PALETTE_CHANGED 0x0009 #define EC_PAUSED 0x000E #define EC_PREPROCESS_COMPLETE 0x0056 #define EC_QUALITY_CHANGE 0x000B #define EC_REPAINT 0x0005 #define EC_SEGMENT_STARTED 0x001D #define EC_SHUTTING_DOWN 0x000C #define EC_SNDDEV_IN_ERROR 0x0200 #define EC_SNDDEV_OUT_ERROR 0x0201 #define EC_STARVATION 0x0017 #define EC_STATE_CHANGE 0x0032 #define EC_STEP_COMPLETE 0x0024 #define EC_STREAM_CONTROL_STARTED 0x001B #define EC_STREAM_CONTROL_STOPPED 0x001A #define EC_STREAM_ERROR_STILLPLAYING 0x0007 #define EC_STREAM_ERROR_STOPPED 0x0006 #define EC_TIMECODE_AVAILABLE 0x0030 #define EC_UNBUILT 0x0301 #define EC_USERABORT 0x0002 #define EC_VIDEO_SIZE_CHANGED 0x000A #define EC_VMR_RENDERDEVICE_SET 0x0053 #define EC_VMR_SURFACE_FLIPPED 0x0054 #define EC_VMR_RECONNECTION_FAILED 0x0055 #define EC_WINDOW_DESTROYED 0x0015 #define EC_WMT_EVENT 0x0252 #define EC_WMT_INDEX_EVENT 0x0251 #define EC_USER 0x8000 /*--- DirectShow Reference - DirectShow Structures */ typedef struct { HRESULT hrStatus; void *pData; } AM_WMT_EVENT_DATA; #ifdef __cplusplus } #endif #endif
snosov1/opencv
3rdparty/libwebp/utils/quant_levels_dec.c
<reponame>snosov1/opencv<gh_stars>100-1000 // Copyright 2013 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // TODO(skal): implement gradient smoothing. // // Author: Skal (<EMAIL>) #include "./quant_levels_dec.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif int DequantizeLevels(uint8_t* const data, int width, int height) { if (data == NULL || width <= 0 || height <= 0) return 0; (void)data; (void)width; (void)height; return 1; } #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif
snosov1/opencv
3rdparty/openexr/IlmImf/ImfRational.h
<gh_stars>100-1000 /////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2006, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// #ifndef INCLUDED_IMF_RATIONAL_H #define INCLUDED_IMF_RATIONAL_H //----------------------------------------------------------------------------- // // Rational numbers // // A rational number is represented as pair of integers, n and d. // The value of of the rational number is // // n/d for d > 0 // positive infinity for n > 0, d == 0 // negative infinity for n < 0, d == 0 // not a number (NaN) for n == 0, d == 0 // //----------------------------------------------------------------------------- namespace Imf { class Rational { public: int n; // numerator unsigned int d; // denominator //---------------------------------------- // Default constructor, sets value to zero //---------------------------------------- Rational (): n (0), d (1) {} //------------------------------------- // Constructor, explicitly sets n and d //------------------------------------- Rational (int _n, int _d): n (_n), d (_d) {} //---------------------------- // Constructor, approximates x //---------------------------- explicit Rational (double x); //--------------------------------- // Approximate conversion to double //--------------------------------- operator double () const {return double (n) / double (d);} }; } // namespace Imf #endif
snosov1/opencv
modules/calib3d/src/rho.h
/* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By downloading, copying, installing or using the software you agree to this license. If you do not agree to this license, do not download, install, copy or use the software. BSD 3-Clause License Copyright (C) 2014, <NAME>, <NAME> & <NAME>, all rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistribution's of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistribution's in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name of the copyright holders may not be used to endorse or promote products derived from this software without specific prior written permission. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the Intel Corporation or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. */ /** * Bilaniuk, Olexa, <NAME>, and <NAME>. "Fast Target * Recognition on Mobile Devices: Revisiting Gaussian Elimination for the * Estimation of Planar Homographies." In Computer Vision and Pattern * Recognition Workshops (CVPRW), 2014 IEEE Conference on, pp. 119-125. * IEEE, 2014. */ /* Include Guards */ #ifndef __OPENCV_RHO_H__ #define __OPENCV_RHO_H__ /* Includes */ #include <opencv2/core.hpp> #include <stdint.h> /* Defines */ /* Flags */ #ifndef RHO_FLAG_NONE #define RHO_FLAG_NONE (0U<<0) #endif #ifndef RHO_FLAG_ENABLE_NR #define RHO_FLAG_ENABLE_NR (1U<<0) #endif #ifndef RHO_FLAG_ENABLE_REFINEMENT #define RHO_FLAG_ENABLE_REFINEMENT (1U<<1) #endif #ifndef RHO_FLAG_ENABLE_FINAL_REFINEMENT #define RHO_FLAG_ENABLE_FINAL_REFINEMENT (1U<<2) #endif /* Namespace cv */ namespace cv{ /* Data structures */ /** * Homography Estimation context. */ struct RHO_HEST; typedef struct RHO_HEST RHO_HEST; /* Functions */ /** * Initialize the estimator context, by allocating the aligned buffers * internally needed. * * @return A pointer to the context if successful; NULL if an error occured. */ Ptr<RHO_HEST> rhoInit(void); /** * Ensure that the estimator context's internal table for non-randomness * criterion is at least of the given size, and uses the given beta. The table * should be larger than the maximum number of matches fed into the estimator. * * A value of N of 0 requests deallocation of the table. * * @param [in] p The initialized estimator context * @param [in] N If 0, deallocate internal table. If > 0, ensure that the * internal table is of at least this size, reallocating if * necessary. * @param [in] beta The beta-factor to use within the table. * @return 0 if unsuccessful; non-zero otherwise. */ int rhoEnsureCapacity(Ptr<RHO_HEST> p, unsigned N, double beta); /** * Seeds the internal PRNG with the given seed. * * Although it is not required to call this function, since context * initialization seeds itself with entropy from rand(), this function allows * reproducible results by using a specified seed. * * @param [in] p The estimator context whose PRNG is to be seeded. * @param [in] seed The 64-bit integer seed. */ void rhoSeed(Ptr<RHO_HEST> p, uint64_t seed); /** * Estimates the homography using the given context, matches and parameters to * PROSAC. * * The given context must have been initialized. * * The matches are provided as two arrays of N single-precision, floating-point * (x,y) points. Points with corresponding offsets in the two arrays constitute * a match. The homography estimation attempts to find the 3x3 matrix H which * best maps the homogeneous-coordinate points in the source array to their * corresponding homogeneous-coordinate points in the destination array. * * Note: At least 4 matches must be provided (N >= 4). * Note: A point in either array takes up 2 floats. The first of two stores * the x-coordinate and the second of the two stores the y-coordinate. * Thus, the arrays resemble this in memory: * * src = [x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, ...] * Matches: | | | | | * dst = [x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, ...] * Note: The matches are expected to be provided sorted by quality, or at * least not be worse-than-random in ordering. * * A pointer to the base of an array of N bytes can be provided. It serves as * an output mask to indicate whether the corresponding match is an inlier to * the returned homography, if any. A zero indicates an outlier; A non-zero * value indicates an inlier. * * The PROSAC estimator requires a few parameters of its own. These are: * * - The maximum distance that a source point projected onto the destination * plane can be from its putative match and still be considered an * inlier. Must be non-negative. * A sane default is 3.0. * - The maximum number of PROSAC iterations. This corresponds to the * largest number of samples that will be drawn and tested. * A sane default is 2000. * - The RANSAC convergence parameter. This corresponds to the number of * iterations after which PROSAC will start sampling like RANSAC. * A sane default is 2000. * - The confidence threshold. This corresponds to the probability of * finding a correct solution. Must be bounded by [0, 1]. * A sane default is 0.995. * - The minimum number of inliers acceptable. Only a solution with at * least this many inliers will be returned. The minimum is 4. * A sane default is 10% of N. * - The beta-parameter for the non-randomness termination criterion. * Ignored if non-randomness criterion disabled, otherwise must be * bounded by (0, 1). * A sane default is 0.35. * - Optional flags to control the estimation. Available flags are: * HEST_FLAG_NONE: * No special processing. * HEST_FLAG_ENABLE_NR: * Enable non-randomness criterion. If set, the beta parameter * must also be set. * HEST_FLAG_ENABLE_REFINEMENT: * Enable refinement of each new best model, as they are found. * HEST_FLAG_ENABLE_FINAL_REFINEMENT: * Enable one final refinement of the best model found before * returning it. * * The PROSAC estimator optionally accepts an extrinsic initial guess of H. * * The PROSAC estimator outputs a final estimate of H provided it was able to * find one with a minimum of supporting inliers. If it was not, it outputs * the all-zero matrix. * * The extrinsic guess at and final estimate of H are both in the same form: * A 3x3 single-precision floating-point matrix with step 3. Thus, it is a * 9-element array of floats, with the elements as follows: * * [ H00, H01, H02, * H10, H11, H12, * H20, H21, 1.0 ] * * Notice that the homography is normalized to H22 = 1.0. * * The function returns the number of inliers if it was able to find a * homography with at least the minimum required support, and 0 if it was not. * * * @param [in/out] p The context to use for homography estimation. Must * be already initialized. Cannot be NULL. * @param [in] src The pointer to the source points of the matches. * Must be aligned to 4 bytes. Cannot be NULL. * @param [in] dst The pointer to the destination points of the matches. * Must be aligned to 4 bytes. Cannot be NULL. * @param [out] inl The pointer to the output mask of inlier matches. * Must be aligned to 4 bytes. May be NULL. * @param [in] N The number of matches. Minimum 4. * @param [in] maxD The maximum distance. Minimum 0. * @param [in] maxI The maximum number of PROSAC iterations. * @param [in] rConvg The RANSAC convergence parameter. * @param [in] cfd The required confidence in the solution. * @param [in] minInl The minimum required number of inliers. Minimum 4. * @param [in] beta The beta-parameter for the non-randomness criterion. * @param [in] flags A union of flags to fine-tune the estimation. * @param [in] guessH An extrinsic guess at the solution H, or NULL if * none provided. * @param [out] finalH The final estimation of H, or the zero matrix if * the minimum number of inliers was not met. * Cannot be NULL. * @return The number of inliers if the minimum number of * inliers for acceptance was reached; 0 otherwise. */ unsigned rhoHest(Ptr<RHO_HEST> p, /* Homography estimation context. */ const float* src, /* Source points */ const float* dst, /* Destination points */ char* inl, /* Inlier mask */ unsigned N, /* = src.length = dst.length = inl.length */ float maxD, /* 3.0 */ unsigned maxI, /* 2000 */ unsigned rConvg, /* 2000 */ double cfd, /* 0.995 */ unsigned minInl, /* 4 */ double beta, /* 0.35 */ unsigned flags, /* 0 */ const float* guessH, /* Extrinsic guess, NULL if none provided */ float* finalH); /* Final result. */ /* End Namespace cv */ } #endif
snosov1/opencv
include/opencv/cxmisc.h
<reponame>snosov1/opencv<filename>include/opencv/cxmisc.h<gh_stars>1000+ #ifndef __OPENCV_OLD_CXMISC_H__ #define __OPENCV_OLD_CXMISC_H__ #ifdef __cplusplus # include "opencv2/core/utility.hpp" #endif #endif
snosov1/opencv
include/opencv/cvwimage.h
<reponame>snosov1/opencv /////////////////////////////////////////////////////////////////////////////// // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to // this license. If you do not agree to this license, do not download, // install, copy or use the software. // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2008, Google, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of Intel Corporation or contributors may not be used to endorse // or promote products derived from this software without specific // prior written permission. // // This software is provided by the copyright holders and contributors "as is" // and any express or implied warranties, including, but not limited to, the // implied warranties of merchantability and fitness for a particular purpose // are disclaimed. In no event shall the Intel Corporation or contributors be // liable for any direct, indirect, incidental, special, exemplary, or // consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. #ifndef __OPENCV_OLD_WIMAGE_HPP__ #define __OPENCV_OLD_WIMAGE_HPP__ #include "opencv2/core/wimage.hpp" #endif
snosov1/opencv
samples/cpp/tutorial_code/features2D/AKAZE_tracking/stats.h
#ifndef STATS_H #define STATS_H struct Stats { int matches; int inliers; double ratio; int keypoints; Stats() : matches(0), inliers(0), ratio(0), keypoints(0) {} Stats& operator+=(const Stats& op) { matches += op.matches; inliers += op.inliers; ratio += op.ratio; keypoints += op.keypoints; return *this; } Stats& operator/=(int num) { matches /= num; inliers /= num; ratio /= num; keypoints /= num; return *this; } }; #endif // STATS_H
snosov1/opencv
3rdparty/openexr/IlmImf/ImfAcesFile.h
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2007, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// #ifndef INCLUDED_IMF_ACES_FILE_H #define INCLUDED_IMF_ACES_FILE_H //----------------------------------------------------------------------------- // // ACES image file I/O. // // This header file declares two classes that directly support // image file input and output according to the Academy Image // Interchange Framework. // // The Academy Image Interchange file format is a subset of OpenEXR: // // - Images are stored as scanlines. Tiles are not allowed. // // - Images contain three color channels, either // R, G, B (red, green, blue) or // Y, RY, BY (luminance, sub-sampled chroma) // // - Images may optionally contain an alpha channel. // // - Only three compression types are allowed: // - NO_COMPRESSION (file is not compressed) // - PIZ_COMPRESSION (lossless) // - B44A_COMPRESSION (lossy) // // - The "chromaticities" header attribute must specify // the ACES RGB primaries and white point. // // class AcesOutputFile writes an OpenEXR file, enforcing the // restrictions listed above. Pixel data supplied by application // software must already be in the ACES RGB space. // // class AcesInputFile reads an OpenEXR file. Pixel data delivered // to application software is guaranteed to be in the ACES RGB space. // If the RGB space of the file is not the same as the ACES space, // then the pixels are automatically converted: the pixels are // converted to CIE XYZ, a color adaptation transform shifts the // white point, and the result is converted to ACES RGB. // //----------------------------------------------------------------------------- #include <ImfHeader.h> #include <ImfRgba.h> #include "ImathVec.h" #include "ImathBox.h" #include <ImfThreading.h> #include <string> namespace Imf { class RgbaOutputFile; class RgbaInputFile; struct PreviewRgba; struct Chromaticities; // // ACES red, green, blue and white-point chromaticities. // const Chromaticities & acesChromaticities (); // // ACES output file. // class AcesOutputFile { public: //--------------------------------------------------- // Constructor -- header is constructed by the caller //--------------------------------------------------- AcesOutputFile (const std::string &name, const Header &header, RgbaChannels rgbaChannels = WRITE_RGBA, int numThreads = globalThreadCount()); //---------------------------------------------------- // Constructor -- header is constructed by the caller, // file is opened by the caller, destructor will not // automatically close the file. //---------------------------------------------------- AcesOutputFile (OStream &os, const Header &header, RgbaChannels rgbaChannels = WRITE_RGBA, int numThreads = globalThreadCount()); //---------------------------------------------------------------- // Constructor -- header data are explicitly specified as function // call arguments (empty dataWindow means "same as displayWindow") //---------------------------------------------------------------- AcesOutputFile (const std::string &name, const Imath::Box2i &displayWindow, const Imath::Box2i &dataWindow = Imath::Box2i(), RgbaChannels rgbaChannels = WRITE_RGBA, float pixelAspectRatio = 1, const Imath::V2f screenWindowCenter = Imath::V2f (0, 0), float screenWindowWidth = 1, LineOrder lineOrder = INCREASING_Y, Compression compression = PIZ_COMPRESSION, int numThreads = globalThreadCount()); //----------------------------------------------- // Constructor -- like the previous one, but both // the display window and the data window are // Box2i (V2i (0, 0), V2i (width - 1, height -1)) //----------------------------------------------- AcesOutputFile (const std::string &name, int width, int height, RgbaChannels rgbaChannels = WRITE_RGBA, float pixelAspectRatio = 1, const Imath::V2f screenWindowCenter = Imath::V2f (0, 0), float screenWindowWidth = 1, LineOrder lineOrder = INCREASING_Y, Compression compression = PIZ_COMPRESSION, int numThreads = globalThreadCount()); //----------- // Destructor //----------- virtual ~AcesOutputFile (); //------------------------------------------------ // Define a frame buffer as the pixel data source: // Pixel (x, y) is at address // // base + x * xStride + y * yStride // //------------------------------------------------ void setFrameBuffer (const Rgba *base, size_t xStride, size_t yStride); //------------------------------------------------- // Write pixel data (see class Imf::OutputFile) // The pixels are assumed to contain ACES RGB data. //------------------------------------------------- void writePixels (int numScanLines = 1); int currentScanLine () const; //-------------------------- // Access to the file header //-------------------------- const Header & header () const; const Imath::Box2i & displayWindow () const; const Imath::Box2i & dataWindow () const; float pixelAspectRatio () const; const Imath::V2f screenWindowCenter () const; float screenWindowWidth () const; LineOrder lineOrder () const; Compression compression () const; RgbaChannels channels () const; // -------------------------------------------------------------------- // Update the preview image (see Imf::OutputFile::updatePreviewImage()) // -------------------------------------------------------------------- void updatePreviewImage (const PreviewRgba[]); private: AcesOutputFile (const AcesOutputFile &); // not implemented AcesOutputFile & operator = (const AcesOutputFile &); // not implemented class Data; Data * _data; }; // // ACES input file // class AcesInputFile { public: //------------------------------------------------------- // Constructor -- opens the file with the specified name, // destructor will automatically close the file. //------------------------------------------------------- AcesInputFile (const std::string &name, int numThreads = globalThreadCount()); //----------------------------------------------------------- // Constructor -- attaches the new AcesInputFile object to a // file that has already been opened by the caller. // Destroying the AcesInputFile object will not automatically // close the file. //----------------------------------------------------------- AcesInputFile (IStream &is, int numThreads = globalThreadCount()); //----------- // Destructor //----------- virtual ~AcesInputFile (); //----------------------------------------------------- // Define a frame buffer as the pixel data destination: // Pixel (x, y) is at address // // base + x * xStride + y * yStride // //----------------------------------------------------- void setFrameBuffer (Rgba *base, size_t xStride, size_t yStride); //-------------------------------------------- // Read pixel data (see class Imf::InputFile) // Pixels returned will contain ACES RGB data. //-------------------------------------------- void readPixels (int scanLine1, int scanLine2); void readPixels (int scanLine); //-------------------------- // Access to the file header //-------------------------- const Header & header () const; const Imath::Box2i & displayWindow () const; const Imath::Box2i & dataWindow () const; float pixelAspectRatio () const; const Imath::V2f screenWindowCenter () const; float screenWindowWidth () const; LineOrder lineOrder () const; Compression compression () const; RgbaChannels channels () const; const char * fileName () const; bool isComplete () const; //---------------------------------- // Access to the file format version //---------------------------------- int version () const; private: AcesInputFile (const AcesInputFile &); // not implemented AcesInputFile & operator = (const AcesInputFile &); // not implemented class Data; Data * _data; }; } // namespace Imf #endif
snosov1/opencv
modules/flann/include/opencv2/flann/object_factory.h
/*********************************************************************** * Software License Agreement (BSD License) * * Copyright 2008-2009 <NAME> (<EMAIL>). All rights reserved. * Copyright 2008-2009 <NAME> (<EMAIL>). All rights reserved. * * THE BSD LICENSE * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *************************************************************************/ #ifndef OPENCV_FLANN_OBJECT_FACTORY_H_ #define OPENCV_FLANN_OBJECT_FACTORY_H_ #include <map> namespace cvflann { class CreatorNotFound { }; template<typename BaseClass, typename UniqueIdType, typename ObjectCreator = BaseClass* (*)()> class ObjectFactory { typedef ObjectFactory<BaseClass,UniqueIdType,ObjectCreator> ThisClass; typedef std::map<UniqueIdType, ObjectCreator> ObjectRegistry; // singleton class, private constructor ObjectFactory() {} public: bool subscribe(UniqueIdType id, ObjectCreator creator) { if (object_registry.find(id) != object_registry.end()) return false; object_registry[id] = creator; return true; } bool unregister(UniqueIdType id) { return object_registry.erase(id) == 1; } ObjectCreator create(UniqueIdType id) { typename ObjectRegistry::const_iterator iter = object_registry.find(id); if (iter == object_registry.end()) { throw CreatorNotFound(); } return iter->second; } static ThisClass& instance() { static ThisClass the_factory; return the_factory; } private: ObjectRegistry object_registry; }; } #endif /* OPENCV_FLANN_OBJECT_FACTORY_H_ */
snosov1/opencv
samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/CsvWriter.h
<reponame>snosov1/opencv #ifndef CSVWRITER_H #define CSVWRITER_H #include <iostream> #include <fstream> #include <opencv2/core/core.hpp> #include "Utils.h" using namespace std; using namespace cv; class CsvWriter { public: CsvWriter(const string &path, const string &separator = " "); ~CsvWriter(); void writeXYZ(const vector<Point3f> &list_points3d); void writeUVXYZ(const vector<Point3f> &list_points3d, const vector<Point2f> &list_points2d, const Mat &descriptors); private: ofstream _file; string _separator; bool _isFirstTerm; }; #endif
snosov1/opencv
3rdparty/libjpeg/jconfig.h
#define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR #define HAVE_UNSIGNED_SHORT /* Define this if an ordinary "char" type is unsigned. * If you're not sure, leaving it undefined will work at some cost in speed. * If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal. */ #undef CHAR_IS_UNSIGNED #if defined __MINGW__ || defined __MINGW32__ || (!defined WIN32 && !defined _WIN32) /* Define this if your system has an ANSI-conforming <stddef.h> file. */ #define HAVE_STDDEF_H /* Define this if your system has an ANSI-conforming <stdlib.h> file. */ #define HAVE_STDLIB_H #endif /* Define this if your system does not have an ANSI/SysV <string.h>, * but does have a BSD-style <strings.h>. */ #undef NEED_BSD_STRINGS /* Define this if your system does not provide typedef size_t in any of the * ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in * <sys/types.h> instead. */ #undef NEED_SYS_TYPES_H /* For 80x86 machines, you need to define NEED_FAR_POINTERS, * unless you are using a large-data memory model or 80386 flat-memory mode. * On less brain-damaged CPUs this symbol must not be defined. * (Defining this symbol causes large data structures to be referenced through * "far" pointers and to be allocated with a special version of malloc.) */ #undef NEED_FAR_POINTERS /* Define this if your linker needs global names to be unique in less * than the first 15 characters. */ #undef NEED_SHORT_EXTERNAL_NAMES /* Although a real ANSI C compiler can deal perfectly well with pointers to * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, * define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you * actually get "missing structure definition" warnings or errors while * compiling the JPEG code. */ #undef INCOMPLETE_TYPES_BROKEN /* Define "boolean" as unsigned char, not int, on Windows systems. */ #ifdef _WIN32 #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; #endif #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #endif /* * The following options affect code selection within the JPEG library, * but they don't need to be visible to applications using the library. * To minimize application namespace pollution, the symbols won't be * defined unless JPEG_INTERNALS has been defined. */ #ifdef JPEG_INTERNALS /* Define this if your compiler implements ">>" on signed values as a logical * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift, * which is the normal and rational definition. */ #undef RIGHT_SHIFT_IS_UNSIGNED /* These are for configuring the JPEG memory manager. */ #define DEFAULT_MAX_MEM 1073741824 /*1Gb*/ #if !defined WIN32 && !defined _WIN32 #define INLINE __inline__ #undef NO_MKTEMP #endif #endif /* JPEG_INTERNALS */ /* * The remaining options do not affect the JPEG library proper, * but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c). * Other applications can ignore these. */ #ifdef JPEG_CJPEG_DJPEG /* These defines indicate which image (non-JPEG) file formats are allowed. */ #define BMP_SUPPORTED /* BMP image file format */ #define GIF_SUPPORTED /* GIF image file format */ #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ #undef RLE_SUPPORTED /* Utah RLE image file format */ #define TARGA_SUPPORTED /* Targa image file format */ /* Define this if you want to name both input and output files on the command * line, rather than using stdout and optionally stdin. You MUST do this if * your system can't cope with binary I/O to stdin/stdout. See comments at * head of cjpeg.c or djpeg.c. */ #if defined WIN32 || defined _WIN32 #define TWO_FILE_COMMANDLINE /* optional */ #define USE_SETMODE /* Microsoft has setmode() */ #else #undef TWO_FILE_COMMANDLINE #endif /* Define this if your system needs explicit cleanup of temporary files. * This is crucial under MS-DOS, where the temporary "files" may be areas * of extended memory; on most other systems it's not as important. */ #undef NEED_SIGNAL_CATCHER /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). * This is necessary on systems that distinguish text files from binary files, * and is harmless on most systems that don't. If you have one of the rare * systems that complains about the "b" spec, define this symbol. */ #undef DONT_USE_B_MODE /* Define this if you want percent-done progress reports from cjpeg/djpeg. */ #undef PROGRESS_REPORT #endif /* JPEG_CJPEG_DJPEG */
snosov1/opencv
modules/features2d/src/kaze/utils.h
#ifndef __OPENCV_FEATURES_2D_KAZE_UTILS_H__ #define __OPENCV_FEATURES_2D_KAZE_UTILS_H__ /* ************************************************************************* */ /** * @brief This function computes the angle from the vector given by (X Y). From 0 to 2*Pi */ inline float getAngle(float x, float y) { if (x >= 0 && y >= 0) { return atanf(y / x); } if (x < 0 && y >= 0) { return static_cast<float>(CV_PI)-atanf(-y / x); } if (x < 0 && y < 0) { return static_cast<float>(CV_PI)+atanf(y / x); } if (x >= 0 && y < 0) { return static_cast<float>(2.0 * CV_PI) - atanf(-y / x); } return 0; } /* ************************************************************************* */ /** * @brief This function computes the value of a 2D Gaussian function * @param x X Position * @param y Y Position * @param sig Standard Deviation */ inline float gaussian(float x, float y, float sigma) { return expf(-(x*x + y*y) / (2.0f*sigma*sigma)); } /* ************************************************************************* */ /** * @brief This function checks descriptor limits * @param x X Position * @param y Y Position * @param width Image width * @param height Image height */ inline void checkDescriptorLimits(int &x, int &y, int width, int height) { if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x > width - 1) { x = width - 1; } if (y > height - 1) { y = height - 1; } } /* ************************************************************************* */ /** * @brief This funtion rounds float to nearest integer * @param flt Input float * @return dst Nearest integer */ inline int fRound(float flt) { return (int)(flt + 0.5f); } /* ************************************************************************* */ /** * @brief Exponentiation by squaring * @param flt Exponentiation base * @return dst Exponentiation value */ inline int fastpow(int base, int exp) { int res = 1; while(exp > 0) { if(exp & 1) { exp--; res *= base; } else { exp /= 2; base *= base; } } return res; } #endif
snosov1/opencv
3rdparty/include/dshow/errors.h
<gh_stars>100-1000 #ifndef _ERRORS_H #define _ERRORS_H #if __GNUC__ >=3 #pragma GCC system_header #endif #ifdef __cplusplus extern "C" { #endif /*--- DirectShow Reference - Constants and GUIDs - Error and Success Codes */ #define VFW_S_NO_MORE_ITEMS 0x00040103 #define VFW_S_DUPLICATE_NAME 0x0004022D #define VFW_S_STATE_INTERMEDIATE 0x00040237 #define VFW_S_PARTIAL_RENDER 0x00040242 #define VFW_S_SOME_DATA_IGNORED 0x00040245 #define VFW_S_CONNECTIONS_DEFERRED 0x00040246 #define VFW_S_RESOURCE_NOT_NEEDED 0x00040250 #define VFW_S_MEDIA_TYPE_IGNORED 0x00040254 #define VFW_S_VIDEO_NOT_RENDERED 0x00040257 #define VFW_S_AUDIO_NOT_RENDERED 0x00040258 #define VFW_S_RPZA 0x0004025A #define VFW_S_ESTIMATED 0x00040260 #define VFW_S_RESERVED 0x00040263 #define VFW_S_STREAM_OFF 0x00040267 #define VFW_S_CANT_CUE 0x00040268 #define VFW_S_NOPREVIEWPIN 0x0004027E #define VFW_S_DVD_NON_ONE_SEQUENTIAL 0x00040280 #define VFW_S_DVD_CHANNEL_CONTENTS_NOT_AVAILABLE 0x0004028C #define VFW_S_DVD_NOT_ACCURATE 0x0004028D #define VFW_E_INVALIDMEDIATYPE 0x80040200 #define VFW_E_INVALIDSUBTYPE 0x80040201 #define VFW_E_NEED_OWNER 0x80040202 #define VFW_E_ENUM_OUT_OF_SYNC 0x80040203 #define VFW_E_ALREADY_CONNECTED 0x80040204 #define VFW_E_FILTER_ACTIVE 0x80040205 #define VFW_E_NO_TYPES 0x80040206 #define VFW_E_NO_ACCEPTABLE_TYPES 0x80040207 #define VFW_E_INVALID_DIRECTION 0x80040208 #define VFW_E_NOT_CONNECTED 0x80040209 #define VFW_E_NO_ALLOCATOR 0x8004020A #define VFW_E_RUNTIME_ERROR 0x8004020B #define VFW_E_BUFFER_NOTSET 0x8004020C #define VFW_E_BUFFER_OVERFLOW 0x8004020D #define VFW_E_BADALIGN 0x8004020E #define VFW_E_ALREADY_COMMITTED 0x8004020F #define VFW_E_BUFFERS_OUTSTANDING 0x80040210 #define VFW_E_NOT_COMMITTED 0x80040211 #define VFW_E_SIZENOTSET 0x80040212 #define VFW_E_NO_CLOCK 0x80040213 #define VFW_E_NO_SINK 0x80040214 #define VFW_E_NO_INTERFACE 0x80040215 #define VFW_E_NOT_FOUND 0x80040216 #define VFW_E_CANNOT_CONNECT 0x80040217 #define VFW_E_CANNOT_RENDER 0x80040218 #define VFW_E_CHANGING_FORMAT 0x80040219 #define VFW_E_NO_COLOR_KEY_SET 0x8004021A #define VFW_E_NOT_OVERLAY_CONNECTION 0x8004021B #define VFW_E_NOT_SAMPLE_CONNECTION 0x8004021C #define VFW_E_PALETTE_SET 0x8004021D #define VFW_E_COLOR_KEY_SET 0x8004021E #define VFW_E_NO_COLOR_KEY_FOUND <KEY> #define VFW_E_NO_PALETTE_AVAILABLE 0x80040220 #define VFW_E_NO_DISPLAY_PALETTE 0x80040221 #define VFW_E_TOO_MANY_COLORS 0x80040222 #define VFW_E_STATE_CHANGED 0x80040223 #define VFW_E_NOT_STOPPED 0x80040224 #define VFW_E_NOT_PAUSED 0x80040225 #define VFW_E_NOT_RUNNING 0x80040226 #define VFW_E_WRONG_STATE 0x80040227 #define VFW_E_START_TIME_AFTER_END 0x80040228 #define VFW_E_INVALID_RECT 0x80040229 #define VFW_E_TYPE_NOT_ACCEPTED 0x8004022A #define VFW_E_SAMPLE_REJECTED 0x8004022B #define VFW_E_SAMPLE_REJECTED_EOS 0x8004022C #define VFW_E_DUPLICATE_NAME 0x8004022D #define VFW_E_TIMEOUT 0x8004022E #define VFW_E_INVALID_FILE_FORMAT 0x8004022F #define VFW_E_ENUM_OUT_OF_RANGE 0x80040230 #define VFW_E_CIRCULAR_GRAPH 0x80040231 #define VFW_E_NOT_ALLOWED_TO_SAVE 0x80040232 #define VFW_E_TIME_ALREADY_PASSED 0x80040233 #define VFW_E_ALREADY_CANCELLED 0x80040234 #define VFW_E_CORRUPT_GRAPH_FILE 0x80040235 #define VFW_E_ADVISE_ALREADY_SET 0x80040236 #define VFW_E_NO_MODEX_AVAILABLE 0x80040238 #define VFW_E_NO_ADVISE_SET 0x80040239 #define VFW_E_NO_FULLSCREEN 0x8004023A #define VFW_E_IN_FULLSCREEN_MODE 0x8004023B #define VFW_E_UNKNOWN_FILE_TYPE 0x80040240 #define VFW_E_CANNOT_LOAD_SOURCE_FILTER 0x80040241 #define VFW_E_FILE_TOO_SHORT 0x80040243 #define VFW_E_INVALID_FILE_VERSION 0x80040244 #define VFW_E_INVALID_CLSID 0x80040247 #define VFW_E_INVALID_MEDIA_TYPE 0x80040248 #define VFW_E_SAMPLE_TIME_NOT_SET 0x80040249 #define VFW_E_MEDIA_TIME_NOT_SET 0x80040251 #define VFW_E_NO_TIME_FORMAT_SET 0x80040252 #define VFW_E_MONO_AUDIO_HW 0x80040253 #define VFW_E_NO_DECOMPRESSOR 0x80040255 #define VFW_E_NO_AUDIO_HARDWARE 0x80040256 #define VFW_E_RPZA 0x80040259 #define VFW_E_PROCESSOR_NOT_SUITABLE 0x8004025B #define VFW_E_UNSUPPORTED_AUDIO 0x8004025C #define VFW_E_UNSUPPORTED_VIDEO 0x8004025D #define VFW_E_MPEG_NOT_CONSTRAINED 0x8004025E #define VFW_E_NOT_IN_GRAPH 0x8004025F #define VFW_E_NO_TIME_FORMAT 0x80040261 #define VFW_E_READ_ONLY 0x80040262 #define VFW_E_BUFFER_UNDERFLOW 0x80040264 #define VFW_E_UNSUPPORTED_STREAM 0x80040265 #define VFW_E_NO_TRANSPORT 0x80040266 #define VFW_E_BAD_VIDEOCD 0x80040269 #define VFW_S_NO_STOP_TIME 0x80040270 #define VFW_E_OUT_OF_VIDEO_MEMORY 0x80040271 #define VFW_E_VP_NEGOTIATION_FAILED 0x80040272 #define VFW_E_DDRAW_CAPS_NOT_SUITABLE 0x80040273 #define VFW_E_NO_VP_HARDWARE 0x80040274 #define VFW_E_NO_CAPTURE_HARDWARE 0x80040275 #define VFW_E_DVD_OPERATION_INHIBITED 0x80040276 #define VFW_E_DVD_INVALIDDOMAIN 0x80040277 #define VFW_E_DVD_NO_BUTTON 0x80040278 #define VFW_E_DVD_GRAPHNOTREADY 0x80040279 #define VFW_E_DVD_RENDERFAIL 0x8004027A #define VFW_E_DVD_DECNOTENOUGH 0x8004027B #define VFW_E_DDRAW_VERSION_NOT_SUITABLE 0x8004027C #define VFW_E_COPYPROT_FAILED 0x8004027D #define VFW_E_TIME_EXPIRED 0x8004027F #define VFW_E_DVD_WRONG_SPEED 0x80040281 #define VFW_E_DVD_MENU_DOES_NOT_EXIST 0x80040282 #define VFW_E_DVD_CMD_CANCELLED 0x80040283 #define VFW_E_DVD_STATE_WRONG_VERSION 0x80040284 #define VFW_E_DVD_STATE_CORRUPT 0x80040285 #define VFW_E_DVD_STATE_WRONG_DISC 0x80040286 #define VFW_E_DVD_INCOMPATIBLE_REGION 0x80040287 #define VFW_E_DVD_NO_ATTRIBUTES 0x80040288 #define VFW_E_DVD_NO_GOUP_PGC 0x80040289 #define VFW_E_DVD_LOW_PARENTAL_LEVEL 0x8004028A #define VFW_E_DVD_NOT_IN_KARAOKE_MODE 0x8004028B #define VFW_E_FRAME_STEP_UNSUPPORTED 0x8004028E #define VFW_E_DVD_STREAM_DISABLED 0x8004028F #define VFW_E_DVD_TITLE_UNKNOWN 0x80040290 #define VFW_E_DVD_INVALID_DISC 0x80040291 #define VFW_E_DVD_NO_RESUME_INFORMATION 0x80040292 #define VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD 0x80040293 #define VFW_E_PIN_ALREADY_BLOCKED 0x80040294 #define VFW_E_CERTIFICATION_FAILURE 0x80040295 #define VFW_E_VMR_NOT_IN_MIXER_MODE 0x80040296 #define VFW_E_VMR_NO_AP_SUPPLIED 0x80040297 #define VFW_E_VMR_NO_DEINTERLACE_HW 0x80040298 #define VFW_E_VMR_NO_PROCAMP_HW 0x80040299 #define VFW_E_DVD_VMR9_INCOMPATIBLEDEC 0x8004029A #define VFW_E_NO_COPP_HW 0x8004029B #define VFW_E_BAD_KEY 0x800403F2 /*--- DirectShow Reference - Functions */ #define MAX_ERROR_TEXT_LEN 160 /*--- DirectShow Reference - Functions */ DWORD WINAPI AMGetErrorTextA(HRESULT,CHAR*,DWORD); DWORD WINAPI AMGetErrorTextW(HRESULT,WCHAR*,DWORD); #ifdef UNICODE #define AMGetErrorText AMGetErrorTextW #else #define AMGetErrorText AMGetErrorTextA #endif #ifdef __cplusplus } #endif #endif
snosov1/opencv
3rdparty/include/dshow/bdatypes.h
#ifndef _BDATYPES_H #define _BDATYPES_H #if __GNUC__ >= 3 #pragma GCC system_header #endif #ifdef __cplusplus extern "C" { #endif /*--- DirectShow Reference - DirectShow Enumerated Types */ typedef enum { MEDIA_TRANSPORT_PACKET, MEDIA_ELEMENTARY_STREAM, MEDIA_MPEG2_PSI, MEDIA_TRANSPORT_PAYLOAD } MEDIA_SAMPLE_CONTENT; /*--- DirectShow Reference - DirectShow Structures */ typedef struct { DWORD dwOffset; DWORD dwPacketLength; DWORD dwStride; } MPEG2_TRANSPORT_STRIDE; typedef struct { ULONG ulPID; MEDIA_SAMPLE_CONTENT MediaSampleContent ; } PID_MAP; #ifdef __cplusplus } #endif #endif
snosov1/opencv
3rdparty/libwebp/dsp/enc_neon.c
<filename>3rdparty/libwebp/dsp/enc_neon.c // Copyright 2012 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // ARM NEON version of speed-critical encoding functions. // // adapted from libvpx (http://www.webmproject.org/code/) #include "./dsp.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #if defined(WEBP_USE_NEON) #include "../enc/vp8enci.h" //------------------------------------------------------------------------------ // Transforms (Paragraph 14.4) // Inverse transform. // This code is pretty much the same as TransformOneNEON in the decoder, except // for subtraction to *ref. See the comments there for algorithmic explanations. static void ITransformOne(const uint8_t* ref, const int16_t* in, uint8_t* dst) { const int kBPS = BPS; const int16_t kC1C2[] = { 20091, 17734, 0, 0 }; // kC1 / (kC2 >> 1) / 0 / 0 __asm__ volatile ( "vld1.16 {q1, q2}, [%[in]] \n" "vld1.16 {d0}, [%[kC1C2]] \n" // d2: in[0] // d3: in[8] // d4: in[4] // d5: in[12] "vswp d3, d4 \n" // q8 = {in[4], in[12]} * kC1 * 2 >> 16 // q9 = {in[4], in[12]} * kC2 >> 16 "vqdmulh.s16 q8, q2, d0[0] \n" "vqdmulh.s16 q9, q2, d0[1] \n" // d22 = a = in[0] + in[8] // d23 = b = in[0] - in[8] "vqadd.s16 d22, d2, d3 \n" "vqsub.s16 d23, d2, d3 \n" // q8 = in[4]/[12] * kC1 >> 16 "vshr.s16 q8, q8, #1 \n" // Add {in[4], in[12]} back after the multiplication. "vqadd.s16 q8, q2, q8 \n" // d20 = c = in[4]*kC2 - in[12]*kC1 // d21 = d = in[4]*kC1 + in[12]*kC2 "vqsub.s16 d20, d18, d17 \n" "vqadd.s16 d21, d19, d16 \n" // d2 = tmp[0] = a + d // d3 = tmp[1] = b + c // d4 = tmp[2] = b - c // d5 = tmp[3] = a - d "vqadd.s16 d2, d22, d21 \n" "vqadd.s16 d3, d23, d20 \n" "vqsub.s16 d4, d23, d20 \n" "vqsub.s16 d5, d22, d21 \n" "vzip.16 q1, q2 \n" "vzip.16 q1, q2 \n" "vswp d3, d4 \n" // q8 = {tmp[4], tmp[12]} * kC1 * 2 >> 16 // q9 = {tmp[4], tmp[12]} * kC2 >> 16 "vqdmulh.s16 q8, q2, d0[0] \n" "vqdmulh.s16 q9, q2, d0[1] \n" // d22 = a = tmp[0] + tmp[8] // d23 = b = tmp[0] - tmp[8] "vqadd.s16 d22, d2, d3 \n" "vqsub.s16 d23, d2, d3 \n" "vshr.s16 q8, q8, #1 \n" "vqadd.s16 q8, q2, q8 \n" // d20 = c = in[4]*kC2 - in[12]*kC1 // d21 = d = in[4]*kC1 + in[12]*kC2 "vqsub.s16 d20, d18, d17 \n" "vqadd.s16 d21, d19, d16 \n" // d2 = tmp[0] = a + d // d3 = tmp[1] = b + c // d4 = tmp[2] = b - c // d5 = tmp[3] = a - d "vqadd.s16 d2, d22, d21 \n" "vqadd.s16 d3, d23, d20 \n" "vqsub.s16 d4, d23, d20 \n" "vqsub.s16 d5, d22, d21 \n" "vld1.32 d6[0], [%[ref]], %[kBPS] \n" "vld1.32 d6[1], [%[ref]], %[kBPS] \n" "vld1.32 d7[0], [%[ref]], %[kBPS] \n" "vld1.32 d7[1], [%[ref]], %[kBPS] \n" "sub %[ref], %[ref], %[kBPS], lsl #2 \n" // (val) + 4 >> 3 "vrshr.s16 d2, d2, #3 \n" "vrshr.s16 d3, d3, #3 \n" "vrshr.s16 d4, d4, #3 \n" "vrshr.s16 d5, d5, #3 \n" "vzip.16 q1, q2 \n" "vzip.16 q1, q2 \n" // Must accumulate before saturating "vmovl.u8 q8, d6 \n" "vmovl.u8 q9, d7 \n" "vqadd.s16 q1, q1, q8 \n" "vqadd.s16 q2, q2, q9 \n" "vqmovun.s16 d0, q1 \n" "vqmovun.s16 d1, q2 \n" "vst1.32 d0[0], [%[dst]], %[kBPS] \n" "vst1.32 d0[1], [%[dst]], %[kBPS] \n" "vst1.32 d1[0], [%[dst]], %[kBPS] \n" "vst1.32 d1[1], [%[dst]] \n" : [in] "+r"(in), [dst] "+r"(dst) // modified registers : [kBPS] "r"(kBPS), [kC1C2] "r"(kC1C2), [ref] "r"(ref) // constants : "memory", "q0", "q1", "q2", "q8", "q9", "q10", "q11" // clobbered ); } static void ITransform(const uint8_t* ref, const int16_t* in, uint8_t* dst, int do_two) { ITransformOne(ref, in, dst); if (do_two) { ITransformOne(ref + 4, in + 16, dst + 4); } } // Same code as dec_neon.c static void ITransformWHT(const int16_t* in, int16_t* out) { const int kStep = 32; // The store is only incrementing the pointer as if we // had stored a single byte. __asm__ volatile ( // part 1 // load data into q0, q1 "vld1.16 {q0, q1}, [%[in]] \n" "vaddl.s16 q2, d0, d3 \n" // a0 = in[0] + in[12] "vaddl.s16 q3, d1, d2 \n" // a1 = in[4] + in[8] "vsubl.s16 q4, d1, d2 \n" // a2 = in[4] - in[8] "vsubl.s16 q5, d0, d3 \n" // a3 = in[0] - in[12] "vadd.s32 q0, q2, q3 \n" // tmp[0] = a0 + a1 "vsub.s32 q2, q2, q3 \n" // tmp[8] = a0 - a1 "vadd.s32 q1, q5, q4 \n" // tmp[4] = a3 + a2 "vsub.s32 q3, q5, q4 \n" // tmp[12] = a3 - a2 // Transpose // q0 = tmp[0, 4, 8, 12], q1 = tmp[2, 6, 10, 14] // q2 = tmp[1, 5, 9, 13], q3 = tmp[3, 7, 11, 15] "vswp d1, d4 \n" // vtrn.64 q0, q2 "vswp d3, d6 \n" // vtrn.64 q1, q3 "vtrn.32 q0, q1 \n" "vtrn.32 q2, q3 \n" "vmov.s32 q4, #3 \n" // dc = 3 "vadd.s32 q0, q0, q4 \n" // dc = tmp[0] + 3 "vadd.s32 q6, q0, q3 \n" // a0 = dc + tmp[3] "vadd.s32 q7, q1, q2 \n" // a1 = tmp[1] + tmp[2] "vsub.s32 q8, q1, q2 \n" // a2 = tmp[1] - tmp[2] "vsub.s32 q9, q0, q3 \n" // a3 = dc - tmp[3] "vadd.s32 q0, q6, q7 \n" "vshrn.s32 d0, q0, #3 \n" // (a0 + a1) >> 3 "vadd.s32 q1, q9, q8 \n" "vshrn.s32 d1, q1, #3 \n" // (a3 + a2) >> 3 "vsub.s32 q2, q6, q7 \n" "vshrn.s32 d2, q2, #3 \n" // (a0 - a1) >> 3 "vsub.s32 q3, q9, q8 \n" "vshrn.s32 d3, q3, #3 \n" // (a3 - a2) >> 3 // set the results to output "vst1.16 d0[0], [%[out]], %[kStep] \n" "vst1.16 d1[0], [%[out]], %[kStep] \n" "vst1.16 d2[0], [%[out]], %[kStep] \n" "vst1.16 d3[0], [%[out]], %[kStep] \n" "vst1.16 d0[1], [%[out]], %[kStep] \n" "vst1.16 d1[1], [%[out]], %[kStep] \n" "vst1.16 d2[1], [%[out]], %[kStep] \n" "vst1.16 d3[1], [%[out]], %[kStep] \n" "vst1.16 d0[2], [%[out]], %[kStep] \n" "vst1.16 d1[2], [%[out]], %[kStep] \n" "vst1.16 d2[2], [%[out]], %[kStep] \n" "vst1.16 d3[2], [%[out]], %[kStep] \n" "vst1.16 d0[3], [%[out]], %[kStep] \n" "vst1.16 d1[3], [%[out]], %[kStep] \n" "vst1.16 d2[3], [%[out]], %[kStep] \n" "vst1.16 d3[3], [%[out]], %[kStep] \n" : [out] "+r"(out) // modified registers : [in] "r"(in), [kStep] "r"(kStep) // constants : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9" // clobbered ); } // Forward transform. // adapted from vp8/encoder/arm/neon/shortfdct_neon.asm static const int16_t kCoeff16[] = { 5352, 5352, 5352, 5352, 2217, 2217, 2217, 2217 }; static const int32_t kCoeff32[] = { 1812, 1812, 1812, 1812, 937, 937, 937, 937, 12000, 12000, 12000, 12000, 51000, 51000, 51000, 51000 }; static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) { const int kBPS = BPS; const uint8_t* src_ptr = src; const uint8_t* ref_ptr = ref; const int16_t* coeff16 = kCoeff16; const int32_t* coeff32 = kCoeff32; __asm__ volatile ( // load src into q4, q5 in high half "vld1.8 {d8}, [%[src_ptr]], %[kBPS] \n" "vld1.8 {d10}, [%[src_ptr]], %[kBPS] \n" "vld1.8 {d9}, [%[src_ptr]], %[kBPS] \n" "vld1.8 {d11}, [%[src_ptr]] \n" // load ref into q6, q7 in high half "vld1.8 {d12}, [%[ref_ptr]], %[kBPS] \n" "vld1.8 {d14}, [%[ref_ptr]], %[kBPS] \n" "vld1.8 {d13}, [%[ref_ptr]], %[kBPS] \n" "vld1.8 {d15}, [%[ref_ptr]] \n" // Pack the high values in to q4 and q6 "vtrn.32 q4, q5 \n" "vtrn.32 q6, q7 \n" // d[0-3] = src - ref "vsubl.u8 q0, d8, d12 \n" "vsubl.u8 q1, d9, d13 \n" // load coeff16 into q8(d16=5352, d17=2217) "vld1.16 {q8}, [%[coeff16]] \n" // load coeff32 high half into q9 = 1812, q10 = 937 "vld1.32 {q9, q10}, [%[coeff32]]! \n" // load coeff32 low half into q11=12000, q12=51000 "vld1.32 {q11,q12}, [%[coeff32]] \n" // part 1 // Transpose. Register dN is the same as dN in C "vtrn.32 d0, d2 \n" "vtrn.32 d1, d3 \n" "vtrn.16 d0, d1 \n" "vtrn.16 d2, d3 \n" "vadd.s16 d4, d0, d3 \n" // a0 = d0 + d3 "vadd.s16 d5, d1, d2 \n" // a1 = d1 + d2 "vsub.s16 d6, d1, d2 \n" // a2 = d1 - d2 "vsub.s16 d7, d0, d3 \n" // a3 = d0 - d3 "vadd.s16 d0, d4, d5 \n" // a0 + a1 "vshl.s16 d0, d0, #3 \n" // temp[0+i*4] = (a0+a1) << 3 "vsub.s16 d2, d4, d5 \n" // a0 - a1 "vshl.s16 d2, d2, #3 \n" // (temp[2+i*4] = (a0-a1) << 3 "vmlal.s16 q9, d7, d16 \n" // a3*5352 + 1812 "vmlal.s16 q10, d7, d17 \n" // a3*2217 + 937 "vmlal.s16 q9, d6, d17 \n" // a2*2217 + a3*5352 + 1812 "vmlsl.s16 q10, d6, d16 \n" // a3*2217 + 937 - a2*5352 // temp[1+i*4] = (d2*2217 + d3*5352 + 1812) >> 9 // temp[3+i*4] = (d3*2217 + 937 - d2*5352) >> 9 "vshrn.s32 d1, q9, #9 \n" "vshrn.s32 d3, q10, #9 \n" // part 2 // transpose d0=ip[0], d1=ip[4], d2=ip[8], d3=ip[12] "vtrn.32 d0, d2 \n" "vtrn.32 d1, d3 \n" "vtrn.16 d0, d1 \n" "vtrn.16 d2, d3 \n" "vmov.s16 d26, #7 \n" "vadd.s16 d4, d0, d3 \n" // a1 = ip[0] + ip[12] "vadd.s16 d5, d1, d2 \n" // b1 = ip[4] + ip[8] "vsub.s16 d6, d1, d2 \n" // c1 = ip[4] - ip[8] "vadd.s16 d4, d4, d26 \n" // a1 + 7 "vsub.s16 d7, d0, d3 \n" // d1 = ip[0] - ip[12] "vadd.s16 d0, d4, d5 \n" // op[0] = a1 + b1 + 7 "vsub.s16 d2, d4, d5 \n" // op[8] = a1 - b1 + 7 "vmlal.s16 q11, d7, d16 \n" // d1*5352 + 12000 "vmlal.s16 q12, d7, d17 \n" // d1*2217 + 51000 "vceq.s16 d4, d7, #0 \n" "vshr.s16 d0, d0, #4 \n" "vshr.s16 d2, d2, #4 \n" "vmlal.s16 q11, d6, d17 \n" // c1*2217 + d1*5352 + 12000 "vmlsl.s16 q12, d6, d16 \n" // d1*2217 - c1*5352 + 51000 "vmvn d4, d4 \n" // !(d1 == 0) // op[4] = (c1*2217 + d1*5352 + 12000)>>16 "vshrn.s32 d1, q11, #16 \n" // op[4] += (d1!=0) "vsub.s16 d1, d1, d4 \n" // op[12]= (d1*2217 - c1*5352 + 51000)>>16 "vshrn.s32 d3, q12, #16 \n" // set result to out array "vst1.16 {q0, q1}, [%[out]] \n" : [src_ptr] "+r"(src_ptr), [ref_ptr] "+r"(ref_ptr), [coeff32] "+r"(coeff32) // modified registers : [kBPS] "r"(kBPS), [coeff16] "r"(coeff16), [out] "r"(out) // constants : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13" // clobbered ); } static void FTransformWHT(const int16_t* in, int16_t* out) { const int kStep = 32; __asm__ volatile ( // d0 = in[0 * 16] , d1 = in[1 * 16] // d2 = in[2 * 16] , d3 = in[3 * 16] "vld1.16 d0[0], [%[in]], %[kStep] \n" "vld1.16 d1[0], [%[in]], %[kStep] \n" "vld1.16 d2[0], [%[in]], %[kStep] \n" "vld1.16 d3[0], [%[in]], %[kStep] \n" "vld1.16 d0[1], [%[in]], %[kStep] \n" "vld1.16 d1[1], [%[in]], %[kStep] \n" "vld1.16 d2[1], [%[in]], %[kStep] \n" "vld1.16 d3[1], [%[in]], %[kStep] \n" "vld1.16 d0[2], [%[in]], %[kStep] \n" "vld1.16 d1[2], [%[in]], %[kStep] \n" "vld1.16 d2[2], [%[in]], %[kStep] \n" "vld1.16 d3[2], [%[in]], %[kStep] \n" "vld1.16 d0[3], [%[in]], %[kStep] \n" "vld1.16 d1[3], [%[in]], %[kStep] \n" "vld1.16 d2[3], [%[in]], %[kStep] \n" "vld1.16 d3[3], [%[in]], %[kStep] \n" "vaddl.s16 q2, d0, d2 \n" // a0=(in[0*16]+in[2*16]) "vaddl.s16 q3, d1, d3 \n" // a1=(in[1*16]+in[3*16]) "vsubl.s16 q4, d1, d3 \n" // a2=(in[1*16]-in[3*16]) "vsubl.s16 q5, d0, d2 \n" // a3=(in[0*16]-in[2*16]) "vqadd.s32 q6, q2, q3 \n" // a0 + a1 "vqadd.s32 q7, q5, q4 \n" // a3 + a2 "vqsub.s32 q8, q5, q4 \n" // a3 - a2 "vqsub.s32 q9, q2, q3 \n" // a0 - a1 // Transpose // q6 = tmp[0, 1, 2, 3] ; q7 = tmp[ 4, 5, 6, 7] // q8 = tmp[8, 9, 10, 11] ; q9 = tmp[12, 13, 14, 15] "vswp d13, d16 \n" // vtrn.64 q0, q2 "vswp d15, d18 \n" // vtrn.64 q1, q3 "vtrn.32 q6, q7 \n" "vtrn.32 q8, q9 \n" "vqadd.s32 q0, q6, q8 \n" // a0 = tmp[0] + tmp[8] "vqadd.s32 q1, q7, q9 \n" // a1 = tmp[4] + tmp[12] "vqsub.s32 q2, q7, q9 \n" // a2 = tmp[4] - tmp[12] "vqsub.s32 q3, q6, q8 \n" // a3 = tmp[0] - tmp[8] "vqadd.s32 q4, q0, q1 \n" // b0 = a0 + a1 "vqadd.s32 q5, q3, q2 \n" // b1 = a3 + a2 "vqsub.s32 q6, q3, q2 \n" // b2 = a3 - a2 "vqsub.s32 q7, q0, q1 \n" // b3 = a0 - a1 "vshrn.s32 d18, q4, #1 \n" // b0 >> 1 "vshrn.s32 d19, q5, #1 \n" // b1 >> 1 "vshrn.s32 d20, q6, #1 \n" // b2 >> 1 "vshrn.s32 d21, q7, #1 \n" // b3 >> 1 "vst1.16 {q9, q10}, [%[out]] \n" : [in] "+r"(in) : [kStep] "r"(kStep), [out] "r"(out) : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10" // clobbered ) ; } //------------------------------------------------------------------------------ // Texture distortion // // We try to match the spectral content (weighted) between source and // reconstructed samples. // Hadamard transform // Returns the weighted sum of the absolute value of transformed coefficients. // This uses a TTransform helper function in C static int Disto4x4(const uint8_t* const a, const uint8_t* const b, const uint16_t* const w) { const int kBPS = BPS; const uint8_t* A = a; const uint8_t* B = b; const uint16_t* W = w; int sum; __asm__ volatile ( "vld1.32 d0[0], [%[a]], %[kBPS] \n" "vld1.32 d0[1], [%[a]], %[kBPS] \n" "vld1.32 d2[0], [%[a]], %[kBPS] \n" "vld1.32 d2[1], [%[a]] \n" "vld1.32 d1[0], [%[b]], %[kBPS] \n" "vld1.32 d1[1], [%[b]], %[kBPS] \n" "vld1.32 d3[0], [%[b]], %[kBPS] \n" "vld1.32 d3[1], [%[b]] \n" // a d0/d2, b d1/d3 // d0/d1: 01 01 01 01 // d2/d3: 23 23 23 23 // But: it goes 01 45 23 67 // Notice the middle values are transposed "vtrn.16 q0, q1 \n" // {a0, a1} = {in[0] + in[2], in[1] + in[3]} "vaddl.u8 q2, d0, d2 \n" "vaddl.u8 q10, d1, d3 \n" // {a3, a2} = {in[0] - in[2], in[1] - in[3]} "vsubl.u8 q3, d0, d2 \n" "vsubl.u8 q11, d1, d3 \n" // tmp[0] = a0 + a1 "vpaddl.s16 q0, q2 \n" "vpaddl.s16 q8, q10 \n" // tmp[1] = a3 + a2 "vpaddl.s16 q1, q3 \n" "vpaddl.s16 q9, q11 \n" // No pair subtract // q2 = {a0, a3} // q3 = {a1, a2} "vtrn.16 q2, q3 \n" "vtrn.16 q10, q11 \n" // {tmp[3], tmp[2]} = {a0 - a1, a3 - a2} "vsubl.s16 q12, d4, d6 \n" "vsubl.s16 q13, d5, d7 \n" "vsubl.s16 q14, d20, d22 \n" "vsubl.s16 q15, d21, d23 \n" // separate tmp[3] and tmp[2] // q12 = tmp[3] // q13 = tmp[2] "vtrn.32 q12, q13 \n" "vtrn.32 q14, q15 \n" // Transpose tmp for a "vswp d1, d26 \n" // vtrn.64 "vswp d3, d24 \n" // vtrn.64 "vtrn.32 q0, q1 \n" "vtrn.32 q13, q12 \n" // Transpose tmp for b "vswp d17, d30 \n" // vtrn.64 "vswp d19, d28 \n" // vtrn.64 "vtrn.32 q8, q9 \n" "vtrn.32 q15, q14 \n" // The first Q register is a, the second b. // q0/8 tmp[0-3] // q13/15 tmp[4-7] // q1/9 tmp[8-11] // q12/14 tmp[12-15] // These are still in 01 45 23 67 order. We fix it easily in the addition // case but the subtraction propegates them. "vswp d3, d27 \n" "vswp d19, d31 \n" // a0 = tmp[0] + tmp[8] "vadd.s32 q2, q0, q1 \n" "vadd.s32 q3, q8, q9 \n" // a1 = tmp[4] + tmp[12] "vadd.s32 q10, q13, q12 \n" "vadd.s32 q11, q15, q14 \n" // a2 = tmp[4] - tmp[12] "vsub.s32 q13, q13, q12 \n" "vsub.s32 q15, q15, q14 \n" // a3 = tmp[0] - tmp[8] "vsub.s32 q0, q0, q1 \n" "vsub.s32 q8, q8, q9 \n" // b0 = a0 + a1 "vadd.s32 q1, q2, q10 \n" "vadd.s32 q9, q3, q11 \n" // b1 = a3 + a2 "vadd.s32 q12, q0, q13 \n" "vadd.s32 q14, q8, q15 \n" // b2 = a3 - a2 "vsub.s32 q0, q0, q13 \n" "vsub.s32 q8, q8, q15 \n" // b3 = a0 - a1 "vsub.s32 q2, q2, q10 \n" "vsub.s32 q3, q3, q11 \n" "vld1.64 {q10, q11}, [%[w]] \n" // abs(b0) "vabs.s32 q1, q1 \n" "vabs.s32 q9, q9 \n" // abs(b1) "vabs.s32 q12, q12 \n" "vabs.s32 q14, q14 \n" // abs(b2) "vabs.s32 q0, q0 \n" "vabs.s32 q8, q8 \n" // abs(b3) "vabs.s32 q2, q2 \n" "vabs.s32 q3, q3 \n" // expand w before using. "vmovl.u16 q13, d20 \n" "vmovl.u16 q15, d21 \n" // w[0] * abs(b0) "vmul.u32 q1, q1, q13 \n" "vmul.u32 q9, q9, q13 \n" // w[4] * abs(b1) "vmla.u32 q1, q12, q15 \n" "vmla.u32 q9, q14, q15 \n" // expand w before using. "vmovl.u16 q13, d22 \n" "vmovl.u16 q15, d23 \n" // w[8] * abs(b1) "vmla.u32 q1, q0, q13 \n" "vmla.u32 q9, q8, q13 \n" // w[12] * abs(b1) "vmla.u32 q1, q2, q15 \n" "vmla.u32 q9, q3, q15 \n" // Sum the arrays "vpaddl.u32 q1, q1 \n" "vpaddl.u32 q9, q9 \n" "vadd.u64 d2, d3 \n" "vadd.u64 d18, d19 \n" // Hadamard transform needs 4 bits of extra precision (2 bits in each // direction) for dynamic raw. Weights w[] are 16bits at max, so the maximum // precision for coeff is 8bit of input + 4bits of Hadamard transform + // 16bits for w[] + 2 bits of abs() summation. // // This uses a maximum of 31 bits (signed). Discarding the top 32 bits is // A-OK. // sum2 - sum1 "vsub.u32 d0, d2, d18 \n" // abs(sum2 - sum1) "vabs.s32 d0, d0 \n" // abs(sum2 - sum1) >> 5 "vshr.u32 d0, #5 \n" // It would be better to move the value straight into r0 but I'm not // entirely sure how this works with inline assembly. "vmov.32 %[sum], d0[0] \n" : [sum] "=r"(sum), [a] "+r"(A), [b] "+r"(B), [w] "+r"(W) : [kBPS] "r"(kBPS) : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15" // clobbered ) ; return sum; } static int Disto16x16(const uint8_t* const a, const uint8_t* const b, const uint16_t* const w) { int D = 0; int x, y; for (y = 0; y < 16 * BPS; y += 4 * BPS) { for (x = 0; x < 16; x += 4) { D += Disto4x4(a + x + y, b + x + y, w); } } return D; } #endif // WEBP_USE_NEON //------------------------------------------------------------------------------ // Entry point extern void VP8EncDspInitNEON(void); void VP8EncDspInitNEON(void) { #if defined(WEBP_USE_NEON) VP8ITransform = ITransform; VP8FTransform = FTransform; VP8ITransformWHT = ITransformWHT; VP8FTransformWHT = FTransformWHT; VP8TDisto4x4 = Disto4x4; VP8TDisto16x16 = Disto16x16; #endif // WEBP_USE_NEON } #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif