Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-04-19 21:23:08 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-04-19 21:23:08 +0400
commit349b71fd02354a3d1288bccbb2d984d5f9a7e605 (patch)
treea54f8a5f9cefafd11d8191f1fa658a5b300a3f55 /intern/audaspace
parentfba67abf7a9caf8ccfa03af38d91f70de8875d2d (diff)
Bring back support of FFmpeg >= 0.7
After planar codecs support minimal FFmpeg was bumped to 0.10 which was not so much nice because it was only released only later last year. Didn't find a way to make compatibility code local in ffmpeg_compat, so there're some ifdefs in audaspace and writeffmpeg. Not entirely happy, but having a bit of ifdefs in code better than lots of real PITA for platform maintainers.
Diffstat (limited to 'intern/audaspace')
-rw-r--r--intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
index 408a4e56f1c..3d830df83e8 100644
--- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
+++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
@@ -43,6 +43,7 @@ extern "C" {
int AUD_FFMPEGReader::decode(AVPacket& packet, AUD_Buffer& buffer)
{
+#ifdef FFMPEG_HAVE_DECODE_AUDIO4
AVFrame* frame = NULL;
int got_frame;
int read_length;
@@ -101,6 +102,54 @@ int AUD_FFMPEGReader::decode(AVPacket& packet, AUD_Buffer& buffer)
av_free(frame);
return buf_pos;
+#else
+ // save packet parameters
+ uint8_t *audio_pkg_data = packet.data;
+ int audio_pkg_size = packet.size;
+
+ int buf_size = buffer.getSize();
+ int buf_pos = 0;
+
+ int read_length, data_size;
+
+ AVPacket tmp_pkt;
+
+ av_init_packet(&tmp_pkt);
+
+ // as long as there is still data in the package
+ while(audio_pkg_size > 0)
+ {
+ // resize buffer if needed
+ if(buf_size - buf_pos < AVCODEC_MAX_AUDIO_FRAME_SIZE)
+ {
+ buffer.resize(buf_size + AVCODEC_MAX_AUDIO_FRAME_SIZE, true);
+ buf_size += AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ }
+
+ // read samples from the packet
+ data_size = buf_size - buf_pos;
+
+ tmp_pkt.data = audio_pkg_data;
+ tmp_pkt.size = audio_pkg_size;
+
+ read_length = avcodec_decode_audio3(
+ m_codecCtx,
+ (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos),
+ &data_size, &tmp_pkt);
+
+ // read error, next packet!
+ if(read_length < 0)
+ break;
+
+ buf_pos += data_size;
+
+ // move packet parameters
+ audio_pkg_data += read_length;
+ audio_pkg_size -= read_length;
+ }
+
+ return buf_pos;
+#endif
}
static const char* streaminfo_error = "AUD_FFMPEGReader: Stream info couldn't "