国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ffmpeg enum AVChannel枚舉解析

這篇具有很好參考價值的文章主要介紹了ffmpeg enum AVChannel枚舉解析。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

AVChannel枚舉是在2022-12-20的提交中添加的,對應的版本號是5.1.
這個提交的描述是"avutil/channel_layout: add AVChannel enum and related
functions"。

原型

typedef struct AVChannelCustom {
    enum AVChannel id;
    char name[16];
    void *opaque;
} AVChannelCustom;

enum AVChannel {
    ///< Invalid channel index
    AV_CHAN_NONE = -1,
    AV_CHAN_FRONT_LEFT,
    AV_CHAN_FRONT_RIGHT,
    AV_CHAN_FRONT_CENTER,
    AV_CHAN_LOW_FREQUENCY,
    AV_CHAN_BACK_LEFT,
    AV_CHAN_BACK_RIGHT,
    AV_CHAN_FRONT_LEFT_OF_CENTER,
    AV_CHAN_FRONT_RIGHT_OF_CENTER,
    AV_CHAN_BACK_CENTER,
    AV_CHAN_SIDE_LEFT,
    AV_CHAN_SIDE_RIGHT,
    AV_CHAN_TOP_CENTER,
    AV_CHAN_TOP_FRONT_LEFT,
    AV_CHAN_TOP_FRONT_CENTER,
    AV_CHAN_TOP_FRONT_RIGHT,
    AV_CHAN_TOP_BACK_LEFT,
    AV_CHAN_TOP_BACK_CENTER,
    AV_CHAN_TOP_BACK_RIGHT,
    /** Stereo downmix. */
    AV_CHAN_STEREO_LEFT = 29,
    /** See above. */
    AV_CHAN_STEREO_RIGHT,
    AV_CHAN_WIDE_LEFT,
    AV_CHAN_WIDE_RIGHT,
    AV_CHAN_SURROUND_DIRECT_LEFT,
    AV_CHAN_SURROUND_DIRECT_RIGHT,
    AV_CHAN_LOW_FREQUENCY_2,
    AV_CHAN_TOP_SIDE_LEFT,
    AV_CHAN_TOP_SIDE_RIGHT,
    AV_CHAN_BOTTOM_FRONT_CENTER,
    AV_CHAN_BOTTOM_FRONT_LEFT,
    AV_CHAN_BOTTOM_FRONT_RIGHT,

    /** Channel is empty can be safely skipped. */
    AV_CHAN_UNUSED = 0x200,

    /** Channel contains data, but its position is unknown. */
    AV_CHAN_UNKNOWN = 0x300,

    /**
     * Range of channels between AV_CHAN_AMBISONIC_BASE and
     * AV_CHAN_AMBISONIC_END represent Ambisonic components using the ACN system.
     *
     * Given a channel id <i> between AV_CHAN_AMBISONIC_BASE and
     * AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel <n> is
     * <n> = <i> - AV_CHAN_AMBISONIC_BASE.
     *
     * @note these values are only used for AV_CHANNEL_ORDER_CUSTOM channel
     * orderings, the AV_CHANNEL_ORDER_AMBISONIC ordering orders the channels
     * implicitly by their position in the stream.
     */
    AV_CHAN_AMBISONIC_BASE = 0x400,
    // leave space for 1024 ids, which correspond to maximum order-32 harmonics,
    // which should be enough for the foreseeable use cases
    AV_CHAN_AMBISONIC_END  = 0x7ff,
};

描述

AVChannel 是一個枚舉類型,用于表示音頻數(shù)據(jù)的各個聲道。在音頻數(shù)據(jù)中,一個“聲道”是一個獨立的音頻信號,它可以被獨立處理和播放。例如,在立體聲音頻中,有兩個聲道:左聲道和右聲道。

這個枚舉中的每個值都代表一個特定的聲道。例如,AV_CHAN_FRONT_LEFT 代表前左聲道,AV_CHAN_FRONT_RIGHT 代表前右聲道,等等。這些值可以用于處理具有特定聲道布局的音頻數(shù)據(jù)。

以下是一些特殊的枚舉值的解釋:

  • AV_CHAN_NONE:無效的聲道索引。
  • AV_CHAN_STEREO_LEFTAV_CHAN_STEREO_RIGHT:立體聲混音的左聲道和右聲道。
  • AV_CHAN_UNUSED:聲道是空的,可以安全地跳過。
  • AV_CHAN_UNKNOWN:聲道包含數(shù)據(jù),但其位置未知。
  • AV_CHAN_AMBISONIC_BASEAV_CHAN_AMBISONIC_END:表示使用 ACN 系統(tǒng)的 Ambisonic 組件的聲道范圍。Ambisonics 是一種全方位的聲音錄制和再現(xiàn)技術,可以捕捉和再現(xiàn)聲音場的三維空間信息。

請注意,這個枚舉的具體值可能會根據(jù)你使用的 FFmpeg 版本和 API 而有所不同。你應該查閱你正在使用的 FFmpeg 版本和 API 的文檔,以獲取最準確的信息。


相關輸出接口

/**
 * Get the channel with the given index in a channel layout.
 *
 * @param channel_layout input channel layout
 * @return channel with the index idx in channel_layout on success or
 *         AV_CHAN_NONE on failure (if idx is not valid or the channel order is
 *         unspecified)
 */
enum AVChannel
av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx);
/**
 * Get a channel described by the given string.
 *
 * This function accepts channel names in the same format as
 * @ref av_channel_from_string().
 *
 * @param channel_layout input channel layout
 * @return a channel described by the given string in channel_layout on success
 *         or AV_CHAN_NONE on failure (if the string is not valid or the channel
 *         order is unspecified)
 */
enum AVChannel
av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout,
                                      const char *name);

/**
 * This is the inverse function of @ref av_channel_name().
 *
 * @return the channel with the given name
 *         AV_CHAN_NONE when name does not identify a known channel
 */
enum AVChannel av_channel_from_string(const char *name);

這些函數(shù)都是用來從不同的輸入獲取 AVChannel 枚舉類型的。下面是每個函數(shù)的簡單解釋和示例:

  1. av_channel_layout_channel_from_string:這個函數(shù)從給定的聲道布局中獲取由給定字符串描述的聲道。例如:
const AVChannelLayout *layout = codec_ctx_->channel_layout;
const char *name = "FL"; // Front Left
AVChannel channel = av_channel_layout_channel_from_string(layout, name);
  1. av_channel_layout_channel_from_index:這個函數(shù)從給定的聲道布局中獲取給定索引的聲道。例如:
const AVChannelLayout *layout = codec_ctx_->channel_layout;
unsigned int idx = 0; // Index of the channel
AVChannel channel = av_channel_layout_channel_from_index(layout, idx);
  1. av_channel_from_string:這個函數(shù)獲取給定名稱的聲道。例如:
const char *name = "FL"; // Front Left
AVChannel channel = av_channel_from_string(name);

請注意,這些函數(shù)都可能返回 AV_CHAN_NONE,這表示輸入無效,或者聲道順序未指定。在使用這些函數(shù)時,你應該檢查返回值是否為 AV_CHAN_NONE

相關輸入接口

/**
 * Get a human readable string in an abbreviated form describing a given channel.
 * This is the inverse function of @ref av_channel_from_string().
 *
 * @param buf pre-allocated buffer where to put the generated string
 * @param buf_size size in bytes of the buffer.
 * @return amount of bytes needed to hold the output string, or a negative AVERROR
 *         on failure. If the returned value is bigger than buf_size, then the
 *         string was truncated.
 */
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel);

/**
 * bprint variant of av_channel_name().
 *
 * @note the string will be appended to the bprint buffer.
 */
void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id);

/**
 * Get a human readable string describing a given channel.
 *
 * @param buf pre-allocated buffer where to put the generated string
 * @param buf_size size in bytes of the buffer.
 * @return amount of bytes needed to hold the output string, or a negative AVERROR
 *         on failure. If the returned value is bigger than buf_size, then the
 *         string was truncated.
 */
int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel);

/**
 * bprint variant of av_channel_description().
 *
 * @note the string will be appended to the bprint buffer.
 */
void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_id);
/**
 * Get the index of a given channel in a channel layout. In case multiple
 * channels are found, only the first match will be returned.
 *
 * @param channel_layout input channel layout
 * @return index of channel in channel_layout on success or a negative number if
 *         channel is not present in channel_layout.
 */
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout,
                                         enum AVChannel channel);


這些函數(shù)都是用來獲取 AVChannel 枚舉值的描述的。下面是每個函數(shù)的簡單解釋和示例:

  1. av_channel_name:這個函數(shù)獲取給定聲道的簡短描述。例如:
char buf[256];
AVChannel channel = AV_CHAN_FRONT_LEFT;
int ret = av_channel_name(buf, sizeof(buf), channel);
if (ret < 0) {
    // Handle error
} else {
    printf("Channel name: %s\n", buf);
}
  1. av_channel_name_bprint:這個函數(shù)是 av_channel_name 的 bprint 變體,它將字符串追加到 bprint 緩沖區(qū)。例如:
AVBPrint bp;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
AVChannel channel = AV_CHAN_FRONT_LEFT;
av_channel_name_bprint(&bp, channel);
printf("Channel name: %s\n", bp.str);
av_bprint_finalize(&bp, NULL);
  1. av_channel_description:這個函數(shù)獲取給定聲道的詳細描述。例如:
char buf[256];
AVChannel channel = AV_CHAN_FRONT_LEFT;
int ret = av_channel_description(buf, sizeof(buf), channel);
if (ret < 0) {
    // Handle error
} else {
    printf("Channel description: %s\n", buf);
}
  1. av_channel_description_bprint:這個函數(shù)是 av_channel_description 的 bprint 變體,它將字符串追加到 bprint 緩沖區(qū)。例如:
AVBPrint bp;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
AVChannel channel = AV_CHAN_FRONT_LEFT;
av_channel_description_bprint(&bp, channel);
printf("Channel description: %s\n", bp.str);
av_bprint_finalize(&bp, NULL);

請注意,這些函數(shù)都可能返回錯誤。在使用這些函數(shù)時,你應該檢查返回值是否為負數(shù),如果是,那么說明發(fā)生了錯誤。
5. av_channel_layout_index_from_channel 函數(shù)用于獲取給定聲道在聲道布局中的索引。如果在聲道布局中找到多個相同的聲道,只會返回第一個匹配的索引。

這個函數(shù)接受兩個參數(shù):

  1. channel_layout:輸入的聲道布局。
  2. channel:要查找的聲道。

如果聲道在聲道布局中存在,函數(shù)會返回聲道的索引;如果聲道在聲道布局中不存在,函數(shù)會返回一個負數(shù)。

以下是一個使用示例:

const AVChannelLayout *layout = codec_ctx_->channel_layout;
AVChannel channel = AV_CHAN_FRONT_LEFT;
int index = av_channel_layout_index_from_channel(layout, channel);
if (index < 0) {
    printf("Channel is not present in the layout\n");
} else {
    printf("Index of the channel in the layout: %d\n", index);
}

在這個示例中,我們首先獲取編解碼器上下文的聲道布局,然后定義我們要查找的聲道(在這個例子中是前左聲道)。然后,我們調用 av_channel_layout_index_from_channel 函數(shù)來獲取聲道在聲道布局中的索引。如果索引是負數(shù),那么聲道在聲道布局中不存在;否則,我們打印出聲道在聲道布局中的索引。

應用場景

FFmpeg 是一個非常靈活的庫,它允許你以多種方式處理音頻和視頻數(shù)據(jù)。這種靈活性的一個結果是,很多函數(shù)需要你手動指定參數(shù),而不是自動從結構體中獲取信息。這是因為在不同的上下文中,你可能需要以不同的方式處理數(shù)據(jù)。

例如,av_channel_layout_channel_from_stringav_channel_layout_channel_from_index 函數(shù)允許你從一個聲道布局中獲取一個特定的聲道。你需要手動指定聲道的名稱或索引,因為 FFmpeg 不知道你想獲取哪個聲道。你可能想獲取前左聲道,也可能想獲取前右聲道,或者其他任何聲道。FFmpeg 提供了這些函數(shù),讓你可以根據(jù)你的需要獲取任何聲道。

同樣,av_channel_from_string 函數(shù)允許你獲取一個給定名稱的聲道。你需要手動指定聲道的名稱,因為 FFmpeg 不知道你想獲取哪個聲道。你可能想獲取 “FL”(前左)聲道,也可能想獲取 “FR”(前右)聲道,或者其他任何聲道。FFmpeg 提供了這個函數(shù),讓你可以根據(jù)你的需要獲取任何聲道。

雖然這些函數(shù)需要你手動指定參數(shù),但這并不意味著代碼的兼容性不強。相反,這種設計使得你的代碼可以在不同的上下文中工作,只要你正確地指定了參數(shù)。如果你想寫更通用的代碼,你可以編寫一個函數(shù),它接受一個 FFmpeg 結構體作為參數(shù),然后從這個結構體中獲取所需的信息,然后調用這些 FFmpeg 函數(shù)。文章來源地址http://www.zghlxwxcb.cn/news/detail-508843.html

到了這里,關于ffmpeg enum AVChannel枚舉解析的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 【C++】枚舉enum使用詳解

    目錄 一.什么是枚舉enum(WHAT) 二.使用枚舉enum的場景(WHEN and WHERE) 三.如何使用枚舉enum(HOW) 1)枚舉的定義 2)枚舉的初始化 3)指定枚舉類型? 4)聲明枚舉對象 5)枚舉對象賦值問題 6)枚舉的取值范圍 四.枚舉enum的應用 枚舉(enumeration)和類相似,能夠定義一種新的數(shù)據(jù)類型,不同的

    2024年02月15日
    瀏覽(21)
  • C語言中enum(枚舉)詳解

    enum 是 enumerate(列舉,枚舉)一詞的縮寫,是 C 語言中的一種 常量 ,被稱為 enumeration constant 。 enum 提供了一種很方便的方法來將值和名稱關聯(lián)起來,是 #define 的一種替代方法。 enum 可以看作是一種特殊的數(shù)組,是 常量組成的列表 ,而且這個常量只能是整數(shù)型。 所以如果是

    2024年02月13日
    瀏覽(24)
  • 【golang】每日chatGPT:golang中實現(xiàn)ENUM枚舉類型 | go enum

    在golang極簡的哲學思想中,沒有內置枚舉類型 這里我們通過map+iota去實現(xiàn)一個枚舉類型 枚舉值如下: key value 1 發(fā)電類 2 儲能類 13 負荷類 打印如下: 發(fā)電類 儲能類 負荷類 ========= 儲能類

    2024年02月15日
    瀏覽(20)
  • C語言學習筆記:枚舉(enum)

    ?博文作者:煙雨孤舟 ?? 喜歡的可以 點贊 收藏 關注哦~~ ?? 作者簡介: 一個熱愛大數(shù)據(jù)的學習者 ?? 筆記簡介:作為大數(shù)據(jù)愛好者,以下是個人總結的學習筆記,如有錯誤,請多多指教! 目錄 簡介 枚舉定義 枚舉變量的定義 枚舉的應用 枚舉enum是英文enumerate的縮寫,列

    2024年02月09日
    瀏覽(30)
  • C語言枚舉類型enum(全面詳細直觀)

    C語言枚舉類型enum(全面詳細直觀)

    維基百科的理解: 枚舉類型用于聲明一組命名的常數(shù),當一個變量有幾種可能的取值時,可以將它定義為枚舉類型。 定義:是指將變量的值一一列出來,變量的值只限于列舉出來的值的范圍內。 我的理解: 枚舉類型就是將一些比較固定的值一一列舉出來 ,比如一年有十二個

    2024年02月06日
    瀏覽(17)
  • 【C程序設計】C enum(枚舉)

    枚舉是 C 語言中的一種基本數(shù)據(jù)類型,用于定義一組具有離散值的常量,它可以讓數(shù)據(jù)更簡潔,更易讀。 枚舉類型通常用于為程序中的一組相關的常量取名字,以便于程序的可讀性和維護性。 定義一個枚舉類型,需要使用?enum?,后面跟著枚舉類型的名稱,以及用大括

    2024年01月23日
    瀏覽(20)
  • C# 枚舉使用整理_C# enum詳解

    一、枚舉的定義 枚舉類型 是由基礎 整型數(shù)值類型 的一組命名常量定義的 值類型 。 System.Enum 類型是所有枚舉類型的抽象基類。 它提供多種方法來獲取有關枚舉類型及其值的信息。 有關更多信息和示例,請參閱 System.Enum API 參考頁。 可在基類約束中使用 System.Enum(稱為枚舉

    2024年02月16日
    瀏覽(18)
  • 虛幻C++中的細節(jié)之枚舉類型(enum)

    虛幻引擎中的代碼部分實現(xiàn)了一套反射機制,為c++代碼帶了更多方便的特性。本篇文章將會著眼于其中更加細節(jié)的部分——虛幻中的enum。 在虛幻風格的代碼中,我們經(jīng)常能使用這樣的方法來創(chuàng)建枚舉類型: 似乎有一些c++的影子,但又好像有一些不一樣的部分。它有基本c++的

    2024年02月02日
    瀏覽(17)
  • C#,入門教程(66)——枚舉Enum的高等用法

    C#,入門教程(66)——枚舉Enum的高等用法

    前言:國內碼農(nóng)與國外優(yōu)秀程序員的最大區(qū)別是,我們的專家、教授喜歡唾沫橫飛地,夸夸其談語言特性、框架、性能,唯一目的是帶私貨(書籍或教程),很少能寫出真有用的程序。差距在哪呢?基礎!基礎!基礎! 枚舉enum是常用的數(shù)據(jù)類型,有很多優(yōu)點。 枚舉使用過程

    2024年01月17日
    瀏覽(20)
  • Java中枚舉類enum的values()方法的詳解

    Java中枚舉類enum的values()方法的詳解

    簡介: 枚舉中的一個特殊方法,values(), 在Enum 的 API 文檔中也找不到這個方法,當點擊values()時,也會跳到本類上。 此方法可以理解為:將枚舉類轉變?yōu)橐粋€枚舉類型的數(shù)組,因為枚舉中沒有下標,我們沒有辦法通過下標來快速找到需要的枚舉類,這時候,轉變?yōu)閿?shù)組之后,

    2024年02月14日
    瀏覽(18)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包