Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty
@ 2023-07-12  2:06 James Almer
  2023-07-12  2:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it James Almer
  2023-07-12  9:06 ` [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty Anton Khirnov
  0 siblings, 2 replies; 9+ messages in thread
From: James Almer @ 2023-07-12  2:06 UTC (permalink / raw)
  To: ffmpeg-devel

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(-)

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;
-- 
2.41.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it
  2023-07-12  2:06 [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty James Almer
@ 2023-07-12  2:06 ` James Almer
  2023-07-12  9:08   ` Anton Khirnov
  2023-07-12  9:06 ` [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty Anton Khirnov
  1 sibling, 1 reply; 9+ messages in thread
From: James Almer @ 2023-07-12  2:06 UTC (permalink / raw)
  To: ffmpeg-devel

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

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 239ad70b41..cd49cca7c2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -242,7 +242,8 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
             (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
             ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
             if (ret < 0) {
-                av_packet_unref(avci->buffer_pkt);
+                if (ret != AVERROR(EAGAIN))
+                    av_packet_unref(avci->buffer_pkt);
                 return ret;
             }
 
-- 
2.41.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty
  2023-07-12  2:06 [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty James Almer
  2023-07-12  2:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it James Almer
@ 2023-07-12  9:06 ` Anton Khirnov
  2023-07-12 11:30   ` James Almer
  1 sibling, 1 reply; 9+ messages in thread
From: Anton Khirnov @ 2023-07-12  9:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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?

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it
  2023-07-12  2:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it James Almer
@ 2023-07-12  9:08   ` Anton Khirnov
  2023-07-12 11:40     ` James Almer
  0 siblings, 1 reply; 9+ messages in thread
From: Anton Khirnov @ 2023-07-12  9:08 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting James Almer (2023-07-12 04:06:44)
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/decode.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 239ad70b41..cd49cca7c2 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -242,7 +242,8 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
>              (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
>              ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
>              if (ret < 0) {
> -                av_packet_unref(avci->buffer_pkt);
> +                if (ret != AVERROR(EAGAIN))
> +                    av_packet_unref(avci->buffer_pkt);

It seems very wrong for ff_decode_get_packet() to return EAGAIN when
we have a buffered packet.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty
  2023-07-12  9:06 ` [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty Anton Khirnov
@ 2023-07-12 11:30   ` James Almer
  2023-07-12 13:28     ` Anton Khirnov
  0 siblings, 1 reply; 9+ messages in thread
From: James Almer @ 2023-07-12 11:30 UTC (permalink / raw)
  To: ffmpeg-devel

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?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it
  2023-07-12  9:08   ` Anton Khirnov
@ 2023-07-12 11:40     ` James Almer
  2023-07-12 13:32       ` Anton Khirnov
  0 siblings, 1 reply; 9+ messages in thread
From: James Almer @ 2023-07-12 11:40 UTC (permalink / raw)
  To: ffmpeg-devel

On 7/12/2023 6:08 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-07-12 04:06:44)
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/decode.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 239ad70b41..cd49cca7c2 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -242,7 +242,8 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
>>               (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
>>               ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
>>               if (ret < 0) {
>> -                av_packet_unref(avci->buffer_pkt);
>> +                if (ret != AVERROR(EAGAIN))
>> +                    av_packet_unref(avci->buffer_pkt);
> 
> It seems very wrong for ff_decode_get_packet() to return EAGAIN when
> we have a buffered packet.

The idea is preventing dropping a packet in the hypothetical case the 
bsf can't take it. Is this scenario possible, or is the call to 
av_bsf_receive_packet() within the loop ensuring it wont?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty
  2023-07-12 11:30   ` James Almer
@ 2023-07-12 13:28     ` Anton Khirnov
  0 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2023-07-12 13:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it
  2023-07-12 11:40     ` James Almer
@ 2023-07-12 13:32       ` Anton Khirnov
  2023-07-12 13:33         ` James Almer
  0 siblings, 1 reply; 9+ messages in thread
From: Anton Khirnov @ 2023-07-12 13:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting James Almer (2023-07-12 13:40:25)
> On 7/12/2023 6:08 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-07-12 04:06:44)
> >> Signed-off-by: James Almer <jamrial@gmail.com>
> >> ---
> >>   libavcodec/decode.c | 3 ++-
> >>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >> index 239ad70b41..cd49cca7c2 100644
> >> --- a/libavcodec/decode.c
> >> +++ b/libavcodec/decode.c
> >> @@ -242,7 +242,8 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
> >>               (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
> >>               ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
> >>               if (ret < 0) {
> >> -                av_packet_unref(avci->buffer_pkt);
> >> +                if (ret != AVERROR(EAGAIN))
> >> +                    av_packet_unref(avci->buffer_pkt);
> > 
> > It seems very wrong for ff_decode_get_packet() to return EAGAIN when
> > we have a buffered packet.
> 
> The idea is preventing dropping a packet in the hypothetical case the 
> bsf can't take it. Is this scenario possible, or is the call to 
> av_bsf_receive_packet() within the loop ensuring it wont?

This block can only be entered if decode_get_packet() returned EAGAIN,
which should always mean that the bsf is empty.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it
  2023-07-12 13:32       ` Anton Khirnov
@ 2023-07-12 13:33         ` James Almer
  0 siblings, 0 replies; 9+ messages in thread
From: James Almer @ 2023-07-12 13:33 UTC (permalink / raw)
  To: ffmpeg-devel

On 7/12/2023 10:32 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-07-12 13:40:25)
>> On 7/12/2023 6:08 AM, Anton Khirnov wrote:
>>> Quoting James Almer (2023-07-12 04:06:44)
>>>> Signed-off-by: James Almer <jamrial@gmail.com>
>>>> ---
>>>>    libavcodec/decode.c | 3 ++-
>>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>>>> index 239ad70b41..cd49cca7c2 100644
>>>> --- a/libavcodec/decode.c
>>>> +++ b/libavcodec/decode.c
>>>> @@ -242,7 +242,8 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
>>>>                (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
>>>>                ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
>>>>                if (ret < 0) {
>>>> -                av_packet_unref(avci->buffer_pkt);
>>>> +                if (ret != AVERROR(EAGAIN))
>>>> +                    av_packet_unref(avci->buffer_pkt);
>>>
>>> It seems very wrong for ff_decode_get_packet() to return EAGAIN when
>>> we have a buffered packet.
>>
>> The idea is preventing dropping a packet in the hypothetical case the
>> bsf can't take it. Is this scenario possible, or is the call to
>> av_bsf_receive_packet() within the loop ensuring it wont?
> 
> This block can only be entered if decode_get_packet() returned EAGAIN,
> which should always mean that the bsf is empty.

Right, patch dropped then.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-12 13:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12  2:06 [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty James Almer
2023-07-12  2:06 ` [FFmpeg-devel] [PATCH 2/2] avcodec/decode: don't discard the buffered packet if the underlying bsf can't take it James Almer
2023-07-12  9:08   ` Anton Khirnov
2023-07-12 11:40     ` James Almer
2023-07-12 13:32       ` Anton Khirnov
2023-07-12 13:33         ` James Almer
2023-07-12  9:06 ` [FFmpeg-devel] [PATCH 1/2] avcodec/decode: don't reject flush packets when buffer_pkt is not empty Anton Khirnov
2023-07-12 11:30   ` James Almer
2023-07-12 13:28     ` Anton Khirnov

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git