Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-11 Thread James Almer
On 8/11/2020 6:48 AM, Nicolas George wrote: > Andreas Rheinhardt (12020-08-11): >> Imagine the context to only contain elements that require a alignment of >> 4 and the internal structure to require an alignment of eight. Then it >> is perfectly possible for &ctx[1] to only have an alignment of fou

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-11 Thread zhilizhao
> On Aug 11, 2020, at 5:48 PM, Nicolas George wrote: > > Andreas Rheinhardt (12020-08-11): >> Imagine the context to only contain elements that require a alignment of >> 4 and the internal structure to require an alignment of eight. Then it >> is perfectly possible for &ctx[1] to only have an a

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-11 Thread Nicolas George
Andreas Rheinhardt (12020-08-11): > Imagine the context to only contain elements that require a alignment of > 4 and the internal structure to require an alignment of eight. Then it > is perfectly possible for &ctx[1] to only have an alignment of four and > not of eight as internal requires it. Wi

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread zhilizhao
> On Aug 11, 2020, at 8:14 AM, Andreas Rheinhardt > wrote: > > James Almer: >> On 8/10/2020 8:12 PM, Andreas Rheinhardt wrote: >>> James Almer: On 8/10/2020 7:11 PM, Nicolas George wrote: > James Almer (12020-08-10): >> Personally, i don't like it. It's extra complexity to save a

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread James Almer
On 8/10/2020 9:14 PM, Andreas Rheinhardt wrote: > James Almer: >> On 8/10/2020 8:12 PM, Andreas Rheinhardt wrote: >>> James Almer: On 8/10/2020 7:11 PM, Nicolas George wrote: > James Almer (12020-08-10): >> Personally, i don't like it. It's extra complexity to save a single 8 or >>

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Andreas Rheinhardt
James Almer: > On 8/10/2020 8:12 PM, Andreas Rheinhardt wrote: >> James Almer: >>> On 8/10/2020 7:11 PM, Nicolas George wrote: James Almer (12020-08-10): > Personally, i don't like it. It's extra complexity to save a single 8 or > 12 byte allocation that happens once during bsf alloc.

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread James Almer
On 8/10/2020 8:12 PM, Andreas Rheinhardt wrote: > James Almer: >> On 8/10/2020 7:11 PM, Nicolas George wrote: >>> James Almer (12020-08-10): Personally, i don't like it. It's extra complexity to save a single 8 or 12 byte allocation that happens once during bsf alloc. It's kind of a

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Andreas Rheinhardt
Andreas Rheinhardt: > James Almer: >> On 8/10/2020 7:11 PM, Nicolas George wrote: >>> James Almer (12020-08-10): Personally, i don't like it. It's extra complexity to save a single 8 or 12 byte allocation that happens once during bsf alloc. It's kind of a pointless micro-optimization

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Andreas Rheinhardt
James Almer: > On 8/10/2020 7:11 PM, Nicolas George wrote: >> James Almer (12020-08-10): >>> Personally, i don't like it. It's extra complexity to save a single 8 or >>> 12 byte allocation that happens once during bsf alloc. It's kind of a >>> pointless micro-optimization. >> >> I do not agree at a

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread James Almer
On 8/10/2020 7:34 PM, Nicolas George wrote: > James Almer (12020-08-10): >> It adds an extra struct and makes the code harder to read. Might as well >> just do >> >> ctx = av_mallocz(sizeof(*ctx) + sizeof(AVBSFInternal)); >> ctx->internal = &ctx[1]; > > This is exactly what the code does I know,

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Nicolas George
James Almer (12020-08-10): > It adds an extra struct and makes the code harder to read. Might as well > just do > > ctx = av_mallocz(sizeof(*ctx) + sizeof(AVBSFInternal)); > ctx->internal = &ctx[1]; This is exactly what the code does, except without the undefined behaviors, because what you just

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread James Almer
On 8/10/2020 7:11 PM, Nicolas George wrote: > James Almer (12020-08-10): >> Personally, i don't like it. It's extra complexity to save a single 8 or >> 12 byte allocation that happens once during bsf alloc. It's kind of a >> pointless micro-optimization. > > I do not agree at all. > > First, it i

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Nicolas George
Andreas Rheinhardt (12020-08-10): > by allocating it together with the AVBSFContext. > > Signed-off-by: Andreas Rheinhardt > --- > Similar things can of course be done with other structures. I did only > this one to see whether everyone is ok with this. I wholeheartedly approve. > libavcodec/

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Nicolas George
James Almer (12020-08-10): > Personally, i don't like it. It's extra complexity to save a single 8 or > 12 byte allocation that happens once during bsf alloc. It's kind of a > pointless micro-optimization. I do not agree at all. First, it is not extra complexity, it actually makes the code simple

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread James Almer
On 8/10/2020 10:55 AM, Andreas Rheinhardt wrote: > by allocating it together with the AVBSFContext. > > Signed-off-by: Andreas Rheinhardt > --- > Similar things can of course be done with other structures. I did only > this one to see whether everyone is ok with this. Personally, i don't like it

[FFmpeg-devel] [PATCH] avcodec/bsf: Avoid allocation for AVBSFInternal

2020-08-10 Thread Andreas Rheinhardt
by allocating it together with the AVBSFContext. Signed-off-by: Andreas Rheinhardt --- Similar things can of course be done with other structures. I did only this one to see whether everyone is ok with this. libavcodec/bsf.c | 25 + 1 file changed, 13 insertions(+), 12 d