Files
FFmpeg/libavcodec/tests/hw_base_encode.c
T
Michael Niedermayer 39bf2a1cfb avcodec/tests: cover hardware encoder timestamp fixup at EOF
Exercise empty input and short streams around the decode delay without requiring hardware. Print results for FATE comparison, including the EOF state and timestamp difference.

Assisted-by: Fairy
2026-11-03 17:19:41 +00:00

50 lines
1.6 KiB
C

/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include "libavcodec/hw_base_encode.c"
int main(void)
{
AVCodecContext avctx = { 0 };
for (int delay = 0; delay <= 3; delay++) {
for (int count = 0; count <= 4; count++) {
FFHWBaseEncodePicture pic = { 0 };
FFHWBaseEncodeContext ctx = { 0 };
int ret;
ctx.decode_delay = delay;
ctx.input_order = count;
ctx.first_pts = 100;
if (count) {
pic.pts = ctx.first_pts + 10 * (count - 1);
ctx.pic_end = &pic;
}
if (count > delay)
ctx.dts_pts_diff = 10 * delay;
ret = hw_base_encode_send_frame(&avctx, &ctx, NULL);
printf("delay=%d frames=%d return=%d eof=%d pts_diff=%"PRId64"\n",
delay, count, ret, ctx.end_of_stream, ctx.dts_pts_diff);
}
}
return 0;
}