Mercurial > libavcodec.hg
changeset 1792:7da4bdafe42e libavcodec
use clip() from common.h
ignore sample_rate==8000 limit if strict_std_compliance < 0
author | michael |
---|---|
date | Sat, 07 Feb 2004 15:33:00 +0000 |
parents | 5e5c3d4a1e82 |
children | 11124a5d04f6 |
files | g726.c |
diffstat | 1 files changed, 10 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/g726.c Sat Feb 07 08:20:00 2004 +0000 +++ b/g726.c Sat Feb 07 15:33:00 2004 +0000 @@ -55,16 +55,6 @@ return (f1->sign ^ f2->sign) ? -res : res; } -static inline int clamp(int value, int min, int max) -{ - if (value < min) - return min; - else if (value > max) - return max; - else - return value; -} - static inline int sgn(int value) { return (value < 0) ? -1 : 1; @@ -220,12 +210,12 @@ c->b[i] = 0; } else { /* This is a bit crazy, but it really is +255 not +256 */ - fa1 = clamp((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255); + fa1 = clip((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255); c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7); - c->a[1] = clamp(c->a[1], -12288, 12288); + c->a[1] = clip(c->a[1], -12288, 12288); c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8); - c->a[0] = clamp(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]); + c->a[0] = clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]); for (i=0; i<6; i++) c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8); @@ -255,7 +245,7 @@ c->ap += (0x200 - c->ap) >> 4; /* Update Yu and Yl */ - c->yu = clamp(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120); + c->yu = clip(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120); c->yl += c->yu + ((-c->yl)>>6); /* Next iteration for Y */ @@ -271,7 +261,7 @@ c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]); c->se >>= 1; - return clamp(re_signal << 2, -0xffff, 0xffff); + return clip(re_signal << 2, -0xffff, 0xffff); } static int g726_reset(G726Context* c, int bit_rate) @@ -329,12 +319,16 @@ { AVG726Context* c = (AVG726Context*)avctx->priv_data; - if (avctx->sample_rate != 8000 || avctx->channels != 1 || + if (avctx->channels != 1 || (avctx->bit_rate != 16000 && avctx->bit_rate != 24000 && avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) { av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); return -1; } + if (avctx->sample_rate != 8000 && avctx->strict_std_compliance>=0) { + av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); + return -1; + } g726_reset(&c->c, avctx->bit_rate); c->code_size = c->c.tbls->bits; c->bit_buffer = 0;