
    dj              
       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         G d d                      Z	e j         G d d                      Z e            Z e j        e j        e j        ej                          e j                  Z	 e                    e          ZesdS e                    ej                   4)    N)uintc_formatwidthheightreturnc                     | t           j        k    rd S t                              t          t                    }|                    | ||           |S N)libAV_PIX_FMT_NONEVideoFormat__new___cinit_bypass_sentinel_init)r   r   r   formats       J/home/agentuser/manim-venv/lib/python3.11/site-packages/av/video/format.pyget_video_formatr      sH     3&&&t%--k;QRRF
LL5&)))M    F)checknamec                 ~    t                               |           }|t           j        k    rt          d| z            |S )z3Wrapper for lib.av_get_pix_fmt with error checking.znot a pixel format: %r)r
   av_get_pix_fmtr   
ValueError)r   pix_fmts     r   get_pix_fmtr      s>    
 "%!3!3D!9!9G#%%%1D89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j        ddej        fd            Zej        ddej        fd            ZdS )r   zM

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

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

7E6*****r   r   r   r   c                 n    || _         t                              |          | _        || _        || _        d S r	   )r   r
   av_pix_fmt_desc_getptrr   r   )r    r   r   r   s       r   r   zVideoFormat._init4   s0    **733
r   c           	          | j         s| j        r(d| 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__;   sk    : 	A 	A\$.1\\DI\\\\dk\\\\@$.1@@DI@@@@r   c                 *    t          | j                  S r	   )intr   r,   s    r   __int__zVideoFormat.__int__A   s    4<   r   c                 J    t          j        t          | j        j                  S )z#Canonical name of the pixel format.)r   r   strr%   r   r,   s    r   r   zVideoFormat.nameD   s     {3...r   c                 h     t           fdt           j        j                  D                       S )Nc              3   8   K   | ]}t          |          V  d S r	   )VideoFormatComponent).0ir    s     r   	<genexpr>z)VideoFormat.components.<locals>.<genexpr>K   s?       
 
./ q))
 
 
 
 
 
r   )tupleranger%   nb_componentsr,   s   `r   
componentszVideoFormat.componentsI   sH     
 
 
 
389O3P3P
 
 
 
 
 	
r   c                 @    t                               | j                  S r	   )r
   av_get_bits_per_pixelr%   r,   s    r   bits_per_pixelzVideoFormat.bits_per_pixelO   s    ((222r   c                 @    t                               | j                  S r	   )r
   av_get_padded_bits_per_pixelr%   r,   s    r   padded_bits_per_pixelz!VideoFormat.padded_bits_per_pixelS   s    //999r   c                 N    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_endianW   s     DHNS%;;<<<r   c                 N    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\        DHNS%<<===r   c                 N    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_streama   s     DHNS%BBCCCr   c                 N    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_planarf   s     DHNS%??@@@r   c                 N    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_rgbk   rK   r   c                 N    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_bayerp   s     DHNS%>>???r   
luma_widthc                 >    |p| j         }|r| | j        j        z	   n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_widthu   s/      -4:
=GN:+$("8899QNr   luma_heightc                 >    |p| j         }|r| | j        j        z	   n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   s/     "0T[>IP;,48#99::q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      s        
+ 
+ 
+ 
+ \S. u e    \A A A! ! ! / / X/ 
 
 X

 3 3 X3 : : X: = = X= > > X> D D XD A A XA > > X> @ @ X@ \	O 	Ovz 	O 	O 	O \	O \	Q 	Q 	Q 	Q 	Q \	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dS )r5   r   indexc                 t    || _         || _        t          j        |j        j        |                   | _        d S r	   )r   rj   r   addressr%   comp)r    r   rj   s      r   r"   zVideoFormatComponent.__cinit__   s.    
>&*/%"899r   c                     | j         j        S )z5The index of the plane which contains this component.)r%   planer,   s    r   ro   zVideoFormatComponent.plane        x~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    r| j        j        j        dk    p| j         dk    o| 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   sB     
aFDKO$AQ$F 
J!OB = B	
r   c                     | j         dk    o6| j        j        j        dk    p!| j        j        j        dk    p| 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   sJ     zQ 
KO)Q. &{,1&;%%	
r   c                 r    | j         dk    s| j         dk    o!| j        j        j        p| 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   s8     
a24:? 
KO)JT[_-J	
r   c                 Z    | j         r| j                                        n| 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^Rt{'')))ARRr   c                 Z    | j         r| j                                        n| 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)     /3nTt{((***$+BTTr   N)r+   r`   ra   r   r   size_tr"   rf   ro   rs   ry   r{   r}   r   r   rh   r   r   r5   r5      s        : :FM : : : :
   X   X 
 
 X
 
 
 X
 
 
 X
 S S XS U U XU U Ur   r5   )r   r   re   declareobjectr   rc   r
   rd   r   r   	exceptvalr   p_const_charr   cclassr5   setnamespointerconstAVPixFmtDescriptorNULLdescav_pix_fmt_desc_nextaddr   rh   r   r   <module>r      s               '99  (-7<4    #%U333f) c.?    43  lQ lQ lQ lQ lQ lQ lQ lQ^ 7U 7U 7U 7U 7U 7U 7U 7Ut 	v~fnV\#2H%IJFKXX##D))D 	IIdi	r   