[FFmpeg-cvslog] avcodec: change number of plane pointers from 4 to 8 at next major bump.

Justin Ruggles git at videolan.org
Sat Dec 3 03:13:09 CET 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Nov 14 16:07:03 2011 -0500| [560f773c7ddd17f66e2621222980c1359a9027be] | committer: Justin Ruggles

avcodec: change number of plane pointers from 4 to 8 at next major bump.

Add AV_NUM_DATA_POINTERS to simplify the bump transition.
This will allow for supporting more planar audio channels without having to
allocate separate pointer arrays.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=560f773c7ddd17f66e2621222980c1359a9027be
---

 doc/APIchanges         |    6 ++++++
 libavcodec/avcodec.h   |   23 ++++++++++++++---------
 libavcodec/huffyuv.c   |    7 ++++---
 libavcodec/mpegvideo.c |   12 ++++++------
 libavcodec/utils.c     |   27 ++++++++++++++++-----------
 libavcodec/version.h   |    6 ++++--
 libavcodec/vp3.c       |    7 ++++---
 7 files changed, 54 insertions(+), 34 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 6c00ee9..f664376 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,12 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-xx-xx - xxxxxxx - lavc 53.24.0
+  Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump.
+  Change AVPicture.data[4]/linesize[4] to [8] at next major bump.
+  Change AVCodecContext.error[4] to [8] at next major bump.
+  Add AV_NUM_DATA_POINTERS to simplify the bump transition.
+
 2011-11-23 - bbb46f3 - lavu 51.18.0
   Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and
   av_samples_alloc(), to samplefmt.h.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 43abcd8..eeafce4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -927,21 +927,26 @@ typedef struct AVPacket {
  * sizeof(AVFrame) must not be used outside libav*.
  */
 typedef struct AVFrame {
+#if FF_API_DATA_POINTERS
+#define AV_NUM_DATA_POINTERS 4
+#else
+#define AV_NUM_DATA_POINTERS 8
+#endif
     /**
      * pointer to the picture planes.
      * This might be different from the first allocated byte
      * - encoding:
      * - decoding:
      */
-    uint8_t *data[4];
-    int linesize[4];
+    uint8_t *data[AV_NUM_DATA_POINTERS];
+    int linesize[AV_NUM_DATA_POINTERS];
     /**
      * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
      * This isn't used by libavcodec unless the default get/release_buffer() is used.
      * - encoding:
      * - decoding:
      */
-    uint8_t *base[4];
+    uint8_t *base[AV_NUM_DATA_POINTERS];
     /**
      * 1 -> keyframe, 0-> not
      * - encoding: Set by libavcodec.
@@ -1065,7 +1070,7 @@ typedef struct AVFrame {
      * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
      * - decoding: unused
      */
-    uint64_t error[4];
+    uint64_t error[AV_NUM_DATA_POINTERS];
 
     /**
      * type of the buffer (to keep track of who has to deallocate data[*])
@@ -1319,7 +1324,7 @@ typedef struct AVCodecContext {
      * @param offset offset into the AVFrame.data from which the slice should be read
      */
     void (*draw_horiz_band)(struct AVCodecContext *s,
-                            const AVFrame *src, int offset[4],
+                            const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
                             int y, int type, int height);
 
     /* audio only */
@@ -1867,7 +1872,7 @@ typedef struct AVCodecContext {
      * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
      * - decoding: unused
      */
-    uint64_t error[4];
+    uint64_t error[AV_NUM_DATA_POINTERS];
 
     /**
      * motion estimation comparison function
@@ -3175,8 +3180,8 @@ typedef struct AVHWAccel {
  * the last component is alpha
  */
 typedef struct AVPicture {
-    uint8_t *data[4];
-    int linesize[4];       ///< number of bytes per line
+    uint8_t *data[AV_NUM_DATA_POINTERS];
+    int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
 } AVPicture;
 
 #define AVPALETTE_SIZE 1024
@@ -3794,7 +3799,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  * according to avcodec_get_edge_width() before.
  */
 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
-                               int linesize_align[4]);
+                               int linesize_align[AV_NUM_DATA_POINTERS]);
 
 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
 
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 865bc6a..57b5f32 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -921,8 +921,8 @@ static int encode_bgr_bitstream(HYuvContext *s, int count){
 
 #if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
 static void draw_slice(HYuvContext *s, int y){
-    int h, cy;
-    int offset[4];
+    int h, cy, i;
+    int offset[AV_NUM_DATA_POINTERS];
 
     if(s->avctx->draw_horiz_band==NULL)
         return;
@@ -939,7 +939,8 @@ static void draw_slice(HYuvContext *s, int y){
     offset[0] = s->picture.linesize[0]*y;
     offset[1] = s->picture.linesize[1]*cy;
     offset[2] = s->picture.linesize[2]*cy;
-    offset[3] = 0;
+    for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
+        offset[i] = 0;
     emms_c();
 
     s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h);
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index dcef706..d673f79 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2329,7 +2329,8 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
 
     if (s->avctx->draw_horiz_band) {
         AVFrame *src;
-        int offset[4];
+        int offset[AV_NUM_DATA_POINTERS];
+        int i;
 
         if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
             src= (AVFrame*)s->current_picture_ptr;
@@ -2339,15 +2340,14 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
             return;
 
         if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
-            offset[0]=
-            offset[1]=
-            offset[2]=
-            offset[3]= 0;
+            for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+                offset[i] = 0;
         }else{
             offset[0]= y * s->linesize;
             offset[1]=
             offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;
-            offset[3]= 0;
+            for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
+                offset[i] = 0;
         }
 
         emms_c();
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 53440e0..998a12c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -127,7 +127,10 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
 
 #define INTERNAL_BUFFER_SIZE (32+1)
 
-void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){
+void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
+                               int linesize_align[AV_NUM_DATA_POINTERS])
+{
+    int i;
     int w_align= 1;
     int h_align= 1;
 
@@ -209,10 +212,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
         *height+=2; // some of the optimized chroma MC reads one line too much
                     // which is also done in mpeg decoders with lowres > 0
 
-    linesize_align[0] =
-    linesize_align[1] =
-    linesize_align[2] =
-    linesize_align[3] = STRIDE_ALIGN;
+    for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
+        linesize_align[i] = STRIDE_ALIGN;
 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
 //picture size unneccessarily in some cases. The solution here is not
@@ -230,7 +231,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
 
 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
     int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;
-    int linesize_align[4];
+    int linesize_align[AV_NUM_DATA_POINTERS];
     int align;
     avcodec_align_dimensions2(s, width, height, linesize_align);
     align = FFMAX(linesize_align[0], linesize_align[3]);
@@ -275,7 +276,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
             return -1;
         }
 
-        for(i=0; i<4; i++){
+        for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
             av_freep(&buf->base[i]);
             buf->data[i]= NULL;
         }
@@ -290,7 +291,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
         int tmpsize;
         int unaligned;
         AVPicture picture;
-        int stride_align[4];
+        int stride_align[AV_NUM_DATA_POINTERS];
         const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
 
         avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
@@ -343,6 +344,10 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
             else
                 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (pixel_size*EDGE_WIDTH>>h_shift), stride_align[i]);
         }
+        for (; i < AV_NUM_DATA_POINTERS; i++) {
+            buf->base[i] = buf->data[i] = NULL;
+            buf->linesize[i] = 0;
+        }
         if(size[1] && !size[2])
             ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
         buf->width  = s->width;
@@ -352,7 +357,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
     }
     pic->type= FF_BUFFER_TYPE_INTERNAL;
 
-    for(i=0; i<4; i++){
+    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
         pic->base[i]= buf->base[i];
         pic->data[i]= buf->data[i];
         pic->linesize[i]= buf->linesize[i];
@@ -392,7 +397,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
         FFSWAP(InternalBuffer, *buf, *last);
     }
 
-    for(i=0; i<4; i++){
+    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
         pic->data[i]=NULL;
 //        pic->base[i]=NULL;
     }
@@ -426,7 +431,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
      * Not internal type and reget_buffer not overridden, emulate cr buffer
      */
     temp_pic = *pic;
-    for(i = 0; i < 4; i++)
+    for(i = 0; i < AV_NUM_DATA_POINTERS; i++)
         pic->data[i] = pic->base[i] = NULL;
     pic->opaque = NULL;
     /* Allocate new frame */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0bd1781..7262c81 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR 23
+#define LIBAVCODEC_VERSION_MINOR 24
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -110,6 +110,8 @@
 #ifndef FF_API_TIFFENC_COMPLEVEL
 #define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)
 #endif
-
+#ifndef FF_API_DATA_POINTERS
+#define FF_API_DATA_POINTERS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index a31ad4e..6e04b7b 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -1331,8 +1331,8 @@ end:
  */
 static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
 {
-    int h, cy;
-    int offset[4];
+    int h, cy, i;
+    int offset[AV_NUM_DATA_POINTERS];
 
     if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
         int y_flipped = s->flipped_image ? s->avctx->height-y : y;
@@ -1358,7 +1358,8 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
     offset[0] = s->current_frame.linesize[0]*y;
     offset[1] = s->current_frame.linesize[1]*cy;
     offset[2] = s->current_frame.linesize[2]*cy;
-    offset[3] = 0;
+    for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
+        offset[i] = 0;
 
     emms_c();
     s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);



More information about the ffmpeg-cvslog mailing list