Àç¹Ì¾ø´Â ¿µÈ¸¦ 1¹è¼ÓÀ¸·Î °è¼Ó ÁöÄÑ º¸´Â °ÍÀº °í¿ª½º·¯¿î ÀÏÀÌ´Ù. Èĵü Èĵü ºÁ Ä¡¿ì°í ½ÍÀ» ¶§´Â ¹è¼ÓÀ» ³ô¿© Àç»ýÇÑ´Ù. ´ÙÀ½ Àü¿ª
º¯¼ö¸¦ Ãß°¡ÇÑ´Ù.
struct sOption {
....
int
speed = 100;
int
speedstep = 10;
};
volatile bool isResample;
volatile bool resampleReady;
speed´Â ¹éºÐÀ²·Î Ç¥ÇöÇÏ´Â Àç»ý ¼ÓµµÀ̸ç speedstepÀº ¼Óµµ¸¦ Á¶Á¤ÇÒ ´Ü°è°ªÀÌ´Ù. ¼Óµµ°¡ º¯°æµÇ¸é ¿Àµð¿ÀÀÇ
¸®»ùÇøµ ÄÁÅؽºÆ®¸¦ ÀçÃʱâÈÇÑ´Ù.
DWORD WINAPI AudioThread(LPVOID para) {
....
while
(isResample) {
resampleReady
= true;
}
....
if
(swrCtx == NULL) {
int
srate = aFrame.sample_rate;
int
channel = aFrame.channels;
int64_t
chanlay = av_get_default_channel_layout(channel);
AVSampleFormat
format = (AVSampleFormat)aFrame.format;
swrCtx
= swr_alloc_set_opts(NULL, AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_S16,
44100
* 100 / op.speed, chanlay, format, srate, 0, NULL);
swr_init(swrCtx);
}
Àç»ýÇÒ »ùÇ÷¹ÀÌÆ®¿¡ ¹è¼ÓÀ» Á¶Á¤Çϴµ¥ 2¹è¼ÓÀ̸é Àý¹ÝÀÇ »ùÇø¸ Àç»ýÇϸé
µÈ´Ù. µå·Î¿ì´Â ÇÁ·¹ÀÓ·¹ÀÌÆ®¿¡ ¹Ý¿µÇÑ´Ù.
DWORD WINAPI DrawThread(LPVOID para) {
int64_t
framegap;
...
for
(;;) {
....
framegap
= int64_t(AV_TIME_BASE / (framerate * op.speed / 100));
¼±¾ð¹®ÀÇ Ãʱâ½ÄÀº »èÁ¦ÇÏ°í ·çÇÁ ³»ºÎ¿¡¼ °è»êÇÑ´Ù. ÀÌ°Å Á¶Á¤ ¾ÈÇصµ
¿Àµð¿À°¡ »¡¶óÁö¸é ºñµð¿Àµµ ½ÌÅ© À¯Áö ÇÏ´À¶ó °°ÀÌ »¡¶óÁöÁö¸¸ Á» ´õ »¡¸® µû¶ó Àâµµ·Ï °°ÀÌ Á¶Á¤Çß´Ù. ¾×¼¿·¯·¹ÀÌÅÍ¿¡¼ 100 ~ 200 »çÀÌÀÇ ¹è¼ÓÀ» Á¶Á¤ÇÏ°í ¿À¹ö·¹ÀÌ ¸Þ½ÃÁö¿¡ ÇöÀç ¹è¼ÓÀ» Ãâ·ÂÇÑ´Ù.
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage,
WPARAM wParam, LPARAM lParam) {
TCHAR
tMsg[128];
....
case
A_W:
case
A_S:
isResample
= true;
resampleReady
= false;
while
(resampleReady == false) { ; }
if
(swrCtx != NULL) { swr_free(&swrCtx); }
if
(LOWORD(wParam) == A_W) {
op.speed
= min(200, op.speed + op.speedstep);
}
else {
op.speed
= max(20, op.speed - op.speedstep);
}
wsprintf(tMsg,
TEXT("Speed = %d"), op.speed);
SetOverlayMsg(tMsg,
2, 0, 3000);
isResample
= false;
break;
¹è¼Ó Á¶Á¤ÀÌ Àß µÇÁö¸¸ ºü¸¥ ¼Óµµ·Î Àç»ýÇϸé À½¼ºÀ» ¾Ë¾Æ µè±â°¡ ¾î·Æ´Ù. ¼Óµµ¸¦
³ôÀ̸鼵µ À½¼ºÀ» ³Ê¹« ÈѼÕÇÏÁö ¾Êµµ·Ï ¿¬±¸°¡ ´õ ÇÊ¿äÇÏ´Ù. ±×¸®°í ¹öÆÛ¿¡ ÀÌ¹Ì »ùÇøµÇØ ³õÀº °ÍÀº
¹Ù·Î Àû¿ëµÇÁö ¾Ê´Âµ¥ À½¼º ¹öÆÛ°¡ Å©´Ù º¸´Ï ºñ¿ì±â ¾î·Æ°í ÀÌ¹Ì ³Ö¾î ³õÀº °É »©³»¼ Á¶ÀÛÇϱ⵵ ¾î·Æ´Ù. ´ÙÀ½
¹öÀü¿¡¼ ´õ °³¼±ÇØ º¼ ¿¹Á¤ÀÌ´Ù.