From patchwork Tue Jan 24 15:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 40097 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp458128pzj; Tue, 24 Jan 2023 07:59:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXuNF1/RVfc2PnV4AkWV1vU831pVUjSt3sk11D5gGof9IpPKO5TVggOCtNSuBD8CSKubNa X-Received: by 2002:a17:906:5a5f:b0:86f:3c6b:f7c6 with SMTP id my31-20020a1709065a5f00b0086f3c6bf7c6mr31337234ejc.64.1674575973284; Tue, 24 Jan 2023 07:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674575973; cv=none; d=google.com; s=arc-20160816; b=IaTHXzPDK6Mt8lWmwS1H1H/5AIzUAEnuEFYE0aqqHsl+ebjsZiDExh+dyU1iT+b2Mi foizNzg6Wi+TXzRDkRPFgWpRVmfndyP50gqD9No1ikk1XP6bocw/dL8KVkrjYDEKFPE/ Ek0pmxNXNUJXGBUuMYJPg1KP697dd6N9rkYttRa9Eh4jCj+zYkXFsQB8UjK8VhMWPdg9 xsM7CE/5C3bBV+QpgoRDJkvJQOcrzhPMWmJC58ZTsXeRlGi3ECy+XR7YBEPYagmn0uKH +dGHursyF8t/VKNitxg4/aEMrJsNBn7XxgzSUoKvge6/2r+5wYS9NoICLC+92aiSB9cg 9S6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=PrB6SHm7Sgqrgq8mottGYY4Y/ZqYh7BR9uPtsoDtRcI=; b=uklH6wOjbYByIZm5C6QrpQzCxJb+u1jqf4+OvHgAACAnBsuZ0vZ+BRNUcDSroYYMGp cAtOAk+5RxuvsZzfVRuMYCbM3Ccsxao6oB/pJAabI6ilWwgNeqWlz4hDoIhyobBs3OAs yLt/ipB6dWISjN2wUpZPFMzQXnOF0ocAz5CcveA3uwexgXG28jdkhi9biUajSJO2m5Mv ugmjqG6BskoNRG/Uf0UlyOW0lgii8SQF8QFRLjPNZ5HC6rvgY7/mzud1ozuZSsIseEGO Z4ejEzqLjrME/dYqPgKO/eHAITwXoFsWy6MS9n5uTdV6yFMGkRqoxmXC9wBgjjYXnX5c pGbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YanqX6eu; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c17-20020a17090620d100b0084a52896279si2734744ejc.950.2023.01.24.07.59.32; Tue, 24 Jan 2023 07:59:33 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YanqX6eu; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A70A568BE06; Tue, 24 Jan 2023 17:59:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0A0B68BA9D for ; Tue, 24 Jan 2023 17:59:23 +0200 (EET) Received: by mail-vs1-f54.google.com with SMTP id t10so16920375vsr.3 for ; Tue, 24 Jan 2023 07:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=MYB/OVWuznSDL9SLM/7/LLYnRTRqkMojwLb0CKy9Cv0=; b=YanqX6eu0o4wIbGBmt1B234HdNnrgbB3jAoOe1nEC1SgFUZHsiW0A7l+nRfJgf0nVJ q4sR4X/m2SCp2hZjAqrF4oqKeOtlQaY9SkoO7RF5Dico9u54YjbjlNDKvaElTj3x4dvf 1FRzj9lPPS5MSzhlCQ2Z/NURQeyhlZsYVsnR0IlFN3/ZBpm8HXNzJOyxMcjrYNkai0Is hWk8solTGsQOetnURCwdq3vR/Zt1B5tYRbrCkuIi9zURWcwLtzO3RYt/4fKtopkmW5JA v4TyDhjjdU5lwi7zA7BPVfiUKRqMhsBt/BwqIntwPjEWZRKLfP2HYjCgI7/ZU+00RUAq fQIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MYB/OVWuznSDL9SLM/7/LLYnRTRqkMojwLb0CKy9Cv0=; b=k1zh7eoq9DurR7AG1HvwVvEJH9Q1jhTXbgKhSvUaGgjt53OKzhIWYCT01ULdNKyh5X Y7kd3vZm66P16aUzaFg2WWoU72b35nKXQ7qXhKNtQZsnbfExey8V16iH/uvRgi/cd2Yo xmMTR0PpmiGIJ2I+zqLWJzRM+iFimOVwjOhj54oD600xfTdNuXR9Qx/GcsUVNHXcIf0S G4e7DeKgWXPKLZfN8WcKHhXW90jipzjcq7wpHdIY9l5qULdVSX6YIyTLxLK5pwN6JnGV Fa/gWxrXiGFIWOThlRXyXjJmJ6ZhMyhmtUhdkXLJg2ngAqzy/z1Ql3iyr5eEDgitHllY 73Gg== X-Gm-Message-State: AFqh2kraFT+JjwAeSaOASPIFJfm8zQS2uum0pzbEIyIX7RI/TuHIyRTR y4ii4zRYK2h/tLkouDphZy8Tw73ZOpSuWRsT7GWxf0Bo X-Received: by 2002:a05:6102:1510:b0:3d3:e5dc:e359 with SMTP id f16-20020a056102151000b003d3e5dce359mr3817657vsv.61.1674575961816; Tue, 24 Jan 2023 07:59:21 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:612c:2428:b0:32a:5eaa:92e4 with HTTP; Tue, 24 Jan 2023 07:59:20 -0800 (PST) From: Paul B Mahol Date: Tue, 24 Jan 2023 16:59:20 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec: add CBD2 DPCM decoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pLJkjCUI43Yi Hi, Patch attached. From 0c4254ed685660fe1bb714a32ea378ddbb23e64e Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 24 Jan 2023 16:14:25 +0100 Subject: [PATCH] avcodec: add CBD2 DPCM decoder Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 +++++++ libavcodec/codec_id.h | 1 + libavcodec/dpcm.c | 10 ++++++++++ libavformat/aiff.c | 1 + libavformat/aiffdec.c | 1 + 7 files changed, 22 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index bfa8132580..e691c8d180 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -277,6 +277,7 @@ OBJS-$(CONFIG_BRENDER_PIX_DECODER) += brenderpix.o OBJS-$(CONFIG_C93_DECODER) += c93.o OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \ cavsdata.o +OBJS-$(CONFIG_CBD2_DECODER) += dpcm.o OBJS-$(CONFIG_CCAPTION_DECODER) += ccaption_dec.o ass.o OBJS-$(CONFIG_CDGRAPHICS_DECODER) += cdgraphics.o OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index a5ab0cb4fe..74e1b00e96 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -621,6 +621,7 @@ extern const FFCodec ff_pcm_vidc_encoder; extern const FFCodec ff_pcm_vidc_decoder; /* DPCM codecs */ +extern const FFCodec ff_cbd2_dpcm_decoder; extern const FFCodec ff_derf_dpcm_decoder; extern const FFCodec ff_gremlin_dpcm_decoder; extern const FFCodec ff_interplay_dpcm_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index f4cbdf744b..6ecdf1002b 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2626,6 +2626,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("DPCM Marble WADY"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_CBD2_DPCM, + .type = AVMEDIA_TYPE_AUDIO, + .name = "cbd2_dpcm", + .long_name = NULL_IF_CONFIG_SMALL("DPCM Cuberoot-Delta-Exact"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* audio codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 60e36cc8a9..ba3b432387 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -431,6 +431,7 @@ enum AVCodecID { AV_CODEC_ID_GREMLIN_DPCM, AV_CODEC_ID_DERF_DPCM, AV_CODEC_ID_WADY_DPCM, + AV_CODEC_ID_CBD2_DPCM, /* audio codecs */ AV_CODEC_ID_MP2 = 0x15000, diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 86cb9134f8..6ea9e2c065 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -194,6 +194,13 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx) } break; + case AV_CODEC_ID_CBD2_DPCM: + for (i = -128; i < 128; i++) { + int16_t cube = (i * i * i) / 64; + s->array[i+128] = cube; + } + break; + case AV_CODEC_ID_GREMLIN_DPCM: { int delta = 0; int code = 64; @@ -265,6 +272,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, case AV_CODEC_ID_WADY_DPCM: case AV_CODEC_ID_DERF_DPCM: case AV_CODEC_ID_GREMLIN_DPCM: + case AV_CODEC_ID_CBD2_DPCM: case AV_CODEC_ID_SDX2_DPCM: out = buf_size; break; @@ -386,6 +394,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, } break; + case AV_CODEC_ID_CBD2_DPCM: case AV_CODEC_ID_SDX2_DPCM: while (output_samples < samples_end) { int8_t n = bytestream2_get_byteu(&gb); @@ -468,6 +477,7 @@ const FFCodec ff_ ## name_ ## _decoder = { \ FF_CODEC_DECODE_CB(dpcm_decode_frame), \ } +DPCM_DECODER(AV_CODEC_ID_CBD2_DPCM, cbd2_dpcm, "DPCM Cuberoot-Delta-Exact"); DPCM_DECODER(AV_CODEC_ID_DERF_DPCM, derf_dpcm, "DPCM Xilam DERF"); DPCM_DECODER(AV_CODEC_ID_GREMLIN_DPCM, gremlin_dpcm, "DPCM Gremlin"); DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); diff --git a/libavformat/aiff.c b/libavformat/aiff.c index 0f25b436bd..1ceac69a70 100644 --- a/libavformat/aiff.c +++ b/libavformat/aiff.c @@ -46,6 +46,7 @@ const AVCodecTag ff_codec_aiff_tags[] = { { AV_CODEC_ID_QDMC, MKTAG('Q','D','M','C') }, { AV_CODEC_ID_QDM2, MKTAG('Q','D','M','2') }, { AV_CODEC_ID_QCELP, MKTAG('Q','c','l','p') }, + { AV_CODEC_ID_CBD2_DPCM, MKTAG('C','B','D','2') }, { AV_CODEC_ID_SDX2_DPCM, MKTAG('S','D','X','2') }, { AV_CODEC_ID_ADPCM_IMA_WS, MKTAG('A','D','P','4') }, { AV_CODEC_ID_NONE, 0 }, diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 80733e5801..1cde12c193 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -164,6 +164,7 @@ static int get_aiff_header(AVFormatContext *s, int64_t size, case AV_CODEC_ID_ADPCM_IMA_WS: case AV_CODEC_ID_ADPCM_G722: case AV_CODEC_ID_MACE6: + case AV_CODEC_ID_CBD2_DPCM: case AV_CODEC_ID_SDX2_DPCM: par->block_align = 1 * channels; break; -- 2.39.1