일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
- 모니터 암
- 유틸리티
- headset switch
- 사전
- AHK
- 삼성 게이밍 모니터
- XL2430T
- 오버워치
- overwatch
- MSA14
- nircmd
- change speaker headset
- CFG70
- 매크로
- 모니터 비교
- 모니터 개봉기
- 헤드폰 스피커 자동 전환
- 인풋렉 측정
- switch speaker headset
- Lingoes
- 게이밍 모니터
- Today
- Total
깐우의 세상 만들기
(C언어)YUV video 파일 읽기 본문
Loading YUV file into memory using c(not c++)
원래 C++의 ifstream과 ofstream을 이용하려고 시도를 했었는데
fread를 대체하는 read 함수는 파라미터를 unsigned가 아닌 char만을 읽게 되어있다.
(write has same problem.)
형변환의 문제로 인해서 제대로 된 비디오가 나오지 못한다.
그래서 종일 구글링을 해봤지만 제대로 성공을 하지 못하고 결국 C로 다시 구현...
어쨋든 아래의 코드가 C를 이용한 yuv 파일의 로드 방법...
칼라니까 3/2을 잊지 말자
이유는 YUV 특성을 공부 할 것
// 메모리 선언 및 동적 메모리 할당
unsigned char **frame_no_loss_yuv;
frame_no_loss_yuv=new unsigned char *[this->Number_of_Frame];
for(int i=0;i<Number_of_Frame;i++)
{
frame_no_loss_yuv[i] = new unsigned char [this->width*this->height*3/2];
}
//읽어올 yuv 파일 선택
FILE* infile = fopen(no_loss_yuv, "rb");
if(!infile)
{
printf("No input file!!\n\n");
exit(100);
}
//yuv 파일을 메모리에 저장
for(int i=0;i<Number_of_Frame;i++)
{
fread(frame_no_loss_yuv[i],1,this->width*this->height*3/2,infile);
}
fclose(infile);
//메모리 내부 확인
FILE* outfile = fopen("test.yuv", "wb");
for(int i=0;i<Number_of_Frame;i++)
{
fwrite(frame_no_loss_yuv[i],1,this->width*this->height*3/2,outfile);
}
fclose(outfile);
'Book / Study' 카테고리의 다른 글
(C++) 해당 파일 존재시 다음 번호의 파일 생성하기(파일입출력) (0) | 2011.07.26 |
---|---|
(C++) 디버깅때는 에러가 없는데 실행시 에러가 생기는 경우 (0) | 2011.06.07 |
(C++) Ifstream 사용 법 (0) | 2011.04.28 |
(C/C++) 자주 사용되는 function (0) | 2011.04.07 |
(C++) Visual studio 실행파일(exe) 파일 찾기 (12) | 2011.03.31 |