On Thu, Apr 03, 2008 at 11:53:22PM +0200, Bartlomiej Wolowiec wrote: > On niedziela, 30 marca 2008, Michael Niedermayer wrote: > > Note, to add the header into the buffer calling ff_combine_frame() with > > END_NOT_FOUND and a smaller buffer size should work. > > > > After its in the buffer you just run the header decoder thing over the > > header and when you know the final frame size you call ff_combine_frame > > with appropriate next value. > > > > Anyway iam not insisting on you changing the current aac/ac3 parser to use > > ff_combine_frame() > > But what you will end up implementing will be quite similar in > > functionality to ff_combine_frame() > > > > [...] > > Hmm... > I tried to implement it using ff_combine_frame, but the code which I got is > in my opinion significantly worse. Main problems which I had: > -ff_combine_frame is rather adapted to using on one frame, when in buffer is > one frame and it currently reads the next one it isn't convenient (the whole > buffer size is not just a new frame's size, so that we should remember size > of earlier frames). > -in the genuine code there is > memmove(s->frame_start, s->frame_start + 1, s->header_size - 1); > s->frame_ptr--; > here we can operate on pc->buffer and pc->index (remembering also where the > new frame begins). However, surely it isn't the simpliest solution...
What i had in mind is below, this is blindly written and likely contains bugs.
I did spot one each time i looked at it :)
But it does not look fundamentally worse to me, it also has the advantage that
its not full of unneeded memcpys and memmoves.
while(s->remaining_size <= buf_size){
if(s->remaining_size && !s->need_next_header){
i= s->remaining_size;
s->remaining_size= 0;
goto output_frame;
}else{ //we need a header first
for(i=s->remaining_size; i<buf_size; i++){
ctx->state= (ctx->state<<8) + buf[i];
if((len=parse_header(ctx->state, &s->need_next_header,
&s->new_frame_start)))
break;
}
i-= header_size;
if(len>0){
s->remaining_size= len + i;
if(pc->index+i > 0 && s->new_frame_start){
s->remaining_size -= i; // remaining_size=len
output_frame:
ff_combine_frame(pc, i, &buf, &buf_size);
*poutbuf = buf;
*poutbuf_size = buf_size;
return i;
}
}else{
break;
}
}
}
ff_combine_frame(pc, END_NOT_FOUND, &buf, &buf_size);
s->remaining_size -= FFMIN(s->remaining_size, buf_size);
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
> Because of that I don't know what to do:
> -leave the code as it is,
> -use ff_combine_frame,
> -write new functions which will operate on the buffer (similar to
> ff_combine_frame, but adapted to the needs of aac_ac3_parser)?
Do what is simplest and fastest.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
signature.asc
Description: Digital signature
_______________________________________________ FFmpeg-soc mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
