[Ffmpeg-cvslog] r5507 - trunk/libavcodec/flac.c
Michael Niedermayer
michaelni
Wed Jun 21 10:49:08 CEST 2006
Hi
On Wed, Jun 21, 2006 at 10:25:18AM +0200, Michael Niedermayer wrote:
> Hi
>
> On Wed, Jun 21, 2006 at 02:21:26AM +0200, lu_zero wrote:
> [...]
>
> >
> > +static inline int16_t shift_to_16_bits(int32_t data, int bps)
> > +{
> > + if (bps == 24) {
> > + return (data >> 8);
> > + } else if (bps == 20) {
> > + return (data >> 4);
> > + } else {
> > + return data;
> > + }
> > +}
> > +
>
> why not data >> (bps-16) ?
and some simplifications like in the attached patch (untested) could be
done too
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
-------------- next part --------------
Index: flac.c
===================================================================
--- flac.c (revision 5507)
+++ flac.c (working copy)
@@ -697,6 +697,17 @@
}
}
#else
+#define DECORRELATE(left, right)\
+ assert(s->channels == 2);\
+ for (i = 0; i < s->blocksize; i++)\
+ {\
+ int a= s->decoded[0][i];\
+ int b= s->decoded[1][i];\
+ *(samples++) = (left ) >> (16 - s->bps);\
+ *(samples++) = (right) >> (16 - s->bps);\
+ }\
+ break;
+
switch(s->decorrelation)
{
case INDEPENDENT:
@@ -707,45 +718,11 @@
}
break;
case LEFT_SIDE:
- assert(s->channels == 2);
- for (i = 0; i < s->blocksize; i++)
- {
- *(samples++) = shift_to_16_bits(s->decoded[0][i], s->bps);
- *(samples++) = shift_to_16_bits(s->decoded[0][i]
- - s->decoded[1][i], s->bps);
- }
- break;
+ DECORRELATE(a,a-b)
case RIGHT_SIDE:
- assert(s->channels == 2);
- for (i = 0; i < s->blocksize; i++)
- {
- *(samples++) = shift_to_16_bits(s->decoded[0][i]
- + s->decoded[1][i], s->bps);
- *(samples++) = shift_to_16_bits(s->decoded[1][i], s->bps);
- }
- break;
+ DECORRELATE(a+b,b)
case MID_SIDE:
- assert(s->channels == 2);
- for (i = 0; i < s->blocksize; i++)
- {
- int mid, side;
- mid = s->decoded[0][i];
- side = s->decoded[1][i];
-
-#if 1 //needs to be checked but IMHO it should be binary identical
- mid -= side>>1;
- *(samples++) = shift_to_16_bits(mid + side, s->bps);
- *(samples++) = shift_to_16_bits(mid, s->bps);
-#else
-
- mid <<= 1;
- if (side & 1)
- mid++;
- *(samples++) = (mid + side) >> 1;
- *(samples++) = (mid - side) >> 1;
-#endif
- }
- break;
+ DECORRELATE( (a-=b>>1) + b, a)
}
#endif
More information about the ffmpeg-cvslog
mailing list