-
Notifications
You must be signed in to change notification settings - Fork 1
Parse convert CLI arguments into pipeline steps #4
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
Open
guilhhotina
wants to merge
11
commits into
gly-engine:develop
Choose a base branch
from
guilhhotina:convert-argv-pipeline
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a934063
fix: report missing pipeline paths
guilhhotina f53f736
feat: parse convert arguments into pipeline steps
guilhhotina 334351f
fix: align codec path test with decode flow
guilhhotina 3790f18
feat: tokenize convert commands
guilhhotina fadfb3c
test: cover convert command tokenizer
guilhhotina 7876068
fix: use defer cleanup in convert cli
guilhhotina d944463
refactor: move format magic detection to common string
guilhhotina 87369fd
feat: parse crop geometry token
guilhhotina d64db45
fix: use project cleanup block in convert cli
guilhhotina 8c3630a
fix: parse crop geometry without offsets
guilhhotina 5788504
fix: reject unsupported crop geometry
guilhhotina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #include <stddef.h> | ||
| #include <string.h> | ||
|
|
||
| #include "haio.h" | ||
|
|
||
| haio_type_t GetFormatFromMagic(const unsigned char *buffer, size_t len) | ||
| { | ||
| static const unsigned char png_signature[] = { | ||
| 0x89, 'P', 'N', 'G', '\r', '\n', 0x1a, '\n' | ||
| }; | ||
|
|
||
| if (len >= sizeof(png_signature) && | ||
| memcmp(buffer, png_signature, sizeof(png_signature)) == 0) { | ||
| return HAIO_TYPE_IMG_PNG; | ||
| } | ||
|
|
||
| return HAIO_TYPE_NULL; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #pragma once | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
| #include <stdio.h> | ||
|
|
||
| #include "haio.h" | ||
|
|
||
| #define CONVERT_MAX_TOKENS 32 | ||
| #define CONVERT_FORMAT_PROBE_SIZE 16 | ||
|
|
||
| typedef enum { | ||
| CONVERT_TOKEN_INPUT_FILE, | ||
| CONVERT_TOKEN_OUTPUT_FILE, | ||
| CONVERT_TOKEN_GENERATOR_XC, | ||
| CONVERT_TOKEN_GENERATOR_GRADIENT, | ||
| CONVERT_TOKEN_FILTER_CROP, | ||
| CONVERT_TOKEN_FILTER_FX | ||
| } convert_token_type_t; | ||
|
|
||
| typedef struct { | ||
| convert_token_type_t type; | ||
| char *value; | ||
| char *arg; | ||
| haio_type_t format; | ||
| } convert_token_t; | ||
|
|
||
| typedef struct { | ||
| char *message; | ||
| char *token; | ||
| } convert_error_t; | ||
|
|
||
| typedef struct { | ||
| convert_error_t error; | ||
| uint8_t token_count; | ||
| bool has_input; | ||
| bool has_generator; | ||
| bool output_is_stdout; | ||
| char *input_path; | ||
| char *output_path; | ||
| char *input_format_name; | ||
| char *output_format_name; | ||
| haio_type_t input_format; | ||
| haio_type_t output_format; | ||
| convert_token_t tokens[CONVERT_MAX_TOKENS]; | ||
| } convert_command_t; | ||
|
|
||
| haio_type_t convert_format_from_path(char *path); | ||
| haio_type_t convert_input_format_from_file(FILE *f_in, char *path); | ||
| void convert_print_unsupported_format(const char *kind, char *format_name, char *fallback); | ||
| int convert_tokenize_args(convert_command_t *cmd, int argc, char* argv[]); | ||
| int convert_build_pipeline(convert_command_t *cmd, haio_pipeline_t *pipe); | ||
| void convert_print_error(convert_error_t error); | ||
|
|
||
| bool convert_slice_iequals(char *txt, size_t len, const char *expected); | ||
| char *convert_find_format_separator(char *txt); | ||
| haio_type_t convert_format_from_name(char *name, size_t len); | ||
| bool convert_known_format_prefix(char *name, size_t len); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.