// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2380
cmpl $0x1, %eax
je 0x69e7
leaq 0x26930(%rip), %rdi     # 0x2d308
callq 0x2280
movl $0xa, %edi
callq 0x2220
movl 0x4(%rbx), %eax
incl %eax
xorl %edx, %edx
divl 0x8(%rbx)
movl %edx, 0x4(%rbx)
movq %rbx, %rdi
callq 0x2360
cmpl $0x0, 0x24(%rbx)
je 0x6a2b
leaq 0xc0(%rbx), %r14
xorl %r15d, %r15d
cmpl $0x0, (%r14)
je 0x6a1c
movl (%rbx), %edi
movq %r14, %rsi
callq 0x22f0
incq %r15
movl 0x24(%rbx), %eax
addq $0x50, %r14
cmpq %rax, %r15
jb 0x6a0c
cmpl $0x0, 0x28(%rbx)
je 0x6a5a
leaq 0x1e0(%rbx), %r14
xorl %r15d, %r15d
cmpl $0x0, (%r14)
je 0x6a4b
movl (%rbx), %edi
movq %r14, %rsi
callq 0x22f0
incq %r15
movl 0x28(%rbx), %eax
addq $0x20, %r14
cmpq %rax, %r15
jb 0x6a3b
cmpl $0x0, 0x260(%rbx)
je 0x6a71
leaq 0x260(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x280(%rbx)
je 0x6a88
leaq 0x280(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x2a0(%rbx)
je 0x6a9f
leaq 0x2a0(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x2c0(%rbx)
je 0x6ab6
leaq 0x2c0(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x60(%rbx)
je 0x6ac7
leaq 0x60(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x40(%rbx)
je 0x6ad8
leaq 0x40(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x80(%rbx)
je 0x6aef
leaq 0x80(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
movl (%rbx), %edi
callq 0x2190
leaq 0x26821(%rip), %rdi     # 0x2d31e
callq 0x2280
movl $0xa, %edi
callq 0x2220
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
retq
nop