Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avcodec_decode_video2 is deprecated #31

Closed
9000h opened this issue Feb 3, 2018 · 1 comment
Closed

avcodec_decode_video2 is deprecated #31

9000h opened this issue Feb 3, 2018 · 1 comment

Comments

@9000h
Copy link
Contributor

9000h commented Feb 3, 2018

codec.c: In function ‘CodecVideoDecode’:
codec.c:617:5: warning: ‘avcodec_decode_video2’ is deprecated [-Wdeprecated-declarations]
used = avcodec_decode_video2(video_ctx, frame, &got_frame, pkt);
^

this can fully replace it

--- codec.c.orig	2018-02-03 20:52:17.250388421 +0100
+++ codec.c	2018-02-03 20:53:22.678721937 +0100
@@ -612,8 +612,25 @@
     *pkt = *avpkt;			// use copy
 
   next_part:
+#if 0
     // FIXME: this function can crash with bad packets
     used = avcodec_decode_video2(video_ctx, frame, &got_frame, pkt);
+#else
+         if (video_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
+             video_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+             used = avcodec_send_packet(video_ctx, pkt);
+             if (used < 0 && used != AVERROR(EAGAIN) && used != AVERROR_EOF) {
+            } else {
+             if (used >= 0)
+                 pkt->size = 0;
+             used = avcodec_receive_frame(video_ctx, frame);
+             if (used >= 0)
+                 got_frame = 1;
+//             if (used == AVERROR(EAGAIN) || used == AVERROR_EOF)
+//                 used = 0;
+             }
+         }
+#endif
     Debug(4, "%s: %p %d -> %d %d\n", __FUNCTION__, pkt->data, pkt->size, used,
 	got_frame);
 
@pesintta
Copy link
Owner

Fixed by merging of #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants