* [FFmpeg-devel] [PATCH] avcodec/decode: Return EAGAIN instead of overwriting unused packet
@ 2023-07-09 23:36 Andreas Rheinhardt
2023-07-10 12:47 ` Anton Khirnov
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rheinhardt @ 2023-07-09 23:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Should fix #10457, a regression caused by
69516ab3e917a6e91d26e38d04183c60fd71cbab.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
I am not sure about this one. The problem is that avcodec_send_packet()
and avcodec_receive_frame() must not return EAGAIN at the same time.
If buffer_frame contains a frame when entering avcodec_send_packet(),
the next call to avcodec_receive_frame() will not return EAGAIN.
But is this actually guaranteed if buffer_pkt is not empty?
libavcodec/decode.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 269633ce10..6595c3ca34 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -666,6 +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);
+
av_packet_unref(avci->buffer_pkt);
if (avpkt && (avpkt->data || avpkt->side_data_elems)) {
ret = av_packet_ref(avci->buffer_pkt, avpkt);
--
2.34.1
_______________________________________________
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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: Return EAGAIN instead of overwriting unused packet
@ 2023-07-10 12:47 ` Anton Khirnov
2023-07-10 14:25 ` Andreas Rheinhardt
2023-07-10 19:05 ` Marton Balint
0 siblings, 2 replies; 4+ messages in thread
From: Anton Khirnov @ 2023-07-10 12:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
Quoting Andreas Rheinhardt (2023-07-10 01:36:41)
> Should fix #10457, a regression caused by
> 69516ab3e917a6e91d26e38d04183c60fd71cbab.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> I am not sure about this one. The problem is that avcodec_send_packet()
> and avcodec_receive_frame() must not return EAGAIN at the same time.
> If buffer_frame contains a frame when entering avcodec_send_packet(),
> the next call to avcodec_receive_frame() will not return EAGAIN.
> But is this actually guaranteed if buffer_pkt is not empty?
It's not guaranteed, but I believe the correct interpretation of the
"must not return EAGAIN at the same time" line is that
send->receive->send must make progress and not be 3x EAGAIN.
>
> libavcodec/decode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 269633ce10..6595c3ca34 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -666,6 +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);
> +
> av_packet_unref(avci->buffer_pkt);
This unref here becomes redundant.
Otherwise looks good, thanks.
--
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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: Return EAGAIN instead of overwriting unused packet
2023-07-10 12:47 ` Anton Khirnov
@ 2023-07-10 14:25 ` Andreas Rheinhardt
2023-07-10 19:05 ` Marton Balint
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2023-07-10 14:25 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Anton Khirnov:
> Quoting Andreas Rheinhardt (2023-07-10 01:36:41)
>> Should fix #10457, a regression caused by
>> 69516ab3e917a6e91d26e38d04183c60fd71cbab.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> I am not sure about this one. The problem is that avcodec_send_packet()
>> and avcodec_receive_frame() must not return EAGAIN at the same time.
>> If buffer_frame contains a frame when entering avcodec_send_packet(),
>> the next call to avcodec_receive_frame() will not return EAGAIN.
>> But is this actually guaranteed if buffer_pkt is not empty?
>
> It's not guaranteed, but I believe the correct interpretation of the
> "must not return EAGAIN at the same time" line is that
> send->receive->send must make progress and not be 3x EAGAIN.
>
>
>>
>> libavcodec/decode.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 269633ce10..6595c3ca34 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -666,6 +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);
>> +
>> av_packet_unref(avci->buffer_pkt);
>
> This unref here becomes redundant.
>
> Otherwise looks good, thanks.
>
Will apply with the unref removed.
- Andreas
_______________________________________________
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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: Return EAGAIN instead of overwriting unused packet
2023-07-10 12:47 ` Anton Khirnov
2023-07-10 14:25 ` Andreas Rheinhardt
@ 2023-07-10 19:05 ` Marton Balint
1 sibling, 0 replies; 4+ messages in thread
From: Marton Balint @ 2023-07-10 19:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, 10 Jul 2023, Anton Khirnov wrote:
> Quoting Andreas Rheinhardt (2023-07-10 01:36:41)
>> Should fix #10457, a regression caused by
>> 69516ab3e917a6e91d26e38d04183c60fd71cbab.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> I am not sure about this one. The problem is that avcodec_send_packet()
>> and avcodec_receive_frame() must not return EAGAIN at the same time.
>> If buffer_frame contains a frame when entering avcodec_send_packet(),
>> the next call to avcodec_receive_frame() will not return EAGAIN.
>> But is this actually guaranteed if buffer_pkt is not empty?
>
> It's not guaranteed, but I believe the correct interpretation of the
> "must not return EAGAIN at the same time" line is that
> send->receive->send must make progress and not be 3x EAGAIN.
I don't think that 2x EAGAIN is allowed, the docs says:
... the only guarantee is that an AVERROR(EAGAIN) return value on a
send/receive call on one end implies that a receive/send call on the other
end will succeed, or at least will not fail with AVERROR(EAGAIN). In
general, no codec will permit unlimited buffering of input or output.
Regards,
Marton
>
>
>>
>> libavcodec/decode.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 269633ce10..6595c3ca34 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -666,6 +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);
>> +
>> av_packet_unref(avci->buffer_pkt);
>
> This unref here becomes redundant.
>
> Otherwise looks good, thanks.
>
> --
> 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".
>
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2023-07-10 19:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-09 23:36 [FFmpeg-devel] [PATCH] avcodec/decode: Return EAGAIN instead of overwriting unused packet Andreas Rheinhardt
2023-07-10 12:47 ` Anton Khirnov
2023-07-10 14:25 ` Andreas Rheinhardt
2023-07-10 19:05 ` Marton Balint
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