레이블이 C인 게시물을 표시합니다. 모든 게시물 표시
레이블이 C인 게시물을 표시합니다. 모든 게시물 표시

2017년 1월 11일 수요일

4GB 이상 파일 포인터 지정( SetFilePointerEx )

4GB 이상의 파일의 파일포인터를 지정할때는 SetFilePointerEx를씀

int64_t llFileSeek (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = distance;
SetFilePointerEx(hf, li, &li, MoveMethod);
if (GetLastError() != NO_ERROR)
{
  li.QuadPart = -1;
}
    return li.QuadPart;
}


SetFilePointer를 쓸대는 QuadPart를 음수로 변환해서
난 잘 안되던데 왜인지.... 댓글좀
int64_t llFileSeek (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = -distance;
SetFilePointerEx(hf, li, &li, MoveMethod);
if (GetLastError() != NO_ERROR)
{
   li.QuadPart = -1;
}
    return li.QuadPart;
}

2016년 12월 5일 월요일

2015년 3월 12일 목요일

FFMPEG Video Decode

기본예제 http://ffmpeg.org/doxygen/trunk/decoding_encoding_8c-example.html#a83


  • Decode(H264 Codec)
avcodec_register_all();

AVCodec *pDecodeCodec = avcodec_find_decoder(AV_CODEC_ID_H264);
AVCodecContext *pDecodeCodecCtx = avcodec_alloc_context3(pDecodeCodec);
int nRet = avcodec_open2(pDecodeCodecCtx, pDecodeCodec, NULL);
if(nRet<0)
  fprintf("err\n");

AVPcket avpkt;
av_init_packet(&avpkt);
avpkt.data = (uint8_t*) stream; //영상데이터의 포인터
avpkt.size = sizeOfStream; //영상데이터의 크기
AVFrame *pFrame;
pFrame = avcodec_alloc_frame();
int got_picture = 0;
nRet = avcodec_decode_video2(pDecodeCodecCtx, pFrame, &got_picture, avpkt);

if(nRet < 0)
  fprintf("err\n");
if(got_picture)
  Docode 결과는 pFrame에 저장

이렇게 하면 디코딩이 된돠~
!!!주의 alloc한것들은 모두 free해줄 것.
다음에는 MFC에서 디코드된 결과를 화면에 뿌려주는것 정리해야지

2014년 7월 29일 화요일

[C++] 반올림

C++ (C)의 Math 라이브러리에는 반올림 함수가 없다.
그래서 보통? floor(x) 함수를 사용한다.
floor은 x보다 크지 않은 정수값을 반환한다.
반올림을 하고 싶으면 floor(x+0.5)를 하면 되겠다.