Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -131,11 +131,35 @@ static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, · 130 unmodified lines | |||
| 131 | nb_samples_notify, time_base); \ | 131 | nb_samples_notify, time_base); \ |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | #define SILENCE_DETECT_PLANAR(name, type) \ | ||
| 135 | static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, \ | ||
| 136 | int nb_samples, int64_t nb_samples_notify, \ | ||
| 137 | AVRational time_base) \ | ||
| 138 | { \ | ||
| 139 | const int channels = insamples->channels; \ | ||
| 140 | const type noise = s->noise; \ | ||
| 141 | \ | ||
| 142 | nb_samples /= channels; \ | ||
| 143 | for (int i = 0; i < nb_samples; i++) { \ | ||
| 144 | for (int ch = 0; ch < insamples->channels; ch++) { \ | ||
| 145 | const type *p = (const type *)insamples->extended_data[ch]; \ | ||
| 146 | update(s, insamples, p[i] < noise && p[i] > -noise, \ | ||
| 147 | channels * i + ch, \ | ||
| 148 | nb_samples_notify, time_base); \ | ||
| 149 | } \ | ||
| 150 | } \ | ||
| 151 | } | ||
| 152 | |||
| 134 | SILENCE_DETECT(dbl, double) | 153 | SILENCE_DETECT(dbl, double) |
| 135 | SILENCE_DETECT(flt, float) | 154 | SILENCE_DETECT(flt, float) |
| 136 | SILENCE_DETECT(s32, int32_t) | 155 | SILENCE_DETECT(s32, int32_t) |
| 137 | SILENCE_DETECT(s16, int16_t) | 156 | SILENCE_DETECT(s16, int16_t) |
| 138 | 157 | ||
| 158 | SILENCE_DETECT_PLANAR(dblp, double) | ||
| 159 | SILENCE_DETECT_PLANAR(fltp, float) | ||
| 160 | SILENCE_DETECT_PLANAR(s32p, int32_t) | ||
| 161 | SILENCE_DETECT_PLANAR(s16p, int16_t) | ||
| 162 | |||
| 139 | static int config_input(AVFilterLink *inlink) | 163 | static int config_input(AVFilterLink *inlink) |
| 140 | { | 164 | { |
| 141 | AVFilterContext *ctx = inlink->dst; | 165 | AVFilterContext *ctx = inlink->dst; |
| @@ -165,6 +189,18 @@ static int config_input(AVFilterLink *inlink) · 23 unmodified lines | |||
| 165 | s->noise *= INT16_MAX; | 189 | s->noise *= INT16_MAX; |
| 166 | s->silencedetect = silencedetect_s16; | 190 | s->silencedetect = silencedetect_s16; |
| 167 | break; | 191 | break; |
| 192 | case AV_SAMPLE_FMT_DBLP: s->silencedetect = silencedetect_dblp; break; | ||
| 193 | case AV_SAMPLE_FMT_FLTP: s->silencedetect = silencedetect_fltp; break; | ||
| 194 | case AV_SAMPLE_FMT_S32P: | ||
| 195 | s->noise *= INT32_MAX; | ||
| 196 | s->silencedetect = silencedetect_s32p; | ||
| 197 | break; | ||
| 198 | case AV_SAMPLE_FMT_S16P: | ||
| 199 | s->noise *= INT16_MAX; | ||
| 200 | s->silencedetect = silencedetect_s16p; | ||
| 201 | break; | ||
| 202 | default: | ||
| 203 | return AVERROR_BUG; | ||
| 168 | } | 204 | } |
| 169 | 205 | ||
| 170 | return 0; | 206 | return 0; |
| @@ -198,10 +234,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 27 unmodified lines | |||
| 198 | static int query_formats(AVFilterContext *ctx) | 234 | static int query_formats(AVFilterContext *ctx) |
| 199 | { | 235 | { |
| 200 | static const enum AVSampleFormat sample_fmts[] = { | 236 | static const enum AVSampleFormat sample_fmts[] = { |
| 201 | AV_SAMPLE_FMT_DBL, | 237 | AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP, |
| 202 | AV_SAMPLE_FMT_FLT, | 238 | AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, |
| 203 | AV_SAMPLE_FMT_S32, | 239 | AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P, |
| 204 | AV_SAMPLE_FMT_S16, | 240 | AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, |
| 205 | AV_SAMPLE_FMT_NONE | 241 | AV_SAMPLE_FMT_NONE |
| 206 | }; | 242 | }; |
| 207 | int ret = ff_set_common_all_channel_counts(ctx); | 243 | int ret = ff_set_common_all_channel_counts(ctx); |