edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | #!/usr/bin/env python3 |
| 2 | """Turn an ffmpeg VP9 keyframe GOP into the intra-only witness. |
| 3 | |
| 4 | Re-heads frame 0 (a visible keyframe) as an INTRA-ONLY inter frame |
| 5 | (frame_type=1, show_frame=0, intra_only=1, reset_frame_context=2, |
| 6 | refresh_frame_flags=0xff) and keeps every later frame as-is: the intra-only |
| 7 | frame must reconstruct exactly like the keyframe it replaces, so the whole GOP |
| 8 | decodes to the same shown frames. |
| 9 | |
| 10 | reset_frame_context=2 matters: `vp9_setup_past_independence` resets the |
| 11 | selected stored context to the defaults, and the keyframe's compressed header |
| 12 | was coded against the defaults. With reset 0/1 the frame would read whatever |
| 13 | context the previous frame stored and the bool stream desyncs. |
| 14 | |
| 15 | usage: gen_intraonly.py <keyframe-gop.ivf> <out.ivf> |
| 16 | The keyframe uncompressed header (profile 0, 8-bit, 4:2:0, error_resilient=0) |
| 17 | is 8 bits + 24 sync + 3 color_space + 1 color_range => the render flag sits at |
| 18 | bit 68 and the fields from bit 69 on (loop filter, quant, segmentation, tile |
| 19 | info, header_size) are copied verbatim. The new prefix is 76 bits, so the |
| 20 | field bits shift by 7 and the compressed header + tiles (orig[U:], with |
| 21 | U = ceil(E/8)) follow the re-padded header. E was found by trying every byte |
| 22 | offset until libvpx accepted the frame; the committed fixture's E is 140. |
| 23 | """ |
| 24 | |
| 25 | |
| 26 | , = , |
| 27 | = |
| 28 | , = 32, |
| 29 | |
| 30 | = |
| 31 | |
| 32 | += 12 + |
| 33 | |
| 34 | |
| 35 | return |
| 36 | |
| 37 | = |
| 38 | = |
| 39 | assert == 0 and == 1 and == 0, |
| 40 | = |
| 41 | = 69 |
| 42 | = + + + + * 8 + + + |
| 43 | |
| 44 | += |
| 45 | assert == 76 |
| 46 | |
| 47 | = 140 # committed fixture; any E whose (E+7)>>3 == 18 also decodes |
| 48 | = |
| 49 | = + |
| 50 | |
| 51 | |
| 52 | = |
| 53 | |
| 54 | = 0 |
| 55 | |
| 56 | = | |
| 57 | |
| 58 | = + |
| 59 | |
| 60 | = |
| 61 | = |
| 62 | = b |
| 63 | = |
| 64 | = |
| 65 | = |
| 66 | = |
| 67 | = |
| 68 | += + + |
| 69 | += + + |
| 70 | |
| 71 | += + + |
| 72 | |
| 73 |