§
    ÜóÉjÄ  ã                   ó²   — d dl 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 d dlmZ d dlmZ e j        e j         G d	„ d
e¦  «        ¦   «         ¦   «         ZdS )é    N)Úlibav)ÚPacket)ÚStream)Úavrational_to_fraction)Ú
VideoFrame)Úint32_t)Úmemcpyc                   ó2  — e Zd Zd„ Zd„ Zej        ddedz  fd„¦   «         Zej        dde	dz  fd„¦   «         Z
ej        d„ ¦   «         Zej        d	„ ¦   «         Zd
„ Zdd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         ZdS )ÚVideoStreamc                 óð   — | j         €d| j        › dt          | ¦  «        d›d�S d| j        › d| j        › d| j        r| j        j        nd › d| j         j        › d| j         j        › dt          | ¦  «        d›d�S )Nz<av.VideoStream #z video/<nocodec> at 0xÚxú>ú z, z at 0x)Úcodec_contextÚindexÚidÚnameÚformatÚwidthÚheight©Úselfs    út/home/lighthouse/badge-speaker-benchmark/.benchmark-venv-community/lib64/python3.11/site-packages/av/video/stream.pyÚ__repr__zVideoStream.__repr__   s´   € ØÔÐ%ØV t¤zÐVÐVÍÈDÉÌÐVÐVÐVÐVÐVð> ¤
ð >ð >¨T¬Yð >ð >Ø#'¤;Ð8ˆtŒ{ÔÐ°Dð>ð >Ø;?Ô;MÔ;Sð>ð >àÔ!Ô(ð>ð >å02°4±´Ð=ð>ð >ð >ð	
ó    c                 óâ   — |dv r(t          dt          | ¦  «        j        › d|› d�¦  «        ‚| j        €(t          dt          | ¦  «        j        › d|› d�¦  «        ‚t	          | j        |¦  «        S )N)Ú	framerateÚrateú'z' object has no attribute ')ÚAttributeErrorÚtypeÚ__name__r   Úgetattr)r   r   s     r   Ú__getattr__zVideoStream.__getattr__   s�   € ØÐ(Ð(Ð(Ý ØK•D˜‘J”JÔ'ÐKÐKÀDÐKÐKÐKñô ð ð ÔÐ%Ý ØK•D˜‘J”JÔ'ÐKÐKÀDÐKÐKÐKñô ð õ �tÔ)¨4Ñ0Ô0Ð0r   NÚframec                 ó¼   — |                       t          j        ¦  «         | j                             |¦  «        }|D ]}| |_        | j        j        |j        _        Œ |S )zÉ
        Encode an :class:`.VideoFrame` and return a list of :class:`.Packet`.

        :rtype: list[Packet]

        .. seealso:: This is mostly a passthrough to :meth:`.CodecContext.encode`.
        )	Ú_assert_has_codec_contextÚlibÚAVERROR_ENCODER_NOT_FOUNDr   ÚencodeÚ_streamÚptrr   Ústream_index)r   r%   ÚpacketsÚpackets       r   r*   zVideoStream.encode"   s]   € ð 	×&Ò&¥sÔ'DÑEÔEÐEØÔ$×+Ò+¨EÑ2Ô2ˆàð 	5ð 	5ˆFØ!ˆFŒNØ&*¤h¤nˆFŒJÔ#Ð#Øˆr   r/   c                 ó^   — |                       ¦   «          | j                             |¦  «        S )zÅ
        Decode a :class:`.Packet` and return a list of :class:`.VideoFrame`.

        :rtype: list[VideoFrame]

        .. seealso:: This is a passthrough to :meth:`.CodecContext.decode`.
        )r'   r   Údecode)r   r/   s     r   r1   zVideoStream.decode3   s-   € ð 	×&Ò&Ñ(Ô(Ð(ØÔ!×(Ò(¨Ñ0Ô0Ð0r   c                 ó¾   — t          j        | ¦  «         | j        �| j        j        j        | j        _        | j        �| j        r|                      ¦   «          d S d S d S ©N)r   Ú_finalize_for_outputr   r,   r   Úavg_frame_rateÚ_has_display_matrixÚ_apply_display_matrixr   s    r   r4   z VideoStream._finalize_for_output?   sh   € åÔ# DÑ)Ô)Ð)ØÔÐ)Ø&*Ô&8Ô&<Ô&FˆDŒHÔ#ð ÔÐ)¨dÔ.FÐ)Ø×&Ò&Ñ(Ô(Ð(Ð(Ð(ð *Ð)Ð)Ð)r   c                 óz  — dt          j        t          ¦  «        z  }t          j        t          j        | j        j        j        ¦  «        t          j        | j        j        j	        ¦  «        t          j
        |d¦  «        }|t           j        k    rt          d¦  «        ‚t          |j        | j        |¦  «         d S )Né	   r   z+could not allocate display matrix side data)ÚcythonÚsizeofr   r(   Úav_packet_side_data_newÚaddressr,   ÚcodecparÚcoded_side_dataÚnb_coded_side_dataÚAV_PKT_DATA_DISPLAYMATRIXÚNULLÚMemoryErrorr	   ÚdataÚ_display_matrix)r   ÚnÚsds      r   r7   z!VideoStream._apply_display_matrixI   s™   € à�FœM­'Ñ2Ô2Ñ2ˆÝ36Ô3NÝŒN˜4œ8Ô,Ô<Ñ=Ô=ÝŒN˜4œ8Ô,Ô?Ñ@Ô@ÝÔ)ØØñ4
ô 4
ˆð •”ÒÐÝÐKÑLÔLÐLåˆrŒw˜Ô,¨aÑ0Ô0Ð0Ð0Ð0r   c                 óÊ   — |€	d| _         dS d„ |D ¦   «         }t          |¦  «        dk    rt          d¦  «        ‚t          d¦  «        D ]}||         | j        |<   Œd| _         dS )aB  Set the display matrix written to the container as coded side data.

        ``matrix`` is a sequence of 9 integers in FFmpeg's ``AV_PKT_DATA_DISPLAYMATRIX``
        layout, or ``None`` to clear. Must be called before the first frame is
        encoded. See :meth:`set_display_rotation` for a higher-level helper.
        NFc                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Úint)Ú.0Úvs     r   ú
<listcomp>z2VideoStream.set_display_matrix.<locals>.<listcomp>c   s   € Ð'Ð'Ð'˜1•�A‘”Ð'Ð'Ð'r   r9   z+display matrix must have exactly 9 elementsT)r6   ÚlenÚ
ValueErrorÚrangerE   )r   ÚmatrixÚvalsÚis       r   Úset_display_matrixzVideoStream.set_display_matrixX   s~   € ð ˆ>Ø',ˆDÔ$ØˆFà'Ð' Ð'Ñ'Ô'ˆÝˆt‰9Œ9˜Š>ˆ>ÝÐJÑKÔKÐKå�q‘”ð 	.ð 	.ˆAØ&*¨1¤gˆDÔ  Ñ#Ð#Ø#'ˆÔ Ð Ð r   Fc                 óÎ   — t          j        | j        t          |¦  «         ¦  «         t          j        | j        t          |¦  «        t          |¦  «        ¦  «         d| _        dS )ah  Set the container display matrix from a rotation and optional flips.

        ``degrees`` is a counter-clockwise rotation (matching the value read back
        from :attr:`VideoFrame.rotation`); ``hflip`` / ``vflip`` mirror after it.
        Together these express all eight EXIF orientations. Must be called before
        the first frame is encoded.
        TN)r(   Úav_display_rotation_setrE   ÚfloatÚav_display_matrix_flipÚboolr6   )r   ÚdegreesÚhflipÚvflips       r   Úset_display_rotationz VideoStream.set_display_rotationk   sT   € õ 	Ô# DÔ$8½5À¹>¼>¸/ÑJÔJÐJÝÔ" 4Ô#7½¸e¹¼ÅdÈ5ÁkÄkÑRÔRÐRØ#'ˆÔ Ð Ð r   c                 óX   — t          t          j        | j        j        ¦  «        ¦  «        S )zá
        The average frame rate of this video stream.

        This is calculated when the file is opened by looking at the first
        few frames and averaging their rate.

        :type: fractions.Fraction | None
        )r   r:   r=   r,   r5   r   s    r   Úaverage_ratezVideoStream.average_ratey   s!   € õ &¥f¤n°T´XÔ5LÑ&MÔ&MÑNÔNÐNr   c                 óX   — t          t          j        | j        j        ¦  «        ¦  «        S )a  
        The base frame rate of this stream.

        This is calculated as the lowest framerate at which the timestamps of
        frames can be represented accurately. See :ffmpeg:`AVStream.r_frame_rate`
        for more.

        :type: fractions.Fraction | None
        )r   r:   r=   r,   Úr_frame_rater   s    r   Ú	base_ratezVideoStream.base_rate…   s!   € õ &¥f¤n°T´XÔ5JÑ&KÔ&KÑLÔLÐLr   c                 ó¢   — t          j        t          j        | j        t          j        ¦  «        }t          t          j        |¦  «        ¦  «        S )zãThe guessed frame rate of this stream.

        This is a wrapper around :ffmpeg:`av_guess_frame_rate`, and uses multiple
        heuristics to decide what is "the" frame rate.

        :type: fractions.Fraction | None
        )r(   Úav_guess_frame_rater:   rB   r,   r   r=   )r   Úvals     r   Úguessed_ratezVideoStream.guessed_rate’   s=   € õ "Ô5ÝŒK˜œ¥6¤;ñ
ô 
ˆõ &¥f¤n°SÑ&9Ô&9Ñ:Ô:Ð:r   c                 ó¢   — t          j        | j        j        | j        t          j        ¦  «        }t          t	          j        |¦  «        ¦  «        S )a  The guessed sample aspect ratio (SAR) of this stream.

        This is a wrapper around :ffmpeg:`av_guess_sample_aspect_ratio`, and uses multiple
        heuristics to decide what is "the" sample aspect ratio.

        :type: fractions.Fraction | None
        )r(   Úav_guess_sample_aspect_ratioÚ	containerr,   r:   rB   r   r=   )r   Úsars     r   Úsample_aspect_ratiozVideoStream.sample_aspect_ratio    s@   € õ "Ô>ØŒNÔ ¤­&¬+ñ
ô 
ˆõ &¥f¤n°SÑ&9Ô&9Ñ:Ô:Ð:r   c                 óh  — t          j        t          j        ¦  «        }t          j        t          j        |j        ¦  «        t          j        |j        ¦  «        | j        j	        | j
        j        z  | j        j        | j
        j        z  d¦  «         t          t          j        |¦  «        ¦  «        S )z¼The guessed display aspect ratio (DAR) of this stream.

        This is calculated from :meth:`.VideoStream.guessed_sample_aspect_ratio`.

        :type: fractions.Fraction | None
        i   )r:   Údeclarer(   Ú
AVRationalÚ	av_reducer=   ÚnumÚdenr   r   rl   r   r   )r   Údars     r   Údisplay_aspect_ratioz VideoStream.display_aspect_ratio®   sŠ   € õ Œn�Sœ^Ñ,Ô,ˆÝŒÝŒN˜3œ7Ñ#Ô#ÝŒN˜3œ7Ñ#Ô#ØŒKÔ Ô 8Ô <Ñ<ØŒKÔ Ô!9Ô!=Ñ=Øñ	
ô 	
ð 	
õ &¥f¤n°SÑ&9Ô&9Ñ:Ô:Ð:r   r3   )FF)r"   Ú
__module__Ú__qualname__r   r$   r:   Úccallr   r*   r   r1   Úcfuncr4   r7   rU   r^   Úpropertyr`   rc   rg   rl   rt   rJ   r   r   r   r      s�  € € € € € ð
ð 
ð 
ð	1ð 	1ð 	1ð „\ðð ˜J¨Ñ-ð ð ð ñ „\ðð  „\ð	1ð 	1˜V d™]ð 	1ð 	1ð 	1ñ „\ð	1ð „\ð)ð )ñ „\ð)ð „\ð1ð 1ñ „\ð1ð(ð (ð (ð&(ð (ð (ð (ð ð	Oð 	Oñ „Xð	Oð ð
Mð 
Mñ „Xð
Mð ð;ð ;ñ „Xð;ð ð;ð ;ñ „Xð;ð ð;ð ;ñ „Xð;ð ;ð ;r   r   )r:   Úcython.cimportsr   r(   Úcython.cimports.av.packetr   Úcython.cimports.av.streamr   Úcython.cimports.av.utilsr   Úcython.cimports.av.video.framer   Úcython.cimports.libc.stdintr   Úcython.cimports.libc.stringr	   ÚfinalÚcclassr   rJ   r   r   ú<module>rƒ      sä   ðØ €€€Ø (Ð (Ð (Ð (Ð (Ð (Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø /Ð /Ð /Ð /Ð /Ð /Ø .Ð .Ð .Ð .Ð .Ð .ð „Ø„ðr;ð r;ð r;ð r;ð r;�&ñ r;ô r;ñ „ñ „ðr;ð r;ð r;r   