* [FFmpeg-devel] [PATCH 2/3] avfilter/vf_transpose_vt: fix output frame dimension
[not found] <20230818142408.74329-1-quinkblack@foxmail.com>
@ 2023-08-18 14:24 ` Zhao Zhili
2023-08-18 14:24 ` [FFmpeg-devel] [PATCH 3/3] avfilter/vf_transpose_vt: fix declaration-after-statement Zhao Zhili
1 sibling, 0 replies; 2+ messages in thread
From: Zhao Zhili @ 2023-08-18 14:24 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Create a new hardware frame context when necessary.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
libavfilter/vf_transpose_vt.c | 47 +++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 5 deletions(-)
diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c
index b5b07e9ef1..da59479a4b 100644
--- a/libavfilter/vf_transpose_vt.c
+++ b/libavfilter/vf_transpose_vt.c
@@ -102,6 +102,39 @@ fail:
return ret;
}
+static int transpose_vt_recreate_hw_ctx(AVFilterLink *outlink)
+{
+ AVFilterContext *avctx = outlink->src;
+ AVFilterLink *inlink = outlink->src->inputs[0];
+ AVHWFramesContext *hw_frame_ctx_in;
+ AVHWFramesContext *hw_frame_ctx_out;
+ int err;
+
+ av_buffer_unref(&outlink->hw_frames_ctx);
+
+ hw_frame_ctx_in = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
+ outlink->hw_frames_ctx = av_hwframe_ctx_alloc(hw_frame_ctx_in->device_ref);
+ hw_frame_ctx_out = (AVHWFramesContext *)outlink->hw_frames_ctx->data;
+ hw_frame_ctx_out->format = AV_PIX_FMT_VIDEOTOOLBOX;
+ hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format;
+ hw_frame_ctx_out->width = outlink->w;
+ hw_frame_ctx_out->height = outlink->h;
+
+ err = ff_filter_init_hw_frames(avctx, outlink, 1);
+ if (err < 0)
+ return err;
+
+ err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
+ if (err < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Failed to init videotoolbox frame context, %s\n",
+ av_err2str(err));
+ return err;
+ }
+
+ return 0;
+}
+
static int transpose_vt_config_output(AVFilterLink *outlink)
{
int err;
@@ -113,6 +146,9 @@ static int transpose_vt_config_output(AVFilterLink *outlink)
CFBooleanRef hflip = kCFBooleanFalse;
int swap_w_h = 0;
+ av_buffer_unref(&outlink->hw_frames_ctx);
+ outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+
if ((inlink->w >= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
(inlink->w <= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
av_log(avctx, AV_LOG_VERBOSE,
@@ -175,12 +211,12 @@ static int transpose_vt_config_output(AVFilterLink *outlink)
return AVERROR_EXTERNAL;
}
- if (swap_w_h) {
- outlink->w = inlink->h;
- outlink->h = inlink->w;
- }
+ if (!swap_w_h)
+ return 0;
- return 0;
+ outlink->w = inlink->h;
+ outlink->h = inlink->w;
+ return transpose_vt_recreate_hw_ctx(outlink);
}
#define OFFSET(x) offsetof(TransposeVtContext, x)
@@ -244,4 +280,5 @@ const AVFilter ff_vf_transpose_vt = {
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VIDEOTOOLBOX),
.priv_class = &transpose_vt_class,
.flags = AVFILTER_FLAG_HWDEVICE,
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
--
2.40.1
_______________________________________________
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] 2+ messages in thread
* [FFmpeg-devel] [PATCH 3/3] avfilter/vf_transpose_vt: fix declaration-after-statement
[not found] <20230818142408.74329-1-quinkblack@foxmail.com>
2023-08-18 14:24 ` [FFmpeg-devel] [PATCH 2/3] avfilter/vf_transpose_vt: fix output frame dimension Zhao Zhili
@ 2023-08-18 14:24 ` Zhao Zhili
1 sibling, 0 replies; 2+ messages in thread
From: Zhao Zhili @ 2023-08-18 14:24 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
libavfilter/vf_transpose_vt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c
index da59479a4b..a3b2b9be79 100644
--- a/libavfilter/vf_transpose_vt.c
+++ b/libavfilter/vf_transpose_vt.c
@@ -69,11 +69,12 @@ static int transpose_vt_filter_frame(AVFilterLink *link, AVFrame *in)
AVFilterLink *outlink = ctx->outputs[0];
CVPixelBufferRef src;
CVPixelBufferRef dst;
+ AVFrame *out;
if (s->passthrough)
return ff_filter_frame(outlink, in);
- AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
ret = AVERROR(ENOMEM);
goto fail;
--
2.40.1
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2023-08-18 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230818142408.74329-1-quinkblack@foxmail.com>
2023-08-18 14:24 ` [FFmpeg-devel] [PATCH 2/3] avfilter/vf_transpose_vt: fix output frame dimension Zhao Zhili
2023-08-18 14:24 ` [FFmpeg-devel] [PATCH 3/3] avfilter/vf_transpose_vt: fix declaration-after-statement Zhao Zhili
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