1
1
/*
2
2
* This file is part of dsp.
3
3
*
4
- * Copyright (c) 2013-2024 Michael Barbour <[email protected] >
4
+ * Copyright (c) 2013-2025 Michael Barbour <[email protected] >
5
5
*
6
6
* Permission to use, copy, modify, and distribute this software for any
7
7
* purpose with or without fee is hereby granted, provided that the above
38
38
(((x) == 0) ? (in_codecs.head == NULL || input_mode == INPUT_MODE_SEQUENCE) ? DEFAULT_FS : in_codecs.head->fs : (x))
39
39
#define CHOOSE_INPUT_CHANNELS (x ) \
40
40
(((x) == 0) ? (in_codecs.head == NULL || input_mode == INPUT_MODE_SEQUENCE) ? DEFAULT_CHANNELS : in_codecs.head->channels : (x))
41
- #define SHOULD_DITHER (in , out , has_effects ) \
41
+ #define SHOULD_DITHER (in , out , chain_dither ) \
42
42
(force_dither != -1 && ((out)->hints & CODEC_HINT_CAN_DITHER) && \
43
- (force_dither == 1 || ((out)->prec < 24 && ((has_effects ) || (in)->prec > (out)->prec || !((in)->hints & CODEC_HINT_CAN_DITHER)))))
43
+ (force_dither == 1 || ((out)->prec < 24 && ((chain_dither ) || (in)->prec > (out)->prec || !((in)->hints & CODEC_HINT_CAN_DITHER)))))
44
44
#define TIME_FMT "%.2zd:%.2zd:%05.2lf"
45
45
#define TIME_FMT_ARGS (frames , fs ) \
46
46
((frames) != -1) ? (frames) / (fs) / 3600 : 0, \
@@ -625,6 +625,7 @@ static void handle_tstp(int is_paused)
625
625
if (init_out_codec(&out_p, &stream, -1, write_buf_blocks) == NULL) \
626
626
cleanup_and_exit(1); \
627
627
} \
628
+ chain_dither = effects_chain_needs_dither(&chain); \
628
629
} while (0)
629
630
630
631
#define REALLOC_BUFS \
@@ -639,7 +640,8 @@ static void handle_tstp(int is_paused)
639
640
640
641
int main (int argc , char * argv [])
641
642
{
642
- int is_paused = 0 , do_dither = 0 , chain_start , chain_argc , term_sig , err ;
643
+ int is_paused = 0 , do_dither = 0 , term_sig , err ;
644
+ int chain_start , chain_argc , chain_dither ;
643
645
int read_buf_blocks = 0 ;
644
646
double in_time = 0.0 ;
645
647
struct codec * c = NULL ;
@@ -753,11 +755,12 @@ int main(int argc, char *argv[])
753
755
int buf_len = 0 ;
754
756
REALLOC_BUFS ;
755
757
dither_mult = tpdf_dither_get_mult (out_codec -> prec );
758
+ chain_dither = effects_chain_needs_dither (& chain );
756
759
757
760
while (in_codecs .head != NULL ) {
758
761
ssize_t r , pos = 0 ;
759
762
int k = 0 ;
760
- do_dither = SHOULD_DITHER (in_codecs .head , out_codec , chain . head != NULL );
763
+ do_dither = SHOULD_DITHER (in_codecs .head , out_codec , chain_dither );
761
764
LOG_FMT (LL_VERBOSE , "info: dither %s" , (do_dither ) ? "on" : "off" );
762
765
print_io_info (in_codecs .head , LL_NORMAL , "input" );
763
766
print_progress (in_codecs .head , pos , is_paused , 1 );
@@ -826,7 +829,7 @@ int main(int argc, char *argv[])
826
829
}
827
830
else REOPEN_OUTPUT ;
828
831
REALLOC_BUFS ;
829
- do_dither = SHOULD_DITHER (in_codecs .head , out_codec , chain . head != NULL );
832
+ do_dither = SHOULD_DITHER (in_codecs .head , out_codec , chain_dither );
830
833
LOG_FMT (LL_VERBOSE , "info: dither %s" , (do_dither ) ? "on" : "off" );
831
834
break ;
832
835
case 'v' :
0 commit comments