// File: OtherCrashOverride[P]xu4enc/./M2M.h
// Function: M2M::CreateOutputBuffers()
void CreateOutputBuffers()
	{
		// Request buffers
		v4l2_requestbuffers requestBuffers = { 0 };
		requestBuffers.count = BUFFER_COUNT;
		requestBuffers.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
		requestBuffers.memory = V4L2_MEMORY_MMAP;

		int io = ioctl(mfc_fd, VIDIOC_REQBUFS, &requestBuffers);
		if (io < 0)
		{
			throw Exception("VIDIOC_REQBUFS failed.");
		}

		if (requestBuffers.count > BUFFER_COUNT)
		{
			throw Exception("too many buffers.");
		}
		else
		{
			fprintf(stderr, "CreateOutputBuffers: requestBuffers.count=%d\n", requestBuffers.count);
		}


		// Map buffers
		//BufferMapping bufferMappings[requestBuffers.count] = { 0 };
		for (int i = 0; i < requestBuffers.count; ++i)
		{
			v4l2_plane planes[VIDEO_MAX_PLANES];

			v4l2_buffer buffer = { 0 };
			buffer.type = requestBuffers.type;
			buffer.memory = V4L2_MEMORY_MMAP;
			buffer.index = i;
			buffer.m.planes = planes;
			buffer.length = 1;

			io = ioctl(mfc_fd, VIDIOC_QUERYBUF, &buffer);
			if (io < 0)
			{
				throw Exception("VIDIOC_QUERYBUF failed.");
			}

			BufferMapping mapping = { 0 };

			mapping.Length0 = buffer.m.planes[0].length;
			mapping.Start0 = mmap(NULL, mapping.Length0,
				PROT_READ | PROT_WRITE, /* recommended */
				MAP_SHARED,             /* recommended */
				mfc_fd,
				buffer.m.planes[0].m.mem_offset);
			if (mapping.Start0 == MAP_FAILED)
			{
				throw Exception("mmap 0 failed.");
			}

			//mapping.Length1 = buffer.m.planes[1].length;
			//mapping.Start1 = mmap(NULL, mapping.Length1,
			//	PROT_READ | PROT_WRITE, /* recommended */
			//	MAP_SHARED,             /* recommended */
			//	mfc_fd,
			//	buffer.m.planes[1].m.mem_offset);
			//if (mapping.Start1 == MAP_FAILED)
			//{
			//	throw Exception("mmap 1 failed.");
			//}

			outputBuffers.push_back(mapping);

			// Queue buffers
			int ret = ioctl(mfc_fd, VIDIOC_QBUF, &buffer);
			if (ret != 0)
			{
				throw Exception("VIDIOC_QBUF failed.");
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x1c(%rbp), %rdi
xorl %esi, %esi
movl $0x14, %edx
callq 0x20b0
movq -0x2b8(%rbp), %rax
movl $0x4, -0x1c(%rbp)
movl $0x9, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
movl 0x8(%rax), %edi
movl $0xc0145608, %esi       # imm = 0xC0145608
leaq -0x1c(%rbp), %rdx
movb $0x0, %al
callq 0x2120
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x3ece
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c0(%rbp)
leaq 0x3546(%rip), %rsi      # 0x73d6
callq 0x28c0
jmp 0x3e97
movq -0x2c0(%rbp), %rdi
leaq 0x6ecb(%rip), %rsi      # 0xad70
leaq -0x158c(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x41a5
cmpl $0x4, -0x1c(%rbp)
jbe 0x3f30
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
leaq 0x34fb(%rip), %rsi      # 0x73ed
callq 0x28c0
jmp 0x3ef9
movq -0x2c8(%rbp), %rdi
leaq 0x6e69(%rip), %rsi      # 0xad70
leaq -0x15ee(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x41a5
movq 0x70a9(%rip), %rax      # 0xafe0
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x3568(%rip), %rsi      # 0x74ac
movb $0x0, %al
callq 0x2130
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x419c
leaq -0x288(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x20b0
movq -0x2b8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x284(%rbp)
movl $0x1, -0x24c(%rbp)
movl -0x30(%rbp), %ecx
movl %ecx, -0x288(%rbp)
leaq -0x230(%rbp), %rcx
movq %rcx, -0x248(%rbp)
movl $0x1, -0x240(%rbp)
movl 0x8(%rax), %edi
movl $0xc0585609, %esi       # imm = 0xC0585609
leaq -0x288(%rbp), %rdx
movb $0x0, %al
callq 0x2120
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x4027
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d0(%rbp)
leaq 0x3443(%rip), %rsi      # 0x742c
callq 0x28c0
jmp 0x3ff0
movq -0x2d0(%rbp), %rdi
leaq 0x6d72(%rip), %rsi      # 0xad70
leaq -0x16e5(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x41a5
leaq -0x2a8(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x20b0
movq -0x2b8(%rbp), %rax
movq -0x248(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq %rcx, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rsi
movl 0x8(%rax), %r8d
movq -0x248(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %r9d
xorl %eax, %eax
movl %eax, %edi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x21d0
movq %rax, -0x2a8(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x2a8(%rbp)
jne 0x40f0
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
leaq 0x3392(%rip), %rsi      # 0x7444
callq 0x28c0
jmp 0x40b9
movq -0x2d8(%rbp), %rdi
leaq 0x6ca9(%rip), %rsi      # 0xad70
leaq -0x17ae(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x41a5
movq -0x2b8(%rbp), %rdi
addq $0x38, %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x4f10
movq -0x2b8(%rbp), %rax
movl 0x8(%rax), %edi
movl $0xc058560f, %esi       # imm = 0xC058560F
leaq -0x288(%rbp), %rdx
movb $0x0, %al
callq 0x2120
movl %eax, -0x2ac(%rbp)
cmpl $0x0, -0x2ac(%rbp)
je 0x418c
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2e0(%rbp)
leaq 0x3389(%rip), %rsi      # 0x74da
callq 0x28c0
jmp 0x4158
movq -0x2e0(%rbp), %rdi
leaq 0x6c0a(%rip), %rsi      # 0xad70
leaq -0x184d(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x41a5
jmp 0x418e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3f52
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x21c0
nop