[Ffmpeg-devel] Re: [PATCH] h264 muxing in mp4
Michael Niedermayer
michaelni
Fri Mar 10 13:30:16 CET 2006
Hi
On Tue, Mar 07, 2006 at 05:40:47PM +0100, Baptiste COUDURIER wrote:
[...]
>
> >> If anyone see a better or faster way to parse, it would be great.
> >
> >
> > 174795 dezicycles in find_startcode_v0 (your algo)
> > 90398 dezicycles in find_startcode_v1
> > 72391 dezicycles in find_startcode_v2 (generic)
> > 69425 dezicycles in find_startcode_v2 (endian)
>
> Is better, faster this way ?
iam fine with it, if loren has no objections then this can be applied
some comments below, just minor things, nothing important
[...]
> +static void avc_parse_nal_units(uint8_t **buf, int *size)
> +{
> + ByteIOContext pb;
> + uint8_t *p = *buf;
> + uint8_t *end = p + *size;
> + uint8_t *nal_start, *nal_end;
> +
> + url_open_dyn_buf(&pb);
> + nal_start = avc_find_startcode(p, end);
i would change avc_find_startcode so it outputs end instead of NULL if
nothing is found, that way the following code could be simplified like:
> + while (nal_start) {
while(nal_start < end) {
> + if (nal_start[2] == 1)
> + nal_start += 3;
> + else
> + nal_start += 4;
somehow my feeling tells me that
while(!*(nal_start++));
would be better but maybe its too hackisch (or even wrong ...)
> + nal_end = avc_find_startcode(nal_start, end);
> + if (nal_end) {
> + put_be32(&pb, nal_end - nal_start);
> + put_buffer(&pb, nal_start, nal_end - nal_start);
> + } else {
> + put_be32(&pb, end - nal_start);
> + put_buffer(&pb, nal_start, end - nal_start);
> + }
put_be32(&pb, nal_end - nal_start);
put_buffer(&pb, nal_start, nal_end - nal_start);
[...]
> @@ -1492,6 +1612,31 @@ static int mov_write_packet(AVFormatCont
> memcpy(trk->vosData, enc->extradata, trk->vosLen);
> }
>
> + if (enc->codec_id == CODEC_ID_H264) {
> + if (trk->vosLen == 0) {
> + if (!enc->extradata) {
> + /* bytestream h264 from avi */
> + /* will parse frame to get extradata when writing avcc */
> + /* XXX: parse all frames to get all sps, pps */
> + trk->vosLen = pkt->size;
> + trk->vosData = av_malloc(trk->vosLen);
> + memcpy(trk->vosData, pkt->data, trk->vosLen);
this isnt needed, code which extract global headers from the bitstream
is in the AVParser and is activated by -vglobal 1 on the cmd line
[...]
--
Michael
More information about the ffmpeg-devel
mailing list