o
    2j                     @   s   d dl Z d dlm  mZ d dlmZ e ee Z	e j
de je jej  defddZe je jG dd dZe j
de jej defd	d
Ze je jG dd dZdS )    N)int64_tptrreturnc                 C      t t}||  |S N)
IndexEntry_cinit_bypass_sentinel_initr   obj r   C/var/www/html/whisper/venv/lib/python3.10/site-packages/av/index.pywrap_index_entry      
r   c                   @   s   e Zd ZdZdd Zejdejeje	j
  fddZdd Zed	d
 Zedd Zedd Zedd Zedd Zedd Zedd ZdS )r   zA single entry from a stream's index.

    This is a thin wrapper around FFmpeg's ``AVIndexEntry``.

    The exact meaning of the fields depends on the container/demuxer.
    c                 C   s   |t urtdd S )Nz&cannot manually instantiate IndexEntryr   RuntimeErrorselfsentinelr   r   r   	__cinit__   s   zIndexEntry.__cinit__r   c                 C   
   || _ d S r   )r   r   r   r   r   r   r	         
zIndexEntry._initc                 C   s.   d| j  d| j d| j d| j d| j dS )Nz<av.IndexEntry pos=z timestamp=z flags=z size=z min_distance=>)pos	timestampflagssizemin_distancer   r   r   r   __repr__!   s   zIndexEntry.__repr__c                 C      | j jS r   )r   r   r   r   r   r   r   '      zIndexEntry.posc                 C   r!   r   )r   r   r   r   r   r   r   +   r"   zIndexEntry.timestampc                 C   r!   r   )r   r   r   r   r   r   r   /   r"   zIndexEntry.flagsc                 C      t | jjtj@ S r   )boolr   r   libAVINDEX_KEYFRAMEr   r   r   r   is_keyframe3      zIndexEntry.is_keyframec                 C   r#   r   )r$   r   r   r%   AVINDEX_DISCARD_FRAMEr   r   r   r   
is_discard7   r(   zIndexEntry.is_discardc                 C   r!   r   )r   r   r   r   r   r   r   ;   r"   zIndexEntry.sizec                 C   r!   r   )r   r   r   r   r   r   r   ?   r"   zIndexEntry.min_distanceN)__name__
__module____qualname____doc__r   cythoncfuncpointerconstr%   AVIndexEntryr	   r    propertyr   r   r   r'   r*   r   r   r   r   r   r   r      s(    





r   c                 C   r   r   )IndexEntriesr   r	   r
   r   r   r   wrap_index_entriesD   r   r6   c                   @   st   e Zd ZdZdd Zejdejej	 fddZ
dd Zd	efd
dZdd Zdd ZddddedefddZdS )r5   aH  A sequence-like view of FFmpeg's per-stream index entries.

    Exposed as :attr:`~av.stream.Stream.index_entries`.

    The index is provided by the demuxer and may be empty or incomplete depending
    on the container format. This is useful for fast multi-seek loops (e.g., decoding
    at a lower-than-native framerate).
    c                 C   s   |t u rd S td)Nz(cannot manually instantiate IndexEntriesr   r   r   r   r   r   W   s   zIndexEntries.__cinit__r   c                 C   r   r   )
stream_ptrr   r   r   r   r	   \   r   zIndexEntries._initc                 C   s   dt |  dS )Nz<av.IndexEntries[z]>)lenr   r   r   r   r    `   s   zIndexEntries.__repr__r   c                 C   s6   t j t| jW  d    S 1 sw   Y  d S r   )r/   nogilr%    avformat_index_get_entries_countr7   r   r   r   r   __len__c   s   
$zIndexEntries.__len__c                 c   s"    t t| D ]}| | V  qd S r   )ranger8   )r   ir   r   r   __iter__g   s   zIndexEntries.__iter__c                    s   t |trLt }|dk r||7 }|dk s||kr#td| d| |}tj t j|}W d    n1 s:w   Y  |tj	krHtdt
|S t |trh|t \}}} fddt|||D S td)Nr   zIndex entries z out of bounds for size zindex entry not foundc                    s   g | ]} | qS r   r   ).0r=   r   r   r   
<listcomp>}   s    z,IndexEntries.__getitem__.<locals>.<listcomp>z#Index must be an integer or a slice)
isinstanceintr8   
IndexErrorr/   r9   r%   avformat_index_get_entryr7   NULLr   sliceindicesr<   	TypeError)r   indexnc_idxentrystartstopstepr   r   r   __getitem__k   s"   


zIndexEntries.__getitem__TF)backward	any_framerQ   rR   c                C   s`   |}d}|r|t jO }|r|t jO }tj t | j||}W d   |S 1 s)w   Y  |S )zSearch the underlying index for ``timestamp``.

        This wraps FFmpeg's ``av_index_search_timestamp``.

        Returns an index into this object, or ``-1`` if no match is found.
        r   N)r%   AVSEEK_FLAG_BACKWARDAVSEEK_FLAG_ANYr/   r9   av_index_search_timestampr7   )r   r   rQ   rR   c_timestampr   idxr   r   r   search_timestamp   s   	


zIndexEntries.search_timestampN)r+   r,   r-   r.   r   r/   r0   r1   r%   AVStreamr	   r    rB   r;   r>   rP   r$   rX   r   r   r   r   r5   K   s    	r5   )r/   cython.cimports.libavcimportslibavr%   cython.cimports.libc.stdintr   declareobjectr   r0   r1   r2   r3   r   r   finalcclassrY   r5   r6   r   r   r   r   <module>   s    "3