Unified · Split
| @@ -71,7 +71,10 @@ static int query_formats(AVFilterContext *ctx) · 70 unmodified lines | ||
| 71 | 71 | AVFilterChannelLayouts *layouts; |
| 72 | 72 | AVFilterLink *inlink = ctx->inputs[0]; |
| 73 | 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 | 78 | static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; |
| 76 | 79 | int ret; |
| 77 | 80 | |
| @@ -144,18 +147,7 @@ static int config_output(AVFilterLink *outlink) · 66 unmodified lines | ||
| 144 | 147 | return 0; |
| 145 | 148 | } |
| 146 | 149 | |
| 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) \ | |
| 159 | 151 | for (int ch = 0; ch < inlink->channels; ch++) { \ |
| 160 | 152 | const type *in = (const type *)insamples->extended_data[ch]; \ |
| 161 | 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 | 155 | const uint32_t color = AV_RN32(&s->fg[4 * ch]); \ |
| 164 | 156 | \ |
| 165 | 157 | 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 | + } \ | |
| 168 | 164 | \ |
| 169 | 165 | for (int b = 0; b < depth; b++) { \ |
| 170 | 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 | 178 | for (int ch = 0; ch < inlink->channels; ch++) { \ |
| 183 | 179 | const int w = outpicref->width / inlink->channels; \ |
| 184 | 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 | 182 | int wv; \ |
| 187 | 183 | \ |
| 188 | 184 | 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 | + } \ | |
| 191 | 191 | \ |
| 192 | 192 | for (int b = 0; b < depth; b++) { \ |
| 193 | 193 | uint8_t colors[4]; \ |
| @@ -236,11 +236,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 42 unmodified lines | ||
| 236 | 236 | outpicref->sample_aspect_ratio = (AVRational){1,1}; |
| 237 | 237 | |
| 238 | 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 | 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 | 244 | break; |
| 245 | + case AV_SAMPLE_FMT_FLTP: | |
| 242 | 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 | 252 | break; |
| 245 | 253 | } |
| 246 | 254 | |