// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImgList<double>::save_ffmpeg_external(char const*, unsigned int, char const*, unsigned int) const
const CImgList<T>& save_ffmpeg_external(const char *const filename, const unsigned int fps=25,
                                            const char *const codec=0, const unsigned int bitrate=2048) const {
      if (!filename)
        throw CImgArgumentException(_cimglist_instance
                                    "save_ffmpeg_external(): Specified filename is (null).",
                                    cimglist_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }

      const char
        *const ext = cimg::split_filename(filename),
        *const _codec = codec?codec:!cimg::strcasecmp(ext,"flv")?"flv":"mpeg2video";

      char command[1024] = { 0 }, filetmp[512] = { 0 }, filetmp2[512] = { 0 };
      CImgList<charT> filenames;
      std::FILE *file = 0;
      cimglist_for(*this,l) if (!_data[l].is_sameXYZ(_data[0]))
        throw CImgInstanceException(_cimglist_instance
                                    "save_ffmpeg_external(): Invalid instance dimensions for file '%s'.",
                                    cimglist_instance,
                                    filename);
      do {
        cimg_snprintf(filetmp,sizeof(filetmp),"%s%c%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
        cimg_snprintf(filetmp2,sizeof(filetmp2),"%s_000001.ppm",filetmp);
        if ((file=std::fopen(filetmp2,"rb"))!=0) cimg::fclose(file);
      } while (file);
      cimglist_for(*this,l) {
        cimg_snprintf(filetmp2,sizeof(filetmp2),"%s_%.6u.ppm",filetmp,l+1);
        CImg<charT>::string(filetmp2).move_to(filenames);
        if (_data[l]._depth>1 || _data[l]._spectrum!=3) _data[l].get_resize(-100,-100,1,3).save_pnm(filetmp2);
        else _data[l].save_pnm(filetmp2);
      }
#if cimg_OS!=2
      cimg_snprintf(command,sizeof(command),"%s -i \"%s_%%6d.ppm\" -vcodec %s -b %uk -r %u -y \"%s\" >/dev/null 2>&1",
                    cimg::ffmpeg_path(),
                    CImg<charT>::string(filetmp)._system_strescape().data(),
                    _codec,bitrate,fps,
                    CImg<charT>::string(filename)._system_strescape().data());
#else
      cimg_snprintf(command,sizeof(command),"\"%s -i \"%s_%%6d.ppm\" -vcodec %s -b %uk -r %u -y \"%s\"\" >NUL 2>&1",
                    cimg::ffmpeg_path(),
                    CImg<charT>::string(filetmp)._system_strescape().data(),
                    _codec,bitrate,fps,
                    CImg<charT>::string(filename)._system_strescape().data());
#endif
      cimg::system(command);
      file = std::fopen(filename,"rb");
      if (!file)
        throw CImgIOException(_cimglist_instance
                              "save_ffmpeg_external(): Failed to save file '%s' with external command 'ffmpeg'.",
                              cimglist_instance,
                              filename);
      else cimg::fclose(file);
      cimglist_for(*this,l) std::remove(filenames[l]);
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x878, %rsp            # imm = 0x878
movq %rdi, %rbx
testq %rsi, %rsi
je 0x4b687
movq %rsi, %r12
cmpq $0x0, 0x8(%rbx)
je 0x4b40e
cmpl $0x0, (%rbx)
je 0x4b40e
movl %r8d, %r13d
movq %rcx, %r15
movq %rdx, 0x28(%rsp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x2cc28
testq %r15, %r15
jne 0x4b351
leaq 0x29ea8(%rip), %r14     # 0x751e1
movq %rax, %rdi
movq %r14, %rsi
callq 0x2ccbe
testl %eax, %eax
leaq 0x2d9d4(%rip), %r15     # 0x78d21
cmoveq %r14, %r15
movq %r15, 0x20(%rsp)
leaq 0x470(%rsp), %rdi
xorl %r14d, %r14d
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x4280
leaq 0x70(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x4280
leaq 0x270(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x4280
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
pushq $-0x1
popq %r15
movslq (%rbx), %rax
incq %r15
cmpq %rax, %r15
jge 0x4b41d
movq 0x8(%rbx), %rsi
leaq (%rsi,%r14), %rdi
callq 0x4b788
addq $0x20, %r14
testb %al, %al
jne 0x4b39d
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r8
subq $0x8, %rsp
leaq 0x2d94e(%rip), %rsi     # 0x78d2c
leaq 0x29cba(%rip), %r9      # 0x7509f
movq %rax, %rdi
xorl %eax, %eax
pushq %r12
callq 0x9bf8
popq %rax
popq %rcx
leaq 0x4484e(%rip), %rsi     # 0x8fc48
movq 0x44bd7(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
jmp 0x4b717
xorl %edi, %edi
movq %r12, %rsi
callq 0x465c3
jmp 0x4b672
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
leaq 0x70(%rsp), %r15
leaq 0x2bb80(%rip), %r12     # 0x76fb3
leaq 0x270(%rsp), %r13
leaq 0x29df9(%rip), %r14     # 0x7523b
xorl %edi, %edi
xorl %esi, %esi
callq 0x2a028
movq %rax, %rbp
callq 0x2a352
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdi
leaq 0x29b74(%rip), %rdx     # 0x74fd6
movq %rbp, %rcx
pushq $0x2f
popq %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x4890
movl $0x200, %esi            # imm = 0x200
movq %r13, %rdi
movq %r12, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x4890
movq %r13, %rdi
movq %r14, %rsi
callq 0x45b0
testq %rax, %rax
je 0x4b4a2
movq %rax, %rdi
callq 0x2a2f8
jmp 0x4b442
leaq 0x270(%rsp), %r15
leaq 0x30(%rsp), %r13
pushq $0x1
popq %r14
xorl %r12d, %r12d
xorl %ebp, %ebp
movslq (%rbx), %rax
cmpq %rax, %rbp
jge 0x4b577
leal 0x1(%rbp), %r8d
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdi
leaq 0x2bb16(%rip), %rdx     # 0x76fed
leaq 0x70(%rsp), %rcx
xorl %eax, %eax
callq 0x4890
movq %r13, %rdi
movq %r15, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x38750
movq %r13, %rdi
movq %rsp, %rsi
pushq $-0x1
popq %rdx
callq 0x38e02
movq %r13, %rdi
callq 0xdba4
movq 0x8(%rbx), %rax
leaq (%rax,%r12), %rsi
cmpl $0x1, 0x8(%rax,%r12)
ja 0x4b530
cmpl $0x3, 0xc(%rax,%r12)
jne 0x4b530
movq %rsi, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x44fda
jmp 0x4b56b
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
movq %r13, %rdi
pushq $-0x64
popq %rcx
movl %ecx, %edx
movl %r14d, %r8d
pushq $0x3
popq %r9
pushq $0x0
pushq $0x1
callq 0x2eeec
popq %rax
popq %rcx
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x44fda
movq %r13, %rdi
callq 0x6c96
addq $0x20, %r12
incq %rbp
jmp 0x4b4b8
xorl %edi, %edi
xorl %esi, %esi
callq 0x42d4f
movq 0x18(%rsp), %r13
movq %rax, %r14
leaq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0x38750
leaq 0x30(%rsp), %rdi
callq 0x387b0
movq 0x18(%rax), %r15
leaq 0x50(%rsp), %rdi
pushq $0x1
popq %rdx
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x38750
leaq 0x50(%rsp), %rdi
callq 0x387b0
movq %rax, %r10
subq $0x8, %rsp
leaq 0x2d7be(%rip), %rdx     # 0x78d92
leaq 0x478(%rsp), %r12
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
movq %r14, %rcx
movq %r15, %r8
movq 0x28(%rsp), %r9
xorl %eax, %eax
pushq 0x18(%r10)
pushq 0x38(%rsp)
pushq 0x28(%rsp)
callq 0x4890
addq $0x20, %rsp
leaq 0x50(%rsp), %rdi
callq 0xdba4
leaq 0x30(%rsp), %rdi
callq 0xdba4
movq %r12, %rdi
xorl %esi, %esi
callq 0x2e487
leaq 0x29c10(%rip), %rsi     # 0x7523b
movq %r13, %rdi
callq 0x45b0
testq %rax, %rax
je 0x4b6cb
movq %rax, %rdi
callq 0x2a2f8
pushq $0x18
popq %r14
xorl %r15d, %r15d
movslq (%rbx), %rax
cmpq %rax, %r15
jge 0x4b66a
movq 0x8(%rsp), %rax
movq (%rax,%r14), %rdi
callq 0x4990
incq %r15
addq $0x20, %r14
jmp 0x4b64b
movq %rsp, %rdi
callq 0xdbb8
movq %rbx, %rax
addq $0x878, %rsp            # imm = 0x878
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r8
leaq 0x2d624(%rip), %rsi     # 0x78cc8
leaq 0x299f4(%rip), %r9      # 0x7509f
movq %rax, %rdi
xorl %eax, %eax
callq 0x9d52
leaq 0x445a4(%rip), %rsi     # 0x8fc60
movq 0x44915(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r8
subq $0x8, %rsp
leaq 0x2d6ea(%rip), %rsi     # 0x78dd6
leaq 0x299ac(%rip), %r9      # 0x7509f
movq %rax, %rdi
xorl %eax, %eax
pushq %r13
callq 0x2a3de
popq %rax
popq %rcx
leaq 0x445f8(%rip), %rsi     # 0x8fd00
movq 0x448c9(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
jmp 0x4b744
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xdba4
jmp 0x4b72d
jmp 0x4b72a
movq %rax, %rbx
jmp 0x4b767
jmp 0x4b775
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
jmp 0x4b780
jmp 0x4b775
jmp 0x4b775
jmp 0x4b775
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
jmp 0x4b778
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6c96
jmp 0x4b778
jmp 0x4b775
jmp 0x4b775
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xdba4
jmp 0x4b778
jmp 0x4b775
movq %rax, %rbx
movq %rsp, %rdi
callq 0xdbb8
movq %rbx, %rdi
callq 0x4950