
    dj                        d dl Z d dlmZ d dlZd dlmc mZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZ d d	lmZ d d
lmZmZmZ d dlmZm Z  d dl!m"Z"m#Z# ej$         G d d                      Z%ej&        de'de'dej(        e         fd            Z)ej&        ej*         ej+        d          dej,        dej(        e#         dej-        fd                                    Z.ej&        ej*         ej+        d          dej,        dej(        e#         dej-        fd                                    Z/ ej0        e' e'                      Z1h dZ2 ej0        e3e4e5ej6        e4f         f         i ddddddddd dd!dd"d#d$d#d%d#d&d#d'd#d(d#d)d#d*d#d+d,d-d.d/d.i d0dd1dd2d3d4d3d5dd6d#d7d#d8d#d9d#d:d#d;d#d<d#d=d#d>d?d@d?dAddBd#i dCd#dDd#dEd#dFd#dGd#dHd#dId#dJd#dKd#dLd?dMd?dNddOd#dPd#dQd#dRd#dSd#i dTd#dUd#dVd#dWddXd#dYd#dZd?d[d?d\d,d]d.d^d.d_dd`ddad3dbd3dcdddedddfdfdgdgdd#d#d#d#ddhdi          Z7ej&        de8fdj            Z9 G dk dle          Z: ej0        ej;        e j<        dmk              Z=ej&        ej>        dnej;        fdo                        Z?ej&        dpedqej6        drej;        dsej;        fdt            Z@ej&        dpedqej6        fdu            ZAej&        ej>        	 ddpedqej6        dxe4fdy                        ZBej&        dze'd{ej;        fd|            ZCej$         G d} d~eD                      Z8dS )    N)IntEnum)
Dictionary)	err_checkget_display_rotation)check_ndarray)get_pix_fmtget_video_format)DLManagedTensor
VideoPlanekCPUkCuda)PyErr_Clear)PyCapsule_GetPointerPyCapsule_IsValidPyCapsule_SetName)	Py_DECREF	Py_INCREF)int64_tuint8_tc            
           e Zd Zddej        dej        fdZd Zej        dej	        e
j                 fd            Zej        d	e
j        d
ej        dej        dej	        e
j                 fd            ZdS )CudaContextr   T	device_idprimary_ctxc                 R    || _         || _        t          j        | _        i | _        d S N)r   r   cythonNULL_device_ref_frames_cache)selfr   r   s      I/home/agentuser/manim-venv/lib/python3.11/site-packages/av/video/frame.py	__cinit__zCudaContext.__cinit__   s)    "&!;    c                    | j                                         D ]t}t          j        t          j        t
          j                 t          j        t          j        |                    }t          j        t          j	        |                     u| j         
                                 | j        }|t          j        k    r9t          j        t          j	        |                     t          j        | _        d S d S r   )r    valuesr   castpointerlibAVBufferRefsize_tav_buffer_unrefaddressclearr   r   )r!   vrefs      r"   __dealloc__zCudaContext.__dealloc__   s     #**,, 	5 	5A+s/FM1-- C s 3 34444  """&+s 3 3444%{D r$   returnc           	      V   | j         }|t          j        k    r|S t          j        }| j                                         }|}t          d| j        rdndi          }t          t          j	        t          j
        |          t          j        ||j        d                     || _         |S )Nr   10r   )r   r   r   r   encoder   r   r   r)   av_hwdevice_ctx_creater-   AV_HWDEVICE_TYPE_CUDAptr)r!   
device_refdevice_bytesc_deviceoptionss        r"   _get_device_refzCudaContext._get_device_ref.   s    6:6F
$$[
.*1133".(4#3<CC=
 
 	&z**) 	
 	
 	
 &r$   sw_fmtwidthheightc                    t          |          t          |          t          |          f}| j                            |          }|t          j        t          j        t          j                 t          j        t          j        |                    }t          j	        |          }|t          j
        k    rt          d          |S |                                 }t          j        |          }	|	t          j
        k    rt          d          	 t          j        t          j        t          j                 |	j                  }
t!          d          |
_        ||
_        t          |          |
_        t          |          |
_        t+          t          j        |	                     n5# t.          $ r( t          j        t          j        |	                      w xY wt          j	        |	          }|t          j
        k    r5t          j        t          j        |	                     t          d          t          j        t          j        |	          | j        |<   |S )Nzav_buffer_ref() failedzav_hwframe_ctx_alloc() failed   cuda)intr    getr   r'   r(   r)   r*   r+   av_buffer_refr   MemoryErrorr>   av_hwframe_ctx_allocAVHWFramesContextdatar	   format	sw_formatr@   rA   r   av_hwframe_ctx_init	Exceptionr,   r-   )r!   r?   r@   rA   keycached
cached_refout_refr:   
frames_ref
frames_ctxs              r"   get_frames_ctxzCudaContext.get_frames_ctxF   s    6{{CJJF4#'',, s/FM622 J '
33G&+%%!":;;;N))++
696N7
 7

 $$=>>>	@Fs45zA AJ !,G 4 4J#)J "5zzJ #FJc-j99:::: 	 	 	z : :;;;	 #J//fk!!z : :;;;6777"(+fmZ"H"H3s   BF+ +2GN)r   T)__name__
__module____qualname__r   rD   bintr#   r1   cfuncr(   r)   r*   r>   AVPixelFormatrU    r$   r"   r   r      s           6:          + + +  \!@    \. \0!0 z0 
	0
 
	(0 0 0 \0 0 0r$   r   objstreamr2   c                    t          | d          r-||                                 n|                     |          }n| }t          |d          st                       t	          d          t          j        t
          j        t                   t          |d                    }|t
          j
        k    rt          d          t          |d          dk    rt          d          |S )	N
__dlpack__)r^   s   dltensorz>expected a DLPack capsule or an object implementing __dlpack__z"PyCapsule_GetPointer returned NULLs   used_dltensorr   zPyCapsule_SetName failed)hasattrr`   r   r   	TypeErrorr   r'   r(   r   r   r   
ValueErrorr   RuntimeError)r]   r^   capsulemanageds       r"   _consume_dlpackrg   z   s    
 sL!! &,n#.."""#..PV.:W:WWk22 
L
 
 	
 k'Wk22 G &+=>>>"233q885666Nr$   F)checkopaquerJ   c                     t          j        t           j        t                   |           }|t           j        k    r|                    |           d S d S r   )r   r'   r(   r   r   deleter)ri   rJ   rf   s      r"   _dlpack_avbuffer_freerl      sP     06{'0 0G &+      r$   c                     | t           j        k    rNt           j        5  t          t          j        t
          |                      d d d            d S # 1 swxY w Y   d S d S r   )r   r   gilr   r'   object)ri   rJ   s     r"   _numpy_avbuffer_freerp      s     Z 	3 	3fk&&11222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 s   (AAA>T   abgrargbbgr8bgragbrpgraynv12pal8rgb8rgbabgr24gbrapgray8rgb24bgr48bebgr48legbrp9begbrp9legray9begray9lergb48bergb48leyuv420pyuv444pyuyv422bgra64bebgra64legbrp10begbrp10legbrp12begbrp12legbrp14begbrp14legbrp16begbrp16legray10begray10legray12begray12legray14begray14legray16begray16lergba64bergba64lergbf32bergbf32leyuvj420pyuvj444p	gbrap10be	gbrap10le	gbrap12be	gbrap12le	gbrap14be	gbrap14le	gbrap16be	gbrap16le	gbrpf32be	gbrpf32le	grayf32be	grayf32le	rgbaf16be	rgbaf16le	rgbaf32be	rgbaf32le
gbrapf32be
gbrapf32lebayer_bggr8bayer_gbrg8bayer_grbg8bayer_rggb8yuv422p10leyuv444p16beyuv444p16leyuva444p16beyuva444p16lebayer_bggr16bebayer_bggr16lebayer_gbrg16bebayer_gbrg16lebayer_grbg16bebayer_grbg16lebayer_rggb16bebayer_rggb16lerq   )   uint8rr   r   )   r   r   r   r   r   )   uint16r   r   r   r   r   r   r   r{   )   r   r   )   r   r   rs   rt   r   )   r   r   r|   r   r   r   r   r   r   r   r   r   )r   float32r   ru   r   r   r   r   r   r   r   r   r   r   r   r   rv   r   r   r   r   r   r   r   r   r}   r   r   r   r   r~   r   r   ry   rz   r   r   r   )r   float16r   )   r   )   r   )r   r   )r   r   r   r   r   r   r   r   r   r   r   c                  *    t          t                    S )zGet a mostly uninitialized VideoFrame.

    You MUST call VideoFrame._init(...) or VideoFrame._init_user_attributes()
    before exposing to the user.

    )
VideoFrame_cinit_bypass_sentinelr\   r$   r"   alloc_video_framer   c  s     ,---r$   c                   ~    e Zd Zej        Zej        Zej        Z	ej
        Zej        Zej        Zej        Zej        ZdS )PictureTypeN)rV   rW   rX   r)   AV_PICTURE_TYPE_NONENONEAV_PICTURE_TYPE_IIAV_PICTURE_TYPE_PPAV_PICTURE_TYPE_BBAV_PICTURE_TYPE_SSAV_PICTURE_TYPE_SISIAV_PICTURE_TYPE_SPSPAV_PICTURE_TYPE_BIBIr\   r$   r"   r   r   n  sN        #DAAAA		B		B		BBBr$   r   big
big_endianc                 D    t           |k    r|                                 S | S r   )_is_big_endianbyteswap)arrayr   s     r"   byteswap_arrayr   |  s$     ##~~Lr$   planebytes_per_pixelflip_horizontalflip_verticalc                    | }d}|j         |z  }|}d}	t          |j                  }
t          j        t          j                  \  }}}|r|j        dz
  }d}d}nd}|j        }d}t          |||          D ]g}||z  }|rDt          d||          D ]1}t          |          D ]}|||z   |z
  |z
  |z            ||	|z   |z   <    2n||||z            ||	|	|z   <   |	|
z  }	hd S )Nr   r   )r@   abs	line_sizer   declarerD   rA   range)	img_bytesr   r   r   r   i_bufi_posi_strideo_bufo_poso_stride	start_rowend_rowsteprowijs                    r"   copy_bytes_to_planer    sQ    '0EE#kO;HEE!%/22H%~fj99Iw L1$		,Y..  h 		N1h88  //  A+0(1,>B,E%!)a-(( /4EEH<L4L.ME%%(**+ r$   c                 T    |                                  }t          |||dd           d S )NF)tobytesr  )r   r   r   imgbytess       r"   copy_array_to_planer	    s+    mmooH%%GGGGGr$   r   r   dtypec                 *   ddl }|                    |          }t          | j        j        j        | j                           }|j        }||z  }|dk    r| j        | j	        f}||f}	n| j        | j	        |f}|||f}	|
                    ||| |	          S )z
    Return the useful part of the VideoPlane as a strided array.

    We are simply creating a view that discards any padding which was added for
    alignment.
    r   Nr   )r
  bufferstrides)numpyr
  r   framer9   linesizeindexitemsizerA   r@   ndarray)
r   r   r
  np	dtype_objtotal_line_sizer  channelsshaper  s
             r"   useful_arrayr    s     I%+/25;?@@O!H(*H1}}u{+"H-u{H5"OX>::e9UG:LLLr$   r   okc                 :    |st          d| j         d          d S )NzUnexpected numpy array shape ``)rc   r  )r   r  s     r"   check_ndarray_shaper    s3     JH%+HHHIIIJ Jr$   c                   
   e Zd Zd0dZej        dej        dej        dej        fd            Z	ej        d             Z
d	 Zd
 Zed             Zed             Zed             Zed             Zed             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zd Zd Zej        defd            Zd Zd1d Zd! Z e!d"             Z"e!d2d$            Z#d% Z$e!d3d&            Z%e!	 	 	 d4d(e&de'de'fd)            Z(e!	 	 	 	 	 	 	 d5de)de'de'd-e'd+z  d.e*f
d/            Z+d+S )6r   r   r   c                 h    |t           u rd S t          |          }|                     |||           d S r   )r   r	   _init)r!   r@   rA   rK   c_formats        r"   r#   zVideoFrame.__cinit__  s<    ***F&1&&9&9

8UF+++++r$   rK   r@   rA   c                     d}t           j        5  || j        _        || j        _        || j        _        |r|rt          j        | j        d          }d d d            n# 1 swxY w Y   |rt          |           | 	                                 d S )Nr   r   )
r   nogilr9   r@   rA   rK   r)   av_frame_get_bufferr   _init_user_attributes)r!   rK   r@   rA   ress        r"   r   zVideoFrame._init  s    \ 	< 	<"DHN$DHO$DHO  < <-dh;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<  	cNNN""$$$$$s   AAA"%A"c                     t          t          j        t          j        | j        j                  | j        j        | j        j                  | _        d S r   )	r
   r   r'   r)   r[   r9   rK   r@   rA   r!   s    r"   r%  z VideoFrame._init_user_attributes  s;    &K)48?;;HNHO
 
r$   c                 8    t          j        | j                   d S r   )r)   av_frame_unrefr9   r(  s    r"   r1   zVideoFrame.__dealloc__  s    48$$$$$r$   c                     d| j         j         d| j         d| j        j         d| j         d| j         dt          |           ddS )Nz<av.z, pts= xz at 0x>)	__class__rV   ptsrK   namer@   rA   idr(  s    r"   __repr__zVideoFrame.__repr__  su    =4>* = =$( = =T[=M = =z= = K= =/1$xx<= = =	
r$   c                      j         } j        j        rht          j        t          j        t          j                  j        j        j                  }t          |j
         j        j         j        j                  }d}t          |j        j                  D ]$}|j        j        |         j        dz   }||k     r|}%|j        dk    rd}d}||k     r/ j        j        |         r|dz  }||k     r j        j        |         |dk    rt'           d          fS t)           fdt          |          D                       S )z:
        A tuple of :class:`.VideoPlane` objects.
        r   r   rx   r   c                 0    g | ]}t          |          S r\   )r   ).0r  r!   s     r"   
<listcomp>z%VideoFrame.planes.<locals>.<listcomp>   s#    FFFajq))FFFr$   )rK   r9   hw_frames_ctxr   r'   r(   r)   rI   rJ   r
   rL   r@   rA   r   nb_componentscompr   r1  extended_datar   tuple)r!   fmtrT   max_plane_countr  countplane_counts   `      r"   planeszVideoFrame.planes  sO    k8! 	@Fs45tx7M7RA AJ #$dhndho C '(sw,-- 	( 	(AGLO)A-E&&"'8vO"#O++0F{0S+1K O++0F{0S+!tQ''))FFFF53E3EFFFGGGr$   c                     | j         j        S )zWidth of the image, in pixels.)r9   r@   r(  s    r"   r@   zVideoFrame.width"  s     x~r$   c                     | j         j        S )zHeight of the image, in pixels.)r9   rA   r(  s    r"   rA   zVideoFrame.height'  s     xr$   c                      t          |           S )zThe rotation component of the `DISPLAYMATRIX` transformation matrix.

        Returns:
            int: The angle (in degrees) by which the transformation rotates the frame
                counterclockwise. The angle will be in range [-180, 180].
        r   r(  s    r"   rotationzVideoFrame.rotation,  s     $D)))r$   c                 N    t          | j        j        t          j        z            S )z+Is this frame an interlaced or progressive?)boolr9   flagsr)   AV_FRAME_FLAG_INTERLACEDr(  s    r"   interlaced_framezVideoFrame.interlaced_frame6  s     DHNS%AABBBr$   c                     | j         j        S )zReturns an integer that corresponds to the PictureType enum.

        Wraps :ffmpeg:`AVFrame.pict_type`

        :type: int
        r9   	pict_typer(  s    r"   rM  zVideoFrame.pict_type<  s     x!!r$   c                     || j         _        d S r   rL  r!   values     r"   rM  zVideoFrame.pict_typeF      "r$   c                     | j         j        S )zKColorspace of frame.

        Wraps :ffmpeg:`AVFrame.colorspace`.

        r9   
colorspacer(  s    r"   rT  zVideoFrame.colorspaceJ  s     x""r$   c                     || j         _        d S r   rS  rO  s     r"   rT  zVideoFrame.colorspaceS  s    #r$   c                     | j         j        S )zMColor range of frame.

        Wraps :ffmpeg:`AVFrame.color_range`.

        r9   color_ranger(  s    r"   rX  zVideoFrame.color_rangeW  s     x##r$   c                     || j         _        d S r   rW  rO  s     r"   rX  zVideoFrame.color_range`  s    $r$   c                     | j         j        S )zWTransfer characteristic of frame.

        Wraps :ffmpeg:`AVFrame.color_trc`.

        r9   	color_trcr(  s    r"   r\  zVideoFrame.color_trcd  s     x!!r$   c                     || j         _        d S r   r[  rO  s     r"   r\  zVideoFrame.color_trcm  rQ  r$   c                     | j         j        S )zUColor primaries of frame.

        Wraps :ffmpeg:`AVFrame.color_primaries`.

        r9   color_primariesr(  s    r"   r`  zVideoFrame.color_primariesq  s     x''r$   c                     || j         _        d S r   r_  rO  s     r"   r`  zVideoFrame.color_primariesz  s    #(   r$   c                 b    | j         st                      | _          | j         j        | g|R i |S )a%  reformat(width=None, height=None, format=None, src_colorspace=None, dst_colorspace=None, interpolation=None, threads=None)

        Create a new :class:`VideoFrame` with the given width/height/format/colorspace.

        .. seealso:: :meth:`.VideoReformatter.reformat` for arguments.

        )reformatterVideoReformatterreformat)r!   argskwargss      r"   re  zVideoFrame.reformat~  sC      	2/11D(t(???????r$   c                       | j         dddi|S )a
  Get an RGB version of this frame.

        Any ``**kwargs`` are passed to :meth:`.VideoReformatter.reformat`.

        >>> frame = VideoFrame(1920, 1080)
        >>> frame.format.name
        'yuv420p'
        >>> frame.to_rgb().format.name
        'rgb24'

        rK   r~   r\   )re  )r!   rg  s     r"   to_rgbzVideoFrame.to_rgb  s!     t}66G6v666r$   filepathc                 J   |                     d          rd}n<|                     d          s|                     d          rd}nt          d          |rdnd}|rd	nd
}ddlm}  ||dddi          5 }|                    ||          }| j        |_        | j        |_        |                    |                    | 	                    |                               |                    |                    d                     ddd           dS # 1 swxY w Y   dS )zPSave a VideoFrame as a JPG or PNG.

        :param filepath: str | Path
        z.pngFz.jpgz.jpegTz"filepath must end with png or jpg.mjpegpngr   r~   r   )openwupdater4   )r=   )pix_fmt)rK   N)
endswithrc   av.container.corern  
add_streamr@   rA   muxr6   re  )r!   rj  is_jpgencoderrq  rn  outputoutput_streams           r"   savezVideoFrame.save  s    V$$ 	CFFv&& 	C(*;*;G*D*D 	CFFABBB"(3wwe%+8zz******T(C(C999 	3V"--gw-GGM"&*M#';M JJ}++DMMM,I,IJJKKKJJ}++D11222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   7BDDDc           	      `   ddl m}  | j        d	ddi|j        d         }|}d}|j        }d}|j        dz  }|j        |z  }	t          |	          }
||	k     r%||||z            |
|||z   <   ||z  }||z  }||	k     %|                    d|j        |j        ft          |
          dddd          S )
zGet an RGB ``PIL.Image`` of this frame.

        Any ``**kwargs`` are passed to :meth:`.VideoReformatter.reformat`.

        .. note:: PIL or Pillow must be installed.

        r   )ImagerK   r~   r   RGBrawr   r\   )
PILr|  re  rA  r   r@   rA   	bytearray	frombytesbytes)r!   rg  r|  r   r   r   r   r   r   o_sizer   s              r"   to_imagezVideoFrame.to_image  s     	)DMCCCFCCJ1M*/ "'/ "'+/ %x 7$V,,fnn.3EEH<L4L.ME%%(**+XEXE fnn
 EK.eeUAq
 
 	
r$   Fc                 d
   | j         j        rd|vrt          j        t          j        t
          j                 | j         j        j                  }t          |          }t          |j
        | j         j        | j         j                  j        |d<   t          |          dk    r | j        di |n| }|j         j        rt!          d          ddl}|j        j        }|j        }|t(          v r^|dk    r:|j         j        dz  dk    s
J d            |j         j        dz  dk    s
J d            t(          |         \  }}	t          |          }
|
d	k    rt+          |d         ||	          }n|                    |j         j        |j         j        |
f|	
          }|                    d          rddd	gt1          d|
          R }nt1          |
          }t3          |          D ]&\  }}t+          ||         ||	          |dddd|f<   't5          ||                    d                    }|s|dv r|                    |dd          }|S |dv r|j         j        dz  dk    s
J d            |j         j        dz  dk    s
J d            |                    t+          |d                                       d          t+          |d	                                       d          t+          |d                                       d          g                              d|j         j                  S |dk    r|j         j        dz  dk    s
J d            |j         j        dz  dk    s
J d            t+          |d         dd          }t+          |d	         dd          }t+          |d         dd          }|                    |dd	          }|                    |dd	          }|r|                     |||gd          S |                     |||gd          S |dk    rtt+          |d                   }|!                    |d	         d          "                    d                              dd	          #                    |j$                  }||fS |dk    r|                    t+          |d                                       d          t+          |d	         d                              d          g                              d|j         j                  S t!          d| d          )aI  Get a numpy array of this frame.

        Any ``**kwargs`` are passed to :meth:`.VideoReformatter.reformat`.

        The array returned is generally of dimension (height, width, channels).

        :param bool channel_last: If True, the shape of array will be
            (height, width, channels) rather than (channels, height, width) for
            the "yuv444p" and "yuvj444p" formats.

        .. note:: Numpy must be installed.

        .. note:: For formats which return an array of ``uint16``, ``float16`` or ``float32``,
            the samples will be in the system's native byte order.

        .. note:: For ``pal8``, an ``(image, palette)`` tuple will be returned,
            with the palette being in ARGB (PyAV will swap bytes if needed).

        .. note:: For ``gbrp`` formats, channels are flipped to RGB order.

        rK   r   z2Cannot convert a hardware frame to numpy directly.Nr   r   z width has to be even for yuyv422z!height has to be even for yuyv422r   )r
  gbrr   be   r   r   >   r   yuv422pr   z$width has to be even for this formatz%height has to be even for this formatr   r   r   axisrx   i4>i4rw   z'Conversion to numpy array with format `` is not yet supportedr\   )%r9   r8  r   r'   r(   r)   rI   rJ   dictr
   rL   r@   rA   r1  lenre  rc   r  rK   rA  _np_pix_fmt_dtypesr  empty
startswithr   	enumerater   rr  moveaxishstackreshaperepeatstack
frombufferastypeviewr   )r!   channel_lastrg  rT   r  r  format_namerA  r  r
  
num_planesr   plane_indicesr  p_idxyur/   u_fullv_fullimagepalettes                         r"   
to_ndarrayzVideoFrame.to_ndarray  s`   , 8! 	hf&<&<@Fs45tx7M7RA AJ &\\F/$dhndho    8 8;6{{QMDM33F333D9" 	SQRRR l').,,,i''y*a///1S///y'!+q0002U0000=OHe(+FJQ$VAY%@@Y%uy
C5 !   ))%00 6%&1$DuQ
/C/C$D$DMM$)*$5$5M )- 8 8 R RHAu%1&-5%Q%QE!!!QQQ'NN"5+*>*>t*D*DEEE 1K3J$J$JE1a00L <<<9?Q&!+++-S+++9#a'1,,,.U,,,99 ++33B77 ++33B77 ++33B77  gb%)/**+ -''9?Q&!+++-S+++9#a'1,,,.U,,,VAY844AVAY844AVAY844A YYq!!Y,,FYYq!!Y,,F =xxFF 3!x<<<88Q/a8888&   ++EfQi..Qbh	  '>!&  99 ++33B77 A..66r:: 
 gb%)/**+ YkYYY
 
 	
r$   c                 ~    |j         dk    r|                    d          }t          || j        d         d           dS )z6
        Update content from a ``PIL.Image``.
        r}  r   r   N)modeconvertr	  rA  )r!   imgs     r"   	set_imagezVideoFrame.set_imageA  s@     8u++e$$CCQ33333r$   c                 ~    t          | j        d         | j        d         d          }|                    |            |S )z9
        Construct a frame from a ``PIL.Image``.
        r   r   r~   )r   sizer  )r  r  s     r"   
from_imagezVideoFrame.from_imageJ  s8    
 'sx{CHQKIIr$   r~   c                 d   ddl }| j        d         }|s| j        d         }|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}ni|d
v rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}n|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}n|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}n7|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}n|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}nk|dv rbt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         f}n|dv rAt          | dd           | j        d         dk    rt          d	          | j        d         f}n|dv rAt          | dd           | j        d         dk    rt          d	          | j        d         f}n{|dv rAt          | dd           | j        d         dk    rt          d	          | j        d         f}n6|dv rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  f}n|dv rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  f}n(|dv rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  f}n|dv rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  | j        d         dz  f}n|d v rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  | j        d         dz  f}nu|d!v rt          | dd           t          | | j        d         dk               | j        dd         dk    rt          d	          | j        d         dz  | j        d         dz  | j        d         dz  | j        d         dz  f}n|d"v rt          | dd           t          | | j        d         dz  dk               t          | | j        d         dz  dk               |d#z  dz  }| j        d         dk    rt          d	          |d$v r-| j        d         | j        d         dz  | j        d         dz  f}n.| j        d         | j        d         f}nt          d%| d&          |                    d'          r5|                    |                    | d(g d)f         d*d                    } nI|                    d+          r4|                    |                    | d(g d,f         d*d                    } t          t                    }|                    | ||||           |S )-a  
        Construct a frame from a numpy buffer.

        :param int width: optional width of actual image, if different from the array width.

        .. note:: For formats which expect an array of ``uint16``, ``float16`` or ``float32``,
            the samples must be in the system's native byte order.

        .. note:: for ``gbrp`` formats, channels are assumed to be given in RGB order.

        .. note:: For formats where width of the array is not the same as the width of the image,
        for example with yuv420p images the UV rows at the bottom have padding bytes in the middle of the
        row as well as at the end. To cope with these, callers need to be able to pass the actual width.
        r   Nr      r{   r~   r   r   r   )r   r   z.provided array does not have C_CONTIGUOUS rows   r   r   r   r   r   )r   r      r   r   r   )r   r      rq   rr   rt   rz   r   )r   r      r   r   r   r   )r   r      r   r   r      r   r   )r   r   >   rs   rv   ry   r}   r   r   r   r   >   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   >   r   r   >   ru   >
   r   r   r   r   r   r   r   r   r   r   >   r   r   >   r|   >   r   r   r   r   r   r   r   r   >   r   r   >   rw   r   r   r      r   r   )Conversion from numpy array with format `r  r|   .)r   r   r   r   r   ru   )r   r   r   )r  r  r   r  r  rc   r  ascontiguousarrayr  r   r   _image_fill_pointers_numpy)r   rK   r@   r  rA   	linesizesr  s          r"   from_numpy_bufferzVideoFrame.from_numpy_bufferT  s	     	Q 	#KNE'''%!,,,u{1~':;;;}QRR F** !QRRRq)+IICCC%1---u{1~':;;;}QRR F** !QRRRq)+II///%A...u{1~':;;;}QRR G++ !QRRRq)+II777%!,,,u{1~':;;;}QRR F** !QRRRq)+IIGGG%1---u{1~':;;;}QRR F** !QRRRq)+II111%A...u{1~':;;;}QRR F** !QRRRq)+II111%A...u{1~':;;;}QRR G++ !QRRRq)+II 	
 	
 	
 %!,,,}Q1$$ !QRRRq)+II 
 
 
( %1---}Q1$$ !QRRRq)+II111%A...}Q1$$ !QRRRq)+IIx%!,,,u{1~':;;;}QRR F** !QRRRa A%a A%a A%II
  
 
 
 %1---u{1~':;;;}QRR F** !QRRRa A%a A%a A%II
 111%A...u{1~':;;;}QRR G++ !QRRRa A%a A%a A%II
 y  %!,,,u{1~':;;;}QRR F** !QRRRa A%a A%a A%a A%	II  	
 	
 	
 %1---u{1~':;;;}QRR F** !QRRRa A%a A%a A%a A%	II 333%A...u{1~':;;;}QRR G++ !QRRRa A%a A%a A%a A%	II 666%!,,,u{1~'9Q'>???u{1~'9Q'>???q[1_F}Q1$$ !QRRR000 M!$M!$)M!$)		 #]1-u}Q/?@		ZFZZZ   W%% 	T((U3;L5MrST)U)UVVEEv&& 	T((U3			>5JBPQ)R)RSSE122((vy&QQQr$   c           	         |j         j        }t          j        t          j        t
                   |          }t          |          }t          j        | j	                   || j	        _
        || j	        _        || j	        _        t          |          D ]\  }	}
|
| j	        j        |	<   t          t          j        | j	        j        t          j        t          j        | j	        j
                  | j	        j        || j	        j                            }t          j        t$          |          }t'          |           t          j        ||t*          t          j        t          j        |          d          | j	        j        d<   | j	        j        d         t          j        k    rt3          |           t5          d          |                                  d S )Nr   zav_buffer_create failed)ctypesrJ   r   r'   r(   r   r	   r)   r*  r9   rK   r@   rA   r  r  r   av_image_fill_pointersr[   ro   r   av_buffer_createrp   p_voidbufr   r   rG   r%  )r!   r  r@   rA   r  rK   c_datac_ptrr!  r  r  requiredpy_bufs                r"   r  z%VideoFrame._image_fill_pointers_numpy1  s   " %+M$6)/V^G5Lf)U)U&1&&9&948$$$ # $Y// 	, 	,KAx#+DHa  &C-tx??! 
 
 VV,,&. Kv..
 
Q 8<?fk))f7888""$$$$$r$   c           	         ddl }i ddddddddd	dd
dddddddddddddddddddddddi ddddddddddddddd d!d"d#d$d#d%d#d&d#d'd#d(d#d)d#d*d#d+d#i d,d#d-d.d/d.d0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<d=d>d=dd!d#d#ddd!d?                    |d@          \  }}}|T| j        dAk    r| dddddf         } t          | |dB           |s|dCv r|                    | ddA          } t          | | j        dA         |k               t          | |                    dD                    } t          | j        dE         | j        d         |          }|j
        j                            dF          rG|                    | dddddEdBf         | ddddddEf         | dddddBdf         gdAG          } t          |          D ]+}t          | dddd|f         |j        |         |           ,|S |dHk    r| \  } }	t          | dIdA           t          |	dIdA           t          |	|	j        dJk               t          | j        dE         | j        d         |          }t          | |j        d         dE           |j        dE                             |	                    dK                              dL                                                     |S |dMv rt          | dIdA           t          | | j        d         dBz  dk               t          | | j        dE         dAz  dk               t          | j        dE         | j        d         dAz  dBz  |          }|j        |j        z  }
dN|
z  dOz  }|                     dP          }t          |d|
         |j        d         dE           t          ||
|         |j        dE         dE           t          ||d         |j        dA         dE           |S |dQk    rt          | dIdA           t          | | j        d         dOz  dk               t          | | j        dE         dAz  dk               t          | j        dE         | j        d         dAz  |          }|j        |j        z  }
|
|
dAz  z   }|                     dP          }t          |d|
         |j        d         dE           t          ||
|         |j        dE         dE           t          ||d         |j        dA         dE           |S |dRk    rct1          | |j                  r| j        |j        k    rt9          dS          |r)| j        dA         dBk    r|                    | dAd          } n | j        d         dBk    st9          dT          | j        dEd         \  }}|dAz  dk    s	|dAz  dk    rt9          dU          t          |||          }t          | d         |j        d         dA           | dEdddddAf                                         }| dAdddddAf                                         }t          ||j        dE         dA           t          ||j        dA         dA           |S |dVk    rvt          | dIdB           t          | | j        d         dAz  dk               t          | | j        dE         dAz  dk               t          | | j        dA         dAk               nw|dWv r2t          | dIdB           t          | | j        dA         dBk               nA|dXv r2t          | dIdB           t          | | j        dA         dOk               n|dYv rt          | dZdB           t          | | j        dA         dBk               t          | j        dE         | j        d         |          }t          t          | |                    dD                    |j        d         d[           |S |d\v rt          | d]dB           t          | | j        dA         dBk               t          | j        dE         | j        d         |          }t          t          | |                    dD                    |j        d         d^           |S |d_v rt          | dZdB           t          | | j        dA         dOk               t          | j        dE         | j        d         |          }t          t          | |                    dD                    |j        d         d`           |S |dav rt          | dbdB           t          | | j        dA         dOk               t          | j        dE         | j        d         |          }t          t          | |                    dD                    |j        d         d`           |S |dcv rt          | d]dB           t          | | j        dA         dOk               t          | j        dE         | j        d         |          }t          t          | |                    dD                    |j        d         dd           |S |dek    rt          | dIdA           t          | | j        d         dBz  dk               t          | | j        dE         dAz  dk               t          | j        dE         | j        d         dAz  dBz  |          }|j        |j        z  }|                     dP          }t          |d|         |j        d         dE           t          ||d         |j        dE         dA           |S t9          df| dg          t          | j        dE         | j        d         |          }t          | |j        d         | j        dAk    rdEn| j        dA                    |S )ha  
        Construct a frame from a numpy array.

        :param bool channel_last: If False (default), the shape for the yuv444p and yuvj444p
            is given by (channels, height, width) rather than (height, width, channels).

        .. note:: For formats which expect an array of ``uint16``, ``float16`` or ``float32``,
            the samples must be in the system's native byte order.

        .. note:: for ``pal8``, an ``(image, palette)`` pair must be passed. `palette` must
            have shape (256, 4) and is given in ARGB format (PyAV will swap bytes if needed).

        .. note:: for ``gbrp`` formats, channels are assumed to be given in RGB order.

        r   Nr   )r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   rs   r|   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   ru   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   rv   r   r   r   r   r   r   r   r   r}   r   r   r   )r   r   r   r   )ry   r   r   r   r   r   r   )NNNr   r   r  r  r   r  r  rx   r   )   r   r  r  r     r   r   r  r   zArray must be uint16 typez>Array must have shape (3, height, width) or (height, width, 3)zWidth and height must be evenr   r  r  r  r   r   r  r   r   r  r   r  r   r  r   rw   r  r  )r  rE   ndimr   r  r  r  r   rr  r   rK   r1  r  concatenater   r	  rA  rp  r  r  r  r@   rA   r  
isinstancer  r
  r   rc   copy)r   rK   r  r  r  r  r
  r  r  r  u_startv_startflatrA   r@   r  r/   uv_starts                     r"   from_ndarrayzVideoFrame.from_ndarrayh  sQ   " 	;%
.;%
.;%
 ?;%
 .	;%

 .;%
 ?;%
 .;%
 .;%
 ?;%
 .;%
 .;%
 ?;%
 O;%
 _;%
 );%
  )!;%
" )#;%
 ;%
$ )%;%
& )';%
( ));%
* )+;%
, )-;%
. +/;%
0 +1;%
2 O3;%
4 (5;%
6 (7;%
8 (9;%
: (;;%
< (=;%
> (?;%
@ (A;%
B (C;%
D 'E;%
 ;%
 ;%
F 'G;%
H *I;%
J *K;%
L OM;%
N (O;%
P (Q;%
R (S;%
T (U;%
V (W;%
X (Y;%
Z ([;%
\ (];%
^ __;%
` 'a;%
b 'c;%
d *e;%
f *g;%
 ;%
h $&++,,'u;%
 ;%
 ;%
v #f(
)
)w 	"(Ex zQaaaDj)%*** 1F.E$E$EE1a00u{1~'ABBB"5&//$*?*?@@Eu{1~u{1~vFFE| ++E22 aaaAaCi(aaaAaCi(aaaABBh
  '   8__ O O#E!!!QQQ'NELOXNNNNL V"NE7%!,,,'7A...()BCCCu{1~u{1~vFFEu|A:::LO""7<<#6#6#=#=d#C#C#K#K#M#MNNNL...%!,,,u{1~'9Q'>???u{1~'9Q'>???u{1~A0Bq/H&QQEkEL0G'kQ&G==$$DQwYa!DDDWW_ 5u|AJJJWXXQCCCLy  %!,,,u{1~'9Q'>???u{1~'9Q'>???u{1~u{1~/BFKKEkEL0G1,G==$$DQwYa!DDDWW_ 5u|AJJJWXXQCCCL}$$eRZ00 >EK294L4L !<===  A! 3 3E1a00k!n)) T   "KOMFEqyA~~!q !@AAAuff55Ea%,q/1===aCCaCi %%''AaCCaCi %%''A5<?A6665<?A666Ly  %!,,,u{1~'9Q'>???u{1~'9Q'>???u{1~':;;;;)))%!,,,u{1~':;;;;777%!,,,u{1~':;;;;CCC%1---u{1~':;;;u{1~u{1~vFFEufood&;&;<<el1oq   L///%A...u{1~':;;;u{1~u{1~vFFEufood&;&;<<el1or   LGGG%1---u{1~':;;;u{1~u{1~vFFEufood&;&;<<el1oq   L111%A...u{1~':;;;u{1~u{1~vFFEufood&;&;<<el1oq   L111%A...u{1~':;;;u{1~u{1~vFFEufood&;&;<<el1or   Lv%!,,,u{1~'9Q'>???u{1~'9Q'>???u{1~A0Bq/H&QQE{U\1H==$$DYhYa!DDDXYYa!DDDLZFZZZ   5;q>5;q>6BB5<?qAAek!n	
 	
 	
 r$   rz   r   c                    t          |||          }|dk    rt          | |j        d         d||           nM|dv r6t          | |j        d         |                    d          rdnd||           nt	          d| d	          |S )
Nrz   r   r   >   r   r   r   r   r   r   r   r   r   r   r   r   8r   r   zFormat 'z' is not supported.)r   r  rA  rr  NotImplementedError)r   r@   rA   rK   r   r   r  s          r"   
from_byteszVideoFrame.from_bytesU  s     5&&11V5<?A     
 
 
  Q__S))0q    &&L&L&L&LMMMr$   rw   NTr   r   c           	         t          | t          t          f          s| f} t          |           dk    rt	          d          t          |          }t          d          }	t          d          }
t          d          }||	|
|fvrt          d          ||	k    rdnd}|dk    rd	nd}t          j        }t          j        }d }	 t          | d
         |          }t          | d	         |          }|j
        j        }|j
        j        }||k    rt	          d          |t          t          fvrt          d          |j
        j        }|j
        j        }||k    rt	          d          |t          k    r||}n+||k    rt	          d          n|dvrt	          d          d
}|t          k    r|d
k    s|d
k    rt	          d          |j
        j        j        d	k    s*|j
        j        j        |k    s|j
        j        j        d	k    rt'          d          |j
        j        j        d	k    s*|j
        j        j        |k    s|j
        j        j        d	k    rt'          d          |j
        j        dk    rt	          d          t          j        t,          |j
        j        d
                   }t          j        t,          |j
        j        d	                   }|d
k    r;|d
k    r5t          j        t0          |          }t          j        t0          |          }n6|d
k    s|d
k    rt	          d          ||k    s||k    rt	          d          |dz  s|dz  rt	          d          |j
        j        t          j        k    rP|j
        j        d	         d	k    rt	          d          t          j        t,          |j
        j        d
                   }nt          j        t,          |          }t          j        t0          ||z            }t          j        t0          ||z            }|j
        j        }|dz  }|dk    rt          j        t0          |j
        j        d
                   }t          j        t0          |j
        j        d	                   }||k    s||k    rt	          d          |j
        j        t          j        k    rQ|j
        j        d	         d	k    rt	          d          t          j        t,          |j
        j        d
                   }not          j        t,          |          }nS|dk    r=t          j        t0          |j
        j        d
                   }t          j        t0          |j
        j        d	                   }t          j        t0          |j
        j        d                   } ||k    s||dz  k    s| dk    rt	          d          |j
        j        t          j        k    rf|j
        j        d         d	k    s|j
        j        d	         dk    rt	          d          t          j        t,          |j
        j        d
                   }n*t          j        t,          |          }nt	          d          t          j        t0          ||z            }!t          j        t0          |!|dz  z            }"t5                      }||j        _        ||j        _        |t          k    r|t=          ||          }#nt          |t<                    st'          d           t1          |j                  t1          |          k    rt	          d!          t?          |j                   t?          |          k    rt	          d"          t          j        t<          |          }#|#!                    |||          }$t          d#          |j        _"        |$|j        _#        ||_$        |#|_%        n||j        _"        t          j        t          j&        tN                   |j
        j(                  t          j        t          j)        |j
        j*                  z   }%t          j        t          j&        tN                   |j
        j(                  t          j        t          j)        |j
        j*                  z   }&tW          j,        |%|tZ          t          j        t          j.        |          d
          |j        j/        d
<   |j        j/        d
         t          j        k    rta          d$          |%|j        j(        d
<   ||j        j1        d
<   t          j        }tW          j,        |&|"tZ          t          j        t          j.        |          d
          |j        j/        d	<   |j        j/        d	         t          j        k    rta          d%          |&|j        j(        d	<   |!|j        j1        d	<   t          j        }|2                                 |S # tf          $ rg |tW          j4        |j                   |t          j        k    r|5                    |           |t          j        k    r|5                    |            w xY w)&Nr   zHfrom_dlpack currently supports 2-plane formats only (nv12/p010le/p016le)s   nv12s   p010les   p016lez.from_dlpack supports nv12, p010le, p016le onlyr   r   r   r   z,plane tensors must have the same device_typez.only CPU and CUDA DLPack tensors are supportedz-plane tensors must be on the same CUDA devicez4device_id does not match the DLPack tensor device_id)Nr   z#device_id must be 0 for CPU tensorsz+CPU DLPack tensors must have device_id == 0zunexpected dtype for plane 0zunexpected dtype for plane 1zplane 0 must be 2D (H, W)z+either specify both width/height or neitherz)plane 0 shape does not match width/heightz0width/height must be even for nv12/p010le/p016lez0plane 0 must be contiguous in the last dimensionz*plane 1 must have shape (H/2, W) for 2D UVz0plane 1 must be contiguous in the last dimensionr   z/plane 1 must have shape (H/2, W/2, 2) for 3D UVz-unexpected UV plane strides for (H/2, W/2, 2)zplane 1 must be 2D or 3D)r   r   z"cuda_context must be a CudaContextzAcuda_context.device_id does not match the DLPack tensor device_idz3cuda_context.primary_ctx does not match primary_ctxrC   z#av_buffer_create failed for plane 0z#av_buffer_create failed for plane 1)6r  r<  listr  rc   r	   r  r   r   rg   	dl_tensordevice_typer   r   r   r
  codebitslanesrb   r  r'   r   r  rD   r  r   r9   r@   rA   r   rG  r   rU   rK   r8  
_device_id	_cuda_ctxr(   r   rJ   r+   byte_offsetr)   r  rl   r  r  rG   r  r%  rN   r*  rk   )'rA  rK   r@   rA   r^   r   r   cuda_contextr?   rw   p010lep016leexpected_bitsr  m0m1r  	dev_type0	dev_type1dev0dev1y_hy_wy_pitch_elems
y_linesizey_sizeuv_ndimuv_h_expecteduv_huv_wuv_pitch_elemsuv_w2uv_cuv_linesizeuv_sizectxrS   y_ptruv_ptrs'                                          r"   from_dlpackzVideoFrame.from_dlpack|  s	    &5$-00 	YFv;;!Z   %0$7$77##Y''Y''$///%&VWWW#t^^%**11.4k.4k p	 F33B F33B0I0II%% !OPPP--)D   <)D<)Dt|| !PQQQE!!$ $II$&&$N   '
 I--$%JKKK	D  daii4199 !NOOO "'1,,<%*m;;<%+q00 >???"'1,,<%*m;;<%+q00 >???| A%% !<===+gr|'9!'<==C+gr|'9!'<==CzzfkkC--S#..!v{{ !NOOO%<<3&==$%PQQQqy UFQJ U !STTT|#v{22<'*a//$%WXXX &GR\5I!5L M M &GU ; ;S-(*BCCJ[j6&9::Fl'G"aKM!||{3(:1(=>>{3(:1(=>>=((DEMM$%QRRR<'6;66|+A.!33(N   &,[",:Nq:Q%R%RNN%+[$%?%?NNA{3(:1(=>>C);A)>??{3(:1(=>>=((Eeqj,A,ATQYY$%VWWW<'6;66|+A.!33r|7KA7NRS7S7S(K   &,[",:Nq:Q%R%RNN%+[%%@%@NN !;<<< +c>H+DEEKk#{fk'BCCG%''E#EIO%EIE!!  '%	{SSSCC%lK@@ N'(LMMM<122c)nnDD(_   L455k9J9JJJ(Q   !+k<@@C //vFF
#.w#7#7	 *4	'#, "%#)	 Kw'): FM2<+CDDEE [w'): FM2<+CDDEF  #3v4fk&-QS6T6TVW   EIM! y}Q6;..!"GHHH %EIN1$.EIq!B"3%FM2..   EIM! y}Q6;..!"GHHH &EIN1$/EIq!B'')))L 	 	 	 "59---V[  

2V[  

2	s   eh A1j	)r   r   r   )F)r~   r   )r~   F)rz   FF)rw   r   r   NNTN),rV   rW   rX   r#   r   rZ   r)   r[   uintr   r%  r1   r3  propertyrA  r@   rA   rE  rJ  rM  setterrT  rX  r\  r`  re  ri  ccallro   rz  r  r  r  staticmethodr  r  r  r  r  rD   r  strrG  r  r\   r$   r"   r   r     s       , , , , \%C- %fk %6; % % % \%$ \
 
 \
% % %
 
 
 H H XH>   X   X * * X* C C XC
 " " X" # # # # # X# $ $ $ $ $ X$ % % % " " X" # # # ( ( X( ) ) )
@ 
@ 
@7 7 7 \3V 3 3 3 \36
 
 
<m
 m
 m
 m
^4 4 4   \ Z Z Z \Zx5% 5% 5%n j j j \jX 
 $ $$$ $ $ $ \$L   $ Q QQ Q 	Q :Q Q Q Q \Q Q Qr$   r   )Esysenumr   r   cython.cimports.libavcimportslibavr)   cython.cimports.av.dictionaryr   cython.cimports.av.errorr   $cython.cimports.av.sidedata.sidedatar   cython.cimports.av.utilsr   cython.cimports.av.video.formatr	   r
   cython.cimports.av.video.planer   r   r   r   cython.cimports.cpython.excr   !cython.cimports.cpython.pycapsuler   r   r   cython.cimports.cpython.refr   r   cython.cimports.libc.stdintr   r   cclassr   rZ   ro   r(   rg   r#  	exceptvalr  voidrl   rp   r   r   supported_np_pix_fmtsr  r  r<  r  r  r   r   r   rY   	byteorderr   inliner   r  r	  r  r  Framer\   r$   r"   <module>r     s!	   



        # # # # # # # # # 4 4 4 4 4 4 . . . . . . E E E E E E 2 2 2 2 2 2 I I I I I I I I S S S S S S S S S S S S 3 3 3 3 3 3         
 = < < < < < < < 8 8 8 8 8 8 8 8 ` ` ` ` ` ` ` `F   FN?4S    8 !M!
.
!! [! ! !   ! 3M3
.
!3 [3 3 3   3 (99 U U U r $V^eFK$%	%&PPP 	|P 	|	P
 	|P 	|P 	-P 	-P 	-P 	-P 	-P 	-P 	-P 	-P 	P  	=!P" 	=#P P$ 	%P& 	'P( 	M)P* 	M+P, 	-P. 	]/P0 	]1P2 	]3P4 	]5P6 	]7P8 	]9P: 	];P< 	]=P> 	n?P@ 	nAPB 	CPD 	MEP P PF 	MGPH 	MIPJ 	MKPL 	MMPN 	MOPP 	MQPR 	MSPT 	=UPV 	=WPX 	^YPZ 	^[P\ 	]P^ 	M_P` 	MaPb 	McPd 	MePf 	MgP P Ph 	MiPj 	MkPl 	MmPn 	oPp 	=qPr 	=sPt 	^uPv 	^wPx 	yPz 	={P| 	=}P~ 	P@ 	APB 	MCPD 	MEPF 	^GPH 	^IP PJ %$##$$%% _P P PS S l .: . . . .         '        S]e-CDD fk      %% [% [	%
 ;% % % %P Hj H6; H H H H
 FMM MM(.M@CM M M  M4 Jv J6; J J J J
 x x x x x x x x x xr$   