Mercurial > x265
annotate source/x265.cpp @ 12733:e31211b2f00c draft default tip master
Disable fall-back on traditional scenecut algorithm with --hist-scenecut
author | Praveen Karadugattu <praveenkumar@multicorewareinc.com> |
---|---|
date | Sun, 20 Jun 2021 21:20:50 +0530 |
parents | a95232209362 |
children |
rev | line source |
---|---|
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
1 /***************************************************************************** |
12599
f161d75ee3bb
copyright: Update copyright in license header
Pradeep Ramachandran <pradeep@multicorewareinc.com>
parents:
12580
diff
changeset
|
2 * Copyright (C) 2013-2020 MulticoreWare, Inc |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
3 * |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
4 * Authors: Steve Borho <steve@borho.org> |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
5 * |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
9 * (at your option) any later version. |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
10 * |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
15 * |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
19 * |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
20 * This program is also available under a commercial proprietary license. |
6952
662e67f642bf
change license email globally
Steve Borho <steve@borho.org>
parents:
6951
diff
changeset
|
21 * For more information, contact us at license @ x265.com. |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
22 *****************************************************************************/ |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
23 |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
24 #if _MSC_VER |
1704
2139a564bc22
x265: more work on CLI options
Steve Borho <steve@borho.org>
parents:
1703
diff
changeset
|
25 #pragma warning(disable: 4127) // conditional expression is constant, yes I know |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
26 #endif |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
27 |
10799
c7f47dde1756
cli: move CSV and dither features into x265-extras, export from CLI on Windows
Steve Borho <steve@borho.org>
parents:
10785
diff
changeset
|
28 #include "x265.h" |
c7f47dde1756
cli: move CSV and dither features into x265-extras, export from CLI on Windows
Steve Borho <steve@borho.org>
parents:
10785
diff
changeset
|
29 #include "x265cli.h" |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
30 #include "abrEncApp.h" |
10799
c7f47dde1756
cli: move CSV and dither features into x265-extras, export from CLI on Windows
Steve Borho <steve@borho.org>
parents:
10785
diff
changeset
|
31 |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
32 #if HAVE_VLD |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
33 /* Visual Leak Detector */ |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
34 #include <vld.h> |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
35 #endif |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
36 |
1854 | 37 #include <signal.h> |
4043
ba3c040a62cf
cli: report errors from registering signal handler
Steve Borho <steve@borho.org>
parents:
4039
diff
changeset
|
38 #include <errno.h> |
ba3c040a62cf
cli: report errors from registering signal handler
Steve Borho <steve@borho.org>
parents:
4039
diff
changeset
|
39 #include <fcntl.h> |
6418
54183671a331
common: consolidate system header includes into common.h
Steve Borho <steve@borho.org>
parents:
6416
diff
changeset
|
40 |
1858
3269169efbc7
x265: Fix compile issue due to -Wwrite-strings and undeclared va_start() and va_end().
ShinYee Chung <shinyee@multicorewareinc.com>
parents:
1856
diff
changeset
|
41 #include <string> |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
42 #include <ostream> |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
43 #include <fstream> |
10070
88596b5ff601
cli: move raw bitstream output to separate file
Xinyue Lu <i@7086.in>
parents:
10025
diff
changeset
|
44 #include <queue> |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
45 |
10591
7f923017ead4
cmake: introduce EXPORT_C_API build variable
Steve Borho <steve@borho.org>
parents:
10590
diff
changeset
|
46 using namespace X265_NS; |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
47 |
12647 | 48 #define X265_HEAD_ENTRIES 3 |
12726
a95232209362
Fix mingw build warnings
Aruna <aruna@multicorewareinc.com>
parents:
12652
diff
changeset
|
49 #define CONSOLE_TITLE_SIZE 200 |
12647 | 50 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
51 #ifdef _WIN32 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
52 #define strdup _strdup |
12726
a95232209362
Fix mingw build warnings
Aruna <aruna@multicorewareinc.com>
parents:
12652
diff
changeset
|
53 static char orgConsoleTitle[CONSOLE_TITLE_SIZE] = ""; |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
54 #endif |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
55 |
11436
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
56 #ifdef _WIN32 |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
57 /* Copy of x264 code, which allows for Unicode characters in the command line. |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
58 * Retrieve command line arguments as UTF-8. */ |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
59 static int get_argv_utf8(int *argc_ptr, char ***argv_ptr) |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
60 { |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
61 int ret = 0; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
62 wchar_t **argv_utf16 = CommandLineToArgvW(GetCommandLineW(), argc_ptr); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
63 if (argv_utf16) |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
64 { |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
65 int argc = *argc_ptr; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
66 int offset = (argc + 1) * sizeof(char*); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
67 int size = offset; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
68 |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
69 for (int i = 0; i < argc; i++) |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
70 size += WideCharToMultiByte(CP_UTF8, 0, argv_utf16[i], -1, NULL, 0, NULL, NULL); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
71 |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
72 char **argv = *argv_ptr = (char**)malloc(size); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
73 if (argv) |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
74 { |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
75 for (int i = 0; i < argc; i++) |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
76 { |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
77 argv[i] = (char*)argv + offset; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
78 offset += WideCharToMultiByte(CP_UTF8, 0, argv_utf16[i], -1, argv[i], size - offset, NULL, NULL); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
79 } |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
80 argv[argc] = NULL; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
81 ret = 1; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
82 } |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
83 LocalFree(argv_utf16); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
84 } |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
85 return ret; |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
86 } |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
87 #endif |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
88 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
89 /* Checks for abr-ladder config file in the command line. |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
90 * Returns true if abr-config file is present. Returns |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
91 * false otherwise */ |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
92 |
12647 | 93 static bool checkAbrLadder(int argc, char **argv, FILE **abrConfig) |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
94 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
95 for (optind = 0;;) |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
96 { |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
97 int long_options_index = -1; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
98 int c = getopt_long(argc, argv, short_options, long_options, &long_options_index); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
99 if (c == -1) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
100 break; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
101 if (long_options_index < 0 && c > 0) |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
102 { |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
103 for (size_t i = 0; i < sizeof(long_options) / sizeof(long_options[0]); i++) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
104 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
105 if (long_options[i].val == c) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
106 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
107 long_options_index = (int)i; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
108 break; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
109 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
110 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
111 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
112 if (long_options_index < 0) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
113 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
114 /* getopt_long might have already printed an error message */ |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
115 if (c != 63) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
116 x265_log(NULL, X265_LOG_WARNING, "internal error: short option '%c' has no long option\n", c); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
117 return false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
118 } |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
119 } |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
120 if (long_options_index < 0) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
121 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
122 x265_log(NULL, X265_LOG_WARNING, "short option '%c' unrecognized\n", c); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
123 return false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
124 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
125 if (!strcmp(long_options[long_options_index].name, "abr-ladder")) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
126 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
127 *abrConfig = x265_fopen(optarg, "rb"); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
128 if (!abrConfig) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
129 x265_log_file(NULL, X265_LOG_ERROR, "%s abr-ladder config file not found or error in opening zone file\n", optarg); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
130 return true; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
131 } |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
132 } |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
133 return false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
134 } |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
135 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
136 static uint8_t getNumAbrEncodes(FILE* abrConfig) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
137 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
138 char line[1024]; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
139 uint8_t numEncodes = 0; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
140 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
141 while (fgets(line, sizeof(line), abrConfig)) |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
142 { |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
143 if (strcmp(line, "\n") == 0) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
144 continue; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
145 else if (!(*line == '#')) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
146 numEncodes++; |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
147 } |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
148 rewind(abrConfig); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
149 return numEncodes; |
12436
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
150 } |
6fad5bc4fe50
Add support for Dolby Vision RPU muxing
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12364
diff
changeset
|
151 |
12647 | 152 static bool parseAbrConfig(FILE* abrConfig, CLIOptions cliopt[], uint8_t numEncodes) |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
153 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
154 char line[1024]; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
155 char* argLine; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
156 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
157 for (uint32_t i = 0; i < numEncodes; i++) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
158 { |
12647 | 159 fgets(line, sizeof(line), abrConfig); |
160 if (*line == '#' || (strcmp(line, "\r\n") == 0)) | |
161 continue; | |
162 int index = (int)strcspn(line, "\r\n"); | |
163 line[index] = '\0'; | |
164 argLine = line; | |
165 char* start = strchr(argLine, ' '); | |
166 while (isspace((unsigned char)*start)) start++; | |
167 int argc = 0; | |
168 char **argv = (char**)malloc(256 * sizeof(char *)); | |
169 // Adding a dummy string to avoid file parsing error | |
170 argv[argc++] = (char *)"x265"; | |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
171 |
12647 | 172 /* Parse CLI header to identify the ID of the load encode and the reuse level */ |
173 char *header = strtok(argLine, "[]"); | |
174 uint32_t idCount = 0; | |
175 char *id = strtok(header, ":"); | |
176 char *head[X265_HEAD_ENTRIES]; | |
177 cliopt[i].encId = i; | |
12652
7c3bb9f913b6
csv: Fix corrupted command field in CSV summary with --abr-ladder option
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12647
diff
changeset
|
178 cliopt[i].isAbrLadderConfig = true; |
7c3bb9f913b6
csv: Fix corrupted command field in CSV summary with --abr-ladder option
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12647
diff
changeset
|
179 |
12647 | 180 while (id && (idCount <= X265_HEAD_ENTRIES)) |
181 { | |
182 head[idCount] = id; | |
183 id = strtok(NULL, ":"); | |
184 idCount++; | |
185 } | |
186 if (idCount != X265_HEAD_ENTRIES) | |
187 { | |
188 x265_log(NULL, X265_LOG_ERROR, "Incorrect number of arguments in ABR CLI header at line %d\n", i); | |
189 return false; | |
190 } | |
191 else | |
192 { | |
193 cliopt[i].encName = strdup(head[0]); | |
194 cliopt[i].loadLevel = atoi(head[1]); | |
195 cliopt[i].reuseName = strdup(head[2]); | |
196 } | |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
197 |
12647 | 198 char* token = strtok(start, " "); |
199 while (token) | |
200 { | |
12652
7c3bb9f913b6
csv: Fix corrupted command field in CSV summary with --abr-ladder option
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12647
diff
changeset
|
201 argv[argc++] = strdup(token); |
12647 | 202 token = strtok(NULL, " "); |
203 } | |
204 argv[argc] = NULL; | |
205 if (cliopt[i].parse(argc++, argv)) | |
206 { | |
207 cliopt[i].destroy(); | |
208 if (cliopt[i].api) | |
209 cliopt[i].api->param_free(cliopt[i].param); | |
210 exit(1); | |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
211 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
212 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
213 return true; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
214 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
215 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
216 static bool setRefContext(CLIOptions cliopt[], uint32_t numEncodes) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
217 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
218 bool hasRef = false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
219 bool isRefFound = false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
220 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
221 /* Identify reference encode IDs and set save/load reuse levels */ |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
222 for (uint32_t curEnc = 0; curEnc < numEncodes; curEnc++) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
223 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
224 isRefFound = false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
225 hasRef = !strcmp(cliopt[curEnc].reuseName, "nil") ? false : true; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
226 if (hasRef) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
227 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
228 for (uint32_t refEnc = 0; refEnc < numEncodes; refEnc++) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
229 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
230 if (!strcmp(cliopt[curEnc].reuseName, cliopt[refEnc].encName)) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
231 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
232 cliopt[curEnc].refId = refEnc; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
233 cliopt[refEnc].numRefs++; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
234 cliopt[refEnc].saveLevel = X265_MAX(cliopt[refEnc].saveLevel, cliopt[curEnc].loadLevel); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
235 isRefFound = true; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
236 break; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
237 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
238 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
239 if (!isRefFound) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
240 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
241 x265_log(NULL, X265_LOG_ERROR, "Reference encode (%s) not found for %s\n", cliopt[curEnc].reuseName, |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
242 cliopt[curEnc].encName); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
243 return false; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
244 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
245 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
246 } |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
247 return true; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
248 } |
9234
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
249 /* CLI return codes: |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
250 * |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
251 * 0 - encode successful |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
252 * 1 - unable to parse command line |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
253 * 2 - unable to open encoder |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
254 * 3 - unable to generate stream headers |
11795
958eb5ba1333
Add csv feature into libx265
Divya Manivannan <divya@multicorewareinc.com>
parents:
11729
diff
changeset
|
255 * 4 - encoder abort */ |
9234
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
256 |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
257 int main(int argc, char **argv) |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
258 { |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
259 #if HAVE_VLD |
3189
3adfc11534ca
vld: report leaks to file as well, useful for regression suite
Steve Borho <steve@borho.org>
parents:
3188
diff
changeset
|
260 // This uses Microsoft's proprietary WCHAR type, but this only builds on Windows to start with |
3adfc11534ca
vld: report leaks to file as well, useful for regression suite
Steve Borho <steve@borho.org>
parents:
3188
diff
changeset
|
261 VLDSetReportOptions(VLD_OPT_REPORT_TO_DEBUGGER | VLD_OPT_REPORT_TO_FILE, L"x265_leaks.txt"); |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
262 #endif |
8991
6fc63510b65d
ppa: minimize code foot-print of profiling events
Steve Borho <steve@borho.org>
parents:
8942
diff
changeset
|
263 PROFILE_INIT(); |
9057
94df19270eae
prof: add support for thread names
Steve Borho <steve@borho.org>
parents:
8993
diff
changeset
|
264 THREAD_NAME("API", 0); |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
265 |
9961
8bd529ef0e20
cli: save and restore console title before and after encoding
Xinyue Lu <i@7086.in>
parents:
9760
diff
changeset
|
266 GetConsoleTitle(orgConsoleTitle, CONSOLE_TITLE_SIZE); |
9963
06bd6630ebf8
cli: prevent Windows from falling into standby
Xinyue Lu <i@7086.in>
parents:
9961
diff
changeset
|
267 SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED); |
11436
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
268 #if _WIN32 |
11438
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
269 char** orgArgv = argv; |
11436
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
270 get_argv_utf8(&argc, &argv); |
5d7966923d73
Allows for Unicode filenames in Windows (output and stat files).
Ma0 <mateuszb@poczta.onet.pl>
parents:
11395
diff
changeset
|
271 #endif |
9961
8bd529ef0e20
cli: save and restore console title before and after encoding
Xinyue Lu <i@7086.in>
parents:
9760
diff
changeset
|
272 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
273 uint8_t numEncodes = 1; |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
274 FILE *abrConfig = NULL; |
12647 | 275 bool isAbrLadder = checkAbrLadder(argc, argv, &abrConfig); |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
276 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
277 if (isAbrLadder) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
278 numEncodes = getNumAbrEncodes(abrConfig); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
279 |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
280 CLIOptions* cliopt = new CLIOptions[numEncodes]; |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
281 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
282 if (isAbrLadder) |
4049
3a6b37e4a507
cli: fix memory leaks on early exits
Steve Borho <steve@borho.org>
parents:
4043
diff
changeset
|
283 { |
12647 | 284 if (!parseAbrConfig(abrConfig, cliopt, numEncodes)) |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
285 exit(1); |
12647 | 286 if (!setRefContext(cliopt, numEncodes)) |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
287 exit(1); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
288 } |
12647 | 289 else if (cliopt[0].parse(argc, argv)) |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
290 { |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
291 cliopt[0].destroy(); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
292 if (cliopt[0].api) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
293 cliopt[0].api->param_free(cliopt[0].param); |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
294 exit(1); |
4049
3a6b37e4a507
cli: fix memory leaks on early exits
Steve Borho <steve@borho.org>
parents:
4043
diff
changeset
|
295 } |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
296 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
297 int ret = 0; |
1854 | 298 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
299 AbrEncoder* abrEnc = new AbrEncoder(cliopt, numEncodes, ret); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
300 int threadsActive = abrEnc->m_numActiveEncodes.get(); |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
301 while (threadsActive) |
3237
3fa9a55c0fc1
x265: add x265_encoder_headers() public API
Steve Borho <steve@borho.org>
parents:
3190
diff
changeset
|
302 { |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
303 threadsActive = abrEnc->m_numActiveEncodes.waitForChange(threadsActive); |
12647 | 304 for (uint8_t idx = 0; idx < numEncodes; idx++) |
305 { | |
306 if (abrEnc->m_passEnc[idx]->m_ret) | |
307 { | |
308 if (isAbrLadder) | |
309 x265_log(NULL, X265_LOG_INFO, "Error generating ABR-ladder \n"); | |
310 ret = abrEnc->m_passEnc[idx]->m_ret; | |
311 threadsActive = 0; | |
312 break; | |
313 } | |
314 } | |
6631
a4cacffcf745
cli: add cli option for dither
Selvakumar Nithiyaruban <selvakumar@multicorewareinc.com>
parents:
6617
diff
changeset
|
315 } |
a4cacffcf745
cli: add cli option for dither
Selvakumar Nithiyaruban <selvakumar@multicorewareinc.com>
parents:
6617
diff
changeset
|
316 |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
317 abrEnc->destroy(); |
12647 | 318 delete abrEnc; |
319 | |
12639
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
320 for (uint8_t idx = 0; idx < numEncodes; idx++) |
a76ed145f75d
abr-ladder: Parse config file and launch ABR tiers
Aruna Matheswaran <aruna@multicorewareinc.com>
parents:
12634
diff
changeset
|
321 cliopt[idx].destroy(); |
6631
a4cacffcf745
cli: add cli option for dither
Selvakumar Nithiyaruban <selvakumar@multicorewareinc.com>
parents:
6617
diff
changeset
|
322 |
12647 | 323 delete[] cliopt; |
324 | |
9961
8bd529ef0e20
cli: save and restore console title before and after encoding
Xinyue Lu <i@7086.in>
parents:
9760
diff
changeset
|
325 SetConsoleTitle(orgConsoleTitle); |
9963
06bd6630ebf8
cli: prevent Windows from falling into standby
Xinyue Lu <i@7086.in>
parents:
9961
diff
changeset
|
326 SetThreadExecutionState(ES_CONTINUOUS); |
9961
8bd529ef0e20
cli: save and restore console title before and after encoding
Xinyue Lu <i@7086.in>
parents:
9760
diff
changeset
|
327 |
11438
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
328 #if _WIN32 |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
329 if (argv != orgArgv) |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
330 { |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
331 free(argv); |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
332 argv = orgArgv; |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
333 } |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
334 #endif |
8afe813ed82f
CLI: free memory allocated for utf8 command line in Windows
Ma0 <mateuszb@poczta.onet.pl>
parents:
11436
diff
changeset
|
335 |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
336 #if HAVE_VLD |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
337 assert(VLDReportLeaks() == 0); |
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
338 #endif |
9234
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
339 |
ab4ec7957d87
cli: improve and document return codes
Steve Borho <steve@borho.org>
parents:
9233
diff
changeset
|
340 return ret; |
1641
3c69c2060479
encoder: introduce new cli front-end, to eventually replace x265-cli
Steve Borho <steve@borho.org>
parents:
diff
changeset
|
341 } |