
    Vji
                         U d dl mZmZ d dlmZ eee         ee         f         ZdededefdZ	dededefdZ
dededefd	Zeeegef         Ze	e
ed
Zeeef         ed<   d ZdedededefdZdZdS )    )CallableUnion)
FrameBatchvaluesdesired_lenreturnc                 D    | | d         g|t          |           z
  z  z  } | S )Nlenr   r   s     U/root/voice-cloning/.venv/lib/python3.11/site-packages/torchcodec/samplers/_common.py_repeat_last_policyr      s)    
 vbzlkCKK788FM    c                 B    | |t          |           z  dz   z  d |         S )N   r   r   s     r   _wrap_policyr      s(    
 kS[[0145||DDr   frames_indicesc                      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   s     r   _error_policyr      s     	@  r   )repeat_lastwraperror_POLICY_FUNCTIONSc                 .   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policys      r   _validate_common_paramsr"   ,   s    
7||aQ3w<<QQQ
 
 	
 aT$7TTT
 
 	
 &++----ZvZZ?P?U?U?W?WZZZ
 
 	
 .-r   frames	num_clipsr    c                     | j         j        dd          }t           | j         j        ||g|R  | j                            ||          | j                            ||                    S )N)datapts_secondsduration_seconds)r'   shaper   viewr(   r)   )r#   r$   r    last_3_dimss       r   _reshape_4d_framebatch_into_5dr-   <   sy     +#BCC(KV[i)<K{KKK&++I7JKK055iATUU   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)typingr   r   
torchcodecr   listintfloat_LIST_OF_INT_OR_FLOATr   r   r   _POLICY_FUNCTION_TYPEr   dictstr__annotations__r"   r-   _FRAMEBATCH_RETURN_DOCS r   r   <module>r:      sy   " " " " " " " " " ! ! ! ! ! !d3ie45 !03   E!E03EE E E E)8;    !"7!=?T!TU  '7 7 4223   
 
 
   	
    
   r   