diff options
author | Tim Walker <tdskywalker@gmail.com> | 2014-02-15 17:12:22 +0000 |
---|---|---|
committer | Tim Walker <tdskywalker@gmail.com> | 2014-02-15 22:24:53 +0100 |
commit | c98f3169bfb578c1a4e407b44524f0bfa3b4dc0c (patch) | |
tree | 0c8b1a195a4ad0d239d372e0b91777ee6a09dd4e | |
parent | 9c0e4b3395cad79c560d03d2a94595d89e017885 (diff) | |
download | ffmpeg-c98f3169bfb578c1a4e407b44524f0bfa3b4dc0c.tar.gz |
lavu: add AV_FRAME_DATA_DOWNMIX_INFO side data type.
-rw-r--r-- | doc/APIchanges | 4 | ||||
-rw-r--r-- | libavutil/Makefile | 2 | ||||
-rw-r--r-- | libavutil/downmix_info.c | 38 | ||||
-rw-r--r-- | libavutil/downmix_info.h | 114 | ||||
-rw-r--r-- | libavutil/frame.h | 5 | ||||
-rw-r--r-- | libavutil/version.h | 2 |
6 files changed, 164 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges index 41c848fac7..d3939e4e12 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2013-12-xx API changes, most recent first: +2014-02-xx - xxxxxxx - lavu 53.3.0 - frame.h + Add AV_FRAME_DATA_DOWNMIX_INFO value to the AVFrameSideDataType enum and + downmix_info.h API, which identify downmix-related metadata. + 2014-02-04 - d9ae103 - lavf 55.11.0 - avformat.h Add AVFormatContext.max_interleave_delta for controlling amount of buffering when interleaving. diff --git a/libavutil/Makefile b/libavutil/Makefile index e0e32b4fba..f663f182b5 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -16,6 +16,7 @@ HEADERS = adler32.h \ common.h \ cpu.h \ crc.h \ + downmix_info.h \ error.h \ eval.h \ fifo.h \ @@ -67,6 +68,7 @@ OBJS = adler32.o \ cpu.o \ crc.o \ des.o \ + downmix_info.o \ error.o \ eval.o \ fifo.o \ diff --git a/libavutil/downmix_info.c b/libavutil/downmix_info.c new file mode 100644 index 0000000000..51505c8e04 --- /dev/null +++ b/libavutil/downmix_info.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com> + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "downmix_info.h" +#include "frame.h" + +AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame) +{ + AVFrameSideData *side_data; + + side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO); + + if (!side_data) + side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO, + sizeof(AVDownmixInfo)); + + if (!side_data) + return NULL; + + return (AVDownmixInfo*)side_data->data; +} diff --git a/libavutil/downmix_info.h b/libavutil/downmix_info.h new file mode 100644 index 0000000000..69969f6fbd --- /dev/null +++ b/libavutil/downmix_info.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com> + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_DOWNMIX_INFO_H +#define AVUTIL_DOWNMIX_INFO_H + +#include "frame.h" + +/** + * @file + * audio downmix medatata + */ + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup downmix_info Audio downmix metadata + * @{ + */ + +/** + * Possible downmix types. + */ +enum AVDownmixType { + AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */ + AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */ + AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */ + AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */ + AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */ +}; + +/** + * This structure describes optional metadata relevant to a downmix procedure. + * + * All fields are set by the decoder to the value indicated in the audio + * bitstream (if present), or to a "sane" default otherwise. + */ +typedef struct AVDownmixInfo { + /** + * Type of downmix preferred by the mastering engineer. + */ + enum AVDownmixType preferred_downmix_type; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during a regular downmix. + */ + double center_mix_level; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during an Lt/Rt compatible downmix. + */ + double center_mix_level_ltrt; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during a regular downmix. + */ + double surround_mix_level; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during an Lt/Rt compatible downmix. + */ + double surround_mix_level_ltrt; + + /** + * Absolute scale factor representing the level at which the LFE data is + * mixed into L/R channels during downmixing. + */ + double lfe_mix_level; +} AVDownmixInfo; + +/** + * Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing. + * + * The side data is created and added to the frame if it's absent. + * + * @param frame the frame for which the side data is to be obtained. + * + * @return the AVDownmixInfo structure to be edited by the caller. + */ +AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame); + +/** + * @} + */ + +/** + * @} + */ + +#endif /* AVUTIL_DOWNMIX_INFO_H */ diff --git a/libavutil/frame.h b/libavutil/frame.h index 5b04291001..20766423f5 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -64,6 +64,11 @@ enum AVFrameSideDataType { * The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h. */ AV_FRAME_DATA_MATRIXENCODING, + /** + * Metadata relevant to a downmix procedure. + * The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h. + */ + AV_FRAME_DATA_DOWNMIX_INFO, }; typedef struct AVFrameSideData { diff --git a/libavutil/version.h b/libavutil/version.h index e95d77c600..5196a674de 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 53 -#define LIBAVUTIL_VERSION_MINOR 2 +#define LIBAVUTIL_VERSION_MINOR 3 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |