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

James Almer jamrial at gmail.com
Mon Dec 16 00:49:41 EET 2019


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.

> +
> +    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;
>  }
> 



More information about the ffmpeg-devel mailing list