{"id":17330443,"url":"https://github.com/yume-chan/cond_bit_field","last_synced_at":"2025-03-27T05:44:48.309Z","repository":{"id":69922099,"uuid":"337036884","full_name":"yume-chan/cond_bit_field","owner":"yume-chan","description":"Experimental H.264 parser in Rust","archived":false,"fork":false,"pushed_at":"2022-03-11T10:29:31.000Z","size":105,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T11:13:02.097Z","etag":null,"topics":["proc-macro","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yume-chan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-08T10:22:36.000Z","updated_at":"2022-11-21T05:37:38.000Z","dependencies_parsed_at":"2023-03-27T16:03:01.653Z","dependency_job_id":null,"html_url":"https://github.com/yume-chan/cond_bit_field","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fcond_bit_field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fcond_bit_field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fcond_bit_field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fcond_bit_field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yume-chan","download_url":"https://codeload.github.com/yume-chan/cond_bit_field/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791932,"owners_count":20672669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["proc-macro","rust"],"created_at":"2024-10-15T14:51:17.667Z","updated_at":"2025-03-27T05:44:48.286Z","avatar_url":"https://github.com/yume-chan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# H.264 NAL Unit Parser in Rust\n\n## Packages\n\n* array_fill: A proc macro to initialize large array.\n* bit_stream: A simple bit stream suitable for H.264 NAL Unit parsing\n* cond_bit_field: A proc macro to generate complex bit field (with conditions, loops, etc.) from extended struct syntax.\n* derive_new_number: A proc macro to impl some basic traits for number new types.\n* h264_nalu: H.264 NAL Unit parser utilizing cond_bit_field\n\n## Status\n\nMy original plan was adding extra variants into `syn::Stmt` enum to support new syntax.\n\nThe problem is, by making my own `cond_bit_field::Stmt`, I also need to alter many (if not all) AST types to use my `Stmt` instead.\n\nConcisely, I want my `Stmt` is only used to parse the \"struct function\", which means syntaxes like `ExprIf`, `ExprLoop` etc should use my `Stmt`, while `ItemFn`, `ItemStruct` should not.\n\nObviously it's not a common use case of `syn`, and because of many functions in `syn` are not exported, a huge amount of code must be copy-pasted.\n\nA possible solution is folking `syn` and make changes, while also depending on original `syn` for parsing routines that should not use my types.\n\nAnyway, currently the development is halted. The idea sounds simple but it's really difficult to implement and maintain.\n\n## Status V2\n\nThe new idea is:\n\n1. The syntax must be valid Rust code\n2. Use some special syntax to identify the \"struct function\"\n\nSo, as it's a function, it maybe look like:\n\n```rust\n#[struct]\nfn StructName(arg1: Type1, arg2: Type2) { // no return type\n    // `3` is not a valid type,\n    // so use `u3` instead.\n    // can only be unsigned, but allow any number of bits\n    // still round up to nearest power of 2 as real type\n    #[field]\n    let field_a: u3;\n\n    // normal varaible are still possible\n    let temp = arg1;\n\n    if arg2 {\n        // fields can be nested\n        // will transform to `Option\u003cu16\u003e` in final struct.\n        #[field]\n        let field_b: u15;\n    }\n\n    for i in 0..16 {\n        // fields in iteration\n        // will transform to `Vec\u003cu8\u003e`\n        #[field]\n        let field_e: u5;\n    }\n\n    // `bool` is 1 bit\n    // still `bool` in final struct\n    #[field]\n    let field_c: bool;\n\n    // field values can also be used as normal variables\n    if field_c {\n        #[field]\n        let field_d: bool;\n    }\n\n    // fields in `if` can be used outside\n    // but the type is `Option\u003cT\u003e` now\n    if let Some(_) = field_d {\n        for i in 0..16 {\n            // `if` and `for` can be nested freely\n            // each time it will be nested in `Option\u003cT\u003e` or `Vec\u003cT\u003e` more deeply\n            #[field]\n            let field_e: u5;\n        }\n    }\n\n    if arg1 {\n        if arg2 {\n            // won't be `Option\u003cOption\u003cT\u003e\u003e`, collapses to one level of `Option\u003cT\u003e`\n            #[field]\n            let field_f: u5;\n        }\n    }\n}\n```\n\n## Progress\n\n- [x] Basic parser structure\n- [x] NAL Unit Header\n  - [ ] extensions\n- [ ] (type 1-5) Coded slice\n  - [x] Header\n    - [ ] ref_pic_list_modification (requires while loop)\n    - [ ] pred_weight_table\n    - [ ] dec_ref_pic_marking\n  - [ ] Data (requires mutable state)\n  - [ ] Others\n- [x] (type 7) Sequence parameter set\n- [x] (type 8) Picture parameter set\n- [x] (type 9) Access unit delimiter\n- [ ] (type 10-16)\n- [ ] (type 19-21)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyume-chan%2Fcond_bit_field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyume-chan%2Fcond_bit_field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyume-chan%2Fcond_bit_field/lists"}