Skip to content

Commit 9bda038

Browse files
committed
Fix deprecated warnings into decoded data classes
1 parent d06084a commit 9bda038

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/AvTranscoder/data/decoded/AudioFrame.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ AudioFrame::AudioFrame(const AudioFrameDesc& desc, const bool forceDataAllocatio
4545
, _desc(desc)
4646
{
4747
// Set Frame properties
48-
av_frame_set_sample_rate(_frame, desc._sampleRate);
49-
av_frame_set_channels(_frame, desc._nbChannels);
50-
av_frame_set_channel_layout(_frame, av_get_default_channel_layout(desc._nbChannels));
48+
_frame->sample_rate = desc._sampleRate;
49+
_frame->channels = desc._nbChannels;
50+
_frame->channel_layout = av_get_default_channel_layout(desc._nbChannels);
5151
_frame->format = desc._sampleFormat;
5252
_frame->nb_samples = getDefaultNbSamples();
5353

@@ -102,9 +102,9 @@ void AudioFrame::allocateData()
102102
LOG_WARN("The AudioFrame seems to already have allocated data. This could lead to memory leaks.")
103103

104104
// Set Frame properties
105-
av_frame_set_sample_rate(_frame, _desc._sampleRate);
106-
av_frame_set_channels(_frame, _desc._nbChannels);
107-
av_frame_set_channel_layout(_frame, av_get_default_channel_layout(_desc._nbChannels));
105+
_frame->sample_rate = _desc._sampleRate;
106+
_frame->channels = _desc._nbChannels;
107+
_frame->channel_layout = av_get_default_channel_layout(_desc._nbChannels);
108108
_frame->format = _desc._sampleFormat;
109109
if(_frame->nb_samples == 0)
110110
_frame->nb_samples = getDefaultNbSamples();

src/AvTranscoder/data/decoded/AudioFrame.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class AvExport AudioFrame : public IFrame
5151
void freeData();
5252
size_t getDataSize() const;
5353

54-
size_t getSampleRate() const { return av_frame_get_sample_rate(_frame); }
55-
size_t getNbChannels() const { return av_frame_get_channels(_frame); }
56-
size_t getChannelLayout() const { return av_frame_get_channel_layout(_frame); }
54+
size_t getSampleRate() const { return _frame->sample_rate; }
55+
size_t getNbChannels() const { return _frame->channels; }
56+
size_t getChannelLayout() const { return _frame->channel_layout; }
5757
std::string getChannelLayoutDesc() const; ///< Get a description of a channel layout (example: '5.1').
5858
AVSampleFormat getSampleFormat() const { return static_cast<AVSampleFormat>(_frame->format); }
5959
size_t getBytesPerSample() const; ///< 0 if unknown sample format

src/AvTranscoder/data/decoded/IFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void IFrame::assignValue(const unsigned char value)
6969

7070
// Create the buffer
7171
const int bufferSize = getDataSize();
72-
unsigned char* dataBuffer = static_cast<unsigned char*>(malloc(bufferSize * sizeof(unsigned char)));
72+
unsigned char* dataBuffer = static_cast<unsigned char*>(av_malloc(bufferSize * sizeof(unsigned char)));
7373
memset(dataBuffer, value, bufferSize);
7474

7575
// Fill the frame

src/AvTranscoder/data/decoded/VideoFrame.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
extern "C" {
66
#include <libavcodec/avcodec.h>
77
#include <libavutil/pixdesc.h>
8+
#include <libavutil/imgutils.h>
89
}
910

1011
#include <stdexcept>
@@ -75,7 +76,7 @@ size_t VideoFrame::getDataSize() const
7576
return 0;
7677
}
7778

78-
const size_t size = avpicture_get_size(getPixelFormat(), getWidth(), getHeight());
79+
const size_t size = av_image_get_buffer_size(getPixelFormat(), getWidth(), getHeight(), 1);
7980
if(size == 0)
8081
throw std::runtime_error("Unable to determine image buffer size: " + getDescriptionFromErrorCode(size));
8182
return size;
@@ -92,7 +93,7 @@ void VideoFrame::allocateData()
9293
_frame->format = _desc._pixelFormat;
9394

9495
// Allocate data
95-
const int ret = avpicture_alloc(reinterpret_cast<AVPicture*>(_frame), _desc._pixelFormat, _desc._width, _desc._height);
96+
const int ret = av_image_alloc(_frame->data, _frame->linesize, _desc._width, _desc._height, _desc._pixelFormat, 1);
9697
if(ret < 0)
9798
{
9899
const std::string formatName = getPixelFormatName(_desc._pixelFormat);
@@ -109,14 +110,13 @@ void VideoFrame::allocateData()
109110

110111
void VideoFrame::freeData()
111112
{
112-
avpicture_free(reinterpret_cast<AVPicture*>(_frame));
113+
av_freep(&_frame->data[0]);
113114
_dataAllocated = false;
114115
}
115116

116117
void VideoFrame::assignBuffer(const unsigned char* ptrValue)
117118
{
118-
const int ret =
119-
avpicture_fill(reinterpret_cast<AVPicture*>(_frame), ptrValue, getPixelFormat(), getWidth(), getHeight());
119+
const int ret = av_image_fill_arrays(_frame->data, _frame->linesize, ptrValue, getPixelFormat(), getWidth(), getHeight(), 1);
120120
if(ret < 0)
121121
{
122122
std::stringstream msg;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy