Skip to content

Commit

Permalink
Replace deprecated ffmpeg functions:
Browse files Browse the repository at this point in the history
  avpicture_get_size -> av_image_get_buffer_size
  avpicture_fill -> av_image_fill_arrays
  av_picture_copy -> av_image_copy

Add missing includes.

This fixes build with ffmpeg-6.x.x
  • Loading branch information
jpulz authored and akallabeth committed May 2, 2023
1 parent 3cb55a8 commit 61983cd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
Expand Up @@ -30,6 +30,8 @@

#include <libavcodec/avcodec.h>
#include <libavutil/common.h>
#include <libavutil/cpu.h>
#include <libavutil/imgutils.h>

#include "tsmf_constants.h"
#include "tsmf_decoder.h"
Expand Down Expand Up @@ -397,9 +399,9 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
mdecoder->frame->linesize[2], mdecoder->frame->linesize[3],
mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
mdecoder->codec_context->height);
mdecoder->decoded_size =
avpicture_get_size(mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
mdecoder->codec_context->height);
mdecoder->decoded_size = av_image_get_buffer_size(mdecoder->codec_context->pix_fmt,
mdecoder->codec_context->width,
mdecoder->codec_context->height, 1);
mdecoder->decoded_data = calloc(1, mdecoder->decoded_size);

if (!mdecoder->decoded_data)
Expand All @@ -410,11 +412,12 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
#else
frame = av_frame_alloc();
#endif
avpicture_fill((AVPicture*)frame, mdecoder->decoded_data, mdecoder->codec_context->pix_fmt,
mdecoder->codec_context->width, mdecoder->codec_context->height);
av_picture_copy((AVPicture*)frame, (AVPicture*)mdecoder->frame,
mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
mdecoder->codec_context->height);
av_image_fill_arrays(frame->data, frame->linesize, mdecoder->decoded_data,
mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width,
mdecoder->codec_context->height, 1);
av_image_copy(frame->data, frame->linesize, (const uint8_t**)mdecoder->frame->data,
mdecoder->frame->linesize, mdecoder->codec_context->pix_fmt,
mdecoder->codec_context->width, mdecoder->codec_context->height);
av_free(frame);
}

Expand Down

1 comment on commit 61983cd

@VVD
Copy link

@VVD VVD commented on 61983cd Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please merge this commit into stable-2.0?

Please sign in to comment.