diff mbox

[FFmpeg-devel,v2] avcodec/bsf: replace ctx->internal-> with bsfi-> for better readability

Message ID 20191216050149.2235-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Limin Wang Dec. 16, 2019, 5:01 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/bsf.c | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

Comments

Limin Wang Jan. 4, 2020, 4:08 p.m. UTC | #1
ping?

On Mon, Dec 16, 2019 at 01:01:49PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/bsf.c | 49 +++++++++++++++++++++++++++----------------------
>  1 file changed, 27 insertions(+), 22 deletions(-)
> 
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index c1653cd..c6dce93 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -82,6 +82,7 @@ const AVClass *av_bsf_get_class(void)
>  int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
>  {
>      AVBSFContext *ctx;
> +    AVBSFInternal *bsfi;
>      int ret;
>  
>      ctx = av_mallocz(sizeof(*ctx));
> @@ -98,14 +99,15 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
>          goto fail;
>      }
>  
> -    ctx->internal = av_mallocz(sizeof(*ctx->internal));
> -    if (!ctx->internal) {
> +    bsfi = av_mallocz(sizeof(*bsfi));
> +    if (!bsfi) {
>          ret = AVERROR(ENOMEM);
>          goto fail;
>      }
> +    ctx->internal = bsfi;
>  
> -    ctx->internal->buffer_pkt = av_packet_alloc();
> -    if (!ctx->internal->buffer_pkt) {
> +    bsfi->buffer_pkt = av_packet_alloc();
> +    if (!bsfi->buffer_pkt) {
>          ret = AVERROR(ENOMEM);
>          goto fail;
>      }
> @@ -175,9 +177,11 @@ int av_bsf_init(AVBSFContext *ctx)
>  
>  void av_bsf_flush(AVBSFContext *ctx)
>  {
> -    ctx->internal->eof = 0;
> +    AVBSFInternal *bsfi = ctx->internal;
>  
> -    av_packet_unref(ctx->internal->buffer_pkt);
> +    bsfi->eof = 0;
> +
> +    av_packet_unref(bsfi->buffer_pkt);
>  
>      if (ctx->filter->flush)
>          ctx->filter->flush(ctx);
> @@ -185,26 +189,27 @@ void av_bsf_flush(AVBSFContext *ctx)
>  
>  int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
>  {
> +    AVBSFInternal *bsfi = ctx->internal;
>      int ret;
>  
>      if (!pkt || (!pkt->data && !pkt->side_data_elems)) {
> -        ctx->internal->eof = 1;
> +        bsfi->eof = 1;
>          return 0;
>      }
>  
> -    if (ctx->internal->eof) {
> +    if (bsfi->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 (bsfi->buffer_pkt->data ||
> +        bsfi->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(bsfi->buffer_pkt, pkt);
>  
>      return 0;
>  }
> @@ -216,38 +221,38 @@ int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
>  
>  int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
>  {
> -    AVBSFInternal *in = ctx->internal;
> +    AVBSFInternal *bsfi = ctx->internal;
>      AVPacket *tmp_pkt;
>  
> -    if (in->eof)
> +    if (bsfi->eof)
>          return AVERROR_EOF;
>  
> -    if (!ctx->internal->buffer_pkt->data &&
> -        !ctx->internal->buffer_pkt->side_data_elems)
> +    if (!bsfi->buffer_pkt->data &&
> +        !bsfi->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 = bsfi->buffer_pkt;
> +    bsfi->buffer_pkt = tmp_pkt;
>  
>      return 0;
>  }
>  
>  int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
>  {
> -    AVBSFInternal *in = ctx->internal;
> +    AVBSFInternal *bsfi = ctx->internal;
>  
> -    if (in->eof)
> +    if (bsfi->eof)
>          return AVERROR_EOF;
>  
> -    if (!ctx->internal->buffer_pkt->data &&
> -        !ctx->internal->buffer_pkt->side_data_elems)
> +    if (!bsfi->buffer_pkt->data &&
> +        !bsfi->buffer_pkt->side_data_elems)
>          return AVERROR(EAGAIN);
>  
> -    av_packet_move_ref(pkt, ctx->internal->buffer_pkt);
> +    av_packet_move_ref(pkt, bsfi->buffer_pkt);
>  
>      return 0;
>  }
> -- 
> 2.9.5
>
Michael Niedermayer Jan. 4, 2020, 7:59 p.m. UTC | #2
On Mon, Dec 16, 2019 at 01:01:49PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/bsf.c | 49 +++++++++++++++++++++++++++----------------------
>  1 file changed, 27 insertions(+), 22 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index c1653cd..c6dce93 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -82,6 +82,7 @@  const AVClass *av_bsf_get_class(void)
 int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
 {
     AVBSFContext *ctx;
+    AVBSFInternal *bsfi;
     int ret;
 
     ctx = av_mallocz(sizeof(*ctx));
@@ -98,14 +99,15 @@  int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
         goto fail;
     }
 
-    ctx->internal = av_mallocz(sizeof(*ctx->internal));
-    if (!ctx->internal) {
+    bsfi = av_mallocz(sizeof(*bsfi));
+    if (!bsfi) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
+    ctx->internal = bsfi;
 
-    ctx->internal->buffer_pkt = av_packet_alloc();
-    if (!ctx->internal->buffer_pkt) {
+    bsfi->buffer_pkt = av_packet_alloc();
+    if (!bsfi->buffer_pkt) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
@@ -175,9 +177,11 @@  int av_bsf_init(AVBSFContext *ctx)
 
 void av_bsf_flush(AVBSFContext *ctx)
 {
-    ctx->internal->eof = 0;
+    AVBSFInternal *bsfi = ctx->internal;
 
-    av_packet_unref(ctx->internal->buffer_pkt);
+    bsfi->eof = 0;
+
+    av_packet_unref(bsfi->buffer_pkt);
 
     if (ctx->filter->flush)
         ctx->filter->flush(ctx);
@@ -185,26 +189,27 @@  void av_bsf_flush(AVBSFContext *ctx)
 
 int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
 {
+    AVBSFInternal *bsfi = ctx->internal;
     int ret;
 
     if (!pkt || (!pkt->data && !pkt->side_data_elems)) {
-        ctx->internal->eof = 1;
+        bsfi->eof = 1;
         return 0;
     }
 
-    if (ctx->internal->eof) {
+    if (bsfi->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 (bsfi->buffer_pkt->data ||
+        bsfi->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(bsfi->buffer_pkt, pkt);
 
     return 0;
 }
@@ -216,38 +221,38 @@  int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
 
 int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
 {
-    AVBSFInternal *in = ctx->internal;
+    AVBSFInternal *bsfi = ctx->internal;
     AVPacket *tmp_pkt;
 
-    if (in->eof)
+    if (bsfi->eof)
         return AVERROR_EOF;
 
-    if (!ctx->internal->buffer_pkt->data &&
-        !ctx->internal->buffer_pkt->side_data_elems)
+    if (!bsfi->buffer_pkt->data &&
+        !bsfi->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 = bsfi->buffer_pkt;
+    bsfi->buffer_pkt = tmp_pkt;
 
     return 0;
 }
 
 int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
 {
-    AVBSFInternal *in = ctx->internal;
+    AVBSFInternal *bsfi = ctx->internal;
 
-    if (in->eof)
+    if (bsfi->eof)
         return AVERROR_EOF;
 
-    if (!ctx->internal->buffer_pkt->data &&
-        !ctx->internal->buffer_pkt->side_data_elems)
+    if (!bsfi->buffer_pkt->data &&
+        !bsfi->buffer_pkt->side_data_elems)
         return AVERROR(EAGAIN);
 
-    av_packet_move_ref(pkt, ctx->internal->buffer_pkt);
+    av_packet_move_ref(pkt, bsfi->buffer_pkt);
 
     return 0;
 }