📄 chan.c
字号:
/******************************************************************************* chan.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2007 Members of the libquicktime project. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*******************************************************************************/ #include "lqt_private.h"#include <stdlib.h>/* * Quicktime chan atom. * * I didn't find any official documentation about the channel * description atom (which is needed for multichannel support). * There is, however this document about the CAF format by Apple: * * http://developer.apple.com/documentation/MusicAudio/Reference/CAFSpec/index.html * The guess was, that the chan atoms in CAF and Quicktime files are the same, * and the guess turned out to be true :) */typedef enum { CHANNEL_LABEL_Unknown = 0xFFFFFFFF, // unknown role or uspecified // other use for channel CHANNEL_LABEL_Unused = 0, // channel is present, but // has no intended role or destination CHANNEL_LABEL_UseCoordinates = 100, // channel is described // solely by the mCoordinates fields CHANNEL_LABEL_Left = 1, CHANNEL_LABEL_Right = 2, CHANNEL_LABEL_Center = 3, CHANNEL_LABEL_LFEScreen = 4, CHANNEL_LABEL_LeftSurround = 5, // WAVE (.wav files): "Back Left" CHANNEL_LABEL_RightSurround = 6, // WAVE: "Back Right" CHANNEL_LABEL_LeftCenter = 7, CHANNEL_LABEL_RightCenter = 8, CHANNEL_LABEL_CenterSurround = 9, // WAVE: "Back Center or // plain "Rear Surround" CHANNEL_LABEL_LeftSurroundDirect = 10, // WAVE: "Side Left" CHANNEL_LABEL_RightSurroundDirect = 11, // WAVE: "Side Right" CHANNEL_LABEL_TopCenterSurround = 12, CHANNEL_LABEL_VerticalHeightLeft = 13, // WAVE: "Top Front Left CHANNEL_LABEL_VerticalHeightCenter = 14, // WAVE: "Top Front Center CHANNEL_LABEL_VerticalHeightRight = 15, // WAVE: "Top Front Right CHANNEL_LABEL_TopBackLeft = 16, CHANNEL_LABEL_TopBackCenter = 17, CHANNEL_LABEL_TopBackRight = 18, CHANNEL_LABEL_RearSurroundLeft = 33, CHANNEL_LABEL_RearSurroundRight = 34, CHANNEL_LABEL_LeftWide = 35, CHANNEL_LABEL_RightWide = 36, CHANNEL_LABEL_LFE2 = 37, CHANNEL_LABEL_LeftTotal = 38, // matrix encoded 4 channels CHANNEL_LABEL_RightTotal = 39, // matrix encoded 4 channels CHANNEL_LABEL_HearingImpaired = 40, CHANNEL_LABEL_Narration = 41, CHANNEL_LABEL_Mono = 42, CHANNEL_LABEL_DialogCentricMix = 43, CHANNEL_LABEL_CenterSurroundDirect = 44, // back center, non diffuse // first order ambisonic channels CHANNEL_LABEL_Ambisonic_W = 200, CHANNEL_LABEL_Ambisonic_X = 201, CHANNEL_LABEL_Ambisonic_Y = 202, CHANNEL_LABEL_Ambisonic_Z = 203, // Mid/Side Recording CHANNEL_LABEL_MS_Mid = 204, CHANNEL_LABEL_MS_Side = 205, // X-Y Recording CHANNEL_LABEL_XY_X = 206, CHANNEL_LABEL_XY_Y = 207, // other CHANNEL_LABEL_HeadphonesLeft = 301, CHANNEL_LABEL_HeadphonesRight = 302, CHANNEL_LABEL_ClickTrack = 304, CHANNEL_LABEL_ForeignLanguage = 305 } channel_label_t;static struct { channel_label_t label; char * name; }channel_label_names[] = { { CHANNEL_LABEL_Unknown, "Unknown" }, { CHANNEL_LABEL_Unused, "Unused" }, // has no intended role or destination { CHANNEL_LABEL_UseCoordinates, "Use Coordinates" }, { CHANNEL_LABEL_Left, "Left" }, { CHANNEL_LABEL_Right, "Right" }, { CHANNEL_LABEL_Center, "Center" }, { CHANNEL_LABEL_LFEScreen, "LFE" }, { CHANNEL_LABEL_LeftSurround, "Left Surround" }, // WAVE (.wav files): Back Left { CHANNEL_LABEL_RightSurround, "Right Surround" }, // WAVE: "Back Right" { CHANNEL_LABEL_LeftCenter, "Left Center" }, { CHANNEL_LABEL_RightCenter, "Right Center" }, { CHANNEL_LABEL_CenterSurround, "Center Surround" }, // WAVE: "Back Center or // plain "Rear Surround" { CHANNEL_LABEL_LeftSurroundDirect, "Side Left" }, // WAVE: "Side Left" { CHANNEL_LABEL_RightSurroundDirect, "Side Right" }, // WAVE: "Side Right" { CHANNEL_LABEL_TopCenterSurround, "Top Center Surround" }, { CHANNEL_LABEL_VerticalHeightLeft, "Top Front Left" }, // WAVE: Top Front Left { CHANNEL_LABEL_VerticalHeightCenter, "Top Front Center" }, // WAVE: Top Front Center { CHANNEL_LABEL_VerticalHeightRight, "Top Front Right" }, // WAVE: "Top Front Right" { CHANNEL_LABEL_TopBackLeft, "Top Back Left" }, { CHANNEL_LABEL_TopBackCenter, "Top Back Center" } , { CHANNEL_LABEL_TopBackRight, "Top Back Right" }, { CHANNEL_LABEL_RearSurroundLeft, "Rear Surround Left" }, { CHANNEL_LABEL_RearSurroundRight, "Rear Surround Right" }, { CHANNEL_LABEL_LeftWide, "Left Wide" }, { CHANNEL_LABEL_RightWide, "Right Wide" }, { CHANNEL_LABEL_LFE2, "LFE 2" }, { CHANNEL_LABEL_LeftTotal, "Left Total" }, // matrix encoded 4 channels { CHANNEL_LABEL_RightTotal, "Right Total" }, // matrix encoded 4 channels { CHANNEL_LABEL_HearingImpaired, "Hearing Impaired" }, { CHANNEL_LABEL_Narration, "Narration" }, { CHANNEL_LABEL_Mono, "Mono" }, { CHANNEL_LABEL_DialogCentricMix, "Dialog Centric Mix" }, { CHANNEL_LABEL_CenterSurroundDirect, "Center Surround Direct" }, // back center, non diffuse // first order ambisonic channels { CHANNEL_LABEL_Ambisonic_W, "Ambisonic W" }, { CHANNEL_LABEL_Ambisonic_X, "Ambisonic X" }, { CHANNEL_LABEL_Ambisonic_Y, "Ambisonic Y" }, { CHANNEL_LABEL_Ambisonic_Z, "Ambisonic Z" }, // Mid/Side Recording { CHANNEL_LABEL_MS_Mid, "MS Mid" }, { CHANNEL_LABEL_MS_Side, "MS Side" }, // X-Y Recording { CHANNEL_LABEL_XY_X, "Label XY X" }, { CHANNEL_LABEL_XY_Y, "Label XY Y" }, // other { CHANNEL_LABEL_HeadphonesLeft, "Headphones Left" }, { CHANNEL_LABEL_HeadphonesRight, "Headphones Right" }, { CHANNEL_LABEL_ClickTrack, "Click Track" }, { CHANNEL_LABEL_ForeignLanguage, "Foreign Language" }, };static const char * get_channel_name(channel_label_t label) { int i; for(i = 0; i < sizeof(channel_label_names)/sizeof(channel_label_names[0]); i++) { if(channel_label_names[i].label == label) return channel_label_names[i].name; } return (char*)0; }typedef enum { CHANNEL_BIT_Left = (1<<0), CHANNEL_BIT_Right = (1<<1), CHANNEL_BIT_Center = (1<<2), CHANNEL_BIT_LFEScreen = (1<<3), CHANNEL_BIT_LeftSurround = (1<<4), // WAVE: "Back Left" CHANNEL_BIT_RightSurround = (1<<5), // WAVE: "Back Right" CHANNEL_BIT_LeftCenter = (1<<6), CHANNEL_BIT_RightCenter = (1<<7), CHANNEL_BIT_CenterSurround = (1<<8), // WAVE: "Back Center" CHANNEL_BIT_LeftSurroundDirect = (1<<9), // WAVE: "Side Left" CHANNEL_BIT_RightSurroundDirect = (1<<10), // WAVE: "Side Right" CHANNEL_BIT_TopCenterSurround = (1<<11), CHANNEL_BIT_VerticalHeightLeft = (1<<12), // WAVE: "Top Front Left" CHANNEL_BIT_VerticalHeightCenter = (1<<13), // WAVE: "Top Front Center" CHANNEL_BIT_VerticalHeightRight = (1<<14), // WAVE: "Top Front Right" CHANNEL_BIT_TopBackLeft = (1<<15), CHANNEL_BIT_TopBackCenter = (1<<16), CHANNEL_BIT_TopBackRight = (1<<17) } channel_bit_t;static struct { channel_bit_t bit; channel_label_t label; }channel_bits[] = { { CHANNEL_BIT_Left, CHANNEL_LABEL_Left }, { CHANNEL_BIT_Right, CHANNEL_LABEL_Right }, { CHANNEL_BIT_Center, CHANNEL_LABEL_Center }, { CHANNEL_BIT_LFEScreen, CHANNEL_LABEL_LFEScreen }, { CHANNEL_BIT_LeftSurround, CHANNEL_LABEL_LeftSurround }, // WAVE: "Back Left" { CHANNEL_BIT_RightSurround, CHANNEL_LABEL_RightSurround },// WAVE: "Back Right" { CHANNEL_BIT_LeftCenter, CHANNEL_LABEL_LeftCenter }, { CHANNEL_BIT_RightCenter, CHANNEL_LABEL_RightCenter }, { CHANNEL_BIT_CenterSurround, CHANNEL_LABEL_CenterSurround }, // WAVE: "Back Center" { CHANNEL_BIT_LeftSurroundDirect, CHANNEL_LABEL_LeftSurroundDirect }, // WAVE: "Side Left" { CHANNEL_BIT_RightSurroundDirect, CHANNEL_LABEL_RightSurroundDirect }, // WAVE: "Side Right" { CHANNEL_BIT_TopCenterSurround, CHANNEL_LABEL_TopCenterSurround }, { CHANNEL_BIT_VerticalHeightLeft, CHANNEL_LABEL_VerticalHeightLeft }, // WAVE: "Top Front Left" { CHANNEL_BIT_VerticalHeightCenter, CHANNEL_LABEL_VerticalHeightCenter }, // WAVE: "Top Front Center" { CHANNEL_BIT_VerticalHeightRight, CHANNEL_LABEL_VerticalHeightRight }, // WAVE: "Top Front Right" { CHANNEL_BIT_TopBackLeft, CHANNEL_LABEL_TopBackLeft }, { CHANNEL_BIT_TopBackCenter, CHANNEL_LABEL_TopBackCenter }, { CHANNEL_BIT_TopBackRight, CHANNEL_LABEL_TopBackRight }, };static channel_label_t channel_bit_2_channel_label(uint32_t bit) { int i; for(i = 0; i < sizeof(channel_bits) / sizeof(channel_bits[0]); i++) { if(bit == channel_bits[i].bit) return channel_bits[i].label; } return CHANNEL_LABEL_Unknown; }static struct { lqt_channel_t lqt_channel; channel_label_t channel_label; }lqt_channels[] = { { LQT_CHANNEL_UNKNOWN, CHANNEL_LABEL_Unknown }, { LQT_CHANNEL_FRONT_LEFT, CHANNEL_LABEL_Left }, { LQT_CHANNEL_FRONT_RIGHT, CHANNEL_LABEL_Right },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -