// File: /workspace/github_c_makefile_star2_O3/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 0x69c7
leaq 0x26968(%rip), %rdi     # 0x2d320
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
movl 0x24(%rbx), %eax
testl %eax, %eax
je 0x6a0e
leaq 0xc0(%rbx), %r14
xorl %r15d, %r15d
cmpl $0x0, (%r14)
je 0x6a00
movl (%rbx), %edi
movq %r14, %rsi
callq 0x22f0
movl 0x24(%rbx), %eax
incq %r15
movl %eax, %ecx
addq $0x50, %r14
cmpq %rcx, %r15
jb 0x69ed
movl 0x28(%rbx), %eax
testl %eax, %eax
je 0x6a40
leaq 0x1e0(%rbx), %r14
xorl %r15d, %r15d
cmpl $0x0, (%r14)
je 0x6a32
movl (%rbx), %edi
movq %r14, %rsi
callq 0x22f0
movl 0x28(%rbx), %eax
incq %r15
movl %eax, %ecx
addq $0x20, %r14
cmpq %rcx, %r15
jb 0x6a1f
cmpl $0x0, 0x260(%rbx)
je 0x6a57
leaq 0x260(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x280(%rbx)
je 0x6a6e
leaq 0x280(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x2a0(%rbx)
je 0x6a85
leaq 0x2a0(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x2c0(%rbx)
je 0x6a9c
leaq 0x2c0(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x60(%rbx)
je 0x6aad
leaq 0x60(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x40(%rbx)
je 0x6abe
leaq 0x40(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
cmpl $0x0, 0x80(%rbx)
je 0x6ad5
leaq 0x80(%rbx), %rsi
movl (%rbx), %edi
callq 0x22f0
movl (%rbx), %edi
callq 0x2190
leaq 0x26853(%rip), %rdi     # 0x2d336
callq 0x2280
movl $0xa, %edi
callq 0x2220
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)