Ë
    ÛÍ:jŸ  ã                   óô   — d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	  G d„ de«      Z
ej                  ej                   G d„ d	e«      «       «       Zej                  ej                   G d
„ d«      «       «       Zy)é    )ÚIntEnumN)Úlibav)ÚSideData)Úuint8_tc                   ól   — e Zd Zej                  Zej                  Zej                  Z	ej                  Zy)ÚVideoEncParamsTypeN)Ú__name__Ú
__module__Ú__qualname__ÚlibÚAV_VIDEO_ENC_PARAMS_NONEÚNONEÚAV_VIDEO_ENC_PARAMS_VP9ÚVP9ÚAV_VIDEO_ENC_PARAMS_H264ÚH264ÚAV_VIDEO_ENC_PARAMS_MPEG2ÚMPEG2© ó    új/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/av/sidedata/encparams.pyr   r   	   s.   „ Ø×'Ñ'€DØ
×
%Ñ
%€CØ×'Ñ'€DØ×)Ñ)�Er   r   c                   ó~   — e Zd Zd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
d„ Zd	„ Zy
)ÚVideoEncParamsc                 óV   — d| j                   › d| j                  › d| j                  › d�S )Nz'<av.sidedata.VideoEncParams, nb_blocks=z, codec_type=z, qp=ú>)Ú	nb_blocksÚ
codec_typeÚqp©Úselfs    r   Ú__repr__zVideoEncParams.__repr__   s4   € Ø8¸¿¹Ð8HÈÐVZ×VeÑVeÐUfÐfkÐlp×lsÑlsÐktÐtuÐvÐvr   c                 ó¨   — t        j                  t         j                  t        j                     | j
                  j                  «      j                  S )zæ
        Number of blocks in the array
        May be 0, in which case no per-block information is present. In this case
        the values of blocks_offset / block_size are unspecified and should not
        be accessed.
        )ÚcythonÚcastÚpointerr   ÚAVVideoEncParamsÚptrÚdatar   r   s    r   r   zVideoEncParams.nb_blocks   s6   € ô �{‰{Ü�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó
ç
‰)ð	r   c                 ó¨   — t        j                  t         j                  t        j                     | j
                  j                  «      j                  S )zk
        Offset in bytes from the beginning of this structure at which the array of blocks starts.
        )r#   r$   r%   r   r&   r'   r(   Úblocks_offsetr   s    r   r*   zVideoEncParams.blocks_offset"   s6   € ô
 �{‰{Ü�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó
ç
‰-ð	r   c                 ó¨   — t        j                  t         j                  t        j                     | j
                  j                  «      j                  S )zX
        Size of each block in bytes. May not match sizeof(AVVideoBlockParams).
        )r#   r$   r%   r   r&   r'   r(   Ú
block_sizer   s    r   r,   zVideoEncParams.block_size+   s6   € ô
 �{‰{Ü�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó
ç
‰*ð	r   c                 ó  — t        j                  t         j                  t        j                     | j
                  j                  «      j                  }t        t        j                  t         j                  |«      «      S )zH
        Type of the parameters (the codec they are used with).
        )
r#   r$   r%   r   r&   r'   r(   Útyper   Úint)r    Úts     r   r   zVideoEncParams.codec_type4   sR   € ô
 '-§k¡kÜ�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó'
ç
‰$ð 	
ô "¤&§+¡+¬f¯j©j¸!Ó"<Ó=Ð=r   c                 ó¨   — t        j                  t         j                  t        j                     | j
                  j                  «      j                  S )a  
        Base quantisation parameter for the frame. The final quantiser for a
        given block in a given plane is obtained from this value, possibly
        combined with `delta_qp` and the per-block delta in a manner
        documented for each type.
        )r#   r$   r%   r   r&   r'   r(   r   r   s    r   r   zVideoEncParams.qp>   s2   € ô �{‰{œ6Ÿ>™>¬#×*>Ñ*>Ñ?ÀÇÁÇÁÓO×RÑRÐRr   c           	      ó.  — t        j                  t         j                  t        j                     | j
                  j                  «      }t        d«      D ��cg c]+  }t        d«      D �cg c]  }|j                  |   |   ‘Œ c}‘Œ- c}}S c c}w c c}}w )z›
        Quantisation parameter offset from the base (per-frame) qp for a given
        plane (first index) and AC/DC coefficients (second index).
        é   é   )	r#   r$   r%   r   r&   r'   r(   ÚrangeÚdelta_qp)r    ÚpÚiÚjs       r   r6   zVideoEncParams.delta_qpH   sh   € ô 39·+±+Ü�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó3
ˆô ?DÀA»h×G¸¬5°«8Ö4 a�—‘˜A‘˜qÓ!Ô4ÓGÐGùÒ4ùÓGs   ÁBÁ*BÂBÂBc                 óX   — |dk  s|| j                   k\  rt        d«      ‚t        | |«      S )z?
        Get the encoding parameters for a given block
        r   z$Expected idx in range [0, nb_blocks))r   Ú
ValueErrorÚVideoBlockParams)r    Úidxs     r   Úblock_paramszVideoEncParams.block_paramsS   s/   € ð
 �Š7�c˜TŸ^™^Ò+ÜÐCÓDÐDä  cÓ*Ð*r   c                 óP  — ddl }| j                  j                  j                  dz   dz  }| j                  j                  j                  dz   dz  }||z  }t        j                  t
        j                  «      \  }}}| j                  |k7  rt        d«      ‚t        j                  t
        j                  t        j                     | j                  j                  «      j                  }|t        j                   j"                  k7  r(|t        j                   j$                  k7  rt'        d«      ‚|j)                  ||f|j*                  ¬«      }	t-        |«      D ]J  }t/        | |«      }
|
j0                  dz  }|
j2                  dz  }| j4                  |
j6                  z   |	||f<   ŒL |	S )zœ
        Convenience method that creates a 2-D map with the quantization parameters per macroblock.
        Only for MPEG2 and H264 encoded videos.
        r   Né   é   z:Expected frame size to match number of blocks in side datazExpected MPEG2 or H264)Údtype)ÚnumpyÚframer'   ÚheightÚwidthr#   Údeclarer/   r   ÚRuntimeErrorr$   r%   r   r&   r(   r.   ÚAVVideoEncParamsTyper   r   r;   ÚemptyÚint32r5   r<   Úsrc_yÚsrc_xr   r6   )r    ÚnpÚmb_hÚmb_wÚnb_mbÚ	block_idxÚxÚyr.   ÚmapÚblocks              r   Úqp_mapzVideoEncParams.qp_map]   sd  € ó
 	à ŸJ™JŸN™N×1Ñ1°BÑ6¸2Ñ=ˆØ ŸJ™JŸN™N×0Ñ0°2Ñ5¸"Ñ<ˆØ  4™KˆÜ Ÿ.™.¬¯©Ó4‰ˆ	�1�að �>‰>˜UÒ"ÜØLóð ô *0¯©Ü�N‰Nœ3×/Ñ/Ñ0°$·(±(·-±-ó*
ç
‰$ð 	ð ”C×,Ñ,×FÑFÒFØœ×0Ñ0×IÑIÒIäÐ5Ó6Ð6ð �h‰h˜˜d�|¨2¯8©8ˆhÓ4ˆô ˜u›ò 	1ˆIÜ$ T¨9Ó5ˆEØ—‘˜rÑ!ˆAØ—‘˜rÑ!ˆAØŸ™ %§.¡.Ñ0ˆC��1�ŠIð		1ð ˆ
r   N)r	   r
   r   r!   Úpropertyr   r*   r,   r   r   r6   r>   rW   r   r   r   r   r      sŽ   „ òwð ñ	ó ð	ð ñó ðð ñó ðð ñ>ó ð>ð ñSó ðSð ñHó ðHò+ó%r   r   c                   óŠ   — e Zd Zdedej
                  ddfd„Zd„ Zed„ «       Z	ed„ «       Z
ed	„ «       Zed
„ «       Zed„ «       Zy)r<   Úvideo_enc_paramsr=   ÚreturnNc                 ó4  — t        j                  t         j                  t           |j                  j
                  «      }|j                  ||j                  z  z   }t        j                  t         j                  t        j                     ||z   «      | _        y )N)
r#   r$   r%   r   r'   r(   r*   r,   r   ÚAVVideoBlockParams)r    rZ   r=   ÚbaseÚoffsets        r   Ú__init__zVideoBlockParams.__init__ˆ   ss   € Ü(.¯©Ü�N‰Nœ7Ñ#Ð%5×%9Ñ%9×%>Ñ%>ó)
ˆð ×*Ñ*¨SÐ3C×3NÑ3NÑ-NÑNð 	ô —;‘;œvŸ~™~¬c×.DÑ.DÑEÀtÈfÁ}ÓUˆ�r   c                 óŠ   — d| j                   › d| j                  › d| j                  › d| j                  › d| j                  › d�S )Nz$<av.sidedata.VideoBlockParams, src=(z, z), size=rS   z, delta_qp=r   )rM   rL   ÚwÚhr6   r   s    r   r!   zVideoBlockParams.__repr__‘   sb   € Ø5°d·j±j°\ÀÀDÇJÁJÀ<ÈxÐX\×X^ÑX^ÐW_Ð_`Ðae×agÑagÐ`hÐhsÐtx÷  uBñ  uBð  tCð  CDð  Eð  	Er   c                 ó.   — | j                   j                  S )zÛ
        Horizontal distance in luma pixels from the top-left corner of the visible frame
        to the top-left corner of the block.
        Can be negative if top/right padding is present on the coded frame.
        )r'   rM   r   s    r   rM   zVideoBlockParams.src_x”   ó   € ð �x‰x�~‰~Ðr   c                 ó.   — | j                   j                  S )zÙ
        Vertical distance in luma pixels from the top-left corner of the visible frame
        to the top-left corner of the block.
        Can be negative if top/right padding is present on the coded frame.
        )r'   rL   r   s    r   rL   zVideoBlockParams.src_y�   re   r   c                 ó.   — | j                   j                  S )z3
        Width of the block in luma pixels
        )r'   rb   r   s    r   rb   zVideoBlockParams.w¦   ó   € ð
 �x‰x�z‰zÐr   c                 ó.   — | j                   j                  S )z4
        Height of the block in luma pixels
        )r'   rc   r   s    r   rc   zVideoBlockParams.h­   rh   r   c                 ó.   — | j                   j                  S )z}
        Difference between this block's final quantization parameter and the
        corresponding per-frame value.
        )r'   r6   r   s    r   r6   zVideoBlockParams.delta_qp´   s   € ð �x‰x× Ñ Ð r   )r	   r
   r   r   r#   r/   r`   r!   rX   rM   rL   rb   rc   r6   r   r   r   r<   r<   …   sŽ   „ ðV¨ð V¸f¿j¹jð VÈTó VòEð ñó ðð ñó ðð ñó ðð ñó ðð ñ!ó ñ!r   r<   )Úenumr   r#   Úcython.cimportsr   r   Ú$cython.cimports.av.sidedata.sidedatar   Úcython.cimports.libc.stdintr   r   ÚfinalÚcclassr   r<   r   r   r   ú<module>rq      sx   ðÝ ã Ý (Ý 9Ý /ô*˜ô *ð ‡�Ø‡�ôp�Xó pó ó ðpðf ‡�Ø‡�÷3!ð 3!ó ó ñ3!r   