Ticket #22399: vlc-3.0.21-ffmpeg8.patch

File vlc-3.0.21-ffmpeg8.patch, 16.7 KB (added by Joe Locash, 11 months ago)

Fix building with ffmpeg-8

  • modules/codec/avcodec/audio.c

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/audio.c vlc-3.0.21/modules/codec/avcodec/audio.c
    old new  
    4444#include <libavutil/channel_layout.h>
    4545
    4646
     47#if ! LIBAVCODEC_VERSION_CHECK(61, 33, 102) // Compatibility for profiles <= FFMPEG 8
     48# define AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
     49# define AV_LEVEL_UNKNOWN FF_LEVEL_UNKNOWN
     50# define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
     51#endif
     52
    4753/*****************************************************************************
    4854 * decoder_sys_t : decoder descriptor
    4955 *****************************************************************************/
    … … static void InitDecoderConfig( decoder_t  
    101107        if( i_size > 0 )
    102108        {
    103109            p_context->extradata =
    104                 av_malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
     110                av_malloc( i_size + AV_INPUT_BUFFER_PADDING_SIZE );
    105111            if( p_context->extradata )
    106112            {
    107113                uint8_t *p_dst = p_context->extradata;
    … … static void InitDecoderConfig( decoder_t  
    109115                p_context->extradata_size = i_size;
    110116
    111117                memcpy( &p_dst[0],            &p_src[i_offset], i_size );
    112                 memset( &p_dst[i_size], 0, FF_INPUT_BUFFER_PADDING_SIZE );
     118                memset( &p_dst[i_size], 0, AV_INPUT_BUFFER_PADDING_SIZE );
    113119            }
    114120        }
    115121    }
    … … int InitAudioDec( vlc_object_t *obj )  
    266272    p_dec->pf_flush  = Flush;
    267273
    268274    /* XXX: Writing input format makes little sense. */
    269     if( avctx->profile != FF_PROFILE_UNKNOWN )
     275    if( avctx->profile != AV_PROFILE_UNKNOWN )
    270276        p_dec->fmt_in.i_profile = avctx->profile;
    271     if( avctx->level != FF_LEVEL_UNKNOWN )
     277    if( avctx->level != AV_LEVEL_UNKNOWN )
    272278        p_dec->fmt_in.i_level = avctx->level;
    273279
    274280    return VLC_SUCCESS;
    … … static int DecodeBlock( decoder_t *p_dec  
    348354
    349355        if( (p_block->i_flags & BLOCK_FLAG_PRIVATE_REALLOCATED) == 0 )
    350356        {
    351             *pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
     357            *pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + AV_INPUT_BUFFER_PADDING_SIZE );
    352358            if( !p_block )
    353359                goto end;
    354             p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
    355             memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
     360            p_block->i_buffer -= AV_INPUT_BUFFER_PADDING_SIZE;
     361            memset( &p_block->p_buffer[p_block->i_buffer], 0, AV_INPUT_BUFFER_PADDING_SIZE );
    356362
    357363            p_block->i_flags |= BLOCK_FLAG_PRIVATE_REALLOCATED;
    358364        }
  • modules/codec/avcodec/avcommon_compat.h

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/avcommon_compat.h vlc-3.0.21/modules/codec/avcodec/avcommon_compat.h
    old new  
    5353#ifndef AV_CODEC_FLAG2_FAST
    5454# define AV_CODEC_FLAG2_FAST CODEC_FLAG2_FAST
    5555#endif
    56 #ifndef FF_INPUT_BUFFER_PADDING_SIZE
    57 # define FF_INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
     56#if ! LIBAVCODEC_VERSION_CHECK(61, 33, 102) // Compatibility for profiles <= FFMPEG 8
     57# ifndef FF_INPUT_BUFFER_PADDING_SIZE
     58#  define FF_INPUT_BUFFER_PADDING_SIZE 64
     59# endif
     60#define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
    5861#endif
    5962#ifndef AV_CODEC_FLAG_INTERLACED_DCT
    6063# define AV_CODEC_FLAG_INTERLACED_DCT CODEC_FLAG_INTERLACED_DCT
    … …  
    7275# define AV_CODEC_CAP_SMALL_LAST_FRAME CODEC_CAP_SMALL_LAST_FRAME
    7376#endif
    7477#ifndef AV_INPUT_BUFFER_MIN_SIZE
    75 # define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE
     78# ifdef FF_MIN_BUFFER_SIZE
     79#  define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE
     80# else
     81#  define AV_INPUT_BUFFER_MIN_SIZE 16384 // removed with ffmpeg 8
     82# endif
    7683#endif
    7784#ifndef  FF_MAX_B_FRAMES
    7885# define  FF_MAX_B_FRAMES 16 // FIXME: remove this
  • modules/codec/avcodec/encoder.c

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/encoder.c vlc-3.0.21/modules/codec/avcodec/encoder.c
    old new  
    6565# define AVC_MAYBE_CONST
    6666#endif
    6767
     68#if ! LIBAVCODEC_VERSION_CHECK(61, 33, 102) // Compatibility for profiles <= FFMPEG 8
     69# define AV_PROFILE_AAC_MAIN    FF_PROFILE_AAC_MAIN
     70# define AV_PROFILE_AAC_LOW     FF_PROFILE_AAC_LOW
     71# define AV_PROFILE_AAC_SSR     FF_PROFILE_AAC_SSR
     72# define AV_PROFILE_AAC_LTP     FF_PROFILE_AAC_LTP
     73# define AV_PROFILE_AAC_HE_V2   FF_PROFILE_AAC_HE_V2
     74# define AV_PROFILE_AAC_HE      FF_PROFILE_AAC_HE
     75# define AV_PROFILE_AAC_LD      FF_PROFILE_AAC_LD
     76# define AV_PROFILE_AAC_ELD     FF_PROFILE_AAC_ELD
     77#endif
     78
    6879/*****************************************************************************
    6980 * Local prototypes
    7081 *****************************************************************************/
    … … int InitVideoEnc( vlc_object_t *p_this )  
    468479    psz_val = var_GetString( p_enc, ENC_CFG_PREFIX "aac-profile" );
    469480    /* libavcodec uses faac encoder atm, and it has issues with
    470481     * other than low-complexity profile, so default to that */
    471     p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
     482    p_sys->i_aac_profile = AV_PROFILE_AAC_LOW;
    472483    if( psz_val && *psz_val )
    473484    {
    474485        if( !strncmp( psz_val, "main", 4 ) )
    475             p_sys->i_aac_profile = FF_PROFILE_AAC_MAIN;
     486            p_sys->i_aac_profile = AV_PROFILE_AAC_MAIN;
    476487        else if( !strncmp( psz_val, "low", 3 ) )
    477             p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
     488            p_sys->i_aac_profile = AV_PROFILE_AAC_LOW;
    478489        else if( !strncmp( psz_val, "ssr", 3 ) )
    479             p_sys->i_aac_profile = FF_PROFILE_AAC_SSR;
     490            p_sys->i_aac_profile = AV_PROFILE_AAC_SSR;
    480491        else if( !strncmp( psz_val, "ltp", 3 ) )
    481             p_sys->i_aac_profile = FF_PROFILE_AAC_LTP;
     492            p_sys->i_aac_profile = AV_PROFILE_AAC_LTP;
    482493/* These require libavcodec with libfdk-aac */
    483494        else if( !strncmp( psz_val, "hev2", 4 ) )
    484             p_sys->i_aac_profile = FF_PROFILE_AAC_HE_V2;
     495            p_sys->i_aac_profile = AV_PROFILE_AAC_HE_V2;
    485496        else if( !strncmp( psz_val, "hev1", 4 ) )
    486             p_sys->i_aac_profile = FF_PROFILE_AAC_HE;
     497            p_sys->i_aac_profile = AV_PROFILE_AAC_HE;
    487498        else if( !strncmp( psz_val, "ld", 2 ) )
    488             p_sys->i_aac_profile = FF_PROFILE_AAC_LD;
     499            p_sys->i_aac_profile = AV_PROFILE_AAC_LD;
    489500        else if( !strncmp( psz_val, "eld", 3 ) )
    490             p_sys->i_aac_profile = FF_PROFILE_AAC_ELD;
     501            p_sys->i_aac_profile = AV_PROFILE_AAC_ELD;
    491502        else
    492503        {
    493504            msg_Warn( p_enc, "unknown AAC profile requested, setting it to low" );
    494             p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
     505            p_sys->i_aac_profile = AV_PROFILE_AAC_LOW;
    495506        }
    496507    }
    497508    free( psz_val );
    … … static block_t *EncodeVideo( encoder_t *  
    12171228        frame->pict_type = 0;
    12181229
    12191230        frame->repeat_pict = p_pict->i_nb_fields - 2;
     1231#if LIBAVUTIL_VERSION_CHECK( 58, 7, 100 )
     1232        if (p_pict->b_progressive)
     1233            frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
     1234        else
     1235            frame->flags |= AV_FRAME_FLAG_INTERLACED;
     1236        if (p_pict->b_top_field_first)
     1237            frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
     1238        else
     1239            frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
     1240#else
    12201241        frame->interlaced_frame = !p_pict->b_progressive;
    12211242        frame->top_field_first = !!p_pict->b_top_field_first;
     1243#endif
    12221244
    12231245        frame->format = p_sys->p_context->pix_fmt;
    12241246        frame->width = p_sys->p_context->width;
    … … void EndVideoEnc( vlc_object_t *p_this )  
    14731495    av_frame_free( &p_sys->frame );
    14741496
    14751497    vlc_avcodec_lock();
    1476     avcodec_close( p_sys->p_context );
    1477     vlc_avcodec_unlock();
    14781498    avcodec_free_context( &p_sys->p_context );
     1499    vlc_avcodec_unlock();
    14791500
    14801501
    14811502    av_free( p_sys->p_interleave_buf );
  • modules/codec/avcodec/subtitle.c

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/subtitle.c vlc-3.0.21/modules/codec/avcodec/subtitle.c
    old new static subpicture_t *DecodeBlock(decoder  
    174174    *block_ptr =
    175175    block      = block_Realloc(block,
    176176                               0,
    177                                block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE);
     177                               block->i_buffer + AV_INPUT_BUFFER_PADDING_SIZE);
    178178    if (!block)
    179179        return NULL;
    180     block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
    181     memset(&block->p_buffer[block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE);
     180    block->i_buffer -= AV_INPUT_BUFFER_PADDING_SIZE;
     181    memset(&block->p_buffer[block->i_buffer], 0, AV_INPUT_BUFFER_PADDING_SIZE);
    182182
    183183    /* */
    184184    AVSubtitle subtitle;
  • modules/codec/avcodec/vaapi.c

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/vaapi.c vlc-3.0.21/modules/codec/avcodec/vaapi.c
    old new static int GetVaProfile(AVCodecContext *  
    8787        count = 18;
    8888        break;
    8989    case AV_CODEC_ID_HEVC:
    90         if (ctx->profile == FF_PROFILE_HEVC_MAIN)
     90        if (ctx->profile == AV_PROFILE_HEVC_MAIN)
    9191            i_profile = VAProfileHEVCMain;
    92         else if (ctx->profile == FF_PROFILE_HEVC_MAIN_10)
     92        else if (ctx->profile == AV_PROFILE_HEVC_MAIN_10)
    9393        {
    9494            i_profile = VAProfileHEVCMain10;
    9595            i_vlc_chroma = VLC_CODEC_VAAPI_420_10BPP;
    … … static int GetVaProfile(AVCodecContext *  
    103103        count = 5;
    104104        break;
    105105    case AV_CODEC_ID_VP9:
    106         if (ctx->profile == FF_PROFILE_VP9_0)
     106        if (ctx->profile == AV_PROFILE_VP9_0)
    107107            i_profile = VAProfileVP9Profile0;
    108108#if VA_CHECK_VERSION( 0, 39, 0 )
    109         else if (ctx->profile == FF_PROFILE_VP9_2)
     109        else if (ctx->profile == AV_PROFILE_VP9_2)
    110110        {
    111111            i_profile = VAProfileVP9Profile2;
    112112            i_vlc_chroma = VLC_CODEC_VAAPI_420_10BPP;
  • modules/codec/avcodec/video.c

    diff -Nuarp vlc-3.0.21.orig/modules/codec/avcodec/video.c vlc-3.0.21/modules/codec/avcodec/video.c
    old new  
    5050#include "../../packetizer/av1.h"
    5151#include "../codec/cc.h"
    5252
     53#if ! LIBAVCODEC_VERSION_CHECK(61, 33, 102) // Compatibility for profiles <= FFMPEG 8
     54# define AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
     55# define AV_LEVEL_UNKNOWN FF_LEVEL_UNKNOWN
     56# define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
     57#endif
     58
     59
    5360/*****************************************************************************
    5461 * decoder_sys_t : decoder descriptor
    5562 *****************************************************************************/
    … … static int lavc_GetVideoFormat(decoder_t  
    200207    else if (ctx->time_base.num > 0 && ctx->time_base.den > 0)
    201208    {
    202209        fmt->i_frame_rate = ctx->time_base.den;
    203         fmt->i_frame_rate_base = ctx->time_base.num
    204                                  * __MAX(ctx->ticks_per_frame, 1);
     210        fmt->i_frame_rate_base = ctx->time_base.num;
    205211    }
    206212
    207213    /* FIXME we should only set the known values and let the core decide
    … … static int lavc_UpdateVideoFormat(decode  
    323329
    324330    /* always have date in fields/ticks units */
    325331    if(dec->p_sys->pts.i_divider_num)
    326         date_Change(&dec->p_sys->pts, fmt_out.i_frame_rate *
    327                                       __MAX(ctx->ticks_per_frame, 1),
     332        date_Change(&dec->p_sys->pts, fmt_out.i_frame_rate,
    328333                                      fmt_out.i_frame_rate_base);
    329334    else
    330         date_Init(&dec->p_sys->pts, fmt_out.i_frame_rate *
    331                                     __MAX(ctx->ticks_per_frame, 1),
     335        date_Init(&dec->p_sys->pts, fmt_out.i_frame_rate,
    332336                                    fmt_out.i_frame_rate_base);
    333337
    334338    fmt_out.p_palette = dec->fmt_out.video.p_palette;
    … … static int InitVideoDecCommon( decoder_t  
    622626    p_dec->pf_flush  = Flush;
    623627
    624628    /* XXX: Writing input format makes little sense. */
    625     if( p_context->profile != FF_PROFILE_UNKNOWN )
     629    if( p_context->profile != AV_PROFILE_UNKNOWN )
    626630        p_dec->fmt_in.i_profile = p_context->profile;
    627     if( p_context->level != FF_LEVEL_UNKNOWN )
     631    if( p_context->level != AV_LEVEL_UNKNOWN )
    628632        p_dec->fmt_in.i_level = p_context->level;
    629633    return VLC_SUCCESS;
    630634}
    … … static vlc_tick_t interpolate_next_pts(  
    937941        p_sys->pts.i_divider_num == 0 )
    938942        return VLC_TICK_INVALID;
    939943
     944#if LIBAVCODEC_VERSION_CHECK( 60, 12, 100 )
     945    int i_tick = p_context->codec_descriptor->props & AV_CODEC_PROP_FIELDS ? 2 : 1;
     946#else
    940947    int i_tick = p_context->ticks_per_frame;
    941     if( i_tick <= 0 )
    942         i_tick = 1;
     948#endif
    943949
    944950    /* interpolate the next PTS */
    945951    return date_Increment( &p_sys->pts, i_tick + frame->repeat_pict );
    … … static picture_t *DecodeBlock( decoder_t  
    11791185        eos_spotted = ( p_block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE ) != 0;
    11801186
    11811187        p_block = block_Realloc( p_block, 0,
    1182                             p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
     1188                            p_block->i_buffer + AV_INPUT_BUFFER_PADDING_SIZE );
    11831189        if( !p_block )
    11841190            return NULL;
    1185         p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
     1191        p_block->i_buffer -= AV_INPUT_BUFFER_PADDING_SIZE;
    11861192        *pp_block = p_block;
    11871193        memset( p_block->p_buffer + p_block->i_buffer, 0,
    1188                 FF_INPUT_BUFFER_PADDING_SIZE );
     1194                AV_INPUT_BUFFER_PADDING_SIZE );
    11891195    }
    11901196
    11911197    do
    … … static picture_t *DecodeBlock( decoder_t  
    14141420        /* Hack to force display of still pictures */
    14151421        p_pic->b_force = p_sys->b_first_frame;
    14161422        p_pic->i_nb_fields = 2 + frame->repeat_pict;
     1423#if LIBAVUTIL_VERSION_CHECK( 58, 7, 100 )
     1424        p_pic->b_progressive = !(frame->flags & AV_FRAME_FLAG_INTERLACED);
     1425        p_pic->b_top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
     1426#else
    14171427        p_pic->b_progressive = !frame->interlaced_frame;
    14181428        p_pic->b_top_field_first = frame->top_field_first;
     1429#endif
    14191430
    14201431        if (DecodeSidedata(p_dec, frame, p_pic))
    14211432            i_pts = VLC_TICK_INVALID;
    … … static void ffmpeg_InitCodec( decoder_t  
    15021513        p_sys->p_context->extradata_size = i_size + 12;
    15031514        p = p_sys->p_context->extradata =
    15041515            av_malloc( p_sys->p_context->extradata_size +
    1505                        FF_INPUT_BUFFER_PADDING_SIZE );
     1516                       AV_INPUT_BUFFER_PADDING_SIZE );
    15061517        if( !p )
    15071518            return;
    15081519
    … … static void ffmpeg_InitCodec( decoder_t  
    15391550    {
    15401551        p_sys->p_context->extradata_size = i_size;
    15411552        p_sys->p_context->extradata =
    1542             av_malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );
     1553            av_malloc( i_size + AV_INPUT_BUFFER_PADDING_SIZE );
    15431554        if( p_sys->p_context->extradata )
    15441555        {
    15451556            memcpy( p_sys->p_context->extradata,
    15461557                    p_dec->fmt_in.p_extra, i_size );
    15471558            memset( p_sys->p_context->extradata + i_size,
    1548                     0, FF_INPUT_BUFFER_PADDING_SIZE );
     1559                    0, AV_INPUT_BUFFER_PADDING_SIZE );
    15491560        }
    15501561    }
    15511562}
  • modules/demux/avformat/demux.c

    diff -Nuarp vlc-3.0.21.orig/modules/demux/avformat/demux.c vlc-3.0.21/modules/demux/avformat/demux.c
    old new static vlc_fourcc_t CodecTagToFourcc( ui  
    112112#endif
    113113}
    114114
     115static inline void* GetStreamSideData(const AVStream *s, enum AVPacketSideDataType type)
     116{
     117#if LIBAVCODEC_VERSION_CHECK( 60, 29, 100 )
     118    const AVCodecParameters *cp = s->codecpar;
     119    const AVPacketSideData *psd =
     120        av_packet_side_data_get(cp->coded_side_data, cp->nb_coded_side_data, type);
     121    return psd ? psd->data : NULL;
     122#else
     123    return av_stream_get_side_data(s, type, NULL);
     124#endif
     125}
     126
    115127/*****************************************************************************
    116128 * Open
    117129 *****************************************************************************/
    … … static void get_rotation(es_format_t *fm  
    138150        else
    139151            fmt->video.orientation = ORIENT_NORMAL;
    140152    }
    141     int32_t *matrix = (int32_t *)av_stream_get_side_data(s, AV_PKT_DATA_DISPLAYMATRIX, NULL);
     153
     154    int32_t *matrix = GetStreamSideData(s, AV_PKT_DATA_DISPLAYMATRIX);
    142155    if( matrix ) {
    143156        angle = lround(av_display_rotation_get(matrix));
    144157