aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorXerxes Rånby <[email protected]>2013-04-28 17:45:12 +0200
committerXerxes Rånby <[email protected]>2013-05-10 09:39:49 +0200
commit6c24449961bb06d3954059f41f7ee70d5bfeb5b5 (patch)
tree1c3c62918357fe23d813c2ad5cded5dbcba9e8fa /src/jogl
parentdce425fdc835ed2289a688bc93cf6037c517d018 (diff)
FFMPEGMediaPlayer: Decode all frames inside video packet.
Signed-off-by: Xerxes Rånby <[email protected]>
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
index ae4507603..a90036fdb 100644
--- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
+++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
@@ -616,7 +616,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex
if (!frameFinished) {
// stop sending empty packets if the decoder is finished
- if (!packet.data && pAV->pVCodecCtx->codec->capabilities & CODEC_CAP_DELAY) {
+ if (!packet.data && pAV->pACodecCtx->codec->capabilities & CODEC_CAP_DELAY) {
flush_complete = 1;
}
continue;
@@ -652,11 +652,35 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex
sp_av_free_packet(&packet);
return res;
}
- sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameFinished, &packet);
- // Did we get a video frame?
- if(frameFinished)
- {
+ int new_packet = 1;
+ int len1;
+ int flush_complete = 0;
+ while (packet.size > 0 || (!packet.data && new_packet)) {
+
+ new_packet = 0;
+ if (flush_complete) {
+ break;
+ }
+
+ len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameFinished, &packet);
+
+ if (len1 < 0) {
+ // if error, we skip the frame
+ packet.size = 0;
+ break;
+ }
+ packet.data += len1;
+ packet.size -= len1;
+
+ if (!frameFinished) {
+ // stop sending empty packets if the decoder is finished
+ if (!packet.data && pAV->pVCodecCtx->codec->capabilities & CODEC_CAP_DELAY) {
+ flush_complete = 1;
+ }
+ continue;
+ }
+
res = 2;
// FIXME: Libav Binary compatibility! JAU01
const AVRational time_base = pAV->pVStream->time_base;