Guest User

ffmpeg8 patch for cingg

a guest
May 10th, 2025
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.32 KB | None | 0 0
  1. diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
  2. index 1f7f027e..1b027a7f 100644
  3. --- a/cinelerra-5.1/cinelerra/bdwrite.C
  4. +++ b/cinelerra-5.1/cinelerra/bdwrite.C
  5. @@ -2586,7 +2586,11 @@ static int field_probe(AVFormatContext *fmt_ctx, AVStream *st)
  6.      }
  7.      ret = avcodec_receive_frame(ctx, ipic);
  8.      if( ret >= 0 ) {
  9. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  10.        ilaced = ipic->interlaced_frame ? 1 : 0;
  11. +#else
  12. +    ilaced = ipic->flags & AV_FRAME_FLAG_INTERLACED  ? 1 : 0;
  13. +#endif
  14.        break;
  15.      }
  16.      if( ret != AVERROR(EAGAIN) )
  17. @@ -2769,7 +2773,9 @@ int media_info::scan()
  18.      ret = scan(fmt_ctx);
  19.  
  20.    for( int i=0; i<(int)streams.size(); ++i )
  21. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  22.      avcodec_close(streams[i]->ctx);
  23. +#endif
  24.    avformat_close_input(&fmt_ctx);
  25.  
  26.    return ret;
  27. diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
  28. index 075ef4dd..8aee2c2a 100644
  29. --- a/cinelerra-5.1/cinelerra/ffmpeg.C
  30. +++ b/cinelerra-5.1/cinelerra/ffmpeg.C
  31. @@ -310,7 +310,9 @@ FFStream::FFStream(FFMPEG *ffmpeg, AVStream *st, int fidx)
  32.  FFStream::~FFStream()
  33.  {
  34.     frm_lock->lock("FFStream::~FFStream");
  35. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  36.     if( reading > 0 || writing > 0 ) avcodec_close(avctx);
  37. +#endif
  38.     if( avctx ) avcodec_free_context(&avctx);
  39.     if( fmt_ctx ) avformat_close_input(&fmt_ctx);
  40.     if( hw_device_ctx ) av_buffer_unref(&hw_device_ctx);
  41. @@ -473,7 +475,9 @@ int FFStream::decode_activate()
  42.             if( ret < 0 && hw_type != AV_HWDEVICE_TYPE_NONE ) {
  43.                 ff_err(ret, "HW device init failed, using SW decode.\nfile:%s\n",
  44.                     ffmpeg->fmt_ctx->url);
  45. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  46.                 avcodec_close(avctx);
  47. +#endif
  48.                 avcodec_free_context(&avctx);
  49.                 av_buffer_unref(&hw_device_ctx);
  50.                 hw_device_ctx = 0;
  51. @@ -1303,7 +1307,7 @@ int FFVideoStream::probe(int64_t pos)
  52.         if( ret > 0 ) {
  53.             //printf("codec interlace: %i \n",frame->interlaced_frame);
  54.             //printf("codec tff: %i \n",frame->top_field_first);
  55. -
  56. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  57.             if (!frame->interlaced_frame)
  58.                 ffmpeg->interlace_from_codec = AV_FIELD_PROGRESSIVE;
  59.             if ((frame->interlaced_frame) && (frame->top_field_first))
  60. @@ -1311,7 +1315,14 @@ int FFVideoStream::probe(int64_t pos)
  61.             if ((frame->interlaced_frame) && (!frame->top_field_first))
  62.                 ffmpeg->interlace_from_codec = AV_FIELD_BB;
  63.             //printf("Interlace mode from codec: %i\n", ffmpeg->interlace_from_codec);
  64. -
  65. +#esle
  66. +           if (!frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
  67. +               ffmpeg->interlace_from_codec = AV_FIELD_PROGRESSIVE;
  68. +           if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
  69. +               ffmpeg->interlace_from_codec = AV_FIELD_TT;
  70. +           if ((frame->flags & AV_FRAME_FLAG_INTERLACED ) && (!frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
  71. +               ffmpeg->interlace_from_codec = AV_FIELD_BB;
  72. +#endif
  73.     }
  74.  
  75.     if( frame->format == AV_PIX_FMT_NONE || frame->width <= 0 || frame->height <= 0 )
  76. @@ -1337,7 +1348,11 @@ int FFVideoStream::load(VFrame *vframe, int64_t pos)
  77.     while( ret>=0 && !flushed && curr_pos<=pos && --i>=0 ) {
  78.         ret = read_frame(frame);
  79.         if( ret > 0 ) {
  80. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  81.             if( frame->key_frame && seeking < 0 ) {
  82. +#else
  83. +           if( (frame->flags & AV_FRAME_FLAG_KEY) && seeking < 0 ) {
  84. +#endif
  85.                 int use_cache = ffmpeg->get_use_cache();
  86.                 if( use_cache < 0 ) {
  87.  // for reverse read, reload file frame_cache from keyframe to pos
  88. @@ -1509,8 +1524,15 @@ int FFVideoStream::drain()
  89.  int FFVideoStream::encode_frame(AVFrame *frame)
  90.  {
  91.     if( frame ) {
  92. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  93.         frame->interlaced_frame = interlaced;
  94.         frame->top_field_first = top_field_first;
  95. +#else
  96. +       if(top_field_first)
  97. +       frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
  98. +       if(interlaced)
  99. +       frame->flags |= AV_FRAME_FLAG_INTERLACED;
  100. +#endif
  101.     }
  102.     if( frame && frame->format == AV_PIX_FMT_VAAPI ) { // ugly
  103.         int ret = avcodec_send_frame(avctx, frame);
  104. @@ -3844,7 +3866,20 @@ double FFVideoStream::get_rotation_angle()
  105.  #else
  106.     int size = 0;
  107.  #endif
  108. +
  109. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  110.     int *matrix = (int*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, &size);
  111. +#else
  112. +   int32_t *matrix = NULL;
  113. +        if (!matrix) {
  114. +            const AVPacketSideData *psd = av_packet_side_data_get(st->codecpar->coded_side_data,
  115. +                                                                  st->codecpar->nb_coded_side_data,
  116. +                                                                  AV_PKT_DATA_DISPLAYMATRIX);
  117. +            if (psd)
  118. +                matrix = (int32_t *)psd->data;
  119. +        }
  120. +  
  121. +#endif
  122.     int len = size/sizeof(*matrix);
  123.     if( !matrix || len < 5 ) return 0;
  124.     const double s = 1/65536.;
  125. diff --git a/cinelerra-5.1/cinelerra/fileac3.C b/cinelerra-5.1/cinelerra/fileac3.C
  126. index 63654f32..34469aef 100644
  127. --- a/cinelerra-5.1/cinelerra/fileac3.C
  128. +++ b/cinelerra-5.1/cinelerra/fileac3.C
  129. @@ -191,7 +191,9 @@ int FileAC3::close_file()
  130.     if(codec_context)
  131.     {
  132.         encode_flush();
  133. +#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(59,16,100)
  134.         avcodec_close(codec_context);
  135. +#endif
  136.         avcodec_free_context(&codec_context);
  137.         codec = 0;
  138.     }
  139.  
Advertisement
Add Comment
Please, Sign In to add comment