Commit graph

13 commits

Author SHA1 Message Date
Jun Zhao
d25d6b991d 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 <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Jun Zhao
752faebaa6 doc/examples/vaapi_encode: open raw YUV input in binary mode
fopen() with "r" opens the file in text mode, which on Windows
translates \r\n to \n, corrupting raw NV12 pixel data. Use "rb"
to open in binary mode, matching the output file which already
uses "w+b".

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-18 02:08:09 +00:00
Zhao Zhili
09856e4e48 doc/examples/vaapi_encode: fix invalid check on fwrite
enc_pkt->size is 0 after av_packet_unref, which makes the check invalid.

Fix regression from 3e4bfff2.

Co-Authored-by: Jin Bo <jinbo@loongson.cn>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-08 20:43:07 +00:00
Michael Niedermayer
3e4bfff211
doc/examples/vaapi_encode: Try to check fwrite() for failure
Fixes: CID1604548 Unused value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-10 18:10:07 +02:00
Stefano Sabatini
34ff361921 examples: apply doxy entries consistency fixes
Use consistent format for the @file field and file description.
2023-02-11 17:49:01 +01:00
Andreas Rheinhardt
626535f6a1 avcodec/codec, allcodecs: Constify the AVCodec API
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:14 -03:00
James Almer
6394c7d51a doc/examples/vaapi_encode: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:37 -03:00
Anton Khirnov
f30a41a608 Stop hardcoding align=32 in av_frame_get_buffer() calls.
Use 0, which selects the alignment automatically.
2020-05-22 14:38:57 +02:00
Jun Zhao
5f090727ad doc/examples/vaapi_encode: re-licensed to MIT-license.
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-08-25 22:09:44 +08:00
Mark Thompson
10bcc41bb4 examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
Jun Zhao
9b955eece6 examples/vaapi_encode: Remove redundancy check when free context.
avcodec_free_context have handle NULL pointer case, so caller doesn't
need to check the NULL before call this function.

Signe-off-by: Jun Zhao <jun.zhao@intel.com>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-01-12 12:31:55 +01:00
Mark Thompson
a763d27827 examples/vaapi_encode: Fix leak on hwframe init failure
Fixes CID #1424882.
2017-12-01 21:12:45 +00:00
Jun Zhao
23db3a1ae6 examples: Add a VA-API encode example.
Supports only raw NV12 input.

Example use:
./vaapi_encode 1920 1080 test.yuv test.h264

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-11-28 22:14:07 +00:00