o
    i
                     @   s   U d dl mZ d dlmZ ee ee B ZdededefddZdededefdd	Z	d
ededefddZ
eeegef Zee	e
dZeeef ed< dd ZdedededefddZdZdS )    )Callable)
FrameBatchvaluesdesired_lenreturnc                 C   s   | | d g|t |   7 } | S )Nlenr   r    r   Z/home/ubuntu/Irodori-TTS/.venv/lib/python3.10/site-packages/torchcodec/samplers/_common.py_repeat_last_policy   s   r   c                 C   s   | |t |  d  d | S )N   r   r
   r   r   r   _wrap_policy   s   r   frames_indicesc                 C   s   t d)NzYou set the 'error' policy, and the sampler tried to decode a frame that is beyond the number of frames in the video. Try to leave sampling_range_end to its default value?)
ValueError)r   r   r   r   r   _error_policy   s   r   )repeat_lastwraperror_POLICY_FUNCTIONSc                 C   sb   t | dk rtdt |  d|dkrtd| d|t vr/td| dt  d	d S )
Nr   z,Decoder must have at least one frame, found z frames.r   znum_frames_per_clip (z) must be strictly positivezInvalid policy (z). Supported values are .)r	   r   r   keys)decodernum_frames_per_clippolicyr   r   r   _validate_common_params,   s   
r   frames	num_clipsr   c                 C   sD   | j jdd  }t| j j||g|R  | j||| j||dS )N)datapts_secondsduration_seconds)r    shaper   viewr!   r"   )r   r   r   last_3_dimsr   r   r   _reshape_4d_framebatch_into_5d<   s   r&   a  
    Returns:
        FrameBatch:
            The sampled :term:`clips`, as a 5D :class:`~torchcodec.FrameBatch`.
            The shape of the ``data`` field is (``num_clips``,
            ``num_frames_per_clips``, ...) where ... is (H, W, C) or (C, H, W)
            depending on the ``dimension_order`` parameter of
            :class:`~torchcodec.decoders.VideoDecoder`. The shape of the
            ``pts_seconds`` and ``duration_seconds`` fields is (``num_clips``,
            ``num_frames_per_clips``).
N)collections.abcr   
torchcodecr   listintfloat_LIST_OF_INT_OR_FLOATr   r   r   _POLICY_FUNCTION_TYPEr   dictstr__annotations__r   r&   _FRAMEBATCH_RETURN_DOCSr   r   r   r   <module>   sP    
	



