PR #26242 opened by luoye-cpu
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26242
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26242.patch

Thanks for considering this patch series.

Add an opt-in `drop_xmp` option to the existing `jpegapp` bitstream filter so a 
sidecar can replace stale XMP metadata instead of stacking another APP1 segment.

## Behavior

With `drop_xmp=1`, scan the contiguous APP0..APP15 marker run immediately after 
SOI and remove APP1 segments carrying either the standard or extended XMP 
identifier, including the identifier's terminating NUL. Insert the sidecar 
payload at the existing insertion point. Kept segments and the packet tail are 
copied unchanged; the existing APP0 replacement rule still applies.

Scanning intentionally stops at the first non-APP marker or fill bytes. 
Malformed APP headers or lengths on the scanned path are errors. Processing 
errors with `drop_xmp` enabled latch the context, preventing unread sidecar 
payload bytes from being interpreted as another record; flushing does not clear 
this error. With the option disabled, the legacy APP0 replacement and 
passthrough paths are retained.

This is a byte-stream edit. It does not parse motion-photo metadata, calculate 
video offsets, validate XMP-declared sizes against the final file, or update 
MPF/gain-map layout references. The caller must generate metadata consistent 
with the output layout.

## Related work

This extends the `jpegapp` filter already merged through #24726 and its 
binary-sidecar option from #25156.

Related PR #25248 adds generic loading of option values from files, including 
the `jpegapp` sidecar. This series deliberately adds no `sidecar_file` option 
and has no dependency on that open PR. XMP replacement and generic file-option 
loading are complementary changes.

## Commits

1. `avcodec/bsf/jpegapp: add drop_xmp option` — implementation, user 
documentation and Changelog.
2. `fate: cover jpegapp XMP replacement and packet boundaries` — eight 
generated CLI tests and a public AVBSF API regression test.

## Testing

Tested on a targeted Windows x64 MinGW-w64 build against master at 
`e8574d0b22b126acc76007babce536c68bc07d0a`.

- All 13 relevant FATE targets pass in two runs: four existing jpegapp targets, 
eight new lavfi CLI targets, and `fate-jpegapp-api`.
- The API target contains 74 cases covering output bytes and packet properties, 
standard/extended identifiers, APP0 interactions, scan boundaries, malformed 
packets, record sequencing, sticky errors and flush behavior.
- New CLI inputs are generated from lavfi; no new fate-suite sample is 
required. Existing sample-based tests use the existing `smjpeg/scenwin.mjpg` 
sample unchanged.

Full-suite FATE, clang, sanitizers, Linux/macOS builds and texi2any rendering 
have not been run. No phone/gallery interoperability is claimed.



From b1de0826a0445e413d9b8083fdd582c1a269071e Mon Sep 17 00:00:00 2001
From: luoye-cpu <[email protected]>
Date: Fri, 20 Nov 2026 17:22:53 +0800
Subject: [PATCH 1/2] avcodec/bsf/jpegapp: add drop_xmp option

Motion photo files append the video to a JPEG whose XMP names it.
Packing an already-packed photo again can stack a stale XMP APP1 next to
the new one, causing consumers to choose the wrong metadata.

Add a drop_xmp option which removes standard and extended XMP APP1
segments from the contiguous APP run after SOI before inserting the
sidecar payload. Other segments are kept byte-exact. Scanning stops at
the first non-APP marker or fill bytes; this is an intentional scope
limit, and malformed APP headers on this path are errors.

Keep the legacy path separate so drop_xmp=0 retains the previous APP0
replacement, record-less fast path, and byte-for-byte behavior. Errors
while drop_xmp is active latch the context because a failed packet may
leave its sidecar payload unread.

Signed-off-by: luoye-cpu <[email protected]>
---
 Changelog                  |   1 +
 doc/bitstream_filters.texi |  37 ++++++-
 libavcodec/bsf/jpegapp.c   | 206 +++++++++++++++++++++++++++++++------
 3 files changed, 207 insertions(+), 37 deletions(-)

diff --git a/Changelog b/Changelog
index 56038443164..6540646ec5d 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ version <next>:
 - No longer disabling GCC autovectorization on PowerPC, RISC-V, MIPS and 
LoongArch
 - PCM PAMF decoder
 - Super Audio CD (SACD) demuxer
+- jpegapp bitstream filter drop_xmp option
 
 version 9.1:
 - ASTC image encoding and decoding via libastcenc, with .astc and KTX 1.0 
muxers and demuxers
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 662979a3294..f8236ca0d69 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -636,7 +636,7 @@ u8    payload[length]
 @end example
 
 @var{length} does not include the 4-byte prefix and must not exceed
-16 MiB. A zero @var{length} leaves that packet unchanged. A non-empty
+16 MiB. A zero @var{length} inserts no segments; @option{drop_xmp} still 
applies. A non-empty
 payload must be a concatenation of complete APP segments (@code{FF En}
 plus the 16-bit length that includes those two length bytes).
 
@@ -645,17 +645,44 @@ the two bytes immediately following SOI, that APP0 
segment is dropped.
 APP0 segments preceded by fill bytes or another segment are retained.
 An APP1-only payload keeps the encoder APP0: SOI, APP1, APP0, DQT, ...
 
+@table @option
+
+@item drop_xmp
+Drop XMP APP1 segments found in the run of segments immediately following
+SOI before the payload is inserted. Both the standard XMP identifier
+(@code{http://ns.adobe.com/xap/1.0/}) and the extended XMP identifier
+(@code{http://ns.adobe.com/xmp/extension/}) are recognized; all other
+segments, such as Exif or gain map APP2 segments, are kept. Scanning
+stops at the first non-APP marker or fill bytes (@code{0xFF 0xFF}) and
+the rest of the packet is kept verbatim --- an intentional limitation,
+not a full marker scan. A truncated APP segment header on this path is
+an error. Without @option{drop_xmp} the filter behaves byte-identically
+to before.
+
+The filter is a byte-level stream editor and does not interpret motion
+photo semantics: it does not compute the video offset a motion photo
+format expects, does not validate the lengths declared in XMP against
+the actual packet or file sizes, and does not guarantee that the sidecar
+is consistent with the final file layout. Keeping those in sync is the
+packer's responsibility.
+
+@end table
+
 The filter requires @option{sidecar}. Extra unused sidecar bytes are
-ignored; a packet without a matching record is an error.
+ignored; a packet without a matching record is an error. A packet
+processing error can leave the current record partly consumed; create a
+new context with a sidecar positioned for the next packet.
 Records follow packets in arrival order. Flushing the filter does not
 rewind the sidecar, so a reused context needs a sidecar positioned for
 the packets it will see next.
 A sidecar read or validation error prevents further record consumption
-by that filter context. To resume, create a new context with a sidecar
-matching the remaining packets. Flushing does not clear this error.
+by that filter context. With @option{drop_xmp}, packet processing errors
+also prevent further record consumption. To resume, create a new context
+with a sidecar matching the remaining packets. Flushing does not clear
+these errors.
 
 @example
-ffmpeg -i in.mp4 -c:v mjpeg -bsf:v jpegapp=sidecar=00000004DEADBEEF 
frame_%d.jpg
+ffmpeg -i in.mp4 -frames:v 1 -c:v mjpeg -bsf:v 
jpegapp=sidecar=00000008FFE1000646415445 frame_%d.jpg
 @end example
 
 @section mjpeg2jpeg
diff --git a/libavcodec/bsf/jpegapp.c b/libavcodec/bsf/jpegapp.c
index 8024b77d469..d5e176ff228 100644
--- a/libavcodec/bsf/jpegapp.c
+++ b/libavcodec/bsf/jpegapp.c
@@ -28,7 +28,7 @@
  *
  * Payload is zero or more complete JPEG APP segments (APP0..APP15),
  * each ``FF En`` + 16-bit length (length includes those two bytes).
- * A zero length leaves the packet unchanged.
+ * A zero length inserts no segments; drop_xmp still applies.
  *
  * After SOI the payload is inserted. If it starts with APP0 and the
  * two bytes immediately after SOI are an APP0 marker, that segment is
@@ -36,6 +36,23 @@
  * bytes or another segment is retained. An APP1-only payload keeps
  * the encoder APP0: SOI, APP1, APP0, DQT, ...
  *
+ * With drop_xmp, before the payload is inserted the run of APP segments
+ * immediately following SOI is scanned and every APP1 segment carrying
+ * the standard XMP identifier ("http://ns.adobe.com/xap/1.0/";) or the
+ * extended XMP identifier ("http://ns.adobe.com/xmp/extension/";) is
+ * dropped, so a sidecar can replace stale metadata in one pass. All
+ * other segments (Exif, gain map, ...) are kept byte-exact.
+ *
+ * On the drop_xmp path a truncated APP segment header is an error. The
+ * scan ends at the first non-APP marker or fill bytes (0xFF 0xFF); the
+ * rest of the packet is kept verbatim. Stopping at fill bytes is an
+ * intentional limitation, matching the scope of the APP0 replacement
+ * above; the filter does not claim a full marker scan.
+ *
+ * Without drop_xmp the filter behaves byte-identically to before: only
+ * the APP0 segment right after SOI is ever inspected, the record-less
+ * fast path is kept, and everything else is copied untouched.
+ *
  * A sidecar read or validation error stops further record consumption
  * for this filter context. Flushing does not clear that error.
  */
@@ -61,11 +78,19 @@
 
 #define JPEGAPP_MAX_RECORD (16 * 1024 * 1024)
 
+/* XMP APP1 identifiers, including the terminating NUL: the standard XMP
+ * identifier is "http://ns.adobe.com/xap/1.0/\0"; (28 chars + NUL = 29 bytes),
+ * the extended XMP identifier is "http://ns.adobe.com/xmp/extension/\0";
+ * (34 chars + NUL = 35 bytes). */
+static const char jpegapp_xmp_ident[]     = "http://ns.adobe.com/xap/1.0/";;
+static const char jpegapp_xmp_ext_ident[] = 
"http://ns.adobe.com/xmp/extension/";;
+
 typedef struct JPEGAppContext {
     const AVClass *class;
     GetByteContext gb;
     uint8_t *sidecar;
     int sidecar_len;
+    int drop_xmp;
     int read_error;
     int64_t packet_index;
 } JPEGAppContext;
@@ -95,6 +120,39 @@ static int jpegapp_validate_payload(const uint8_t *data, 
int size)
     return 0;
 }
 
+static int jpeg_app_is_xmp(const uint8_t *p, int len)
+{
+    if (len >= (int)sizeof(jpegapp_xmp_ident) &&
+        !memcmp(p, jpegapp_xmp_ident, sizeof(jpegapp_xmp_ident)))
+        return 1;
+    if (len >= (int)sizeof(jpegapp_xmp_ext_ident) &&
+        !memcmp(p, jpegapp_xmp_ext_ident, sizeof(jpegapp_xmp_ext_ident)))
+        return 1;
+    return 0;
+}
+
+/* Pure drop decision for the drop_xmp scan: marker parsing and bounds
+ * checks live in the caller, so no inferences about neighbouring segments
+ * can happen here. payload/payload_len describe this segment's payload
+ * only (seg_len - 4), never the remaining packet. Only called with
+ * s->drop_xmp set. */
+static int jpeg_app_drop_segment(const JPEGAppContext *s, int first_segment,
+                                 int rec_app0, int marker,
+                                 const uint8_t *payload, int payload_len)
+{
+    /* The APP0 segment right after SOI is dropped when the payload starts
+     * with APP0, so the sidecar can replace it (existing semantics). */
+    if (first_segment && rec_app0 && marker == APP0)
+        return 1;
+
+    /* Standard and extended XMP APP1 segments are dropped. */
+    if (s->drop_xmp && marker == APP1 &&
+        jpeg_app_is_xmp(payload, payload_len))
+        return 1;
+
+    return 0;
+}
+
 static int jpegapp_init(AVBSFContext *ctx)
 {
     JPEGAppContext *s = ctx->priv_data;
@@ -150,7 +208,8 @@ static int jpegapp_filter(AVBSFContext *ctx, AVPacket *out)
 {
     JPEGAppContext *s = ctx->priv_data;
     AVPacket *in;
-    int rec_size = 0, src_off, dst_size, ret;
+    int rec_size = 0, rec_app0, src_off, dst_size, dst_off, drop_total, ret;
+    int pos, scan_end, seg_len, drop;
 
     ret = ff_bsf_get_packet(ctx, &in);
     if (ret < 0)
@@ -171,45 +230,126 @@ static int jpegapp_filter(AVBSFContext *ctx, AVPacket 
*out)
         goto fail;
     }
 
-    src_off = 2;
-    if (rec_size >= 2 && s->gb.buffer[0] == 0xff && s->gb.buffer[1] == APP0 &&
-        in->size >= 4 && in->data[2] == 0xff && in->data[3] == APP0) {
-        int skip = jpeg_app_segment_len(in->data + 2, in->size - 2);
-        if (skip < 0) {
-            av_log(ctx, AV_LOG_ERROR,
-                   "jpegapp: existing APP0 is invalid or truncated\n");
-            ret = skip;
+    rec_app0 = rec_size >= 2 && s->gb.buffer[0] == 0xff && s->gb.buffer[1] == 
APP0;
+
+    if (!s->drop_xmp) {
+        /* Legacy path, byte-identical to the behaviour before drop_xmp:
+         * only the APP0 segment right after SOI is inspected (and only
+         * replaced when the payload starts with APP0); everything after it
+         * is tail and is copied verbatim. */
+        src_off = 2;
+        if (rec_app0 && in->size >= 4 &&
+            in->data[2] == 0xff && in->data[3] == APP0) {
+            int skip = jpeg_app_segment_len(in->data + 2, in->size - 2);
+            if (skip < 0) {
+                av_log(ctx, AV_LOG_ERROR,
+                       "jpegapp: existing APP0 is invalid or truncated\n");
+                ret = skip;
+                goto fail;
+            }
+            src_off = 2 + skip;
+        }
+
+        if (!rec_size) {
+            ret = av_packet_ref(out, in);
             goto fail;
         }
-        src_off = 2 + skip;
+
+        if (in->size - src_off > INT_MAX - 2 - rec_size) {
+            ret = AVERROR(ERANGE);
+            goto fail;
+        }
+        dst_size = 2 + rec_size + (in->size - src_off);
+        ret = av_new_packet(out, dst_size);
+        if (ret < 0)
+            goto fail;
+        ret = av_packet_copy_props(out, in);
+        if (ret < 0)
+            goto fail;
+
+        memcpy(out->data, in->data, 2);
+        bytestream2_get_buffer(&s->gb, out->data + 2, rec_size);
+        memcpy(out->data + 2 + rec_size, in->data + src_off, in->size - 
src_off);
+    } else {
+        /* Full scan path: walk the run of APP segments immediately after
+         * SOI. Non-APP markers and fill bytes (0xFF 0xFF) end the scan and
+         * everything from there on is tail -- an intentional limitation,
+         * matching the scope of the APP0 replacement above. A truncated APP
+         * segment header, however, is an error. There is no record-less
+         * fast path here: drop_xmp always rebuilds the packet, even when
+         * nothing matches, to keep a single semantics. */
+        drop_total = 0;
+        for (pos = 2, seg_len = 0; in->size - pos >= 2; pos += seg_len) {
+            if (in->data[pos] != 0xff ||
+                in->data[pos + 1] < APP0 || in->data[pos + 1] > APP15) {
+                /* Not an APP marker, includes fill bytes: keep the rest
+                 * as tail. */
+                break;
+            }
+            if (in->size - pos < 4) {
+                av_log(ctx, AV_LOG_ERROR,
+                       "jpegapp: truncated APP segment header\n");
+                ret = AVERROR_INVALIDDATA;
+                goto fail;
+            }
+            seg_len = jpeg_app_segment_len(in->data + pos, in->size - pos);
+            if (seg_len < 0) {
+                av_log(ctx, AV_LOG_ERROR,
+                       "jpegapp: segment after SOI is invalid or truncated\n");
+                ret = seg_len;
+                goto fail;
+            }
+            if (jpeg_app_drop_segment(s, pos == 2, rec_app0,
+                                      in->data[pos + 1], in->data + pos + 4,
+                                      seg_len - 4))
+                drop_total += seg_len;
+        }
+        scan_end = pos;
+
+        if (in->size - 2 - drop_total > INT_MAX - 2 - rec_size) {
+            ret = AVERROR(ERANGE);
+            goto fail;
+        }
+        dst_size = 2 + rec_size + (in->size - 2 - drop_total);
+        ret = av_new_packet(out, dst_size);
+        if (ret < 0)
+            goto fail;
+        ret = av_packet_copy_props(out, in);
+        if (ret < 0)
+            goto fail;
+
+        /* Second pass: copy SOI, the payload, then the kept segments in
+         * order, then the tail. Segment validity was established by the
+         * first pass; only the drop decision is re-evaluated, with the
+         * same arguments. */
+        memcpy(out->data, in->data, 2);
+        if (rec_size)
+            bytestream2_get_buffer(&s->gb, out->data + 2, rec_size);
+        dst_off = 2 + rec_size;
+        for (pos = 2; pos < scan_end; pos += seg_len) {
+            seg_len = AV_RB16(in->data + pos + 2) + 2;
+            drop = jpeg_app_drop_segment(s, pos == 2, rec_app0,
+                                         in->data[pos + 1],
+                                         in->data + pos + 4, seg_len - 4);
+            if (!drop) {
+                memcpy(out->data + dst_off, in->data + pos, seg_len);
+                dst_off += seg_len;
+            }
+        }
+        memcpy(out->data + dst_off, in->data + pos, in->size - pos);
     }
 
-    if (!rec_size) {
-        ret = av_packet_ref(out, in);
-        goto fail;
-    }
-
-    if (in->size - src_off > INT_MAX - 2 - rec_size) {
-        ret = AVERROR(ERANGE);
-        goto fail;
-    }
-    dst_size = 2 + rec_size + (in->size - src_off);
-    ret = av_new_packet(out, dst_size);
-    if (ret < 0)
-        goto fail;
-    ret = av_packet_copy_props(out, in);
-    if (ret < 0)
-        goto fail;
-
-    memcpy(out->data, in->data, 2);
-    bytestream2_get_buffer(&s->gb, out->data + 2, rec_size);
-    memcpy(out->data + 2 + rec_size, in->data + src_off, in->size - src_off);
     av_packet_free(&in);
     return 0;
 
 fail:
-    if (ret < 0)
+    if (ret < 0) {
+        /* A failed drop_xmp scan may leave the current payload unread.
+         * Do not interpret those bytes as the next record's length. */
+        if (s->drop_xmp)
+            s->read_error = ret;
         av_packet_unref(out);
+    }
     av_packet_free(&in);
     return ret;
 }
@@ -219,6 +359,8 @@ fail:
 static const AVOption jpegapp_options[] = {
     { "sidecar", "sidecar of u32be-length + APP-segment records", 
OFFSET(sidecar),
       AV_OPT_TYPE_BINARY, .flags = FLAGS },
+    { "drop_xmp", "drop existing XMP APP1 segments (standard and extended) 
before inserting",
+      OFFSET(drop_xmp), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
     { NULL },
 };
 
-- 
2.54.1


From d07eb49823dacd7185d162dd04298789a4041699 Mon Sep 17 00:00:00 2001
From: luoye-cpu <[email protected]>
Date: Sat, 21 Nov 2026 09:07:23 +0800
Subject: [PATCH 2/2] fate: cover jpegapp XMP replacement and packet boundaries

Add eight lavfi-generated tests for standard and extended XMP removal,
non-XMP APP preservation, APP0 replacement, identifier boundaries and
legacy behavior.

Add 74 direct public AVBSF API cases covering malformed packets, packet
properties, sidecar sequencing, flush behavior and error latching. The API
test does not require external samples, an encoder or a decoder.

Signed-off-by: luoye-cpu <[email protected]>
---
 libavcodec/Makefile                           |   1 +
 libavcodec/tests/jpegapp.c                    | 797 ++++++++++++++++++
 tests/fate/jpegapp.mak                        |  66 ++
 tests/fate/libavcodec.mak                     |   4 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-ext-multi |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-keep-exif |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-multi     |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-no-xmp    |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-nomatch   |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-replace   |   1 +
 tests/ref/fate/bsf-jpegapp-drop-xmp-short     |   1 +
 tests/ref/fate/bsf-jpegapp-no-drop-legacy     |   1 +
 tests/ref/fate/jpegapp-api                    |   1 +
 13 files changed, 877 insertions(+)
 create mode 100644 libavcodec/tests/jpegapp.c
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-ext-multi
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-keep-exif
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-multi
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-no-xmp
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-nomatch
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-replace
 create mode 100644 tests/ref/fate/bsf-jpegapp-drop-xmp-short
 create mode 100644 tests/ref/fate/bsf-jpegapp-no-drop-legacy
 create mode 100644 tests/ref/fate/jpegapp-api

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f12ad9c8e8d..0f296dbc1e7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1408,6 +1408,7 @@ TESTPROGS-$(CONFIG_MPEGAUDIOHEADER)       += 
mpegaudiodecheader
 TESTPROGS-$(CONFIG_MPEGVIDEO)             += mpeg12framerate
 TESTPROGS-$(CONFIG_H264_METADATA_BSF)     += h264_levels
 TESTPROGS-$(CONFIG_HEVC_METADATA_BSF)     += h265_levels
+TESTPROGS-$(CONFIG_JPEGAPP_BSF)           += jpegapp
 TESTPROGS-$(CONFIG_RANGECODER)            += rangecoder
 TESTPROGS-$(CONFIG_SNOW_ENCODER)          += snowenc
 
diff --git a/libavcodec/tests/jpegapp.c b/libavcodec/tests/jpegapp.c
new file mode 100644
index 00000000000..1f7808112ff
--- /dev/null
+++ b/libavcodec/tests/jpegapp.c
@@ -0,0 +1,797 @@
+/*
+ * jpegapp bitstream filter regression tests
+ *
+ * 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
+ */
+
+/* Exercise the public AVBSF API with synthetic JPEG packets. No decoder,
+ * demuxer, fixture file, or private filter structure is used. */
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdatomic.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "libavcodec/bsf.h"
+#include "libavcodec/packet.h"
+#include "libavutil/avutil.h"
+#include "libavutil/buffer.h"
+#include "libavutil/error.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+
+#define CAPACITY 2048
+
+typedef struct Bytes {
+    uint8_t data[CAPACITY];
+    int len;
+} Bytes;
+
+static int passed;
+static int opaque_token;
+static atomic_uint error_logs;
+static const uint8_t side_bytes[] = { 'k', 0, 'v', 0, 0xa5 };
+static const uint8_t opaque_bytes[] = { 0x07, 0x00, 0xfe, 0x99 };
+
+static void fail(const char *name, const char *fmt, ...)
+{
+    va_list ap;
+
+    fprintf(stderr, "FAIL %s: ", name);
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
+    fputc('\n', stderr);
+    exit(EXIT_FAILURE);
+}
+
+/* Count diagnostics without depending on their wording. A sticky filter error
+ * must not parse the old record payload again and emit another error. Use an
+ * atomic counter to honor the public log callback's thread-safety contract. */
+static void capture_log(void *avcl, int level, const char *fmt, va_list ap)
+{
+    (void)avcl;
+    (void)fmt;
+    (void)ap;
+    if (level <= AV_LOG_ERROR)
+        atomic_fetch_add_explicit(&error_logs, 1, memory_order_relaxed);
+}
+
+static unsigned log_count(void)
+{
+    return atomic_load_explicit(&error_logs, memory_order_relaxed);
+}
+
+static void expect_log_count(const char *name, unsigned wanted)
+{
+    unsigned got = log_count();
+    if (got != wanted)
+        fail(name, "error log count changed from %u to %u after terminal 
error",
+             wanted, got);
+}
+
+static void append(Bytes *dst, const void *src, size_t len)
+{
+    if (len > (size_t)(CAPACITY - dst->len))
+        fail("fixture", "buffer capacity exceeded: %d + %zu", dst->len, len);
+    if (len)
+        memcpy(dst->data + dst->len, src, len);
+    dst->len += (int)len;
+}
+
+static Bytes bytes(const uint8_t *src, size_t len)
+{
+    Bytes out = { { 0 }, 0 };
+    append(&out, src, len);
+    return out;
+}
+
+static Bytes concat(const Bytes *const *parts, size_t count)
+{
+    Bytes out = { { 0 }, 0 };
+    size_t i;
+
+    for (i = 0; i < count; i++)
+        append(&out, parts[i]->data, (size_t)parts[i]->len);
+    return out;
+}
+
+#define RAW(...) bytes((const uint8_t[]){ __VA_ARGS__ }, \
+                       sizeof((const uint8_t[]){ __VA_ARGS__ }))
+#define CAT(...) concat((const Bytes *const[]){ __VA_ARGS__ }, \
+                        sizeof((const Bytes *const[]){ __VA_ARGS__ }) / \
+                        sizeof(const Bytes *))
+
+static Bytes segment(unsigned marker, const void *payload, size_t len)
+{
+    Bytes out = { { 0 }, 0 };
+    uint8_t header[4];
+
+    if (marker < 0xe0 || marker > 0xef || len > 65533)
+        fail("fixture", "invalid segment marker/length");
+    header[0] = 0xff;
+    header[1] = (uint8_t)marker;
+    header[2] = (uint8_t)((len + 2) >> 8);
+    header[3] = (uint8_t)(len + 2);
+    append(&out, header, sizeof(header));
+    append(&out, payload, len);
+    return out;
+}
+
+static Bytes record(const Bytes *payload)
+{
+    Bytes out = { { 0 }, 0 };
+    uint32_t n = (uint32_t)payload->len;
+    uint8_t header[4] = { (uint8_t)(n >> 24), (uint8_t)(n >> 16),
+                          (uint8_t)(n >> 8), (uint8_t)n };
+
+    append(&out, header, sizeof(header));
+    append(&out, payload->data, (size_t)payload->len);
+    return out;
+}
+
+static void expect_ret(const char *name, const char *operation, int got, int 
want)
+{
+    if (got != want)
+        fail(name, "%s returned %d, expected %d", operation, got, want);
+}
+
+static AVBSFContext *new_context(const char *name, const Bytes *sidecar, int 
drop)
+{
+    const AVBitStreamFilter *filter = av_bsf_get_by_name("jpegapp");
+    AVBSFContext *ctx = NULL;
+    int ret;
+
+    if (!filter)
+        fail(name, "av_bsf_get_by_name(jpegapp) returned NULL");
+    ret = av_bsf_alloc(filter, &ctx);
+    expect_ret(name, "av_bsf_alloc", ret, 0);
+    if (!ctx || !ctx->par_in || !ctx->priv_data)
+        fail(name, "av_bsf_alloc returned an incomplete context");
+    ctx->par_in->codec_type = AVMEDIA_TYPE_VIDEO;
+    ctx->par_in->codec_id = AV_CODEC_ID_MJPEG;
+    ctx->par_in->width = 8;
+    ctx->par_in->height = 8;
+    ctx->time_base_in = (AVRational){ 1, 90000 };
+    ret = av_opt_set_bin(ctx->priv_data, "sidecar", sidecar->data,
+                         sidecar->len, 0);
+    expect_ret(name, "av_opt_set_bin(sidecar)", ret, 0);
+    ret = av_opt_set_int(ctx->priv_data, "drop_xmp", drop, 0);
+    expect_ret(name, "av_opt_set_int(drop_xmp)", ret, 0);
+    ret = av_bsf_init(ctx);
+    expect_ret(name, "av_bsf_init", ret, 0);
+    if (ctx->par_out->codec_type != AVMEDIA_TYPE_VIDEO ||
+        ctx->par_out->codec_id != AV_CODEC_ID_MJPEG ||
+        ctx->time_base_out.num != 1 || ctx->time_base_out.den != 90000)
+        fail(name, "output codec parameters/time base changed");
+    return ctx;
+}
+
+static AVPacket *new_packet(const char *name, const Bytes *data)
+{
+    AVPacket *pkt = av_packet_alloc();
+    uint8_t *sd;
+    int ret;
+
+    if (!pkt)
+        fail(name, "av_packet_alloc returned NULL");
+    ret = av_new_packet(pkt, data->len);
+    expect_ret(name, "av_new_packet", ret, 0);
+    if (data->len)
+        memcpy(pkt->data, data->data, (size_t)data->len);
+    pkt->pts = 900001;
+    pkt->dts = 899999;
+    pkt->duration = 7;
+    pkt->pos = 12345;
+    pkt->stream_index = 2;
+    pkt->flags = AV_PKT_FLAG_KEY | AV_PKT_FLAG_CORRUPT | AV_PKT_FLAG_DISCARD;
+    pkt->time_base = (AVRational){ 1, 90000 };
+    pkt->opaque = &opaque_token;
+    pkt->opaque_ref = av_buffer_alloc(sizeof(opaque_bytes));
+    if (!pkt->opaque_ref)
+        fail(name, "av_buffer_alloc(opaque_ref) returned NULL");
+    memcpy(pkt->opaque_ref->data, opaque_bytes, sizeof(opaque_bytes));
+    sd = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
+                                 sizeof(side_bytes));
+    if (!sd)
+        fail(name, "av_packet_new_side_data returned NULL");
+    memcpy(sd, side_bytes, sizeof(side_bytes));
+    return pkt;
+}
+
+static void expect_empty(const char *name, const char *operation,
+                         const AVPacket *pkt)
+{
+    if (pkt->data || pkt->size || pkt->buf || pkt->side_data_elems ||
+        pkt->opaque_ref)
+        fail(name, "%s left packet data/references behind", operation);
+}
+
+static void expect_props(const char *name, const AVPacket *pkt)
+{
+    const uint8_t *sd;
+    size_t sd_size = 0;
+
+    if (pkt->pts != 900001 || pkt->dts != 899999 || pkt->duration != 7 ||
+        pkt->pos != 12345 || pkt->stream_index != 2 ||
+        pkt->flags != (AV_PKT_FLAG_KEY | AV_PKT_FLAG_CORRUPT |
+                       AV_PKT_FLAG_DISCARD) ||
+        pkt->time_base.num != 1 || pkt->time_base.den != 90000 ||
+        pkt->opaque != &opaque_token)
+        fail(name, "packet timestamp/position/index/flags/time_base/opaque 
lost");
+    if (!pkt->opaque_ref || pkt->opaque_ref->size != sizeof(opaque_bytes) ||
+        memcmp(pkt->opaque_ref->data, opaque_bytes, sizeof(opaque_bytes)))
+        fail(name, "opaque_ref content lost");
+    sd = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &sd_size);
+    if (pkt->side_data_elems != 1 || !sd || sd_size != sizeof(side_bytes) ||
+        memcmp(sd, side_bytes, sizeof(side_bytes)))
+        fail(name, "packet side data lost/changed");
+}
+
+static void dump_bytes(const char *label, const uint8_t *data, int size)
+{
+    int i;
+    fprintf(stderr, "  %s (%d):", label, size);
+    for (i = 0; i < size && i < 128; i++)
+        fprintf(stderr, " %02x", data[i]);
+    if (size > 128)
+        fprintf(stderr, " ...");
+    fputc('\n', stderr);
+}
+
+static void expect_bytes(const char *name, const AVPacket *pkt,
+                         const Bytes *expected)
+{
+    int i, common = pkt->size < expected->len ? pkt->size : expected->len;
+
+    for (i = 0; i < common; i++) {
+        if (pkt->data[i] != expected->data[i])
+            break;
+    }
+    if (i != common || pkt->size != expected->len) {
+        dump_bytes("actual", pkt->data, pkt->size);
+        dump_bytes("expected", expected->data, expected->len);
+        fail(name, "packet bytes differ at offset %d", i);
+    }
+}
+
+static void receive_status(const char *name, AVBSFContext *ctx, int wanted)
+{
+    AVPacket *out = av_packet_alloc();
+    int ret;
+
+    if (!out)
+        fail(name, "av_packet_alloc(status) returned NULL");
+    ret = av_bsf_receive_packet(ctx, out);
+    expect_ret(name, "av_bsf_receive_packet(status)", ret, wanted);
+    expect_empty(name, "status receive", out);
+    av_packet_free(&out);
+}
+
+static void step(const char *name, AVBSFContext *ctx, const Bytes *input,
+                 const Bytes *expected, int wanted)
+{
+    AVPacket *in = new_packet(name, input);
+    AVPacket *out = av_packet_alloc();
+    int ret;
+
+    if (!out)
+        fail(name, "av_packet_alloc(output) returned NULL");
+    ret = av_bsf_send_packet(ctx, in);
+    expect_ret(name, "av_bsf_send_packet", ret, 0);
+    expect_empty(name, "successful send", in);
+    av_packet_free(&in);
+    ret = av_bsf_receive_packet(ctx, out);
+    expect_ret(name, "av_bsf_receive_packet", ret, wanted);
+    if (!wanted) {
+        expect_bytes(name, out, expected);
+        expect_props(name, out);
+    } else {
+        expect_empty(name, "failed receive", out);
+    }
+    av_packet_free(&out);
+    receive_status(name, ctx, AVERROR(EAGAIN));
+}
+
+static void finish(const char *name, AVBSFContext **ctx)
+{
+    int ret = av_bsf_send_packet(*ctx, NULL);
+    expect_ret(name, "av_bsf_send_packet(EOF)", ret, 0);
+    receive_status(name, *ctx, AVERROR_EOF);
+    receive_status(name, *ctx, AVERROR_EOF);
+    av_bsf_free(ctx);
+    if (*ctx)
+        fail(name, "av_bsf_free did not clear context");
+}
+
+static void run_case(const char *name, int drop, const Bytes *input,
+                     const Bytes *sidecar, const Bytes *expected, int wanted)
+{
+    AVBSFContext *ctx = new_context(name, sidecar, drop);
+
+    receive_status(name, ctx, AVERROR(EAGAIN));
+    step(name, ctx, input, expected, wanted);
+    finish(name, &ctx);
+    passed++;
+}
+
+#define CASE(name, drop, input_expr, payload_expr, expected_expr, wanted) do { 
\
+    const Bytes input_ = (input_expr); \
+    const Bytes payload_ = (payload_expr); \
+    const Bytes sidecar_ = record(&payload_); \
+    const Bytes expected_ = (expected_expr); \
+    run_case(name, drop, &input_, &sidecar_, &expected_, wanted); \
+} while (0)
+
+#define RAW_CASE(name, drop, input_expr, sidecar_expr, wanted) do { \
+    const Bytes input_ = (input_expr); \
+    const Bytes sidecar_ = (sidecar_expr); \
+    const Bytes expected_ = { { 0 }, 0 }; \
+    run_case(name, drop, &input_, &sidecar_, &expected_, wanted); \
+} while (0)
+
+static void content_cases(void)
+{
+    static const char std_id[] = "http://ns.adobe.com/xap/1.0/";;
+    static const char ext_id[] = "http://ns.adobe.com/xmp/extension/";;
+    static const uint8_t exif_id[] = { 'E', 'x', 'i', 'f', 0, 0, 1, 2 };
+    Bytes empty = { { 0 }, 0 };
+    Bytes soi = RAW(0xff, 0xd8);
+    Bytes tail = RAW(0xff, 0xdb, 0x00, 0x04, 0x00, 0x80,
+                     0xff, 0xda, 0x00, 0x02, 0x99, 0xff, 0x00, 0x42,
+                     0xff, 0xd9);
+    Bytes std_xmp = segment(0xe1, std_id, sizeof(std_id));
+    Bytes ext_xmp = segment(0xe1, ext_id, sizeof(ext_id));
+    Bytes exif = segment(0xe1, exif_id, sizeof(exif_id));
+    Bytes app2 = segment(0xe2, "ICC\0\xff\x80", 6);
+    Bytes app0 = segment(0xe0, "old", 3);
+    Bytes new0 = segment(0xe0, "new", 3);
+    Bytes inject = segment(0xe3, "fresh", 5);
+    Bytes fill = RAW(0xff, 0xff);
+    Bytes nonapp = RAW(0xff, 0xdb, 0x00, 0x02);
+    Bytes lone_ff = RAW(0xff);
+    Bytes short_id = segment(0xe1, std_id, sizeof(std_id) - 1);
+    Bytes std_suffix = CAT(&std_xmp, &ext_xmp);
+    Bytes wrong_case = segment(0xe1, "HTTP://ns.adobe.com/xap/1.0/", 29);
+    Bytes app2_xmp = segment(0xe2, std_id, sizeof(std_id));
+    Bytes empty_app = segment(0xef, NULL, 0);
+    Bytes empty0 = segment(0xe0, NULL, 0);
+    Bytes std_with_body, ext_with_body, bad_nul;
+    Bytes payload_std = bytes((const uint8_t *)std_id, sizeof(std_id));
+    Bytes payload_ext = bytes((const uint8_t *)ext_id, sizeof(ext_id));
+    Bytes extra = RAW(0x00, 0x23, 0xff, 0x80);
+
+    append(&payload_std, extra.data, (size_t)extra.len);
+    append(&payload_ext, extra.data, (size_t)extra.len);
+    std_with_body = segment(0xe1, payload_std.data, (size_t)payload_std.len);
+    ext_with_body = segment(0xe1, payload_ext.data, (size_t)payload_ext.len);
+    payload_std.data[sizeof(std_id) - 1] = 'X';
+    bad_nul = segment(0xe1, payload_std.data, (size_t)payload_std.len);
+
+    CASE("zero-record deletes standard XMP", 1,
+         CAT(&soi, &std_xmp, &tail), empty, CAT(&soi, &tail), 0);
+    CASE("zero-record deletes extended XMP", 1,
+         CAT(&soi, &ext_xmp, &tail), empty, CAT(&soi, &tail), 0);
+    CASE("delete repeated standard and extended XMP", 1,
+         CAT(&soi, &std_xmp, &exif, &ext_xmp, &app2, &std_xmp, &ext_xmp, 
&tail),
+         empty, CAT(&soi, &exif, &app2, &tail), 0);
+    CASE("delete identifiers with body bytes", 1,
+         CAT(&soi, &std_with_body, &ext_with_body, &tail),
+         empty, CAT(&soi, &tail), 0);
+    CASE("insert sidecar and preserve Exif APP2 tail", 1,
+         CAT(&soi, &exif, &std_xmp, &app2, &ext_xmp, &tail),
+         inject, CAT(&soi, &inject, &exif, &app2, &tail), 0);
+    CASE("inserted standard and extended XMP are retained", 1,
+         CAT(&soi, &std_xmp, &ext_xmp, &tail), std_suffix,
+         CAT(&soi, &std_suffix, &tail), 0);
+    CASE("missing identifier NUL is retained", 1,
+         CAT(&soi, &short_id, &tail), empty,
+         CAT(&soi, &short_id, &tail), 0);
+    CASE("non-NUL identifier terminator is retained", 1,
+         CAT(&soi, &bad_nul, &tail), empty,
+         CAT(&soi, &bad_nul, &tail), 0);
+    CASE("case-sensitive identifier matching", 1,
+         CAT(&soi, &wrong_case, &tail), empty,
+         CAT(&soi, &wrong_case, &tail), 0);
+    CASE("XMP identifier in APP2 is retained", 1,
+         CAT(&soi, &app2_xmp, &tail), empty,
+         CAT(&soi, &app2_xmp, &tail), 0);
+    CASE("empty APP15 retained", 1,
+         CAT(&soi, &empty_app, &std_xmp, &tail), empty,
+         CAT(&soi, &empty_app, &tail), 0);
+    CASE("all APP segments deleted through end of packet", 1,
+         CAT(&soi, &std_xmp, &ext_xmp), empty, soi, 0);
+    CASE("SOI-only packet accepted", 1, soi, empty, soi, 0);
+    CASE("single trailing FF kept as unparsed tail", 1,
+         CAT(&soi, &lone_ff), empty, CAT(&soi, &lone_ff), 0);
+    CASE("single trailing FF kept after deletion", 1,
+         CAT(&soi, &std_xmp, &lone_ff), empty,
+         CAT(&soi, &lone_ff), 0);
+    CASE("fill bytes stop scan", 1,
+         CAT(&soi, &std_xmp, &fill, &ext_xmp, &tail), empty,
+         CAT(&soi, &fill, &ext_xmp, &tail), 0);
+    CASE("non-APP marker stops scan", 1,
+         CAT(&soi, &std_xmp, &nonapp, &ext_xmp, &tail), empty,
+         CAT(&soi, &nonapp, &ext_xmp, &tail), 0);
+    CASE("non-marker byte stops scan", 1,
+         CAT(&soi, &extra, &std_xmp, &tail), empty,
+         CAT(&soi, &extra, &std_xmp, &tail), 0);
+    CASE("immediate APP0 replaced with drop_xmp", 1,
+         CAT(&soi, &app0, &std_xmp, &tail), new0,
+         CAT(&soi, &new0, &tail), 0);
+    CASE("immediate APP0 replaced on legacy path", 0,
+         CAT(&soi, &app0, &std_xmp, &tail), new0,
+         CAT(&soi, &new0, &std_xmp, &tail), 0);
+    CASE("only first duplicate APP0 is replaced", 1,
+         CAT(&soi, &app0, &app0, &std_xmp, &tail), new0,
+         CAT(&soi, &new0, &app0, &tail), 0);
+    CASE("APP0 after deleted XMP is retained", 1,
+         CAT(&soi, &std_xmp, &app0, &tail), new0,
+         CAT(&soi, &new0, &app0, &tail), 0);
+    CASE("APP0 after Exif retained", 1,
+         CAT(&soi, &exif, &app0, &tail), new0,
+         CAT(&soi, &new0, &exif, &app0, &tail), 0);
+    CASE("APP0 after fill retained", 1,
+         CAT(&soi, &fill, &app0, &tail), new0,
+         CAT(&soi, &new0, &fill, &app0, &tail), 0);
+    CASE("APP0 after non-APP retained", 1,
+         CAT(&soi, &nonapp, &app0, &tail), new0,
+         CAT(&soi, &new0, &nonapp, &app0, &tail), 0);
+    CASE("zero record preserves original APP0", 1,
+         CAT(&soi, &app0, &std_xmp, &tail), empty,
+         CAT(&soi, &app0, &tail), 0);
+    CASE("APP1-first sidecar does not replace original APP0", 1,
+         CAT(&soi, &app0, &tail), CAT(&std_xmp, &new0),
+         CAT(&soi, &std_xmp, &new0, &app0, &tail), 0);
+    CASE("empty original APP0 replaced", 1,
+         CAT(&soi, &empty0, &tail), new0, CAT(&soi, &new0, &tail), 0);
+    CASE("legacy zero record preserves old XMP", 0,
+         CAT(&soi, &std_xmp, &ext_xmp, &tail), empty,
+         CAT(&soi, &std_xmp, &ext_xmp, &tail), 0);
+    CASE("legacy APP1 insertion preserves original APP0", 0,
+         CAT(&soi, &app0, &tail), std_xmp,
+         CAT(&soi, &std_xmp, &app0, &tail), 0);
+    CASE("legacy APP0 after XMP retained", 0,
+         CAT(&soi, &std_xmp, &app0, &tail), new0,
+         CAT(&soi, &new0, &std_xmp, &app0, &tail), 0);
+}
+
+static void malformed_cases(void)
+{
+    Bytes empty = { { 0 }, 0 };
+    Bytes soi = RAW(0xff, 0xd8);
+    Bytes inject = segment(0xe3, "new", 3);
+    Bytes new0 = segment(0xe0, "new", 3);
+    Bytes bad_marker = RAW(0xff, 0xe1);
+    Bytes bad_header = RAW(0xff, 0xe1, 0x00);
+    Bytes len0 = RAW(0xff, 0xe1, 0x00, 0x00);
+    Bytes len1 = RAW(0xff, 0xe1, 0x00, 0x01);
+    Bytes len_over = RAW(0xff, 0xe1, 0x00, 0x03);
+    Bytes len_max = RAW(0xff, 0xe1, 0xff, 0xff, 0x41);
+    Bytes bad_app0 = RAW(0xff, 0xe0, 0x00, 0x01);
+    Bytes nonapp = RAW(0xff, 0xdb);
+    Bytes zero_record = record(&empty);
+    Bytes short_prefix = RAW(0x00, 0x00, 0x00);
+    Bytes oversize = RAW(0x01, 0x00, 0x00, 0x01);
+    Bytes missing_payload = RAW(0x00, 0x00, 0x00, 0x04, 0xff, 0xe1);
+    Bytes bad_payload = RAW(0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00);
+    Bytes payload_junk = CAT(&inject, &short_prefix);
+
+    CASE("drop rejects two-byte APP marker", 1,
+         CAT(&soi, &bad_marker), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects three-byte APP header", 1,
+         CAT(&soi, &bad_header), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects APP length zero", 1,
+         CAT(&soi, &len0), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects APP length one", 1,
+         CAT(&soi, &len1), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects APP payload truncation", 1,
+         CAT(&soi, &len_over), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects maximum APP length truncation", 1,
+         CAT(&soi, &len_max), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects bad header after valid APP", 1,
+         CAT(&soi, &inject, &bad_header), empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop does not parse malformed APP after non-APP", 1,
+         CAT(&soi, &nonapp, &bad_header), empty,
+         CAT(&soi, &nonapp, &bad_header), 0);
+    CASE("legacy zero record keeps truncated APP marker", 0,
+         CAT(&soi, &bad_marker), empty, CAT(&soi, &bad_marker), 0);
+    CASE("legacy zero record keeps truncated APP header", 0,
+         CAT(&soi, &bad_header), empty, CAT(&soi, &bad_header), 0);
+    CASE("legacy zero record keeps invalid APP length", 0,
+         CAT(&soi, &len0), empty, CAT(&soi, &len0), 0);
+    CASE("legacy inserted APP keeps malformed original APP1", 0,
+         CAT(&soi, &bad_header), inject,
+         CAT(&soi, &inject, &bad_header), 0);
+    CASE("legacy malformed APP0 kept without replacement", 0,
+         CAT(&soi, &bad_app0), inject,
+         CAT(&soi, &inject, &bad_app0), 0);
+    CASE("legacy malformed APP0 still rejected when replaced", 0,
+         CAT(&soi, &bad_app0), new0, empty, AVERROR_INVALIDDATA);
+    CASE("drop malformed APP0 rejected without replacement", 1,
+         CAT(&soi, &bad_app0), inject, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects missing SOI", 1,
+         inject, empty, empty, AVERROR_INVALIDDATA);
+    CASE("legacy rejects missing SOI", 0,
+         inject, empty, empty, AVERROR_INVALIDDATA);
+    CASE("drop rejects one-byte JPEG packet", 1,
+         RAW(0xff), empty, empty, AVERROR_INVALIDDATA);
+    RAW_CASE("sidecar truncated length prefix", 1,
+             soi, short_prefix, AVERROR_INVALIDDATA);
+    RAW_CASE("sidecar oversized record rejected before allocation", 1,
+             soi, oversize, AVERROR_INVALIDDATA);
+    RAW_CASE("sidecar truncated payload", 1,
+             soi, missing_payload, AVERROR_INVALIDDATA);
+    RAW_CASE("sidecar invalid APP payload", 1,
+             soi, bad_payload, AVERROR_INVALIDDATA);
+    CASE("sidecar valid APP followed by junk rejected", 1,
+         soi, payload_junk, empty, AVERROR_INVALIDDATA);
+    RAW_CASE("legacy also rejects truncated sidecar prefix", 0,
+             soi, short_prefix, AVERROR_INVALIDDATA);
+
+    /* Keep this fixture checked independently of filter output. */
+    if (zero_record.len != 4 || memcmp(zero_record.data, "\0\0\0\0", 4))
+        fail("fixture", "zero record is not four zero bytes");
+}
+
+static void state_cases(void)
+{
+    const char *name;
+    AVBSFContext *ctx;
+    AVPacket *queued;
+    int ret;
+    Bytes empty = { { 0 }, 0 };
+    Bytes soi = RAW(0xff, 0xd8);
+    Bytes tail = RAW(0xff, 0xd9);
+    Bytes in = CAT(&soi, &tail);
+    Bytes a = segment(0xe2, "A", 1);
+    Bytes b = segment(0xe3, "B", 1);
+    Bytes r0 = record(&empty);
+    Bytes ra = record(&a);
+    Bytes rb = record(&b);
+    Bytes exp_a = CAT(&soi, &a, &tail);
+    Bytes exp_b = CAT(&soi, &b, &tail);
+    Bytes records = CAT(&r0, &ra, &r0, &rb);
+    Bytes oversize = RAW(0x01, 0x00, 0x00, 0x01);
+    Bytes invalid_payload = RAW(0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 
0x00);
+    Bytes broken;
+
+    name = "multiple records and flush preserve sidecar position";
+    ctx = new_context(name, &records, 1);
+    step(name, ctx, &in, &in, 0);
+    step(name, ctx, &in, &exp_a, 0);
+    av_bsf_flush(ctx);
+    receive_status(name, ctx, AVERROR(EAGAIN));
+    step(name, ctx, &in, &in, 0);
+    step(name, ctx, &in, &exp_b, 0);
+    finish(name, &ctx);
+    passed++;
+
+    name = "EOF then flush resumes at next record";
+    records = CAT(&ra, &rb);
+    ctx = new_context(name, &records, 1);
+    step(name, ctx, &in, &exp_a, 0);
+    ret = av_bsf_send_packet(ctx, NULL);
+    expect_ret(name, "av_bsf_send_packet(EOF)", ret, 0);
+    receive_status(name, ctx, AVERROR_EOF);
+    av_bsf_flush(ctx);
+    receive_status(name, ctx, AVERROR(EAGAIN));
+    step(name, ctx, &in, &exp_b, 0);
+    finish(name, &ctx);
+    passed++;
+
+    name = "flush discards queued packet without consuming record";
+    ctx = new_context(name, &records, 1);
+    queued = new_packet(name, &in);
+    ret = av_bsf_send_packet(ctx, queued);
+    expect_ret(name, "av_bsf_send_packet(queued)", ret, 0);
+    expect_empty(name, "queued send", queued);
+    av_packet_free(&queued);
+    av_bsf_flush(ctx);
+    receive_status(name, ctx, AVERROR(EAGAIN));
+    step(name, ctx, &in, &exp_a, 0);
+    step(name, ctx, &in, &exp_b, 0);
+    finish(name, &ctx);
+    passed++;
+
+    name = "record exhaustion is error and survives flush";
+    ctx = new_context(name, &r0, 1);
+    step(name, ctx, &in, &in, 0);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    av_bsf_flush(ctx);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    finish(name, &ctx);
+    passed++;
+
+    /* After the bad prefix the cursor points at a complete valid record.
+     * Without the latch, the next packet would incorrectly succeed. */
+    name = "oversize read error latch survives next packet and flush";
+    broken = CAT(&oversize, &ra);
+    ctx = new_context(name, &broken, 1);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    av_bsf_flush(ctx);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    finish(name, &ctx);
+    passed++;
+
+    /* Invalid payload is itself a zero-record prefix. Without the latch,
+     * reinterpreting it as a prefix would incorrectly produce success. */
+    name = "payload validation latch survives EOF and flush";
+    broken = CAT(&invalid_payload, &ra);
+    ctx = new_context(name, &broken, 1);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    ret = av_bsf_send_packet(ctx, NULL);
+    expect_ret(name, "av_bsf_send_packet(EOF)", ret, 0);
+    receive_status(name, ctx, AVERROR_EOF);
+    av_bsf_flush(ctx);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    finish(name, &ctx);
+    passed++;
+
+    name = "legacy read error latch survives flush";
+    broken = CAT(&oversize, &ra);
+    ctx = new_context(name, &broken, 0);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    av_bsf_flush(ctx);
+    step(name, ctx, &in, &empty, AVERROR_INVALIDDATA);
+    finish(name, &ctx);
+    passed++;
+}
+
+static void scan_error_sequence(const char *name, const Bytes *bad_input,
+                                int nonempty_record)
+{
+    AVBSFContext *ctx;
+    unsigned before, after;
+    int ret;
+    Bytes empty = { { 0 }, 0 };
+    Bytes soi = RAW(0xff, 0xd8);
+    Bytes eoi = RAW(0xff, 0xd9);
+    Bytes good_input = CAT(&soi, &eoi);
+    Bytes first = segment(0xe2, "first-record", 12);
+    Bytes next = segment(0xe3, "next-record", 11);
+    Bytes r0 = record(&empty);
+    Bytes rfirst = record(&first);
+    Bytes rnext = record(&next);
+    Bytes records = nonempty_record ? CAT(&rfirst, &rnext) : CAT(&r0, &rnext);
+
+    ctx = new_context(name, &records, 1);
+    before = log_count();
+    step(name, ctx, bad_input, &empty, AVERROR_INVALIDDATA);
+    after = log_count();
+    if (after <= before)
+        fail(name, "first malformed packet emitted no error diagnostic");
+
+    /* If the failed packet's record was empty, resuming would incorrectly
+     * apply the next valid record. If it was nonempty, resuming would parse
+     * FF E2 ... as a huge record length and return the same INVALIDDATA.
+     * Therefore both the return value AND absence of another diagnostic are
+     * checked; the latter distinguishes a real latch from a second parse. */
+    step(name, ctx, &good_input, &empty, AVERROR_INVALIDDATA);
+    expect_log_count(name, after);
+    av_bsf_flush(ctx);
+    receive_status(name, ctx, AVERROR(EAGAIN));
+    step(name, ctx, &good_input, &empty, AVERROR_INVALIDDATA);
+    expect_log_count(name, after);
+    ret = av_bsf_send_packet(ctx, NULL);
+    expect_ret(name, "av_bsf_send_packet(EOF)", ret, 0);
+    receive_status(name, ctx, AVERROR_EOF);
+    av_bsf_flush(ctx);
+    step(name, ctx, &good_input, &empty, AVERROR_INVALIDDATA);
+    expect_log_count(name, after);
+    finish(name, &ctx);
+    passed++;
+}
+
+static void scan_error_sequences(void)
+{
+    const char *name;
+    AVBSFContext *ctx;
+    unsigned before, after;
+    Bytes empty = { { 0 }, 0 };
+    Bytes soi = RAW(0xff, 0xd8);
+    Bytes eoi = RAW(0xff, 0xd9);
+    Bytes good = CAT(&soi, &eoi);
+    Bytes two_byte_header = RAW(0xff, 0xd8, 0xff, 0xe1);
+    Bytes three_byte_header = RAW(0xff, 0xd8, 0xff, 0xe1, 0x00);
+    Bytes bad_length = RAW(0xff, 0xd8, 0xff, 0xe1, 0x00, 0x01);
+    Bytes truncated_payload = RAW(0xff, 0xd8, 0xff, 0xe1, 0x00, 0x04, 0x41);
+    Bytes missing_soi = RAW(0x00, 0x00, 0xff, 0xd9);
+    Bytes bad_app0 = RAW(0xff, 0xd8, 0xff, 0xe0, 0x00, 0x01);
+    Bytes new0 = segment(0xe0, "replacement", 11);
+    Bytes next = segment(0xe3, "next", 4);
+    Bytes r0 = record(&empty);
+    Bytes rnew0 = record(&new0);
+    Bytes rnext = record(&next);
+    Bytes records;
+    Bytes expected = CAT(&soi, &next, &eoi);
+
+    scan_error_sequence("two-byte APP scan error with nonempty record latches",
+                        &two_byte_header, 1);
+    scan_error_sequence("two-byte APP scan error with zero record latches",
+                        &two_byte_header, 0);
+    scan_error_sequence("three-byte APP scan error with nonempty record 
latches",
+                        &three_byte_header, 1);
+    scan_error_sequence("three-byte APP scan error with zero record latches",
+                        &three_byte_header, 0);
+    scan_error_sequence("invalid APP length with nonempty record latches",
+                        &bad_length, 1);
+    scan_error_sequence("invalid APP length with zero record latches",
+                        &bad_length, 0);
+    scan_error_sequence("truncated APP payload with nonempty record latches",
+                        &truncated_payload, 1);
+    scan_error_sequence("truncated APP payload with zero record latches",
+                        &truncated_payload, 0);
+    scan_error_sequence("drop missing SOI with nonempty record latches",
+                        &missing_soi, 1);
+    scan_error_sequence("drop missing SOI with zero record latches",
+                        &missing_soi, 0);
+
+    /* Hard preservation: adding a terminal error to drop_xmp must not change
+     * the legacy missing-SOI behavior. A failed packet with a zero record
+     * leaves the next record aligned, so the next valid packet still 
succeeds. */
+    name = "legacy missing SOI with zero record remains recoverable";
+    records = CAT(&r0, &rnext);
+    ctx = new_context(name, &records, 0);
+    step(name, ctx, &missing_soi, &empty, AVERROR_INVALIDDATA);
+    av_bsf_flush(ctx);
+    step(name, ctx, &good, &expected, 0);
+    finish(name, &ctx);
+    passed++;
+
+    /* Hard preservation also covers legacy APP0 replacement failure. In that
+     * mode the first error still leaves a nonempty record payload unconsumed;
+     * the next packet emits the pre-existing sidecar parse diagnostic. */
+    name = "legacy APP0 failure retains existing continuation behavior";
+    records = CAT(&rnew0, &rnext);
+    ctx = new_context(name, &records, 0);
+    before = log_count();
+    step(name, ctx, &bad_app0, &empty, AVERROR_INVALIDDATA);
+    after = log_count();
+    if (after <= before)
+        fail(name, "legacy APP0 parse error emitted no diagnostic");
+    step(name, ctx, &good, &empty, AVERROR_INVALIDDATA);
+    if (log_count() <= after)
+        fail(name, "legacy continuation unexpectedly acquired drop_xmp latch");
+    after = log_count();
+    av_bsf_flush(ctx);
+    step(name, ctx, &good, &empty, AVERROR_INVALIDDATA);
+    expect_log_count(name, after);
+    finish(name, &ctx);
+    passed++;
+}
+
+int main(void)
+{
+    /* Capture expected errors without platform-dependent log output. */
+    av_log_set_level(AV_LOG_ERROR);
+    av_log_set_callback(capture_log);
+    content_cases();
+    malformed_cases();
+    state_cases();
+    scan_error_sequences();
+    av_log_set_callback(av_log_default_callback);
+    if (passed != 74)
+        fail("case count", "ran %d cases, expected 74", passed);
+    printf("PASS jpegapp: 74 cases\n");
+    return EXIT_SUCCESS;
+}
diff --git a/tests/fate/jpegapp.mak b/tests/fate/jpegapp.mak
index 1ec4b41d26b..3656c710475 100644
--- a/tests/fate/jpegapp.mak
+++ b/tests/fate/jpegapp.mak
@@ -38,3 +38,69 @@ fate-bsf-jpegapp-oversize-continuation: CMD = \
         -bsf:v 
"jpegapp=sidecar=000000000100000100000008ffe100064641544500000000" -fflags 
+bitexact -f mjpeg
 
 FATE_SAMPLES_FFMPEG += $(FATE_JPEGAPP-yes)
+
+# Explicit scale/format stages are required by the FATE runner, which
+# disables automatic conversion between testsrc2 and the MJPEG encoder.
+JPEGAPP_LAVFI = LAVFI_INDEV TESTSRC2_FILTER WRAPPED_AVFRAME_DECODER \
+                SCALE_FILTER FORMAT_FILTER MJPEG_ENCODER JPEGAPP_BSF \
+                MJPEG_MUXER FILE_PROTOCOL
+
+# Replace both XMP identifier forms and the APP0 directly after SOI. The first
+# instance adds old APP0 + standard/extended XMP; the second replaces APP0 and
+# drops both stale XMP segments before adding the new standard XMP segment.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-replace
+fate-bsf-jpegapp-drop-xmp-replace: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=0000005EFFE000064F4C4430FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441FFE1002C687474703A2F2F6E732E61646F62652E636F6D2F786D702F657874656E73696F6E2F00584D5044415441,jpegapp=drop_xmp=1:sidecar=0000002DFFE000064E455730FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# Exif APP1 is retained while an existing standard XMP APP1 is replaced.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-keep-exif
+fate-bsf-jpegapp-drop-xmp-keep-exif: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=0000003AFFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441FFE100104578696600004558494644415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# Two standard XMP APP1 segments around Exif are both dropped; Exif is kept.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-multi
+fate-bsf-jpegapp-drop-xmp-multi: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=00000062FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441FFE100104578696600004558494644415441FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# Extended XMP and standard XMP are both removed, in mixed order and count.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-ext-multi
+fate-bsf-jpegapp-drop-xmp-ext-multi: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=00000084FFE1002C687474703A2F2F6E732E61646F62652E636F6D2F786D702F657874656E73696F6E2F00584D5044415441FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441FFE1002C687474703A2F2F6E732E61646F62652E636F6D2F786D702F657874656E73696F6E2F00584D5044415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# The identifier includes its terminating NUL; a non-matching identifier is 
kept.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-nomatch
+fate-bsf-jpegapp-drop-xmp-nomatch: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=00000028FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F58584D5044415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# A short APP1 payload does not match XMP; the following Exif APP1 stays 
intact.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-short
+fate-bsf-jpegapp-drop-xmp-short: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=0000001EFFE1000A53484F5254584D50FFE100104578696600004558494644415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# Without drop_xmp both instances stack their XMP segments (legacy behavior).
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-no-drop-legacy
+fate-bsf-jpegapp-no-drop-legacy: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=00000028FFE10026687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F00584D5044415441,jpegapp=sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+# drop_xmp also works when the input carries no XMP, while keeping Exif.
+FATE_JPEGAPP_LAVFI-$(call ALLYES, $(JPEGAPP_LAVFI)) += 
fate-bsf-jpegapp-drop-xmp-no-xmp
+fate-bsf-jpegapp-drop-xmp-no-xmp: CMD = \
+    md5 -f lavfi -i 
"testsrc2=size=64x64:rate=1,scale=out_range=pc,format=yuvj420p" -frames:v 1 
-c:v mjpeg \
+        -threads 1 -flags +bitexact -fflags +bitexact \
+        -bsf:v 
"jpegapp=sidecar=00000012FFE100104578696600004558494644415441,jpegapp=drop_xmp=1:sidecar=00000025FFE10023687474703A2F2F6E732E61646F62652E636F6D2F7861702F312E302F0046415445"
 -f mjpeg
+
+FATE_FFMPEG += $(FATE_JPEGAPP_LAVFI-yes)
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 2e2dabcd148..76a36c76543 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -98,6 +98,10 @@ fate-h265-levels: libavcodec/tests/h265_levels$(EXESUF)
 fate-h265-levels: CMD = run libavcodec/tests/h265_levels$(EXESUF)
 fate-h265-levels: REF = /dev/null
 
+FATE_LIBAVCODEC-$(CONFIG_JPEGAPP_BSF) += fate-jpegapp-api
+fate-jpegapp-api: libavcodec/tests/jpegapp$(EXESUF)
+fate-jpegapp-api: CMD = run libavcodec/tests/jpegapp$(EXESUF)
+
 FATE_LIBAVCODEC-$(CONFIG_MPEGVIDEO) += fate-mpeg12framerate
 fate-mpeg12framerate: libavcodec/tests/mpeg12framerate$(EXESUF)
 fate-mpeg12framerate: CMD = run libavcodec/tests/mpeg12framerate$(EXESUF)
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-ext-multi 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-ext-multi
new file mode 100644
index 00000000000..1ecc08e1d1c
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-ext-multi
@@ -0,0 +1 @@
+c98b854e0481c37b2a62615ead4969f2
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-keep-exif 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-keep-exif
new file mode 100644
index 00000000000..756c6382b0d
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-keep-exif
@@ -0,0 +1 @@
+3c94c58997d15a5b058742b70b5f86d1
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-multi 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-multi
new file mode 100644
index 00000000000..756c6382b0d
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-multi
@@ -0,0 +1 @@
+3c94c58997d15a5b058742b70b5f86d1
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-no-xmp 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-no-xmp
new file mode 100644
index 00000000000..756c6382b0d
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-no-xmp
@@ -0,0 +1 @@
+3c94c58997d15a5b058742b70b5f86d1
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-nomatch 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-nomatch
new file mode 100644
index 00000000000..68d7d07d3ed
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-nomatch
@@ -0,0 +1 @@
+89fdee52d08caa0248aedd00a0edfff2
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-replace 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-replace
new file mode 100644
index 00000000000..47b3cf86249
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-replace
@@ -0,0 +1 @@
+dee26fea35ec12ca2daeaaa76d3add36
diff --git a/tests/ref/fate/bsf-jpegapp-drop-xmp-short 
b/tests/ref/fate/bsf-jpegapp-drop-xmp-short
new file mode 100644
index 00000000000..77fce1c0e4e
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-drop-xmp-short
@@ -0,0 +1 @@
+ee23775c4cd7f93cb9d5aa8eccccc5d8
diff --git a/tests/ref/fate/bsf-jpegapp-no-drop-legacy 
b/tests/ref/fate/bsf-jpegapp-no-drop-legacy
new file mode 100644
index 00000000000..fc01115155d
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-no-drop-legacy
@@ -0,0 +1 @@
+ea66c0fbe10c14e71412de47465c961f
diff --git a/tests/ref/fate/jpegapp-api b/tests/ref/fate/jpegapp-api
new file mode 100644
index 00000000000..096d3116386
--- /dev/null
+++ b/tests/ref/fate/jpegapp-api
@@ -0,0 +1 @@
+PASS jpegapp: 74 cases
-- 
2.54.1

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

Reply via email to