Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Mar 28, 2024
1 parent 6b41eab commit 96aa82d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/pixel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub enum PixelFormat {
YUV444P16LE,
/// Planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
YUV444P16BE,
/// HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
/// HW decoding through DXVA2
DXVA2_VLD,
/// Packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
RGB444LE,
Expand Down Expand Up @@ -207,7 +207,7 @@ pub enum PixelFormat {
YUVA444P16BE,
/// Planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
YUVA444P16LE,
/// HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
/// HW acceleration through VDPAU
VDPAU,
/// Packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0
XYZ12LE,
Expand Down Expand Up @@ -243,7 +243,7 @@ pub enum PixelFormat {
QSV,
/// MMAL
MMAL,
/// HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer
/// HW decoding through Direct3D11 via old API
D3D11VA_VLD,
/// CUDA
CUDA,
Expand Down
29 changes: 17 additions & 12 deletions src/resample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::audio::AudioChannel;
/// Surround Sound Matrix Encoding.
///
/// Matrix encoding is an audio technique which transforms N-channel signals to
/// M-channel signals, where N > M, enabling the same audio content to be
/// M-channel signals, where `N > M`, enabling the same audio content to be
/// played on different systems.
#[derive(Clone, Copy, Debug, Default)]
pub enum MatrixEncoding {
Expand Down Expand Up @@ -134,7 +134,8 @@ pub enum ResampleFilterType {
///
/// The input parameter is the beta value for Kaiser window.
///
/// Must be a double float value in the interval [2,16], default value is 9.
/// Must be a double float value in the interval `[2,16]`,
/// default value is `9`.
Kaiser(usize),
}

Expand Down Expand Up @@ -246,41 +247,45 @@ impl MixingCoefficientType {
pub struct ResampleOptions {
/// Audio stream channel layout.
///
/// If `None`, no channel layout has been found.
/// If [`None`], no channel layout has been found.
pub channel_layout: Option<Vec<AudioChannel>>,
/// Audio stream sample format.
///
/// If `None`, no sample format has been found.
/// If [`None`], no sample format has been found.
pub sample_format: Option<SampleFormat>,
/// Audio stream sample rate.
pub sample_rate: usize,
/// Channel mixing coefficient types.
pub mixing_coefficient_type: MixingCoefficientType,
/// Center Mix Level.
///
/// It is a value expressed in dB, and must be in the interval [-32,32].
/// It is a value expressed in `dB`, and must be in
/// the interval `[-32, 32]`.
pub center_mix_level: f64,
/// Surround Mix Level.
///
/// It is a value expressed in dB, and must be in the interval [-32,32].
/// It is a value expressed in `dB`, and must be in
/// the interval `[-32, 32]`.
pub surround_mix_level: f64,
/// Low Frequency Effects (LFE) mix into non LFE level.
/// **Low Frequency Effects (LFE)** mix into non LFE level.
///
/// It is used when there is a LFE input, but no LFE output.
///
/// It is a value expressed in dB, and must be in the interval [-32,32].
/// It is a value expressed in `dB`, and must be in
/// the interval `[-32, 32]`.
pub lfe_mix_level: f64,
/// Mix level normalization.
pub normalize: usize,
/// Force resampling.
pub force_resample: bool,
/// Length of each FIR filter in the resampling filterbank relative to the
/// cutoff frequency.
/// Length of each **FIR** filter in the resampling filter bank relative
/// to the cutoff frequency.
pub filter_size: usize,
/// Binary logarithm of the number of entries in the
/// resampling polyphase filterbank.
/// resampling polyphase filter bank.
pub phase_shift: usize,
/// If `true`, then the resampling FIR filter will be linearly interpolated.
/// If [`true`], then the resampling **FIR** filter will be
/// linearly interpolated.
pub linear_interpolation: bool,
/// Resampling cutoff frequency.
pub cutoff_frequency_ratio: f64,
Expand Down
4 changes: 2 additions & 2 deletions src/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Track {

/// Builds a new [`Track`] from a video source.
///
/// The [`TrackType`] is `Video`.
/// The track type is [`Video`](TrackType::Video).
pub fn from_video(video_source: &mut VideoSource) -> Result<Self> {
let track = unsafe {
ffms2_sys::FFMS_GetTrackFromVideo(video_source.as_mut_ptr())
Expand All @@ -118,7 +118,7 @@ impl Track {

/// Builds a new [`Track`] from an audio source.
///
/// The [`TrackType`] is `Audio`.
/// The track type is [`Audio`](TrackType::Audio).
pub fn from_audio(audio_source: &mut AudioSource) -> Result<Self> {
let track = unsafe {
ffms2_sys::FFMS_GetTrackFromAudio(audio_source.as_mut_ptr())
Expand Down
56 changes: 29 additions & 27 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub enum SeekMode {
Normal,
/// Unsafe normal mode.
///
/// Same as `Normal` mode, but no error will be thrown when the exact
/// destination has to be guessed.
/// Same as [`Normal`](Self::Normal) mode, but no error will be
/// thrown when the exact destination has to be guessed.
Unsafe,
/// Aggressive mode.
///
Expand All @@ -62,7 +62,7 @@ impl SeekMode {
}
}

/// Pixel type packaging for a stereoscopic 3D video source.
/// Pixel type packaging for a stereoscopic **3D** video source.
#[derive(Clone, Copy, Debug, Default)]
pub enum Stereo3DType {
/// Unknown type.
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Stereo3DType {
}
}

/// Flags for a stereoscopic 3D video source.
/// Flags for a stereoscopic **3D** video source.
#[derive(Clone, Copy, Debug, Default)]
pub enum Stereo3DFlags {
/// Unknown flag.
Expand All @@ -181,21 +181,21 @@ impl Stereo3DFlags {
}
}

/// Valid range of luma values for a YUV video source.
/// Valid range of luma values for a `YUV` video source.
#[derive(Clone, Copy, Debug, Default)]
pub enum ColorRange {
/// The range is not specified.
#[default]
Unspecified,
/// TV range, also known as limited range.
///
/// Range of luma values: [16, 235].
/// Bit-depth: 8-bit
/// Range of luma values: `[16, 235]`.
/// Bit-depth: `8-bit`
Mpeg,
/// PC range, also known as full range.
///
/// Range of luma values: [0, 255].
/// Bit-depth: 8-bit.
/// Range of luma values: `[0, 255]`.
/// Bit-depth: `8-bit`.
Jpeg,
}

Expand Down Expand Up @@ -248,7 +248,8 @@ pub enum Flip {
/// be considered reliable for old containers formats such as AVI.
///
/// It would be better to generate individual frame timestamps based on
/// the `[Frame.pts]` value instead of using this field.
/// the [`FrameInfo.pts`](crate::frame::FrameInfo::pts) value
/// instead of using this field.
#[derive(Clone, Copy, Debug, Default)]
pub struct FrameRate {
/// Frame rate numerator.
Expand All @@ -257,12 +258,12 @@ pub struct FrameRate {
pub denominator: usize,
}

/// Repeat First Field (RFF) timebase associated with a MPEG video source.
/// **Repeat First Field (RFF)** timebase associated with a _MPEG_ video source.
#[derive(Clone, Copy, Debug, Default)]
pub struct RFFTimebase {
/// RFF timebase numerator.
/// **RFF** timebase numerator.
pub numerator: usize,
/// RFF timebase denominator.
/// **RFF** timebase denominator.
pub denominator: usize,
}

Expand Down Expand Up @@ -300,7 +301,8 @@ pub struct Crop {
pub struct VideoProperties {
/// Frame rate associated with a video source.
pub frame_rate: FrameRate,
/// Repeat First Field (RFF) timebase associated with a MPEG video source.
/// **Repeat First Field (RFF)** timebase associated with a
/// _MPEG_ video source.
pub rff_timebase: RFFTimebase,
/// Number of frames in a video source.
pub frames_count: usize,
Expand All @@ -324,7 +326,7 @@ pub struct VideoProperties {
pub last_time: f64,
/// Video source rotation in degrees.
pub rotation: usize,
/// Pixel type format for a stereoscopic 3D video source.
/// Pixel type format for a stereoscopic **3D** video source.
pub stereo3d_type: Stereo3DType,
/// Flags for a stereoscopic 3D video source.
pub stereo3d_flags: Stereo3DFlags,
Expand Down Expand Up @@ -353,20 +355,20 @@ pub struct VideoProperties {
/// source content are accessible.
pub has_mastering_display_luminance: bool,
/// Minimum luminance of the display used to master a video
/// source content in cd/m^2.
/// source content in `cd/m^2`.
pub mastering_display_min_luminance: f64,
/// Maximum luminance of the display used to master a video
/// source content in cd/m^2.
/// source content in `cd/m^2`.
pub mastering_display_max_luminance: f64,
/// Whether a video source content has maximum and average light levels.
/// Both of these values are measured over the duration of the content.
///
/// A receiver can use this information to adjust the content light
/// levels so that they match the capability of the current display.
pub has_content_light_level: bool,
/// Maximum light level of a video source content in cd/m^2.
/// Maximum light level of a video source content in `cd/m^2`.
pub content_light_level_max: usize,
/// Average light level of a video source content in cd/m^2.
/// Average light level of a video source content in `cd/m^2`.
pub content_light_level_average: usize,
/// Flip direction to be applied to a frame before a rotation.
pub flip: Flip,
Expand All @@ -375,15 +377,15 @@ pub struct VideoProperties {
/// Video source manager.
///
/// Among its functionalities:
/// - Opening a video source which must be indexed first through `[Index]`
/// - Opening a video source which must be indexed first through [`Index`]
/// - Retrieving video frames data
/// - Setting data format for an output video source
pub struct VideoSource(*mut ffms2_sys::FFMS_VideoSource);

unsafe impl Send for VideoSource {}

impl VideoSource {
/// Creates a new `[VideoSource]` instance.
/// Creates a new [`VideoSource`] instance.
pub fn new(
source_file: &Path,
track_number: usize,
Expand Down Expand Up @@ -486,13 +488,13 @@ impl VideoSource {
/// Overrides the video source color space.
///
/// This method is intended primarily for compatibility with programs which
/// use the wrong YUV color space when converting to or from RGB, but it can
/// also be useful for files which have incorrect color space flags.
/// use the wrong `YUV` color space when converting to or from RGB, but
/// it can also be useful for files which have incorrect color space flags.
///
/// Values passed to this functions are not checked for sanity.
/// For example, RGB files can be treated as if they are actually YUV files
/// using this method, but even if this approach works, it does not produce
/// useful results.
/// For example, `RGB` files can be treated as if they are actually `YUV`
/// files using this method, but even if this approach works,
/// it does not produce useful results.
pub fn set_input_format(
&self,
color_space: PixelFormat,
Expand Down Expand Up @@ -527,7 +529,7 @@ impl VideoSource {

/// Sets the color space and frame dimensions to be used for
/// output video source frames.
/// For example, tt can be used to convert a video source to
/// For example, it can be used to convert a video source to
/// greyscale or monochrome.
pub fn set_output_format(
&self,
Expand Down

0 comments on commit 96aa82d

Please sign in to comment.