6 releases (breaking)

0.7.0 May 30, 2023
0.6.0 Aug 8, 2022
0.5.0 Jun 9, 2021
0.4.0 Mar 31, 2020
0.2.0 Jun 1, 2019

#75 in Video

Download history 292/week @ 2024-07-29 566/week @ 2024-08-05 392/week @ 2024-08-12 359/week @ 2024-08-19 304/week @ 2024-08-26 236/week @ 2024-09-02 269/week @ 2024-09-09 243/week @ 2024-09-16 338/week @ 2024-09-23 353/week @ 2024-09-30 367/week @ 2024-10-07 459/week @ 2024-10-14 442/week @ 2024-10-21 539/week @ 2024-10-28 485/week @ 2024-11-04 407/week @ 2024-11-11

1,912 downloads per month
Used in 10 crates (5 directly)

MIT/Apache

220KB
5K SLoC

h264-reader

Reader for H264 bitstream syntax, written in Rust.

crates.io version Documentation

Aims to provide access to stream metadata; does not actually decode the video.

The implementation attempts to minimise copying of source data, for efficiency, at the cost of a more complicated API

Supported syntax

The following list shows the current state of support per H264 syntax element:

  • Bytestream formats
    • Annex B format (e.g. in MPEG-TS)
    • AVCC format (e.g. in MP4)
  • Network Abstraction Layer Units (NAL Units)
    • slice_layer_without_partitioning_rbsp()
    • slice_data_partition_a_layer_rbsp()
    • slice_data_partition_b_layer_rbsp()
    • slice_data_partition_c_layer_rbsp()
    • slice_layer_without_partitioning_rbsp()
    • sei_rbsp() Supplementary Enhancement Information headers - the following payloads are supported:
      • buffering_period()
      • pic_timing()
      • pan_scan_rect()
      • filler_payload()
      • user_data_registered_itu_t_t35()
      • user_data_unregistered()
      • recovery_point()
      • dec_ref_pic_marking_repetition()
      • spare_pic()
      • scene_info()
      • sub_seq_info()
      • sub_seq_layer_characteristics()
      • sub_seq_characteristics()
      • full_frame_freeze()
      • full_frame_freeze_release()
      • full_frame_snapshot()
      • progressive_refinement_segment_start()
      • progressive_refinement_segment_end()
      • motion_constrained_slice_group_set()
      • film_grain_characteristics()
      • deblocking_filter_display_preference()
      • stereo_video_info()
      • post_filter_hint()
      • tone_mapping_info()
      • Annex G headers
      • Annex H headers
      • Annex I headers
      • Annex J headers
      • frame_packing_arrangement()
      • display_orientation()
      • mastering_display_colour_volume()
      • colour_remapping_info()
      • alternative_transfer_characteristics()
      • alternative_depth_info()
    • seq_parameter_set_rbsp()
    • pic_parameter_set_rbsp()
    • access_unit_delimiter_rbsp()
    • end_of_stream_rbsp()
    • filler_data_rbsp()
    • seq_parameter_set_extension_rbsp()
    • prefix_nal_unit_rbsp()
    • subset_seq_parameter_set_rbsp()
    • depth_parameter_set_rbsp()
    • slice_layer_without_partitioning_rbsp()
    • slice_layer_extension_rbsp()
    • slice_layer_extension_rbsp()

Design goals

Avoid copies

Parsing components accept partial data to avoid coping data into intermediate buffers. This is intended to support common cases like,

  • data embedded in MPEG-TS packets, where h264 data is interspersed with MPEG-TS header data
  • data being read from the network, where the data available at any instant may be incomplete

An alternative to accepting partial data would be to take a number of peices of partial data

Lazy parsing

The implementation should be written to defer parsing data structures until an accessor method is called. This can mean saving parsing costs for callers that don't care about all the data. It can be difficult to apply this principal universally, so in some areas we don't bother and just 'eager parse' (particularly structures defined bit-by-bit rather than byte-by-byte).

Dependencies

~510–690KB