PR #26359 opened by 06needhamt URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26359 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26359.patch
# Summary of changes New PR for the changes in #26083 which is showing as merged even though it isn't I'm not sure how that happened Adds a demuxer and a muxer for Dynacolor MVC, the recording format used by surveillance cameras and DVRs built on Dynacolor chipsets. A file is a sequence of records. Each record has a 16-byte index header, an optional 16-byte extra index header followed by "super extra" data, a 32-byte MPEG PES-style header, and one MJPEG, MPEG-4 Part 2 or H.264 frame. The index headers are little-endian and protected by XOR checksums. The layout is documented in `libavformat/dynacolor.h`. **Demuxer** - Each channel number in the records becomes its own video stream. - Records only carry a time in whole seconds, so decoding timestamps are placed on a 25 fps (PAL) or 30 fps (NTSC) grid within each second, chosen by the PAL/NTSC flag. The time of the first record is exported as `creation_time`. - B-pictures are presented at their decoding time. I- and P-pictures followed by B-pictures get no PTS, since it is only known later. The next record's header is read ahead to detect this. - After a seek, each channel gets back the exact timestamps from its next indexed keyframe on. The demuxer only indexes keyframes whose timestamps are exact. - Audio records are skipped with a request for a sample, since no sample with audio is available. As described in the vendor's IP module protocol, they can carry their payload without a PES header; the probe and the reader skip them by their size. When an IP device enables audio routing, byte 3 bits 0-1 are left/right audio flags, not channel number bits. **Muxer** - Writes each video stream (MJPEG, MPEG-4, H.264) as a separate channel. - Records have no global header. H.264 is written in Annex B form; the muxer converts length-prefixed input itself, keeps the current SPS/PPS of each stream by id (from extradata, `NEW_EXTRADATA` side data and in-band updates) and inserts the ones a key access unit (IDR or recovery point) refers to but lacks, after the AUD if there is one. Non-key access units get a referenced SPS/PPS that changed out of band and was not written yet. Data partition A counts as a slice. The MPEG-4 VOL header from extradata is added to every keyframe that does not carry one. Nothing is added when the configuration is already in band. - The picture type (I/P/B) of each record is read from the bitstream. - The record time comes from `creation_time` plus the packet DTS, and the PAL/NTSC flag from the stream frame rate. As a result, remuxing a demuxed file with `-c copy -map_metadata 0` gives back the same packets and timestamps, and the same file. **Tests** - `fate-dynacolor-demux`: stream copy of the sample. - `fate-dynacolor-seek`: the `seek` tool on the sample (seeks before and after its keyframe). - `fate-dynacolor-remux` (`stream_remux`): the sample remuxed into Dynacolor. The packets match `fate-dynacolor-demux` except for the corrupt flag of the sample's truncated last record. - `fate-dynacolor-h264` (`stream_remux`): the existing `h264/h264_3bf_nopyramid_nobsrestriction.mp4` sample, H.264 with B-frames in MP4. - `fate-dynacolor-h264-aud` (`stream_remux`): the same sample with an AUD and its SPS/PPS removed. The muxer inserts them after the AUD. - `fate-dynacolor-h264-recovery` and `fate-dynacolor-h264-recovery-keys` (`stream_remux`): the existing `h264/intra_refresh.h264` sample. Parameter sets are inserted at a non-IDR recovery point, and recovery points are demuxed as keyframes. - `fate-dynacolor-h264-dpa` (`stream_remux`): the existing `h264/data_partitioning_ab.h264` sample with its parameter sets removed; the decoded frames match the sample's own decode. - `fate-dynacolor-seek-channels`: the `seek` tool on a generated two-channel file. Keyframes of both channels keep their linear-reading timestamps after each seek. - `fate-dynacolor-mpeg4` (`transcode`): MPEG-4 with B-frames and `+global_header`, from `testsrc2` (no sample needed). The packets match the encoder's, with the VOL header added to keyframes. - `fate-lavf-dynacolor`: the standard lavf container test. The sample (24,413 bytes, md5 `dd6f4d19a17a642e4302317386d95ea5`) is attached to this PR. It is copied byte for byte from https://streams.videolan.org/samples/camera-dvr/dynacolor/dynacolor-camera-sample: record 7, the smallest keyframe in that file (with the VOL header), followed by the first 200 bytes of record 8, a P-frame, as a truncated last record. ```fate-samples dynacolor/dynacolor-camera-keyframe ``` >From 3b436edbad85cb4900ed8597bbc780036c924831 Mon Sep 17 00:00:00 2001 From: Tom Needham <[email protected]> Date: Wed, 18 Nov 2026 18:22:13 +0000 Subject: [PATCH 1/2] avformat: add Dynacolor MVC demuxer Dynacolor MVC is the recording format of surveillance cameras and DVRs based on Dynacolor chipsets. Each record consists of a 16 byte index header, an optional 16 byte extra index header followed by "super extra" data, a 32 byte MPEG PES style header and an MJPEG, MPEG-4 Part 2 or H.264 frame. Records carry the channel number, which is exported as a separate stream, a picture type, and a timestamp with one second resolution. Decoding timestamps are placed on a grid of the nominal PAL (25 fps) or NTSC (30 fps) frame rate, starting at the beginning of the second each record belongs to. The time of the first record is exported as creation_time. Presentation timestamps are not set by the demuxer, as reference pictures followed by B-pictures are presented at a time that is only known later. MPEG-4 headers are parsed, also for channels found after avformat_find_stream_info(), so that the generic code knows the reorder delay and picture types and leaves unknown presentation times unset. The demuxer indexes keyframes itself, only when their timestamps are those of linear reading. H.264 recovery points, signalled by a recovery point SEI message, are keyframes too, as for the H.264 parser, while the record keeps its P-picture type. The SEI message must be complete within its NAL unit, and followed by a slice (including data partition A), for the record to count as a recovery point. After a seek, the timestamps of each channel are restored from its first indexed record at or after the new position; records before it have estimated timestamps. Audio records are skipped as no sample with audio is available. As described for the IP module, they can carry their payload directly after the index headers, without a PES header; the probe and the reader skip them by their size. When an IP device enables audio routing, the channel extension bits are left/right audio flags and not part of the channel number. The FATE sample holds record 7, a keyframe, and the first 200 bytes of record 8, a P-frame, of https://streams.videolan.org/samples/camera-dvr/dynacolor/dynacolor-camera-sample byte for byte. It is expected at dynacolor/dynacolor-camera-keyframe. The restoration of indexed timestamps for every channel follows the fix suggested in the Fairy review of #26083. Co-authored-by: Michael Niedermayer <[email protected]> Signed-off-by: Tom Needham <[email protected]> --- .forgejo/pre-commit/ignored-words.txt | 1 + Changelog | 1 + configure | 1 + doc/general_contents.texi | 2 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/dynacolor.h | 97 +++++ libavformat/dynacolordec.c | 516 ++++++++++++++++++++++++++ libavformat/version.h | 2 +- tests/Makefile | 1 + tests/fate/dynacolor.mak | 11 + tests/ref/fate/dynacolor-demux | 8 + tests/ref/fate/dynacolor-seek | 52 +++ 13 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 libavformat/dynacolor.h create mode 100644 libavformat/dynacolordec.c create mode 100644 tests/fate/dynacolor.mak create mode 100644 tests/ref/fate/dynacolor-demux create mode 100644 tests/ref/fate/dynacolor-seek diff --git a/.forgejo/pre-commit/ignored-words.txt b/.forgejo/pre-commit/ignored-words.txt index 0bdf0a65911..ced72b99af7 100644 --- a/.forgejo/pre-commit/ignored-words.txt +++ b/.forgejo/pre-commit/ignored-words.txt @@ -25,6 +25,7 @@ clen clens Collet compre +covert dum endin erro diff --git a/Changelog b/Changelog index aaa3fe97ca8..989faf4f3e1 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ version <next>: - DSS variable rate SP (format 1) support - Added the ability to derive an AMF hwdevice from a Vulkan hwdevice - MIGraphX execution provider support for the ONNX Runtime DNN backend +- Dynacolor MVC demuxer version 9.1: - ASTC image encoding and decoding via libastcenc, with .astc and KTX 1.0 muxers and demuxers diff --git a/configure b/configure index eed7a76aa92..0787528a4d3 100755 --- a/configure +++ b/configure @@ -3930,6 +3930,7 @@ dv_muxer_select="dvprofile" dvdvideo_demuxer_select="mpegps_demuxer" dvdvideo_demuxer_deps="libdvdnav libdvdread" dxa_demuxer_select="riffdec" +dynacolor_demuxer_select="mpeg4video_parser" eac3_demuxer_select="ac3_parser" evc_demuxer_select="evc_frame_merge_bsf evc_parser" f4v_muxer_select="mov_muxer" diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 8f7e07becb3..db37a7b73e6 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -617,6 +617,8 @@ library: @item DXA @tab @tab X @tab This format is used in the non-Windows version of the Feeble Files game and different game cutscenes repacked for use with ScummVM. +@item Dynacolor MVC @tab @tab X + @tab Format used by surveillance cameras and DVRs with a Dynacolor chipset. @item Electronic Arts cdata @tab @tab X @item Electronic Arts Multimedia @tab @tab X @tab Used in various EA games; files have extensions like WVE and UV2. diff --git a/libavformat/Makefile b/libavformat/Makefile index 9b5731d9593..454c41f69b5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -216,6 +216,7 @@ OBJS-$(CONFIG_DVBSUB_DEMUXER) += dvbsub.o rawdec.o OBJS-$(CONFIG_DVBTXT_DEMUXER) += dvbtxt.o rawdec.o OBJS-$(CONFIG_DVDVIDEO_DEMUXER) += dvdvideodec.o dvdclut.o OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o +OBJS-$(CONFIG_DYNACOLOR_DEMUXER) += dynacolordec.o OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o OBJS-$(CONFIG_EAC3_DEMUXER) += ac3dec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index db5656c7dbc..1ffb177df7d 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -156,6 +156,7 @@ extern const FFOutputFormat ff_dv_muxer; extern const FFInputFormat ff_dvbsub_demuxer; extern const FFInputFormat ff_dvbtxt_demuxer; extern const FFInputFormat ff_dxa_demuxer; +extern const FFInputFormat ff_dynacolor_demuxer; extern const FFInputFormat ff_ea_demuxer; extern const FFInputFormat ff_ea_cdata_demuxer; extern const FFInputFormat ff_eac3_demuxer; diff --git a/libavformat/dynacolor.h b/libavformat/dynacolor.h new file mode 100644 index 00000000000..07cac692825 --- /dev/null +++ b/libavformat/dynacolor.h @@ -0,0 +1,97 @@ +/* + * Dynacolor MVC common definitions + * Copyright (c) 2020-2026 Tom Needham + * + * 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 + */ + +#ifndef AVFORMAT_DYNACOLOR_H +#define AVFORMAT_DYNACOLOR_H + +#include <stdint.h> + +/* + * A Dynacolor MVC file is a sequence of records, each made of: + * + * - a 16 byte basic index: + * 0 '@' + * 1 device type + * 2 bits 0-3: reserved, bit 4: source (0: DVR, 1: IP device), + * bits 5-6: width base (0: 720, 1: 704, 2: 640), + * bit 7: channel bits 5-6 valid (DVR), or audio routing + * enabled (IP module) + * 3 bits 0-1: channel bits 5-6, bits 2-3: stream type, + * bits 4-7: quality index. With IP audio routing enabled, + * bits 0-1 signal left/right audio instead. + * 4-7 record size (PES header if present + payload), little-endian + * 8-11 UNIX time in seconds, little-endian + * 12 bit 0: 0: NTSC, 1: PAL, bit 1: 0: live, 1: playback, + * bit 2: audio, bit 3: DST, bit 4: covert, bit 5: video loss, + * bit 6: alarm in, bit 7: motion + * 13 bit 0: extra index present, bit 1: event, bits 2-7: PPS index + * 14 bits 0-2: picture type (1: I, 2: P, 3: B), + * bits 3-7: channel bits 0-4 + * 15 XOR of bytes 0-14 + * - if bit 0 of byte 13 is set, a 16 byte extra index: + * 0 DST minutes + * 1 bit 0: summer/winter time, bit 1: over speed, + * bits 2-6: skipped picture count, bit 7: exception + * 2-3 size of the following "super extra" data, little-endian + * 4-7 serial number, little-endian + * 8-13 alarm in, video loss and motion status bitmaps + * 14 bits 0-1: DVR recording, bits 2-7: time zone + * 15 XOR of bytes 0-14 + * followed by the super extra data (camera title, GPS, text, ...). + * - a 32 byte MPEG PES style header: + * 0-2 start code 0x000001 + * 3 bits 4-7: format, bits 0-3: channel bits 0-3 + * 4-23 unused by the format + * 24-26 record size, with marker bits: + * byte 24: 1 << 7 | size bits 15-21 + * byte 25: size bits 11-14 << 4 | 1 << 3 | size bits 8-10 + * byte 26: size bits 0-7 + * 27 picture type + * 28-31 field information + * - the payload, an elementary stream frame. Audio records with byte 12 + * bit 2 set may carry their payload directly without a PES header. + */ + +#define DYNACOLOR_BASIC_IDX_SIZE 16 +#define DYNACOLOR_EXTRA_IDX_SIZE 16 +#define DYNACOLOR_PES_HEADER_SIZE 32 + +#define DYNACOLOR_MAX_RECORD_SIZE 0x3FFFFF /* 22 bit size field in the PES header */ +#define DYNACOLOR_MAX_CHANNELS 128 /* 7 bit channel number */ + +#define DYNACOLOR_FORMAT_AUDIO 0xC +#define DYNACOLOR_FORMAT_JPEG 0xD +#define DYNACOLOR_FORMAT_MPEG4 0xE +#define DYNACOLOR_FORMAT_H264 0xF + +#define DYNACOLOR_PICTURE_I 1 +#define DYNACOLOR_PICTURE_P 2 +#define DYNACOLOR_PICTURE_B 3 + +static inline uint8_t ff_dynacolor_checksum(const uint8_t *buf, int size) +{ + uint8_t sum = 0; + for (int i = 0; i < size; i++) + sum ^= buf[i]; + return sum; +} + +#endif /* AVFORMAT_DYNACOLOR_H */ diff --git a/libavformat/dynacolordec.c b/libavformat/dynacolordec.c new file mode 100644 index 00000000000..00c1ddc5f2b --- /dev/null +++ b/libavformat/dynacolordec.c @@ -0,0 +1,516 @@ +/* + * Dynacolor MVC demuxer + * Copyright (c) 2020-2026 Tom Needham + * + * 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 "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "libavcodec/defs.h" +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/h264.h" +#include "libavcodec/sei.h" +#include "libavcodec/startcode.h" + +#include "avformat.h" +#include "avio_internal.h" +#include "demux.h" +#include "dynacolor.h" +#include "internal.h" + +typedef struct DynacolorRecord { + int64_t pos; + int64_t data_pos; + uint32_t size; + uint32_t time; + int channel; + int pal; + int pic_type; + int format; +} DynacolorRecord; + +typedef struct DynacolorStream { + int64_t next_dts; + /* first indexed record at or after the last seek target, and its dts */ + int64_t resume_pos; + int64_t resume_dts; + /* the timestamps are those of linear reading from the start */ + int exact; + int codec_change_reported; +} DynacolorStream; + +typedef struct DynacolorDemuxContext { + DynacolorRecord rec; + uint32_t start_time; + int64_t next_pos; + int64_t first_pos; + int seeked; + unsigned unsupported_reported; +} DynacolorDemuxContext; + +static int dynacolor_probe(const AVProbeData *p) +{ + int64_t pos = 0; + + while (p->buf_size - pos >= DYNACOLOR_BASIC_IDX_SIZE) { + const uint8_t *b = p->buf + pos; + uint32_t size = AV_RL32(b + 4); + int offset = DYNACOLOR_BASIC_IDX_SIZE; + + if (b[0] != '@' || ff_dynacolor_checksum(b, 15) != b[15]) + break; + + if (b[13] & 1) { + if (p->buf_size - pos < offset + DYNACOLOR_EXTRA_IDX_SIZE || + ff_dynacolor_checksum(b + offset, 15) != b[offset + 15]) + break; + offset += DYNACOLOR_EXTRA_IDX_SIZE + AV_RL16(b + offset + 2); + } + + if (b[12] & 4) { + pos += offset + (int64_t)size; + continue; + } + + if (size < DYNACOLOR_PES_HEADER_SIZE || p->buf_size - pos < offset + 4 || + AV_RB24(b + offset) != 1 || b[offset + 3] >> 4 < DYNACOLOR_FORMAT_AUDIO) + break; + + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +static int read_record_header(AVFormatContext *s, DynacolorRecord *rec) +{ + AVIOContext *pb = s->pb; + uint8_t basic[DYNACOLOR_BASIC_IDX_SIZE]; + uint8_t extra[DYNACOLOR_EXTRA_IDX_SIZE]; + uint8_t pes[DYNACOLOR_PES_HEADER_SIZE]; + int64_t ret; + + rec->pos = avio_tell(pb); + + ret = avio_read(pb, basic, sizeof(basic)); + if (ret != sizeof(basic)) + return ret < 0 ? ret : AVERROR_EOF; + + if (basic[0] != '@') { + av_log(s, AV_LOG_ERROR, "Invalid record header at 0x%"PRIx64"\n", rec->pos); + return AVERROR_INVALIDDATA; + } + if (ff_dynacolor_checksum(basic, 15) != basic[15]) { + av_log(s, AV_LOG_WARNING, "Record header checksum mismatch at 0x%"PRIx64"\n", rec->pos); + if (s->error_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; + } + + rec->size = AV_RL32(basic + 4); + rec->time = AV_RL32(basic + 8); + rec->pal = basic[12] & 1; + rec->pic_type = basic[14] & 7; + rec->channel = basic[14] >> 3; + /* The IP module uses these bits for left/right audio when enabled. */ + if ((basic[2] & 0x90) != 0x90) + rec->channel |= (basic[3] & 3) << 5; + + if (basic[13] & 1) { + ret = ffio_read_size(pb, extra, sizeof(extra)); + if (ret < 0) + return avio_feof(pb) ? AVERROR_EOF : ret; + if (ff_dynacolor_checksum(extra, 15) != extra[15]) { + av_log(s, AV_LOG_WARNING, "Extra header checksum mismatch at 0x%"PRIx64"\n", rec->pos); + if (s->error_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; + } + ret = avio_skip(pb, AV_RL16(extra + 2)); + if (ret < 0) + return ret; + } + + /* Audio records can carry their payload directly, without a PES header. */ + if (basic[12] & 4) { + rec->format = DYNACOLOR_FORMAT_AUDIO; + rec->data_pos = avio_tell(pb); + return 0; + } + + if (rec->size < DYNACOLOR_PES_HEADER_SIZE) { + av_log(s, AV_LOG_ERROR, "Invalid record size %"PRIu32"\n", rec->size); + return AVERROR_INVALIDDATA; + } + ret = ffio_read_size(pb, pes, sizeof(pes)); + if (ret < 0) + return avio_feof(pb) ? AVERROR_EOF : ret; + if (AV_RB24(pes) != 1) { + av_log(s, AV_LOG_ERROR, "Invalid PES header at 0x%"PRIx64"\n", rec->pos); + return AVERROR_INVALIDDATA; + } + + rec->format = pes[3] >> 4; + rec->size -= DYNACOLOR_PES_HEADER_SIZE; + if (rec->format == DYNACOLOR_FORMAT_JPEG) + rec->pic_type = DYNACOLOR_PICTURE_I; + + rec->data_pos = avio_tell(pb); + + return 0; +} + +typedef struct RBSPReader { + const uint8_t *p, *end; + int zeros; +} RBSPReader; + +/* Read a byte of a NAL unit payload, skipping emulation prevention bytes. + * Return -1 at the end of the NAL unit. */ +static int rbsp_byte(RBSPReader *r) +{ + while (r->p < r->end) { + if (r->zeros >= 2) { + if (*r->p == 3) { + r->zeros = 0; + r->p++; + continue; + } + if (*r->p <= 2) + return -1; + } + r->zeros = *r->p ? 0 : r->zeros + 1; + return *r->p++; + } + return -1; +} + +/* Read the payloadType or payloadSize value of an SEI message. */ +static int rbsp_sei_value(RBSPReader *r) +{ + int value = 0, b; + + do { + b = rbsp_byte(r); + if (b < 0 || value > INT_MAX - b) + return -1; + value += b; + } while (b == 0xFF); + return value; +} + +/* A maximal recovery_frame_cnt and its four following bits fit in 5 bytes. */ +static int rbsp_recovery_point(RBSPReader *r, int size) +{ + uint8_t data[5 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; + GetBitContext gb; + unsigned recovery_frame_cnt; + + if (!size) + return 0; + for (int i = 0; i < size; i++) { + int b = rbsp_byte(r); + if (b < 0) + return 0; + if (i < 5) + data[i] = b; + } + init_get_bits8(&gb, data, FFMIN(size, 5)); + recovery_frame_cnt = get_ue_golomb_long(&gb); + /* The maximum MaxFrameNum in H.264 is 2^16. */ + return recovery_frame_cnt < (1U << 16) && get_bits_left(&gb) >= 4; +} + +/* Check whether an H.264 access unit starts at a recovery point, i.e. + * carries a recovery point SEI message before its first slice. */ +static int h264_is_recovery_point(const uint8_t *buf, int size) +{ + const uint8_t *p = buf, *end; + uint32_t state = -1; + int recovery = 0; + + if (!size) + return 0; + end = buf + size; + while ((p = avpriv_find_start_code(p, end, &state)) < end) { + RBSPReader r = { p, end }; + int type = state & 0x1F; + uint32_t next_state = -1; + const uint8_t *next; + + if (type == H264_NAL_SLICE || type == H264_NAL_IDR_SLICE || type == H264_NAL_DPA) + return recovery; + if (recovery || type != H264_NAL_SEI) + continue; + + next = avpriv_find_start_code(p, end, &next_state); + if ((next_state & 0xFFFFFF00) == 0x100) + r.end = next - 4; + while (r.end > p && !r.end[-1]) + r.end--; + /* The byte-aligned SEI messages are followed by rbsp_trailing_bits. */ + if (r.end == p || r.end[-1] != 0x80) + continue; + r.end--; + + for (;;) { + int payload_type = rbsp_sei_value(&r); + int payload_size; + + if (payload_type < 0) + break; + payload_size = rbsp_sei_value(&r); + if (payload_size < 0 || payload_size > r.end - r.p) + break; + if (payload_type == SEI_TYPE_RECOVERY_POINT) { + if (rbsp_recovery_point(&r, payload_size)) { + recovery = 1; + break; + } + } else { + while (payload_size-- > 0 && rbsp_byte(&r) >= 0) + ; + } + } + } + return 0; +} + +static int get_stream(AVFormatContext *s, const DynacolorRecord *rec, AVStream **pst) +{ + DynacolorDemuxContext *dyn = s->priv_data; + enum AVCodecID codec_id; + AVStream *st; + + *pst = NULL; + + switch (rec->format) { + case DYNACOLOR_FORMAT_JPEG: codec_id = AV_CODEC_ID_MJPEG; break; + case DYNACOLOR_FORMAT_MPEG4: codec_id = AV_CODEC_ID_MPEG4; break; + case DYNACOLOR_FORMAT_H264: codec_id = AV_CODEC_ID_H264; break; + default: + if (!(dyn->unsupported_reported & (1U << rec->format))) { + if (rec->format == DYNACOLOR_FORMAT_AUDIO) + avpriv_request_sample(s, "Audio"); + else + avpriv_request_sample(s, "Format 0x%X", rec->format); + dyn->unsupported_reported |= 1U << rec->format; + } + return 0; + } + + for (unsigned i = 0; i < s->nb_streams; i++) { + if (s->streams[i]->id == rec->channel) { + st = s->streams[i]; + if (st->codecpar->codec_id != codec_id) { + DynacolorStream *dst = st->priv_data; + if (!dst->codec_change_reported) { + av_log(s, AV_LOG_WARNING, "Codec change on channel %d is not supported\n", + rec->channel); + dst->codec_change_reported = 1; + } + return 0; + } + *pst = st; + return 0; + } + } + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + st->priv_data = av_mallocz(sizeof(DynacolorStream)); + if (!st->priv_data) { + ff_remove_stream(s, st); + return AVERROR(ENOMEM); + } + DynacolorStream *dyna_stream = ((DynacolorStream *)st->priv_data); + dyna_stream->next_dts = AV_NOPTS_VALUE; + dyna_stream->resume_pos = -1; + /* A channel found after a seek may have started earlier in the file. */ + dyna_stream->exact = !dyn->seeked; + + st->id = rec->channel; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = codec_id; + /* Late channels also need reordering information for generic PTS filling. */ + if (codec_id == AV_CODEC_ID_MPEG4) + ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS; + st->r_frame_rate = (AVRational){ rec->pal ? 25 : 30, 1 }; + avpriv_set_pts_info(st, 64, 1, rec->pal ? 25 : 30); + + *pst = st; + return 0; +} + +static int dynacolor_read_header(AVFormatContext *s) +{ + DynacolorDemuxContext *dyn = s->priv_data; + DynacolorRecord *rec = &dyn->rec; + AVStream *st; + int ret; + + ret = ffio_ensure_seekback(s->pb, DYNACOLOR_BASIC_IDX_SIZE + DYNACOLOR_EXTRA_IDX_SIZE + + UINT16_MAX + DYNACOLOR_PES_HEADER_SIZE); + if (ret < 0) + return ret; + ret = read_record_header(s, rec); + if (ret < 0) + return ret; + dyn->next_pos = rec->pos; + dyn->first_pos = rec->pos; + dyn->start_time = rec->time; + + ret = ff_dict_set_timestamp(&s->metadata, "creation_time", + dyn->start_time * INT64_C(1000000)); + if (ret < 0) + return ret; + + /* More channels may show up later in the file. */ + s->ctx_flags |= AVFMTCTX_NOHEADER; + + ret = get_stream(s, rec, &st); + if (ret < 0) + return ret; + + /* Leave the first record to read_packet(), the data starts there. */ + ret = avio_seek(s->pb, rec->pos, SEEK_SET); + return ret < 0 ? ret : 0; +} + +/* Find the timestamp the generic index holds for the record at pos. */ +/* + * After a seek to pos, find the first record of each channel at or after + * pos that the index holds, so that its timestamp can be restored once it + * is reached. A seek to the first record restarts linear reading. + */ +static void seek_reset(AVFormatContext *s, int64_t pos) +{ + DynacolorDemuxContext *dyn = s->priv_data; + int restart = pos == dyn->first_pos; + + dyn->seeked = !restart; + + for (unsigned i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + DynacolorStream *dst = st->priv_data; + int nb_entries = avformat_index_get_entries_count(st); + + dst->next_dts = AV_NOPTS_VALUE; + dst->resume_pos = -1; + dst->exact = restart; + if (restart) + continue; + for (int j = 0; j < nb_entries; j++) { + const AVIndexEntry *e = avformat_index_get_entry(st, j); + if (e->pos >= pos && (dst->resume_pos < 0 || e->pos < dst->resume_pos)) { + dst->resume_pos = e->pos; + dst->resume_dts = e->timestamp; + } + } + } +} + +static int dynacolor_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + DynacolorDemuxContext *dyn = s->priv_data; + DynacolorRecord *rec = &dyn->rec; + AVIOContext *pb = s->pb; + DynacolorStream *dst; + DynacolorRecord cur; + AVStream *st; + int64_t dts, skip; + int ret; + + for (;;) { + ret = read_record_header(s, rec); + if (ret < 0) + return ret; + + if (rec->pos != dyn->next_pos) + seek_reset(s, rec->pos); + dyn->next_pos = rec->data_pos + rec->size; + + ret = get_stream(s, rec, &st); + if (ret < 0) + return ret; + if (st) + break; + + skip = avio_skip(pb, rec->size); + if (skip < 0) + return skip; + } + + cur = *rec; + ret = av_get_packet(pb, pkt, cur.size); + if (ret < 0) + return ret; + + /* + * Records only carry a timestamp in seconds. Frames are placed on a + * grid of the nominal PAL/NTSC frame rate, in decoding order, starting + * at the beginning of the second they belong to, so that the timestamps + * written by the muxer are reproduced. + * + * After a seek, the timestamps of each channel are restored from the + * first of its records held by the index. Records before it are only + * known with a granularity of one second; the estimates never exceed + * the timestamps of linear reading. + */ + dst = st->priv_data; + if (dst->resume_pos >= 0 && cur.pos >= dst->resume_pos) { + if (cur.pos == dst->resume_pos) { + dst->next_dts = FFMAX(dst->next_dts, dst->resume_dts); + dst->exact = 1; + } + dst->resume_pos = -1; + } + dts = ((int64_t)cur.time - dyn->start_time) * st->time_base.den; + if (dst->next_dts != AV_NOPTS_VALUE) + dts = FFMAX(dts, dst->next_dts); + dst->next_dts = dts + 1; + + pkt->stream_index = st->index; + pkt->pos = cur.pos; + pkt->dts = dts; + /* H.264 decoding can also start at a recovery point, which is not an + * I-picture: mark it and index it as a keyframe, as the parser does. */ + if (cur.pic_type == DYNACOLOR_PICTURE_I || + (st->codecpar->codec_id == AV_CODEC_ID_H264 && + h264_is_recovery_point(pkt->data, pkt->size))) { + pkt->flags |= AV_PKT_FLAG_KEY; + /* Only exact timestamps are indexed, estimates must not be reused. */ + if (dst->exact) { + ff_reduce_index(s, st->index); + av_add_index_entry(st, cur.pos, dts, 0, 0, AVINDEX_KEYFRAME); + } + } + + return 0; +} + +const FFInputFormat ff_dynacolor_demuxer = { + .p.name = "dynacolor", + .p.long_name = NULL_IF_CONFIG_SMALL("Dynacolor MVC"), + .p.extensions = "dyna,dyn", + .priv_data_size = sizeof(DynacolorDemuxContext), + .read_probe = dynacolor_probe, + .read_header = dynacolor_read_header, + .read_packet = dynacolor_read_packet, +}; diff --git a/libavformat/version.h b/libavformat/version.h index 683184d5da1..d8fc959f19b 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 21 +#define LIBAVFORMAT_VERSION_MINOR 22 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/tests/Makefile b/tests/Makefile index 2fb8a368ccb..df823b3ddbd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -204,6 +204,7 @@ include $(SRC_PATH)/tests/fate/dfa.mak include $(SRC_PATH)/tests/fate/dnxhd.mak include $(SRC_PATH)/tests/fate/dpcm.mak include $(SRC_PATH)/tests/fate/dvvideo.mak +include $(SRC_PATH)/tests/fate/dynacolor.mak include $(SRC_PATH)/tests/fate/ea.mak include $(SRC_PATH)/tests/fate/exif.mak include $(SRC_PATH)/tests/fate/enc_external.mak diff --git a/tests/fate/dynacolor.mak b/tests/fate/dynacolor.mak new file mode 100644 index 00000000000..edc960b125e --- /dev/null +++ b/tests/fate/dynacolor.mak @@ -0,0 +1,11 @@ +DYNACOLOR_SAMPLE = $(TARGET_SAMPLES)/dynacolor/dynacolor-camera-keyframe + +FATE_DYNACOLOR-$(call FRAMECRC, DYNACOLOR, MPEG4, EXTRACT_EXTRADATA_BSF) += fate-dynacolor-demux +fate-dynacolor-demux: CMD = framecrc -i $(DYNACOLOR_SAMPLE) -c copy -copyinkf + +FATE_DYNACOLOR-$(call DEMDEC, DYNACOLOR, MPEG4) += fate-dynacolor-seek +fate-dynacolor-seek: libavformat/tests/seek$(EXESUF) +fate-dynacolor-seek: CMD = run libavformat/tests/seek$(EXESUF) $(DYNACOLOR_SAMPLE) -duration 3 -frames 2 + +FATE_SAMPLES_FFMPEG += $(FATE_DYNACOLOR-yes) +fate-dynacolor: $(FATE_DYNACOLOR-yes) diff --git a/tests/ref/fate/dynacolor-demux b/tests/ref/fate/dynacolor-demux new file mode 100644 index 00000000000..e893a1f66b5 --- /dev/null +++ b/tests/ref/fate/dynacolor-demux @@ -0,0 +1,8 @@ +#extradata 0: 19, 0x14fa035e +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: mpeg4 +#dimensions 0: 720x576 +#sar 0: 1/1 +0, 0, 0, 1, 24133, 0x179a3c98 +0, 1, 1, 1, 120, 0xfc814029, F=0x2 diff --git a/tests/ref/fate/dynacolor-seek b/tests/ref/fate/dynacolor-seek new file mode 100644 index 00000000000..fdf3f08bdd7 --- /dev/null +++ b/tests/ref/fate/dynacolor-seek @@ -0,0 +1,52 @@ +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st:-1 flags:0 ts:-1.000000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret:-1 st:-1 flags:1 ts:-0.105833 +ret:-1 st: 0 flags:0 ts: 0.800000 +ret: 0 st: 0 flags:1 ts: 1.680000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st:-1 flags:0 ts:-0.423332 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st:-1 flags:1 ts: 0.470835 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret:-1 st: 0 flags:0 ts: 1.360000 +ret:-1 st: 0 flags:1 ts:-0.760000 +ret:-1 st:-1 flags:0 ts: 0.153336 +ret: 0 st:-1 flags:1 ts: 1.047503 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret:-1 st: 0 flags:0 ts: 1.960000 +ret:-1 st: 0 flags:1 ts:-0.160000 +ret:-1 st:-1 flags:0 ts: 0.730004 +ret: 0 st:-1 flags:1 ts: 1.624171 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st: 0 flags:0 ts:-0.480000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st: 0 flags:1 ts: 0.400000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret:-1 st:-1 flags:0 ts: 1.306672 +ret:-1 st:-1 flags:1 ts:-0.799161 +ret:-1 st: 0 flags:0 ts: 0.080000 +ret: 0 st: 0 flags:1 ts: 1.000000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret:-1 st:-1 flags:0 ts: 1.883340 +ret:-1 st:-1 flags:1 ts:-0.222493 +ret:-1 st: 0 flags:0 ts: 0.680000 +ret: 0 st: 0 flags:1 ts: 1.560000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st:-1 flags:0 ts:-0.539992 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 +ret: 0 st:-1 flags:1 ts: 0.354175 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 24133 +ret: 0 st: 0 flags:2 dts: 0.040000 pts: 0.040000 pos: 24213 size: 120 -- 2.54.1 >From 319f2ff04bd09040876daf2807e4845c7b98cb4d Mon Sep 17 00:00:00 2001 From: Tom Needham <[email protected]> Date: Wed, 25 Nov 2026 18:12:43 +0000 Subject: [PATCH 2/2] avformat: add Dynacolor MVC muxer Video streams are written as separate channels. The record time is derived from creation_time and the packet dts, and the PAL/NTSC flag from the stream frame rate, so that remuxing a file demuxed by the Dynacolor demuxer with stream copy and -map_metadata 0 reproduces the same packets and timestamps. Records have no global header. H.264 is written in Annex B form, and length-prefixed input is converted with the start codes h264_mp4toannexb would use. The muxer keeps the current SPS and PPS of each stream by id, from extradata (avcC or Annex B, which also sets the packet framing), from AV_PKT_DATA_NEW_EXTRADATA side data and from in-band parameter sets, in decoding order. Key access units, at IDR pictures or recovery points, that do not carry the PPS their first slice refers to, or the SPS that PPS refers to, get the current ones; other access units get them if they have not been written since they changed. The SPS goes after the access unit delimiter if there is one, as it must come first, and the PPS right before the first slice. Data partition A counts as a slice, as it carries the slice header. The MPEG-4 VOL header from extradata is added to every keyframe that does not carry one. Channels above 31 set the channel extension enable bit. The picture type of each record is read from the bitstream. The packets demuxed in fate-dynacolor-remux match fate-dynacolor-demux, except for the corrupt flag of the truncated last packet of the sample. In fate-dynacolor-mpeg4, they match those of the encoder, with the VOL header added to keyframes. fate-dynacolor-seek-channels checks that seeking keeps the timestamps of the keyframes of every channel. fate-dynacolor-h264-recovery and fate-dynacolor-h264-recovery-keys check H.264 recovery points, fate-dynacolor-h264-dpa data partitioning. Co-authored-by: Michael Niedermayer <[email protected]> Signed-off-by: Tom Needham <[email protected]> --- Changelog | 2 +- doc/general_contents.texi | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/dynacolorenc.c | 660 ++++++++++++++++++++ libavformat/version.h | 2 +- tests/fate/dynacolor.mak | 49 +- tests/fate/lavf-container.mak | 2 + tests/ref/fate/dynacolor-h264 | 33 + tests/ref/fate/dynacolor-h264-aud | 33 + tests/ref/fate/dynacolor-h264-dpa | 17 + tests/ref/fate/dynacolor-h264-recovery | 9 + tests/ref/fate/dynacolor-h264-recovery-keys | 19 + tests/ref/fate/dynacolor-mpeg4 | 83 +++ tests/ref/fate/dynacolor-remux | 10 + tests/ref/fate/dynacolor-seek-channels | 114 ++++ tests/ref/lavf/dynacolor | 3 + 17 files changed, 1036 insertions(+), 4 deletions(-) create mode 100644 libavformat/dynacolorenc.c create mode 100644 tests/ref/fate/dynacolor-h264 create mode 100644 tests/ref/fate/dynacolor-h264-aud create mode 100644 tests/ref/fate/dynacolor-h264-dpa create mode 100644 tests/ref/fate/dynacolor-h264-recovery create mode 100644 tests/ref/fate/dynacolor-h264-recovery-keys create mode 100644 tests/ref/fate/dynacolor-mpeg4 create mode 100644 tests/ref/fate/dynacolor-remux create mode 100644 tests/ref/fate/dynacolor-seek-channels create mode 100644 tests/ref/lavf/dynacolor diff --git a/Changelog b/Changelog index 989faf4f3e1..7ac1ee0ee25 100644 --- a/Changelog +++ b/Changelog @@ -11,7 +11,7 @@ version <next>: - DSS variable rate SP (format 1) support - Added the ability to derive an AMF hwdevice from a Vulkan hwdevice - MIGraphX execution provider support for the ONNX Runtime DNN backend -- Dynacolor MVC demuxer +- Dynacolor MVC demuxer and muxer version 9.1: - ASTC image encoding and decoding via libastcenc, with .astc and KTX 1.0 muxers and demuxers diff --git a/doc/general_contents.texi b/doc/general_contents.texi index db37a7b73e6..9dfa39b4250 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -617,7 +617,7 @@ library: @item DXA @tab @tab X @tab This format is used in the non-Windows version of the Feeble Files game and different game cutscenes repacked for use with ScummVM. -@item Dynacolor MVC @tab @tab X +@item Dynacolor MVC @tab X @tab X @tab Format used by surveillance cameras and DVRs with a Dynacolor chipset. @item Electronic Arts cdata @tab @tab X @item Electronic Arts Multimedia @tab @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index 454c41f69b5..4b1781932fe 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -217,6 +217,7 @@ OBJS-$(CONFIG_DVBTXT_DEMUXER) += dvbtxt.o rawdec.o OBJS-$(CONFIG_DVDVIDEO_DEMUXER) += dvdvideodec.o dvdclut.o OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o OBJS-$(CONFIG_DYNACOLOR_DEMUXER) += dynacolordec.o +OBJS-$(CONFIG_DYNACOLOR_MUXER) += dynacolorenc.o OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o OBJS-$(CONFIG_EAC3_DEMUXER) += ac3dec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 1ffb177df7d..ffadf345bd9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -157,6 +157,7 @@ extern const FFInputFormat ff_dvbsub_demuxer; extern const FFInputFormat ff_dvbtxt_demuxer; extern const FFInputFormat ff_dxa_demuxer; extern const FFInputFormat ff_dynacolor_demuxer; +extern const FFOutputFormat ff_dynacolor_muxer; extern const FFInputFormat ff_ea_demuxer; extern const FFInputFormat ff_ea_cdata_demuxer; extern const FFInputFormat ff_eac3_demuxer; diff --git a/libavformat/dynacolorenc.c b/libavformat/dynacolorenc.c new file mode 100644 index 00000000000..43b85a378f1 --- /dev/null +++ b/libavformat/dynacolorenc.c @@ -0,0 +1,660 @@ +/* + * Dynacolor MVC muxer + * Copyright (c) 2020-2026 Tom Needham + * + * 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 "libavutil/attributes.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mathematics.h" +#include "libavutil/mem.h" + +#include "libavcodec/defs.h" +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/h264.h" +#include "libavcodec/startcode.h" + +#include "avformat.h" +#include "dynacolor.h" +#include "internal.h" +#include "mux.h" + +#define H264_MAX_SPS 32 +#define H264_MAX_PPS 256 + +typedef struct H264ParamSet { + uint8_t *data; ///< NAL unit, without start code + int size; + int sps_id; + int pending; ///< current definition not yet written +} H264ParamSet; + +typedef struct H264Unit { + const uint8_t *nal; ///< NAL unit header + int size; ///< NAL unit size + const uint8_t *src; ///< Annex B input: bytes written as is, start code included + int src_size; + int type; +} H264Unit; + +typedef struct DynacolorMuxStream { + int format; + int pal; + int width_base; + int64_t last_time; + + /* H.264: input NAL unit length size (0 for Annex B), and the current + * parameter sets, inserted in key access units that lack them */ + int nal_length_size; + H264ParamSet sps[H264_MAX_SPS]; + H264ParamSet pps[H264_MAX_PPS]; + H264Unit *units; + unsigned units_size; +} DynacolorMuxStream; + +typedef struct DynacolorMuxContext { + int64_t start_time; + uint32_t serial; +} DynacolorMuxContext; + +/* Unused PES header bytes 6-23, as found in files written by Dynacolor devices. */ +static const uint8_t pes_filler[18] = { + 0x87, 0x01, 0x17, 0x31, 0x00, 0x01, 0x00, 0x01, 0x11, + 0x00, 0x01, 0x00, 0x01, 0x0F, 0x8B, 0x00, 0x00, 0x00, +}; + +typedef struct H264NAL { + const uint8_t *start; ///< start code + const uint8_t *header; ///< NAL unit header + int type; +} H264NAL; + +/* Find the next H.264 NAL unit at or after p. */ +static int h264_next_nal(const uint8_t *p, const uint8_t *buf, const uint8_t *end, + H264NAL *nal) +{ + uint32_t state = -1; + + p = avpriv_find_start_code(p, end, &state); + if ((state & 0xFFFFFF00) != 0x100) + return 0; + nal->header = p - 1; + nal->start = p - 4; + if (nal->start > buf && !nal->start[-1]) + nal->start--; + nal->type = *nal->header & 0x1F; + return 1; +} + +/* Read the first Exp-Golomb values of the H.264 NAL unit starting at nal, + * after skip bits of its payload, ignoring emulation prevention bytes. */ +static void h264_read_ue(const uint8_t *nal, const uint8_t *end, int skip, + unsigned *val, int nb_val) +{ + uint8_t rbsp[32 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; + const uint8_t *p = nal + 1; + int len = 0, zeros = 0; + GetBitContext gb; + + for (; p < end && len < 32; p++) { + if (zeros >= 2 && *p == 3) { + zeros = 0; + continue; + } + zeros = *p ? 0 : zeros + 1; + rbsp[len++] = *p; + } + init_get_bits8(&gb, rbsp, len); + skip_bits_long(&gb, skip); + for (int i = 0; i < nb_val; i++) + val[i] = get_ue_golomb_long(&gb); +} + +/** + * Find the type of the first picture of an MPEG-4 packet. + * + * @param config set to 1 if the packet carries a VOL header + * @return DYNACOLOR_PICTURE_I/P/B, or 0 if no picture was found + */ +static int mpeg4_parse_packet(const uint8_t *buf, int size, int *config) +{ + const uint8_t *p = buf, *end = buf + size; + uint32_t state = -1; + + *config = 0; + while ((p = avpriv_find_start_code(p, end, &state)) < end) { + if (state >= 0x120 && state <= 0x12F) { + *config = 1; + } else if (state == 0x1B6) { + switch (*p >> 6) { + case 0: return DYNACOLOR_PICTURE_I; + case 2: return DYNACOLOR_PICTURE_B; + default: return DYNACOLOR_PICTURE_P; + } + } + } + return 0; +} + +/* Make an SPS or PPS the current one for its id. */ +static int h264_store_param_set(DynacolorMuxStream *dst, const uint8_t *nal, + int size, int pending) +{ + H264ParamSet *ps; + uint8_t *data; + unsigned val[2]; + int sps_id = 0; + + while (size > 1 && !nal[size - 1]) + size--; + if (size < 2) + return 0; + + if ((nal[0] & 0x1F) == H264_NAL_SPS) { + h264_read_ue(nal, nal + size, 24, val, 1); + if (val[0] >= H264_MAX_SPS) + return 0; + ps = &dst->sps[val[0]]; + } else { + h264_read_ue(nal, nal + size, 0, val, 2); + if (val[0] >= H264_MAX_PPS || val[1] >= H264_MAX_SPS) + return 0; + ps = &dst->pps[val[0]]; + sps_id = val[1]; + } + + if (!pending && ps->size == size && !memcmp(ps->data, nal, size)) { + ps->pending = 0; + return 0; + } + data = av_memdup(nal, size); + if (!data) + return AVERROR(ENOMEM); + av_free(ps->data); + ps->data = data; + ps->size = size; + ps->sps_id = sps_id; + ps->pending = pending; + return 0; +} + +/* Update the current parameter sets from avcC or Annex B extradata. */ +static int h264_parse_extradata(AVFormatContext *s, DynacolorMuxStream *dst, + const uint8_t *buf, int size) +{ + const uint8_t *end = buf + size; + H264NAL nal, next; + int ret; + + if (size >= 7 && buf[0] == 1) { + const uint8_t *p = buf + 5; + + dst->nal_length_size = (buf[4] & 3) + 1; + /* SPS, then PPS */ + for (int list = 0; list < 2 && p < end; list++) { + int nb = *p++ & (list ? 0xFF : 0x1F); + for (int i = 0; i < nb; i++) { + int nal_size; + if (end - p < 2 || end - p - 2 < AV_RB16(p)) + goto invalid; + nal_size = AV_RB16(p); + p += 2; + if (nal_size && ((*p & 0x1F) == H264_NAL_SPS || (*p & 0x1F) == H264_NAL_PPS)) { + ret = h264_store_param_set(dst, p, nal_size, 1); + if (ret < 0) + return ret; + } + p += nal_size; + } + } + return 0; + } + + if (!h264_next_nal(buf, buf, end, &nal)) + return 0; + dst->nal_length_size = 0; + for (;; nal = next) { + int next_have = h264_next_nal(nal.header + 1, buf, end, &next); + + if (nal.type == H264_NAL_SPS || nal.type == H264_NAL_PPS) { + ret = h264_store_param_set(dst, nal.header, + (next_have ? next.start : end) - nal.header, 1); + if (ret < 0) + return ret; + } + if (!next_have) + break; + } + return 0; + +invalid: + av_log(s, AV_LOG_WARNING, "Invalid H.264 extradata\n"); + return 0; +} + +static int h264_add_unit(DynacolorMuxStream *dst, int *nb_units, + const uint8_t *nal, int size, const uint8_t *src, int src_size) +{ + H264Unit *unit = av_fast_realloc(dst->units, &dst->units_size, + (*nb_units + 1) * sizeof(*unit)); + if (!unit) + return AVERROR(ENOMEM); + dst->units = unit; + unit += (*nb_units)++; + unit->nal = nal; + unit->size = size; + unit->type = *nal & 0x1F; + unit->src = src; + unit->src_size = src_size; + return 0; +} + +/* Split an H.264 packet into NAL units. */ +static int h264_split_packet(AVFormatContext *s, DynacolorMuxStream *dst, + const AVPacket *pkt, int *nb_units) +{ + const uint8_t *p = pkt->data, *end = pkt->data + pkt->size; + H264NAL nal, next; + int ret; + + *nb_units = 0; + + if (dst->nal_length_size) { + while (end - p >= dst->nal_length_size) { + uint32_t nal_size = 0; + for (int i = 0; i < dst->nal_length_size; i++) + nal_size = nal_size << 8 | *p++; + if (nal_size > end - p) + return AVERROR_INVALIDDATA; + if (nal_size) { + ret = h264_add_unit(dst, nb_units, p, nal_size, NULL, 0); + if (ret < 0) + return ret; + } + p += nal_size; + } + return p == end ? 0 : AVERROR_INVALIDDATA; + } + + if (!h264_next_nal(p, p, end, &nal)) { + av_log(s, AV_LOG_ERROR, "H.264 packet without start code, and no avcC configuration\n"); + return AVERROR_INVALIDDATA; + } + /* Annex B NAL units are written as they are, with their start codes and + * any leading or trailing zero bytes. */ + for (;;) { + int has_next = h264_next_nal(nal.header + 1, pkt->data, end, &next); + const uint8_t *nal_end = has_next ? next.start : end; + const uint8_t *src = *nb_units ? nal.start : pkt->data; + + ret = h264_add_unit(dst, nb_units, nal.header, nal_end - nal.header, + src, nal_end - src); + if (ret < 0) + return ret; + if (!has_next) + return 0; + nal = next; + } +} + +static int h264_has_slice_header(int nal_type) +{ + return nal_type == H264_NAL_SLICE || nal_type == H264_NAL_IDR_SLICE || + nal_type == H264_NAL_DPA; +} + +/* Find the picture type of a split H.264 access unit. */ +static int h264_picture_type(const H264Unit *units, int nb_units) +{ + for (int i = 0; i < nb_units; i++) { + if (h264_has_slice_header(units[i].type)) { + unsigned val[2]; /* first_mb_in_slice, slice_type */ + h264_read_ue(units[i].nal, units[i].nal + units[i].size, 0, val, 2); + switch (val[1] % 5) { + case 1: return DYNACOLOR_PICTURE_B; + case 2: + case 4: return DYNACOLOR_PICTURE_I; + default: return DYNACOLOR_PICTURE_P; + } + } + } + return 0; +} + +typedef struct H264ConfigInsert { + int before[2]; ///< index of the unit to insert before + H264ParamSet *ps[2]; ///< SPS first + int nb; +} H264ConfigInsert; + +/** + * Find the current SPS and PPS that the first slice refers to but does not + * carry. Repeat them at key access units; otherwise only insert definitions + * that have not been written. The SPS goes at the start of the access unit, + * after its AUD if there is one, so that an in-band PPS can refer to it. + * The PPS goes immediately before the first slice, after the in-band SPS. + */ +static void h264_find_config_insert(DynacolorMuxStream *dst, + const H264Unit *units, int nb_units, int key, + H264ConfigInsert *ins) +{ + uint32_t sps_mask = 0; + uint64_t pps_mask[4] = { 0 }; + uint8_t pps_sps[H264_MAX_PPS]; + unsigned val[3], pps_id, sps_id; + int slice; + + memset(ins, 0, sizeof(*ins)); + + for (slice = 0; slice < nb_units; slice++) { + const H264Unit *u = &units[slice]; + if (h264_has_slice_header(u->type)) + break; + if (u->type == H264_NAL_SPS) { + h264_read_ue(u->nal, u->nal + u->size, 24, val, 1); + if (val[0] < H264_MAX_SPS) + sps_mask |= 1U << val[0]; + } else if (u->type == H264_NAL_PPS) { + h264_read_ue(u->nal, u->nal + u->size, 0, val, 2); + if (val[0] < H264_MAX_PPS && val[1] < H264_MAX_SPS) { + pps_mask[val[0] >> 6] |= 1ULL << (val[0] & 63); + pps_sps[val[0]] = val[1]; + } + } + } + if (slice == nb_units) + return; + + /* first_mb_in_slice, slice_type, pic_parameter_set_id */ + h264_read_ue(units[slice].nal, units[slice].nal + units[slice].size, 0, val, 3); + pps_id = val[2]; + if (pps_id >= H264_MAX_PPS) + return; + + if (pps_mask[pps_id >> 6] & 1ULL << (pps_id & 63)) { + sps_id = pps_sps[pps_id]; + } else { + if (!dst->pps[pps_id].data) + return; + sps_id = dst->pps[pps_id].sps_id; + } + + if (!(sps_mask & 1U << sps_id) && dst->sps[sps_id].data && + (key || dst->sps[sps_id].pending)) { + ins->before[ins->nb] = nb_units && units[0].type == H264_NAL_AUD; + ins->ps[ins->nb++] = &dst->sps[sps_id]; + } + if (!(pps_mask[pps_id >> 6] & 1ULL << (pps_id & 63)) && + (key || dst->pps[pps_id].pending)) { + ins->before[ins->nb] = slice; + ins->ps[ins->nb++] = &dst->pps[pps_id]; + } +} + +/* Write an H.264 NAL unit with a start code, or count its size if pb is NULL. */ +static int h264_write_nal(AVIOContext *pb, const uint8_t *nal, int size, + int start_code_size) +{ + if (pb) { + if (start_code_size == 4) + avio_wb32(pb, 1); + else + avio_wb24(pb, 1); + avio_write(pb, nal, size); + } + return start_code_size + size; +} + +/* Write a split H.264 access unit in Annex B form with the inserted parameter + * sets, or count its size if pb is NULL. The conversion of length-prefixed + * NAL units is done here, with the start codes h264_mp4toannexb uses. */ +static int64_t h264_write_units(AVIOContext *pb, const H264Unit *units, int nb_units, + const H264ConfigInsert *ins) +{ + int64_t size = 0; + + for (int i = 0, j = 0; i <= nb_units; i++) { + for (; j < ins->nb && ins->before[j] == i; j++) + size += h264_write_nal(pb, ins->ps[j]->data, ins->ps[j]->size, 4); + if (i == nb_units) + break; + if (units[i].src) { + if (pb) + avio_write(pb, units[i].src, units[i].src_size); + size += units[i].src_size; + } else { + int ps = units[i].type == H264_NAL_SPS || units[i].type == H264_NAL_PPS; + size += h264_write_nal(pb, units[i].nal, units[i].size, + ps || !size ? 4 : 3); + } + } + return size; +} + +static av_cold int dynacolor_init(AVFormatContext *s) +{ + DynacolorMuxContext *dyn = s->priv_data; + int ret; + + if (s->nb_streams > DYNACOLOR_MAX_CHANNELS) { + av_log(s, AV_LOG_ERROR, "At most %d streams are supported\n", + DYNACOLOR_MAX_CHANNELS); + return AVERROR(EINVAL); + } + + ret = ff_parse_creation_time_metadata(s, &dyn->start_time, 1); + if (ret < 0) + return ret; + if (dyn->start_time < 0 || dyn->start_time > UINT32_MAX) { + av_log(s, AV_LOG_ERROR, "creation_time out of range\n"); + return AVERROR(EINVAL); + } + + for (unsigned i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + const AVCodecParameters *par = st->codecpar; + DynacolorMuxStream *dst; + AVRational rate; + + if (par->codec_type != AVMEDIA_TYPE_VIDEO) { + av_log(s, AV_LOG_ERROR, "Only video streams are supported\n"); + return AVERROR_PATCHWELCOME; + } + + dst = st->priv_data = av_mallocz(sizeof(*dst)); + if (!dst) + return AVERROR(ENOMEM); + dst->last_time = dyn->start_time; + + switch (par->codec_id) { + case AV_CODEC_ID_MJPEG: dst->format = DYNACOLOR_FORMAT_JPEG; break; + case AV_CODEC_ID_MPEG4: dst->format = DYNACOLOR_FORMAT_MPEG4; break; + case AV_CODEC_ID_H264: dst->format = DYNACOLOR_FORMAT_H264; break; + default: + av_log(s, AV_LOG_ERROR, "Codec %s is not supported\n", + avcodec_get_name(par->codec_id)); + return AVERROR(EINVAL); + } + + /* Frame rates above 25 fps can only be represented by NTSC. */ + rate = st->r_frame_rate; + if (rate.num <= 0 || rate.den <= 0) + rate = st->avg_frame_rate; + dst->pal = rate.num <= 0 || rate.den <= 0 || av_cmp_q(rate, (AVRational){ 25, 1 }) <= 0; + + switch (par->width) { + case 704: dst->width_base = 1; break; + case 640: dst->width_base = 2; break; + default: dst->width_base = 0; break; + } + + if (par->codec_id == AV_CODEC_ID_H264 && par->extradata_size) { + ret = h264_parse_extradata(s, dst, par->extradata, par->extradata_size); + if (ret < 0) + return ret; + } + } + + return 0; +} + +static int dynacolor_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + DynacolorMuxContext *dyn = s->priv_data; + AVStream *st = s->streams[pkt->stream_index]; + DynacolorMuxStream *dst = st->priv_data; + const AVCodecParameters *par = st->codecpar; + AVIOContext *pb = s->pb; + uint8_t buf[DYNACOLOR_BASIC_IDX_SIZE + DYNACOLOR_EXTRA_IDX_SIZE + DYNACOLOR_PES_HEADER_SIZE]; + uint8_t *basic = buf; + uint8_t *extra = basic + DYNACOLOR_BASIC_IDX_SIZE; + uint8_t *pes = extra + DYNACOLOR_EXTRA_IDX_SIZE; + int channel = pkt->stream_index; + int64_t time, data_size = pkt->size; + H264ConfigInsert ins = { 0 }; + int nb_units = 0, pic_type = 0, extra_size = 0, config, ret; + uint32_t size; + + if (dst->format == DYNACOLOR_FORMAT_H264) { + size_t side_size; + const uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, + &side_size); + if (side && side_size <= INT_MAX) { + ret = h264_parse_extradata(s, dst, side, side_size); + if (ret < 0) + return ret; + } + + ret = h264_split_packet(s, dst, pkt, &nb_units); + if (ret < 0) + return ret; + + h264_find_config_insert(dst, dst->units, nb_units, + pkt->flags & AV_PKT_FLAG_KEY, &ins); + data_size = h264_write_units(NULL, dst->units, nb_units, &ins); + pic_type = h264_picture_type(dst->units, nb_units); + } else if (dst->format == DYNACOLOR_FORMAT_MPEG4) { + pic_type = mpeg4_parse_packet(pkt->data, pkt->size, &config); + if (!config && (pkt->flags & AV_PKT_FLAG_KEY) && + (s->flags & AVFMT_FLAG_AUTO_BSF)) { + extra_size = par->extradata_size; + data_size += extra_size; + } + } else { + pic_type = DYNACOLOR_PICTURE_I; + } + if (!pic_type) + pic_type = pkt->flags & AV_PKT_FLAG_KEY ? DYNACOLOR_PICTURE_I : DYNACOLOR_PICTURE_P; + + if (data_size > DYNACOLOR_MAX_RECORD_SIZE - DYNACOLOR_PES_HEADER_SIZE) { + av_log(s, AV_LOG_ERROR, "Packet of size %"PRId64" is too large\n", data_size); + return AVERROR(EINVAL); + } + size = data_size + DYNACOLOR_PES_HEADER_SIZE; + + time = dst->last_time; + if (pkt->dts != AV_NOPTS_VALUE) { + int64_t seconds = av_rescale_rnd(pkt->dts, st->time_base.num, + st->time_base.den, AV_ROUND_DOWN); + if (seconds < -dyn->start_time || + seconds > UINT32_MAX - dyn->start_time) { + av_log(s, AV_LOG_ERROR, "Timestamp out of range\n"); + return AVERROR(EINVAL); + } + time = dyn->start_time + seconds; + } + dst->last_time = time; + + memset(buf, 0, sizeof(buf)); + + basic[0] = '@'; + basic[1] = '2'; + /* Channels above 31 need the channel extension bits, enabled by bit 7. */ + basic[2] = dst->width_base << 5 | (channel >> 5 ? 0x80 : 0); + basic[3] = channel >> 5; + AV_WL32(basic + 4, size); + AV_WL32(basic + 8, time); + basic[12] = dst->pal; + basic[13] = 1; /* extra index present */ + basic[14] = (channel & 0x1F) << 3 | pic_type; + basic[15] = ff_dynacolor_checksum(basic, 15); + + AV_WL32(extra + 4, dyn->serial++); + extra[15] = ff_dynacolor_checksum(extra, 15); + + AV_WB24(pes, 1); + pes[3] = dst->format << 4 | (channel & 0xF); + AV_WB16(pes + 4, size - 6 <= UINT16_MAX ? size - 6 : 0); + memcpy(pes + 6, pes_filler, sizeof(pes_filler)); + pes[24] = 0x80 | (size >> 15 & 0x7F); + pes[25] = (size >> 11 & 0xF) << 4 | 0x08 | (size >> 8 & 0x7); + pes[26] = size & 0xFF; + pes[27] = pic_type; + AV_WN32(pes + 28, 0xFFFFFFFF); + + avio_write(pb, buf, sizeof(buf)); + if (dst->format == DYNACOLOR_FORMAT_H264) { + h264_write_units(pb, dst->units, nb_units, &ins); + for (int i = 0; i < ins.nb; i++) + ins.ps[i]->pending = 0; + + /* In-band parameter sets replace the current ones, in decoding order. */ + for (int i = 0; i < nb_units; i++) { + if (dst->units[i].type == H264_NAL_SPS || dst->units[i].type == H264_NAL_PPS) { + ret = h264_store_param_set(dst, dst->units[i].nal, dst->units[i].size, 0); + if (ret < 0) + return ret; + } + } + } else { + if (extra_size) + avio_write(pb, par->extradata, extra_size); + avio_write(pb, pkt->data, pkt->size); + } + + return 0; +} + +static av_cold void dynacolor_deinit(AVFormatContext *s) +{ + for (unsigned i = 0; i < s->nb_streams; i++) { + DynacolorMuxStream *dst = s->streams[i]->priv_data; + if (!dst) + continue; + for (int j = 0; j < H264_MAX_SPS; j++) + av_freep(&dst->sps[j].data); + for (int j = 0; j < H264_MAX_PPS; j++) + av_freep(&dst->pps[j].data); + av_freep(&dst->units); + } +} + +const FFOutputFormat ff_dynacolor_muxer = { + .p.name = "dynacolor", + .p.long_name = NULL_IF_CONFIG_SMALL("Dynacolor MVC"), + .p.extensions = "dyna,dyn", + .p.audio_codec = AV_CODEC_ID_NONE, + .p.video_codec = AV_CODEC_ID_MPEG4, + .p.subtitle_codec = AV_CODEC_ID_NONE, + .p.flags = AVFMT_VARIABLE_FPS, + .priv_data_size = sizeof(DynacolorMuxContext), + .init = dynacolor_init, + .write_packet = dynacolor_write_packet, + .deinit = dynacolor_deinit, +}; diff --git a/libavformat/version.h b/libavformat/version.h index d8fc959f19b..a8385d1a7bd 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 22 +#define LIBAVFORMAT_VERSION_MINOR 23 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/tests/fate/dynacolor.mak b/tests/fate/dynacolor.mak index edc960b125e..e6f396a5ed7 100644 --- a/tests/fate/dynacolor.mak +++ b/tests/fate/dynacolor.mak @@ -7,5 +7,52 @@ FATE_DYNACOLOR-$(call DEMDEC, DYNACOLOR, MPEG4) += fate-dynacolor-seek fate-dynacolor-seek: libavformat/tests/seek$(EXESUF) fate-dynacolor-seek: CMD = run libavformat/tests/seek$(EXESUF) $(DYNACOLOR_SAMPLE) -duration 3 -frames 2 +# The packets demuxed from the remuxed file must match fate-dynacolor-demux, +# except for the corrupt flag of the truncated last packet of the sample. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, MPEG4_DECODER EXTRACT_EXTRADATA_BSF) += fate-dynacolor-remux +fate-dynacolor-remux: CMD = stream_remux dynacolor $(DYNACOLOR_SAMPLE) "" dynacolor "-map 0 -map_metadata 0 -copyinkf" "" "-c copy -copyinkf" + +# H.264 in MP4: the muxer converts the stream to Annex B with in-band SPS/PPS. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, MOV_DEMUXER H264_DECODER H264_PARSER EXTRACT_EXTRADATA_BSF) += fate-dynacolor-h264 +fate-dynacolor-h264: CMD = stream_remux mov $(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4 "" dynacolor "-map 0:v" "" "-c copy" + +# Annex B H.264 with an AUD but no in-band SPS/PPS: the muxer inserts them +# from extradata after the AUD, which must stay first. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, MOV_DEMUXER H264_DECODER H264_PARSER EXTRACT_EXTRADATA_BSF H264_MP4TOANNEXB_BSF H264_METADATA_BSF FILTER_UNITS_BSF) += fate-dynacolor-h264-aud +fate-dynacolor-h264-aud: CMD = stream_remux mov $(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4 "" dynacolor "-map 0:v -bsf:v h264_mp4toannexb,h264_metadata=aud=insert,filter_units=remove_types=7-8" "" "-c copy" + +# A non-IDR recovery point needs the parameter sets that the muxer got +# from probing, even when the in-band copies have been removed. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, H264_DEMUXER H264_DECODER H264_PARSER EXTRACT_EXTRADATA_BSF FILTER_UNITS_BSF SETTS_BSF) += fate-dynacolor-h264-recovery +fate-dynacolor-h264-recovery: CMD = stream_remux h264 $(TARGET_SAMPLES)/h264/intra_refresh.h264 "" dynacolor "-map 0:v -bsf:v filter_units=remove_types=7-8,setts=ts=N*DURATION -frames:v 30" "" "-c copy -copyinkf -frames:v 1" + +# Recovery points are keyframes, as for the H.264 parser: list them. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, H264_DEMUXER H264_DECODER H264_PARSER EXTRACT_EXTRADATA_BSF SETTS_BSF NOISE_BSF) += fate-dynacolor-h264-recovery-keys +fate-dynacolor-h264-recovery-keys: CMD = stream_remux h264 $(TARGET_SAMPLES)/h264/intra_refresh.h264 "" dynacolor "-map 0:v -bsf:v setts=ts=N*DURATION" "" "-c copy -bsf:v noise=drop=not(key)" + +# Data partition A carries the slice header: the parameter sets its slices +# refer to must be inserted, the decoded frames show that they are. +FATE_DYNACOLOR-$(call REMUX, DYNACOLOR, H264_DEMUXER H264_DECODER H264_PARSER EXTRACT_EXTRADATA_BSF FILTER_UNITS_BSF SETTS_BSF RAWVIDEO_ENCODER) += fate-dynacolor-h264-dpa +fate-dynacolor-h264-dpa: CMD = stream_remux h264 $(TARGET_SAMPLES)/h264/data_partitioning_ab.h264 "" dynacolor "-map 0:v -bsf:v filter_units=remove_types=7-8,setts=ts=N*DURATION" "" "" + +# MPEG-4 with B-frames and the VOL header only in extradata: the muxer +# repeats it on keyframes and writes B-pictures as such. +FATE_DYNACOLOR_FFMPEG-$(call TRANSCODE, MPEG4, DYNACOLOR, LAVFI_INDEV TESTSRC2_FILTER WRAPPED_AVFRAME_DECODER EXTRACT_EXTRADATA_BSF) += fate-dynacolor-mpeg4 +fate-dynacolor-mpeg4: CMD = transcode lavfi "testsrc2=size=176x144:rate=25:duration=3" dynacolor "-c:v mpeg4 -g 25 -bf 2 -flags +global_header -metadata creation_time=2009-01-21T14:21:08Z" "-c copy" + +# Two channels with keyframes at the same times. After each seek, the +# keyframes of both channels keep the timestamps of linear reading; the other +# records of a channel are estimated until its next indexed keyframe. +tests/data/fate/dynacolor-channels.dyna: TAG = GEN +tests/data/fate/dynacolor-channels.dyna: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data/fate + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin -f lavfi -i testsrc2=s=176x144:r=25:d=3 \ + -f lavfi -i testsrc2=s=128x96:r=25:d=3 -map 0 -map 1 -c:v mpeg4 -g 10 -threads 1 \ + -dct fastint -idct simple -flags +bitexact -fflags +bitexact -y $(TARGET_PATH)/$@ 2>/dev/null + +FATE_DYNACOLOR_FFMPEG-$(call ENCDEC, MPEG4, DYNACOLOR, LAVFI_INDEV TESTSRC2_FILTER WRAPPED_AVFRAME_DECODER) += fate-dynacolor-seek-channels +fate-dynacolor-seek-channels: libavformat/tests/seek$(EXESUF) tests/data/fate/dynacolor-channels.dyna +fate-dynacolor-seek-channels: CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_PATH)/tests/data/fate/dynacolor-channels.dyna -duration 3 -frames 4 + FATE_SAMPLES_FFMPEG += $(FATE_DYNACOLOR-yes) -fate-dynacolor: $(FATE_DYNACOLOR-yes) +FATE_FFMPEG += $(FATE_DYNACOLOR_FFMPEG-yes) +fate-dynacolor: $(FATE_DYNACOLOR-yes) $(FATE_DYNACOLOR_FFMPEG-yes) diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak index 3e5eadaaaa6..106f1803efd 100644 --- a/tests/fate/lavf-container.mak +++ b/tests/fate/lavf-container.mak @@ -1,6 +1,7 @@ FATE_LAVF_CONTAINER-$(call ENCDEC2, MSMPEG4V3, MP2, ASF) += asf FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG4, MP2, AVI) += avi FATE_LAVF_CONTAINER-$(call ENCDEC2, DVVIDEO, PCM_S16LE, AVI) += dv dv_pal dv_ntsc +FATE_LAVF_CONTAINER-$(call ENCDEC, MPEG4, DYNACOLOR) += dynacolor FATE_LAVF_CONTAINER-$(call ENCDEC, FLV, FLV) += flv FATE_LAVF_CONTAINER-$(call ENCDEC, RAWVIDEO, FILMSTRIP) += flm FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, GXF) += gxf gxf_pal gxf_ntsc @@ -41,6 +42,7 @@ fate-lavf-avi fate-lavf-nut: CMD = lavf_container "" "-c:a mp2 -ar 44100 -thread fate-lavf-dv: CMD = lavf_container "-ar 48000 -channel_layout stereo" "-r 25 -s pal" fate-lavf-dv_pal: CMD = lavf_container_timecode_nodrop "-af aresample=48000:tsf=s16p -r 25 -s pal -ac 2 -f dv" fate-lavf-dv_ntsc: CMD = lavf_container_timecode_drop "-af aresample=48000:tsf=s16p -pix_fmt yuv411p -s ntsc -ac 2 -f dv" +fate-lavf-dynacolor: CMD = lavf_container "" "-an -c:v mpeg4 -threads 1 -f dynacolor" fate-lavf-flv fate-lavf-swf: CMD = lavf_container "" "-an" fate-lavf-flm: CMD = lavf_container "" "-pix_fmt rgba" fate-lavf-gxf: CMD = lavf_container "-ar 48000" "-r 25 -s pal -ac 1 -threads 1" diff --git a/tests/ref/fate/dynacolor-h264 b/tests/ref/fate/dynacolor-h264 new file mode 100644 index 00000000000..d34c5fcc7b4 --- /dev/null +++ b/tests/ref/fate/dynacolor-h264 @@ -0,0 +1,33 @@ +94fc272a1651c2dd7525c1547cf0ccfc *tests/data/fate/dynacolor-h264.dynacolor +56895 tests/data/fate/dynacolor-h264.dynacolor +#extradata 0: 36, 0x73960742 +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, -9223372036854775808, 1, 5704, 0x0249f4e1 +0, 1, -9223372036854775808, 1, 3606, 0x49860684, F=0x0 +0, 2, -9223372036854775808, 1, 1710, 0xa4555847, F=0x0 +0, 3, -9223372036854775808, 1, 1852, 0x1ec79818, F=0x0 +0, 4, -9223372036854775808, 1, 1808, 0xafa56955, F=0x0 +0, 5, -9223372036854775808, 1, 3214, 0x07e63879, F=0x0 +0, 6, -9223372036854775808, 1, 1686, 0xe6d36098, F=0x0 +0, 7, -9223372036854775808, 1, 1702, 0x475559b6, F=0x0 +0, 8, -9223372036854775808, 1, 1729, 0xb59b6561, F=0x0 +0, 9, -9223372036854775808, 1, 3033, 0xff2ae70e, F=0x0 +0, 10, -9223372036854775808, 1, 1433, 0x0eb0bf96, F=0x0 +0, 11, -9223372036854775808, 1, 1658, 0x63cc41b2, F=0x0 +0, 12, -9223372036854775808, 1, 1755, 0xea3f73a2, F=0x0 +0, 13, -9223372036854775808, 1, 2615, 0x954509c8, F=0x0 +0, 14, -9223372036854775808, 1, 1489, 0x9d76e07c, F=0x0 +0, 15, -9223372036854775808, 1, 1899, 0xe9609720, F=0x0 +0, 16, -9223372036854775808, 1, 1891, 0x3a66a5d8, F=0x0 +0, 17, -9223372036854775808, 1, 2750, 0x71653748, F=0x0 +0, 18, -9223372036854775808, 1, 1637, 0x9f602d39, F=0x0 +0, 19, -9223372036854775808, 1, 1760, 0x063e5ac7, F=0x0 +0, 20, -9223372036854775808, 1, 1716, 0x75b95471, F=0x0 +0, 21, -9223372036854775808, 1, 2759, 0xfada5f77, F=0x0 +0, 22, -9223372036854775808, 1, 1836, 0x1fbc8d02, F=0x0 +0, 23, -9223372036854775808, 1, 1946, 0x8a9fc6c6, F=0x0 +0, 24, -9223372036854775808, 1, 2107, 0x14012383, F=0x0 diff --git a/tests/ref/fate/dynacolor-h264-aud b/tests/ref/fate/dynacolor-h264-aud new file mode 100644 index 00000000000..bc91b515c21 --- /dev/null +++ b/tests/ref/fate/dynacolor-h264-aud @@ -0,0 +1,33 @@ +40ff3fd7ff25cf4e8f986ea418025e8a *tests/data/fate/dynacolor-h264-aud.dynacolor +57021 tests/data/fate/dynacolor-h264-aud.dynacolor +#extradata 0: 36, 0x73960742 +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, -9223372036854775808, 1, 5710, 0x45dcf4fb +0, 1, -9223372036854775808, 1, 3611, 0x7aba06be, F=0x0 +0, 2, -9223372036854775808, 1, 1715, 0xfdaa58a1, F=0x0 +0, 3, -9223372036854775808, 1, 1857, 0xaa089872, F=0x0 +0, 4, -9223372036854775808, 1, 1813, 0x2b7d69af, F=0x0 +0, 5, -9223372036854775808, 1, 3219, 0xe03b38b3, F=0x0 +0, 6, -9223372036854775808, 1, 1691, 0x37c760f2, F=0x0 +0, 7, -9223372036854775808, 1, 1707, 0x9dda5a10, F=0x0 +0, 8, -9223372036854775808, 1, 1734, 0x15ad65bb, F=0x0 +0, 9, -9223372036854775808, 1, 3038, 0xae8ce748, F=0x0 +0, 10, -9223372036854775808, 1, 1438, 0x06a3bff0, F=0x0 +0, 11, -9223372036854775808, 1, 1663, 0xaad9420c, F=0x0 +0, 12, -9223372036854775808, 1, 1760, 0x537573fc, F=0x0 +0, 13, -9223372036854775808, 1, 2620, 0xe5e40a02, F=0x0 +0, 14, -9223372036854775808, 1, 1494, 0xa919e0d6, F=0x0 +0, 15, -9223372036854775808, 1, 1904, 0x8536977a, F=0x0 +0, 16, -9223372036854775808, 1, 1896, 0xd35da632, F=0x0 +0, 17, -9223372036854775808, 1, 2755, 0xe09a3782, F=0x0 +0, 18, -9223372036854775808, 1, 1642, 0xdf0b2d93, F=0x0 +0, 19, -9223372036854775808, 1, 1765, 0x71275b21, F=0x0 +0, 20, -9223372036854775808, 1, 1721, 0xd12a54cb, F=0x0 +0, 21, -9223372036854775808, 1, 2764, 0x6c285fb1, F=0x0 +0, 22, -9223372036854775808, 1, 1841, 0xa55d8d5c, F=0x0 +0, 23, -9223372036854775808, 1, 1951, 0x36fbc720, F=0x0 +0, 24, -9223372036854775808, 1, 2112, 0xf8e823dd, F=0x0 diff --git a/tests/ref/fate/dynacolor-h264-dpa b/tests/ref/fate/dynacolor-h264-dpa new file mode 100644 index 00000000000..521999c6442 --- /dev/null +++ b/tests/ref/fate/dynacolor-h264-dpa @@ -0,0 +1,17 @@ +41f3849ebe0c1c6ff68251884f79778f *tests/data/fate/dynacolor-h264-dpa.dynacolor +47628 tests/data/fate/dynacolor-h264-dpa.dynacolor +#tb 0: 1/30 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 176x144 +#sar 0: 0/1 +0, 0, 0, 1, 38016, 0x1b6c95f8 +0, 1, 1, 1, 38016, 0xc732de4b +0, 2, 2, 1, 38016, 0x34875d49 +0, 3, 3, 1, 38016, 0x76906edf +0, 4, 4, 1, 38016, 0xe673e1a7 +0, 5, 5, 1, 38016, 0xc2f1f465 +0, 6, 6, 1, 38016, 0x08f49ac4 +0, 7, 7, 1, 38016, 0xee04b8ff +0, 8, 8, 1, 38016, 0xf45202b2 +0, 9, 9, 1, 38016, 0x40051425 diff --git a/tests/ref/fate/dynacolor-h264-recovery b/tests/ref/fate/dynacolor-h264-recovery new file mode 100644 index 00000000000..0c4e21fd288 --- /dev/null +++ b/tests/ref/fate/dynacolor-h264-recovery @@ -0,0 +1,9 @@ +46dd8e60b11fce33eb3dbd830f80a44d *tests/data/fate/dynacolor-h264-recovery.dynacolor +44158 tests/data/fate/dynacolor-h264-recovery.dynacolor +#extradata 0: 182, 0xcaba50c1 +#tb 0: 1/30 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 320x240 +#sar 0: 0/1 +0, 0, -9223372036854775808, 1, 3442, 0x556aac0d diff --git a/tests/ref/fate/dynacolor-h264-recovery-keys b/tests/ref/fate/dynacolor-h264-recovery-keys new file mode 100644 index 00000000000..bbe16167b36 --- /dev/null +++ b/tests/ref/fate/dynacolor-h264-recovery-keys @@ -0,0 +1,19 @@ +d3f294a3e588ae3205af0d36ddaa0bb2 *tests/data/fate/dynacolor-h264-recovery-keys.dynacolor +573768 tests/data/fate/dynacolor-h264-recovery-keys.dynacolor +#extradata 0: 38, 0x9bb009e6 +#tb 0: 1/30 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 320x240 +#sar 0: 0/1 +0, 0, -9223372036854775808, 1, 3297, 0xb6f46532 +0, 54, -9223372036854775808, 1, 4577, 0x94dfe1e3 +0, 122, -9223372036854775808, 1, 3283, 0x3d7050ef +0, 183, -9223372036854775808, 1, 2958, 0x04e0b7bf +0, 194, -9223372036854775808, 1, 13740, 0x2b7c9ef7 +0, 254, -9223372036854775808, 1, 1398, 0xbd27ae9b +0, 314, -9223372036854775808, 1, 1284, 0x7a107f3b +0, 374, -9223372036854775808, 1, 3246, 0x0bf130a8 +0, 434, -9223372036854775808, 1, 3015, 0xbe78d91f +0, 468, -9223372036854775808, 1, 11245, 0xab9f15c7 +0, 510, -9223372036854775808, 1, 9404, 0x85e05b09 diff --git a/tests/ref/fate/dynacolor-mpeg4 b/tests/ref/fate/dynacolor-mpeg4 new file mode 100644 index 00000000000..90398206bbd --- /dev/null +++ b/tests/ref/fate/dynacolor-mpeg4 @@ -0,0 +1,83 @@ +03217b0d227631eea5dc77a2acd3bcef *tests/data/fate/dynacolor-mpeg4.dynacolor +125022 tests/data/fate/dynacolor-mpeg4.dynacolor +#extradata 0: 31, 0x677e067a +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: mpeg4 +#dimensions 0: 176x144 +#sar 0: 1/1 +0, 0, -9223372036854775808, 1, 6342, 0x433db3a0 +0, 1, -9223372036854775808, 1, 5569, 0x3fe79a47, F=0x0 +0, 2, 2, 1, 3281, 0x91c11a85, F=0x0 +0, 3, 3, 1, 3039, 0x8ebda92f, F=0x0 +0, 4, -9223372036854775808, 1, 6633, 0x0a9d0cb6, F=0x0 +0, 5, 5, 1, 2510, 0xb707bd37, F=0x0 +0, 6, 6, 1, 2368, 0xeaf77f50, F=0x0 +0, 7, -9223372036854775808, 1, 5634, 0x7c26afb0, F=0x0 +0, 8, 8, 1, 3092, 0xfd92bed4, F=0x0 +0, 9, 9, 1, 2960, 0xe5b1a55e, F=0x0 +0, 10, -9223372036854775808, 1, 3519, 0x20df4592, F=0x0 +0, 11, 11, 1, 1430, 0xf273c647, F=0x0 +0, 12, 12, 1, 1458, 0x5545d93c, F=0x0 +0, 13, -9223372036854775808, 1, 3060, 0x4194c24f, F=0x0 +0, 14, 14, 1, 778, 0x07c084cb, F=0x0 +0, 15, 15, 1, 868, 0xd266a758, F=0x0 +0, 16, -9223372036854775808, 1, 1902, 0x6e2ec101, F=0x0 +0, 17, 17, 1, 990, 0x0a24fa04, F=0x0 +0, 18, 18, 1, 768, 0xc51285a4, F=0x0 +0, 19, -9223372036854775808, 1, 2126, 0x1edf1bb2, F=0x0 +0, 20, 20, 1, 894, 0xefbbcbe8, F=0x0 +0, 21, 21, 1, 1012, 0x5d50f6e5, F=0x0 +0, 22, -9223372036854775808, 1, 1890, 0x9bd7b6aa, F=0x0 +0, 23, 23, 1, 631, 0x0ab945bc, F=0x0 +0, 24, 24, 1, 670, 0x81ab4f83, F=0x0 +0, 25, -9223372036854775808, 1, 5685, 0xe67687c0 +0, 26, 26, 1, 970, 0x835bdf19, F=0x0 +0, 27, 27, 1, 637, 0x8b9f396d, F=0x0 +0, 28, -9223372036854775808, 1, 1340, 0xe27ca329, F=0x0 +0, 29, 29, 1, 661, 0x9ab344f4, F=0x0 +0, 30, 30, 1, 711, 0xfc8058d4, F=0x0 +0, 31, -9223372036854775808, 1, 1360, 0xcae39e77, F=0x0 +0, 32, 32, 1, 488, 0x817ceb8e, F=0x0 +0, 33, 33, 1, 477, 0x15a9ec0e, F=0x0 +0, 34, -9223372036854775808, 1, 1244, 0xa5aa6beb, F=0x0 +0, 35, 35, 1, 755, 0x11697969, F=0x0 +0, 36, 36, 1, 423, 0x9e9ed13b, F=0x0 +0, 37, -9223372036854775808, 1, 1389, 0x6386b625, F=0x0 +0, 38, 38, 1, 777, 0x30288053, F=0x0 +0, 39, 39, 1, 716, 0xc5946c64, F=0x0 +0, 40, -9223372036854775808, 1, 1317, 0x744b9256, F=0x0 +0, 41, 41, 1, 552, 0xa97a0c59, F=0x0 +0, 42, 42, 1, 807, 0xa92e9040, F=0x0 +0, 43, -9223372036854775808, 1, 1408, 0xbd69c8f2, F=0x0 +0, 44, 44, 1, 528, 0x2bb00712, F=0x0 +0, 45, 45, 1, 578, 0xc3421a07, F=0x0 +0, 46, -9223372036854775808, 1, 1490, 0xd17addd6, F=0x0 +0, 47, 47, 1, 651, 0xed403b00, F=0x0 +0, 48, 48, 1, 696, 0x17c15d65, F=0x0 +0, 49, -9223372036854775808, 1, 5130, 0x886499ca +0, 50, 50, 1, 848, 0x09a1a9a7, F=0x0 +0, 51, 51, 1, 1224, 0xc869774c, F=0x0 +0, 52, -9223372036854775808, 1, 1692, 0x007e46e3, F=0x0 +0, 53, 53, 1, 636, 0x78593a44, F=0x0 +0, 54, 54, 1, 586, 0x955d1697, F=0x0 +0, 55, -9223372036854775808, 1, 1538, 0x387d05c9, F=0x0 +0, 56, 56, 1, 653, 0xf8903d2c, F=0x0 +0, 57, 57, 1, 670, 0x21a94fd8, F=0x0 +0, 58, -9223372036854775808, 1, 1408, 0x65deacdc, F=0x0 +0, 59, 59, 1, 487, 0xaaf8e6af, F=0x0 +0, 60, 60, 1, 569, 0xbe830f57, F=0x0 +0, 61, -9223372036854775808, 1, 1397, 0x3d009f8e, F=0x0 +0, 62, 62, 1, 546, 0x13c00049, F=0x0 +0, 63, 63, 1, 452, 0x41eed618, F=0x0 +0, 64, -9223372036854775808, 1, 1314, 0xcc7b8453, F=0x0 +0, 65, 65, 1, 632, 0xa7f02bf7, F=0x0 +0, 66, 66, 1, 689, 0x31023e63, F=0x0 +0, 67, -9223372036854775808, 1, 1437, 0xde41c784, F=0x0 +0, 68, 68, 1, 745, 0xe94d5b95, F=0x0 +0, 69, 69, 1, 701, 0xa1214c67, F=0x0 +0, 70, -9223372036854775808, 1, 1593, 0x242007cc, F=0x0 +0, 71, 71, 1, 540, 0x1a27ff61, F=0x0 +0, 72, 72, 1, 571, 0xaead0fdf, F=0x0 +0, 73, -9223372036854775808, 1, 4348, 0x9f894597 +0, 74, 74, 1, 732, 0xa8286dda, F=0x0 diff --git a/tests/ref/fate/dynacolor-remux b/tests/ref/fate/dynacolor-remux new file mode 100644 index 00000000000..2d64561ccfd --- /dev/null +++ b/tests/ref/fate/dynacolor-remux @@ -0,0 +1,10 @@ +a37367d69bdf3520bec019d570e4cd5a *tests/data/fate/dynacolor-remux.dynacolor +24381 tests/data/fate/dynacolor-remux.dynacolor +#extradata 0: 19, 0x14fa035e +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: mpeg4 +#dimensions 0: 720x576 +#sar 0: 1/1 +0, 0, 0, 1, 24133, 0x179a3c98 +0, 1, 1, 1, 120, 0xfc814029, F=0x0 diff --git a/tests/ref/fate/dynacolor-seek-channels b/tests/ref/fate/dynacolor-seek-channels new file mode 100644 index 00000000000..8df84edd29b --- /dev/null +++ b/tests/ref/fate/dynacolor-seek-channels @@ -0,0 +1,114 @@ +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 6341 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 +ret: 0 st:-1 flags:0 ts:-1.000000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 6341 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 +ret:-1 st:-1 flags:1 ts:-0.105833 +ret: 0 st: 0 flags:0 ts: 0.800000 +ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos: 106212 size: 5746 +ret: 0 st: 1 flags:1 dts: 0.800000 pts: 0.800000 pos: 112022 size: 5332 +ret: 0 st: 0 flags:0 dts: 0.840000 pts: 0.840000 pos: 117418 size: 1473 +ret: 0 st: 1 flags:0 dts: 0.840000 pts: 0.840000 pos: 118955 size: 1101 +ret: 0 st: 0 flags:1 ts: 1.680000 +ret: 0 st: 0 flags:1 dts: 1.600000 pts: 1.600000 pos: 172088 size: 5862 +ret: 0 st: 1 flags:1 dts: 1.600000 pts: 1.600000 pos: 178014 size: 4835 +ret: 0 st: 0 flags:0 dts: 1.640000 pts: 1.640000 pos: 182913 size: 1207 +ret: 0 st: 1 flags:0 dts: 1.640000 pts: 1.640000 pos: 184184 size: 826 +ret: 0 st: 1 flags:0 ts:-0.440000 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 19480 size: 3997 +ret: 0 st: 1 flags:1 ts: 0.480000 +ret: 0 st: 1 flags:1 dts: 0.400000 pts: 0.400000 pos: 72200 size: 4917 +ret: 0 st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos: 77181 size: 1285 +ret: 0 st: 1 flags:0 dts: 0.440000 pts: 0.440000 pos: 78530 size: 1725 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 80319 size: 1694 +ret: 0 st:-1 flags:0 ts: 1.365002 +ret: 0 st: 0 flags:1 dts: 1.600000 pts: 1.600000 pos: 172088 size: 5862 +ret: 0 st: 1 flags:1 dts: 1.600000 pts: 1.600000 pos: 178014 size: 4835 +ret: 0 st: 0 flags:0 dts: 1.640000 pts: 1.640000 pos: 182913 size: 1207 +ret: 0 st: 1 flags:0 dts: 1.640000 pts: 1.640000 pos: 184184 size: 826 +ret:-1 st:-1 flags:1 ts:-0.740831 +ret: 0 st: 0 flags:0 ts: 0.160000 +ret: 0 st: 0 flags:1 dts: 0.400000 pts: 0.400000 pos: 65665 size: 6471 +ret: 0 st: 1 flags:1 dts: 0.400000 pts: 0.400000 pos: 72200 size: 4917 +ret: 0 st: 0 flags:0 dts: 0.440000 pts: 0.440000 pos: 77181 size: 1285 +ret: 0 st: 1 flags:0 dts: 0.440000 pts: 0.440000 pos: 78530 size: 1725 +ret: 0 st: 0 flags:1 ts: 1.040000 +ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos: 106212 size: 5746 +ret: 0 st: 1 flags:1 dts: 0.800000 pts: 0.800000 pos: 112022 size: 5332 +ret: 0 st: 0 flags:0 dts: 0.840000 pts: 0.840000 pos: 117418 size: 1473 +ret: 0 st: 1 flags:0 dts: 0.840000 pts: 0.840000 pos: 118955 size: 1101 +ret: 0 st: 1 flags:0 ts: 1.960000 +ret: 0 st: 1 flags:1 dts: 2.000000 pts: 2.000000 pos: 208561 size: 4056 +ret: 0 st: 0 flags:0 dts: 2.000000 pts: 2.000000 pos: 212681 size: 1221 +ret: 0 st: 1 flags:0 dts: 2.040000 pts: 2.040000 pos: 213966 size: 913 +ret: 0 st: 0 flags:0 dts: 2.040000 pts: 2.040000 pos: 214943 size: 978 +ret:-1 st: 1 flags:1 ts:-0.160000 +ret: 0 st:-1 flags:0 ts: 0.730004 +ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos: 106212 size: 5746 +ret: 0 st: 1 flags:1 dts: 0.800000 pts: 0.800000 pos: 112022 size: 5332 +ret: 0 st: 0 flags:0 dts: 0.840000 pts: 0.840000 pos: 117418 size: 1473 +ret: 0 st: 1 flags:0 dts: 0.840000 pts: 0.840000 pos: 118955 size: 1101 +ret: 0 st:-1 flags:1 ts: 1.624171 +ret: 0 st: 0 flags:1 dts: 1.600000 pts: 1.600000 pos: 172088 size: 5862 +ret: 0 st: 1 flags:1 dts: 1.600000 pts: 1.600000 pos: 178014 size: 4835 +ret: 0 st: 0 flags:0 dts: 1.640000 pts: 1.640000 pos: 182913 size: 1207 +ret: 0 st: 1 flags:0 dts: 1.640000 pts: 1.640000 pos: 184184 size: 826 +ret: 0 st: 0 flags:0 ts:-0.480000 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 6341 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 +ret: 0 st: 0 flags:1 ts: 0.400000 +ret: 0 st: 0 flags:1 dts: 0.400000 pts: 0.400000 pos: 65665 size: 6471 +ret: 0 st: 1 flags:1 dts: 0.400000 pts: 0.400000 pos: 72200 size: 4917 +ret: 0 st: 0 flags:0 dts: 0.440000 pts: 0.440000 pos: 77181 size: 1285 +ret: 0 st: 1 flags:0 dts: 0.440000 pts: 0.440000 pos: 78530 size: 1725 +ret: 0 st: 1 flags:0 ts: 1.320000 +ret: 0 st: 1 flags:1 dts: 1.600000 pts: 1.600000 pos: 178014 size: 4835 +ret: 0 st: 0 flags:0 dts: 1.000000 pts: 1.000000 pos: 182913 size: 1207 +ret: 0 st: 1 flags:0 dts: 1.640000 pts: 1.640000 pos: 184184 size: 826 +ret: 0 st: 0 flags:0 dts: 1.040000 pts: 1.040000 pos: 185074 size: 1067 +ret:-1 st: 1 flags:1 ts:-0.800000 +ret: 0 st:-1 flags:0 ts: 0.095006 +ret: 0 st: 0 flags:1 dts: 0.400000 pts: 0.400000 pos: 65665 size: 6471 +ret: 0 st: 1 flags:1 dts: 0.400000 pts: 0.400000 pos: 72200 size: 4917 +ret: 0 st: 0 flags:0 dts: 0.440000 pts: 0.440000 pos: 77181 size: 1285 +ret: 0 st: 1 flags:0 dts: 0.440000 pts: 0.440000 pos: 78530 size: 1725 +ret: 0 st:-1 flags:1 ts: 0.989173 +ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos: 106212 size: 5746 +ret: 0 st: 1 flags:1 dts: 0.800000 pts: 0.800000 pos: 112022 size: 5332 +ret: 0 st: 0 flags:0 dts: 0.840000 pts: 0.840000 pos: 117418 size: 1473 +ret: 0 st: 1 flags:0 dts: 0.840000 pts: 0.840000 pos: 118955 size: 1101 +ret: 0 st: 0 flags:0 ts: 1.880000 +ret: 0 st: 0 flags:1 dts: 2.000000 pts: 2.000000 pos: 203327 size: 5170 +ret: 0 st: 1 flags:1 dts: 2.000000 pts: 2.000000 pos: 208561 size: 4056 +ret: 0 st: 0 flags:0 dts: 2.040000 pts: 2.040000 pos: 212681 size: 1221 +ret: 0 st: 1 flags:0 dts: 2.040000 pts: 2.040000 pos: 213966 size: 913 +ret:-1 st: 0 flags:1 ts:-0.240000 +ret: 0 st: 1 flags:0 ts: 0.680000 +ret: 0 st: 1 flags:1 dts: 0.800000 pts: 0.800000 pos: 112022 size: 5332 +ret: 0 st: 0 flags:0 dts: 0.000000 pts: 0.000000 pos: 117418 size: 1473 +ret: 0 st: 1 flags:0 dts: 0.840000 pts: 0.840000 pos: 118955 size: 1101 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 120120 size: 875 +ret: 0 st: 1 flags:1 ts: 1.560000 +ret: 0 st: 1 flags:1 dts: 1.200000 pts: 1.200000 pos: 146563 size: 4726 +ret: 0 st: 0 flags:0 dts: 1.000000 pts: 1.000000 pos: 151353 size: 684 +ret: 0 st: 1 flags:0 dts: 1.240000 pts: 1.240000 pos: 152101 size: 786 +ret: 0 st: 0 flags:0 dts: 1.040000 pts: 1.040000 pos: 152951 size: 1469 +ret: 0 st:-1 flags:0 ts:-0.539992 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 6341 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 +ret: 0 st:-1 flags:1 ts: 0.354175 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 0 size: 6341 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 6405 size: 4575 +ret: 0 st: 0 flags:0 dts: 0.040000 pts: 0.040000 pos: 11044 size: 5684 +ret: 0 st: 1 flags:0 dts: 0.040000 pts: 0.040000 pos: 16792 size: 2624 diff --git a/tests/ref/lavf/dynacolor b/tests/ref/lavf/dynacolor new file mode 100644 index 00000000000..e1c1a955fd7 --- /dev/null +++ b/tests/ref/lavf/dynacolor @@ -0,0 +1,3 @@ +fe1d8e75b2957fcf0a6fbb1fa654f347 *tests/data/lavf/lavf.dynacolor +312744 tests/data/lavf/lavf.dynacolor +tests/data/lavf/lavf.dynacolor CRC=0x9d9a638a -- 2.54.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
