Skip to content

Commit 9bb6bcd

Browse files
authored
Merge pull request #277 from cchampet/fix_generatorSetCustomFrame
generators: fixed set of a custom frame with any parameters
2 parents a76f38f + a52ccb7 commit 9bb6bcd

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ void AudioDecoder::setupDecoder(const ProfileLoader::Profile& profile)
5656
for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
5757
{
5858
if((*it).first == constants::avProfileIdentificator || (*it).first == constants::avProfileIdentificatorHuman ||
59-
(*it).first == constants::avProfileType || (*it).first == constants::avProfileThreads)
59+
(*it).first == constants::avProfileType || (*it).first == constants::avProfileCodec ||
60+
(*it).first == constants::avProfileThreads)
6061
continue;
6162

6263
try

src/AvTranscoder/decoder/AudioGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ bool AudioGenerator::decodeNextFrame(Frame& frameBuffer)
5555
// Take audio frame from _inputFrame
5656
else
5757
{
58-
LOG_DEBUG("Copy data of the audio specified when decode next frame")
59-
frameBuffer.copyData(*_inputFrame);
58+
LOG_DEBUG("Convert data of the audio specified when decode next frame")
59+
_audioTransform.convert(*_inputFrame, frameBuffer);
6060
}
6161
return true;
6262
}

src/AvTranscoder/decoder/AudioGenerator.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "IDecoder.hpp"
55
#include <AvTranscoder/codec/AudioCodec.hpp>
6+
#include <AvTranscoder/transform/AudioTransform.hpp>
67

78
namespace avtranscoder
89
{
@@ -21,12 +22,18 @@ class AvExport AudioGenerator : public IDecoder
2122
bool decodeNextFrame(Frame& frameBuffer);
2223
bool decodeNextFrame(Frame& frameBuffer, const std::vector<size_t> channelIndexArray);
2324

25+
/**
26+
* @brief Force to return this frame when calling the decoding methods.
27+
* @param inputFrame: could have other properties than the given frame when decoding (will be converted).
28+
* @see decodeNextFrame
29+
*/
2430
void setNextFrame(Frame& inputFrame) { _inputFrame = &inputFrame; }
2531

2632
private:
2733
Frame* _inputFrame; ///< Has link (no ownership)
2834
AudioFrame* _silent; ///< The generated silent (has ownership)
2935
const AudioFrameDesc _frameDesc; ///< The description of the given frame buffer when decoding.
36+
AudioTransform _audioTransform; ///< To transform the specified data when decoding.
3037
};
3138
}
3239

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ void VideoDecoder::setupDecoder(const ProfileLoader::Profile& profile)
5454
for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
5555
{
5656
if((*it).first == constants::avProfileIdentificator || (*it).first == constants::avProfileIdentificatorHuman ||
57-
(*it).first == constants::avProfileType || (*it).first == constants::avProfileThreads)
57+
(*it).first == constants::avProfileType || (*it).first == constants::avProfileCodec ||
58+
(*it).first == constants::avProfileThreads)
5859
continue;
5960

6061
try

src/AvTranscoder/decoder/VideoGenerator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ VideoGenerator::VideoGenerator(const VideoFrameDesc& frameDesc)
1111
: _inputFrame(NULL)
1212
, _blackImage(NULL)
1313
, _frameDesc(frameDesc)
14-
, _videoTransform()
1514
{
1615
}
1716

@@ -57,8 +56,8 @@ bool VideoGenerator::decodeNextFrame(Frame& frameBuffer)
5756
// Take image from _inputFrame
5857
else
5958
{
60-
LOG_DEBUG("Copy data of the image specified when decode next frame")
61-
frameBuffer.copyData(*_inputFrame);
59+
LOG_DEBUG("Convert data of the image specified when decode next frame")
60+
_videoTransform.convert(*_inputFrame, frameBuffer);
6261
}
6362
return true;
6463
}

src/AvTranscoder/decoder/VideoGenerator.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class AvExport VideoGenerator : public IDecoder
2323

2424
/**
2525
* @brief Force to return this frame when calling the decoding methods.
26-
* @param inputFrame: should have the same properties as the given frames when decoding.
26+
* @param inputFrame: could have other properties than the given frame when decoding (will be converted).
27+
* @see decodeNextFrame
2728
*/
2829
void setNextFrame(Frame& inputFrame) { _inputFrame = &inputFrame; }
2930

src/AvTranscoder/file/InputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void InputFile::setupUnwrapping(const ProfileLoader::Profile& profile)
147147
for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
148148
{
149149
if((*it).first == constants::avProfileIdentificator || (*it).first == constants::avProfileIdentificatorHuman ||
150-
(*it).first == constants::avProfileType)
150+
(*it).first == constants::avProfileType || (*it).first == constants::avProfileFormat)
151151
continue;
152152

153153
try

test/pyTest/testSetFrame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def testSetVideoFrame():
3838
p.progress( i, nbFrames )
3939

4040
# set video frame
41-
frame = av.VideoFrame( av.VideoFrameDesc(1920, 1080, "yuv422p") )
41+
frame = av.VideoFrame(av.VideoFrameDesc(1920, 1080, "rgb24"))
4242
frame.assign(i)
4343
videoDecoder.setNextFrame( frame )
4444

@@ -84,7 +84,7 @@ def testSetAudioFrame():
8484
p.progress( i, nbFrames )
8585

8686
# set video frame
87-
frame = av.AudioFrame( av.AudioFrameDesc(48000, 1, "s32") )
87+
frame = av.AudioFrame(av.AudioFrameDesc(44100, 1, "s16"))
8888
frame.assign(i)
8989
audioDecoder.setNextFrame( frame )
9090

0 commit comments

Comments
 (0)