[FFmpeg-cvslog] swscale/input: add VUYA input support

2022-08-05 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Aug  4 00:10:30 
2022 -0300| [f0abd07996c35d2160488cb7e6794eb6d22cecc9] | committer: James Almer

swscale/input: add VUYA input support

Reviewed-by: Philip Langdale 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0abd07996c35d2160488cb7e6794eb6d22cecc9
---

 libswscale/input.c   | 35 +++
 libswscale/utils.c   |  1 +
 libswscale/version.h |  2 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 750367b28b..68abc4d62c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -650,6 +650,32 @@ static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t 
*src, const uint8_t *u
 AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
 }
 
+static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t 
*unused0, const uint8_t *src,
+   const uint8_t *unused1, int width, uint32_t 
*unused2)
+{
+int i;
+for (i = 0; i < width; i++) {
+dstU[i] = src[i * 4 + 1];
+dstV[i] = src[i * 4];
+}
+}
+
+static void read_vuya_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+  uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+dst[i] = src[i * 4 + 2];
+}
+
+static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+  uint32_t *unused2)
+{
+int i;
+for (i = 0; i < width; i++)
+dst[i] = src[i * 4 + 3];
+}
+
 /* This is almost identical to the previous, end exists only because
  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1, const uint8_t *unused2,  int width,
@@ -1229,6 +1255,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->chrToYV12 = bswap16UV_c;
 break;
 #endif
+case AV_PIX_FMT_VUYA:
+c->chrToYV12 = read_vuya_UV_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->chrToYV12 = read_ayuv64le_UV_c;
 break;
@@ -1591,6 +1620,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_YA16BE:
 c->lumToYV12 = read_ya16be_gray_c;
 break;
+case AV_PIX_FMT_VUYA:
+c->lumToYV12 = read_vuya_Y_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->lumToYV12 = read_ayuv64le_Y_c;
 break;
@@ -1746,6 +1778,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_YA16BE:
 c->alpToYV12 = read_ya16be_alpha_c;
 break;
+case AV_PIX_FMT_VUYA:
+c->alpToYV12 = read_vuya_A_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->alpToYV12 = read_ayuv64le_A_c;
 break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c0504a6dfc..bc3d1c955c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -258,6 +258,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_P416BE]  = { 1, 1 },
 [AV_PIX_FMT_P416LE]  = { 1, 1 },
 [AV_PIX_FMT_NV16]= { 1, 1 },
+[AV_PIX_FMT_VUYA]= { 1, 0 },
 };
 
 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
diff --git a/libswscale/version.h b/libswscale/version.h
index bb7e324876..3193562d18 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR   8
-#define LIBSWSCALE_VERSION_MICRO 101
+#define LIBSWSCALE_VERSION_MICRO 102
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vsrc_ddagrab: move most of init to config_props

2022-08-05 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Fri Aug  
5 14:27:53 2022 +0200| [cbb53bfbd803f6407f6e19211b2cf47dc9711408] | committer: 
Timo Rothenpieler

avfilter/vsrc_ddagrab: move most of init to config_props

Most notably, the input hw_device_ctx is not set at init time, so using it was 
impossible.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbb53bfbd803f6407f6e19211b2cf47dc9711408
---

 libavfilter/vsrc_ddagrab.c | 80 +-
 1 file changed, 37 insertions(+), 43 deletions(-)

diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 0543e889ad..2f33a40f6f 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -389,56 +389,15 @@ static av_cold int init_render_resources(AVFilterContext 
*avctx)
 static av_cold int ddagrab_init(AVFilterContext *avctx)
 {
 DdagrabContext *dda = avctx->priv;
-int ret = 0;
-
-if (avctx->hw_device_ctx) {
-dda->device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data;
-
-if (dda->device_ctx->type != AV_HWDEVICE_TYPE_D3D11VA) {
-av_log(avctx, AV_LOG_ERROR, "Non-D3D11VA input hw_device_ctx\n");
-return AVERROR(EINVAL);
-}
-
-dda->device_ref = av_buffer_ref(avctx->hw_device_ctx);
-if (!dda->device_ref)
-return AVERROR(ENOMEM);
-
-av_log(avctx, AV_LOG_VERBOSE, "Using provided hw_device_ctx\n");
-} else {
-ret = av_hwdevice_ctx_create(&dda->device_ref, 
AV_HWDEVICE_TYPE_D3D11VA, NULL, NULL, 0);
-if (ret < 0) {
-av_log(avctx, AV_LOG_ERROR, "Failed to create D3D11VA device.\n");
-return ret;
-}
-
-dda->device_ctx = (AVHWDeviceContext*)dda->device_ref->data;
-
-av_log(avctx, AV_LOG_VERBOSE, "Created internal hw_device_ctx\n");
-}
-
-dda->device_hwctx = (AVD3D11VADeviceContext*)dda->device_ctx->hwctx;
-
-ret = init_dxgi_dda(avctx);
-if (ret < 0)
-goto fail;
-
-dda->time_base  = av_inv_q(dda->framerate);
-dda->time_frame = av_gettime_relative() / av_q2d(dda->time_base);
-dda->time_timeout = av_rescale_q(1, dda->time_base, (AVRational) { 1, 1000 
}) / 2;
 
 dda->last_frame = av_frame_alloc();
-if (!dda->last_frame) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!dda->last_frame)
+return AVERROR(ENOMEM);
 
 dda->mouse_x = -1;
 dda->mouse_y = -1;
 
 return 0;
-fail:
-ddagrab_uninit(avctx);
-return ret;
 }
 
 static int create_d3d11_pointer_tex(AVFilterContext *avctx,
@@ -710,6 +669,37 @@ static int ddagrab_config_props(AVFilterLink *outlink)
 DdagrabContext *dda = avctx->priv;
 int ret;
 
+if (avctx->hw_device_ctx) {
+dda->device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data;
+
+if (dda->device_ctx->type != AV_HWDEVICE_TYPE_D3D11VA) {
+av_log(avctx, AV_LOG_ERROR, "Non-D3D11VA input hw_device_ctx\n");
+return AVERROR(EINVAL);
+}
+
+dda->device_ref = av_buffer_ref(avctx->hw_device_ctx);
+if (!dda->device_ref)
+return AVERROR(ENOMEM);
+
+av_log(avctx, AV_LOG_VERBOSE, "Using provided hw_device_ctx\n");
+} else {
+ret = av_hwdevice_ctx_create(&dda->device_ref, 
AV_HWDEVICE_TYPE_D3D11VA, NULL, NULL, 0);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Failed to create D3D11VA device.\n");
+return ret;
+}
+
+dda->device_ctx = (AVHWDeviceContext*)dda->device_ref->data;
+
+av_log(avctx, AV_LOG_VERBOSE, "Created internal hw_device_ctx\n");
+}
+
+dda->device_hwctx = (AVD3D11VADeviceContext*)dda->device_ctx->hwctx;
+
+ret = init_dxgi_dda(avctx);
+if (ret < 0)
+return ret;
+
 ret = probe_output_format(avctx);
 if (ret < 0)
 return ret;
@@ -717,6 +707,10 @@ static int ddagrab_config_props(AVFilterLink *outlink)
 dda->width -= FFMAX(dda->width - dda->raw_width + dda->offset_x, 0);
 dda->height -= FFMAX(dda->height - dda->raw_height + dda->offset_y, 0);
 
+dda->time_base  = av_inv_q(dda->framerate);
+dda->time_frame = av_gettime_relative() / av_q2d(dda->time_base);
+dda->time_timeout = av_rescale_q(1, dda->time_base, (AVRational) { 1, 1000 
}) / 2;
+
 if (dda->draw_mouse) {
 ret = init_render_resources(avctx);
 if (ret < 0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vsrc_ddagrab: fix mouse cursor render init

2022-08-05 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Fri Aug  
5 14:02:44 2022 +0200| [fbf87a46ab97cf487141002d660bf4ed9379e334] | committer: 
Timo Rothenpieler

avfilter/vsrc_ddagrab: fix mouse cursor render init

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fbf87a46ab97cf487141002d660bf4ed9379e334
---

 libavfilter/vsrc_ddagrab.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 98daec1d04..0543e889ad 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -435,12 +435,6 @@ static av_cold int ddagrab_init(AVFilterContext *avctx)
 dda->mouse_x = -1;
 dda->mouse_y = -1;
 
-if (dda->draw_mouse) {
-ret = init_render_resources(avctx);
-if (ret < 0)
-goto fail;
-}
-
 return 0;
 fail:
 ddagrab_uninit(avctx);
@@ -723,6 +717,12 @@ static int ddagrab_config_props(AVFilterLink *outlink)
 dda->width -= FFMAX(dda->width - dda->raw_width + dda->offset_x, 0);
 dda->height -= FFMAX(dda->height - dda->raw_height + dda->offset_y, 0);
 
+if (dda->draw_mouse) {
+ret = init_render_resources(avctx);
+if (ret < 0)
+return ret;
+}
+
 ret = init_hwframes_ctx(avctx);
 if (ret < 0)
 return ret;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".