diff mpegvideo.c @ 1368:0fd38b711f06 libavcodec

AVCodec.flush() ff_draw_horiz_band() in coded order / cleanup
author michaelni
date Thu, 17 Jul 2003 12:29:07 +0000
parents 1f89adb69349
children 8a150a66d2d9
line wrap: on
line diff
--- a/mpegvideo.c	Wed Jul 16 18:20:46 2003 +0000
+++ b/mpegvideo.c	Thu Jul 17 12:29:07 2003 +0000
@@ -2725,29 +2725,26 @@
  * @param h is the normal height, this will be reduced automatically if needed for the last row
  */
 void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
-    if (    s->avctx->draw_horiz_band 
-        && (s->last_picture_ptr || s->low_delay) ) {
+    if (s->avctx->draw_horiz_band) {
         uint8_t *src_ptr[3];
-        int offset;
+        int offset[4];
         h= FFMIN(h, s->height - y);
 
-        if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME)
-            offset = 0;
-        else
-            offset = y * s->linesize;
-
-        if(s->pict_type==B_TYPE || s->low_delay){
-            src_ptr[0] = s->current_picture.data[0] + offset;
-            src_ptr[1] = s->current_picture.data[1] + (offset >> 2);
-            src_ptr[2] = s->current_picture.data[2] + (offset >> 2);
-        } else {
-            src_ptr[0] = s->last_picture.data[0] + offset;
-            src_ptr[1] = s->last_picture.data[1] + (offset >> 2);
-            src_ptr[2] = s->last_picture.data[2] + (offset >> 2);
+        if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME){
+            offset[0]=
+            offset[1]=
+            offset[2]=
+            offset[3]= 0;
+        }else{
+            offset[0]= y * s->linesize;;
+            offset[1]= 
+            offset[2]= (y>>1) * s->uvlinesize;;
+            offset[3]= 0;
         }
+
         emms_c();
 
-        s->avctx->draw_horiz_band(s->avctx, src_ptr, s->linesize,
+        s->avctx->draw_horiz_band(s->avctx, (AVFrame*)s->current_picture_ptr, offset,
                                y, s->width, h);
     }
 }
@@ -3076,6 +3073,18 @@
     return 0;
 }
 
+void ff_mpeg_flush(AVCodecContext *avctx){
+    int i;
+    MpegEncContext *s = avctx->priv_data;
+    
+    for(i=0; i<MAX_PICTURE_COUNT; i++){
+       if(s->picture[i].data[0] && (   s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
+                                    || s->picture[i].type == FF_BUFFER_TYPE_USER))
+        avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
+    }
+    s->last_picture_ptr = s->next_picture_ptr = NULL;
+}
+
 #ifdef CONFIG_ENCODERS
 void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
 {