FFmpeg
Loading...
Searching...
No Matches
downmix_info.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "downmix_info.h"
22#include "frame.h"
23#include "mem.h"
24
26{
27 AVFrameSideData *side_data;
28
30
31 if (!side_data) {
33 sizeof(AVDownmixInfo));
34 if (side_data)
35 memset(side_data->data, 0, sizeof(AVDownmixInfo));
36 }
37
38 if (!side_data)
39 return NULL;
40
41 return (AVDownmixInfo*)side_data->data;
42}
43
44#define MAX_CHANNELS 64
45
46static const int type_map[] = {
51};
52
54 int in_ch_count, size_t *out_size)
55{
56 struct TestStruct {
59 };
60 const size_t coeffs_offset = offsetof(struct TestStruct, b);
61 size_t size = coeffs_offset;
62 unsigned int nb_coeffs;
64
65 if ((unsigned)type >= FF_ARRAY_ELEMS(type_map) ||
66 (unsigned)in_ch_count > MAX_CHANNELS)
67 return NULL;
68
69 nb_coeffs = type_map[type] * in_ch_count;
70 size += sizeof(AVDownmixCoeff) * nb_coeffs;
71
72 dc = av_mallocz(size);
73 if (!dc)
74 return NULL;
75
76 dc->downmix_type = type;
77 dc->nb_coeffs = nb_coeffs;
78 dc->in_ch_count = in_ch_count;
79 dc->coeffs_offset = coeffs_offset;
80
81 if (out_size)
82 *out_size = size;
83
84 return dc;
85}
#define MAX_CHANNELS
Definition aac.h:33
#define NULL
Definition coverity.c:32
static AVFrame * frame
static const int type_map[]
audio downmix medatata
reference-counted frame API
AVDownmixMatrix * av_downmix_matrix_alloc(enum AVDownmixType type, int in_ch_count, size_t *out_size)
Allocates memory for AVDownmixMatrix of the given type, plus an array of in_ch_count times the implic...
double AVDownmixCoeff
Data type for storing coefficients, which are allocated as a part of AVDownmixMatrix and should be re...
AVDownmixType
Possible downmix types.
AVDownmixInfo * av_downmix_info_update_side_data(AVFrame *frame)
Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
@ AV_DOWNMIX_TYPE_UNKNOWN
Not indicated.
@ AV_DOWNMIX_TYPE_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
@ AV_DOWNMIX_TYPE_LORO
Lo/Ro 2-channel downmix (Stereo).
@ AV_DOWNMIX_TYPE_DPLII
Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition frame.c:659
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition frame.c:647
@ AV_FRAME_DATA_DOWNMIX_INFO
Metadata relevant to a downmix procedure.
Definition frame.h:73
cl_device_type type
#define b
Definition input.c:43
Memory handling functions.
#define FF_ARRAY_ELEMS(a)
This structure describes optional metadata relevant to a downmix procedure.
This structure describes optional metadata relevant to a downmix procedure in the form of a remixing ...
size_t coeffs_offset
Offset in bytes from the beginning of this structure at which the array of coefficients starts.
int in_ch_count
Input channel count.
unsigned int nb_coeffs
Amount of coefficients in the matrix.
enum AVDownmixType downmix_type
Type of downmix the coeffs will produce.
Structure to hold side data for an AVFrame.
Definition frame.h:327
uint8_t * data
Definition frame.h:329
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
#define av_mallocz(s)
static int out_size
Definition movenc.c:56
int size