diff utils.c @ 1630:586b5c08863c libavcodec

- Add reget_buffer() function to AVCodecContext - Add default reget_buffer implementation in libavcodec/utils.c - Remove AVCodecContext.cr_available, no longer needed - Remove CODEC_CAP_CR, no longer used - Add img_copy() prototype to avcodec.h (function from imgconvert.c) - Rename img_copy() to jpeg_img_copy() in libavformat/jpeg.c to avoid conflict - Updated msrle, msvideo1, rpza, smc to use reget_buffer
author rtognimp
date Wed, 26 Nov 2003 20:57:15 +0000
parents a1ac8e675b95
children 0e7f1aabd498
line wrap: on
line diff
--- a/utils.c	Tue Nov 25 00:35:18 2003 +0000
+++ b/utils.c	Wed Nov 26 20:57:15 2003 +0000
@@ -290,6 +290,38 @@
 //printf("R%X\n", pic->opaque);
 }
 
+int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
+    AVFrame temp_pic;
+    int i;
+
+    /* If no picture return a new buffer */
+    if(pic->data[0] == NULL) {
+        /* We will copy from buffer, so must be readable */
+        pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
+        return s->get_buffer(s, pic);
+    }
+
+    /* If internal buffer type return the same buffer */
+    if(pic->type == FF_BUFFER_TYPE_INTERNAL)
+        return 0;
+
+    /*
+     * Not internal type and reget_buffer not overridden, emulate cr buffer
+     */
+    temp_pic = *pic;
+    for(i = 0; i < 4; i++)
+        pic->data[i] = pic->base[i] = NULL;
+    pic->opaque = NULL;
+    /* Allocate new frame */
+    if (s->get_buffer(s, pic))
+        return -1;
+    /* Copy image data from old buffer to new buffer */
+    img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
+             s->height);
+    s->release_buffer(s, &temp_pic); // Release old frame
+    return 0;
+}
+
 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum PixelFormat * fmt){
     return fmt[0];
 }
@@ -326,7 +358,7 @@
     s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
     s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
     s->palctrl = NULL;
-    s->cr_available = 0;
+    s->reget_buffer= avcodec_default_reget_buffer;
 }
 
 /**