Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Jean-Baptiste Kempf
libaacs
Commits
3d91f76e
Commit
3d91f76e
authored
Jul 09, 2020
by
npzacs
Committed by
hpi1
Jul 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read MKB_RO.inf in chunks, skip padding
Makes opening UHD discs ~10 second faster
parent
76327e6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
2 deletions
+52
-2
src/libaacs/aacs.c
src/libaacs/aacs.c
+52
-2
No files found.
src/libaacs/aacs.c
View file @
3d91f76e
...
...
@@ -473,17 +473,67 @@ static size_t _read_file(AACS *aacs, const char *file, void **data)
return
*
data
?
size
:
0
;
}
static
size_t
_read_mkb_file
(
AACS
*
aacs
,
const
char
*
file
,
void
**
pdata
)
{
AACS_FILE_H
*
fp
;
size_t
size
=
0
;
size_t
data_size
=
65536
;
/* initial alloc */
uint32_t
chunk_size
=
4
;
/* initial read */
uint8_t
*
data
;
*
pdata
=
NULL
;
fp
=
_file_open
(
aacs
,
file
);
if
(
!
fp
)
{
BD_DEBUG
(
DBG_AACS
|
DBG_CRIT
,
"Unable to open %s
\n
"
,
file
);
return
0
;
}
data
=
malloc
(
data_size
);
if
(
!
data
)
{
BD_DEBUG
(
DBG_AACS
|
DBG_CRIT
,
"Out of memory
\n
"
);
file_close
(
fp
);
return
0
;
}
do
{
int64_t
read_size
=
chunk_size
;
if
(
file_read
(
fp
,
data
+
size
,
read_size
)
!=
read_size
)
{
BD_DEBUG
(
DBG_AACS
|
DBG_CRIT
,
"Failed reading %s
\n
"
,
file
);
X_FREE
(
data
);
break
;
}
size
+=
read_size
;
chunk_size
=
MKINT_BE24
(
data
+
size
-
4
+
1
);
if
(
data_size
<
size
+
chunk_size
)
{
for
(
;
data_size
<
size
+
chunk_size
;
data_size
*=
2
)
;
void
*
tmp
=
realloc
(
data
,
data_size
);
if
(
!
tmp
)
{
X_FREE
(
data
);
break
;
}
data
=
tmp
;
}
}
while
(
chunk_size
>=
4
);
file_close
(
fp
);
*
pdata
=
data
;
return
data
?
size
:
0
;
}
static
MKB
*
_mkb_open
(
AACS
*
aacs
)
{
size_t
size
;
void
*
data
;
MKB
*
mkb
;
size
=
_read_file
(
aacs
,
"AACS"
DIR_SEP
"MKB_RO.inf"
,
&
data
);
size
=
_read_
mkb_
file
(
aacs
,
"AACS"
DIR_SEP
"MKB_RO.inf"
,
&
data
);
if
(
size
<
4
)
{
/* retry with backup file */
X_FREE
(
data
);
size
=
_read_file
(
aacs
,
"AACS"
DIR_SEP
"DUPLICATE"
DIR_SEP
"MKB_RO.inf"
,
&
data
);
size
=
_read_
mkb_
file
(
aacs
,
"AACS"
DIR_SEP
"DUPLICATE"
DIR_SEP
"MKB_RO.inf"
,
&
data
);
}
if
(
size
<
4
)
{
X_FREE
(
data
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment