[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#993379: libyami-utils FTBFS: error: ‘void av_init_packet(AVPacket*)’ is deprecated [-Werror=deprecated-declarations]



Package: libyami-utils
Version: 1.3.0-3
Followup-For: Bug #993379
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu jammy ubuntu-patch
X-Debbugs-Cc: simon.chopin@canonical.com
Control: tags -1 patch

Hi,

In Ubuntu, the attached patch was applied to fix the aforementioned
FTBFS:

Thanks for considering the patch.

Cheers,
Simon
diff -Nru libyami-utils-1.3.0/debian/patches/0004-tests-decodeinputavformat-use-heap-allocated-m_packe.patch libyami-utils-1.3.0/debian/patches/0004-tests-decodeinputavformat-use-heap-allocated-m_packe.patch
--- libyami-utils-1.3.0/debian/patches/0004-tests-decodeinputavformat-use-heap-allocated-m_packe.patch	1970-01-01 01:00:00.000000000 +0100
+++ libyami-utils-1.3.0/debian/patches/0004-tests-decodeinputavformat-use-heap-allocated-m_packe.patch	2021-12-17 15:50:51.000000000 +0100
@@ -0,0 +1,85 @@
+From dbd0c5508d0084a9b069cafd583e6004a12f562a Mon Sep 17 00:00:00 2001
+From: Simon Chopin <simon.chopin@canonical.com>
+Date: Fri, 17 Dec 2021 16:03:10 +0100
+Subject: [PATCH] tests/decodeinputavformat: use heap-allocated m_packet
+Forwarded: https://github.com/intel/libyami-utils/pull/138
+
+This allows us to migrate away from av_init_packet() which has been
+deprecated in recent FFMpeg, making the build fail.
+
+This implementation is somewhat rough, there's probably a way to avoid
+reallocating the packet each iteration, but it does the job.
+---
+ tests/decodeinputavformat.cpp | 23 +++++++++--------------
+ tests/decodeinputavformat.h   |  2 +-
+ 2 files changed, 10 insertions(+), 15 deletions(-)
+
+--- a/tests/decodeinputavformat.cpp
++++ b/tests/decodeinputavformat.cpp
+@@ -22,18 +22,12 @@
+ #include "common/log.h"
+ #include <Yami.h>
+ 
+-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 39, 100)
+-#define av_packet_unref av_free_packet
+-#endif
+-
+ DecodeInputAvFormat::DecodeInputAvFormat()
+-:m_format(NULL),m_videoId(-1), m_codecId(AV_CODEC_ID_NONE), m_isEos(true)
++:m_format(NULL),m_videoId(-1), m_codecId(AV_CODEC_ID_NONE), m_packet(av_packet_alloc()), m_isEos(true)
+ {
+ #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
+     av_register_all();
+ #endif
+-
+-    av_init_packet(&m_packet);
+ }
+ 
+ bool DecodeInputAvFormat::initInput(const char* fileName)
+@@ -132,18 +126,19 @@
+     int ret;
+     while (1) {
+         //free old packet
+-        av_packet_unref(&m_packet);
++        av_packet_free(&m_packet);
++        m_packet = av_packet_alloc();
+ 
+-        ret = av_read_frame(m_format, &m_packet);
++        ret = av_read_frame(m_format, m_packet);
+         if (ret) {
+             m_isEos = true;
+             return false;
+         }
+-        if (m_packet.stream_index == m_videoId) {
++        if (m_packet->stream_index == m_videoId) {
+             memset(&inputBuffer, 0, sizeof(inputBuffer));
+-            inputBuffer.data = m_packet.data;
+-            inputBuffer.size = m_packet.size;
+-            inputBuffer.timeStamp = m_packet.dts;
++            inputBuffer.data = m_packet->data;
++            inputBuffer.size = m_packet->size;
++            inputBuffer.timeStamp = m_packet->dts;
+             return true;
+         }
+     }
+@@ -158,8 +153,8 @@
+ DecodeInputAvFormat::~DecodeInputAvFormat()
+ {
+     if (m_format) {
+-        av_packet_unref(&m_packet);
+         avformat_close_input(&m_format);
+     }
++    av_packet_free(&m_packet);
+ 
+ }
+--- a/tests/decodeinputavformat.h
++++ b/tests/decodeinputavformat.h
+@@ -47,7 +47,7 @@
+     AVFormatContext* m_format;
+     int m_videoId;
+     AVCodecID m_codecId;
+-    AVPacket m_packet;
++    AVPacket* m_packet;
+     bool m_isEos;
+     string m_codecData;
+ };
diff -Nru libyami-utils-1.3.0/debian/patches/av_packet_init-deprecated.patch libyami-utils-1.3.0/debian/patches/av_packet_init-deprecated.patch
--- libyami-utils-1.3.0/debian/patches/av_packet_init-deprecated.patch	1970-01-01 01:00:00.000000000 +0100
+++ libyami-utils-1.3.0/debian/patches/av_packet_init-deprecated.patch	2021-12-17 15:48:08.000000000 +0100
@@ -0,0 +1,61 @@
+Description: Migrate away from the deprecated av_packet_init API
+Author: Simon Chopin <simon.chopin@canonical.com>
+
+--- a/tests/decodeinputavformat.cpp
++++ b/tests/decodeinputavformat.cpp
+@@ -33,7 +33,7 @@
+     av_register_all();
+ #endif
+ 
+-    av_init_packet(&m_packet);
++    m_packet = av_packet_alloc();
+ }
+ 
+ bool DecodeInputAvFormat::initInput(const char* fileName)
+@@ -132,18 +132,19 @@
+     int ret;
+     while (1) {
+         //free old packet
+-        av_packet_unref(&m_packet);
++        av_packet_free(&m_packet);
++        m_packet = av_packet_alloc();
+ 
+-        ret = av_read_frame(m_format, &m_packet);
++        ret = av_read_frame(m_format, m_packet);
+         if (ret) {
+             m_isEos = true;
+             return false;
+         }
+-        if (m_packet.stream_index == m_videoId) {
++        if (m_packet->stream_index == m_videoId) {
+             memset(&inputBuffer, 0, sizeof(inputBuffer));
+-            inputBuffer.data = m_packet.data;
+-            inputBuffer.size = m_packet.size;
+-            inputBuffer.timeStamp = m_packet.dts;
++            inputBuffer.data = m_packet->data;
++            inputBuffer.size = m_packet->size;
++            inputBuffer.timeStamp = m_packet->dts;
+             return true;
+         }
+     }
+@@ -157,8 +158,8 @@
+ 
+ DecodeInputAvFormat::~DecodeInputAvFormat()
+ {
++    av_packet_free(&m_packet);
+     if (m_format) {
+-        av_packet_unref(&m_packet);
+         avformat_close_input(&m_format);
+     }
+ 
+--- a/tests/decodeinputavformat.h
++++ b/tests/decodeinputavformat.h
+@@ -47,7 +47,7 @@
+     AVFormatContext* m_format;
+     int m_videoId;
+     AVCodecID m_codecId;
+-    AVPacket m_packet;
++    AVPacket* m_packet;
+     bool m_isEos;
+     string m_codecData;
+ };
diff -Nru libyami-utils-1.3.0/debian/patches/series libyami-utils-1.3.0/debian/patches/series
--- libyami-utils-1.3.0/debian/patches/series	2021-08-12 16:52:14.000000000 +0200
+++ libyami-utils-1.3.0/debian/patches/series	2021-12-17 15:50:51.000000000 +0100
@@ -1,3 +1,4 @@
 0001-decode-avformat-av_register_all-is-deprecated-since-.patch
 0002-decode-avformat-use-LIBAVFORMAT_VERSION_INT-instead.patch
 0003-Use-libmd-instead-of-libbsd-for-message-digest-funct.patch
+0004-tests-decodeinputavformat-use-heap-allocated-m_packe.patch

Reply to: