[MPlayer-dev-eng] [PATCH] [TEST AFILTER] Encode ac3 at runtime using lavc

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 20 19:14:28 CET 2007


[...]
> +        if (data->format != AF_FORMAT_S16_LE
> +                && data->format != AF_FORMAT_S16_BE) {
> +            af_msg(AF_MSG_ERROR, "af_lavcac3enc only supports s16le or s16be "
> +                   "input, current input: %s.", af_fmt2str_short(data->format));
> +            return AF_ERROR;
> +        }

No, your filter only supports AF_FORMAT_S16_NE, do not claim otherwise,
and more importantly, never, never, never, never, ever add your own
format conversion in the filter.
In addition AF_ERROR is the wrong return value for a format mismatch.
Just use af_test_output, and see af_lavcresample for how to use it if
input != output.

> +            if (c->format != AF_FORMAT_S16_NE)
> +                swab(s->pending_data, s->pending_data, s->expect_len);

As said before: evil.

[...]
> +        if (s->add_iec61937_header) {
> +            int16_t *out = (int16_t *)buf;
> +            out[0] = 0xF872;   // iec 61937 syncword 1
> +            out[1] = 0x4E1F;   // iec 61937 syncword 2
> +            out[2] = 0x0001;   // data-type ac3
> +            out[2] |= (buf[8+5] & 0x7) << 8; // bsmod
> +            out[3] = len << 3; // number of bits in payload
> +
> +#ifndef WORDS_BIGENDIAN
> +            swab(buf + 8, buf + 8, len);
> +            if (len & 1) {
> +                buf[8+len] = buf[8+len-1];
> +                buf[8+len-1] = 0;
> +                len++;
> +            }
> +#endif

Maybe better wait for AC3 endianness patch?
Btw. do you have any documentation that guarantees that you may call
swab with dst == src? As I read the man page, you actually may not
(though it is not explicit).

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list