Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99dba44

Browse files
authored
Merge pull request#315 from avTranscoder/dev/fix_some_deprecated_warnings
Fix some deprecated warnings
2 parents7953180 +fb86d8d commit99dba44

16 files changed

+75
-62
lines changed

‎src/AvTranscoder/Library.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ Libraries getLibraries()
105105
std::vector<std::string>getInputExtensions()
106106
{
107107
std::vector<std::string> extensions;
108-
AVInputFormat* iFormat =NULL;
108+
const AVInputFormat* iFormat =NULL;
109+
void *iFormatOpaque =NULL;
109110

110-
while((iFormat =av_iformat_next(iFormat)))
111+
while((iFormat =av_demuxer_iterate(&iFormatOpaque)))
111112
{
112113
if(iFormat->extensions !=NULL)
113114
{
@@ -143,9 +144,10 @@ std::vector<std::string> getInputExtensions()
143144
std::vector<std::string>getOutputExtensions()
144145
{
145146
std::vector<std::string> extensions;
146-
AVOutputFormat* oFormat =NULL;
147+
const AVOutputFormat* oFormat =NULL;
148+
void *oFormatOpaque =NULL;
147149

148-
while((oFormat =av_oformat_next(oFormat)))
150+
while((oFormat =av_muxer_iterate(&oFormatOpaque)))
149151
{
150152
if(oFormat->extensions !=NULL)
151153
{

‎src/AvTranscoder/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ namespace avtranscoder
1515

1616
voidpreloadCodecsAndFormats()
1717
{
18+
#if LIBAVFILTER_VERSION_MAJOR < 7
1819
av_register_all();
1920
avfilter_register_all();
21+
#endif
2022
}
2123

2224
std::stringgetDescriptionFromErrorCode(constint code)

‎src/AvTranscoder/data/coded/CodedData.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CodedData& CodedData::operator=(const CodedData& other)
4343

4444
CodedData::~CodedData()
4545
{
46-
av_free_packet(&_packet);
46+
av_packet_unref(&_packet);
4747
}
4848

4949
voidCodedData::resize(constsize_t newSize)
@@ -75,7 +75,7 @@ void CodedData::refData(CodedData& frame)
7575

7676
voidCodedData::clear()
7777
{
78-
av_free_packet(&_packet);
78+
av_packet_unref(&_packet);
7979
initAVPacket();
8080
}
8181

@@ -94,7 +94,9 @@ void CodedData::initAVPacket()
9494

9595
voidCodedData::copyAVPacket(const AVPacket& avPacket)
9696
{
97-
#if AVTRANSCODER_FFMPEG_DEPENDENCY && LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 56, 0)
97+
#if AVTRANSCODER_FFMPEG_DEPENDENCY && LIBAVCODEC_VERSION_MAJOR > 57
98+
av_packet_ref(&_packet, &avPacket);
99+
#elif AVTRANSCODER_FFMPEG_DEPENDENCY && LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 56, 0)
98100
// Need const_cast<AVCodec*> for libav versions from 54.56. to 55.56.
99101
av_copy_packet(&_packet,const_cast<AVPacket*>(&avPacket));
100102
#else

‎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
voidfreeData();
5252
size_tgetDataSize()const;
5353

54-
size_tgetSampleRate()const {returnav_frame_get_sample_rate(_frame); }
55-
size_tgetNbChannels()const {returnav_frame_get_channels(_frame); }
56-
size_tgetChannelLayout()const {returnav_frame_get_channel_layout(_frame); }
54+
size_tgetSampleRate()const {return _frame->sample_rate; }
55+
size_tgetNbChannels()const {return _frame->channels; }
56+
size_tgetChannelLayout()const {return _frame->channel_layout; }
5757
std::stringgetChannelLayoutDesc()const;///< Get a description of a channel layout (example: '5.1').
5858
AVSampleFormatgetSampleFormat()const {returnstatic_cast<AVSampleFormat>(_frame->format); }
5959
size_tgetBytesPerSample()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
constint bufferSize =getDataSize();
72-
unsignedchar* dataBuffer =static_cast<unsignedchar*>(malloc(bufferSize *sizeof(unsignedchar)));
72+
unsignedchar* dataBuffer =static_cast<unsignedchar*>(av_malloc(bufferSize *sizeof(unsignedchar)));
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
return0;
7677
}
7778

78-
constsize_t size =avpicture_get_size(getPixelFormat(),getWidth(),getHeight());
79+
constsize_t size =av_image_get_buffer_size(getPixelFormat(),getWidth(),getHeight(),1);
7980
if(size ==0)
8081
throwstd::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-
constint ret =avpicture_alloc(reinterpret_cast<AVPicture*>(_frame), _desc._pixelFormat, _desc._width, _desc._height);
96+
constint 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
voidVideoFrame::freeData()
111112
{
112-
avpicture_free(reinterpret_cast<AVPicture*>(_frame));
113+
av_freep(&_frame->data[0]);
113114
_dataAllocated =false;
114115
}
115116

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

‎src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,18 @@ bool AudioEncoder::encodeFrame(const IFrame& sourceFrame, CodedData& codedFrame)
9696
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
9797

9898
AVPacket& packet = codedFrame.getAVPacket();
99-
if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (int)AV_NOPTS_VALUE))
99+
const AVFrame& srcAvFrame = sourceFrame.getAVFrame();
100+
if(srcAvFrame.pts != (int)AV_NOPTS_VALUE)
100101
{
101-
packet.pts =avCodecContext.coded_frame->pts;
102+
packet.pts =srcAvFrame.pts;
102103
}
103104

104-
if(avCodecContext.coded_frame && avCodecContext.coded_frame->key_frame)
105+
if(srcAvFrame.key_frame)
105106
{
106107
packet.flags |= AV_PKT_FLAG_KEY;
107108
}
108109

109-
returnencode(&sourceFrame.getAVFrame(), packet);
110+
returnencode(&srcAvFrame, packet);
110111
}
111112

112113
boolAudioEncoder::encodeFrame(CodedData& codedFrame)

‎src/AvTranscoder/encoder/AudioEncoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _AV_TRANSCODER_ENCODER_AUDIO_ENCODER_HPP_
22
#define_AV_TRANSCODER_ENCODER_AUDIO_ENCODER_HPP_
33

4-
#include"IEncoder.hpp"
4+
#include<AvTranscoder/encoder/IEncoder.hpp>
55
#include<AvTranscoder/codec/AudioCodec.hpp>
66
#include<AvTranscoder/profile/ProfileLoader.hpp>
77

‎src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,18 @@ bool VideoEncoder::encodeFrame(const IFrame& sourceFrame, CodedData& codedFrame)
113113
AVCodecContext& avCodecContext = _codec.getAVCodecContext();
114114

115115
AVPacket& packet = codedFrame.getAVPacket();
116-
if((avCodecContext.coded_frame) && (avCodecContext.coded_frame->pts != (int)AV_NOPTS_VALUE))
116+
const AVFrame& srcAvFrame = sourceFrame.getAVFrame();
117+
if(srcAvFrame.pts != (int)AV_NOPTS_VALUE)
117118
{
118-
packet.pts =avCodecContext.coded_frame->pts;
119+
packet.pts =srcAvFrame.pts;
119120
}
120121

121-
if(avCodecContext.coded_frame && avCodecContext.coded_frame->key_frame)
122+
if(srcAvFrame.key_frame)
122123
{
123124
packet.flags |= AV_PKT_FLAG_KEY;
124125
}
125126

126-
returnencode(&sourceFrame.getAVFrame(), packet);
127+
returnencode(&srcAvFrame, packet);
127128
}
128129

129130
boolVideoEncoder::encodeFrame(CodedData& codedFrame)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp