This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit d25d6b991d0808856bc5803896739fc620ea0600
Author:     Jun Zhao <[email protected]>
AuthorDate: Mon Mar 9 08:42:56 2026 +0800
Commit:     toots <[email protected]>
CommitDate: Wed Mar 18 02:08:09 2026 +0000

    doc/examples/vaapi_encode: return raw error codes from encode_write
    
    encode_write() mapped all return values from avcodec_receive_packet()
    into 0 or -1, which destroyed the AVERROR_EOF signal needed by the
    caller. The flush call in main() could never see AVERROR_EOF, so a
    successful encode always exited with a non-zero status.
    
    Let encode_write() return the original error code and have each
    call site handle the expected status:
    
      - Encoding loop: ignore AVERROR(EAGAIN) (need more input)
      - Flush path:    ignore AVERROR_EOF (normal end-of-stream)
    
    This makes the control flow explicit and easier to follow for
    anyone reading the example.
    
    Signed-off-by: Jun Zhao <[email protected]>
---
 doc/examples/vaapi_encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/examples/vaapi_encode.c b/doc/examples/vaapi_encode.c
index d4381776ca..a27bb03da2 100644
--- a/doc/examples/vaapi_encode.c
+++ b/doc/examples/vaapi_encode.c
@@ -96,7 +96,6 @@ static int encode_write(AVCodecContext *avctx, AVFrame 
*frame, FILE *fout)
 
 end:
     av_packet_free(&enc_pkt);
-    ret = ((ret == AVERROR(EAGAIN)) ? 0 : -1);
     return ret;
 }
 
@@ -198,7 +197,8 @@ int main(int argc, char *argv[])
             goto close;
         }
 
-        if ((err = (encode_write(avctx, hw_frame, fout))) < 0) {
+        err = encode_write(avctx, hw_frame, fout);
+        if (err != AVERROR(EAGAIN) && err < 0) {
             fprintf(stderr, "Failed to encode.\n");
             goto close;
         }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to