aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorAlexander Strange <astrange@ithinksw.com>2011-04-18 00:47:35 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-18 00:47:35 +0200
commit7e2eb4bacd70541702bd086ab2a39cb7653d314e (patch)
tree45898e55103fffe67ebe5a5454522688fd40cdca /libavcodec/mpegvideo.c
parent2d2b5a1421ee652f76a756024d0210f0b6455fda (diff)
downloadffmpeg-7e2eb4bacd70541702bd086ab2a39cb7653d314e.tar.gz
Merge remote-tracking branch 'ffmpeg-mt/master'
* ffmpeg-mt/master: Release unused pictures even when not calling ff_h264_frame_start() h264: Fix decoding race condition with PAFF h264: cosmetic whitespace change Duplicate Fix REBASE_PICTURE with h.264 Not pulled Update test scripts to use ffmpeg instead of ffmpeg_g Duplicate Fix ffmpeg-mt fixme in h264 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 676c3ebe8a..819f58dc95 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -316,6 +316,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
s->prev_pict_types[0]= s->dropable ? FF_B_TYPE : s->pict_type;
if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == FF_B_TYPE)
pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
+ pic->owner2 = s;
return 0;
fail: //for the FF_ALLOCZ_OR_GOTO macro
@@ -946,6 +947,21 @@ void init_vlc_rl(RLTable *rl)
}
}
+void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
+{
+ int i;
+
+ /* release non reference frames */
+ for(i=0; i<s->picture_count; i++){
+ if(s->picture[i].data[0] && !s->picture[i].reference
+ && s->picture[i].owner2 == s
+ && (remove_current || &s->picture[i] != s->current_picture_ptr)
+ /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
+ free_frame_buffer(s, &s->picture[i]);
+ }
+ }
+}
+
int ff_find_unused_picture(MpegEncContext *s, int shared){
int i;
@@ -1025,12 +1041,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
if(!s->encoding){
- /* release non reference frames */
- for(i=0; i<s->picture_count; i++){
- if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
- free_frame_buffer(s, &s->picture[i]);
- }
- }
+ ff_release_unused_pictures(s, 1);
if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL)
pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header)