diff mbox series

[FFmpeg-devel,1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty

Message ID 20230712020644.22606-1-jamrial@gmail.com
State Accepted
Commit e6954fd087d4b36cae6834e2c6b423db604f569b
Headers show
Series [FFmpeg-devel,1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer July 12, 2023, 2:06 a.m. UTC
Restores the behavior pre commit a92dbeb9ae.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/decode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Anton Khirnov July 12, 2023, 9:06 a.m. UTC | #1
Quoting James Almer (2023-07-12 04:06:43)
> Restores the behavior pre commit a92dbeb9ae.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>

Do you see any advantage to this?
James Almer July 12, 2023, 11:30 a.m. UTC | #2
On 7/12/2023 6:06 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-07-12 04:06:43)
>> Restores the behavior pre commit a92dbeb9ae.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
> 
> Do you see any advantage to this?

Not returning an error when a flush packet is feed to the decoder. Why 
would the API force me to retrieve frames before i can tell it I'm not 
going to feed it any more packets?
Anton Khirnov July 12, 2023, 1:28 p.m. UTC | #3
Quoting James Almer (2023-07-12 13:30:30)
> On 7/12/2023 6:06 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-07-12 04:06:43)
> >> Restores the behavior pre commit a92dbeb9ae.
> >>
> >> Signed-off-by: James Almer <jamrial@gmail.com>
> > 
> > Do you see any advantage to this?
> 
> Not returning an error when a flush packet is feed to the decoder. Why 
> would the API force me to retrieve frames before i can tell it I'm not 
> going to feed it any more packets?

Right, I guess that makes sense.
We should document this behaviour explicitly though, if we're bothering
to maintain it.
diff mbox series

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a47abeca06..239ad70b41 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -666,10 +666,9 @@  int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
     if (avpkt && !avpkt->size && avpkt->data)
         return AVERROR(EINVAL);
 
-    if (!AVPACKET_IS_EMPTY(avci->buffer_pkt))
-        return AVERROR(EAGAIN);
-
     if (avpkt && (avpkt->data || avpkt->side_data_elems)) {
+        if (!AVPACKET_IS_EMPTY(avci->buffer_pkt))
+            return AVERROR(EAGAIN);
         ret = av_packet_ref(avci->buffer_pkt, avpkt);
         if (ret < 0)
             return ret;