FFmpeg
Loading...
Searching...
No Matches
downmix_info.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <limits.h>
20#include <stdio.h>
21
23#include "libavutil/frame.h"
24#include "libavutil/mem.h"
25
26int main(void)
27{
29 AVDownmixInfo *info, *info2;
30
31 /* First call: allocates side data, zero-initialized. */
32 printf("Testing av_downmix_info_update_side_data()\n");
34 if (!frame)
35 return 1;
36
38 if (info) {
39 printf("create: OK\n");
40 printf("defaults: type=%d center=%.3f center_ltrt=%.3f surround=%.3f"
41 " surround_ltrt=%.3f lfe=%.3f\n",
45 info->lfe_mix_level);
46
47 /* Write fields and read them back. The mix levels are absolute scale
48 * factors, not gains in dB, so every value is a distinct nonnegative
49 * factor. Each one is a negative power of two or a sum of two, which
50 * makes the decimal output exact on any platform. */
52 info->center_mix_level = 0.5;
53 info->center_mix_level_ltrt = 0.625;
54 info->surround_mix_level = 0.25;
55 info->surround_mix_level_ltrt = 0.375;
56 info->lfe_mix_level = 0.125;
57 printf("write: type=%d center=%.3f center_ltrt=%.3f surround=%.3f"
58 " surround_ltrt=%.3f lfe=%.3f\n",
62 info->lfe_mix_level);
63 } else {
64 printf("create: FAIL\n");
65 }
66
67 /* Second call must reuse the existing side data (same pointer, values kept). */
69 if (info && info2) {
70 printf("reuse: same_pointer=%s preserved_type=%d preserved_center=%.3f\n",
71 info == info2 ? "yes" : "no",
73 }
74
76
77 /* OOM path: av_max_alloc(1) forces the internal side data allocation to fail. */
78 printf("\nTesting OOM path\n");
80 if (frame) {
81 av_max_alloc(1);
83 printf("OOM: %s\n", info ? "FAIL" : "OK");
84 av_max_alloc(INT_MAX);
86 }
87
88 return 0;
89}
__device__ int printf(const char *,...)
static AVFrame * frame
audio downmix medatata
reference-counted frame API
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_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
Definition mem.c:76
Memory handling functions.
This structure describes optional metadata relevant to a downmix procedure.
double lfe_mix_level
Absolute scale factor representing the level at which the LFE data is mixed into L/R channels during ...
double surround_mix_level_ltrt
Absolute scale factor representing the nominal level of the surround channels during an Lt/Rt compati...
double surround_mix_level
Absolute scale factor representing the nominal level of the surround channels during a regular downmi...
double center_mix_level
Absolute scale factor representing the nominal level of the center channel during a regular downmix.
enum AVDownmixType preferred_downmix_type
Type of downmix preferred by the mastering engineer.
double center_mix_level_ltrt
Absolute scale factor representing the nominal level of the center channel during an Lt/Rt compatible...
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int main(void)