[Android] avcodec_flush_buffers() in avcodec module causes broken picture

Rui Zhang bbcallen at gmail.com
Wed Feb 27 15:21:53 CET 2013


Hello

I have been testing playing 720p video (FLV: H264+AAC) on Nexus S via
customized vlc-android build (based on 0.0.9 release, libav-master.
video and audio are both decoded with avcodec module.)

I added some msleep() in http module to simulate a busy network. As
expected, vlc-android prerolled very often. The point is that, after
BLOCK_FLAG_DISCONTINUITY block is caught in avcodec decoder, if
following frames are p-frames, there is a very high chance for decoder
to send some broken pictures to vout until next I-frame data.

After some attempt, I'm able to make output pictures much better (at
least for my video sample) by revert the commit below

http://git.videolan.org/?p=vlc.git;a=blobdiff;f=modules/codec/avcodec/video.c;h=0b8ce63b7cd01af933535cb36ba6d1d5842fd45a;hp=ad71de551861451404798060f74b93bd4aafd956;hb=4979e6d702eab1973dfee025c492bb3f945363e0;hpb=27e306df96c937068816685406593e980a53a585

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index ad71de5..0b8ce63 100644 (file)
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -451,10 +451,10 @@ picture_t *DecodeVideo( decoder_t *p_dec,
block_t **pp_block )

         p_sys->i_late_frames = 0;

-        block_Release( p_block );
+        if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+            avcodec_flush_buffers( p_context );

-        //if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
-            //avcodec_flush_buffers( p_context );
+        block_Release( p_block );
         return NULL;
     }


I don't have enough knowledge about ffmpeg/libav and VLC to tell
whether it is a clean shot, and how danger without
avcodec_flush_buffers()

I'd like to be shared with any better idea to handle p-frame after
discontinuity block in VLC. Related TODO/FIXME are also welcomed.

Best regards


More information about the Android mailing list