[Ffmpeg-devel] [PATCH] support S302M streams in MPEG TS

Reimar Döffinger Reimar.Doeffinger
Tue Dec 12 20:48:27 CET 2006


Hello,
On Fri, Dec 01, 2006 at 11:58:21AM +0100, Baptiste Coudurier wrote:
> +static void s302m_subframe_20bit(S302MContext *s, const uint8_t *buf)
> +{
> +    /* reverse sample to suit big endian */
> +    s->outbuf_ptr[0] = ff_reverse[((buf[1] & 0x0f) << 4) | ((buf[2] & 0xf0) >> 4)];
> +    s->outbuf_ptr[1] = ff_reverse[((buf[0] & 0x0f) << 4) | ((buf[1] & 0xf0) >> 4)];
> +    s->outbuf_ptr[2] = ff_reverse[buf[0] & 0xf0];
> +    s->outbuf_ptr[3] = ff_reverse[((buf[4] & 0x0f) << 4) | ((buf[5] & 0xf0) >> 4)];
> +    s->outbuf_ptr[4] = ff_reverse[((buf[3] & 0x0f) << 4) | ((buf[4] & 0xf0) >> 4)];
> +    s->outbuf_ptr[5] = ff_reverse[buf[3] & 0xf0];
> +    s->outbuf_ptr += 6;
> +}

Simplification example:
uint32_t tmp = BE_32(buf);
tmp >>= 12;
s->outbuf_ptr[0] = ff_reverse[tmp & 0xff];
tmp >>= 8;
s->outbuf_ptr[1] = ff_reverse[tmp & 0xff];
s->outbuf_ptr[2] = ff_reverse[tmp >> 8];
tmp = BE_32(&buf[3]);
...

Or even just doing ff_reverse before all the bit shifting should help.
Also, though not important, the bits in e.g. buf[2] & 0x0f seem to
contain some data, too (synchronization info or some such).

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list