
    m i'                     r    d dl mZ d dlZd dlmZ d dlmZ d dlmZ ej	         G d d                      Z
dS )    )EAGAINN)FilterContext)Graph)FFmpegErrorc                   J    e Zd ZdZddZej        dedz  defd            Z	dS )AudioResampleraB  AudioResampler(format=None, layout=None, rate=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.
    Nc                     |+t          |t                    r|nt          |          | _        |t          |          | _        |rt          |          nd| _        |rt          |          nd| _        d | _        d S )Nr   )	
isinstanceAudioFormatformatAudioLayoutlayoutintrate
frame_sizegraph)selfr   r   r   r   s        R/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/av/audio/resampler.py	__cinit__zAudioResampler.__cinit__   s{    $V[99R{6?R?R K %f--DK!%,CIII1	-7>#j///Q


    framereturnc                 X   | j         s|g S | j        r|gS | j         s|| _        | j        p|j        | _        | j        p|j        | _        | j        p|j        | _        |j        j        | j        j        k    r5|j        | j        k    r%|j        | j        k    r| j        dk    r
d| _        |gS t                      | _         i }|j
        |j
         |d<    | j         j        	 d|j         t          |j                  j        |j        j        d|}| j                             d| j         | j        j        | j        j                  }| j                             d	          }|                    |           |                    |           | j                                          | j        dk    r| j                             | j                   |X|j        j        | j        j        j        k    s*|j        | j        j        k    s|j        | j        j        k    rt#          d
          | j                             |           g }	 	 |                    | j                                                    n3# t*          $ r Y n(t,          $ r}|j        t0          k    r Y d}~n	d}~ww xY wb|S )ao  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abuffer)sample_rate
sample_fmtchannel_layoutaformat)sample_ratessample_fmtschannel_layoutsabuffersinkz*Frame does not match AudioResampler setup.)r   )r   is_passthroughtemplater   r   r   r   r   r   r   r   addr   namelink_to	configureset_audio_frame_size
ValueErrorpushappendpullEOFErrorr   errnor   )r   r   
extra_argsr   r   r#   outputes           r   resamplezAudioResampler.resample"   s    z 	emI  	7N z ,	A!DM +5DK+5DK	6U%6DI '4;+AAALDK//%22Oq((&*#w DJJ*-2_*>
;'$djn$02&u|449$|0	 
  G jnn $	^ K, $ 0	 %  G *..77KOOG$$$OOK(((J  """""
//@@@'4=+?+JJJ<4=#777$(::: !MNNN
	djoo//0000      7f$$	 s   	,I6 6
J&	J&J!!J&)NNNN)
__name__
__module____qualname____doc__r   cythonccall
AudioFramelistr4    r   r   r   r   
   so             \Wj4/ WD W W W \W W Wr   r   )r0   r   r9   !cython.cimports.av.filter.contextr   cython.cimports.av.filter.graphr   av.errorr   cclassr   r=   r   r   <module>rB      s           ; ; ; ; ; ; 1 1 1 1 1 1             o o o o o o o o o or   