rusty_h265, HEVC C स्टैक का शुद्ध Rust विकल्प है
libde265 या FFmpeg के HEVC decoder को rusty_h265 से बदलें: सभी 147 HEVC_v1 conformance streams byte-exact, forbid(unsafe_code) core, और RExt का स्पष्ट अस्वीकार।

क्या rusty_h265 HEVC decoding के लिए libde265 या FFmpeg की जगह ले सकता है?
Main, Main 10 और Main Still Picture streams के लिए, हाँ। rusty_h265 सभी 147 JCT-VC HEVC_v1 conformance streams को reference के बराबर byte-for-byte decode करता है, forbid(unsafe_code) core के साथ और बिना C। यह केवल decoder है, आज single-threaded है, और SPS पर Range Extensions को अस्वीकार करता है।
Related reading
rusty_h265: An HEVC Decoder Written From the Spec in Safe Rustrusty_h265 decodes HEVC Main, Main 10 and Main Still Picture in Rust, byte-exact on all 147 JCT-VC conformance streams, with a forbid(unsafe) core and no C or FFI.
rusty_h265 एक HEVC (H.265) decoder है जो ITU-T specification से Rust में लिखा गया है, इसमें #![forbid(unsafe_code)] core, शून्य आवश्यक dependencies और Apache-2.0 licence है। यह remade_ffmpeg_rs के अंदर का HEVC decoder है और Remade-With-Rust/rusty_h265 पर मौजूद है। यह पृष्ठ उन products के लिए है जो आज H.265 को libde265, FFmpeg के hevc decoder या C में लिपटी किसी platform library के ज़रिए decode करते हैं, और जानना चाहते हैं कि दूसरी जगह जाने में क्या शामिल है।
सामान्य परिचय rusty_h265 field note है। नवीनतम speed numbers के पीछे का kernel काम the 0.7.0 decoder campaign में लिखा गया है, और pins repo landing पर हैं।
जिन C decoders को आप बदल रहे हैं
libde265 और FFmpeg
libde265 एक आम standalone open-source HEVC decoder है, जिसका उपयोग HEIF images और हल्के players में होता है। इसका API de265_push_data या de265_push_NAL से data भेजता है, loop में de265_decode चलाता है और de265_get_next_picture से frames निकालता है। FFmpeg का native hevc decoder तेज़ है, हाथ से लिखी assembly के साथ, और आम तौर पर libavcodec के ज़रिए पहुँचा जाता है। दोनों बड़े C code bases हैं जो untrusted files से आने वाले जटिल bitstream को parse करते हैं।
एक ठोस विफलता
CVE-2020-21598 libde265 v1.0.4 में ff_hevc_put_unweighted_pred_8_sse में heap buffer overflow है, जो एक crafted file से trigger होता है। HEVC फोन की तस्वीरों (HEIC), camera recordings और downloaded video में आता है, इसलिए decoder तक वह content पहुँचता है जिसे उपयोगकर्ता ने कभी जाँचा ही नहीं। libde265 पर बना Rust wrapper उस overflow को binary में बनाए रखता है।
rusty_h265 क्या decode करता है
Main, Main 10 और Main Still Picture: 8-bit और 10-bit 4:2:0। Coding tools में पूरा CTU quadtree, strong smoothing वाले सभी 35 intra modes, merge और AMVP inter prediction, weighted prediction, transform-skip के साथ DCT और DST inverse transforms, deblocking, SAO, PCM, tiles, wavefronts, long-term references और RPS तथा DPB machinery शामिल हैं। CABAC अपनी range और state tables के साथ एक branchless step में fused चलता है।
अपने decode loop को स्थानांतरित करना
API को मैप करना
Cargo के साथ rusty_h265 जोड़ें। Decoder::new() बनाएं, अपने Annex-B bitstream को NAL units में बाँटें, और हर एक के लिए decode_nal(nal) कॉल करें। जब picture तैयार होती है तो यह Some(pic) लौटाता है, जिसमें pic.planes[0] luma और planes 1 और 2 chroma होते हैं, हर एक stride के साथ &[u16], साथ में width, height और bit_depth। यह libde265 के push, decode और get-picture तीनों को और libavcodec के send और receive packet loop को बदल देता है। 8-bit streams के लिए भी samples 16-bit में आते हैं, इसलिए अगर आपका renderer bytes चाहता है तो किनारे पर convert करें।
जिन streams को यह अस्वीकार करता है उन्हें संभालना
Range Extensions (12-bit, 4:2:2, 4:4:4), SHVC, 3D-HEVC और screen-content coding को SPS पर error के साथ अस्वीकार किया जाता है, गलत decode नहीं किया जाता। अगर आपके inputs में professional 4:2:2 footage या SCC का उपयोग करने वाली screen recordings शामिल हैं, तो fallback path रखें और उस error पर route करें।
ship करने से पहले सत्यापन
- बंडल किए गए CLI को अपने sources के streams पर चलाएँ,
cargo run --release --bin rusty_h265 -- input.hevc output.yuv, और YUV की तुलना अपने वर्तमान decoder से करें। - crate के अपने suite को
HEVC_REQUIRE_VECTORS=1 cargo test --releaseके साथ चलाएँ, जो conformance vectors न होने पर खोखले तरीके से pass होने के बजाय fail होता है। - जाँचें कि picture-hash SEI वाले streams सत्यापित होते हैं; crate हर देखे गए SEI की जाँच करता है।
- audit build के लिए
--no-default-featuresके साथ compile करें: scalar kernels चलते हैं और tree में कहीं भीunsafeनहीं बचता।
गति, सुरक्षा और roadmap
ffmpeg 8.1.2 के मुकाबले मापा गया
Single thread, pinned, 21 interleaved pairs: weighted prediction 432 ms में decode हुआ, 600 ms के मुकाबले, 1.37x तेज़। Deblocking-heavy content और 10-bit 720p बराबर थे। 720p पर mainstream 8-bit inter 0.80x पर आया, और लंबे x265 तथा all-intra clips 0.82x पर। मौजूदा release 0.6 से 1.23x से 1.50x तेज़ है, output समान रहते हुए। README बताता है कि -C target-cpu=x86-64-v3 के साथ build करने से और मदद मिलती है, लेकिन वह binary पुराने CPUs पर वितरित नहीं किया जा सकता।
unsafe को कैसे सीमित रखा गया है
हर raw pointer और target_feature function एक अलग crate, rusty_h265-accel, में runtime-dispatched seam के पीछे रहता है। हर SIMD kernel का एक scalar twin रखा जाता है, जिसे tolerance के बजाय bit identity के लिए जाँचा जाता है। core crate सीधे तौर पर unsafe को मना करता है।
परीक्षण का तरीका आपकी अपनी acceptance checks में कॉपी करने लायक है। Conformance को reference decoder के मुकाबले MD5 से आँका जाता है, PSNR या visual check से नहीं। जब speed काम ने buffer clears हटाए, तो हर per-block map को poison values से भरा गया, जो इस तरह चुने गए थे कि अगर कोई उन्हें लिखने से पहले पढ़े तो output बदल जाए, और सभी 147 streams फिर भी मेल खाए। एक control map जो केवल आंशिक रूप से लिखा गया था, उसी तरह poisoned किया गया और उसने 147 में से 128 को तोड़ दिया, जो दिखाता है कि probe वास्तव में fail हो सकता है। Recycled picture buffers अब पूरी तरह zero नहीं किए जाते; केवल वे blocks साफ़ किए जाते हैं जिन्हें किसी slice ने कवर नहीं किया, इसलिए जिस stream की slice बीच block में खत्म हो जाती है वह भी हर बार वही bytes decode करती है।
अभी क्या कम है
- Multi-threaded decode। Tiles और wavefronts parse होते हैं, लेकिन pipeline एक thread पर चलता है।
- Range Extensions, roadmap पर पहले सूचीबद्ध।
- Encoding। अगर x265 आपके C स्टैक का हिस्सा है, तो यह तब तक रहेगा जब तक अलग encoder न हो।
H.264 के लिए rusty_h264 देखें। आसपास का engine FFmpeg replacement page पर है, और band overview Media on Vision है। जो cameras footage आपके अपने network पर रखते हैं, वे इस decoder को mata.network और Disco Party के साथ जोड़ सकते हैं।
FAQ
क्या rusty_h265, libde265 या FFmpeg का port है?
नहीं। यह ITU-T H.265 specification से लिखा गया है। Conformance को सभी 147 HEVC_v1 streams पर reference decoder के मुकाबले MD5 से जाँचा जाता है, और 6,183 में से 6,183 decoded-picture-hash SEI messages सत्यापित होते हैं।
rusty_h265 किन HEVC streams को अस्वीकार करेगा?
Range Extensions (12-bit, 4:2:2 और 4:4:4), SHVC, 3D-HEVC और screen-content coding। ये SPS पर स्पष्ट रूप से अस्वीकार किए जाते हैं, गलत decode नहीं, इसलिए आप इन्हें किसी दूसरे decoder को भेज सकते हैं।
क्या rusty_h265 HEVC encode करता है?
नहीं। यह एक decoder है। अगर आपके C स्टैक में encoding के लिए x265 शामिल है, तो उस हिस्से के लिए अलग plan चाहिए।
ffmpeg के मुकाबले यह कितना तेज़ है?
ffmpeg 8.1.2 के assembly decoder के मुकाबले single-threaded: weighted prediction पर 1.37x तेज़, deblocking-heavy और 10-bit content पर बराबर, और mainstream 8-bit inter पर 0.80x। Multi-threaded decode roadmap पर है।
क्या मैं इसे बिना किसी unsafe code के बना सकता हूँ?
हाँ। सभी raw pointers और target_feature code rusty_h265-accel में रहते हैं। --no-default-features के साथ build करने पर पूरे dependency tree में शून्य unsafe वाला decoder मिलता है, जो scalar kernels का उपयोग करता है।