-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added AVIF sanitizer tool #210
base: master
Are you sure you want to change the base?
Conversation
@y-guyon |
Just added him as "Team member" and Maintainer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
- I am not a fan of one big file.
- The concise functions were easy to read.
- I feel like there is some overlap with the Compliance Warden.
|
||
|
||
def write_integer_array_of_size(values: list[int], nbytes: int, unsigned: bool = True) -> bytes: | ||
"""Writes a value as an integer of nbytes size.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Writes values as integers each of nbytes size."""
self.file.seek(position) | ||
|
||
def read_integer_of_size(self, end: int, nbytes: int, unsigned: bool = True) -> int: | ||
"""Reads an integer of size nbytes from file.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: There could be some comment about endianness
self, nbytes: int, end: Optional[int] = None | ||
) -> "FileReader.BitReader": | ||
"""Returns a BitReader for the next nbytes of data.""" | ||
data = self.read_data(nbytes, end=end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is end=end
suggested by pylint?
buf.append(byte[0]) | ||
if len(buf) > 0: | ||
return decode_data_to_string(buf) | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent
return decode_data_to_string(buf) if len(buf) > 0 else None
vs
if len(buf) > 0:
return decode_data_to_string(buf)
return None
def add_property_association( | ||
self, item_id: int, ipco_index: int, essential: bool, position: Optional[int] = None | ||
) -> None: | ||
"""Add an association from an item to a property in the ipco box.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""... if not already present."""
?
description = "No 'pixi' present. This is a requirement by MIAF." | ||
else: | ||
description = ( | ||
"'pixi' does not match Sequence Header OBU." + f" {existing_pixi} != {generated_pixi}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "AV1" before "Sequence Header OBU" would be clearer for novices
fixed_clap["v_offset"] = [round(fixed_offset[1] * 2), 2] | ||
parsed_file.replace_property_for_item(BoxType("clap"), {}, fixed_clap, item_id) | ||
|
||
issue.add_fix(_fix_clap_origin, f"Truncate origin to {trunc_origin[0]}x{trunc_origin[1]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Truncate 'clap' origin"?
|
||
|
||
def validate_file(parsed_file: ParsedFile, default_nclx: dict[str, list[int]]) -> list[BoxIssue]: | ||
"""Validates that a AVIF file is correct.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an*
) | ||
parser.add_argument( | ||
"-o", | ||
"--only-verify", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--dry-run" maybe?
Agreed. It would have been nicer from a readability perspective to have it split into submodules, but I decided to keep it monolithic due to the following:
Again agreed. I mention in the help text that it's not a replacement for Compliance Warden since it will only detect a subset of actually fixable issues. |
No description provided.