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

#67 in Video

Download history 2673/week @ 2023-12-11 2962/week @ 2023-12-18 243/week @ 2023-12-25 549/week @ 2024-01-01 826/week @ 2024-01-08 917/week @ 2024-01-15 1673/week @ 2024-01-22 1300/week @ 2024-01-29 1063/week @ 2024-02-05 863/week @ 2024-02-12 1441/week @ 2024-02-19 1382/week @ 2024-02-26 1309/week @ 2024-03-04 635/week @ 2024-03-11 514/week @ 2024-03-18 653/week @ 2024-03-25

3,164 downloads per month
Used in 6 crates (4 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

~740KB