History

avfilter/avf_abitscope: add support for more input formats

Paul B Mahol committed 4 years ago

Commit 352a01c1 parent de0bb771 file · +28 −20Browse files

Unified · Split

libavfilter/avf_abitscope.c+28−20
@@ -71,7 +71,10 @@ static int query_formats(AVFilterContext *ctx) · 70 unmodified lines
7171 AVFilterChannelLayouts *layouts;
7272 AVFilterLink *inlink = ctx->inputs[0];
7373 AVFilterLink *outlink = ctx->outputs[0];
74− static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE };
74+ static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P,
75+ AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S64P,
76+ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP,
77+ AV_SAMPLE_FMT_NONE };
7578 static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
7679 int ret;
7780
@@ -144,18 +147,7 @@ static int config_output(AVFilterLink *outlink) · 66 unmodified lines
144147 return 0;
145148 }
146149
147−static void count_bits(AudioBitScopeContext *s, uint32_t sample, int max)
148−{
149− int i;
150−
151− for (i = 0; i < max; i++) {
152− if (sample & (1U << i))
153− s->counter[i]++;
154− }
155−}
156−
157−
158−#define BARS(type, depth) \
150+#define BARS(type, depth, one) \
159151 for (int ch = 0; ch < inlink->channels; ch++) { \
160152 const type *in = (const type *)insamples->extended_data[ch]; \
161153 const int w = outpicref->width / inlink->channels; \
@@ -163,8 +155,12 @@ static void count_bits(AudioBitScopeContext *s, uint32_t sample, int max) · 1 unmodified line
163155 const uint32_t color = AV_RN32(&s->fg[4 * ch]); \
164156 \
165157 memset(s->counter, 0, sizeof(s->counter)); \
166− for (int i = 0; i < insamples->nb_samples; i++) \
167− count_bits(s, in[i], depth); \
158+ for (int i = 0; i < insamples->nb_samples; i++) { \
159+ for (int j = 0; j < depth; j++) { \
160+ if (in[i] & (one << j)) \
161+ s->counter[j]++; \
162+ } \
163+ } \
168164 \
169165 for (int b = 0; b < depth; b++) { \
170166 for (int j = 1; j < h - 1; j++) { \
@@ -178,7 +174,7 @@ static void count_bits(AudioBitScopeContext *s, uint32_t sample, int max) · 7 unmodified lines
178174 } \
179175 }
180176
181−#define TRACE(type, depth) \
177+#define TRACE(type, depth, one) \
182178 for (int ch = 0; ch < inlink->channels; ch++) { \
183179 const int w = outpicref->width / inlink->channels; \
184180 const type *in = (const type *)insamples->extended_data[ch]; \
@@ -186,8 +182,12 @@ static void count_bits(AudioBitScopeContext *s, uint32_t sample, int max) · 1 unmodified line
186182 int wv; \
187183 \
188184 memset(s->counter, 0, sizeof(s->counter)); \
189− for (int i = 0; i < insamples->nb_samples; i++) \
190− count_bits(s, in[i], depth); \
185+ for (int i = 0; i < insamples->nb_samples; i++) { \
186+ for (int j = 0; j < depth; j++) { \
187+ if (in[i] & (one << j)) \
188+ s->counter[j]++; \
189+ } \
190+ } \
191191 \
192192 for (int b = 0; b < depth; b++) { \
193193 uint8_t colors[4]; \
@@ -236,11 +236,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 42 unmodified lines
236236 outpicref->sample_aspect_ratio = (AVRational){1,1};
237237
238238 switch (insamples->format) {
239+ case AV_SAMPLE_FMT_U8P:
240+ if (s->mode == 0) { BARS(uint8_t, 8, 1) } else { TRACE(uint8_t, 8, 1) }
241+ break;
239242 case AV_SAMPLE_FMT_S16P:
240− if (s->mode == 0) { BARS(uint16_t, 16) } else { TRACE(uint16_t, 16) }
243+ if (s->mode == 0) { BARS(uint16_t, 16, 1) } else { TRACE(uint16_t, 16, 1) }
241244 break;
245+ case AV_SAMPLE_FMT_FLTP:
242246 case AV_SAMPLE_FMT_S32P:
243− if (s->mode == 0) { BARS(uint32_t, 32) } else { TRACE(uint32_t, 32) }
247+ if (s->mode == 0) { BARS(uint32_t, 32, 1U) } else { TRACE(uint32_t, 32, 1U) }
248+ break;
249+ case AV_SAMPLE_FMT_DBLP:
250+ case AV_SAMPLE_FMT_S64P:
251+ if (s->mode == 0) { BARS(uint64_t, 64, 1ULL) } else { TRACE(uint64_t, 64, 1ULL) }
244252 break;
245253 }
246254

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t