
    ybj                         S SK Jr  S SKrS SKJr  S SKJr  \R                  \R                   " S S5      5       5       r	g)    )EAGAINN)Graph)FFmpegErrorc                   Z    \ rS rSrSr S	S jr\R                  S\S-  S\	4S j5       r
Srg)
AudioResampler	   a  AudioResampler(format=None, layout=None, rate=None, frame_size=None, options=None)

:param AudioFormat format: The target format, or string that parses to one
    (e.g. ``"s16"``).
:param AudioLayout layout: The target layout, or an int/string that parses
    to one (e.g. ``"stereo"``).
:param int rate: The target sample rate.
:param int frame_size: The number of samples per output frame.
:param dict options: ``libswresample`` options passed to the underlying
    ``aresample`` filter (e.g. ``{"resampler": "soxr", "precision": "28"}``).
    See the `FFmpeg resampler documentation
    <https://ffmpeg.org/ffmpeg-resampler.html>`_ for the full list.
Nc                    Ub'  [        U[        5      (       a  UO
[        U5      U l        Ub  [        U5      U l        U(       a  [        U5      OSU l        U(       a  [        U5      OSU l        U(       a8  UR                  5        VVs0 s H  u  pg[        U5      [        U5      _M     snnO0 U l
        S U l        g s  snnf )Nr   )
isinstanceAudioFormatformatAudioLayoutlayoutintrate
frame_sizeitemsstroptionsgraph)selfr   r   r   r   r   kvs           ڎ/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/stt/lib/python3.13/site-packages/av/audio/resampler.py	__cinit__AudioResampler.__cinit__   s     $V[99{6?R K %f-DK!%CI1	-7#j/QGN7==?C?41AA?CTV
 Ds   
!B>framereturnc                    U R                   (       d  Uc  / $ U R                  (       a  U/$ U R                   (       Gd  Xl        U R                  =(       d    UR                  U l        U R                  =(       d    UR                  U l        U R
                  =(       d    UR                  U l        UR                  R                  U R                  R                  :X  aN  UR                  U R                  :X  a4  UR                  U R
                  :X  a  U R                  S:X  a
  SU l        U/$ [        5       U l         0 nUR                  b  UR                   US'   U R                   R                  "  S
UR                   [        UR                  5      R                  UR                  R                  S.UD6nU R                   R                  SU R
                   U R                  R                  U R                  R                  S9nU R                   R                  S5      nU R                  (       aI  U R                   R                  " S0 U R                  D6nUR                  U5        UR                  U5        OUR                  U5        UR                  U5        U R                   R!                  5         U R                  S:  a%  U R                   R#                  U R                  5        Ub  UR                  R                  U R                  R                  R                  :w  dH  UR                  U R                  R                  :w  d$  UR                  U R                  R
                  :w  a  [%        S	5      eU R                   R'                  U5        / n  UR)                  U R                   R+                  5       5        M,  ! [,         a     U$ [.         a   nUR0                  [2        :w  a  e  SnAU$ SnAff = f)a?  resample(frame)

Convert the ``sample_rate``, ``channel_layout`` and/or ``format`` of
a :class:`~.AudioFrame`.

:param AudioFrame frame: The frame to convert or `None` to flush.
:returns: A list of :class:`AudioFrame` in new parameters. If the nothing is to be done return the same frame
    as a single element list.

Nr   T	time_base)sample_rate
sample_fmtchannel_layoutaformat)sample_ratessample_fmtschannel_layoutsabuffersinkz*Frame does not match AudioResampler setup.)abuffer)	aresample)r   is_passthroughtemplater   r   r   r    r!   r   r   r   addr   namer   link_to	configureset_audio_frame_size
ValueErrorpushappendpullEOFErrorr   errnor   )	r   r   
extra_argsr(   r#   r'   r)   outputes	            r   resampleAudioResampler.resample*   s    zzemI 7N zzz!M ++5DK++5DK		6U%6%6DI ''4;;+A+AALLDKK/%%2OOq(&*#w DJJ*-2__,=
;'jjnn$001&u||499$||00	
 G jjnn $		{ KK,, $ 0 0	 % G **..7K
 || JJNNG$,,G		*!!'*(OOK(JJ  ""

//@''4==+?+?+J+JJ<<4==#7#77$$(:(:: !MNN

djjoo/0      77f$s   )O 
O9	O9O44O9)r   r   r   r*   r   r   r   r+   )NNNNN)__name__
__module____qualname____firstlineno____doc__r   cythonccall
AudioFramelistr:   __static_attributes__     r   r   r   	   sB     MQ  \\aj4/ aD a arG   r   )
r6   r   rA   cython.cimports.av.filter.graphr   av.errorr   finalcclassr   rF   rG   r   <module>rL      s=      1   A A  ArG   