1 /*
2 * Copyright (c) 2022 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
22 #include <math.h>
23
38
50 };
51
59 };
60
67 };
68
74 };
75
128
131
132 #define OFFSET(x) offsetof(ShowCWTContext, x)
133 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
134
181 };
182
184
186 {
188
193
205
207 for (
int n = 0; n <
s->nb_threads; n++)
210 }
211
213 for (
int n = 0; n <
s->nb_threads; n++)
216 }
217
219 for (
int n = 0; n <
s->frequency_band_count; n++)
221 }
223
225 }
226
228 {
236
240
244
248
252
253 return 0;
254 }
255
257 int frequency_band_count,
258 float frequency_range,
259 float frequency_offset,
260 int frequency_scale, float deviation)
261 {
263
264 deviation =
sqrtf(deviation / (4.
f *
M_PI));
// Heisenberg Gabor Limit
265 for (int y = 0; y < frequency_band_count; y++) {
266 float frequency = frequency_range * (1.f - (
float)y / frequency_band_count) + frequency_offset;
267 float frequency_derivative = frequency_range / frequency_band_count;
268
269 switch (frequency_scale) {
271 frequency =
powf(2.
f, frequency);
272 frequency_derivative *= logf(2.
f) * frequency;
273 break;
275 frequency = 600.f * sinhf(frequency / 6.
f);
276 frequency_derivative *=
sqrtf(frequency * frequency + 360000.
f) / 6.f;
277 break;
279 frequency = 700.f * (
powf(10.
f, frequency / 2595.
f) - 1.f);
280 frequency_derivative *= (frequency + 700.f) * logf(10.
f) / 2595.f;
281 break;
283 frequency = 676170.4f / (47.06538f -
expf(frequency * 0.08950404
f)) - 14678.49
f;
284 frequency_derivative *= (frequency * frequency + 14990.4f * frequency + 4577850.f) / 160514.
f;
285 break;
287 frequency = frequency * frequency;
288 frequency_derivative *= 2.f *
sqrtf(frequency);
289 break;
291 frequency = frequency * frequency * frequency;
292 frequency_derivative *= 3.f *
powf(frequency, 2.
f / 3.
f);
293 break;
295 frequency = frequency * frequency * frequency * frequency;
296 frequency_derivative *= 4.f *
powf(frequency, 3.
f / 4.
f);
297 break;
299 frequency = 2.f *
powf(frequency, 3.
f / 2.
f) / 3.f;
300 frequency_derivative *=
sqrtf(frequency);
301 break;
302 }
303
306
307 ret = 1.f / (frequency_derivative * deviation);
308 }
309
311 }
312
314 {
315 const float max =
s->maximum_intensity;
316 const float min =
s->minimum_intensity;
318
320
321 switch (iscale) {
324 break;
328 break;
332 break;
336 break;
340 break;
341 }
342
344 }
345
347 {
349 const int hop_size =
s->hop_size;
351 float *cache = (
float *)
s->cache->extended_data[ch];
354 const int offset = (
s->input_padding_size - hop_size) >> 1;
355
356 if (fin) {
359
362 }
363
364 if (fin &&
s->hop_index + fin->
nb_samples < hop_size)
365 return 0;
366
367 memset(
src, 0,
sizeof(
float) *
s->fft_size);
368 for (int n = 0; n < hop_size; n++)
370
371 s->tx_fn(
s->fft[jobnr], dst,
src,
sizeof(*
src));
372
373 return 0;
374 }
375
376 #define DRAW_BAR_COLOR(x) \
377 do { \
378 if (Y <= ht) { \
379 dstY[x] = 0; \
380 dstU[x] = 128; \
381 dstV[x] = 128; \
382 } else { \
383 float mul = (Y - ht) * bh[0]; \
384 dstY[x] = av_clip_uint8(lrintf(Y * mul * 255.f)); \
385 dstU[x] = av_clip_uint8(lrintf((U-0.5f) * 128.f + 128)); \
386 dstV[x] = av_clip_uint8(lrintf((V-0.5f) * 128.f + 128)); \
387 } \
388 } while (0)
389
391 float Y,
float U,
float V)
392 {
393 float *bh = ((
float *)
s->bh_out->extended_data[0]) + y;
394 const ptrdiff_t ylinesize =
s->outpicref->linesize[0];
395 const ptrdiff_t ulinesize =
s->outpicref->linesize[1];
396 const ptrdiff_t vlinesize =
s->outpicref->linesize[2];
397 const int direction =
s->direction;
398 const int sono_size =
s->sono_size;
399 const int bar_size =
s->bar_size;
400 const float rcp_bar_h = 1.f / bar_size;
401 uint8_t *dstY, *dstU, *dstV;
403
404 bh[0] = 1.f / (
Y + 0.0001f);
405 switch (direction) {
407 dstY =
s->outpicref->data[0] + y * ylinesize;
408 dstU =
s->outpicref->data[1] + y * ulinesize;
409 dstV =
s->outpicref->data[2] + y * vlinesize;
410 for (int x = 0; x < bar_size; x++) {
411 float ht = (bar_size - x) * rcp_bar_h;
413 }
414 break;
416 dstY =
s->outpicref->data[0] + y * ylinesize;
417 dstU =
s->outpicref->data[1] + y * ulinesize;
418 dstV =
s->outpicref->data[2] + y * vlinesize;
419 for (int x = 0; x < bar_size; x++) {
420 float ht = x * rcp_bar_h;
422 }
423 break;
425 dstY =
s->outpicref->data[0] +
w - 1 - y;
426 dstU =
s->outpicref->data[1] +
w - 1 - y;
427 dstV =
s->outpicref->data[2] +
w - 1 - y;
428 for (int x = 0; x < bar_size; x++) {
429 float ht = (bar_size - x) * rcp_bar_h;
431 dstY += ylinesize;
432 dstU += ulinesize;
433 dstV += vlinesize;
434 }
435 break;
437 dstY =
s->outpicref->data[0] +
w - 1 - y + ylinesize * sono_size;
438 dstU =
s->outpicref->data[1] +
w - 1 - y + ulinesize * sono_size;
439 dstV =
s->outpicref->data[2] +
w - 1 - y + vlinesize * sono_size;
440 for (int x = 0; x < bar_size; x++) {
441 float ht = x * rcp_bar_h;
443 dstY += ylinesize;
444 dstU += ulinesize;
445 dstV += vlinesize;
446 }
447 break;
448 }
449 }
450
452 {
454 const ptrdiff_t ylinesize =
s->outpicref->linesize[0];
455 const ptrdiff_t ulinesize =
s->outpicref->linesize[1];
456 const ptrdiff_t vlinesize =
s->outpicref->linesize[2];
457 const ptrdiff_t alinesize =
s->outpicref->linesize[3];
458 const float log_factor = 1.f/logf(
s->logarithmic_basis);
459 const int count =
s->frequency_band_count;
460 const int start = (count * jobnr) / nb_jobs;
461 const int end = (count * (jobnr+1)) / nb_jobs;
462 const int nb_channels =
s->nb_channels;
463 const int iscale =
s->intensity_scale;
464 const int ihop_index =
s->ihop_index;
465 const int ihop_size =
s->ihop_size;
466 const float rotation =
s->rotation;
467 const int direction =
s->direction;
468 uint8_t *dstY, *dstU, *dstV, *dstA;
469 const int sono_size =
s->sono_size;
470 const int bar_size =
s->bar_size;
471 const int mode =
s->mode;
472 const int w_1 =
s->w - 1;
473 const int x =
s->pos;
475
476 for (int y = start; y < end; y++) {
478 0 * ihop_size + ihop_index;
479
480 if (sono_size <= 0)
482
483 switch (direction) {
486 dstY =
s->outpicref->data[0] + y * ylinesize;
487 dstU =
s->outpicref->data[1] + y * ulinesize;
488 dstV =
s->outpicref->data[2] + y * vlinesize;
489 dstA =
s->outpicref->data[3] ?
s->outpicref->data[3] + y * alinesize :
NULL;
490 break;
493 dstY =
s->outpicref->data[0] + x * ylinesize + w_1 - y;
494 dstU =
s->outpicref->data[1] + x * ulinesize + w_1 - y;
495 dstV =
s->outpicref->data[2] + x * vlinesize + w_1 - y;
496 dstA =
s->outpicref->data[3] ?
s->outpicref->data[3] + x * alinesize + w_1 - y :
NULL;
497 break;
498 }
499
503 /* nothing to do here */
504 break;
506 switch (
s->direction) {
508 memmove(dstY, dstY + 1, w_1);
509 memmove(dstU, dstU + 1, w_1);
510 memmove(dstV, dstV + 1, w_1);
512 memmove(dstA, dstA + 1, w_1);
513 break;
515 memmove(dstY + 1, dstY, w_1);
516 memmove(dstU + 1, dstU, w_1);
517 memmove(dstV + 1, dstV, w_1);
519 memmove(dstA + 1, dstA, w_1);
520 break;
521 }
522 break;
523 }
524
527 dstY += x;
528 dstU += x;
529 dstV += x;
531 dstA += x;
532 }
534
536 case 4:
537 {
540
542 u = hypotf(
src[0].re,
src[0].im);
544
548
552
555
556 U = 0.5f + 0.5f * z *
u;
557 V = 0.5f + 0.5f * z * v;
558
559 if (sono_size > 0) {
563 if (dstA)
564 dstA[0] = dstY[0];
565 }
566
567 if (bar_size > 0)
569 }
570 break;
571 case 3:
572 {
573 const int nb_channels =
s->nb_channels;
574 const float yf = 1.f / nb_channels;
575
578 for (int ch = 0; ch < nb_channels; ch++) {
580 float z;
581
582 z = hypotf(srcn[0].re, srcn[0].im);
584
586 U += z * yf *
sinf(2.
f *
M_PI * (ch * yf + rotation));
587 V += z * yf *
cosf(2.
f *
M_PI * (ch * yf + rotation));
588 }
589
590 if (sono_size > 0) {
594 if (dstA)
595 dstA[0] = dstY[0];
596 }
597
598 if (bar_size > 0)
600 }
601 break;
602 case 2:
603 Y = hypotf(
src[0].re,
src[0].im);
606 U = 0.5f + 0.5f *
U *
Y /
M_PI;
608
609 if (sono_size > 0) {
613 if (dstA)
614 dstA[0] = dstY[0];
615 }
616
617 if (bar_size > 0)
619 break;
620 case 1:
622 Y = 0.5f + 0.5f *
Y /
M_PI;
623
624 if (sono_size > 0) {
626 if (dstA)
627 dstA[0] = dstY[0];
628 }
629
630 if (bar_size > 0)
632 break;
633 case 0:
634 Y = hypotf(
src[0].re,
src[0].im);
636
637 if (sono_size > 0) {
639 if (dstA)
640 dstA[0] = dstY[0];
641 }
642
643 if (bar_size > 0)
645 break;
646 }
647 }
648
649 return 0;
650 }
651
653 {
655 const int ch = *(
int *)
arg;
659 const int output_padding_size =
s->output_padding_size;
660 const int input_padding_size =
s->input_padding_size;
661 const float scale = 1.f / input_padding_size;
662 const int ihop_size =
s->ihop_size;
663 const int count =
s->frequency_band_count;
664 const int start = (count * jobnr) / nb_jobs;
665 const int end = (count * (jobnr+1)) / nb_jobs;
666
667 for (int y = start; y < end; y++) {
673 const unsigned *
index = (
const unsigned *)
s->index;
674 const int kernel_start =
s->kernel_start[y];
675 const int kernel_stop =
s->kernel_stop[y];
676 const int kernel_range = kernel_stop - kernel_start + 1;
678
679 if (kernel_start >= 0) {
681 memcpy(srcx, fft_out + kernel_start, sizeof(*fft_out) * kernel_range);
682 } else {
684 memcpy(srcx+
offset, fft_out,
sizeof(*fft_out) * (kernel_range-
offset));
685 memcpy(srcx, fft_out+input_padding_size-
offset,
sizeof(*fft_out)*
offset);
686 }
687
688 s->fdsp->vector_fmul_scalar((
float *)srcx, (
const float *)srcx,
scale,
FFALIGN(kernel_range * 2, 4));
689 s->fdsp->vector_fmul((
float *)dstx, (
const float *)srcx,
690 (
const float *)kernel,
FFALIGN(kernel_range * 2, 16));
691
692 memset(isrc, 0, sizeof(*isrc) * output_padding_size);
694 const unsigned *kindex =
index + kernel_start;
695 for (
int i = 0;
i < kernel_range;
i++) {
696 const unsigned n = kindex[
i];
697
698 isrc[n].re += dstx[
i].re;
699 isrc[n].im += dstx[
i].im;
700 }
701 } else {
702 for (
int i = 0;
i < kernel_range;
i++) {
703 const unsigned n = (
i-kernel_start) & (output_padding_size-1);
704
705 isrc[n].re += dstx[
i].re;
706 isrc[n].im += dstx[
i].im;
707 }
708 }
709
710 s->itx_fn(
s->ifft[jobnr], idst, isrc,
sizeof(*isrc));
711
712 memcpy(chout, idst, sizeof(*chout) * ihop_size);
713 for (int n = 0; n < ihop_size; n++) {
714 chout[n].
re += over[n].
re;
715 chout[n].
im += over[n].
im;
716 }
717 memcpy(over, idst + ihop_size, sizeof(*over) * ihop_size);
718 }
719
720 return 0;
721 }
722
724 {
726 const int size =
s->input_padding_size;
727 const int output_sample_count =
s->output_sample_count;
728 const int fsize =
s->frequency_band_count;
729 int *kernel_start =
s->kernel_start;
730 int *kernel_stop =
s->kernel_stop;
731 unsigned *
index =
s->index;
732 int range_min = INT_MAX;
733 int range_max = 0,
ret = 0;
734 float *tkernel;
735
737 if (!tkernel)
739
740 for (
int y = 0; y <
fsize; y++) {
742 int start = INT_MIN, stop = INT_MAX;
743 const float frequency =
s->frequency_band[y*2];
744 const float deviation = 1.f / (
s->frequency_band[y*2+1] *
745 output_sample_count);
749
750 memset(tkernel, 0,
size *
sizeof(*tkernel));
751 for (
int n =
a; n <
b; n++) {
752 float ff,
f = n+0.5f-frequency;
753
754 ff =
expf(-
f*
f*deviation);
755 tkernel[n+
range] = ff;
756 }
757
758 for (
int n =
a; n <
b; n++) {
759 if (tkernel[n+
range] != 0.
f) {
760 if (tkernel[n+
range] > FLT_MIN)
762 start = n;
763 break;
764 }
765 }
766
767 for (
int n =
b; n >=
a; n--) {
768 if (tkernel[n+
range] != 0.
f) {
769 if (tkernel[n+
range] > FLT_MIN)
771 stop = n;
772 break;
773 }
774 }
775
776 if (start == INT_MIN || stop == INT_MAX) {
778 break;
779 }
780
781 kernel_start[y] = start;
782 kernel_stop[y] = stop;
783
785 if (!kernel) {
787 break;
788 }
789
790 for (int n = 0; n <= stop - start; n++) {
791 kernel[n].
re = tkernel[n+
range+start];
792 kernel[n].
im = tkernel[n+
range+start];
793 }
794
795 range_min =
FFMIN(range_min, stop+1-start);
796 range_max =
FFMAX(range_max, stop+1-start);
797
798 s->kernel[y] = kernel;
799 }
800
801 for (
int n = 0; n <
size; n++)
802 index[n] = n & (
s->output_padding_size - 1);
803
806
808
810 }
811
813 {
817 const float limit_frequency =
inlink->sample_rate * 0.5f;
818 float maximum_frequency =
fminf(
s->maximum_frequency, limit_frequency);
819 float minimum_frequency =
s->minimum_frequency;
822
823 if (minimum_frequency >= maximum_frequency) {
825 minimum_frequency, maximum_frequency);
827 }
828
830
834
835 switch (
s->direction) {
838 s->bar_size =
s->w *
s->bar_ratio;
839 s->sono_size =
s->w -
s->bar_size;
840 s->frequency_band_count =
s->h;
841 break;
844 s->bar_size =
s->h *
s->bar_ratio;
845 s->sono_size =
s->h -
s->bar_size;
846 s->frequency_band_count =
s->w;
847 break;
848 }
849
850 switch (
s->frequency_scale) {
852 minimum_frequency = logf(minimum_frequency) / logf(2.
f);
853 maximum_frequency = logf(maximum_frequency) / logf(2.
f);
854 break;
856 minimum_frequency = 6.f * asinhf(minimum_frequency / 600.
f);
857 maximum_frequency = 6.f * asinhf(maximum_frequency / 600.
f);
858 break;
860 minimum_frequency = 2595.f *
log10f(1.
f + minimum_frequency / 700.
f);
861 maximum_frequency = 2595.f *
log10f(1.
f + maximum_frequency / 700.
f);
862 break;
864 minimum_frequency = 11.17268f * logf(1.
f + (46.06538
f * minimum_frequency) / (minimum_frequency + 14678.49
f));
865 maximum_frequency = 11.17268f * logf(1.
f + (46.06538
f * maximum_frequency) / (maximum_frequency + 14678.49
f));
866 break;
868 minimum_frequency =
sqrtf(minimum_frequency);
869 maximum_frequency =
sqrtf(maximum_frequency);
870 break;
872 minimum_frequency =
cbrtf(minimum_frequency);
873 maximum_frequency =
cbrtf(maximum_frequency);
874 break;
876 minimum_frequency =
powf(minimum_frequency, 0.25
f);
877 maximum_frequency =
powf(maximum_frequency, 0.25
f);
878 break;
880 minimum_frequency =
powf(9.
f * (minimum_frequency * minimum_frequency) / 4.
f, 1.
f / 3.
f);
881 maximum_frequency =
powf(9.
f * (maximum_frequency * maximum_frequency) / 4.
f, 1.
f / 3.
f);
882 break;
883 }
884
885 s->frequency_band =
av_calloc(
s->frequency_band_count,
886 sizeof(*
s->frequency_band) * 2);
887 if (!
s->frequency_band)
889
890 s->nb_consumed_samples =
inlink->sample_rate *
892 s->frequency_band_count, maximum_frequency - minimum_frequency,
893 minimum_frequency,
s->frequency_scale,
s->deviation);
894 s->nb_consumed_samples =
FFMIN(
s->nb_consumed_samples, 65536);
895
897 s->nb_channels =
inlink->ch_layout.nb_channels;
900
901 s->input_sample_count = 1 << (32 -
ff_clz(
s->nb_consumed_samples));
902 s->input_padding_size = 1 << (32 -
ff_clz(
s->input_sample_count));
904 s->output_padding_size = 1 << (32 -
ff_clz(
s->output_sample_count));
905
906 s->hop_size =
s->input_sample_count;
907 s->ihop_size =
s->output_padding_size >> 1;
908
912
915
919
920 for (
int n = 0; n <
s->nb_threads; n++) {
924 }
925
929
930 for (
int n = 0; n <
s->nb_threads; n++) {
934 }
935
941 s->kernel =
av_calloc(
s->frequency_band_count,
sizeof(*
s->kernel));
948 s->index =
av_calloc(
s->input_padding_size,
sizeof(*
s->index));
949 s->kernel_start =
av_calloc(
s->frequency_band_count,
sizeof(*
s->kernel_start));
950 s->kernel_stop =
av_calloc(
s->frequency_band_count,
sizeof(*
s->kernel_stop));
951 if (!
s->outpicref || !
s->fft_in || !
s->fft_out || !
s->src_x || !
s->dst_x || !
s->over ||
952 !
s->ifft_in || !
s->ifft_out || !
s->kernel_start || !
s->kernel_stop || !
s->ch_out ||
953 !
s->cache || !
s->index || !
s->bh_out || !
s->kernel)
955
956 s->ch_out->format =
inlink->format;
957 s->ch_out->nb_samples = 2 *
s->ihop_size *
inlink->ch_layout.nb_channels;
958 s->ch_out->ch_layout.nb_channels =
s->frequency_band_count;
962
963 s->ifft_in->format =
inlink->format;
964 s->ifft_in->nb_samples =
s->ifft_size * 2;
965 s->ifft_in->ch_layout.nb_channels =
s->nb_threads;
969
970 s->ifft_out->format =
inlink->format;
971 s->ifft_out->nb_samples =
s->ifft_size * 2;
972 s->ifft_out->ch_layout.nb_channels =
s->nb_threads;
976
977 s->src_x->format =
inlink->format;
978 s->src_x->nb_samples =
s->fft_size * 2;
979 s->src_x->ch_layout.nb_channels =
s->nb_threads;
983
984 s->dst_x->format =
inlink->format;
985 s->dst_x->nb_samples =
s->fft_size * 2;
986 s->dst_x->ch_layout.nb_channels =
s->nb_threads;
990
991 s->outpicref->sample_aspect_ratio = (
AVRational){1,1};
992
993 for (
int y = 0; y < outlink->
h; y++) {
994 memset(
s->outpicref->data[0] + y *
s->outpicref->linesize[0], 0, outlink->
w);
995 memset(
s->outpicref->data[1] + y *
s->outpicref->linesize[1], 128, outlink->
w);
996 memset(
s->outpicref->data[2] + y *
s->outpicref->linesize[2], 128, outlink->
w);
997 if (
s->outpicref->data[3])
998 memset(
s->outpicref->data[3] + y *
s->outpicref->linesize[3], 0, outlink->
w);
999 }
1000
1002
1004 for (
int n = 0; n <
s->frequency_band_count; n++) {
1005 s->frequency_band[2*n ] *=
factor;
1006 s->frequency_band[2*n+1] *=
factor;
1007 }
1008
1017
1018 switch (
s->direction) {
1021 s->pos =
s->bar_size;
1022 break;
1025 s->pos =
s->sono_size;
1026 break;
1027 }
1028
1030 if (strcmp(
s->rate_str,
"auto")) {
1034 } else {
1035 s->frame_rate =
s->auto_frame_rate;
1036 }
1039
1043
1044 return 0;
1045 }
1046
1048 {
1052 const int nb_planes = 3 + (
s->outpicref->data[3] !=
NULL);
1054
1057 switch (
s->direction) {
1059 for (int p = 0; p < nb_planes; p++) {
1060 ptrdiff_t linesize =
s->outpicref->linesize[p];
1061
1062 for (
int y =
s->h - 1; y >
s->bar_size; y--) {
1063 uint8_t *dst =
s->outpicref->data[p] + y * linesize;
1064
1065 memmove(dst, dst - linesize,
s->w);
1066 }
1067 }
1068 break;
1070 for (int p = 0; p < nb_planes; p++) {
1071 ptrdiff_t linesize =
s->outpicref->linesize[p];
1072
1073 for (
int y = 0; y <
s->sono_size; y++) {
1074 uint8_t *dst =
s->outpicref->data[p] + y * linesize;
1075
1076 memmove(dst, dst + linesize,
s->w);
1077 }
1078 }
1079 break;
1080 }
1081 break;
1082 }
1083
1085
1089 switch (
s->direction) {
1092 if (
s->pos >=
s->w) {
1093 s->pos =
s->bar_size;
1095 }
1096 break;
1100 s->pos =
s->sono_size;
1102 }
1103 break;
1106 if (
s->pos >=
s->h) {
1107 s->pos =
s->bar_size;
1109 }
1110 break;
1114 s->pos =
s->sono_size;
1116 }
1117 break;
1118 }
1119 break;
1121 switch (
s->direction) {
1124 s->pos =
s->bar_size;
1125 break;
1128 s->pos =
s->sono_size;
1129 break;
1130 }
1131 break;
1132 }
1133
1135 switch (
s->direction) {
1137 for (int p = 0; p < nb_planes; p++) {
1138 ptrdiff_t linesize =
s->outpicref->linesize[p];
1139 const int size =
s->w -
s->pos;
1140 const int fill = p > 0 && p < 3 ? 128 : 0;
1141 const int x =
s->pos;
1142
1143 for (
int y = 0; y <
s->h; y++) {
1144 uint8_t *dst =
s->outpicref->data[p] + y * linesize + x;
1145
1146 memset(dst, fill,
size);
1147 }
1148 }
1149 break;
1151 for (int p = 0; p < nb_planes; p++) {
1152 ptrdiff_t linesize =
s->outpicref->linesize[p];
1153 const int size =
s->w -
s->pos;
1154 const int fill = p > 0 && p < 3 ? 128 : 0;
1155
1156 for (
int y = 0; y <
s->h; y++) {
1157 uint8_t *dst =
s->outpicref->data[p] + y * linesize;
1158
1159 memset(dst, fill,
size);
1160 }
1161 }
1162 break;
1164 for (int p = 0; p < nb_planes; p++) {
1165 ptrdiff_t linesize =
s->outpicref->linesize[p];
1166 const int fill = p > 0 && p < 3 ? 128 : 0;
1167
1168 for (
int y =
s->pos; y < s->
h; y++) {
1169 uint8_t *dst =
s->outpicref->data[p] + y * linesize;
1170
1171 memset(dst, fill,
s->w);
1172 }
1173 }
1174 break;
1176 for (int p = 0; p < nb_planes; p++) {
1177 ptrdiff_t linesize =
s->outpicref->linesize[p];
1178 const int fill = p > 0 && p < 3 ? 128 : 0;
1179
1180 for (
int y =
s->h -
s->pos; y >= 0; y--) {
1181 uint8_t *dst =
s->outpicref->data[p] + y * linesize;
1182
1183 memset(dst, fill,
s->w);
1184 }
1185 }
1186 break;
1187 }
1188 }
1189
1191
1194 const int offset = (
s->input_padding_size -
s->hop_size) >> 1;
1195
1198 s->outpicref->duration = 1;
1199 }
1200
1202 if (
s->ihop_index >=
s->ihop_size)
1203 s->ihop_index =
s->hop_index = 0;
1204
1206 return 1;
1207
1208 if (
s->old_pts <
s->outpicref->pts) {
1218 s->old_pts =
s->outpicref->pts;
1226 }
1227
1228 return 1;
1229 }
1230
1232 {
1234 const int count =
s->nb_channels;
1235 const int start = (count * jobnr) / nb_jobs;
1236 const int end = (count * (jobnr+1)) / nb_jobs;
1237
1238 for (int ch = start; ch < end; ch++)
1240
1241 return 0;
1242 }
1243
1245 {
1251
1253
1256
1257 if (
s->hop_index <
s->hop_size) {
1262 }
1263
1264 if (
ret > 0 ||
s->eof) {
1266 FFMIN(
s->nb_threads,
s->nb_channels));
1267 if (fin) {
1268 if (
s->hop_index == 0) {
1269 s->in_pts = fin->
pts;
1272 }
1275 } else {
1276 s->hop_index =
s->hop_size;
1277 }
1278 }
1279 }
1280
1281 if (
s->hop_index >=
s->hop_size ||
s->ihop_index > 0) {
1282 for (
int ch = 0; ch <
s->nb_channels &&
s->ihop_index == 0; ch++) {
1285 }
1286
1290 }
1291 }
1292
1298 }
1299
1305 return 0;
1306 }
1307 }
1308
1310 s->hop_index >=
s->hop_size ||
s->eof) {
1312 return 0;
1313 }
1314
1317 return 0;
1318 }
1319
1321 }
1322
1324 {
1328 },
1329 };
1330
1333 .description =
NULL_IF_CONFIG_SMALL(
"Convert input audio to a CWT (Continuous Wavelet Transform) spectrum video output."),
1340 .priv_class = &showcwt_class,
1342 };