[FFmpeg-devel] [PATCH v1] avcodec/bsf: replace ctx->internal-> with in-> for better readability

Limin Wang lance.lmwang at gmail.com
Mon Dec 16 03:00:35 EET 2019


On Sun, Dec 15, 2019 at 07:49:41PM -0300, James Almer wrote:
> On 12/14/2019 12:03 PM, lance.lmwang at gmail.com wrote:
> > From: Limin Wang <lance.lmwang at gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> > ---
> >  libavcodec/bsf.c | 31 +++++++++++++++++--------------
> >  1 file changed, 17 insertions(+), 14 deletions(-)
> > 
> > diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> > index c1653cd..a5a5a03 100644
> > --- a/libavcodec/bsf.c
> > +++ b/libavcodec/bsf.c
> > @@ -175,9 +175,11 @@ int av_bsf_init(AVBSFContext *ctx)
> >  
> >  void av_bsf_flush(AVBSFContext *ctx)
> >  {
> > -    ctx->internal->eof = 0;
> > +    AVBSFInternal *in = ctx->internal;
> 
> in is used as input in the context of bsfs, so maybe bsfi instead? It's
> also more in line with names like avci for the internal field in
> AVCodecContext.

yes, for two following function have using in, so I follow the same style, 
it's preferalbe to use bsfi. I'll update the patch to change in to bsfi soon.

> 
> > +
> > +    in->eof = 0;
> >  
> > -    av_packet_unref(ctx->internal->buffer_pkt);
> > +    av_packet_unref(in->buffer_pkt);
> >  
> >      if (ctx->filter->flush)
> >          ctx->filter->flush(ctx);
> > @@ -185,26 +187,27 @@ void av_bsf_flush(AVBSFContext *ctx)
> >  
> >  int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
> >  {
> > +    AVBSFInternal *in = ctx->internal;
> >      int ret;
> >  
> >      if (!pkt || (!pkt->data && !pkt->side_data_elems)) {
> > -        ctx->internal->eof = 1;
> > +        in->eof = 1;
> >          return 0;
> >      }
> >  
> > -    if (ctx->internal->eof) {
> > +    if (in->eof) {
> >          av_log(ctx, AV_LOG_ERROR, "A non-NULL packet sent after an EOF.\n");
> >          return AVERROR(EINVAL);
> >      }
> >  
> > -    if (ctx->internal->buffer_pkt->data ||
> > -        ctx->internal->buffer_pkt->side_data_elems)
> > +    if (in->buffer_pkt->data ||
> > +        in->buffer_pkt->side_data_elems)
> >          return AVERROR(EAGAIN);
> >  
> >      ret = av_packet_make_refcounted(pkt);
> >      if (ret < 0)
> >          return ret;
> > -    av_packet_move_ref(ctx->internal->buffer_pkt, pkt);
> > +    av_packet_move_ref(in->buffer_pkt, pkt);
> >  
> >      return 0;
> >  }
> > @@ -222,16 +225,16 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
> >      if (in->eof)
> >          return AVERROR_EOF;
> >  
> > -    if (!ctx->internal->buffer_pkt->data &&
> > -        !ctx->internal->buffer_pkt->side_data_elems)
> > +    if (!in->buffer_pkt->data &&
> > +        !in->buffer_pkt->side_data_elems)
> >          return AVERROR(EAGAIN);
> >  
> >      tmp_pkt = av_packet_alloc();
> >      if (!tmp_pkt)
> >          return AVERROR(ENOMEM);
> >  
> > -    *pkt = ctx->internal->buffer_pkt;
> > -    ctx->internal->buffer_pkt = tmp_pkt;
> > +    *pkt = in->buffer_pkt;
> > +    in->buffer_pkt = tmp_pkt;
> >  
> >      return 0;
> >  }
> > @@ -243,11 +246,11 @@ int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
> >      if (in->eof)
> >          return AVERROR_EOF;
> >  
> > -    if (!ctx->internal->buffer_pkt->data &&
> > -        !ctx->internal->buffer_pkt->side_data_elems)
> > +    if (!in->buffer_pkt->data &&
> > +        !in->buffer_pkt->side_data_elems)
> >          return AVERROR(EAGAIN);
> >  
> > -    av_packet_move_ref(pkt, ctx->internal->buffer_pkt);
> > +    av_packet_move_ref(pkt, in->buffer_pkt);
> >  
> >      return 0;
> >  }
> > 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list