
    Vji                        U d dl Z d dlZd dlmZ d dlmZ d dlmZmZ d dl	m
Z
 d dlmZ dZdeeeej        ej        ee
f         d	ed
e
fdZ e j        dd          Ze j        e         ed<   eded
ed         fd            Zd
efdZdS )    N)contextmanager)Path)	GeneratorUnion)Tensor)_corez
This should never happen. Please report an issue following the steps in
https://github.com/pytorch/torchcodec/issues/new?assignees=&labels=&projects=&template=bug-report.yml.
source	seek_modereturnc                    t          | t                    rt          j        | |          S t          | t                    r"t          j        t          |           |          S t          | t
          j                  st          | t
          j                  rt          j        | |          S t          | t                    rt          j
        | |          S t          | t                    rt          j        | |          S t          | t
          j                  rt          d          t          | d          r%t          | d          rt          j        | |          S t          dt!          |            d          )NzYsource is for reading text, likely from open(..., 'r'). Try with 'rb' for binary reading?readseekzUnknown source type: z. Supported types are str, Path, bytes, Tensor and file-like objects with read(self, size: int) -> bytes and seek(self, offset: int, whence: int) -> int methods.)
isinstancestrcorecreate_from_filer   io	RawIOBaseBufferedReadercreate_from_file_likebytescreate_from_bytesr   create_from_tensor
TextIOBase	TypeErrorhasattrtype)r	   r
   s     \/root/voice-cloning/.venv/lib/python3.11/site-packages/torchcodec/decoders/_decoder_utils.pycreate_decoderr      sj   
 &# =$VY777	FD	!	! =$S[[)<<<	FBL	)	) =Z@Q-R-R =)&)<<<	FE	"	" =%fi888	FF	#	# =&vy999	FBM	*	* 	=g
 
 	
 
	 	  =WVV%<%< =
 )&)<<<
	?V 	? 	? 	?      _CUDA_BACKENDffmpeg)defaultbackend)NNNc              #     K   |                                  } | dvrt          d|  d          t                              |           }	 dV  t                              |           dS # t                              |           w xY w)a  Context Manager to set the CUDA backend for :class:`~torchcodec.decoders.VideoDecoder`.

    This context manager allows you to specify which CUDA backend implementation
    to use when creating :class:`~torchcodec.decoders.VideoDecoder` instances
    with CUDA devices.

    .. note::
        **We recommend trying the "beta" backend instead of the default "ffmpeg"
        backend!** The beta backend is faster, and will eventually become the
        default in future versions. It may have rough edges that we'll polish
        over time, but it's already quite stable and ready for adoption. Let us
        know what you think!

    Only the creation of the decoder needs to be inside the context manager, the
    decoding methods can be called outside of it. You still need to pass
    ``device="cuda"`` when creating the
    :class:`~torchcodec.decoders.VideoDecoder` instance. If a CUDA device isn't
    specified, this context manager will have no effect. See example below.

    This is thread-safe and async-safe.

    Args:
        backend (str): The CUDA backend to use. Can be "ffmpeg" (default) or
            "beta". We recommend trying "beta" as it's faster!

    Example:
        >>> with set_cuda_backend("beta"):
        ...     decoder = VideoDecoder("video.mp4", device="cuda")
        ...
        ... # Only the decoder creation needs to be part of the context manager.
        ... # Decoder will now the beta CUDA implementation:
        ... decoder.get_frame_at(0)
    )r"   betazInvalid CUDA backend (z,). Supported values are 'ffmpeg' and 'beta'.N)lower
ValueErrorr!   setreset)r$   previous_states     r   set_cuda_backendr,   ?   s      F mmooG(((ZWZZZ
 
 	
 #&&w//N,N+++++N++++s   	A) )Bc                  4    t                                           S )N)r!   get r    r   _get_cuda_backendr0   o   s    r    )contextvarsr   
contextlibr   pathlibr   typingr   r   torchr   
torchcodecr   r   ERROR_REPORTING_INSTRUCTIONSr   r   r   r   r   
ContextVarr!   __annotations__r,   r0   r/   r    r   <module>r:      sc        				 % % % % % %       # # # # # # # #       $ $ $ $ $ $  #tR\2+<eVKL  	   F .D[-CX. . .{%c*   
 ,,c ,,i0@&A ,, ,, ,, ,,^3      r    