1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Description: fix ftbfs with ffmpeg 5.0.
Author: Fernando Hueso González <Fernando.Hueso@uv.es>
Bug: https://github.com/ferdymercury/amide/issues/22
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004597
Forwarded: https://github.com/ferdymercury/amide/pull/23
Reviewed-by: Étienne Mollier <emollier@debian.org>
Last-Update: 2022-07-09
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- amide.orig/amide-current/src/mpeg_encode.c
+++ amide/amide-current/src/mpeg_encode.c
@@ -216,11 +216,13 @@
static void mpeg_encoding_init(void) {
if (!avcodec_initialized) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 137, 100)
/* must be called before using avcodec lib */
avcodec_register_all();
/* register all the codecs */
avcodec_register_all();
+#endif
avcodec_initialized=TRUE;
}
@@ -376,8 +378,6 @@
gboolean mpeg_encode_frame(gpointer data, GdkPixbuf * pixbuf) {
encode_t * encode = data;
// gint out_size;
- AVPacket pkt = {0};
- int ret, got_packet = 0;
convert_rgb_pixbuf_to_yuv(encode->yuv, pixbuf);
@@ -386,13 +386,37 @@
// fwrite(encode->output_buffer, 1, out_size, encode->output_file);
// return TRUE;
+ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
+ AVPacket pkt = {0};
+ int ret, got_packet = 0;
ret = avcodec_encode_video2(encode->context, &pkt, encode->picture, &got_packet);
if (ret >= 0 && got_packet) {
- fwrite(pkt.data, 1, pkt.size, encode->output_file);
- av_packet_unref(&pkt);
-}
+ fwrite(pkt.data, 1, pkt.size, encode->output_file);
+ av_packet_unref(&pkt);
+ }
return (ret >= 0) ? TRUE : FALSE;
+ #else
+ int result = avcodec_send_frame(encode->context, encode->picture);
+ if (result == AVERROR_EOF)
+ return TRUE;
+ else if (result < 0)
+ return FALSE;
+ else {
+ AVPacket* pkt = av_packet_alloc();
+ if (pkt != NULL) {
+ while (avcodec_receive_packet(encode->context, pkt) == 0) {
+ fwrite(pkt->data, 1, pkt->size, encode->output_file);
+ av_packet_unref(pkt);
+ }
+ av_packet_free(&pkt);
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ #endif
};
/* close everything up */
|