
    3jT                        S SK r S SKJrJr  S SKJrJrJrJr  S SK	J
r
  \ R                  \ R                   " S S5      5       5       r\ R                  SS\ R                  S\S-  4S	 jj5       r\ R                   " S
 S5      5       rg)    N)PyBUF_WRITABLEPyBuffer_FillInfo)PyBUF_SIMPLEPyBuffer_ReleasePyObject_CheckBufferPyObject_GetBuffer)memcpyc                        \ rS rSrS rS rSrg)
ByteSource   c                    Xl          Xl        [        U5      U l        g ! [         a     Of = f[        U5      (       a  [        U[        R                  " U R                  5      [        5      nU(       da  SU l        [        R                  " [        R                  U R                  R                  5      U l        U R                  R                  U l        g [	        S5      e)NTz'expected bytes, bytearray or memoryview)ownerptrlenlength	TypeErrorr   r   cythonaddressviewr   has_viewcastp_ucharbuf)selfr   ress      C/home/wildlama/miniconda3/lib/python3.13/site-packages/av/buffer.py	__cinit__ByteSource.__cinit__   s    
	H e*DK	  		  &&$UFNN499,E|TC $!;;v~~tyy}}E"iimmABBs    
,,c                 z    U R                   (       a*  [        [        R                  " U R                  5      5        g g N)r   r   r   r   r   r   s    r   __dealloc__ByteSource.__dealloc__%   s#    ==V^^DII67     )r   r   r   r   N)__name__
__module____qualname____firstlineno__r   r"   __static_attributes__ r$   r   r   r      s    C,8r$   r   
allow_nonereturnc                 \    U(       a  U c  g [        U [        5      (       a  U $ [        U 5      $ r    )
isinstancer   )objr+   s     r   
bytesourcer0   *   s(    ck	C	$	$
#r$   c                      \ rS rSrSr\R                  S\R                  4S j5       rS\R                  4S jr
S\R                  4S jrS\R                  \   S\R                  4S	 jr\S
 5       r\S 5       rS rSrg)Buffer4   zpA base class for PyAV objects which support the buffer protocol, such
as :class:`.Packet` and :class:`.Plane`.

r,   c                     g)Nr   r*   r!   s    r   _buffer_sizeBuffer._buffer_size;   s    r$   c                 "    [         R                  $ r    )r   NULLr!   s    r   _buffer_ptrBuffer._buffer_ptr?   s    {{r$   c                     g)NTr*   r!   s    r   _buffer_writableBuffer._buffer_writableB   s    r$   r   flagsc                     U[         -  (       a   U R                  5       (       d  [        S5      e[        XU R	                  5       U R                  5       SU5        g )Nbuffer is not writabler   )r   r<   
ValueErrorr   r9   r5   )r   r   r>   s      r   __getbuffer__Buffer.__getbuffer__E   sG    >!$*?*?*A*A566$d&6&6&8$:K:K:MqRWXr$   c                 "    U R                  5       $ r    )r5   r!   s    r   buffer_sizeBuffer.buffer_sizeK   s      ""r$   c                 h    [         R                  " [         R                  U R                  5       5      $ )z!The memory address of the buffer.)r   r   size_tr9   r!   s    r   
buffer_ptrBuffer.buffer_ptrO   s"     {{6==$*:*:*<==r$   c                    U R                  5       (       d  [        S5      e[        U5      nU R                  5       nUR                  U:w  a  [        SUR                   SU S35      e[        U R                  5       UR                  U5        g)zReplace the data in this object with the given buffer.

Accepts anything that supports the `buffer protocol <https://docs.python.org/3/c-api/buffer.html>`_,
e.g. bytes, NumPy arrays, other :class:`Buffer` objects, etc..

r@   zgot z bytes; need z bytesN)r<   rA   r0   r5   r   r	   r9   r   )r   inputsourcesizes       r   updateBuffer.updateT   sz     $$&&566'."//1==D tFMM?-vVLMMt!6::t4r$   r*   N)r%   r&   r'   r(   __doc__r   cfuncrH   r5   p_voidr9   bintr<   pointer	Py_bufferintrB   propertyrE   rI   rO   r)   r*   r$   r   r2   r2   4   s    
 \\fmm  V]] &++ Y&.."; YFJJ Y # # > >5r$   r2   )F)r   cython.cimports.cpythonr   r   cython.cimports.cpython.bufferr   r   r   r   cython.cimports.libc.stringr	   finalcclassr   rR   rT   r0   r2   r*   r$   r   <module>r^      s     E  / 8 8  88  
T8I   /5 /5 /5r$   