Bonjour,

Je dois avoir du mal pour libérer mes structs, pointeurs et autre parce que mon programme a de grosse fuite mémoire (quelques giga en quelques secondes). Je crois avoir isoler le probleme dans ces deux fonctions, pouvez vous m'aider a me montrer ce que j'ai oublié de libérer et comment les libérer.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
BITMAP take_screenshot()
{
	HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);

	HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, 
							nScreenWidth, nScreenHeight);
	SelectObject(hCaptureDC,hCaptureBitmap); 
	BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,
		   hDesktopDC,0,0,SRCCOPY|CAPTUREBLT); 

  //Get Cursor Pos
  POINT xPoint;
  GetCursorPos( &xPoint );

  //Draw the Cursor
  bool g_recordcursor = 1;
  if (g_recordcursor == 1) {
    BOOL ret;
    CURSORINFO cinfo;
	cinfo.cbSize = sizeof(CURSORINFO);
	ret = GetCursorInfo(&cinfo);

	DrawIcon( hCaptureDC,  cinfo.ptScreenPos.x,  cinfo.ptScreenPos.y, cinfo.hCursor);

  }

	HBITMAP hNewBitmap = (HBITMAP)SelectObject(hCaptureDC, hCaptureBitmap);

	BITMAP bm;
	ZeroMemory(&bm,sizeof(BITMAP));
	GetObject(hNewBitmap, sizeof(bm), &bm);

	int bm_size = bm.bmWidthBytes * bm.bmHeight;
	bm.bmBits = new char[bm_size];
	long nfetched = GetBitmapBits(hCaptureBitmap, bm_size, bm.bmBits);

	DeleteDC(hCaptureDC);
	DeleteObject(hCaptureBitmap);
	DeleteObject(hNewBitmap);
	

	return bm;
}

static void fill_yuv_image(AVFrame *pict, int frame_index, int width, int height)
{
	BITMAP bm = take_screenshot();

	SwsContext *fooContext = sws_getContext(nScreenWidth,nScreenHeight,PIX_FMT_RGB32,
											width,height,STREAM_PIX_FMT,
											sws_flags,NULL,NULL,NULL);

	uint8_t *movie_dib_bits = reinterpret_cast<uint8_t *>(bm.bmBits);

	int dibrowbytes = bm.bmWidthBytes;

	uint8_t* data_out[4];
	int stride_out[4];
	data_out[0] = movie_dib_bits;

	stride_out[0] = dibrowbytes;

	sws_scale(fooContext,data_out,stride_out,0,nScreenHeight,pict->data,pict->linesize);

	// A partir d'ici j'ai besoin de plus rien sauf pict
	free(movie_dib_bits);
	DeleteObject(&bm);
}
Merci !