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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/avf_abitscope.c+28−20
@@ -71,7 +71,10 @@ static int query_formats(AVFilterContext *ctx) · 70 unmodified lines
71 AVFilterChannelLayouts *layouts;71 AVFilterChannelLayouts *layouts;
72 AVFilterLink *inlink = ctx->inputs[0];72 AVFilterLink *inlink = ctx->inputs[0];
73 AVFilterLink *outlink = ctx->outputs[0];73 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 };
75 static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };78 static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
76 int ret;79 int ret;
77 80
@@ -144,18 +147,7 @@ static int config_output(AVFilterLink *outlink) · 66 unmodified lines
144 return 0;147 return 0;
145}148}
146 149
147static void count_bits(AudioBitScopeContext *s, uint32_t sample, int max)150#define BARS(type, depth, one) \
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) \
159 for (int ch = 0; ch < inlink->channels; ch++) { \151 for (int ch = 0; ch < inlink->channels; ch++) { \
160 const type *in = (const type *)insamples->extended_data[ch]; \152 const type *in = (const type *)insamples->extended_data[ch]; \
161 const int w = outpicref->width / inlink->channels; \153 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
163 const uint32_t color = AV_RN32(&s->fg[4 * ch]); \155 const uint32_t color = AV_RN32(&s->fg[4 * ch]); \
164 \156 \
165 memset(s->counter, 0, sizeof(s->counter)); \157 memset(s->counter, 0, sizeof(s->counter)); \
166 for (int i = 0; i < insamples->nb_samples; i++) \158 for (int i = 0; i < insamples->nb_samples; i++) { \
167 count_bits(s, in[i], depth); \159 for (int j = 0; j < depth; j++) { \
160 if (in[i] & (one << j)) \
161 s->counter[j]++; \
162 } \
163 } \
168 \164 \
169 for (int b = 0; b < depth; b++) { \165 for (int b = 0; b < depth; b++) { \
170 for (int j = 1; j < h - 1; j++) { \166 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
178 } \174 } \
179 }175 }
180 176
181#define TRACE(type, depth) \177#define TRACE(type, depth, one) \
182 for (int ch = 0; ch < inlink->channels; ch++) { \178 for (int ch = 0; ch < inlink->channels; ch++) { \
183 const int w = outpicref->width / inlink->channels; \179 const int w = outpicref->width / inlink->channels; \
184 const type *in = (const type *)insamples->extended_data[ch]; \180 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
186 int wv; \182 int wv; \
187 \183 \
188 memset(s->counter, 0, sizeof(s->counter)); \184 memset(s->counter, 0, sizeof(s->counter)); \
189 for (int i = 0; i < insamples->nb_samples; i++) \185 for (int i = 0; i < insamples->nb_samples; i++) { \
190 count_bits(s, in[i], depth); \186 for (int j = 0; j < depth; j++) { \
187 if (in[i] & (one << j)) \
188 s->counter[j]++; \
189 } \
190 } \
191 \191 \
192 for (int b = 0; b < depth; b++) { \192 for (int b = 0; b < depth; b++) { \
193 uint8_t colors[4]; \193 uint8_t colors[4]; \
@@ -236,11 +236,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 42 unmodified lines
236 outpicref->sample_aspect_ratio = (AVRational){1,1};236 outpicref->sample_aspect_ratio = (AVRational){1,1};
237 237
238 switch (insamples->format) {238 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;
239 case AV_SAMPLE_FMT_S16P:242 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) }
241 break;244 break;
245 case AV_SAMPLE_FMT_FLTP:
242 case AV_SAMPLE_FMT_S32P:246 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) }
244 break;252 break;
245 }253 }
246 254

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