
    ybj                         % S SK Jr  S SKJr  S SKrS SKJr  Sr\R                  \
S'   \R                   " S S5      5       r\R                  S	\R                  S
\4S j5       r\R                  " \5        g)    )Fraction)RationalN)libavi
_INT32_MAXc                       \ rS rSrSrSS jr\R                  S\R                  4S j5       r
\S 5       r\S 5       rS rS	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!Sr"g)
AVRational   uF  
An exact rational number stored as two int32s, mirroring FFmpeg's
``AVRational``.

Values are always reduced to lowest terms with a positive denominator.
Arithmetic between two :class:`AVRational` uses FFmpeg's ``av_mul_q``
family: intermediates are computed in int64, then reduced back to int32,
**approximating** the result if it does not fit. Arithmetic with other
numeric types promotes to :class:`fractions.Fraction` (exact).

Following FFmpeg, a zero denominator is allowed: ``1/0``, ``-1/0``
(infinities) and ``0/0`` (undefined) exist and, like the unset value
``AVRational(0, 1)``, are falsy — so ``if rate:`` covers every
not-a-real-value case that used to be ``None``.

Every PyAV setter that accepts a :class:`fractions.Fraction` (e.g.
``stream.time_base``, ``codec_context.framerate``) also accepts an
:class:`AVRational`.
c                 >   US:X  a,  [        U[        5      (       a  UR                  UR                  p!UnUn[        R
                  " [        R                  " W5      [        R                  " W5      X4[        5      (       d  [        U SU S35      eXPl
        X`l        g )N   /z" cannot be reduced to fit in int32)
isinstancer   	numeratordenominatorlib	av_reducecythonaddressr   OverflowErrornumden)selfr   r   n64d64nds          ڇ/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/stt/lib/python3.13/site-packages/av/rational.py__init__AVRational.__init__!   s    !8
311}}coo"" }}NN1v~~a0#J
 
  3%q-O PQQ    returnc                 J    U R                   Wl         U R                  Ul        U$ Nr   r   )r   qs     r   _qAVRational._q/   s     r   c                     U R                   $ r"   )r   r   s    r   r   AVRational.numerator6       xxr   c                     U R                   $ r"   )r   r(   s    r   r   AVRational.denominator:   r*   r   c                 <    SU R                    SU R                   S3$ )NzAVRational(z, )r#   r(   s    r   __repr__AVRational.__repr__>   s    TXXJb
!44r   c                 8    U R                    SU R                   3$ )Nr   r#   r(   s    r   __str__AVRational.__str__A   s    ((1TXXJ''r   c                 L    U R                   S:g  =(       a    U R                  S:g  $ Nr   r#   r(   s    r   __bool__AVRational.__bool__D   s    xx1}.Q.r   c                     U R                   S:X  a3  U R                  S:X  a  [        S5      $ U R                  [        S5      -  $ U R                  U R                   -  $ )Nr   naninf)r   r   floatr(   s    r   	__float__AVRational.__float__G   sF    88q=#'88q=5<Mdhhu6MMxx$((""r   c                     U R                   S:X  a  [        U R                  S45      $ [        [        U R                  U R                   5      5      $ r5   )r   hashr   r   r(   s    r   __hash__AVRational.__hash__L   s:    88q=1&&HTXXtxx011r   c                 >    [         U R                  U R                  44$ r"   r   r   r   r(   s    r   
__reduce__AVRational.__reduce__Q   s    TXXtxx011r   c                 
   [        U[        5      (       a;  UnU R                  UR                  :H  =(       a    U R                  UR                  :H  $ U R                  S:X  a  g[	        U R                  U R                  5      U:H  $ )Nr   F)r   r   r   r   r   r   otheros      r   __eq__AVRational.__eq__T   sa    eZ((!A88quu$:QUU)::88q=$((+u44r   c                 H    [        U R                  U R                  5      U:  $ r"   r   r   r   r   rH   s     r   __lt__AVRational.__lt__\       $((+e33r   c                 H    [        U R                  U R                  5      U:*  $ r"   rM   rN   s     r   __le__AVRational.__le___       $((+u44r   c                 H    [        U R                  U R                  5      U:  $ r"   rM   rN   s     r   __gt__AVRational.__gt__b   rQ   r   c                 H    [        U R                  U R                  5      U:  $ r"   rM   rN   s     r   __ge__AVRational.__ge__e   rU   r   c                 D    [        U R                  * U R                  5      $ r"   rC   r(   s    r   __neg__AVRational.__neg__h   s    488)TXX..r   c                     [        U[        5      (       a>  Un[        [        R                  " U R                  5       UR                  5       5      5      $ [        U R                  U R                  5      U-  $ r"   )	r   r   from_avrationalr   av_mul_qr%   r   r   r   rG   s      r   __mul__AVRational.__mul__k   P    eZ((!A"3<<	1446#BCC$((+e33r   c                 H    U[        U R                  U R                  5      -  $ r"   rM   rN   s     r   __rmul__AVRational.__rmul__q       x$((333r   c                 .   [        U[        5      (       a^  UnUR                  S:X  a  [        U  SU 35      e[	        [
        R                  " U R                  5       UR                  5       5      5      $ [        U R                  U R                  5      U-  $ )Nr   z / )
r   r   r   ZeroDivisionErrorr`   r   av_div_qr%   r   r   rG   s      r   __truediv__AVRational.__truediv__t   sq    eZ((!Auuz'4&E7(;<<"3<<	1446#BCC$((+e33r   c                 H    U[        U R                  U R                  5      -  $ r"   rM   rN   s     r   __rtruediv__AVRational.__rtruediv__|   rh   r   c                     [        U[        5      (       a>  Un[        [        R                  " U R                  5       UR                  5       5      5      $ [        U R                  U R                  5      U-   $ r"   )	r   r   r`   r   av_add_qr%   r   r   r   rG   s      r   __add__AVRational.__add__   rd   r   c                 H    U[        U R                  U R                  5      -   $ r"   rM   rN   s     r   __radd__AVRational.__radd__   rh   r   c                     [        U[        5      (       a>  Un[        [        R                  " U R                  5       UR                  5       5      5      $ [        U R                  U R                  5      U-
  $ r"   )	r   r   r`   r   av_sub_qr%   r   r   r   rG   s      r   __sub__AVRational.__sub__   rd   r   c                 H    U[        U R                  U R                  5      -
  $ r"   rM   rN   s     r   __rsub__AVRational.__rsub__   rh   r   )r   r   N)r   r   )#__name__
__module____qualname____firstlineno____doc__r   r   cfuncr   r   r%   propertyr   r   r/   r2   r6   r<   r@   rD   rJ   rO   rS   rW   rZ   r]   rb   rf   rl   ro   rs   rv   rz   r}   __static_attributes__ r   r   r   r      s    ( \\CNN      5(/#
2
254545/44444444r   r   r$   r    c                    [         R                  [         5      n[        R                  " [        R
                  " UR                  5      [        R
                  " UR                  5      U R                  U R                  [        5        U$ r"   )	r   __new__r   r   r   r   r   r   r   )r$   objs     r   r`   r`      sR     ((4CMMsww!8!%%
 Jr   )	fractionsr   numbersr   r   cython.cimportsr   r   r   longlong__annotations__cclassr   r   r`   registerr   r   r   <module>r      sz       ((
FOO ( C4 C4 C4L s~~ *   	  * r   