Skip to content

Display and control your Android device

Move the new avcodec implementation before the old

Romain Vimont84ad6633a68d
diff --git a/app/src/decoder.c b/app/src/decoder.c
index f831107a..8c912715 100644
--- a/app/src/decoder.c
+++ b/app/src/decoder.c
@@ -94,7 +94,19 @@ static int run_decoder(void *data) {
while (!av_read_frame(format_ctx, &packet) && !avio_ctx->eof_reached) {
// the new decoding/encoding API has been introduced by:
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 0)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
+ int ret;
+ if ((ret = avcodec_send_packet(codec_ctx, &packet)) < 0) {
+ LOGE("Could not send video packet: %d", ret);
+ goto run_quit;
+ }
+ if ((ret = avcodec_receive_frame(codec_ctx, decoder->frames->decoding_frame)) < 0) {
+ LOGE("Could not receive video frame: %d", ret);
+ goto run_quit;
+ }
+
+ push_frame(decoder);
+#else
while (packet.size > 0) {
int got_picture;
int len = avcodec_decode_video2(codec_ctx, decoder->frames->decoding_frame, &got_picture, &packet);
@@ -108,18 +120,6 @@ static int run_decoder(void *data) {
packet.size -= len;
packet.data += len;
}
-#else
- int ret;
- if ((ret = avcodec_send_packet(codec_ctx, &packet)) < 0) {
- LOGE("Could not send video packet: %d", ret);
- goto run_quit;
- }
- if ((ret = avcodec_receive_frame(codec_ctx, decoder->frames->decoding_frame)) < 0) {
- LOGE("Could not receive video frame: %d", ret);
- goto run_quit;
- }
-
- push_frame(decoder);
#endif
}