From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D2DCE4BBB1 for ; Sat, 1 Feb 2025 14:48:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B38CE68C2ED; Sat, 1 Feb 2025 16:48:32 +0200 (EET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA45C68BFBD for ; Sat, 1 Feb 2025 16:48:26 +0200 (EET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-219f8263ae0so54907505ad.0 for ; Sat, 01 Feb 2025 06:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738421304; x=1739026104; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=RWYRBi6mol/sSPVBuL3wKtaEZdiYueLgp0JmX0sLaOg=; b=JgN9MJLmVX5sg+VpeKDYbphUrlOA5cQBkE+tZ3pAYN1pgrDhLQkoTclJoDO7TrxTx4 7+WMIH2ZM/hbQrWdA77Uerk0QhTY1Jhv2PGx7ISa47WiMuuJSb8WHZYMKC6EkR02kNlX +YYwtnPsG4pLtIIY0oPViP0dOp25a++hPWlTCbK/MCgy1RPNXsg2nzMcLqV5cSTOJyhJ 8AvwnGtMpS6EJjmQcRUreDL9ziSfypJfZLwvX/BWlxdFghh/jDkM3SLlQlBMvHuf1Pl/ ZsUe2ea1A5gcPtqzETwU1RVM7oW4meGYs7vlgTF4vAC3/9vrRy7uKII0rxm0KUK3M5u4 6ETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738421304; x=1739026104; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RWYRBi6mol/sSPVBuL3wKtaEZdiYueLgp0JmX0sLaOg=; b=p52HX1r4SESyIiP4K80jgREXQ2FLCR+1og7ja+bRFSFeS96tsKBYjqK+5iy38ao3Zr VbozAHHRI3QW11DBwrqlcd2PDyvmCabEHs6iKvF0VMepj5w0SWSr3cwBmx98yoX6T3sb hOM8jb1GLHSsMPQTK9su05x+HYWE8SxX8pfUVqdbmm184fW418sUB5YBjW57+lDkYjck rva/kSpA888wjcNj3hK+dXfFONvUY5KEHpdJXRhzZ+9oc+J1oLCQKYaThIbtJnbE2+P/ vRfmxrxicRSgFJHB65F5cHhhkbiSTKlBZ/E/on4OyxJ9ARbb8FHl/3lJwB5Sotme6YSW LYzw== X-Gm-Message-State: AOJu0YzxEfgIr2mHuwZF4UxsQi/cqXUpvvybzbycmAmhHXQjOxhPIQC1 jNRIZabQOHhhCemNyo5iwaX8lj45ijTvFW+B03/GixSshNFfMiRRKTpn+si9 X-Gm-Gg: ASbGncurNbQZj2wvzeoAQ4L4l3o3ov/ZAoW8KtWVTzIIIiDO77UqXQBwFSZTiuVg9hk pRHQOAgkm7OHAa5aHBdHZrDjDToMVEZ6u1emfa/i4J4w7COrLhzzsntGj2AySqVBCt1sveVTgGf FFCMNqwgqCoYJ9tgbA3JlS0me1HXKqrmGYzdYAPZ1P7ho6b8XysypPOWebJaBDWnIEMD2amkkcR 3br3u5TZ6ebJ2P5hB/u18TsPdpONDEKjyfoWuPucOeRLR7EyzZGP7gaH+qA8TUVhAHIaE3AtCt6 /58zXX2axLfGST5mZuwG4080hMfewJ9T X-Google-Smtp-Source: AGHT+IEP3aKUNCKBqv/cH2L7HCbN7qOinTV+eA61/zdFNechxfhuBeJHfrQiTNbUpzEGXd8oGdeWlQ== X-Received: by 2002:a17:902:e803:b0:21d:dfae:3014 with SMTP id d9443c01a7336-21ddfae3494mr182674165ad.10.1738421304194; Sat, 01 Feb 2025 06:48:24 -0800 (PST) Received: from localhost.localdomain ([2800:2121:b040:c:4c60:7427:1f30:5ddd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21de32ea5e6sm46723885ad.152.2025.02.01.06.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2025 06:48:23 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Feb 2025 11:48:11 -0300 Message-ID: <20250201144811.8015-1-jamrial@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec: add a simple ffv1 parser 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Only setting key frames. Signed-off-by: James Almer --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/ffv1_parser.c | 45 ++++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + 4 files changed, 48 insertions(+) create mode 100644 libavcodec/ffv1_parser.c diff --git a/configure b/configure index 06f641ead0..f09faaf505 100755 --- a/configure +++ b/configure @@ -3469,6 +3469,7 @@ vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec" aac_parser_select="adts_header mpeg4audio" av1_parser_select="cbs_av1" evc_parser_select="evcparse" +ffv1_parser_select="rangecoder" ftr_parser_select="adts_header mpeg4audio" h264_parser_select="golomb h264dsp h264parse h264_sei" hevc_parser_select="hevcparse hevc_sei" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a3ef11a258..1df595d58f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1207,6 +1207,7 @@ OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o OBJS-$(CONFIG_EVC_PARSER) += evc_parser.o +OBJS-$(CONFIG_FFV1_PARSER) += ffv1_parser.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o OBJS-$(CONFIG_FTR_PARSER) += ftr_parser.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o diff --git a/libavcodec/ffv1_parser.c b/libavcodec/ffv1_parser.c new file mode 100644 index 0000000000..f9fd1152d0 --- /dev/null +++ b/libavcodec/ffv1_parser.c @@ -0,0 +1,45 @@ +/* + * 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 "avcodec.h" +#include "rangecoder.h" + +static int parse(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + RangeCoder c; + uint8_t keystate = 128; + ff_init_range_decoder(&c, buf, buf_size); + ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8); + + *poutbuf = buf; + *poutbuf_size = buf_size; + s->key_frame = get_rac(&c, &keystate); + s->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P, see ffv1dec.c + s->field_order = AV_FIELD_UNKNOWN; + s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; + + return buf_size; +} + +const AVCodecParser ff_ffv1_parser = { + .codec_ids = { AV_CODEC_ID_FFV1 }, + .parser_parse = parse, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 8bfd2dbce0..5387351fd0 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -45,6 +45,7 @@ extern const AVCodecParser ff_dvd_nav_parser; extern const AVCodecParser ff_evc_parser; extern const AVCodecParser ff_flac_parser; extern const AVCodecParser ff_ftr_parser; +extern const AVCodecParser ff_ffv1_parser; extern const AVCodecParser ff_g723_1_parser; extern const AVCodecParser ff_g729_parser; extern const AVCodecParser ff_gif_parser; -- 2.48.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".