From: "Kacper Michajłow" <kasper93@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: "Kacper Michajłow" <kasper93@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/sonic: remove dead code Date: Thu, 17 Jul 2025 01:57:03 +0200 Message-ID: <20250716235707.66547-2-kasper93@gmail.com> (raw) In-Reply-To: <20250716235707.66547-1-kasper93@gmail.com> This was in else branch of `#if 1` since ever. No need to keep dead code like that, if anyone needs it they can get it from git history. Signed-off-by: Kacper Michajłow <kasper93@gmail.com> --- libavcodec/sonic.c | 299 --------------------------------------------- 1 file changed, 299 deletions(-) diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 8b1d092ec9..acefbbdbfb 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -166,7 +166,6 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si } } -#if 1 static inline int intlist_write(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part) { int i; @@ -186,274 +185,6 @@ static inline int intlist_read(RangeCoder *c, uint8_t *state, int *buf, int entr return 1; } -#elif 1 -static inline int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - set_se_golomb(pb, buf[i]); - - return 1; -} - -static inline int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) -{ - int i; - - for (i = 0; i < entries; i++) - buf[i] = get_se_golomb(gb); - - return 1; -} - -#else - -#define ADAPT_LEVEL 8 - -static int bits_to_store(uint64_t x) -{ - int res = 0; - - while(x) - { - res++; - x >>= 1; - } - return res; -} - -static void write_uint_max(PutBitContext *pb, unsigned int value, unsigned int max) -{ - int i, bits; - - if (!max) - return; - - bits = bits_to_store(max); - - for (i = 0; i < bits-1; i++) - put_bits(pb, 1, value & (1 << i)); - - if ( (value | (1 << (bits-1))) <= max) - put_bits(pb, 1, value & (1 << (bits-1))); -} - -static unsigned int read_uint_max(GetBitContext *gb, int max) -{ - int i, bits, value = 0; - - if (!max) - return 0; - - bits = bits_to_store(max); - - for (i = 0; i < bits-1; i++) - if (get_bits1(gb)) - value += 1 << i; - - if ( (value | (1<<(bits-1))) <= max) - if (get_bits1(gb)) - value += 1 << (bits-1); - - return value; -} - -static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) -{ - int i, j, x = 0, low_bits = 0, max = 0; - int step = 256, pos = 0, dominant = 0, any = 0; - int *copy, *bits; - - copy = av_calloc(entries, sizeof(*copy)); - if (!copy) - return AVERROR(ENOMEM); - - if (base_2_part) - { - int energy = 0; - - for (i = 0; i < entries; i++) - energy += abs(buf[i]); - - low_bits = bits_to_store(energy / (entries * 2)); - if (low_bits > 15) - low_bits = 15; - - put_bits(pb, 4, low_bits); - } - - for (i = 0; i < entries; i++) - { - put_bits(pb, low_bits, abs(buf[i])); - copy[i] = abs(buf[i]) >> low_bits; - if (copy[i] > max) - max = abs(copy[i]); - } - - bits = av_calloc(entries*max, sizeof(*bits)); - if (!bits) - { - av_free(copy); - return AVERROR(ENOMEM); - } - - for (i = 0; i <= max; i++) - { - for (j = 0; j < entries; j++) - if (copy[j] >= i) - bits[x++] = copy[j] > i; - } - - // store bitstream - while (pos < x) - { - int steplet = step >> 8; - - if (pos + steplet > x) - steplet = x - pos; - - for (i = 0; i < steplet; i++) - if (bits[i+pos] != dominant) - any = 1; - - put_bits(pb, 1, any); - - if (!any) - { - pos += steplet; - step += step / ADAPT_LEVEL; - } - else - { - int interloper = 0; - - while (((pos + interloper) < x) && (bits[pos + interloper] == dominant)) - interloper++; - - // note change - write_uint_max(pb, interloper, (step >> 8) - 1); - - pos += interloper + 1; - step -= step / ADAPT_LEVEL; - } - - if (step < 256) - { - step = 65536 / step; - dominant = !dominant; - } - } - - // store signs - for (i = 0; i < entries; i++) - if (buf[i]) - put_bits(pb, 1, buf[i] < 0); - - av_free(bits); - av_free(copy); - - return 0; -} - -static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) -{ - int i, low_bits = 0, x = 0; - int n_zeros = 0, step = 256, dominant = 0; - int pos = 0, level = 0; - int *bits = av_calloc(entries, sizeof(*bits)); - - if (!bits) - return AVERROR(ENOMEM); - - if (base_2_part) - { - low_bits = get_bits(gb, 4); - - if (low_bits) - for (i = 0; i < entries; i++) - buf[i] = get_bits(gb, low_bits); - } - -// av_log(NULL, AV_LOG_INFO, "entries: %d, low bits: %d\n", entries, low_bits); - - while (n_zeros < entries) - { - int steplet = step >> 8; - - if (!get_bits1(gb)) - { - for (i = 0; i < steplet; i++) - bits[x++] = dominant; - - if (!dominant) - n_zeros += steplet; - - step += step / ADAPT_LEVEL; - } - else - { - int actual_run = read_uint_max(gb, steplet-1); - -// av_log(NULL, AV_LOG_INFO, "actual run: %d\n", actual_run); - - for (i = 0; i < actual_run; i++) - bits[x++] = dominant; - - bits[x++] = !dominant; - - if (!dominant) - n_zeros += actual_run; - else - n_zeros++; - - step -= step / ADAPT_LEVEL; - } - - if (step < 256) - { - step = 65536 / step; - dominant = !dominant; - } - } - - // reconstruct unsigned values - n_zeros = 0; - for (i = 0; n_zeros < entries; i++) - { - while(1) - { - if (pos >= entries) - { - pos = 0; - level += 1 << low_bits; - } - - if (buf[pos] >= level) - break; - - pos++; - } - - if (bits[i]) - buf[pos] += 1 << low_bits; - else - n_zeros++; - - pos++; - } - av_free(bits); - - // read signs - for (i = 0; i < entries; i++) - if (buf[i] && get_bits1(gb)) - buf[i] = -buf[i]; - -// av_log(NULL, AV_LOG_INFO, "zeros: %d pos: %d\n", n_zeros, pos); - - return 0; -} -#endif static void predictor_init_state(int *k, int *state, int order) { @@ -476,7 +207,6 @@ static int predictor_calc_error(int *k, int *state, int order, int error) { int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT); -#if 1 int *k_ptr = &(k[order-2]), *state_ptr = &(state[order-2]); for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) @@ -485,13 +215,6 @@ static int predictor_calc_error(int *k, int *state, int order, int error) x -= (unsigned)shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT); state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT); } -#else - for (i = order-2; i >= 0; i--) - { - x -= (unsigned)shift_down(k[i] * state[i], LATTICE_SHIFT); - state[i+1] = state[i] + shift_down(k[i] * x, LATTICE_SHIFT); - } -#endif // don't drift too far, to avoid overflows if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16); @@ -519,7 +242,6 @@ static void modified_levinson_durbin(int *window, int window_entries, { int step = (i+1)*channels, k, j; double xx = 0.0, xy = 0.0; -#if 1 int *x_ptr = &(window[step]); int *state_ptr = &(state[0]); j = window_entries - step; @@ -530,17 +252,6 @@ static void modified_levinson_durbin(int *window, int window_entries, xx += state_value*state_value; xy += x_value*state_value; } -#else - for (j = 0; j <= (window_entries - step); j++); - { - double stepval = window[step+j]; - double stateval = window[j]; -// xx += (double)window[j]*(double)window[j]; -// xy += (double)window[step+j]*(double)window[j]; - xx += stateval*stateval; - xy += stepval*stateval; - } -#endif if (xx == 0.0) k = 0; else @@ -554,7 +265,6 @@ static void modified_levinson_durbin(int *window, int window_entries, out[i] = k; k *= tap_quant[i]; -#if 1 x_ptr = &(window[step]); state_ptr = &(state[0]); j = window_entries - step; @@ -565,15 +275,6 @@ static void modified_levinson_durbin(int *window, int window_entries, *x_ptr = x_value + shift_down(k*state_value,LATTICE_SHIFT); *state_ptr = state_value + shift_down(k*x_value, LATTICE_SHIFT); } -#else - for (j=0; j <= (window_entries - step); j++) - { - int stepval = window[step+j]; - int stateval=state[j]; - window[step+j] += shift_down(k * stateval, LATTICE_SHIFT); - state[j] += shift_down(k * stepval, LATTICE_SHIFT); - } -#endif } } -- 2.50.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-07-16 23:59 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-07-16 23:57 [FFmpeg-devel] [PATCH 1/5] avformat/udp: avoid warning about always false comparision Kacper Michajłow 2025-07-16 23:57 ` Kacper Michajłow [this message] 2025-07-16 23:57 ` [FFmpeg-devel] [PATCH 3/5] avcodec/sonic: move code closer to use to avoid unused warnings Kacper Michajłow 2025-07-16 23:57 ` [FFmpeg-devel] [PATCH 4/5] swscale/lut3d: remove unused function Kacper Michajłow 2025-07-16 23:57 ` [FFmpeg-devel] [PATCH 5/5] avfilter/vaf_spectrumsynth: don't use uninitialized variable as scale Kacper Michajłow
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250716235707.66547-2-kasper93@gmail.com \ --to=kasper93@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git