From patchwork Wed Feb 17 19:42:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 25714 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 79A0844A27A for ; Wed, 17 Feb 2021 21:43:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B13668A2A9; Wed, 17 Feb 2021 21:43:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE092689DC3 for ; Wed, 17 Feb 2021 21:42:53 +0200 (EET) Received: by mail-ej1-f48.google.com with SMTP id do6so13898216ejc.3 for ; Wed, 17 Feb 2021 11:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=LZMIEoKdQP3HUeuRRm0lekW+0Z99xlUnYHlfeJhxO6g=; b=TRd9sjWKl9Y1gbmjizpY1v54X0vda+zIAQmdZkfcddIQ+CCD6eivnM9pH+LosMbu9Y NF3+39hcFMNMlVZ99+eaUs6ydCIVhmQWau/Z+YGRele1sVGMNo3IG06xbiHDQMVk1F4n QE+Q7h6Px+Kqovjydq9Z2mqPo8q9xL8grC457mCEHAdmC5HvQVTWPPAEYEdWYwDuheoO OgXGvH5LYdpTuqa9snRlSAEstx2DEsg1HWGhvsQwcxXz7DOwGgvneWGu8hFsV4QlpSsO UWY51glZTwKCoTTYCBllM17FCgnkpAs3yGJAOf78J+ReftLOqiAlYPs7inXGrxVvJ6Fg XI3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=LZMIEoKdQP3HUeuRRm0lekW+0Z99xlUnYHlfeJhxO6g=; b=D+uVQhOdLs7S6jBaMX6M6r936SxpfklPF6/yLs6sr9oKvWLO21xnoQk0lr2djfAIUZ ARAFNITLfpG0Q9FG/98pO761c5+uXpNKc8fKPGfSug/RNHJC9SQbZMT4UA4J9ZOkyRWP ImbLXgV1A8KrIYg40SH2lFr/pZcC4DPVqC1t8ViW8JSE5ftWZjIf5ykaSrWRe+0XxneY HBcNok3yokyTHCRyL0srVkFZew+2ZF/HEN52g1nW92B7D9/mkq/iw/+UAf79M63tJmDg EONkU1Fyc0lOlJFphFZdag+SCtE+mua/MfWNs8jWWOVzuMA0jCuXx6Idr/qzgX/Lw5kD 2HYQ== X-Gm-Message-State: AOAM530V5gZazIFyA/qcuWVVchzgGczgyZEkxYVrkgsxcC4w+gT4F8Jx eqCvszaqxKsGTQhMCMWpncR04gUHFb/2cA== X-Google-Smtp-Source: ABdhPJyogGIOXueLWZRbupUsDGjoDOm/GVIJmt+TiaV8lDGBVhPSihe07o3bvhnxVX3zFDNwqmR9wQ== X-Received: by 2002:a17:907:78d5:: with SMTP id kv21mr488511ejc.461.1613590973391; Wed, 17 Feb 2021 11:42:53 -0800 (PST) Received: from localhost.localdomain ([94.250.162.225]) by smtp.gmail.com with ESMTPSA id w24sm797768edu.2.2021.02.17.11.42.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 11:42:53 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Feb 2021 20:42:36 +0100 Message-Id: <20210217194237.26754-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec: add Simbiosis IMX video decoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/imx.c | 153 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 libavcodec/imx.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 82d1f15b40..6a57ddf2b1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -620,6 +620,7 @@ OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \ acelp_filters.o celp_filters.o \ sipr16k.o OBJS-$(CONFIG_SIREN_DECODER) += siren.o +OBJS-$(CONFIG_SIMBIOSIS_IMX_DECODER) += imx.o OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMC_DECODER) += smc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index cb3f0e7c18..354d146379 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -293,6 +293,7 @@ extern AVCodec ff_sgi_encoder; extern AVCodec ff_sgi_decoder; extern AVCodec ff_sgirle_decoder; extern AVCodec ff_sheervideo_decoder; +extern AVCodec ff_simbiosis_imx_decoder; extern AVCodec ff_smacker_decoder; extern AVCodec ff_smc_decoder; extern AVCodec ff_smvjpeg_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index a7594f9004..8e695b11d2 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1842,6 +1842,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_SIMBIOSIS_IMX, + .type = AVMEDIA_TYPE_VIDEO, + .name = "simbiosis_imx", + .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 7a8a896bfe..56a69cf1c2 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -305,6 +305,7 @@ enum AVCodecID { AV_CODEC_ID_IPU, AV_CODEC_ID_ARGO, AV_CODEC_ID_CRI, + AV_CODEC_ID_SIMBIOSIS_IMX, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/imx.c b/libavcodec/imx.c new file mode 100644 index 0000000000..1552a4ebea --- /dev/null +++ b/libavcodec/imx.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2021 Paul B Mahol + * + * 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/common.h" +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +typedef struct SimbiosisIMXContext { + uint32_t pal[256]; + uint8_t history[32768]; + int pos; +} SimbiosisIMXContext; + +static av_cold int imx_decode_init(AVCodecContext *avctx) +{ + avctx->pix_fmt = AV_PIX_FMT_PAL8; + avctx->width = 320; + avctx->height = 160; + return 0; +} + +static int imx_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) +{ + SimbiosisIMXContext *imx = avctx->priv_data; + int ret, x, y, pal_size; + const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size); + AVFrame *frame = data; + GetByteContext gb; + + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + if (pal && pal_size == AVPALETTE_SIZE) { + memcpy(imx->pal, pal, pal_size); + frame->palette_has_changed = 1; + } + + bytestream2_init(&gb, avpkt->data, avpkt->size); + + memcpy(frame->data[1], imx->pal, AVPALETTE_SIZE); + + x = 0, y = 0; + while (bytestream2_get_bytes_left(&gb) > 0 && + x < 320 && y < 160) { + int b = bytestream2_get_byte(&gb); + int len = b & 0x3f; + int op = b >> 6; + int fill; + + switch (op) { + case 3: + len = len * 64 + bytestream2_get_byte(&gb); + case 0: + while (len > 0) { + x++; + len--; + if (x >= 320) { + x = 0; + y++; + } + if (y >= 160) + break; + } + break; + case 1: + if (len == 0) { + int offset = bytestream2_get_le16(&gb); + + if (offset < 0 || offset >= 32768) + return AVERROR_INVALIDDATA; + + len = bytestream2_get_byte(&gb); + while (len > 0 && offset < 32768) { + frame->data[0][x + y * frame->linesize[0]] = imx->history[offset++]; + x++; + len--; + if (x >= 320) { + x = 0; + y++; + } + if (y >= 160) + break; + } + } else { + while (len > 0) { + fill = bytestream2_get_byte(&gb); + frame->data[0][x + y * frame->linesize[0]] = fill; + if (imx->pos < 32768) + imx->history[imx->pos++] = fill; + x++; + len--; + if (x >= 320) { + x = 0; + y++; + } + if (y >= 160) + break; + } + } + break; + case 2: + fill = bytestream2_get_byte(&gb); + + while (len > 0) { + frame->data[0][x + y * frame->linesize[0]] = fill; + x++; + len--; + if (x >= 320) { + x = 0; + y++; + } + if (y >= 160) + break; + } + break; + } + } + + *got_frame = 1; + + return avpkt->size; +} + +AVCodec ff_simbiosis_imx_decoder = { + .name = "simbiosis_imx", + .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_SIMBIOSIS_IMX, + .priv_data_size = sizeof(SimbiosisIMXContext), + .init = imx_decode_init, + .decode = imx_decode_frame, + .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, +}; From patchwork Wed Feb 17 19:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 25716 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CA3BF44A27A for ; Wed, 17 Feb 2021 21:43:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B103568A326; Wed, 17 Feb 2021 21:43:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C302068A192 for ; Wed, 17 Feb 2021 21:42:54 +0200 (EET) Received: by mail-ej1-f48.google.com with SMTP id hs11so24377477ejc.1 for ; Wed, 17 Feb 2021 11:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=HHwHQ7scTTDcPGrt3/TveiNCSmFOw9vHMfky36k85Vc=; b=jBCoXfaCVmG7fsQ61yN7UEFiPxt3xobJvx0LRrMKBVse/ro0uy5xxSMM2ftkaY/mKE RpOUZh5T8bUfnGgsFowv7/lmS2DABKCngWKO6E/BGgb3M7Q2IJLrBp65aUcOzMiviTGB YfgGC5B+dNhVHreUZQDIUqfzl+f9n6qFRJbcMlFBtQ/QjAKytzTilOMBILxAYtka7hNo J13jbxlAeJwAiSVAIvaBO6aADsFdKfUgQjuD7+1L7PA8gSgryaN2fuUEPgCAxFslsafv m2NXUh0phjhIpcs3ZfEYPn+gK5vBuA17K4cu0esql25L48YqwETr025JHFiBPuYXvYUk IzYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HHwHQ7scTTDcPGrt3/TveiNCSmFOw9vHMfky36k85Vc=; b=PNesud7JzMH2ZFEaBON9nT8Mgf+rIdgIazuS+g0fqCsusLIeml5YORLBdeVkGK0jeY E9CGtTaGaGv8OY3+hk64W8EKk7w8U7/XK646FRVbJlcS7eRCMPNl/4ibbU2Prl270par AQ6IFqNLKn/p6OJRdvhac1L/pBxQJki5xPVhksyRVxnGUWEZHX1N37gkSE+cEAnebhET URM0AEKI4VU4XdFWUHrGQ6aN80jQtC1BkqHexvAbpvl9m+QKullwMfZdD3r4ULihad8d cmpigadw6eGmF/W0Ak6fbS1MoUfItSsg0NCyEPU9OZGmiZotMdVqx0gSPv1d2nNYbUZL FFuA== X-Gm-Message-State: AOAM530wa9aVKL3LeA6VDvWtXhBC559Uv8hZJypoFHK5MSGWOdmbcLR8 C73DbxEMNOHk6mxdkV3dUeheOUMbdrEPHA== X-Google-Smtp-Source: ABdhPJxnLvUKEebpOpvANSu6B5UhG+hdfHSgxoRhS1Z4nhr5VpvX4531kAK2tXvj10/iifXE9BLykg== X-Received: by 2002:a17:906:4e1a:: with SMTP id z26mr495637eju.349.1613590974351; Wed, 17 Feb 2021 11:42:54 -0800 (PST) Received: from localhost.localdomain ([94.250.162.225]) by smtp.gmail.com with ESMTPSA id w24sm797768edu.2.2021.02.17.11.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 11:42:54 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Feb 2021 20:42:37 +0100 Message-Id: <20210217194237.26754-2-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210217194237.26754-1-onemda@gmail.com> References: <20210217194237.26754-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avformat: add Simbiosis IMX demuxer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/imx.c | 160 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 libavformat/imx.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 7bbf000cdc..e4d1f82c78 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -504,6 +504,7 @@ OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o OBJS-$(CONFIG_SER_DEMUXER) += serdec.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += shortendec.o rawdec.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o +OBJS-$(CONFIG_SIMBIOSIS_IMX_DEMUXER) += imx.o OBJS-$(CONFIG_SINGLEJPEG_MUXER) += rawenc.o OBJS-$(CONFIG_SLN_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index f837ddabc8..3b69423508 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -403,6 +403,7 @@ extern AVOutputFormat ff_stream_segment_muxer; extern AVInputFormat ff_ser_demuxer; extern AVInputFormat ff_shorten_demuxer; extern AVInputFormat ff_siff_demuxer; +extern AVInputFormat ff_simbiosis_imx_demuxer; extern AVOutputFormat ff_singlejpeg_muxer; extern AVInputFormat ff_sln_demuxer; extern AVInputFormat ff_smacker_demuxer; diff --git a/libavformat/imx.c b/libavformat/imx.c new file mode 100644 index 0000000000..66f18177a5 --- /dev/null +++ b/libavformat/imx.c @@ -0,0 +1,160 @@ +/* + * Simbiosis game demuxer + * + * Copyright (C) 2021 Paul B Mahol + * + * 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 "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" +#include "libavutil/internal.h" +#include "argo_asf.h" + +#define IMX_TAG MKTAG('I', 'M', 'A', 'X') + +typedef struct SimbiosisIMXDemuxContext { + uint8_t pal[AVPALETTE_SIZE]; + int pal_changed; +} SimbiosisIMXDemuxContext; + +static int simbiosis_imx_probe(const AVProbeData *p) +{ + if (AV_RL32(p->buf) != IMX_TAG) + return 0; + if (AV_RN32(p->buf+4) == 0) + return 0; + if (AV_RN16(p->buf+8) == 0) + return 0; + if (AV_RL16(p->buf+10) != 0x102) + return 0; + + return AVPROBE_SCORE_EXTENSION + 10; +} + +static int simbiosis_imx_read_header(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + AVStream *vst, *ast; + int rate; + + vst = avformat_new_stream(s, NULL); + ast = avformat_new_stream(s, NULL); + if (!vst || !ast) + return AVERROR(ENOMEM); + + avio_skip(pb, 4); + + vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + vst->codecpar->codec_tag = 0; + vst->codecpar->format = AV_PIX_FMT_PAL8; + vst->codecpar->codec_id = AV_CODEC_ID_SIMBIOSIS_IMX; + vst->start_time = 0; + vst->nb_frames = avio_rl32(pb); + rate = avio_rl16(pb); + avio_skip(pb, 12); + + avpriv_set_pts_info(vst, 64, 1, rate); + + ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + ast->codecpar->codec_tag = 0; + ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8; + ast->codecpar->channels = 1; + ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + ast->codecpar->sample_rate = 22050; + ast->start_time = 0; + + avpriv_set_pts_info(ast, 64, 1, 22050); + + return 0; +} + +static int simbiosis_imx_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVIOContext *pb = s->pb; + SimbiosisIMXDemuxContext *imx = s->priv_data; + uint32_t chunk_size, chunk_type; + int64_t pos = avio_tell(pb); + int ret, idx = -1; + +retry: + if (avio_feof(pb)) + return AVERROR_EOF; + + chunk_size = avio_rl32(pb); + chunk_type = avio_rl32(pb); + + switch (chunk_type) { + case 0xAAFF: + return AVERROR_EOF; + case 0xAA99: + idx = 1; + break; + case 0xAA97: + idx = 0; + break; + case 0xAA98: + for (int i = 0; i < chunk_size / 3; i++) { + unsigned r = avio_r8(pb) << 18; + unsigned g = avio_r8(pb) << 10; + unsigned b = avio_r8(pb) << 2; + + AV_WL32(imx->pal + i * 4, (0xFFU << 24) | r | g | b); + } + imx->pal_changed = 1; + idx = -1; + break; + default: + return AVERROR_INVALIDDATA; + } + + if (idx == -1) + goto retry; + + ret = av_get_packet(pb, pkt, chunk_size); + if (ret < 0) + return ret; + + if (imx->pal_changed && idx == 0) { + uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, + AVPALETTE_SIZE); + if (!pal) + return AVERROR(ENOMEM); + memcpy(pal, imx->pal, AVPALETTE_SIZE); + imx->pal_changed = 0; + pkt->flags |= AV_PKT_FLAG_KEY; + } + + pkt->pos = pos; + pkt->stream_index = idx; + pkt->duration = idx ? chunk_size : 1; + + return ret; +} + +AVInputFormat ff_simbiosis_imx_demuxer = { + .name = "simbiosis_imx", + .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX"), + .priv_data_size = sizeof(SimbiosisIMXDemuxContext), + .read_probe = simbiosis_imx_probe, + .read_header = simbiosis_imx_read_header, + .read_packet = simbiosis_imx_read_packet, + .extensions = "imx", + .flags = AVFMT_GENERIC_INDEX, +};