Thursday, July 14, 2016

C언어 Quick Soft 예제

int data[7] = { 3,5,1,2,6,9,7 };

void swapInt(int &a, int &b)
{
int tmp = a;
a = b;
b = tmp;
}

void printArr(int arr[]) {
printf("arr=");
for (int i = 0; i < 7; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}

void quickSort(int arr[], int left, int right)
{
printf("left=%d right=%d\n", left, right);

int i = left;
int j = right;
printArr(arr);

int pivotIndex = (left + right) / 2;
int pivot = arr[pivotIndex];
printf("pivotIndex=%d pivot=%d\n", pivotIndex, pivot);

while (i <= j) {
// 피봇을 기준으로 left의 값이 pivot의 값보다 큰 것을 찾는다.(잘못 놓여진 것을 찾음)
while (arr[i] < pivot) {
printf("arr[%d]=%d i++\n", i, arr[i]);
i++;
}
// 피봇을 기준으로 right의 값이 pivot의 값보다 작은 것을 찾는다.(잘못 놓여진 것을 찾음)
while (arr[j] > pivot) {
printf("arr[%d]=%d j--\n", j, arr[j]);
j--;
}

// 인덱스가 정상적인 상황일때 스왑한다.
if (i <= j) {
printf("swap begin %d %d\n", i, j);
swapInt(arr[i], arr[j]);
printArr(arr);
i++;
j--;
printf("swap end %d %d\n", i, j);
}
}

// 나머지 좌우에 대해서 다시 퀵소트 한다.
if (left < j) {
quickSort(arr, left, j);
}

if (i < right) {
quickSort(arr, i, right);
}
}


int main()
{
quickSort(data, 0, 6);
printf("data=");
for (int i = 0; i < 7; i++) {
printf("%d ", data[i]);
}
printf("\n");
return 0;
}

Android Camera2 API 기능

간단히 Camera2 API가 할 수 있는 기능은

- Burst capture at full resolution at up to 30fps.
센서 풀 해상도로 초당 30프레임의 사진을 찍을 수 있습니다.

- RAW (dng) image capture (more on this later).
DNG 파일로 캡처할 수 있습니다.

- Full manual focus.
흉내만 낸 수동초점이 아닌 진짜 리얼 풀 매뉴얼 포커스가 가능합니다.

- Faster autofocus
좀더 빠른 자동초점을 잡습니다.

- A smoother viewfinder.
부드러운 미리보기를 볼 수 있습니다.

- Full resolution video.
센서 풀 해상도의 영상을 저장할 수 있습니다.

- No viewfinder swapping when switching between modes.
모드변경을 위해 미리보는 화면 변경되는 과정이 없습니다.

- Implement granular settings before capture.
세부적인 설정이 가능합니다.

- Request target frame rates.
프레임레이트를 정할 수 있습니다.

- Access to raw sensor data.
RAW 데이타에 접근할 수 있습니다. 이전에는 포스트프로세스 애프터프로세스를 통해 JPG로 저장되었죠

- Flash firing support
플래쉬 터뜨리는 방법을 조절할 수 있습니다. 상상이지만 모델링 플래쉬도 구현되겠죠?

- Video HDR
HDR 영상을 지원합니다.

- Focus stacking.
Burst로 한 사진에 여러 초점 사진을 찍을 수 있습니다.

- Exposure bracketing
Burst로 노출 브라켓팅 (여러 노출로 찍는 기법입니다)을 찍을 수 있습니다.

Wednesday, July 13, 2016

Android ANR 디버깅 방법

안드로이드에서 ANR 디버깅 방법
-Method profiling
-Thread monitor
-StrictMode 정의
Main Thread에서는 시간이 많이 소모될 수 있는, 동작을 규정하고 막을 수 있다.
그 규정은 안드로이드에서 제공하는 범위에서 개발자가 정한다.
그 규정 위반시 안드로이드에서 제공하는 범위에서 처리를 할 수 있다.
-Dropbox 사용(제조사, 에뮬레이터)

http://cluster1.cafe.daum.net/_c21_/bbs_search_read?grpid=1MWA2&fldid=aAfL&datanum=99&openArticle=true&docid=1MWA2%7CaAfL%7C99%7C20110712112022

동영상 프레임의 종류 I/P/B 프레임(i-frame, p-frame, b-frame)

I 프레임 - Infra Frame 의 약자로, 쉽게 말해 키 프레임 입니다. 이것은 JPEG 같은 방식으로 소스로부터 직접 압축되어 온 전체 그림이죠. 가장 화질도 좋지만 가장 용량도 큽니다.
P 프레임 - Previous 또는 Predicted Frame 이라 불리며, 이전에 나온 키 프레임의 정보를 바탕으로 구성된 프레임 입니다. 화질/용량 둘 다 중간급입니다.
B 프레임 - Bidirectional Frame 의 약자로, 전후의 I/P 프레임의 정보를 바탕으로 구성된 프레임 입니다. 화질/용량이 다 최하급입니다.

Java GC root

GC의 reachability를 판단할때는 다음과 같은 GC root 노드를 기준으로 판단한다. 그 GC root에 해당하는 것들은 다음과 같은 것이 있다.

The so-called GC (Garbage Collector) roots are objects special for garbage collector. Garbage collector collects those objects that are not GC roots and are not accessible by references from GC roots.

There are several kinds of GC roots. One object can belong to more than one kind of root. The root kinds are:

- Class - class loaded by system class loader. Such classes can never be unloaded. They can hold objects via static fields. Please note that classes loaded by custom class loaders are not roots, unless corresponding instances of java.lang.Class happen to be roots of other kind(s).
- Thread - live thread
- Stack Local - local variable or parameter of Java method
- JNI Local - local variable or parameter of JNI method
- JNI Global - global JNI reference
- Monitor Used - objects used as a monitor for synchronization
- Held by JVM - objects held from garbage collection by JVM for its purposes. Actually the list of such objects depends on JVM implementation. Possible known cases are: the system class loader, a few important exception classes which the JVM knows about, a few pre-allocated objects for exception handling, and custom class loaders when they are in the process of loading classes. Unfortunately, JVM provides absolutely no additional detail for such objects. Thus it is up to the analyst to decide to which case a certain "Held by JVM" belongs.