
    3j                         S SK Jr  S SKrS SKJr  S SKJr  S SKJ	r	   " S S\5      r
\R                  \R                   " S S	\5      5       5       r\R                  \R                   " S
 S5      5       5       rg)    )IntEnumN)libav)SideData)uint8_tc                   t    \ rS rSr\R
                  r\R                  r\R                  r
\R                  rSrg)VideoEncParamsType	    N)__name__
__module____qualname____firstlineno__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__static_attributes__r
       O/home/wildlama/miniconda3/lib/python3.13/site-packages/av/sidedata/encparams.pyr   r   	   s.    ''D

%
%C''D))Er   r   c                       \ rS rSrS r\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	 rS
 rSrg)VideoEncParams   c                 V    SU R                    SU R                   SU R                   S3$ )Nz'<av.sidedata.VideoEncParams, nb_blocks=z, codec_type=z, qp=>)	nb_blocks
codec_typeqpselfs    r   __repr__VideoEncParams.__repr__   s4    88HVZVeVeUffklplslskttuvvr   c                     [         R                  " [         R                  [        R                     U R
                  R                  5      R                  $ )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    VideoEncParams.nb_blocks   s6     {{NN3//0$((--

)	r   c                     [         R                  " [         R                  [        R                     U R
                  R                  5      R                  $ )z[
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   r0   VideoEncParams.blocks_offset"   s6    
 {{NN3//0$((--

-	r   c                     [         R                  " [         R                  [        R                     U R
                  R                  5      R                  $ )zH
Size of each block in bytes. May not match sizeof(AVVideoBlockParams).
)r(   r)   r*   r   r+   r,   r-   
block_sizer#   s    r   r3   VideoEncParams.block_size+   s6    
 {{NN3//0$((--

*	r   c                    [         R                  " [         R                  [        R                     U R
                  R                  5      R                  n[        [         R                  " [         R                  U5      5      $ )z8
Type of the parameters (the codec they are used with).
)
r(   r)   r*   r   r+   r,   r-   typer   int)r$   ts     r   r!   VideoEncParams.codec_type4   sR    
 '-kkNN3//0$((--'

$ 	
 "&++fjj!"<==r   c                     [         R                  " [         R                  [        R                     U R
                  R                  5      R                  $ )z
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"   VideoEncParams.qp>   s2     {{6>>#*>*>?ORRRr   c           	      :   [         R                  " [         R                  [        R                     U R
                  R                  5      n[        S5       VVs/ s H.  n[        S5       Vs/ s H  o1R                  U   U   PM     snPM0     snn$ s  snf s  snnf )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   r@   VideoEncParams.delta_qpH   sn     39++NN3//0$((--3
 ?DAhGh5848aAq!84hGG4Gs   B,BBBc                 X    US:  d  XR                   :  a  [        S5      e[        X5      $ )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_paramsVideoEncParams.block_paramsS   s+    
 7c^^+CDD**r   c                 N   SSK nU R                  R                  R                  S-   S-  nU R                  R                  R                  S-   S-  nX#-  n[
        R                  " [
        R                  5      u  pVnU R                  U:w  a  [        S5      e[
        R                  " [
        R                  [        R                     U R                  R                  5      R                  nU[        R                   R"                  :w  a)  U[        R                   R$                  :w  a  ['        S5      eUR)                  X#4UR*                  S9n	[-        U5       HI  n[/        X5      n
U
R0                  S-  nU
R2                  S-  nU R4                  U
R6                  -   XU4'   MK     U	$ )z
Convenience method that creates a 2-D map with the quantization parameters per macroblock.
Only for MPEG2 and H264 encoded videos.
r   N   r   z:Expected frame size to match number of blocks in side datazExpected MPEG2 or H264)dtype)numpyframer,   heightwidthr(   declarer7   r    RuntimeErrorr)   r*   r   r+   r-   r6   AVVideoEncParamsTyper   r   rF   emptyint32r?   rG   src_ysrc_xr"   r@   )r$   npmb_hmb_wnb_mb	block_idxxyr6   mapblocks              r   qp_mapVideoEncParams.qp_map]   sU   
 	 JJNN11B62= JJNN0025"< K ..4	a >>U"L  *0NN3//0$((--*

$ 	 C,,FFF00III566 hh|288h4 uI$T5Er!Ar!A%..0C1I	 & 
r   r
   N)r   r   r   r   r%   propertyr    r0   r3   r!   r"   r@   rI   rb   r   r
   r   r   r   r      s    w 	 	     > > S S H H+%r   r   c                       \ rS rSrS\S\R                  SS4S jrS r\	S 5       r
\	S	 5       r\	S
 5       r\	S 5       r\	S 5       rSrg)rG      video_enc_paramsrH   returnNc                 4   [         R                  " [         R                  [           UR                  R
                  5      nUR                  X!R                  -  -   n[         R                  " [         R                  [        R                     X4-   5      U l        g )N)
r(   r)   r*   r   r,   r-   r0   r3   r   AVVideoBlockParams)r$   rg   rH   baseoffsets        r   __init__VideoBlockParams.__init__   sn    (.NN7#%5%9%9%>%>)
 **S3N3N-NN 	 ;;v~~c.D.DEt}Ur   c                     SU R                    SU R                   SU R                   SU R                   SU R                   S3$ )Nz$<av.sidedata.VideoBlockParams, src=(z, z), size=r^   z, delta_qp=r   )rX   rW   whr@   r#   s    r   r%   VideoBlockParams.__repr__   sb    5djj\DJJ<xX\X^X^W__`aeagag`hhstx  uB  uB  tC  CD  E  	Er   c                 .    U R                   R                  $ )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,   rX   r#   s    r   rX   VideoBlockParams.src_x        xx~~r   c                 .    U R                   R                  $ )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,   rW   r#   s    r   rW   VideoBlockParams.src_y   ru   r   c                 .    U R                   R                  $ )z#
Width of the block in luma pixels
)r,   rp   r#   s    r   rp   VideoBlockParams.w       
 xxzzr   c                 .    U R                   R                  $ )z$
Height of the block in luma pixels
)r,   rq   r#   s    r   rq   VideoBlockParams.h   rz   r   c                 .    U R                   R                  $ )ze
Difference between this block's final quantization parameter and the
corresponding per-frame value.
)r,   r@   r#   s    r   r@   VideoBlockParams.delta_qp   s     xx   r   )r,   )r   r   r   r   r   r(   r7   rm   r%   rd   rX   rW   rp   rq   r@   r   r
   r   r   rG   rG      s    V Vfjj VT VE         ! !r   rG   )enumr   r(   cython.cimportsr   r   $cython.cimports.av.sidedata.sidedatar   cython.cimports.libc.stdintr   r   finalcclassr   rG   r
   r   r   <module>r      sx      ( 9 /* * pX p  pf 3! 3!  3!r   