[FFmpeg-devel] [PATCH] lavc/rawdec: rename RawVideoContext variable "length" to buffer_size

Stefano Sabatini stefasab at gmail.com
Tue Jun 26 13:16:59 CEST 2012


Make more apparent the relationship with the variable "buffer".
---
 libavcodec/rawdec.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 25ecde1..1bbe93d 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -35,7 +35,7 @@ typedef struct RawVideoContext {
     AVClass *av_class;
     uint32_t palette[AVPALETTE_COUNT];
     unsigned char * buffer;  /* block of memory for holding one frame */
-    int             length;  /* number of bytes in buffer */
+    int             buffer_size;  /* number of bytes in buffer */
     int flip;
     AVFrame pic;             ///< AVCodecContext.coded_frame
     int tff;
@@ -111,12 +111,12 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
        avctx->pix_fmt==PIX_FMT_PAL8 &&
        (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){
-        context->length = avpicture_get_size(avctx->pix_fmt, FFALIGN(avctx->width, 16), avctx->height);
-        context->buffer = av_malloc(context->length);
+        context->buffer_size = avpicture_get_size(avctx->pix_fmt, FFALIGN(avctx->width, 16), avctx->height);
+        context->buffer = av_malloc(context->buffer_size);
         if (!context->buffer)
             return AVERROR(ENOMEM);
     } else {
-        context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+        context->buffer_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
     }
     context->pic.pict_type = AV_PICTURE_TYPE_I;
     context->pic.key_frame = 1;
@@ -171,7 +171,7 @@ static int raw_decode(AVCodecContext *avctx,
     if (context->buffer) {
         int i;
         uint8_t *dst = context->buffer;
-        buf_size = context->length - 256*4;
+        buf_size = context->buffer_size - 256*4;
         if (avctx->bits_per_coded_sample == 4){
             for(i=0; 2*i+1 < buf_size && i<avpkt->size; i++){
                 dst[2*i+0]= buf[i]>>4;
@@ -192,9 +192,9 @@ static int raw_decode(AVCodecContext *avctx,
 
     if(avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
        avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
-        buf += buf_size - context->length;
+        buf += buf_size - context->buffer_size;
 
-    len = context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0);
+    len = context->buffer_size - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0);
     if (buf_size < len) {
         av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected length %d\n", buf_size, len);
         return AVERROR(EINVAL);
@@ -203,7 +203,7 @@ static int raw_decode(AVCodecContext *avctx,
     if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
                               avctx->width, avctx->height)) < 0)
         return res;
-    if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
+    if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->buffer_size) ||
        (av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
         frame->data[1]= context->palette;
     }
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list