
    \j              
          d dl Z d dl mZ  e j                  e e             Ze j                  dej                  dedede	dz  fd       Z
e j                   e j                  ej                  d	      d
e j                  dej                  fd              Ze j                  e j                    G d d                    Z	e j                  e j                    G d d                    Z e       Z e j                  e j(                  e j*                  ej,                        e j.                        Z	 ej3                  e      Zesyej5                  ej6                         0)    N)uintc_formatwidthheightreturnc                     | t         j                  k(  ry t        j                  t        t              }|j                  | ||       |S N)libAV_PIX_FMT_NONEVideoFormat__new___cinit_bypass_sentinel_init)r   r   r   formats       B/root/.hermes/venv/lib/python3.12/site-packages/av/video/format.pyget_video_formatr      s=     3&&&%--k;QRF
LL5&)M    F)checknamec                 r    t         j                  |       }|t         j                  k(  rt        d|       |S )z3Wrapper for lib.av_get_pix_fmt with error checking.znot a pixel format: )r
   av_get_pix_fmtr   
ValueError)r   pix_fmts     r   get_pix_fmtr      s:    
 "%!3!3D!9G#%%%/x899Nr   c                      e Zd ZdZddZej                  dej                  de	de	f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d        Zed        Zed        Zed        Zej0                  ddej2                  fd       Zej0                  ddej2                  fd       Zy)r   zM

    >>> format = VideoFormat('rgb24')
    >>> format.name
    'rgb24'

    c                    |t         u ry t        |t              rTt        j                  t        |      }| j                  |j                  |xs |j                  |xs |j                         y t        |      }| j                  |||       y r	   )
r   
isinstancer   cythoncastr   r   r   r   r   )selfr   r   r   otherr   s         r   	__cinit__zVideoFormat.__cinit__)   sk    ))dK(!'[$!?EJJu}}e&:u{{F<RellS%0%6

7E6*r   r   r   r   c                 b    || _         t        j                  |      | _        || _        || _        y r	   )r   r
   av_pix_fmt_desc_getptrr   r   )r    r   r   r   s       r   r   zVideoFormat._init5   s)    **73
r   c           	         | j                   s| j                  rAd| j                  j                   d| j                   d| j                    d| j                   d	S d| j                  j                   d| j                   dS )Nz<av. z, x>)r   r   	__class____name__r   r    s    r   __repr__zVideoFormat.__repr__<   sl    ::$..112!DII;bAdkk]Z[\\$..112!DII;a@@r   c                 ,    t        | j                        S r	   )intr   r,   s    r   __int__zVideoFormat.__int__B   s    4<<  r   c                 ^    t        j                  t        | j                  j                        S )z#Canonical name of the pixel format.)r   r   strr%   r   r,   s    r   r   zVideoFormat.nameE   s     {{3..r   c                 f     t         fdt         j                  j                        D              S )Nc              3   6   K   | ]  }t        |        y wr	   )VideoFormatComponent).0ir    s     r   	<genexpr>z)VideoFormat.components.<locals>.<genexpr>L   s      
./ q)
s   )tupleranger%   nb_componentsr,   s   `r   
componentszVideoFormat.componentsJ   s,     
389O9O3P
 
 	
r   c                 @    t         j                  | j                        S r	   )r
   av_get_bits_per_pixelr%   r,   s    r   bits_per_pixelzVideoFormat.bits_per_pixelP   s    ((22r   c                 @    t         j                  | j                        S r	   )r
   av_get_padded_bits_per_pixelr%   r,   s    r   padded_bits_per_pixelz!VideoFormat.padded_bits_per_pixelT   s    //99r   c                 b    t        | j                  j                  t        j                  z        S )zPixel format is big-endian.)boolr%   flagsr
   AV_PIX_FMT_FLAG_BEr,   s    r   is_big_endianzVideoFormat.is_big_endianX   s"     DHHNNS%;%;;<<r   c                 b    t        | j                  j                  t        j                  z        S )zJPixel format has a palette in data[1], values are indexes in this palette.)rD   r%   rE   r
   AV_PIX_FMT_FLAG_PALr,   s    r   has_palettezVideoFormat.has_palette]   "     DHHNNS%<%<<==r   c                 b    t        | j                  j                  t        j                  z        S )z9All values of a component are bit-wise packed end to end.)rD   r%   rE   r
   AV_PIX_FMT_FLAG_BITSTREAMr,   s    r   is_bit_streamzVideoFormat.is_bit_streamb   s"     DHHNNS%B%BBCCr   c                 b    t        | j                  j                  t        j                  z        S )z<At least one pixel component is not in the first data plane.)rD   r%   rE   r
   AV_PIX_FMT_FLAG_PLANARr,   s    r   	is_planarzVideoFormat.is_planarg   s"     DHHNNS%?%??@@r   c                 b    t        | j                  j                  t        j                  z        S )zFThe pixel format contains RGB-like data (as opposed to YUV/grayscale).)rD   r%   rE   r
   AV_PIX_FMT_FLAG_RGBr,   s    r   is_rgbzVideoFormat.is_rgbl   rK   r   c                 b    t        | j                  j                  t        j                  z        S )z%The pixel format contains Bayer data.)rD   r%   rE   r
   AV_PIX_FMT_FLAG_BAYERr,   s    r   is_bayerzVideoFormat.is_bayerq   s"     DHHNNS%>%>>??r   
luma_widthc                 `    |xs | j                   }|r| | j                  j                  z	   S dS )zchroma_width(luma_width=0)

        Width of a chroma plane relative to a luma plane.

        :param int luma_width: Width of the luma plane; defaults to ``self.width``.

        r   )r   r%   log2_chroma_w)r    rX   s     r   chroma_widthzVideoFormat.chroma_widthv   s3      -4::
=G:+$(("8"889NQNr   luma_heightc                 `    |xs | j                   }|r| | j                  j                  z	   S dS )zchroma_height(luma_height=0)

        Height of a chroma plane relative to a luma plane.

        :param int luma_height: Height of the luma plane; defaults to ``self.height``.

        r   )r   r%   log2_chroma_h)r    r\   s     r   chroma_heightzVideoFormat.chroma_height   s3     "0T[[>I;,488#9#99:PqPr   N)r   r   )r   )r+   
__module____qualname____doc__r"   r   cfuncr
   AVPixelFormatcuintr   r-   r0   propertyr   r<   r?   rB   rG   rJ   rN   rQ   rT   rW   ccallr/   r[   r_    r   r   r   r      sd   
+ \\S.. u e  A! / / 
 

 3 3 : : = = > > D D A A > > @ @ \\	Ovzz 	O 	O \\	Q 	Q 	Qr   r   c                       e Zd Zdedej
                  fdZed        Zed        Z	ed        Z
ed        Zed        Zed	        Zed
        Zy)r5   r   indexc                     || _         || _        t        j                  |j                  j
                  |         | _        y r	   )r   rj   r   addressr%   comp)r    r   rj   s      r   r"   zVideoFormatComponent.__cinit__   s-    
>>&**//%"89r   c                 .    | j                   j                  S )z5The index of the plane which contains this component.)r%   planer,   s    r   ro   zVideoFormatComponent.plane        xx~~r   c                 .    | j                   j                  S )z Number of bits in the component.)r%   depthr,   s    r   bitszVideoFormatComponent.bits   rp   r   c                     | j                   dk(  xr# | j                  j                  j                  dk(  xs4 | j                   dk(  xr# | j                  j                  j                  dk(  S )z#Is this component an alpha channel?            )rj   r   r%   r;   r,   s    r   is_alphazVideoFormatComponent.is_alpha   sT     

aFDKKOO$A$AQ$F 
JJ!OB = = B	
r   c                     | j                   dk(  xra | j                  j                  j                  dk(  xs< | j                  j                  j                  dk(  xs | j                  j                   S )z!Is this component a luma channel?r   ru   rv   )rj   r   r%   r;   rT   r,   s    r   is_lumazVideoFormatComponent.is_luma   s_     zzQ 
KKOO))Q. &{{,,1&;;%%%	
r   c                     | j                   dk(  xs | j                   dk(  xrB | j                  j                  j                  xs  | j                  j                  j                  S )z#Is this component a chroma channel?ru   rv   )rj   r   r%   rZ   r^   r,   s    r   	is_chromazVideoFormatComponent.is_chroma   sJ     

a24::? 
KKOO))JT[[__-J-J	
r   c                 z    | j                   r| j                  j                         S | j                  j                  S )zqThe width of this component's plane.

        Requires the parent :class:`VideoFormat` to have a width.

        )r}   r   r[   r   r,   s    r   r   zVideoFormatComponent.width   s,     .2^^t{{'')RARARRr   c                 z    | j                   r| j                  j                         S | j                  j                  S )zsThe height of this component's plane.

        Requires the parent :class:`VideoFormat` to have a height.

        )r}   r   r_   r   r,   s    r   r   zVideoFormatComponent.height   s,     /3nnt{{((*T$++BTBTTr   N)r+   r`   ra   r   r   r   r"   rf   ro   rs   ry   r{   r}   r   r   rh   r   r   r5   r5      s    : :FKK :
     
 
 
 
 
 
 S S U Ur   r5   )r   r   re   declareobjectr   rc   r
   rd   r   r   	exceptvalr   p_const_charr   finalcclassr5   setnamespointerconstAVPixFmtDescriptorNULLdescav_pix_fmt_desc_nextaddr   rh   r   r   <module>r      st     '9  (-7<4  #%%U3f)) c.?.?  4  lQ lQ  lQ^ 7U 7U  7Ut 	v~~fnnV\\#2H2H%IJFKKX
##D)D	IIdii	 r   