Skip to main content

Module boundary

Module boundary 

Source
Expand description

Boundary conversions between FFmpeg’s bindgen integers and the unified mediadecode vocabulary.

Centralised so the rest of the crate never compares raw AVPixelFormat integers against literals or transmutes back into the bindgen enum (UB hazard when the value isn’t in the enum’s discriminant set).

Functions§

audio_packet_from_ffmpeg
Wraps a borrowed [ffmpeg::Packet] as a mediadecode::packet::AudioPacket. Same shape as video_packet_from_ffmpeg — refcounted payload, forwarded metadata.
empty_audio_frame
Constructs an empty mediadecode::frame::AudioFrame suitable as the destination argument to mediadecode::decoder::AudioStreamDecoder::receive_frame. Same behaviour as empty_video_frame — eight 1-byte plane placeholders, plane_count = 0.
empty_subtitle_frame
Constructs an empty mediadecode::frame::SubtitleFrame suitable as the destination argument to mediadecode::decoder::SubtitleDecoder::receive_frame. The payload is an empty Text placeholder; the decoder overwrites it on success.
empty_video_frame
Constructs an empty mediadecode::frame::VideoFrame suitable as the destination argument to mediadecode::decoder::VideoStreamDecoder::receive_frame. The decoder overwrites the frame on success; this just provides a well-formed slot.
ffmpeg_packet_from_audio_packet
Builds an ffmpeg::Packet from a [mediadecode::AudioPacket]. Same shape as ffmpeg_packet_from_video_packet — bytes are copied; pts/dts/duration/flags/stream_index are forwarded. Same failure modes.
ffmpeg_packet_from_subtitle_packet
Builds an ffmpeg::Packet from a [mediadecode::SubtitlePacket]. Bytes copied; pts/duration/flags/stream_index forwarded. Subtitle packets have no dts in the mediadecode model. Same failure modes as ffmpeg_packet_from_video_packet.
ffmpeg_packet_from_video_packet
Builds an ffmpeg::Packet from a [mediadecode::VideoPacket] parameterized by crate::extras::VideoPacketExtra and crate::FfmpegBuffer.
from_av_pixel_format
Maps a raw AVFrame.format integer (i.e. the value of an AVPixelFormat enum variant) onto mediadecode::PixelFormat.
is_hardware_pix_fmt
Returns true when raw is one of FFmpeg’s hardware-frame markers (AV_PIX_FMT_VIDEOTOOLBOX / _VAAPI / _CUDA / _D3D11 / _DRM_PRIME / _MEDIACODEC / _VULKAN). Used by the HW probe to identify GPU-resident frames before triggering av_hwframe_transfer_data.
subtitle_packet_from_ffmpeg
Wraps a borrowed [ffmpeg::Packet] as a mediadecode::packet::SubtitlePacket. Subtitle packets have no dts in the mediadecode model; everything else mirrors video_packet_from_ffmpeg.
try_empty_audio_frame
Fallible counterpart to empty_audio_frame. Returns None if any of the eight placeholder allocations fails.
try_empty_subtitle_frame
Fallible counterpart to empty_subtitle_frame. Returns None if the placeholder allocation fails.
try_empty_video_frame
Fallible counterpart to empty_video_frame. Returns None if any of the four placeholder allocations fails.
video_packet_from_ffmpeg
Wraps a borrowed [ffmpeg::Packet] as a mediadecode::packet::VideoPacket. The compressed payload is shared with the source AVPacket via refcount bump (no copy). Timestamps, duration, key/corrupt flags, and the source stream index are forwarded to the produced packet.