티스토리 뷰
미디어 플레이어 관련 개발을 하다보면 콘텐츠의 Video 크기를
미디어 플레이어의 화면 사이즈와 콘텐츠의 Video 비율에 맞게 조정할 필요가 있다.
아래는 위 요구에 맞게 구현한 코드다.
void adjustVideoSize(int viewWidth, int viewHeight, int videoWidth, int videoHeight, int *adjustedVideoWidth, int *adjustedVideoHeight) { // Get GCD of video int gcd; { int max, min; if (videoWidth > videoHeight) { max = videoHeight; min = videoWidth; } else { max = videoWidth; min = videoHeight; } int temp; while((max % min) != 0) { temp = max % min; max = min; min = temp; } gcd = min; } // Get video ratio int videoWidthRatio = videoWidth / gcd; int videoHeightRatio = videoHeight / gcd; int referenceValue; { int oneRatioWidth = viewWidth / videoWidthRatio; int oneRatioHeight = viewHeight / videoHeightRatio; if (oneRatioWidth > oneRatioHeight) { referenceValue = oneRatioHeight; } else { referenceValue = oneRatioWidth; } } *adjustedVideoWidth = videoWidthRatio * referenceValue; *adjustedVideoHeight = videoHeightRatio * referenceValue; } |
'TIL > C++' 카테고리의 다른 글
데이터 타입 크기와 signed/unsigned 체크 방법 (0) | 2014.12.16 |
---|
- Total
- Today
- Yesterday
- jdk6
- springboot
- Java
- JDK21
- Programming
- HTTP Live Streaming
- programmer
- ffmpeg
- development
- onbeforeunload
- HDFS
- DB
- oid
- CentOS
- HLS
- Virtual Thread
- C/C++
- JAXB
- libavformat
- fluentd
- springjpa
- JPA
- Spring
- Rolling-Restart
- jdk7
- popupWindow
- elasticsearch
- springframework
- AVIOContext
- DATABASE
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |