// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x4(%rdi), %esi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x23b0
cmpl $0x1, %eax
je 0x667b
leaq 0x25cb2(%rip), %rdi     # 0x2c320
callq 0x2290
pushq $0xa
popq %rdi
callq 0x2230
movl 0x4(%rbx), %eax
incl %eax
xorl %r15d, %r15d
xorl %edx, %edx
divl 0x8(%rbx)
movl %edx, 0x4(%rbx)
movq %rbx, %rdi
callq 0x2380
leaq 0xc0(%rbx), %r14
movl 0x24(%rbx), %eax
cmpq %rax, %r15
jae 0x66bb
cmpl $0x0, (%r14)
je 0x66b2
movl (%rbx), %edi
movq %r14, %rsi
callq 0x2310
incq %r15
addq $0x50, %r14
jmp 0x669a
leaq 0x1e0(%rbx), %r14
xorl %r15d, %r15d
movl 0x28(%rbx), %eax
cmpq %rax, %r15
jae 0x66e6
cmpl $0x0, (%r14)
je 0x66dd
movl (%rbx), %edi
movq %r14, %rsi
callq 0x2310
incq %r15
addq $0x20, %r14
jmp 0x66c5
cmpl $0x0, 0x260(%rbx)
je 0x66fd
leaq 0x260(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x280(%rbx)
je 0x6714
leaq 0x280(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x2a0(%rbx)
je 0x672b
leaq 0x2a0(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x2c0(%rbx)
je 0x6742
leaq 0x2c0(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x60(%rbx)
je 0x6753
leaq 0x60(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x40(%rbx)
je 0x6764
leaq 0x40(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
cmpl $0x0, 0x80(%rbx)
je 0x677b
leaq 0x80(%rbx), %rsi
movl (%rbx), %edi
callq 0x2310
movl (%rbx), %edi
callq 0x21a0
leaq 0x25bad(%rip), %rdi     # 0x2c336
callq 0x2290
pushq $0xa
popq %rdi
callq 0x2230
pushq $0x1
popq %rax
popq %rbx
popq %r14
popq %r15
retq
nop