1 year ago
#310005
massivemoisture
Undefined symbols "_sws_getContext" for architecture aarm64
I'm playing around with scrcpy
source code (https://github.com/Genymobile/scrcpy).
I run my build of scrcpy with my Android phone and see that the AVFrame in this code (from /app/src/screen.c
):
static bool
sc_screen_update_frame(struct sc_screen *screen) {
av_frame_unref(screen->frame);
sc_video_buffer_consume(&screen->vb, screen->frame);
AVFrame *frame = screen->frame;
...
}
that the AVFrame that scrcpy gets from the device has the pixel format of AV_PIX_FMT_YUV420P
.
I want to change this format to something more common like AV_PIX_FMT_BGRA
. I found some tutorial online that suggested using sws_getContext
.
So I add these lines to that sc_screen_update_frame
function:
AVFrame* converted = av_frame_alloc();
converted->format = AV_PIX_FMT_BGRA;
converted->width = frame->width;
converted->height = frame->height;
av_frame_get_buffer(converted, 0);
struct SwsContext *img_convert_context = sws_getContext(frame->width,
frame->height,
(enum AVPixelFormat)frame->format,
converted->width,
converted->height,
(enum AVPixelFormat)converted->format,
SWS_BICUBIC, NULL, NULL, NULL);
sws_scale(img_convert_context,
frame->data,
frame->linesize,
0,
converted->height,
converted->data[0],
converted->linesize);
And then I build scrcpy with "ninja -Cx" command but I got this error:
undef: _sws_getContext
undef: _sws_scale
Undefined symbols for architecture arm64:
"_sws_getContext", referenced from:
_scrcpy in lto.o
"_sws_scale", referenced from:
_scrcpy in lto.o
I'm using a Macbook Pro with M1 CPU. Does that message mean that sws_getContext
and sws_scale
functions are not available for ARM CPUs? I appreciate any help, thank you!
Edit: I have included #include <libswscale/swscale.h>
in screen.c
c
ffmpeg
ninja
meson-build
0 Answers
Your Answer