
    dj                         d dl Z d dlmZ d dlmZ d dlmZ  e j        e	 e	                      Z
e j         G d de                      Ze j         G d d                      ZdS )	    N)libav)SideData)	uintptr_tc                   V    e Zd Zdedej        fdZd Zd Zdej	        fdZ
d Zd Zd	S )
MotionVectorsframeindexc                     t          j        | |||           i | _        | j        j        t          j        t          j                  z  | _	        d S N)
r   __init___vectorsptrsizecythonsizeoflibAVMotionVector_len)selfsentinelr   r	   s       T/home/agentuser/manim-venv/lib/python3.11/site-packages/av/sidedata/motionvectors.pyr   zMotionVectors.__init__   sA    $%777HMV]33E%F%FF			    c           	          d| j         j         dt          |            dt          j        t
          | j         j                  ddS )Nz<av.sidedata.MotionVectors z
 bytes of z vectors at 0x0x>)r   r   lenr   castr   datar   s    r   __repr__zMotionVectors.__repr__   s\    W$(- W Wd))W W+1;y$(-+P+PVW W W	
r   c                     | j         S r   )r   r   s    r   __len__zMotionVectors.__len__   s
    yr   c                     	 | j         |         S # t          $ r Y nw xY w|| j        k    rt          |          t	          t
          | |          x}| j         |<   |S r   )r   KeyErrorr   
IndexErrorMotionVector_cinit_bypass_sentinel)r   r	   vectors      r   __getitem__zMotionVectors.__getitem__   s|    	='' 	 	 	D	 DIU###(4"D%)
 )
 	
u% s    
c              #   L   K   t          | j                  D ]}| |         V  dS )z Iterate over all motion vectors.N)ranger   )r   is     r   __iter__zMotionVectors.__iter__'   s8      ty!! 	 	Aq'MMMM	 	r   c                 f    ddl }|                    | |                    g dd                    S )z
        Convert motion vectors to a NumPy structured array.

        Returns a NumPy array with fields corresponding to the AVMotionVector structure.
        r   N))sourceint32)wuint8)hr2   )src_xint16)src_yr5   )dst_xr5   )dst_yr5   )flagsuint64)motion_xr0   )motion_yr0   )motion_scaleuint16T)align)dtype)numpy
frombufferr@   )r   nps     r   
to_ndarrayzMotionVectors.to_ndarray,   sX     	}}((        
 
 	
r   N)__name__
__module____qualname__Framer   intr   r    r"   
Py_ssize_tr)   r-   rD    r   r   r   r   	   s        G Gfj G G G G

 
 
  !2      

 
 
 
 
r   r   c                      e Zd ZdZdedej        fdZd Ze	d             Z
e	d             Ze	d             Ze	d	             Ze	d
             Ze	d             Ze	d             Ze	d             Ze	d             Ze	d             ZdS )r&   z
    Represents a single motion vector from video frame data.

    Motion vectors describe the motion of a block of pixels between frames.
    parentr	   c                     |t           urt          d          || _        t          j        t          j        t          j                 |j        j	                  }||z   | _        d S )Nz(cannot manually instantiate MotionVector)
r'   RuntimeErrorrM   r   r   pointerr   r   r   r   )r   r   rM   r	   bases        r   r   zMotionVector.__init__Q   sY    111IJJJ39;N3-.
4
 4
 %<r   c                 h    d| j          d| j         d| j         d| j         d| j         d| j         dS )Nz<av.sidedata.MotionVector xz from (,z) to (z)>)r1   r3   r4   r6   r7   r8   r   s    r   r    zMotionVector.__repr__Z   sw    P P P$& P PZP P"&*P P48JP PAEP P P	
r   c                     | j         j        S r   )r   r/   r   s    r   r/   zMotionVector.source`   s    xr   c                     | j         j        S r   )r   r1   r   s    r   r1   zMotionVector.wd       xzr   c                     | j         j        S r   )r   r3   r   s    r   r3   zMotionVector.hh   rW   r   c                     | j         j        S r   )r   r4   r   s    r   r4   zMotionVector.src_xl       x~r   c                     | j         j        S r   )r   r6   r   s    r   r6   zMotionVector.src_yp   rZ   r   c                     | j         j        S r   )r   r7   r   s    r   r7   zMotionVector.dst_xt   rZ   r   c                     | j         j        S r   )r   r8   r   s    r   r8   zMotionVector.dst_yx   rZ   r   c                     | j         j        S r   )r   r;   r   s    r   r;   zMotionVector.motion_x|       x  r   c                     | j         j        S r   )r   r<   r   s    r   r<   zMotionVector.motion_y   r_   r   c                     | j         j        S r   )r   r=   r   s    r   r=   zMotionVector.motion_scale   s    x$$r   N)rE   rF   rG   __doc__r   r   rI   r   r    propertyr/   r1   r3   r4   r6   r7   r8   r;   r<   r=   rK   r   r   r&   r&   I   s_           vz        
 
 
   X   X   X   X   X   X   X ! ! X! ! ! X! % % X% % %r   r&   )r   cython.cimportsr   r   $cython.cimports.av.sidedata.sidedatar   cython.cimports.libc.stdintr   declareobjectr'   cclassr   r&   rK   r   r   <module>rj      s     ( ( ( ( ( ( 9 9 9 9 9 9 1 1 1 1 1 1'99  <
 <
 <
 <
 <
H <
 <
 <
~ <% <% <% <% <% <% <% <% <% <%r   