From de9b79ec2dd73e5442c6bf0161669bcd8ca7d5be Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 11 Apr 2021 15:01:05 +0200 Subject: [PATCH] Remove compat with old FFmpeg decoding API The new API has been introduced in 2016 in libavcodec 57.xx, it's very old. This will avoid to maintain two code paths for decoding. --- app/src/compat.h | 10 ---------- app/src/decoder.c | 17 ----------------- 2 files changed, 27 deletions(-) diff --git a/app/src/compat.h b/app/src/compat.h index 9a84a4c1..f3e7bd7a 100644 --- a/app/src/compat.h +++ b/app/src/compat.h @@ -8,7 +8,6 @@ # define _DARWIN_C_SOURCE #endif -#include #include #include @@ -33,15 +32,6 @@ # define SCRCPY_LAVF_REQUIRES_REGISTER_ALL #endif -// In ffmpeg/doc/APIchanges: -// 2016-04-21 - 7fc329e - lavc 57.37.100 - avcodec.h -// Add a new audio/video encoding and decoding API with decoupled input -// and output -- avcodec_send_packet(), avcodec_receive_frame(), -// avcodec_send_frame() and avcodec_receive_packet(). -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) -# define SCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API -#endif - #if SDL_VERSION_ATLEAST(2, 0, 5) // # define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH diff --git a/app/src/decoder.c b/app/src/decoder.c index b7101194..f05303a3 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -36,9 +36,6 @@ decoder_close(struct decoder *decoder) { bool decoder_push(struct decoder *decoder, const AVPacket *packet) { -// the new decoding/encoding API has been introduced by: -// -#ifdef SCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API int ret; if ((ret = avcodec_send_packet(decoder->codec_ctx, packet)) < 0) { LOGE("Could not send video packet: %d", ret); @@ -53,19 +50,5 @@ decoder_push(struct decoder *decoder, const AVPacket *packet) { LOGE("Could not receive video frame: %d", ret); return false; } -#else - int got_picture; - int len = avcodec_decode_video2(decoder->codec_ctx, - decoder->video_buffer->producer_frame, - &got_picture, - packet); - if (len < 0) { - LOGE("Could not decode video packet: %d", len); - return false; - } - if (got_picture) { - video_buffer_producer_offer_frame(decoder->video_buffer); - } -#endif return true; }