From patchwork Fri Jul 14 14:30:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 4318 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1082560vsb; Fri, 14 Jul 2017 07:31:21 -0700 (PDT) X-Received: by 10.28.153.21 with SMTP id b21mr3180516wme.96.1500042681440; Fri, 14 Jul 2017 07:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500042681; cv=none; d=google.com; s=arc-20160816; b=wkNAZ5us+eHp9Wk6+YDWIq5rDiDh3Bl4GDsqtNdpIMlMTZvH7ewG3MytbVZAKoIejA siMtNZMm/hpAIyhFfHEKGytYs2j2B7dHfXo+HmOYnkGaMyJy1JLhcNYqvnz5dXqPk15A PNm5CyrRsxovoIrlAsEDlGcjNa2xzISSboN2UVffCPFxgTZ5/tdxPmvBM4wY3YOC8uSQ KebG/EJyP8DeaNGhNrLSG3Ap1fJJTeKNeOPV4I4bFlebQDXJrtPzz62eQirUq8FPmbx7 EdDwj/35MWyirCcPth1zBaI10nGzV3Hc/ymeLIl563rs7AELLusHLSLsj8THzcnbSIFi ulvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=bwVm1o6C/PbnyyYmigSRssXgGGxTI+khbhgkBSEWz9o=; b=0qtcxh8xZnk2b8YrQ3El9eGg5VfBn+0SAvUpw8z/7J3f29Vd9+Hgx/tWaGuVSz7wqP AoGWL9LuqbJ3sBFUXxZOkOzT4T1627Si1PUUyH74LXPGnsuv71Ng7w/UzNzbVshI1eG6 QttRLCDZ9Cqa482FExV+vFDOx0SYKJjdYqRGNGxXg7XLLZ4b0K0FUx9fhN/m6LNA6lJP SrglPcxJDOJrniS33rQ1GSZRiPF1mI8p08mSRRkiU6Yru0IUpBFho61egI9G3AHGHowp s66ZfGyQr+wExgvFwcZkXedsWIcuI0coex9YBxosRs8guhw8RFtn/H8bUXuO1TNTUw7D BTqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=K6PJovEq; 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=NONE 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 q189si2407062wma.70.2017.07.14.07.31.20; Fri, 14 Jul 2017 07:31:21 -0700 (PDT) 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.b=K6PJovEq; 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=NONE 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 2FDAF689E69; Fri, 14 Jul 2017 17:31:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 88438689D0D for ; Fri, 14 Jul 2017 17:31:06 +0300 (EEST) Received: by mail-wr0-f177.google.com with SMTP id v60so2060062wrc.3 for ; Fri, 14 Jul 2017 07:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=9wsexBqZJkk7KcS/DmwqERaAu9c7bCvc3h8KCi2OIGM=; b=K6PJovEqittKJxj1VuiXyDzeuniL4aiB63f58L1YfjJqb/TlGGibteIPgw1Vny3vnA TqKqc+mr/EclICTehtS+oEx/btesSbVYHLTxfkM5JGTqatMfAyaQZ+msVMRcdexWxeNI JL0QxEeMqkg+gsMr7SkP1du7bgnrN4xcGte5z0ntJjaKz6NjCDm5jxCyL5Tfx5F1xeYJ 9ArSxGl7W6zEkINBnyKCWCuwtGBHNFM4pVPEYySid3Y4NQjC5Otrav4mTm/OVyy+y1lg kJB/iSpx/HknaNG0UOj5wrxudCrfuY74MOgU/TdMopLOZCWmb3u2cxzZHOpGWDfPo1mz PgHA== 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=9wsexBqZJkk7KcS/DmwqERaAu9c7bCvc3h8KCi2OIGM=; b=ZRex/GBW4ZN8glOQ4uD0n0pZUB3lgt/sU5d9Mdn6LRbmp1JIcZLpNVHB2kV3SJzEzI opMkmEAU0YG58/vQFhPkvsR6y6q/WGZ1JJ44yLw5F+My67T0LbwQkEq2ykJZt86DKFeR IparAlQgEh2IGUINGioflcBAVHgXvfGbekDopYp/BUch+BykHB3aIVOAnwBZwieO4bbR J6Qy9GObsv0yQzvN4a0bNJ05xxksOei4BRFzndQMne7Bzgf/8B3pYAYgYZYhcDk+WSnc VVoq4ZmC0xsZdx+0MI+/Zt2DvMJ6C0e/iYURbvrb7NwcXEstRXnvtS0J12uiX8kKD9LQ FqRw== X-Gm-Message-State: AIVw11348mP2/SMuVAQIhwERKRK1A82M0At0zqPihheJ+c1HpjAnii34 zcvMNgfJ2CgMG3r4 X-Received: by 10.223.165.86 with SMTP id j22mr4584685wrb.147.1500042671440; Fri, 14 Jul 2017 07:31:11 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id q17sm3067860wmd.4.2017.07.14.07.31.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 07:31:10 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jul 2017 16:30:58 +0200 Message-Id: <20170714143058.23905-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avcodec: add MagicYUV encoder 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 | 2 +- libavcodec/magicyuvenc.c | 482 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 484 insertions(+), 1 deletion(-) create mode 100644 libavcodec/magicyuvenc.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 59029a8..af7e1f2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -384,6 +384,7 @@ OBJS-$(CONFIG_M101_DECODER) += m101.o OBJS-$(CONFIG_MACE3_DECODER) += mace.o OBJS-$(CONFIG_MACE6_DECODER) += mace.o OBJS-$(CONFIG_MAGICYUV_DECODER) += magicyuv.o +OBJS-$(CONFIG_MAGICYUV_ENCODER) += magicyuvenc.o OBJS-$(CONFIG_MDEC_DECODER) += mdec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 0243f47..2fe415a 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -239,7 +239,7 @@ static void register_all(void) REGISTER_ENCODER(LJPEG, ljpeg); REGISTER_DECODER(LOCO, loco); REGISTER_DECODER(M101, m101); - REGISTER_DECODER(MAGICYUV, magicyuv); + REGISTER_ENCDEC (MAGICYUV, magicyuv); REGISTER_DECODER(MDEC, mdec); REGISTER_DECODER(MIMIC, mimic); REGISTER_ENCDEC (MJPEG, mjpeg); diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c new file mode 100644 index 0000000..bf79247 --- /dev/null +++ b/libavcodec/magicyuvenc.c @@ -0,0 +1,482 @@ +/* + * MagicYUV encoder + * Copyright (c) 2017 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 +#include + +#include "libavutil/pixdesc.h" +#include "libavutil/qsort.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "put_bits.h" +#include "internal.h" +#include "thread.h" +#include "lossless_videoencdsp.h" + +typedef enum Prediction { + LEFT = 1, + GRADIENT, + MEDIAN, +} Prediction; + +typedef struct HuffEntry { + uint8_t sym; + uint8_t len; + uint32_t code; +} HuffEntry; + +typedef struct MagicYUVContext { + PutBitContext pb; + int planes; + uint8_t format; + AVFrame *p; + int max; + int slice_height; + int nb_slices; + int correlate; + int hshift[4]; + int vshift[4]; + uint8_t *slices[4]; + unsigned slice_pos[4]; + unsigned tables_size; + HuffEntry he[4][256]; + LLVidEncDSPContext llvidencdsp; +} MagicYUVContext; + +static av_cold int magy_encode_init(AVCodecContext *avctx) +{ + MagicYUVContext *s = avctx->priv_data; + int i; + + switch (avctx->pix_fmt) { + case AV_PIX_FMT_GBRP: + avctx->codec_tag = MKTAG('M', '8', 'R', 'G'); + s->correlate = 1; + s->format = 0x65; + break; + case AV_PIX_FMT_GBRAP: + avctx->codec_tag = MKTAG('M', '8', 'R', 'A'); + s->correlate = 1; + s->format = 0x66; + break; + case AV_PIX_FMT_YUV420P: + avctx->codec_tag = MKTAG('M', '8', 'Y', '0'); + s->hshift[1] = + s->vshift[1] = + s->hshift[2] = + s->vshift[2] = 1; + s->format = 0x69; + break; + case AV_PIX_FMT_YUV422P: + avctx->codec_tag = MKTAG('M', '8', 'Y', '2'); + s->hshift[1] = + s->hshift[2] = 1; + s->format = 0x68; + break; + case AV_PIX_FMT_YUV444P: + avctx->codec_tag = MKTAG('M', '8', 'Y', '4'); + s->format = 0x67; + break; + case AV_PIX_FMT_YUVA444P: + avctx->codec_tag = MKTAG('M', '8', 'Y', 'A'); + s->format = 0x6a; + break; + case AV_PIX_FMT_GRAY8: + avctx->codec_tag = MKTAG('M', '8', 'G', '0'); + s->format = 0x6b; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", + avctx->pix_fmt); + return AVERROR_INVALIDDATA; + } + + ff_llvidencdsp_init(&s->llvidencdsp); + + s->planes = av_pix_fmt_count_planes(avctx->pix_fmt); + + s->nb_slices = 1; + + for (i = 0; i < s->planes; i++) { + s->slices[i] = av_malloc(avctx->width * (avctx->height + 2) + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->slices[i]) { + av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer.\n"); + return AVERROR(ENOMEM); + } + } + + return 0; +} + +static void left_predict(uint8_t *src, uint8_t *dst, ptrdiff_t stride, + int width, int height) +{ + uint8_t prev = 0; + int i, j; + + for (i = 0; i < width; i++) { + dst[i] = src[i] - prev; + prev = src[i]; + } + dst += width; + src += stride; + for (j = 1; j < height; j++) { + prev = src[-stride]; + for (i = 0; i < width; i++) { + dst[i] = src[i] - prev; + prev = src[i]; + } + dst += width; + src += stride; + } +} + +static int ff_magy_huff_cmp_len(const void *a, const void *b) +{ + const HuffEntry *aa = a, *bb = b; + return (aa->len - bb->len)*256 + aa->sym - bb->sym; +} + +static int huff_cmp_sym(const void *a, const void *b) +{ + const HuffEntry *aa = a, *bb = b; + return bb->sym - aa->sym; +} + +static void calculate_codes(HuffEntry *he) +{ + uint32_t code; + int i; + + qsort(he, 256, sizeof(*he), ff_magy_huff_cmp_len); + + code = 1; + for (i = 255; i >= 0; i--) { + he[i].code = code >> (32 - he[i].len); + code += 0x80000000u >> (he[i].len - 1); + } + + qsort(he, 256, sizeof(*he), huff_cmp_sym); +} + +typedef struct PTable { + int value; ///< input value + int64_t prob; ///< number of occurences of this value in input +} PTable; + +static void count_usage(uint8_t *src, int width, + int height, PTable *counts) +{ + int i, j; + + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + counts[src[i]].prob++; + } + src += width; + } +} + +typedef struct PackageMergerList { + int nitems; ///< number of items in the list and probability ex. 4 + int item_idx[515]; ///< index range for each item in items 0, 2, 5, 9, 13 + int probability[514]; ///< probability of each item 3, 8, 18, 46 + int items[257 * 16]; ///< chain of all individual values that make up items A, B, A, B, C, A, B, C, D, C, D, D, E +} PackageMergerList; + +static int compare_by_prob(const void *a, const void *b) +{ + PTable a_val = *(PTable *)a; + PTable b_val = *(PTable *)b; + return a_val.prob - b_val.prob; +} + +static void ff_magy_huffman_compute_bits(PTable *prob_table, HuffEntry *distincts, + int size, int max_length) +{ + PackageMergerList list_a, list_b, *to = &list_a, *from = &list_b, *temp; + int times, i, j, k; + int nbits[257] = {0}; + int min; + + av_assert0(max_length > 0); + + to->nitems = 0; + from->nitems = 0; + to->item_idx[0] = 0; + from->item_idx[0] = 0; + AV_QSORT(prob_table, size, PTable, compare_by_prob); + + for (times = 0; times <= max_length; times++) { + to->nitems = 0; + to->item_idx[0] = 0; + + j = 0; + k = 0; + + if (times < max_length) { + i = 0; + } + while (i < size || j + 1 < from->nitems) { + to->nitems++; + to->item_idx[to->nitems] = to->item_idx[to->nitems - 1]; + if (i < size && + (j + 1 >= from->nitems || + prob_table[i].prob < + from->probability[j] + from->probability[j + 1])) { + to->items[to->item_idx[to->nitems]++] = prob_table[i].value; + to->probability[to->nitems - 1] = prob_table[i].prob; + i++; + } else { + for (k = from->item_idx[j]; k < from->item_idx[j + 2]; k++) { + to->items[to->item_idx[to->nitems]++] = from->items[k]; + } + to->probability[to->nitems - 1] = + from->probability[j] + from->probability[j + 1]; + j += 2; + } + } + temp = to; + to = from; + from = temp; + } + + min = (size - 1 < from->nitems) ? size - 1 : from->nitems; + for (i = 0; i < from->item_idx[min]; i++) { + nbits[from->items[i]]++; + } + + for (i = 0; i < size; i++) { + distincts[i].sym = i; + distincts[i].len = nbits[i]; + } +} + +static int encode_table(AVCodecContext *avctx, uint8_t *dst, + int width, int height, + PutBitContext *pb, HuffEntry *he) +{ + PTable counts[257] = { 0 }; + int i; + + count_usage(dst, width, height, counts); + + for (i = 0; i < 256; i++) { + counts[i].prob++; + counts[i].value = i; + } + counts[i].value = 256; + counts[i].prob = 0; + + ff_magy_huffman_compute_bits(counts, he, 256, 16); + + calculate_codes(he); + + for (i = 0; i < 256;) { + put_bits(pb, 1, 0); + put_bits(pb, 7, he[i].len); + i += 1; + } + + return 0; +} + +static int encode_slice(uint8_t *src, uint8_t *dst, int dst_size, + int width, int height, HuffEntry *he) +{ + PutBitContext pb; + int i, j; + int count; + + init_put_bits(&pb, dst, dst_size); + + put_bits(&pb, 8, 0); + put_bits(&pb, 8, LEFT); + + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + const int idx = src[i]; + put_bits(&pb, he[idx].len, he[idx].code); + } + + src += width; + } + + count = put_bits_count(&pb) & 0x1F; + + if (count) + put_bits(&pb, 32 - count, 0); + + count = put_bits_count(&pb); + + flush_put_bits(&pb); + + return count >> 3; +} + +static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + MagicYUVContext *s = avctx->priv_data; + PutByteContext pb; + const int width = avctx->width, height = avctx->height; + int pos, slice, i, j, ret = 0; + + ret = ff_alloc_packet2(avctx, pkt, (256 + 4 * s->nb_slices + width * height) * + s->planes + 256, 0); + if (ret < 0) + return ret; + + bytestream2_init_writer(&pb, pkt->data, pkt->size); + bytestream2_put_le32(&pb, MKTAG('M', 'A', 'G', 'Y')); + bytestream2_put_le32(&pb, 32); + bytestream2_put_byte(&pb, 7); + bytestream2_put_byte(&pb, s->format); + bytestream2_put_byte(&pb, 0); + bytestream2_put_byte(&pb, 0); + bytestream2_put_le32(&pb, 0); + + bytestream2_put_le32(&pb, avctx->width); + bytestream2_put_le32(&pb, avctx->height); + bytestream2_put_le32(&pb, avctx->width); + bytestream2_put_le32(&pb, avctx->height); + bytestream2_put_le32(&pb, 0); + + for (i = 0; i < s->planes; i++) { + bytestream2_put_le32(&pb, 0); + for (j = 1; j < s->nb_slices; j++) { + bytestream2_put_le32(&pb, 0); + } + } + + bytestream2_put_byte(&pb, s->planes); + + for (i = 0; i < s->planes; i++) { + for (slice = 0; slice < s->nb_slices; slice++) { + bytestream2_put_byte(&pb, i); + } + } + + if (s->correlate) { + uint8_t *r, *g, *b; + AVFrame *p = av_frame_clone(frame); + + g = p->data[0]; + b = p->data[1]; + r = p->data[2]; + + for (i = 0; i < height; i++) { + s->llvidencdsp.diff_bytes(b, b, g, width); + s->llvidencdsp.diff_bytes(r, r, g, width); + g += p->linesize[0]; + b += p->linesize[1]; + r += p->linesize[2]; + } + + FFSWAP(uint8_t*, p->data[0], p->data[1]); + FFSWAP(int, p->linesize[0], p->linesize[1]); + + for (i = 0; i < s->planes; i++) { + for (slice = 0; slice < s->nb_slices; slice++) { + left_predict(p->data[i], s->slices[i], p->linesize[i], + p->width, p->height); + } + } + + av_frame_free(&p); + } else { + for (i = 0; i < s->planes; i++) { + for (slice = 0; slice < s->nb_slices; slice++) { + left_predict(frame->data[i], s->slices[i], frame->linesize[i], + AV_CEIL_RSHIFT(frame->width, s->hshift[i]), + AV_CEIL_RSHIFT(frame->height, s->vshift[i])); + } + } + } + + init_put_bits(&s->pb, pkt->data + bytestream2_tell_p(&pb), bytestream2_get_bytes_left_p(&pb)); + + for (i = 0; i < s->planes; i++) { + encode_table(avctx, s->slices[i], + AV_CEIL_RSHIFT(frame->width, s->hshift[i]), + AV_CEIL_RSHIFT(frame->height, s->vshift[i]), + &s->pb, s->he[i]); + } + s->tables_size = (put_bits_count(&s->pb) + 7) >> 3; + bytestream2_skip_p(&pb, s->tables_size); + + for (i = 0; i < s->planes; i++) { + unsigned slice_size; + + s->slice_pos[i] = bytestream2_tell_p(&pb); + slice_size = encode_slice(s->slices[i], pkt->data + bytestream2_tell_p(&pb), + bytestream2_get_bytes_left_p(&pb), + AV_CEIL_RSHIFT(frame->width, s->hshift[i]), + AV_CEIL_RSHIFT(frame->height, s->vshift[i]), + s->he[i]); + bytestream2_skip_p(&pb, slice_size); + } + + pos = bytestream2_tell_p(&pb); + bytestream2_seek_p(&pb, 32, SEEK_SET); + bytestream2_put_le32(&pb, s->slice_pos[0] - 32); + for (i = 0; i < s->planes; i++) { + bytestream2_put_le32(&pb, s->slice_pos[i] - 32); + } + bytestream2_seek_p(&pb, pos, SEEK_SET); + + pkt->size = bytestream2_tell_p(&pb); + pkt->flags |= AV_PKT_FLAG_KEY; + + *got_packet = 1; + + return 0; +} + +static av_cold int magy_encode_close(AVCodecContext *avctx) +{ + MagicYUVContext *s = avctx->priv_data; + int i; + + for (i = 0; i < s->planes; i++) + av_freep(&s->slices[i]); + + return 0; +} + +AVCodec ff_magicyuv_encoder = { + .name = "magicyuv", + .long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MAGICYUV, + .priv_data_size = sizeof(MagicYUVContext), + .init = magy_encode_init, + .close = magy_encode_close, + .encode2 = magy_encode_frame, + .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, + .pix_fmts = (const enum AVPixelFormat[]) { + AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8, + AV_PIX_FMT_NONE + }, +};