[Ffmpeg-devel] [PATCH] DTS decoder

Kostya kostya.shishkov
Tue Feb 27 07:31:27 CET 2007


On Tue, Feb 27, 2007 at 01:10:13AM +0100, Michael Niedermayer wrote:
> Hi
 
[...]
> > +    uint32_t state;
> > +    ParseContext *pc = &pc1->pc;
> > +
> > +    start_found = pc->frame_start_found;
> > +    state = pc->state;
> > +
> > +    i = 0;
> > +    if (!start_found) {
> > +        for (i = 0; i < buf_size; i++) {
> > +            state = (state << 8) | buf[i];
> > +            if (IS_MARKER(state, i, buf, buf_size)) {
> > +                if (pc1->lastmarker && state == pc1->lastmarker) {
> 
> the pc1->lastmarker check is useless state == pc1->lastmarker is enough

In the beginning parser does not know what kind of stream it will get.
I set lastmarker with the first kind of marker met and use it as reference
(because other type of markers may also occur which result in broken
frames otherwise).
Also marker size may be 5.5 bytes for escaped streams so parser needs to
check additional bytes in case of such marker.
 
> > +                    start_found = 1;
> > +                    break;
> > +                } else if (!pc1->lastmarker) {
> > +                    start_found = 1;
> > +                    pc1->lastmarker = state;
> > +                    break;
> > +                }
> > +            }
> > +        }
> > +    }
> > +    if (start_found) {
> > +        for (; i < buf_size; i++) {
> > +            state = (state << 8) | buf[i];
> > +            if (IS_MARKER(state, i, buf, buf_size)
> > +                && state == pc1->lastmarker) {
> > +                pc->frame_start_found = 0;
> > +                pc->state = -1;
> > +                return i - 3;
> > +            }
> 
> wont if(state == pc1->lastmarker) do?
> exceuting the whole IS_MARKER() check per byte is slow

swapped so it will check lastmarker first and then IS_MARKER()

> besides these iam fine with the patch

committed

> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> If you really think that XML is the answer, then you definitly missunderstood
> the question -- Attila Kinali






More information about the ffmpeg-devel mailing list