[MPlayer-dev-eng] [PATCH] [TEST AFILTER] Encode ac3 at runtime using lavc
Ulion
ulion2002 at gmail.com
Wed Nov 21 10:13:38 CET 2007
2007/11/21, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> [...]
> > + 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.
I got it.
>
> > + if (c->format != AF_FORMAT_S16_NE)
> > + swab(s->pending_data, s->pending_data, s->expect_len);
>
> As said before: evil.
Removed.
>
> [...]
> > + 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?
That patch is not the end, and also can be applied in the future. Let
me explain:
The real AC3 format not include iec 61937 header and padding zeroes,
with a 61937 header, the format should be IEC61937 or SPDIF I think.
So the current AC-3 stuff totally need refixed.
If you agree introduce format IEC61937 or SPDIF? (which should also
has le,be,ne), and can be combined with AC3/EAC3, DTS, AAC, WMA PRO,
MPEG, etc as the format flag. That make sence,
and will be a proper format fix more than the current ac3 endian
patch. But it can be added later since without it currently everything
works fine and the patch will huge and slow commited.
> 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).
No, I don't, but I used it since it simple and works on my machine,
but fortunately we can remove it.
Here's the fixed version, also add support selection the sample rate.
--
Ulion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: af_lavcac3enc8.diff
Type: text/x-diff
Size: 13871 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20071121/88d9c950/attachment.diff>
More information about the MPlayer-dev-eng
mailing list