Description: Fix FTBFS with ffmpeg/5.0.
Bug-Debian: https://bugs.debian.org/1004766
Author: Yavor Doganov <yavor@gnu.org>
Forwarded: no
Last-Update: 2024-01-14
---

--- lynkeos.app.orig/application/Sources/FFmpegReader.h
+++ lynkeos.app/application/Sources/FFmpegReader.h
@@ -74,7 +74,7 @@
    u_short           *_convBuffer;          //!< Temporary buffer for conversion
    int                _bufLineLength;       //<! Temporary buffer line length for each plane
    int               _videoStream;          //!< Index of the selected video stream
-   AVPacket          _packet;               //!< Last packet read
+   AVPacket          *_packet;              //!< Last packet read
    DecoderState_t    _decoderState;         //! State of the decoder with respect to packet data
    u_long            _numberOfFrames;       //!< Number of image frames in the movie
    KeyFrames_t      *_times;                //!< Times of key frames
--- lynkeos.app.orig/application/Sources/FFmpegReader.m
+++ lynkeos.app/application/Sources/FFmpegReader.m
@@ -113,12 +113,12 @@
          do
          {
             // Free old packet content
-            av_packet_unref( &_packet );
+            av_packet_unref( _packet );
 
             // Read new packet
-            ret = av_read_frame(_pFormatCtx, &_packet);
+            ret = av_read_frame(_pFormatCtx, _packet);
 
-         } while( ret >= 0 && (_packet.stream_index != _videoStream ) );
+         } while( ret >= 0 && (_packet->stream_index != _videoStream ) );
 
          if ( ret < 0 )
          {
@@ -136,7 +136,7 @@
          {
             case DataNeeded:
             case DataRepeat:
-               pk = &_packet;
+               pk = _packet;
                break;
             case EndOfFile:
                // We will send a *last* NULL packet
@@ -213,9 +213,9 @@
           || _times[index].keyFrame != _times[_nextIndex].keyFrame )
       {
          // Reset the decoder
-         if ( _packet.data != NULL )
-            av_packet_unref( &_packet );
-         _packet.size = 0;
+         if ( _packet->data != NULL )
+            av_packet_unref( _packet );
+         _packet->size = 0;
          avcodec_flush_buffers(_pCodecCtx);
          _decoderState = DataNeeded;
 
@@ -337,9 +337,7 @@
       _convBuffer = NULL;
       _bufLineLength = 0;
       _videoStream = -1;
-      av_init_packet(&_packet);
-      _packet.data = NULL;
-      _packet.size = 0;
+      _packet = av_packet_alloc();
       _decoderState = DataNeeded;
       _numberOfFrames = 0;
       _nextIndex = 0;
@@ -538,8 +536,7 @@
       sws_freeContext( _procConverter );
    if (_convBuffer != NULL)
       free(_convBuffer);
-   if ( _packet.data != NULL )
-      av_packet_unref( &_packet );
+   av_packet_free( &_packet );
    if ( _pFormatCtx != NULL )
       avformat_close_input( &_pFormatCtx );
    if ( _times != NULL )
