// File: /workspace/github_c_makefile_star2_O0/xiane[P]libvphevcodec/AML_HEVCEncoder.cpp
// Function: AML_HEVCRelease(AMVHEVCEncHandle_s*)
AMVEnc_Status AML_HEVCRelease(AMVHEVCEncHandle *Handle) {
    int end = 1;

    if (Wave4VpuEncEncPic(Handle, Handle->src_idx, end, NULL, NULL, NULL) != AMVENC_SUCCESS) {
        VLOG(ERR, "Wave4VpuEncEncPic err\n");
    }
    Handle->src_idx++;
    Handle->src_idx = Handle->src_idx % Handle->src_count;
    Wave4VpuEncFiniSeq(Handle);

    for (unsigned int i = 0; i < Handle->src_num; i++) {
        if (Handle->src_pics[i].vb.size) {
            vdi_free_dma_memory(Handle->instance_id, &Handle->src_pics[i].vb);
        }
    }
    for (unsigned int i = 0; i < Handle->fb_num; i++) {
        if (Handle->fb_vb[i].size) {
            vdi_free_dma_memory(Handle->instance_id, &Handle->fb_vb[i]);
        }
    }
    if (Handle->fbc_ltable_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->fbc_ltable_vb);
    }
    if (Handle->fbc_ctable_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->fbc_ctable_vb);
    }
    if (Handle->fbc_mv_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->fbc_mv_vb);
    }
    if (Handle->subsample_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->subsample_vb);
    }
    if (Handle->temp_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->temp_vb);
    }
    if (Handle->work_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->work_vb);
    }
    if (Handle->bs_vb.size) {
        vdi_free_dma_memory(Handle->instance_id, &Handle->bs_vb);
    }
    vdi_release(Handle->instance_id);

#if SUPPORT_SCALE
    if (amlge2d.ge2dinfo.src_info[0].vaddr[0] != NULL) {
        aml_ge2d_mem_free(&amlge2d);
        aml_ge2d_exit(&amlge2d);
        amlge2d.ge2dinfo.src_info[0].vaddr[0] = NULL;
        VLOG(DEBUG, "ge2d exit!!!\n");
    }
#endif
    VLOG(INFO, "AML_HEVCRelease succeed\n");
    return AMVENC_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x1, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %esi
movl -0xc(%rbp), %edx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rcx
movq %r9, %r8
callq 0x2390
cmpl $0x1, %eax
je 0x8986
jmp 0x8968
leaq 0x279b1(%rip), %rdi     # 0x30320
movb $0x0, %al
callq 0x2050
leaq 0x278e9(%rip), %rdi     # 0x30266
movb $0x0, %al
callq 0x2050
jmp 0x8986
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x8(%rcx)
movq -0x8(%rbp), %rax
movl %edx, 0x4(%rax)
movq -0x8(%rbp), %rdi
callq 0x2360
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jae 0x8a11
movq -0x8(%rbp), %rax
addq $0xa0, %rax
movl -0x10(%rbp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x20(%rax)
je 0x8a04
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0xa0, %rsi
movl -0x10(%rbp), %eax
imulq $0x50, %rax, %rax
addq %rax, %rsi
addq $0x20, %rsi
callq 0x22f0
jmp 0x8a06
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x89ba
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jae 0x8a6a
movq -0x8(%rbp), %rax
addq $0x1e0, %rax            # imm = 0x1E0
movl -0x14(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x8a5d
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x1e0, %rsi            # imm = 0x1E0
movl -0x14(%rbp), %eax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x22f0
jmp 0x8a5f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8a18
movq -0x8(%rbp), %rax
cmpl $0x0, 0x260(%rax)
je 0x8a8d
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x260, %rsi            # imm = 0x260
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x280(%rax)
je 0x8ab0
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x280, %rsi            # imm = 0x280
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x2a0(%rax)
je 0x8ad3
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x2a0, %rsi            # imm = 0x2A0
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x2c0(%rax)
je 0x8af6
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x2c0, %rsi            # imm = 0x2C0
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x60(%rax)
je 0x8b13
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x60, %rsi
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x8b30
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x40, %rsi
callq 0x22f0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x80(%rax)
je 0x8b53
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
addq $0x80, %rsi
callq 0x22f0
movq -0x8(%rbp), %rax
movl (%rax), %edi
callq 0x21a0
leaq 0x277d2(%rip), %rdi     # 0x30337
movb $0x0, %al
callq 0x2050
leaq 0x276f3(%rip), %rdi     # 0x30266
movb $0x0, %al
callq 0x2050
movl $0x1, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop