
    3jv                        S SK r S SKJr  S SKrS SKJs  Jr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJr  S SKJrJrJrJr  S S	KJr  S S
KJrJrJr  S SKJrJ r   S SK!J"r"J#r#  \RH                  \RJ                   " S S5      5       5       r&\RN                  S\(S\(S\RR                  \   4S j5       r*\RN                  \RV                  \RX                  " SS9S\RZ                  S\RR                  \#   S\R\                  4S j5       5       5       r/\RN                  \RV                  \RX                  " SS9S\RZ                  S\RR                  \#   S\R\                  4S j5       5       5       r0\Rb                  " \(\(" 5       5      r21 Skr3\Rb                  " \4\5\6\Rn                  \54   4   0 SS_SS_SS_SS_S S_S!S_S"S#_S$S#_S%S#_S&S#_S'S#_S(S#_S)S#_S*S#_S+S,_S-S._S/S._0 S0S_S1S_S2S3_S4S3_S5S_S6S#_S7S#_S8S#_S9S#_S:S#_S;S#_S<S#_S=S#_S>S?_S@S?_SAS_SBS#_E0 SCS#_SDS#_SES#_SFS#_SGS#_SHS#_SIS#_SJS#_SKS#_SLS?_SMS?_SNS_SOS#_SPS#_SQS#_SRS#_SSS#_E0 STS#_SUS#_SVS#_SWS_SXS#_SYS#_SZS?_S[S?_S\S,_S]S._S^S._S_S_S`S_SaS3_SbS3_ScSd_SeSd_ESfSfSgSgSS#S#S#S#SShSi.E5      r8\RN                  S\94Sj j5       r: " Sk Sl\5      r;\Rb                  " \Rx                  \ Rz                  Sm:H  5      r>\RN                  \R~                  Sn\Rx                  4So j5       5       r@\RN                  Sp\Sq\Rn                  Sr\Rx                  Ss\Rx                  4St j5       rA\RN                  Sp\Sq\Rn                  4Su j5       rB\RN                  \R~                   SSp\Sq\Rn                  Sv\54Sw jj5       5       rC\RN                  Sx\(Sy\Rx                  4Sz j5       rD\RH                  \RJ                   " S{ S|\E5      5       5       r9g)}    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            
       T   \ rS rSrSS\R
                  S\R                  4S jjrS r\R                  S\R                  \R                     4S j5       r\R                  S\R                  S	\R
                  S
\R
                  S\R                  \R                     4S j5       rSrg)CudaContext   	device_idprimary_ctxc                 T    Xl         X l        [        R                  U l        0 U l        g N)r   r   cythonNULL_device_ref_frames_cache)selfr   r   s      H/home/wildlama/miniconda3/lib/python3.13/site-packages/av/video/frame.py	__cinit__CudaContext.__cinit__   s!    "&!;;    c                 @   U R                   R                  5        H  n[        R                  " [        R                  [
        R                     [        R                  " [        R                  U5      5      n[
        R                  " [        R                  " U5      5        M     U R                   R                  5         U R                  nU[        R                  :w  a@  [
        R                  " [        R                  " U5      5        [        R                  U l        g g r   )r!   valuesr   castpointerlibAVBufferRefsize_tav_buffer_unrefaddressclearr    r   )r"   vrefs      r#   __dealloc__CudaContext.__dealloc__   s     ##**,A++s/FMM1-C s 34 - 	  "&++s 34%{{D r&   returnc           	         U R                   nU[        R                  :w  a  U$ [        R                  nU R                   R	                  5       nUn[        SU R                  (       a  SOS05      n[        [        R                  " [        R                  " U5      [        R                  UUR                  S5      5        Xl         U$ )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_refCudaContext._get_device_ref/   s    6:6F6F
$[[
..)113".(4#3#3C=
 	&&z*))	
 &r&   sw_fmtwidthheightc                    [        U5      [        U5      [        U5      4nU R                  R                  U5      nUb  [        R                  " [        R
                  [        R                     [        R                  " [        R                  U5      5      n[        R                  " U5      nU[        R                  :X  a  [        S5      eU$ U R                  5       n[        R                  " U5      n	U	[        R                  :X  a  [        S5      e [        R                  " [        R
                  [        R                     U	R                  5      n
[!        S5      U
l        Xl        [        U5      U
l        [        U5      U
l        [+        [        R,                  " U	5      5        [        R                  " U	5      nU[        R                  :X  a5  [        R0                  " [        R2                  " U	5      5        [        S5      e[        R                  " [        R                  U	5      U R                  U'   U$ ! [.         a,    [        R0                  " [        R2                  " U	5      5        e f = f)Nzav_buffer_ref() failedzav_hwframe_ctx_alloc() failed   cuda)intr!   getr   r)   r*   r+   r,   r-   av_buffer_refr   MemoryErrorrA   av_hwframe_ctx_allocAVHWFramesContextdatar	   format	sw_formatrD   rE   r   av_hwframe_ctx_init	Exceptionr.   r/   )r"   rC   rD   rE   keycached
cached_refout_refr=   
frames_ref
frames_ctxs              r#   get_frames_ctxCudaContext.get_frames_ctxG   s    6{CJF4##'', s/FMM62J ''
3G&++%!":;;N))+
696N6N7

 $=>>	@Fs445zAJ !,G 4J#) "5zJ #FJc--j9:
 ##J/fkk!z :;677"(++fmmZ"H3  	z :;	s   BH= =6I3)r    r!   r   r   N)r   T)__name__
__module____qualname____firstlineno__r   rH   bintr$   r3   cfuncr*   r+   r,   rA   AVPixelFormatrY   __static_attributes__ r&   r#   r   r      s     6::    +  \\!@  . \\0!!0 zz0 

	0
 
	(0 0r&   r   objstreamr5   c                    [        U S5      (       a#  Uc  U R                  5       OU R                  US9nOU n[        US5      (       d  [        5         [	        S5      e[
        R                  " [
        R                  [           [        US5      5      nU[
        R                  :X  a  [        S5      e[        US5      S:w  a  [        S5      eU$ )	N
__dlpack__)re   s   dltensorz>expected a DLPack capsule or an object implementing __dlpack__z"PyCapsule_GetPointer returned NULLs   used_dltensorr   zPyCapsule_SetName failed)hasattrrg   r   r   	TypeErrorr   r)   r*   r   r   r   
ValueErrorr   RuntimeError)rd   re   capsulemanageds       r#   _consume_dlpackrn   {   s    
 sL!!&,n#.."#..PV.:WWk22L
 	
 kk'Wk2G &++=>>"23q8566Nr&   F)checkopaquerN   c                     [         R                  " [         R                  [           U 5      nU[         R                  :w  a  UR                  U5        g g r   )r   r)   r*   r   r   deleter)rp   rN   rm   s      r#   _dlpack_avbuffer_freers      s?     06{{'0G &++  r&   c                     U [         R                  :w  a>  [         R                     [        [         R                  " [
        U 5      5        S S S 5        g g ! , (       d  f       g = fr   )r   r   gilr   r)   object)rp   rN   s     r#   _numpy_avbuffer_freerw      s<     ZZfkk&&12 Z Zs   %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_rggb16lerx   )   uint8ry   r   )   r   r   r   r   r   )   uint16r   r   r   r   r   r   r   r   )   r   r   )   r   r   rz   r{   r   )   r   r   r   r   r   r   r   r   r   r   r   r   )r   float32r   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   r   r   r   r   r   r   r   r   r   r   )r   float16r   )   r   )   r   )r   r   )r   r   r   r   r   r   r   r   r   r   r   c                       [        [        5      $ )zGet a mostly uninitialized VideoFrame.

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

)
VideoFrame_cinit_bypass_sentinelrc   r&   r#   alloc_video_framer   d  s     ,--r&   c                       \ rS rSr\R
                  r\R                  r\R                  r
\R                  r\R                  r\R                  r\R"                  r\R&                  rSrg)PictureTypeio  rc   N)r[   r\   r]   r^   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BIrb   rc   r&   r#   r   r   o  sZ    ##DAAAA			B			B			Br&   r   big
big_endianc                 :    [         U:w  a  U R                  5       $ U $ r   )_is_big_endianbyteswap)arrayr   s     r#   byteswap_arrayr   }  s     #~~Lr&   planebytes_per_pixelflip_horizontalflip_verticalc                    U nSnUR                   U-  nUnSn	[        UR                  5      n
[        R                  " [        R
                  5      u  pnU(       a  UR                  S-
  nSnSnOSnUR                  nSn[        XU5       HZ  nX-  nU(       a>  [        SXr5       H-  n[        U5       H  nUXg-   U-
  U-
  U-      XU-   U-   '   M     M/     O
XVXg-    XX-   & X-  n	M\     g )Nr   r   )rD   abs	line_sizer   declarerH   rE   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    s     '0EE#kkO;HEE!%//2H%~~fjj9ILL1$		,,Y.1h8/A+0(1,>B,E!)a-( 0 9 /4E<L.ME%*+ /r&   c                 @    U R                  5       n[        X1USS5        g )NF)tobytesr  )r   r   r   imgbytess       r#   copy_array_to_planer    s    mmoH%Gr&   dtypec                    SSK nUR                  U5      nU R                  R                  R                  U R
                     n[        U5      nUR                  nX-  nUS:X  a  U R                  U R                  4n	Xg4n
OU R                  U R                  U4n	XaU4n
US:  a-  U R                  S-
  U-  nU* /U
SS Q7n
UR                  XXU
S9$ UR                  XX
S9$ )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offsetstrides)r  r  r  )numpyr  framer<   linesizeindexr   itemsizerE   rD   ndarray)r   r   r  np	dtype_objr   total_line_sizer  channelsshaper  r  s               r#   useful_arrayr!    s     I((5I)nO!!H*H1}u{{+"-u{{H5"X>1},,"o5##2gabk2zz5  
 	
 ::eU:LLr&   r   okc                 D    U(       d  [        SU R                   S35      eg )NzUnexpected numpy array shape ``)rj   r   )r   r"  s     r#   check_ndarray_shaper%    s#    9%++aHII r&   c                      \ rS rSrS+S jr\R                  S\R                  S\R                  S\R                  4S j5       r
\R                  S 5       rS rS	 r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\R*                  S 5       r\S 5       r\R*                  S 5       r\S 5       r\R*                  S 5       r\S 5       r\R*                  S 5       r\S 5       r\R*                  S 5       rS rS r\R8                  S\4S j5       rS rS,S jr S r!\"S  5       r#\"S-S! j5       r$S" r%\"S.S# j5       r&\"   S/S$\'S\(S\(4S% jj5       r)\"       S0S\*S\(S\(S'\(S&-  S(\+4
S) jj5       r,S*r-g&)1r   i  c                 R    U[         L a  g [        U5      nU R                  XAU5        g r   )r   r	   _init)r"   rD   rE   rO   c_formats        r#   r$   VideoFrame.__cinit__  s&    **&1&&9

8F+r&   rO   rD   rE   c                 ^   Sn[         R                     X R                  l        X0R                  l        XR                  l        U(       a(  U(       a!  [        R                  " U R                  S5      nS S S 5        U(       a  [        U5        U R                  5         g ! , (       d  f       N1= f)Nr   r   )
r   nogilr<   rD   rE   rO   r+   av_frame_get_bufferr   _init_user_attributes)r"   rO   rD   rE   ress        r#   r(  VideoFrame._init  sk    \\"HHN$HHO$HHO --dhh;  cN""$ \s   A B
B,c                     [        [        R                  " [        R                  U R
                  R                  5      U R
                  R                  U R
                  R                  5      U l        g r   )	r
   r   r)   r+   ra   r<   rO   rD   rE   r"   s    r#   r.   VideoFrame._init_user_attributes  s@    &KK))488??;HHNNHHOO
r&   c                 D    [         R                  " U R                  5        g r   )r+   av_frame_unrefr<   r2  s    r#   r3   VideoFrame.__dealloc__  s    488$r&   c                     SU R                   R                   SU R                   SU R                  R                   SU R
                   SU R                   S[        U 5      S S3$ )Nz<av.z, pts= xz at 0x>)	__class__r[   ptsrO   namerD   rE   idr2  s    r#   __repr__VideoFrame.__repr__  s\    4>>**+6$((1T[[=M=M<Nazzl!DKK=r$xl!=	
r&   c           	      r   U R                   nU R                  R                  (       a  [        R                  " [        R
                  [        R                     U R                  R                  R                  5      n[        UR                  U R                  R                  U R                  R                  5      nSn[        UR                  R                  5       H2  nUR                  R                  U   R                   S-   nX5:  d  M0  UnM4     UR"                  S:X  a  SnSnXc:  aH  U R                  R$                  U   (       a*  US-  nXc:  a   U R                  R$                  U   (       a  M*  US:X  a  ['        U S5      4$ [)        [        U5       Vs/ s H  n['        X5      PM     sn5      $ s  snf )z*
A tuple of :class:`.VideoPlane` objects.
r   r   r   r   )rO   r<   hw_frames_ctxr   r)   r*   r+   rM   rN   r
   rP   rD   rE   r   nb_componentscompr   r=  extended_datar   tuple)r"   fmtrX   max_plane_countr
  countplane_counts          r#   planesVideoFrame.planes  sS    kk88!!@Fs445txx7M7M7R7RAJ #$$dhhnndhhooC '(sww,,-AGGLLO))A-E&"' . 88vO"#+0F0F{0S1K +0F0F{0S0S!tQ'))53EF3Eaj)3EFGGFs   F4c                 .    U R                   R                  $ )zWidth of the image, in pixels.)r<   rD   r2  s    r#   rD   VideoFrame.width,  s     xx~~r&   c                 .    U R                   R                  $ )zHeight of the image, in pixels.)r<   rE   r2  s    r#   rE   VideoFrame.height1  s     xxr&   c                     [        U 5      $ )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   r2  s    r#   rotationVideoFrame.rotation6  s     $D))r&   c                 b    [        U R                  R                  [        R                  -  5      $ )z+Is this frame an interlaced or progressive?)boolr<   flagsr+   AV_FRAME_FLAG_INTERLACEDr2  s    r#   interlaced_frameVideoFrame.interlaced_frame@  s"     DHHNNS%A%AABBr&   c                 .    U R                   R                  $ )zlReturns an integer that corresponds to the PictureType enum.

Wraps :ffmpeg:`AVFrame.pict_type`

:type: int
r<   	pict_typer2  s    r#   r\  VideoFrame.pict_typeF  s     xx!!!r&   c                 $    XR                   l        g r   r[  r"   values     r#   r\  r]  P      "r&   c                 .    U R                   R                  $ )z;Colorspace of frame.

Wraps :ffmpeg:`AVFrame.colorspace`.

r<   
colorspacer2  s    r#   rd  VideoFrame.colorspaceT  s     xx"""r&   c                 $    XR                   l        g r   rc  r_  s     r#   rd  re  ]  s    #r&   c                 .    U R                   R                  $ )z=Color range of frame.

Wraps :ffmpeg:`AVFrame.color_range`.

r<   color_ranger2  s    r#   ri  VideoFrame.color_rangea  s     xx###r&   c                 $    XR                   l        g r   rh  r_  s     r#   ri  rj  j  s    $r&   c                 .    U R                   R                  $ )zGTransfer characteristic of frame.

Wraps :ffmpeg:`AVFrame.color_trc`.

r<   	color_trcr2  s    r#   rn  VideoFrame.color_trcn  s     xx!!!r&   c                 $    XR                   l        g r   rm  r_  s     r#   rn  ro  w  ra  r&   c                 .    U R                   R                  $ )zEColor primaries of frame.

Wraps :ffmpeg:`AVFrame.color_primaries`.

r<   color_primariesr2  s    r#   rs  VideoFrame.color_primaries{  s     xx'''r&   c                 $    XR                   l        g r   rr  r_  s     r#   rs  rt    s    #( r&   c                     U R                   (       d  [        5       U l         U R                   R                  " U /UQ70 UD6$ )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#   ry  VideoFrame.reformat  s9     /1D((????r&   c                 *    U R                   " SSS0UD6$ )zGet 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'

rO   r   rc   )ry  )r"   r{  s     r#   to_rgbVideoFrame.to_rgb  s     }}6G6v66r&   filepathc           	      &   UR                  S5      (       a  SnO:UR                  S5      (       d  UR                  S5      (       a  SnO[        S5      eU(       a  SOSnU(       a  S	OS
nSSKJn  U" USSS0S9 nUR	                  X4S9nU R
                  Ul        U R                  Ul        UR                  UR                  U R                  US95      5        UR                  UR                  S5      5        SSS5        g! , (       d  f       g= f)z@Save 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updater7   )r@   )pix_fmt)rO   N)
endswithrj   av.container.corer  
add_streamrD   rE   muxr9   ry  )r"   r  is_jpgencoderr  r  outputoutput_streams           r#   saveVideoFrame.save  s     V$$Fv&&(*;*;G*D*DFABB"(we%+z*(C(C9V"--g-GM"&**M#';;M JJ}++DMMM,IJKJJ}++D12 :99s   :A?D
Dc           	         SSK Jn  U R                  " S	SS0UD6R                  S   nUnUR                  n[        U5      nSnUR                  S-  nUR                  U-  n	[        U	5      n
US:  a  UR                  S-
  U-  OSnXy:  a$  XKX-    XXx-   & US:  a  X-  nOX-  nXx-  nXy:  a  M$  UR                  SUR                  UR                  4[        U
5      SSSS5      $ )
zGet an RGB ``PIL.Image`` of this frame.

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

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

r   )ImagerO   r   r   r   RGBrawrc   )PILr  ry  rK  r   r   rD   rE   	bytearray	frombytesbytes)r"   r{  r  r   r   r   r  r  r  o_sizer  r  s               r#   to_imageVideoFrame.to_image  s     	 MMCCFCJJ1M*/ %	"%i. "'++/ %x 7$V, AJAq 0H<STn.3E<L.ME%*+1}!!E n EKK.eeUAq
 	
r&   c                 H
   U R                   R                  (       a  SU;  a  [        R                  " [        R                  [
        R                     U R                   R                  R                  5      n[        U5      n[        UR                  U R                   R                  U R                   R                  5      R                  US'   [        U5      S:  a  U R                  " S0 UD6OU nUR                   R                  (       a  [!        S5      eSSKnUR$                  R                  nUR&                  nU[(        ;   GaQ  US:X  aH  UR                   R                  S-  S:X  d   S5       eUR                   R                  S-  S:X  d   S5       e[(        U   u  p[        U5      n
U
S	:X  a  [+        US   X5      nOUR-                  UR                   R                  UR                   R                  U
4U	S
9nUR/                  S5      (       a  SSS	/[1        SU
5      Q7nO[1        U
5      n[3        U5       H  u  p[+        X~   X5      USS2SS2U4'   M     [5        XR7                  S5      5      nU(       d  US;   a  UR9                  USS5      nU$ US;   a  UR                   R                  S-  S:X  d   S5       eUR                   R                  S-  S:X  d   S5       eUR;                  [+        US   5      R=                  S5      [+        US	   5      R=                  S5      [+        US   5      R=                  S5      /5      R=                  SUR                   R                  5      $ US:X  a  UR                   R                  S-  S:X  d   S5       eUR                   R                  S-  S:X  d   S5       e[+        US   SS5      n[+        US	   SS5      n[+        US   SS5      nUR?                  USS	S9nUR?                  USS	S9nU(       a  URA                  UUU/SS9$ URA                  UUU/SS9$ US:X  a_  [+        US   5      nURC                  US	   S5      RE                  S5      R=                  SS	5      RG                  URH                  5      nUU4$ US:X  an  UR;                  [+        US   5      R=                  S5      [+        US	   S5      R=                  S5      /5      R=                  SUR                   R                  5      $ [!        SU S35      e)a  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.

rO   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   axisr   i4>i4r~   z'Conversion to numpy array with format `` is not yet supportedrc   )%r<   rB  r   r)   r*   r+   rM   rN   dictr
   rP   rD   rE   r=  lenry  rj   r  rO   rK  _np_pix_fmt_dtypesr!  empty
startswithr   	enumerater   r  moveaxishstackreshaperepeatstack
frombufferastypeviewr   )r"   channel_lastr{  rX   r  r  format_namerK  r  r  
num_planesr   plane_indicesr
  p_idxyur1   u_fullv_fullimagepalettes                         r#   
to_ndarrayVideoFrame.to_ndarray  s   , 88!!hf&<@Fs445txx7M7M7R7RAJ &\F/$$dhhnndhhoo d 8 8;6{QDMM3F3D99""QRR ll'').,,i'yy*a/S1SS/yy''!+q0U2UU00=OH(+FJQ$VAY@YY%%uyy
C5 !  ))%00%&1$DuQ
/C$DM$)*$5M )- 8HA%1&-%QE!Q'N !9"5*>*>t*DEEK3J$JE1a0L <<99??Q&!+S-SS+99##a'1,U.UU,99 +33B7 +33B7 +33B7 gb%))//*+ -'99??Q&!+S-SS+99##a'1,U.UU,VAY84AVAY84AVAY84A YYq!!Y,FYYq!!Y,FxxFF 3!x<<88Q/a888&  +EfQi.Qbhh	  '>!& 99 +33B7 A.66r:
 gb%))//*+ 5k]BXY
 	
r&   c                 x    UR                   S:w  a  UR                  S5      n[        XR                  S   S5        g)z&
Update content from a ``PIL.Image``.
r  r   r   N)modeconvertr  rK  )r"   imgs     r#   	set_imageVideoFrame.set_imageR  s0     88u++e$CCQ3r&   c                 v    [        U R                  S   U R                  S   S5      nUR                  U 5        U$ )z)
Construct a frame from a ``PIL.Image``.
r   r   r   )r   sizer  )r  r  s     r#   
from_imageVideoFrame.from_image[  s3    
 'sxx{CHHQKIr&   c                    SSK nU R                  S   nU(       d  U R                  S   nUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOUS
;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOaUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOGUS;   aX  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   4nGOUS;   a=  [        U SS5        U R                  S   S:w  a  [        S	5      eU R                  S   4nGOUS;   a=  [        U SS5        U R                  S   S:w  a  [        S	5      eU R                  S   4nGOcUS;   a=  [        U SS5        U R                  S   S:w  a  [        S	5      eU R                  S   4nGO US;   a}  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  4nGOUS;   a}  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  4nGOUS;   a}  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  4nGOUS;   a  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  U R                  S   S-  4nGOUS ;   a  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  U R                  S   S-  4nGOoUS!;   a  [        U SS5        [        X R                  S   S:H  5        U R                  SS S:w  a  [        S	5      eU R                  S   S-  U R                  S   S-  U R                  S   S-  U R                  S   S-  4nOUS";   a  [        U SS5        [        X R                  S   S-  S:H  5        [        X R                  S   S-  S:H  5        US#-  S-  nU R                  S   S:w  a  [        S	5      eUS$;   a3  U R                  S   U R                  S   S-  U R                  S   S-  4nO.U R                  S   U R                  S   4nO[        S%U S&35      eUR                  S'5      (       a*  UR                  UR                  U S(/ S)Q4   S*S5      5      n O?UR                  S+5      (       a)  UR                  UR                  U S(/ S,Q4   S*S5      5      n [        [        5      nUR                  XXEU5        U$ )-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   >   rx   ry   r{   r   r   )r   r      r   r   r   r   )r   r      r   r   r      r   r   )r   r   >   rz   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   >   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   r   >   r~   r   r   r      r   r   )Conversion from numpy array with format `r  r   .)r   r   r   r   r   r|   )r   r   r   )r  r   r   r%  r  rj   r  ascontiguousarrayr  r   r   _image_fill_pointers_numpy)r   rO   rD   r  rE   	linesizesr  s          r#   from_numpy_bufferVideoFrame.from_numpy_buffere  sJ     	QKKNE''%!,{{1~':;}}QR F* !QRRq)+ICC%1-{{1~':;}}QR F* !QRRq)+I//%A.{{1~':;}}QR G+ !QRRq)+I77%!,{{1~':;}}QR F* !QRRq)+IGG%1-{{1~':;}}QR F* !QRRq)+I11%A.{{1~':;}}QR F* !QRRq)+I11%A.{{1~':;}}QR G+ !QRRq)+I 	
 	
 %!,}}Q1$ !QRRq)+I 
 
( %1-}}Q1$ !QRRq)+I11%A.}}Q1$ !QRRq)+Ix%!,{{1~':;}}QR F* !QRRa A%a A%a A%I
  
 
 %1-{{1~':;}}QR F* !QRRa A%a A%a A%I
 11%A.{{1~':;}}QR G+ !QRRa A%a A%a A%I
 y %!,{{1~':;}}QR F* !QRRa A%a A%a A%a A%	I  	
 	
 %1-{{1~':;}}QR F* !QRRa A%a A%a A%a A%	I 33%A.{{1~':;}}QR G+ !QRRa A%a A%a A%a A%	I 66%!,{{1~'9Q'>?{{1~'9Q'>?q[1_F}}Q1$ !QRR00 MM!$MM!$)MM!$)	 #]]1-u}}Q/?@	;F8CYZ  W%%((U3;L5MrST)UVEv&&((U3	>5JBPQ)RSE12((v&Qr&   c           	      `   UR                   R                  n[        R                  " [        R                  [
           U5      n[        U5      n[        R                  " U R                  5        XR                  l
        X R                  l        X0R                  l        [        U5       H  u  pXR                  R                  U	'   M     [        [        R                   " U R                  R                  [        R                  " [        R"                  U R                  R                  5      U R                  R                  UU R                  R                  5      5      n[        R                  " [$        U5      n['        U5        [        R(                  " UU[*        [        R                  " [        R,                  U5      S5      U R                  R.                  S'   U R                  R.                  S   [        R0                  :X  a  [3        U5        [5        S5      eU R7                  5         g )Nr   zav_buffer_create failed)ctypesrN   r   r)   r*   r   r	   r+   r5  r<   rO   rD   rE   r  r  r   av_image_fill_pointersra   rv   r   av_buffer_createrw   p_voidbufr   r   rK   r.  )r"   r  rD   rE   r  rO   c_datac_ptrr)  r
  r  requiredpy_bufs                r#   r  %VideoFrame._image_fill_pointers_numpyB  sr   " %+MM$6$6)/V^^G5Lf)U&1&&9488$ # $Y/KA#+HHa  0 &&C--txx?!!
 VV,&.. KKv.
Q 88<<?fkk)f788""$r&   c           	         SSK n0 SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_S S!_S"S#_S$S#_S%S#_S&S#_S'S#_S(S#_S)S#_S*S#_S+S#_E0 S,S#_S-S._S/S._S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S=_S>S=_ESS!S#S#SSS!S?.ER                  US@5      u  pEnUGb=  U R                  SA:X  a  U SS2SS2S4   n [        XSB5        U(       d  USC;   a  UR	                  U SSA5      n [        X R                  SA   U:H  5        [        XR                  SD5      5      n [        U R                  SE   U R                  S   U5      nUR                  R                  R                  SF5      (       a7  UR                  U SS2SS2SESB24   U SS2SS2SSE24   U SS2SS2SBS24   /SASG9n [        U5       H'  n[        U SS2SS2U4   UR                   U   U5        M)     U$ USH:X  a  U u  p	[        U SISA5        [        U	SISA5        [        XR                  SJ:H  5        [        U R                  SE   U R                  S   U5      n[        XR                   S   SE5        UR                   SE   R#                  U	R%                  SK5      R'                  SL5      R)                  5       5        U$ USM;   a  [        U SISA5        [        X R                  S   SB-  S:H  5        [        X R                  SE   SA-  S:H  5        [        U R                  SE   U R                  S   SA-  SB-  U5      nUR*                  UR,                  -  n
SNU
-  SO-  nU R/                  SP5      n[        USU
 UR                   S   SE5        [        XU UR                   SE   SE5        [        XS UR                   SA   SE5        U$ USQ:X  a  [        U SISA5        [        X R                  S   SO-  S:H  5        [        X R                  SE   SA-  S:H  5        [        U R                  SE   U R                  S   SA-  U5      nUR*                  UR,                  -  n
XSA-  -   nU R/                  SP5      n[        USU
 UR                   S   SE5        [        XU UR                   SE   SE5        [        XS UR                   SA   SE5        U$ USR:X  GaM  [1        XR2                  5      (       a  U R4                  UR6                  :w  a  [9        SS5      eU(       a'  U R                  SA   SB:X  a  UR	                  U SAS5      n OU R                  S   SB:X  d  [9        ST5      eU R                  SES u  pUSA-  S:w  d	  USA-  S:w  a  [9        SU5      e[        XU5      n[        U S   UR                   S   SA5        U SESS2SSSA24   R;                  5       nU SASS2SSSA24   R;                  5       n[        XR                   SE   SA5        [        UUR                   SA   SA5        U$ USV:X  af  [        U SISB5        [        X R                  S   SA-  S:H  5        [        X R                  SE   SA-  S:H  5        [        X R                  SA   SA:H  5        GOUSW;   a*  [        U SISB5        [        X R                  SA   SB:H  5        GOUSX;   a*  [        U SISB5        [        X R                  SA   SO:H  5        GOUSY;   a  [        U SZSB5        [        X R                  SA   SB:H  5        [        U R                  SE   U R                  S   U5      n[        [        XR                  SD5      5      UR                   S   S[5        U$ US\;   a  [        U S]SB5        [        X R                  SA   SB:H  5        [        U R                  SE   U R                  S   U5      n[        [        XR                  SD5      5      UR                   S   S^5        U$ US_;   a  [        U SZSB5        [        X R                  SA   SO:H  5        [        U R                  SE   U R                  S   U5      n[        [        XR                  SD5      5      UR                   S   S`5        U$ USa;   a  [        U SbSB5        [        X R                  SA   SO:H  5        [        U R                  SE   U R                  S   U5      n[        [        XR                  SD5      5      UR                   S   S`5        U$ USc;   a  [        U S]SB5        [        X R                  SA   SO:H  5        [        U R                  SE   U R                  S   U5      n[        [        XR                  SD5      5      UR                   S   Sd5        U$ USe:X  a  [        U SISA5        [        X R                  S   SB-  S:H  5        [        X R                  SE   SA-  S:H  5        [        U R                  SE   U R                  S   SA-  SB-  U5      nUR*                  UR,                  -  nU R/                  SP5      n[        USU UR                   S   SE5        [        UUS UR                   SE   SA5        U$ [9        SfU Sg35      e[        U R                  SE   U R                  S   U5      n[        XR                   S   U R                  SA:X  a  SE5        U$ U R                  SA   5        U$ )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   rz   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   )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   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   )NNNr   r   r  r  r   r  r  r   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  >   rx   ry   r{   r   r  r   r   r  r   r   r  r   r  r   r  r   r~   r  r  )r  rI   ndimr   r  r%  r   r   r  r   rO   r=  r  concatenater   r  rK  r  r  r  r  rD   rE   r  
isinstancer  r  r   rj   copy)r   rO   r  r  r  r  r  r  r
  r  u_startv_startflatrE   rD   r  r1   uv_starts                     r#   from_ndarrayVideoFrame.from_ndarrayy  s
   " 	;%
.;%
.;%
 ?;%
 .	;%

 .;%
 ?;%
 .;%
 .;%
 ?;%
 .;%
 .;%
 ?;%
 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 zzQaDj)%*F.E$EE1a0{{1~'AB"5//$*?@Eu{{1~u{{1~vFE||  ++E22aAaCi(aAaCi(aABh
  '  8_#E!Q'NELLOXN %L V"NE%!,'7A.()BCu{{1~u{{1~vFE||A:LLO""7<<#6#=#=d#C#K#K#MNL..%!,{{1~'9Q'>?{{1~'9Q'>?u{{1~A0Bq/H&QEkkELL0G'kQ&G==$DQwa!DW 5u||AJXQCLy %!,{{1~'9Q'>?{{1~'9Q'>?u{{1~u{{1~/BFKEkkELL0G1,G==$DQwa!DW 5u||AJXQCL}$eZZ00EKK2994L !<== A! 3E1a0kk!n) T  "KKOMFqyA~!q !@AAuf5Ea%,,q/1=aCaCi %%'AaCaCi %%'A<<?A65<<?A6Ly %!,{{1~'9Q'>?{{1~'9Q'>?{{1~':;))%!,{{1~':;77%!,{{1~':;CC%1-{{1~':;u{{1~u{{1~vFEuood&;<ell1oq L//%A.{{1~':;u{{1~u{{1~vFEuood&;<ell1or LGG%1-{{1~':;u{{1~u{{1~vFEuood&;<ell1oq L11%A.{{1~':;u{{1~u{{1~vFEuood&;<ell1oq L11%A.{{1~':;u{{1~u{{1~vFEuood&;<ell1or Lv%!,{{1~'9Q'>?{{1~'9Q'>?u{{1~A0Bq/H&QE{{U\\1H==$DYha!DXYa!DL;F8CYZ  5;;q>5;;q>6B<<?qA	
  ?Dkk!n	
 r&   r   c                     [        XU5      nUS:X  a  [        XR                  S   SXE5        U$ US;   a6  [        U UR                  S   UR                  S5      (       a  SOSUU5        U$ [	        SU S	35      e)
Nr   r   r   >   r   r   r   r   r   r   r   r   r   r   r   r   8r   r   zFormat 'z' is not supported.)r   r  rK  r  NotImplementedError)r   rD   rE   rO   r   r   r  s          r#   
from_bytesVideoFrame.from_bytesf  s     5&1V<<?A4 /  
 
  Q__S))q  &8K&LMMr&   Nr   r   c           	         [        U [        [        45      (       d  U 4n [        U 5      S:w  a  [	        S5      e[        U5      n[        S5      n	[        S5      n
[        S5      nXX4;  a  [        S5      eX:X  a  SOSnUS:X  a  S	OSn[        R                  n[        R                  nS n [        U S
   U5      n[        U S	   U5      nUR                  R                  nUR                  R                  nUU:w  a  [	        S5      eU[        [        4;  a  [        S5      eUR                  R                  nUR                  R                  nUU:w  a  [	        S5      eU[        :X  a  Uc  UnO%UU:w  a  [	        S5      eOUS;  a  [	        S5      eS
nU[        :X  a  US
:w  d  US
:w  a  [	        S5      eUR                  R                  R                   S	:w  dH  UR                  R                  R"                  U:w  d$  UR                  R                  R$                  S	:w  a  ['        S5      eUR                  R                  R                   S	:w  dH  UR                  R                  R"                  U:w  d$  UR                  R                  R$                  S	:w  a  ['        S5      eUR                  R(                  S:w  a  [	        S5      e[        R*                  " [,        UR                  R.                  S
   5      n[        R*                  " [,        UR                  R.                  S	   5      nUS
:X  a=  US
:X  a7  [        R*                  " [0        U5      n[        R*                  " [0        U5      nO.US
:X  d  US
:X  a  [	        S5      eUU:w  d  UU:w  a  [	        S5      eUS-  (       d
  US-  (       a  [	        S5      eUR                  R2                  [        R                  :w  a[  UR                  R2                  S	   S	:w  a  [	        S5      e[        R*                  " [,        UR                  R2                  S
   5      nO[        R*                  " [,        U5      n[        R*                  " [0        UU-  5      n[        R*                  " [0        UU-  5      nUR                  R(                  nUS-  nUS:X  Ga  [        R*                  " [0        UR                  R.                  S
   5      n[        R*                  " [0        UR                  R.                  S	   5      nUU:w  d  UU:w  a  [	        S5      eUR                  R2                  [        R                  :w  a\  UR                  R2                  S	   S	:w  a  [	        S5      e[        R*                  " [,        UR                  R2                  S
   5      nGO[        R*                  " [,        U5      nGOUS:X  Gar  [        R*                  " [0        UR                  R.                  S
   5      n[        R*                  " [0        UR                  R.                  S	   5      n[        R*                  " [0        UR                  R.                  S   5      n UU:w  d  UUS-  :w  d  U S:w  a  [	        S5      eUR                  R2                  [        R                  :w  ax  UR                  R2                  S   S	:w  d  UR                  R2                  S	   S:w  a  [	        S5      e[        R*                  " [,        UR                  R2                  S
   5      nO'[        R*                  " [,        U5      nO[	        S5      e[        R*                  " [0        UU-  5      n![        R*                  " [0        U!US-  -  5      n"[5        5       nUUR6                  l        UUR6                  l        U[        :X  a  Uc
  [=        XVS9n#O[        U[<        5      (       d  ['        S 5      e[1        UR                  5      [1        U5      :w  a  [	        S!5      e[?        UR@                  5      [?        U5      :w  a  [	        S"5      e[        R*                  " [<        U5      n#U#RC                  XU5      n$[        S#5      UR6                  l"        U$UR6                  l#        UUl$        U#Ul%        OUUR6                  l"        [        R*                  " [        RL                  [N           UR                  RP                  5      [        R*                  " [        RR                  UR                  RT                  5      -   n%[        R*                  " [        RL                  [N           UR                  RP                  5      [        R*                  " [        RR                  UR                  RT                  5      -   n&[V        RX                  " U%U[Z        [        R*                  " [        R\                  U5      S
5      UR6                  R^                  S
'   UR6                  R^                  S
   [        R                  :X  a  [a        S$5      eU%UR6                  RP                  S
'   UUR6                  Rb                  S
'   [        R                  n[V        RX                  " U&U"[Z        [        R*                  " [        R\                  U5      S
5      UR6                  R^                  S	'   UR6                  R^                  S	   [        R                  :X  a  [a        S%5      eU&UR6                  RP                  S	'   U!UR6                  Rb                  S	'   [        R                  nURe                  5         U$ ! [f         ao    Ub   [V        Rh                  " UR6                  5        U[        R                  :w  a  URk                  U5        U[        R                  :w  a  URk                  U5        e f = f)&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_ctxrG   z#av_buffer_create failed for plane 0z#av_buffer_create failed for plane 1)6r  rF  listr  rj   r	   r  r   r   rn   	dl_tensordevice_typer   r   r   r  codebitslanesri   r  r)   r   r   rH   r  r   r<   rD   rE   r   rU  r   rY   rO   rB  
_device_id	_cuda_ctxr*   r   rN   r-   byte_offsetr+   r  rs   r  r  rK   r  r.  rR   r5  rr   )'rK  rO   rD   rE   re   r   r   cuda_contextrC   r~   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ctxrW   y_ptruv_ptrs'                                          r#   from_dlpackVideoFrame.from_dlpack  s	    &5$-00YFv;!Z  %0$77#Y'Y'//%&VWW#^%*1.4kk.4kk p	 F3B F3B00I00II% !OPP-)D  <<))D<<))Dt| !PQQE!$ $I$&$N  '
 I-$%JKK	D dai419 !NOO ""''1,<<%%**m;<<%%++q0 >??""''1,<<%%**m;<<%%++q0 >??||  A% !<==++gr||'9'9!'<=C++gr||'9'9!'<=CzfkC-S#.!v{ !NOO%<3&=$%PQQqyFQJ !STT||##v{{2<<''*a/$%WXX &GR\\5I5I!5L M &GU ;S-(*BCJ[[j6&9:Fll''G"aKM!|{{3(:(:1(=>{{3(:(:1(=>=(DEM$%QRR<<''6;;6||++A.!3(N  &,[[",,:N:Nq:Q%RN%+[[$%?NA{{3(:(:1(=>C););A)>?{{3(:(:1(=>=(Eeqj,ATQY$%VWW<<''6;;6||++A.!3r||7K7KA7NRS7S(K  &,[[",,:N:Nq:Q%RN%+[[%%@N !;<< ++c>H+DEKkk#{fk'BCG%'E#EIIO%EIIE!  '%	SC%lK@@'(LMM<112c)nD(_  L445k9JJ(Q  !++k<@C //vF
#.w#7		 *4		'#, "%#)		 KKw'):):FMM2<<+C+CDEE [[w'):):FMM2<<+C+CDEF  #33v4fkk&--QS6TVW EIIMM! yy}}Q6;;.!"GHH %EIINN1$.EIIq!B"33%FMM2. EIIMM! yy}}Q6;;.!"GHH &EIINN1$/EIIq!B'')L 	 ""599-V[[ 

2V[[ 

2	s   -km3 3A9o,)rO   rw  )r   r   r   )F)r   r   )r   F)r   FF)r~   r   r   NNTN).r[   r\   r]   r^   r$   r   r`   r+   ra   uintr(  r.  r3   r?  propertyrK  rD   rE   rR  rX  r\  setterrd  ri  rn  rs  ry  r~  ccallrv   r  r  r  r  staticmethodr  r  r  r  r  rH   r  strrU  r  rb   rc   r&   r#   r   r     s   , \\%C-- %fkk %6;; % %$ \\
 
%
 H H>     * * C C
 " " # # # # $ $ $ $ % % " " # # ( ( ) )
@7 \\3V 3 36#
Jm
^4   Z Zx5%n j jX 
 $$$ $ $L   $ QQ Q 	Q :Q Q Qr&   r   )F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   finalcclassr   r`   rv   r*   rn   r,  	exceptvalr  voidrs   rw   r   r   supported_np_pix_fmtsr  r#  rF  r  r  r   r   r   r_   	byteorderr   inliner   r  r  r!  r%  Framerc   r&   r#   <module>r;     s4   
   # # 4 . E 2 I S S 3 
 = 8 ` `  `F   FNN?4S  8 !MM!
..
!! [[!   ! 3MM3
..
!3 [[3   3  9 U r ^^eFKK$%	%&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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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J %$##$$%% _PS l .: . . '   S]]e-CD fkk    %% [[% [[	%
 ;;% %P Hj H6;; H H
 FMMM(.M@CM  MD Jv J6;; J J
    r&   