Fix: remove swscale, we are not software scaling nor color convert a frame

This commit is contained in:
AreaScout 2015-09-05 18:00:42 +00:00 committed by Iwan Timmer
parent a25a83f98f
commit 7e73b65797
2 changed files with 3 additions and 36 deletions

View File

@ -25,12 +25,11 @@ pkg_check_modules(UDEV REQUIRED libudev)
pkg_check_modules(SDL sdl2>=2.0.4)
pkg_check_modules(AVCODEC libavcodec)
pkg_check_modules(AVUTIL libavutil)
pkg_check_modules(SWSCALE libswscale)
pkg_check_modules(XLIB x11-xcb)
pkg_check_modules(LIBVA vdpau)
pkg_check_modules(PULSE libpulse-simple)
if(AVCODEC_FOUND AND AVUTIL_FOUND AND SWSCALE_FOUND AND SDL_FOUND)
if(AVCODEC_FOUND AND AVUTIL_FOUND AND SDL_FOUND)
set(SOFTWARE_FOUND TRUE)
if(XLIB_FOUND AND LIBVA_FOUND)
set(VDPAU_FOUND TRUE)
@ -114,8 +113,8 @@ if(FREESCALE_FOUND)
endif()
if (SOFTWARE_FOUND)
target_include_directories(moonlight PRIVATE ${SDL_INCLUDE_DIRS} ${AVCODEC_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS} ${SWSCALE_INCLUDE_DIRS})
target_link_libraries(moonlight ${SDL_LIBRARIES} ${AVCODEC_LIBRARIES} ${AVUTIL_LIBRARIES} ${SWSCALE_LIBRARIES})
target_include_directories(moonlight PRIVATE ${SDL_INCLUDE_DIRS} ${AVCODEC_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS})
target_link_libraries(moonlight ${SDL_LIBRARIES} ${AVCODEC_LIBRARIES} ${AVUTIL_LIBRARIES})
if(VDPAU_FOUND)
target_include_directories(moonlight PRIVATE ${XLIB_INCLUDE_DIRS} ${LIBVA_INCLUDE_DIRS})
target_link_libraries(moonlight ${XLIB_LIBRARIES} ${LIBVA_LIBRARIES})

View File

@ -34,7 +34,6 @@ static AVPacket pkt;
static AVCodec* decoder;
static AVCodecContext* decoder_ctx;
static AVFrame* dec_frame;
static struct SwsContext* scaler_ctx;
enum decoders {SOFTWARE, VDPAU};
enum decoders decoder_system;
@ -109,22 +108,6 @@ int ffmpeg_init(int width, int height, int perf_lvl, int thread_count) {
vdpau_init(decoder_ctx, width, height);
#endif
int filtering;
if (perf_lvl & FAST_BILINEAR_FILTERING)
filtering = SWS_FAST_BILINEAR;
else if (perf_lvl & BILINEAR_FILTERING)
filtering = SWS_BILINEAR;
else
filtering = SWS_BICUBIC;
if (decoder_system == SOFTWARE) {
scaler_ctx = sws_getContext(decoder_ctx->width, decoder_ctx->height, decoder_ctx->pix_fmt, decoder_ctx->width, decoder_ctx->height, PIX_FMT_YUV420P, filtering, NULL, NULL, NULL);
if (scaler_ctx == NULL) {
printf("Couldn't get scaler context\n");
return -1;
}
}
return 0;
}
@ -136,27 +119,12 @@ void ffmpeg_destroy(void) {
av_free(decoder_ctx);
decoder_ctx = NULL;
}
if (scaler_ctx) {
sws_freeContext(scaler_ctx);
scaler_ctx = NULL;
}
if (dec_frame) {
av_frame_free(&dec_frame);
dec_frame = NULL;
}
}
int ffmpeg_draw_frame(AVFrame *pict) {
int err = sws_scale(scaler_ctx, (const uint8_t* const*) dec_frame->data, dec_frame->linesize, 0, decoder_ctx->height, pict->data, pict->linesize);
if (err != decoder_ctx->height) {
fprintf(stderr, "Scaling failed\n");
return 0;
}
return 1;
}
AVFrame* ffmpeg_get_frame() {
if (decoder_system == SOFTWARE)
return dec_frame;