Changeset 11165
- Timestamp:
- 03/05/10 16:04:36 (3 years ago)
- Location:
- OpenSceneGraph/trunk/src/osgPlugins/ffmpeg
- Files:
-
- 2 modified
-
FFmpegDecoderAudio.cpp (modified) (2 diffs)
-
FFmpegDecoderVideo.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
r10961 r11165 13 13 namespace osgFFmpeg { 14 14 15 static int decode_audio(AVCodecContext *avctx, int16_t *samples, 16 int *frame_size_ptr, 17 const uint8_t *buf, int buf_size) 18 { 19 #if LIBAVCODEC_VERSION_MAJOR >= 52 20 21 // following code segment copied from ffmpeg's avcodec_decode_audio2() 22 // implementation to avoid warnings about deprecated function usage. 23 AVPacket avpkt; 24 av_init_packet(&avpkt); 25 avpkt.data = const_cast<uint8_t *>(buf); 26 avpkt.size = buf_size; 27 28 return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt); 29 #else 30 // fallback for older versions of ffmpeg that don't have avcodec_decode_audio3. 31 return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size); 32 #endif 33 } 15 34 16 35 … … 295 314 int data_size = size; 296 315 297 const int bytes_decoded = avcodec_decode_audio2(m_context, reinterpret_cast<int16_t*>(buffer), &data_size, m_packet_data, m_bytes_remaining);316 const int bytes_decoded = decode_audio(m_context, reinterpret_cast<int16_t*>(buffer), &data_size, m_packet_data, m_bytes_remaining); 298 317 299 318 if (bytes_decoded < 0) -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp
r10892 r11165 8 8 9 9 namespace osgFFmpeg { 10 11 static int decode_video(AVCodecContext *avctx, AVFrame *picture, 12 int *got_picture_ptr, 13 const uint8_t *buf, int buf_size) 14 { 15 #if LIBAVCODEC_VERSION_MAJOR >= 52 16 // following code segment copied from ffmpeg avcodec_decode_video() implementation 17 // to avoid warnings about deprecated function usage. 18 AVPacket avpkt; 19 av_init_packet(&avpkt); 20 avpkt.data = const_cast<uint8_t *>(buf); 21 avpkt.size = buf_size; 22 // HACK for CorePNG to decode as normal PNG by default 23 avpkt.flags = AV_PKT_FLAG_KEY; 24 25 return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt); 26 #else 27 // fallback for older versions of ffmpeg that don't have avcodec_decode_video2. 28 return avcodec_decode_video(avctx, picture, got_picture_ptr, buf, buf_size); 29 #endif 30 } 31 10 32 11 33 FFmpegDecoderVideo::FFmpegDecoderVideo(PacketQueue & packets, FFmpegClocks & clocks) : … … 166 188 int frame_finished = 0; 167 189 168 const int bytes_decoded = avcodec_decode_video(m_context, m_frame.get(), &frame_finished, m_packet_data, m_bytes_remaining);190 const int bytes_decoded = decode_video(m_context, m_frame.get(), &frame_finished, m_packet_data, m_bytes_remaining); 169 191 170 192 if (bytes_decoded < 0)
