From: "Rémi Denis-Courmont" <remi@remlab.net> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avcodec: add farbfeld encoder Date: Mon, 03 Jun 2024 09:05:58 +0300 Message-ID: <8BB15462-F176-4ADB-B01E-BC726256B80F@remlab.net> (raw) In-Reply-To: <20240603032722.352435-2-marcus@marcusspencer.xyz> Le 3 juin 2024 06:27:16 GMT+03:00, Marcus B Spencer <marcus@marcusspencer.xyz> a écrit : >farbfeld is an uncompressed image format that is a part of suckless >tools (https://tools.suckless.org). > >Its documentation is available at https://tools.suckless.org/farbfeld. > >Add support for this image format in avcodec and update the image2 >format accordingly. > >Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz> >--- > Changelog | 1 + > doc/general_contents.texi | 2 + > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/codec_desc.c | 7 ++++ > libavcodec/codec_id.h | 1 + > libavcodec/farbfeldenc.c | 84 +++++++++++++++++++++++++++++++++++++++ > libavcodec/version.h | 2 +- > libavformat/img2.c | 1 + > libavformat/img2enc.c | 2 +- > 10 files changed, 100 insertions(+), 2 deletions(-) > create mode 100644 libavcodec/farbfeldenc.c >diff --git a/libavcodec/farbfeldenc.c b/libavcodec/farbfeldenc.c >new file mode 100644 >index 0000000000..e48eba680e >--- /dev/null >+++ b/libavcodec/farbfeldenc.c >@@ -0,0 +1,84 @@ >+/* >+ * Copyright (c) 2024 Marcus B Spencer <marcus@marcusspencer.xyz> >+ * >+ * Permission is hereby granted, free of charge, to any person obtaining a copy >+ * of this software and associated documentation files (the “Software”), to >+ * deal in the Software without restriction, including without limitation the >+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >+ * sell copies of the Software, and to permit persons to whom the Software is >+ * furnished to do so, subject to the following conditions: >+ * >+ * The above copyright notice and this permission notice shall be included in >+ * all copies or substantial portions of the Software. >+ * >+ * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS >+ * IN THE SOFTWARE. >+ */ >+ >+#include "libavutil/imgutils.h" >+#include "codec_internal.h" >+#include "bytestream.h" >+#include "avcodec.h" >+#include "encode.h" >+ >+#define HEADER_SIZE 16 >+ >+static int farbfeld_encode_frame(AVCodecContext *ctx, AVPacket *pkt, >+ const AVFrame *p, int *got_packet) >+{ >+ int pkt_size = HEADER_SIZE + av_image_get_buffer_size( >+ p->format, >+ p->width, >+ p->height, >+ 1 >+ ); >+ uint8_t *buf; >+ int ret; >+ >+ if (pkt_size < 0) >+ return pkt_size; >+ >+ // 16 is the header size >+ if ((ret = ff_get_encode_buffer(ctx, pkt, pkt_size, 0)) < 0) >+ return ret; >+ >+ buf = pkt->data; >+ >+ bytestream_put_buffer(&buf, "farbfeld", 8); >+ >+ bytestream_put_be32(&buf, ctx->width); >+ bytestream_put_be32(&buf, ctx->height); >+ >+ av_image_copy_to_buffer( >+ buf, >+ pkt_size - HEADER_SIZE, >+ (const uint8_t **)p->data, Bogus cast / aliasing violation. >+ p->linesize, >+ p->format, >+ p->width, >+ p->height, >+ 1 >+ ); >+ >+ *got_packet = 1; >+ >+ return 0; >+} >+ >+const FFCodec ff_farbfeld_encoder = { >+ .p.name = "farbfeld", >+ CODEC_LONG_NAME("farbfeld uncompressed image"), >+ .p.type = AVMEDIA_TYPE_VIDEO, >+ .p.id = AV_CODEC_ID_FARBFELD, >+ .p.capabilities = AV_CODEC_CAP_DR1, >+ FF_CODEC_ENCODE_CB(farbfeld_encode_frame), >+ .p.pix_fmts = (const enum AVPixelFormat[]){ >+ AV_PIX_FMT_RGBA64BE, >+ AV_PIX_FMT_NONE >+ }, >+}; _______________________________________________ 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".
next prev parent reply other threads:[~2024-06-03 6:06 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-03 3:27 Marcus B Spencer 2024-06-03 6:05 ` Rémi Denis-Courmont [this message] 2024-06-03 19:29 ` marcus 2024-06-03 19:38 ` Rémi Denis-Courmont 2024-06-03 21:56 ` Andreas Rheinhardt 2024-06-04 6:04 ` Rémi Denis-Courmont 2024-06-04 7:06 ` Andreas Rheinhardt 2024-06-04 7:19 ` Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=8BB15462-F176-4ADB-B01E-BC726256B80F@remlab.net \ --to=remi@remlab.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git