1 /*
2 * Copyright (c) 2012 Andrey Utkin
3 * Copyright (c) 2012 Stefano Sabatini
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Filter that changes number of samples on single output operation
25 */
26
35
43
44 #define OFFSET(x) offsetof(ASNSContext, x)
45 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
46
48 {
"nb_out_samples",
"set the number of per-frame output samples",
OFFSET(nb_out_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
49 {
"n",
"set the number of per-frame output samples",
OFFSET(nb_out_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
52 { NULL }
53 };
54
56
58 {
60
63
64 return 0;
65 }
66
68 {
71 }
72
74 {
76
81
82 return 0;
83 }
84
86 {
89 int ret, nb_out_samples, nb_pad_samples;
90
94 } else {
96 nb_pad_samples = 0;
97 }
98
99 if (!nb_out_samples)
100 return 0;
101
103 if (!outsamples)
105
108
109 if (nb_pad_samples)
117
120
122 if (ret < 0)
124 return nb_out_samples;
125 }
126
128 {
134
136 av_log(ctx,
AV_LOG_DEBUG,
"No space for %d samples, stretching audio fifo\n", nb_samples);
138 if (ret < 0) {
140 "Stretching audio fifo failed, discarded %d samples\n", nb_samples);
141 return -1;
142 }
143 }
148
151 return 0;
152 }
153
155 {
158
163 }
164
166 }
167
169 {
173 },
174 { NULL }
175 };
176
178 {
183 },
184 { NULL }
185 };
186
188 .
name =
"asetnsamples",
191 .priv_class = &asetnsamples_class,
194 .
inputs = asetnsamples_inputs,
195 .
outputs = asetnsamples_outputs,
196 };