-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path0001-cartwheel-imtl-y210le-support.patch
96 lines (89 loc) · 3.45 KB
/
0001-cartwheel-imtl-y210le-support.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 97931318cc23dfea90629a2c4e9fd17828df4111 Mon Sep 17 00:00:00 2001
From: Tomasz Szumski <[email protected]>
Date: Wed, 9 Oct 2024 08:37:30 +0200
Subject: [PATCH] cartwheel imtl y210le support
---
ecosystem/ffmpeg_plugin/mtl_st20p_rx.c | 20 ++++++++++++++++++++
ecosystem/ffmpeg_plugin/mtl_st20p_tx.c | 13 +++++++++++++
2 files changed, 33 insertions(+)
diff --git a/ecosystem/ffmpeg_plugin/mtl_st20p_rx.c b/ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
index af7c247..6323b77 100644
--- a/ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
+++ b/ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
@@ -21,6 +21,7 @@
#ifdef MTL_GPU_DIRECT_ENABLED
#include <mtl_gpu_direct/gpu.h>
#endif /* MTL_GPU_DIRECT_ENABLED */
+#include <mtl/st_convert_api.h>
typedef struct MtlSt20pDemuxerContext {
const AVClass* class; /**< Class for private options. */
@@ -120,6 +121,10 @@ static int mtl_st20p_read_header(AVFormatContext* ctx) {
ops_rx.transport_fmt = ST20_FMT_YUV_422_10BIT;
ops_rx.output_fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
break;
+ case AV_PIX_FMT_Y210LE:
+ ops_rx.transport_fmt = ST20_FMT_YUV_422_10BIT;
+ ops_rx.output_fmt = ST_FRAME_FMT_Y210;
+ break;
case AV_PIX_FMT_RGB24:
ops_rx.transport_fmt = ST20_FMT_RGB_8BIT;
ops_rx.output_fmt = ST_FRAME_FMT_RGB8;
@@ -256,6 +261,21 @@ static int mtl_st20p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
st20p_rx_put_frame(s->rx_handle, frame);
return ret;
}
+
+ switch (s->pixel_format) {
+ case AV_PIX_FMT_Y210LE:
+ ret = st20_rfc4175_422be10_to_y210(
+ (struct st20_rfc4175_422_10_pg2_be*)frame, (uint16_t*)pkt->data,
+ s->width, s->height);
+ if (ret != 0) {
+ av_log(ctx, AV_LOG_ERROR,
+ "st20_rfc4175_422be10_to_y210le failed with %d\n", ret);
+ // s->stopped = true;
+ // pthread_mutex_unlock(&(s->read_packet_mutex));
+ return ret;
+ break;
+ }
+ }
/* todo: zero copy with external frame mode */
mtl_memcpy(pkt->data, frame->addr[0], ctx->packet_size);
st20p_rx_put_frame(s->rx_handle, frame);
diff --git a/ecosystem/ffmpeg_plugin/mtl_st20p_tx.c b/ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
index 48c7b4a..0bbcf6e 100644
--- a/ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
+++ b/ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
@@ -18,6 +18,7 @@
*/
#include "mtl_common.h"
+#include <mtl/st_convert_api.h>
typedef struct mtlSt20pMuxerContext {
const AVClass* class; /**< Class for private options. */
@@ -94,6 +95,10 @@ static int mtl_st20p_write_header(AVFormatContext* ctx) {
ops_tx.input_fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
ops_tx.transport_fmt = ST20_FMT_YUV_422_10BIT;
break;
+ case AV_PIX_FMT_Y210LE:
+ ops_tx.transport_fmt = ST20_FMT_YUV_422_10BIT;
+ ops_tx.input_fmt = ST_FRAME_FMT_Y210;
+ break;
case AV_PIX_FMT_RGB24:
ops_tx.input_fmt = ST_FRAME_FMT_RGB8;
ops_tx.transport_fmt = ST20_FMT_RGB_8BIT;
@@ -152,6 +157,14 @@ static int mtl_st20p_write_packet(AVFormatContext* ctx, AVPacket* pkt) {
return AVERROR(EIO);
}
dbg(ctx, "%s(%d), st20p_tx_get_frame: %p\n", __func__, s->idx, frame);
+
+ switch (s->pixel_format) {
+ case AV_PIX_FMT_Y210LE:
+ st20_y210_to_rfc4175_422be10(
+ (uint16_t*)pkt->data, (struct st20_rfc4175_422_10_pg2_be*)(frame->addr[0]),
+ s->width, s->height);
+ break;
+ }
/* todo: zero copy with external frame mode */
mtl_memcpy(frame->addr[0], pkt->data, s->frame_size);
--
2.46.2.windows.1