o
    ]i                     @   sd   U d dl Z d dlZe jdkrdndZeed< e Zejde	j
defdd	ZejG d
d dZdS )    Nlittlelebecontainer_format_postfixc_formatreturnc                 C   s   | dk rdS t t}| |_|S )z2Get an AudioFormat without going through a string.r   N)AudioFormat_cinit_bypass_sentinel
sample_fmt)r   format r   C/home/ubuntu/.local/lib/python3.10/site-packages/av/audio/format.pyget_audio_format	   s
   r   c                   @   s   e Zd ZdZdd Zdd Zedd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd ZdS )r   zDescriptor of audio formats.c                 C   sP   |t u rd S t|trtt|j}nt|}|dk r#td||| _d S )Nr   zNot a sample format: )	r	   
isinstancer   cythoncastr
   libav_get_sample_fmt
ValueError)selfnamer
   r   r   r   	__cinit__   s   


zAudioFormat.__cinit__c                 C   s   d| j  dS )Nz<av.AudioFormat >)r   r   r   r   r   __repr__(   s   zAudioFormat.__repr__c                 C      t | jS )zcCanonical name of the sample format.

        >>> AudioFormat('s16p').name
        's16p'

        )r   av_get_sample_fmt_namer
   r   r   r   r   r   +      zAudioFormat.namec                 C   r   )zVNumber of bytes per sample.

        >>> AudioFormat('s16p').bytes
        2

        r   av_get_bytes_per_sampler
   r   r   r   r   bytes5   r   zAudioFormat.bytesc                 C   s   t | jd> S )zUNumber of bits per sample.

        >>> AudioFormat('s16p').bits
        16

           r   r   r   r   r   bits?   s   zAudioFormat.bitsc                 C   s   t t| jS )zSIs this a planar format?

        Strictly opposite of :attr:`is_packed`.

        )boolr   av_sample_fmt_is_planarr
   r   r   r   r   	is_planarI   s   zAudioFormat.is_planarc                 C   s   t | j S )zSIs this a packed format?

        Strictly opposite of :attr:`is_planar`.

        )r   r$   r
   r   r   r   r   	is_packedR   s   zAudioFormat.is_packedc                 C      | j r| S tt| jS )zThe planar variant of this format.

        Is itself when planar:

        >>> fmt = AudioFormat('s16p')
        >>> fmt.planar is fmt
        True

        )r%   r   r   av_get_planar_sample_fmtr
   r   r   r   r   planar[      zAudioFormat.planarc                 C   r'   )zThe packed variant of this format.

        Is itself when packed:

        >>> fmt = AudioFormat('s16')
        >>> fmt.packed is fmt
        True

        )r&   r   r   av_get_packed_sample_fmtr
   r   r   r   r   packedj   r*   zAudioFormat.packedc                 C   sv   | j rtd| jtjkrdS | jtjkrdt S | jtjkr#dt S | jtjkr-dt S | jtj	kr7dt S td)zThe name of a :class:`ContainerFormat` which directly accepts this data.

        :raises ValueError: when planar, since there are no such containers.

        zno planar container formatsu8s16s32f32f64zunknown layout)
r%   r   r
   r   AV_SAMPLE_FMT_U8AV_SAMPLE_FMT_S16r   AV_SAMPLE_FMT_S32AV_SAMPLE_FMT_FLTAV_SAMPLE_FMT_DBLr   r   r   r   container_namey   s   zAudioFormat.container_nameN)__name__
__module____qualname____doc__r   r   propertyr   r    r"   r%   r&   r)   r,   r7   r   r   r   r   r      s(    
	
	
	



r   )sysr   	byteorderr   str__annotations__objectr	   cfuncr   AVSampleFormatr   r   cclassr   r   r   r   <module>   s   
 