Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt()
@ 2023-02-24  8:59 Tomas Härdin
  2023-02-24  9:00 ` [FFmpeg-devel] [PATCH 2/4] lavc/mediacodec_wrapper: Refactor ff_AMediaCodecList_getCodecNameByType() Tomas Härdin
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Tomas Härdin @ 2023-02-24  8:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-lavc-mediacodecenc-Add-pix2color_fmt-and-color2pix_f.patch --]
[-- Type: text/x-patch, Size: 2211 bytes --]

From 7374dab21cb37dc14d2481c72d333b435e23a76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 10 Jan 2023 20:37:18 +0100
Subject: [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and
 color2pix_fmt()

This patch has been released by Epic Games' legal department.
---
 libavcodec/mediacodecenc.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index a92a8dc5a9..03c80cbf99 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -2,6 +2,7 @@
  * Android MediaCodec encoders
  *
  * Copyright (c) 2022 Zhao Zhili <zhilizhao@tencent.com>
+ * Modifications by Epic Games, Inc., 2023.
  *
  * This file is part of FFmpeg.
  *
@@ -110,6 +111,26 @@ static void mediacodec_output_format(AVCodecContext *avctx)
     ff_AMediaFormat_delete(out_format);
 }
 
+static int pix2color_fmt(AVCodecContext *avctx, enum AVPixelFormat pix_fmt)
+{
+    for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
+        if (pix_fmt == color_formats[i].pix_fmt) {
+            return color_formats[i].color_format;
+        }
+    }
+    av_assert0(0);
+}
+
+static enum AVPixelFormat color2pix_fmt(AVCodecContext *avctx, int color_format)
+{
+    for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
+        if (color_format == color_formats[i].color_format) {
+            return color_formats[i].pix_fmt;
+        }
+    }
+    av_assert0(0);
+}
+
 static int mediacodec_init_bsf(AVCodecContext *avctx)
 {
     MediaCodecEncContext *s = avctx->priv_data;
@@ -235,13 +256,7 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
         }
     }
 
-    for (int i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
-        if (avctx->pix_fmt == color_formats[i].pix_fmt) {
-            ff_AMediaFormat_setInt32(format, "color-format",
-                                     color_formats[i].color_format);
-            break;
-        }
-    }
+    ff_AMediaFormat_setInt32(format, "color-format", pix2color_fmt(avctx, avctx->pix_fmt));
 
     if (avctx->bit_rate)
         ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-28 12:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24  8:59 [FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt() Tomas Härdin
2023-02-24  9:00 ` [FFmpeg-devel] [PATCH 2/4] lavc/mediacodec_wrapper: Refactor ff_AMediaCodecList_getCodecNameByType() Tomas Härdin
2023-02-28 12:13   ` "zhilizhao(赵志立)"
2023-02-24  9:00 ` [FFmpeg-devel] [PATCH 3/4] lavc/mediacodec_wrapper: Add function for probing supported color formats Tomas Härdin
2023-02-28 12:18   ` "zhilizhao(赵志立)"
2023-02-24  9:03 ` [FFmpeg-devel] [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on configuration error Tomas Härdin
2023-02-28 12:25   ` "zhilizhao(赵志立)"
2023-02-28 12:02 ` [FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt() "zhilizhao(赵志立)"

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