diff mbox series

[FFmpeg-devel] avcodec/bsf: Use macro for packet is empty

Message ID 20200419192252.14405-1-andreas.rheinhardt@gmail.com
State Accepted
Commit ee593bff984bed20a35e2a98119d82a1bcf6d3bd
Headers show
Series [FFmpeg-devel] avcodec/bsf: Use macro for packet is empty | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 19, 2020, 7:22 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/bsf.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Anton Khirnov April 20, 2020, 1:21 p.m. UTC | #1
Quoting Andreas Rheinhardt (2020-04-19 21:22:52)
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/bsf.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 

Good idea
Andreas Rheinhardt April 20, 2020, 4:38 p.m. UTC | #2
Anton Khirnov:
> Quoting Andreas Rheinhardt (2020-04-19 21:22:52)
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavcodec/bsf.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
> 
> Good idea
> 
Applied, thanks.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index b9fc771a88..68fee82e0d 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -28,6 +28,8 @@ 
 #include "avcodec.h"
 #include "bsf.h"
 
+#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
+
 struct AVBSFInternal {
     AVPacket *buffer_pkt;
     int eof;
@@ -195,7 +197,7 @@  int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
     AVBSFInternal *bsfi = ctx->internal;
     int ret;
 
-    if (!pkt || (!pkt->data && !pkt->side_data_elems)) {
+    if (!pkt || IS_EMPTY(pkt)) {
         bsfi->eof = 1;
         return 0;
     }
@@ -205,8 +207,7 @@  int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
         return AVERROR(EINVAL);
     }
 
-    if (bsfi->buffer_pkt->data ||
-        bsfi->buffer_pkt->side_data_elems)
+    if (!IS_EMPTY(bsfi->buffer_pkt))
         return AVERROR(EAGAIN);
 
     ret = av_packet_make_refcounted(pkt);
@@ -230,8 +231,7 @@  int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
     if (bsfi->eof)
         return AVERROR_EOF;
 
-    if (!bsfi->buffer_pkt->data &&
-        !bsfi->buffer_pkt->side_data_elems)
+    if (IS_EMPTY(bsfi->buffer_pkt))
         return AVERROR(EAGAIN);
 
     tmp_pkt = av_packet_alloc();
@@ -251,8 +251,7 @@  int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
     if (bsfi->eof)
         return AVERROR_EOF;
 
-    if (!bsfi->buffer_pkt->data &&
-        !bsfi->buffer_pkt->side_data_elems)
+    if (IS_EMPTY(bsfi->buffer_pkt))
         return AVERROR(EAGAIN);
 
     av_packet_move_ref(pkt, bsfi->buffer_pkt);