Quoting Mark Thompson (2017-05-26 01:37:21)
> On 21/05/17 09:46, Anton Khirnov wrote:
> > Quoting Mark Thompson (2017-05-14 23:24:11)
> >> +
> >> +        start = end = 6;
> >> +        for (i = 0; i < count; i++) {
> >> +            size = AV_RB16(data + end) + 2;
> >> +            if (end + size > frag->data_size)
> >> +                return AVERROR_INVALIDDATA;
> >> +            end += size;
> >> +        }
> >> +        err = ff_h2645_packet_split(&packet, frag->data + start, end - 
> >> start,
> >> +                                    ctx, 1, 2, AV_CODEC_ID_H264);
> >> +        if (err < 0) {
> >> +            av_log(ctx, AV_LOG_ERROR, "Failed to split AVCC SPSs.\n");
> >> +            return err;
> >> +        }
> >> +
> >> +        err = cbs_h2645_fragment_add_nals(ctx, frag, &packet);
> >> +        ff_h2645_packet_uninit(&packet);
> > 
> > You could store the packet in the context and call uninit only once at
> > the end. It doesn't need to (and shouldn't) be called after every split.
> 
> Ah, right - you can keep splitting into the same packet structure and then 
> add all of the NAL units and uninit once at the end.  I didn't notice that.
> 
> Yeah, that would be nicer.  I don't see any reason why it shouldn't stay on 
> the stack, though.

I mean once per whole filter lifetime. That way you don't keep
allocating and freeing the RBSP buffer. And it's slightly safer against
leaks.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to