Skip to content

Commit

Permalink
Remove compat with old FFmpeg decoding API
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rom1v committed Apr 25, 2021
1 parent 55806e7 commit de9b79e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
10 changes: 0 additions & 10 deletions app/src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# define _DARWIN_C_SOURCE
#endif

#include <libavcodec/version.h>
#include <libavformat/version.h>
#include <SDL2/SDL_version.h>

Expand All @@ -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)
// <https://wiki.libsdl.org/SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH>
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
Expand Down
17 changes: 0 additions & 17 deletions app/src/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
#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);
Expand All @@ -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;
}

0 comments on commit de9b79e

Please sign in to comment.