// File: /workspace/github_c_makefile_star2_O0/phoboslab[P]pl_mpeg/pl_mpeg_player_gl.c
// Function: app_on_video
void app_on_video(plm_t *mpeg, plm_frame_t *frame, void *user) {
	app_t *self = (app_t *)user;
	
	// Hand the decoded data over to OpenGL. For the RGB texture mode, the
	// YCrCb->RGB conversion is done on the CPU.

	if (self->texture_mode == APP_TEXTURE_MODE_YCRCB) {
		app_update_texture(self, GL_TEXTURE0, self->texture_y, &frame->y);
		app_update_texture(self, GL_TEXTURE1, self->texture_cb, &frame->cb);
		app_update_texture(self, GL_TEXTURE2, self->texture_cr, &frame->cr);

		// The dimensions of the planes are always rounded up to the next
		// multiple of 16. We don't want to display these extra pixels, so
		// calculate the crop w/h and hand it over to the shader program.
		float cw = (float)frame->width / (float)frame->y.width;
		float ch = (float)frame->height / (float)frame->y.height;
		glUniform2f(self->texture_crop_size, cw, ch);
	}
	else {
		plm_frame_to_rgb(frame, self->rgb_data, frame->width * 3);
	
		glBindTexture(GL_TEXTURE_2D, self->texture_rgb);
		glTexImage2D(
			GL_TEXTURE_2D, 0, GL_RGB, frame->width, frame->height, 0,
			GL_RGB, GL_UNSIGNED_BYTE, self->rgb_data
		);

		// plm_frame_to_rgb() always returns the cropped portion of the display
		// size, so the crop size is always 1.0, 1.0
		glUniform2f(self->texture_crop_size, 1.0, 1.0);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, 0x3c(%rax)
jne 0xc561
movq -0x20(%rbp), %rdi
movl 0x40(%rdi), %edx
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movl $0x84c0, %esi           # imm = 0x84C0
callq 0xca40
movq -0x20(%rbp), %rdi
movl 0x44(%rdi), %edx
movq -0x10(%rbp), %rcx
addq $0x30, %rcx
movl $0x84c1, %esi           # imm = 0x84C1
callq 0xca40
movq -0x20(%rbp), %rdi
movl 0x48(%rdi), %edx
movq -0x10(%rbp), %rcx
addq $0x20, %rcx
movl $0x84c2, %esi           # imm = 0x84C2
callq 0xca40
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movl 0x10(%rax), %eax
cvtsi2ss %rcx, %xmm0
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movl 0x14(%rax), %eax
cvtsi2ss %rcx, %xmm0
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x28(%rbp)
movq 0x5a22(%rip), %rax      # 0x11f68
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x4c(%rcx), %edi
movss -0x24(%rbp), %xmm0
movss -0x28(%rbp), %xmm1
callq *%rax
jmp 0xc5e9
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x10(%rbp), %rax
imull $0x3, 0x8(%rax), %edx
callq 0x8080
movq -0x20(%rbp), %rax
movl 0x50(%rax), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x21d0
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %r8d
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xde1, %edi            # imm = 0xDE1
xorl %r9d, %r9d
movl $0x1907, %edx           # imm = 0x1907
movl %r9d, %esi
movl $0x1907, (%rsp)         # imm = 0x1907
movl $0x1401, 0x8(%rsp)      # imm = 0x1401
movq %rax, 0x10(%rsp)
callq 0x20b0
movq 0x5996(%rip), %rax      # 0x11f68
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x4c(%rcx), %edi
movss 0x1f7c(%rip), %xmm1     # 0xe560
movaps %xmm1, %xmm0
callq *%rax
addq $0x40, %rsp
popq %rbp
retq
nop