PR #26323 opened by Pu Cheng (GeekQAQ) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26323 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26323.patch
Signed-off-by: Pu Cheng <[email protected]> >From 11259832460bb4806b75181001239df7defec7f6 Mon Sep 17 00:00:00 2001 From: Pu Cheng <[email protected]> Date: Wed, 25 Nov 2026 00:36:16 +0800 Subject: [PATCH 1/3] avcodec/mpeg4videodec: switch every frame thread to the Xvid IDCT ff_mpeg4_workaround_bugs() switches to the Xvid IDCT if the stream is identified as Xvid and avctx->idct_algo is FF_IDCT_AUTO. With frame threading, idct_algo is copied from the previous thread, but the IDCT functions are only copied on the first use of a thread. So if the identification is not found in the first frame, only the thread that found it switches; the others see idct_algo already set and keep their IDCT. Remember in each context which IDCT it uses. Signed-off-by: Pu Cheng <[email protected]> --- libavcodec/mpeg4videodec.c | 16 +++++++++++----- libavcodec/mpeg4videodec.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 03b145379df..16d7e68f722 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3622,14 +3622,16 @@ static av_cold void permute_quant_matrix(uint16_t matrix[64], matrix[new_perm[i]] = tmp[old_perm[i]]; } -static av_cold void switch_to_xvid_idct(AVCodecContext *const avctx, - H263DecContext *const h) +static av_cold void set_idct_algo(AVCodecContext *const avctx, + Mpeg4DecContext *const ctx, int idct_algo) { + H263DecContext *const h = &ctx->h; uint8_t old_permutation[64]; memcpy(old_permutation, h->c.idsp.idct_permutation, sizeof(old_permutation)); - avctx->idct_algo = FF_IDCT_XVID; + avctx->idct_algo = idct_algo; + ctx->xvid_idct = idct_algo == FF_IDCT_XVID; ff_mpv_idct_init(&h->c); ff_permute_scantable(h->permutated_intra_h_scantable, h->c.alternate_scan ? ff_alternate_vertical_scan : ff_alternate_horizontal_scan, @@ -3749,9 +3751,11 @@ void ff_mpeg4_workaround_bugs(AVCodecContext *avctx) h->c.workaround_bugs, ctx->lavc_build, ctx->xvid_build, ctx->divx_version, ctx->divx_build, h->divx_packed ? "p" : ""); + /* With frame threading, avctx->idct_algo is copied from the previous + * thread, so it does not tell which IDCT this context uses. */ if (ctx->xvid_build >= 0 && - avctx->idct_algo == FF_IDCT_AUTO && !h->c.studio_profile) { - switch_to_xvid_idct(avctx, h); + ctx->idct_auto && !ctx->xvid_idct && !h->c.studio_profile) { + set_idct_algo(avctx, ctx, FF_IDCT_XVID); } } @@ -3903,6 +3907,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, ret = update_mpvctx(&s->h.c, &s1->h.c); if (ret < 0) return ret; + s->xvid_idct = s1->xvid_idct; // goes with h.c.idsp } ret = ff_mpeg_update_thread_context(dst, src); @@ -4020,6 +4025,7 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->divx_build = ctx->xvid_build = ctx->lavc_build = -1; + ctx->idct_auto = avctx->idct_algo == FF_IDCT_AUTO; if ((ret = ff_h263_decode_init(avctx)) < 0) return ret; diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 2eafa1ef8be..74494be553f 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -75,6 +75,8 @@ typedef struct Mpeg4DecContext { int divx_build; int xvid_build; int lavc_build; + int idct_auto; ///< the user left the choice of the IDCT to us + int xvid_idct; ///< h.c.idsp has been switched to the Xvid IDCT /// Divx 5.01 puts several frames in a single one, this is used to reorder them AVBufferRef *bitstream_buffer; -- 2.54.1 >From 15000ffba377ce9c9dcdd1a34dcefd9dd24fa25d Mon Sep 17 00:00:00 2001 From: Pu Cheng <[email protected]> Date: Wed, 25 Nov 2026 00:36:16 +0800 Subject: [PATCH 2/3] avcodec/mpeg4videodec: do not keep the encoder workarounds on flush The decoder reads the encoder identification (divx_version, xvid_build, lavc_build etc.) from the user data, and ff_mpeg4_workaround_bugs() derives bits of workaround_bugs, the old qpel functions, the edge positions and the Xvid IDCT from it. All of this was only ever added to and never undone, so after avcodec_flush_buffers() another stream was decoded with the workarounds for the encoder of the previous one, even if it identified its own encoder: after a stream from Xvid, one from libavcodec was decoded with the Xvid IDCT. Undo the derived state in mpeg4_flush(); it is set up again before the next frame if it is still needed. Forget the identification at the first headers after the flush, except for what the extradata says. It is not forgotten in the flush itself because a seek in the same stream may end up at a packet without headers. padding_bug_score and FF_BUG_NO_PADDING are not touched. Signed-off-by: Pu Cheng <[email protected]> --- libavcodec/mpeg4videodec.c | 43 ++++++++++++++++++++++++++++++++++++++ libavcodec/mpeg4videodec.h | 5 +++++ 2 files changed, 48 insertions(+) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 16d7e68f722..5e0a088b6c2 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3441,6 +3441,15 @@ static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb) return 0; } +static void reset_encoder_id(Mpeg4DecContext *ctx) +{ + ctx->divx_version = ctx->init_id.divx_version; + ctx->divx_build = ctx->init_id.divx_build; + ctx->xvid_build = ctx->init_id.xvid_build; + ctx->lavc_build = ctx->init_id.lavc_build; + ctx->h.divx_packed = ctx->init_id.divx_packed; +} + /** * Decode MPEG-4 headers. * @@ -3556,6 +3565,12 @@ int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb, startcode, name, get_bits_count(gb)); } + /* The first headers after a flush may belong to another stream. */ + if (ctx->flushed && (startcode <= 0x12F || startcode == VOS_STARTCODE)) { + reset_encoder_id(ctx); + ctx->flushed = 0; + } + if (startcode >= 0x120 && startcode <= 0x12F) { if (vol) { av_log(s->avctx, AV_LOG_WARNING, "Ignoring multiple VOL headers\n"); @@ -3611,6 +3626,12 @@ end: } #if CONFIG_MPEG4_DECODER +/* the bugs that ff_mpeg4_workaround_bugs() detects from the user data */ +#define ENCODER_ID_BUGS (FF_BUG_QPEL_CHROMA | FF_BUG_QPEL_CHROMA2 | \ + FF_BUG_STD_QPEL | FF_BUG_DIRECT_BLOCKSIZE | \ + FF_BUG_EDGE | FF_BUG_HPEL_CHROMA | \ + FF_BUG_DC_CLIP | FF_BUG_IEDGE) + static av_cold void permute_quant_matrix(uint16_t matrix[64], const uint8_t new_perm[64], const uint8_t old_perm[64]) @@ -3935,6 +3956,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, s->divx_build = s1->divx_build; s->xvid_build = s1->xvid_build; s->lavc_build = s1->lavc_build; + s->init_id = s1->init_id; + s->flushed = s1->flushed; s->vo_type = s1->vo_type; s->showed_packed_warning = s1->showed_packed_warning; s->vol_control_parameters = s1->vol_control_parameters; @@ -4064,12 +4087,32 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_mpeg4_parse_picture_header(ctx, &gb, 1, 0); } + ctx->init_id.divx_version = ctx->divx_version; + ctx->init_id.divx_build = ctx->divx_build; + ctx->init_id.xvid_build = ctx->xvid_build; + ctx->init_id.lavc_build = ctx->lavc_build; + ctx->init_id.divx_packed = h->divx_packed; + return 0; } static av_cold void mpeg4_flush(AVCodecContext *avctx) { Mpeg4DecContext *const ctx = avctx->priv_data; + H263DecContext *const h = &ctx->h; + + /* Undo what ff_mpeg4_workaround_bugs() derived from the encoder + * identification. It is called again before the next frame is decoded; + * the identification itself is kept until the next headers, as a seek + * need not end up at a packet that repeats it. */ + h->c.workaround_bugs = (h->c.workaround_bugs & ~ENCODER_ID_BUGS) | + (avctx->workaround_bugs & ENCODER_ID_BUGS); + h->c.h_edge_pos = h->c.mb_width * 16; + h->c.v_edge_pos = h->c.mb_height * 16; + ff_qpeldsp_init(&h->c.qdsp); + if (ctx->idct_auto && avctx->idct_algo != FF_IDCT_AUTO) + set_idct_algo(avctx, ctx, FF_IDCT_AUTO); + ctx->flushed = 1; av_buffer_unref(&ctx->bitstream_buffer); ff_mpeg_flush(avctx); diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 74494be553f..d7d1132ad74 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -75,6 +75,11 @@ typedef struct Mpeg4DecContext { int divx_build; int xvid_build; int lavc_build; + /// the above and divx_packed as found in the extradata + struct { + int divx_version, divx_build, xvid_build, lavc_build, divx_packed; + } init_id; + int flushed; ///< flushed, and no headers seen since then int idct_auto; ///< the user left the choice of the IDCT to us int xvid_idct; ///< h.c.idsp has been switched to the Xvid IDCT /// Divx 5.01 puts several frames in a single one, this is used to reorder them -- 2.54.1 >From 8d2011fa2d97370191c7d953eb0e13ccdd260ab5 Mon Sep 17 00:00:00 2001 From: Pu Cheng <[email protected]> Date: Wed, 25 Nov 2026 00:36:16 +0800 Subject: [PATCH 3/3] tests/api: test the MPEG-4 decoder workarounds across a flush Signed-off-by: Pu Cheng <[email protected]> --- tests/api/Makefile | 1 + tests/api/api-mpeg4-flush-test.c | 380 +++++++++++++++++++++++++++++++ tests/fate/api.mak | 5 + 3 files changed, 386 insertions(+) create mode 100644 tests/api/api-mpeg4-flush-test.c diff --git a/tests/api/Makefile b/tests/api/Makefile index 75df91492d9..ff3dc01aa89 100644 --- a/tests/api/Makefile +++ b/tests/api/Makefile @@ -4,6 +4,7 @@ APITESTPROGS-$(call ALLYES, LIBASTCENC_ENCODER LIBASTCENC_DECODER) += api-astc-p APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264-slice +APITESTPROGS-$(call ALLYES, MPEG4_ENCODER MPEG4_DECODER) += api-mpeg4-flush APITESTPROGS-$(CONFIG_MOV_MUXER) += api-movenc APITESTPROGS-$(CONFIG_MOVTEXT_ENCODER) += api-movtext APITESTPROGS-$(call ALLYES, HEVC_MP4TOANNEXB_BSF HEVC_DECODER) += api-hevc-mp4toannexb diff --git a/tests/api/api-mpeg4-flush-test.c b/tests/api/api-mpeg4-flush-test.c new file mode 100644 index 00000000000..12d689dfc20 --- /dev/null +++ b/tests/api/api-mpeg4-flush-test.c @@ -0,0 +1,380 @@ +/* + * 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 + */ + +/* + * Check that the encoder identification the MPEG-4 decoder reads from the user + * data, and the workarounds it derives from it, do not carry over to another + * stream after avcodec_flush_buffers(), and that they survive a seek. + * The streams differ only in the user data. + */ + +#include <stdio.h> +#include <string.h> + +#include "libavcodec/avcodec.h" +#include "libavutil/adler32.h" +#include "libavutil/common.h" +#include "libavutil/error.h" +#include "libavutil/frame.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/lfg.h" +#include "libavutil/mem.h" + +#define WIDTH 88 +#define HEIGHT 72 +#define GOP 4 +#define FRAMES (2 * GOP) + +typedef struct Frames { + unsigned hash[FRAMES + 1]; + int nb; +} Frames; + +static AVPacket *stream[FRAMES]; + +static int encode_stream(void) +{ + const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MPEG4); + AVCodecContext *enc = avcodec_alloc_context3(codec); + AVFrame *frame = av_frame_alloc(); + uint8_t texture[2 * HEIGHT][2 * WIDTH]; + AVLFG lfg; + int ret = AVERROR(ENOMEM), nb = 0; + + if (!codec || !enc || !frame) + goto end; + + enc->width = WIDTH; + enc->height = HEIGHT; + enc->pix_fmt = AV_PIX_FMT_YUV420P; + enc->time_base = (AVRational){ 1, 25 }; + enc->gop_size = GOP; + enc->global_quality = 4 * FF_QP2LAMBDA; + enc->flags = AV_CODEC_FLAG_BITEXACT | AV_CODEC_FLAG_QSCALE | + AV_CODEC_FLAG_QPEL; + enc->thread_count = 1; + ret = avcodec_open2(enc, codec, NULL); + if (ret < 0) + goto end; + + frame->width = WIDTH; + frame->height = HEIGHT; + frame->format = AV_PIX_FMT_YUV420P; + ret = av_frame_get_buffer(frame, 0); + if (ret < 0) + goto end; + + av_lfg_init(&lfg, 1); + for (int y = 0; y < 2 * HEIGHT; y++) + for (int x = 0; x < 2 * WIDTH; x++) + texture[y][x] = 64 + ((x ^ y) & 31) + av_lfg_get(&lfg) % 64; + + for (int i = 0; i <= FRAMES; i++) { + if (i < FRAMES) { + ret = av_frame_make_writable(frame); + if (ret < 0) + goto end; + for (int p = 0; p < 3; p++) + for (int y = 0; y < HEIGHT >> !!p; y++) + for (int x = 0; x < WIDTH >> !!p; x++) { + /* move by fractions of a sample */ + const uint8_t *t = &texture[y + 3 * i / 4][x + 7 * i / 4]; + int fx = 7 * i & 3, fy = 3 * i & 3; + frame->data[p][y * frame->linesize[p] + x] = + ((4 - fy) * ((4 - fx) * t[0] + fx * t[1]) + + fy * ((4 - fx) * t[2 * WIDTH] + fx * t[2 * WIDTH + 1]) + 8) >> 4; + } + frame->pts = i; + } + ret = avcodec_send_frame(enc, i < FRAMES ? frame : NULL); + while (ret >= 0) { + AVPacket *pkt = av_packet_alloc(); + if (!pkt) { + ret = AVERROR(ENOMEM); + goto end; + } + ret = avcodec_receive_packet(enc, pkt); + if (ret < 0 || nb == FRAMES) + av_packet_free(&pkt); + else + stream[nb++] = pkt; + } + if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) + goto end; + } + ret = nb == FRAMES ? 0 : AVERROR_BUG; +end: + av_frame_free(&frame); + avcodec_free_context(&enc); + return ret; +} + +/* size of the headers in front of the first GOP or VOP header */ +static int header_size(const AVPacket *pkt) +{ + for (int i = 0; i + 4 <= pkt->size; i++) { + uint32_t code = AV_RB32(pkt->data + i); + if (code == 0x1B3 || code == 0x1B6) + return i; + } + return 0; +} + +/* headers of the first packet followed by an optional user data section */ +static int write_headers(uint8_t **data, const char *user_data) +{ + int size = header_size(stream[0]); + int len = user_data ? 4 + strlen(user_data) : 0; + uint8_t *buf = av_mallocz(size + len + AV_INPUT_BUFFER_PADDING_SIZE); + + if (!buf) + return AVERROR(ENOMEM); + memcpy(buf, stream[0]->data, size); + if (len) { + AV_WB32(buf + size, 0x1B2); + memcpy(buf + size + 4, user_data, len - 4); + } + *data = buf; + return size + len; +} + +/* remove the headers of the packet and add the ones given */ +static AVPacket *change_headers(const AVPacket *in, const uint8_t *headers, int size) +{ + int skip = header_size(in); + AVPacket *pkt = av_packet_alloc(); + + if (!pkt || av_new_packet(pkt, size + in->size - skip) < 0 || + av_packet_copy_props(pkt, in) < 0) { + av_packet_free(&pkt); + return NULL; + } + if (size) + memcpy(pkt->data, headers, size); + memcpy(pkt->data + size, in->data + skip, in->size - skip); + return pkt; +} + +static AVCodecContext *open_decoder(int threads, const char *extradata_id) +{ + const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MPEG4); + AVCodecContext *dec = avcodec_alloc_context3(codec); + int ret; + + if (!dec) + return NULL; + dec->thread_count = threads; + dec->thread_type = FF_THREAD_FRAME; + if (extradata_id) { + ret = write_headers(&dec->extradata, extradata_id); + if (ret < 0) + goto fail; + dec->extradata_size = ret; + } + if (avcodec_open2(dec, codec, NULL) >= 0) + return dec; +fail: + avcodec_free_context(&dec); + return NULL; +} + +static int receive(AVCodecContext *dec, AVFrame *frame, Frames *out) +{ + int ret; + + while ((ret = avcodec_receive_frame(dec, frame)) >= 0) { + unsigned hash = 1; + for (int p = 0; p < 3; p++) + for (int y = 0; y < HEIGHT >> !!p; y++) + hash = av_adler32_update(hash, frame->data[p] + y * frame->linesize[p], + WIDTH >> !!p); + if (out && out->nb < FF_ARRAY_ELEMS(out->hash)) + out->hash[out->nb++] = hash; + av_frame_unref(frame); + } + return ret == AVERROR(EAGAIN) || ret == AVERROR_EOF ? 0 : ret; +} + +enum { + HEADERS_STRIP, ///< no headers at all + HEADERS_KEEP, ///< headers without user data + HEADERS_ID, ///< headers and user data with the encoder identification +}; + +/* decode packets first to last - 1; mode is for the headers of the first one */ +static int decode(AVCodecContext *dec, int first, int last, int mode, + const char *id, int drain, Frames *out) +{ + AVFrame *frame = av_frame_alloc(); + uint8_t *headers = NULL; + int ret = AVERROR(ENOMEM), size = 0; + + if (!frame) + return ret; + if (mode != HEADERS_STRIP) { + ret = size = write_headers(&headers, mode == HEADERS_ID ? id : NULL); + if (ret < 0) + goto end; + } + for (int i = first; i < last; i++) { + AVPacket *pkt = change_headers(stream[i], headers, i == first ? size : 0); + if (!pkt) { + ret = AVERROR(ENOMEM); + goto end; + } + ret = avcodec_send_packet(dec, pkt); + av_packet_free(&pkt); + if (ret < 0 || (ret = receive(dec, frame, out)) < 0) + goto end; + } + if (drain && ((ret = avcodec_send_packet(dec, NULL)) < 0 || + (ret = receive(dec, frame, out)) < 0)) + goto end; + ret = 0; +end: + av_freep(&headers); + av_frame_free(&frame); + return ret; +} + +static int check(const char *what, const char *id, int threads, + const Frames *out, const Frames *ref, int ref_start) +{ + int nb = ref->nb - ref_start; + + if (nb > 0 && out->nb == nb && + !memcmp(out->hash, ref->hash + ref_start, nb * sizeof(*out->hash))) + return 0; + fprintf(stderr, "%s, %s, %d thread(s): the frames differ\n", id, what, threads); + return 1; +} + +static int test(const char *id, int threads) +{ + static const char other_id[] = "Lavc60.3.100"; + AVCodecContext *dec = NULL; + Frames plain = { 0 }, with_id = { 0 }, late, out; + int fail = 0; + + /* references, from decoders that are not flushed */ + if (!(dec = open_decoder(1, NULL)) || + decode(dec, 0, FRAMES, HEADERS_KEEP, NULL, 1, &plain) < 0) + goto error; + avcodec_free_context(&dec); + if (!(dec = open_decoder(1, NULL)) || + decode(dec, 0, FRAMES, HEADERS_ID, id, 1, &with_id) < 0) + goto error; + avcodec_free_context(&dec); + if (plain.nb != FRAMES || with_id.nb != FRAMES || + !memcmp(plain.hash, with_id.hash, sizeof(plain.hash))) { + fprintf(stderr, "%s: no effect on the references\n", id); + fail = 1; + } + + /* no flush, the identification comes after a few frames */ + for (int i = 0; i < 2; i++) { + Frames *const f = i ? &out : ⪭ + f->nb = 0; + if (!(dec = open_decoder(i ? threads : 1, NULL)) || + decode(dec, 0, GOP, HEADERS_KEEP, NULL, 0, f) < 0 || + decode(dec, GOP, FRAMES, HEADERS_ID, id, 1, f) < 0) + goto error; + avcodec_free_context(&dec); + } + fail |= check("late identification", id, threads, &out, &late, 0); + + /* another stream after the flush */ + for (int drain = 0; drain < 2; drain++) { + out.nb = 0; + if (!(dec = open_decoder(threads, NULL)) || + decode(dec, 0, GOP, HEADERS_ID, id, drain, NULL) < 0) + goto error; + avcodec_flush_buffers(dec); + if (decode(dec, 0, FRAMES, HEADERS_KEEP, NULL, 1, &out) < 0) + goto error; + fail |= check(drain ? "other stream after draining" : "other stream", + id, threads, &out, &plain, 0); + if (dec->idct_algo != FF_IDCT_AUTO) { + fprintf(stderr, "%s, %d thread(s): idct_algo %d after the flush\n", + id, threads, dec->idct_algo); + fail = 1; + } + avcodec_free_context(&dec); + } + + /* another stream that has its own identification */ + out.nb = 0; + if (!(dec = open_decoder(threads, NULL)) || + decode(dec, 0, FRAMES, HEADERS_ID, id, 1, NULL) < 0) + goto error; + avcodec_flush_buffers(dec); + if (decode(dec, 0, FRAMES, HEADERS_ID, other_id, 1, &out) < 0) + goto error; + fail |= check("other stream with identification", id, threads, &out, &plain, 0); + avcodec_free_context(&dec); + + /* seek to a packet without headers */ + out.nb = 0; + if (!(dec = open_decoder(threads, NULL)) || + decode(dec, 0, GOP - 1, HEADERS_ID, id, 0, NULL) < 0) + goto error; + avcodec_flush_buffers(dec); + if (decode(dec, GOP, FRAMES, HEADERS_STRIP, NULL, 1, &out) < 0) + goto error; + fail |= check("seek", id, threads, &out, &with_id, GOP); + avcodec_free_context(&dec); + + /* seek to a packet with headers, the identification is in the extradata */ + out.nb = 0; + if (!(dec = open_decoder(threads, id)) || + decode(dec, 0, GOP - 1, HEADERS_KEEP, NULL, 0, NULL) < 0) + goto error; + avcodec_flush_buffers(dec); + if (decode(dec, GOP, FRAMES, HEADERS_KEEP, NULL, 1, &out) < 0) + goto error; + fail |= check("seek with extradata", id, threads, &out, &with_id, GOP); + avcodec_free_context(&dec); + + return fail; +error: + fprintf(stderr, "%s, %d thread(s): error\n", id, threads); + avcodec_free_context(&dec); + return 1; +} + +int main(void) +{ + static const char *const ids[] = { + "XviD0001", "XviD0050", "DivX503b1338", + "FFmpeg v0.4.6 / libavcodec build: 4000", + }; + int fail = 0; + + if (encode_stream() < 0) { + fprintf(stderr, "encoding failed\n"); + return 1; + } + for (int i = 0; i < FF_ARRAY_ELEMS(ids); i++) { + fail |= test(ids[i], 1); + fail |= test(ids[i], 3); + } + for (int i = 0; i < FRAMES; i++) + av_packet_free(&stream[i]); + + return fail; +} diff --git a/tests/fate/api.mak b/tests/fate/api.mak index 69df95b90d0..96cf11d933e 100644 --- a/tests/fate/api.mak +++ b/tests/fate/api.mak @@ -24,6 +24,11 @@ FATE_API_LIBAVCODEC-$(CONFIG_PCM_S16LE_DECODER) += fate-api-skip-samples fate-api-skip-samples: $(APITESTSDIR)/api-skip-samples-test$(EXESUF) fate-api-skip-samples: CMD = run $(APITESTSDIR)/api-skip-samples-test$(EXESUF) +FATE_API_LIBAVCODEC-$(call ALLYES, MPEG4_ENCODER MPEG4_DECODER) += fate-api-mpeg4-flush +fate-api-mpeg4-flush: $(APITESTSDIR)/api-mpeg4-flush-test$(EXESUF) +fate-api-mpeg4-flush: CMD = run $(APITESTSDIR)/api-mpeg4-flush-test$(EXESUF) +fate-api-mpeg4-flush: CMP = null + FATE_API_LIBAVCODEC-$(CONFIG_MOVTEXT_ENCODER) += fate-api-movtext fate-api-movtext: $(APITESTSDIR)/api-movtext-test$(EXESUF) fate-api-movtext: CMD = run $(APITESTSDIR)/api-movtext-test$(EXESUF) -- 2.54.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
