[FFmpeg-devel] [PATCH] Stop hardcoding align=32 in av_frame_get_buffer() calls.

Anton Khirnov anton at khirnov.net
Mon May 18 17:34:09 EEST 2020


Use 0, which selects the alignment automatically.
---
 doc/examples/encode_video.c        | 2 +-
 doc/examples/muxing.c              | 2 +-
 doc/examples/vaapi_encode.c        | 2 +-
 fftools/ffmpeg.c                   | 2 +-
 fftools/ffmpeg_videotoolbox.c      | 2 +-
 libavcodec/asvenc.c                | 2 +-
 libavcodec/encode.c                | 2 +-
 libavcodec/libwebpenc_common.c     | 2 +-
 libavcodec/mpegvideo_enc.c         | 2 +-
 libavcodec/pngenc.c                | 4 ++--
 libavcodec/tdsc.c                  | 2 +-
 libavfilter/af_compand.c           | 2 +-
 libavfilter/af_compensationdelay.c | 2 +-
 libavfilter/avf_showcqt.c          | 2 +-
 libavfilter/vf_find_rect.c         | 2 +-
 libavfilter/vf_signalstats.c       | 2 +-
 libavutil/frame.c                  | 4 ++--
 libavutil/hwcontext.c              | 2 +-
 libavutil/hwcontext_qsv.c          | 2 +-
 tests/api/api-flac-test.c          | 2 +-
 tests/api/api-threadmessage-test.c | 2 +-
 21 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/doc/examples/encode_video.c b/doc/examples/encode_video.c
index d9ab409908..908eb203d5 100644
--- a/doc/examples/encode_video.c
+++ b/doc/examples/encode_video.c
@@ -145,7 +145,7 @@ int main(int argc, char **argv)
     frame->width  = c->width;
     frame->height = c->height;
 
-    ret = av_frame_get_buffer(frame, 32);
+    ret = av_frame_get_buffer(frame, 0);
     if (ret < 0) {
         fprintf(stderr, "Could not allocate the video frame data\n");
         exit(1);
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index c1d42303af..bd16486a24 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -396,7 +396,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
     picture->height = height;
 
     /* allocate the buffers for the frame data */
-    ret = av_frame_get_buffer(picture, 32);
+    ret = av_frame_get_buffer(picture, 0);
     if (ret < 0) {
         fprintf(stderr, "Could not allocate frame data.\n");
         exit(1);
diff --git a/doc/examples/vaapi_encode.c b/doc/examples/vaapi_encode.c
index 98fd5d3b51..707939db37 100644
--- a/doc/examples/vaapi_encode.c
+++ b/doc/examples/vaapi_encode.c
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
         sw_frame->width  = width;
         sw_frame->height = height;
         sw_frame->format = AV_PIX_FMT_NV12;
-        if ((err = av_frame_get_buffer(sw_frame, 32)) < 0)
+        if ((err = av_frame_get_buffer(sw_frame, 0)) < 0)
             goto close;
         if ((err = fread((uint8_t*)(sw_frame->data[0]), size, 1, fin)) <= 0)
             break;
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f697460a30..ad95a0e417 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -182,7 +182,7 @@ static int sub2video_get_blank_frame(InputStream *ist)
     ist->sub2video.frame->width  = ist->dec_ctx->width  ? ist->dec_ctx->width  : ist->sub2video.w;
     ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
     ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
-    if ((ret = av_frame_get_buffer(frame, 32)) < 0)
+    if ((ret = av_frame_get_buffer(frame, 0)) < 0)
         return ret;
     memset(frame->data[0], 0, frame->height * frame->linesize[0]);
     return 0;
diff --git a/fftools/ffmpeg_videotoolbox.c b/fftools/ffmpeg_videotoolbox.c
index 628fb5e32c..a6b78d0f7d 100644
--- a/fftools/ffmpeg_videotoolbox.c
+++ b/fftools/ffmpeg_videotoolbox.c
@@ -67,7 +67,7 @@ static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame)
 
     vt->tmp_frame->width  = frame->width;
     vt->tmp_frame->height = frame->height;
-    ret = av_frame_get_buffer(vt->tmp_frame, 32);
+    ret = av_frame_get_buffer(vt->tmp_frame, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index 3cc94bf91a..c2c940f365 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -228,7 +228,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         clone->format = pict->format;
         clone->width  = FFALIGN(pict->width, 16);
         clone->height = FFALIGN(pict->height, 16);
-        ret = av_frame_get_buffer(clone, 32);
+        ret = av_frame_get_buffer(clone, 0);
         if (ret < 0) {
             av_frame_free(&clone);
             return ret;
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 9ed2cf0f59..03d579fd4e 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -90,7 +90,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
     frame->channel_layout = src->channel_layout;
     frame->channels       = src->channels;
     frame->nb_samples     = s->frame_size;
-    ret = av_frame_get_buffer(frame, 32);
+    ret = av_frame_get_buffer(frame, 0);
     if (ret < 0)
         goto fail;
 
diff --git a/libavcodec/libwebpenc_common.c b/libavcodec/libwebpenc_common.c
index 21d7adaf56..3c4c3e2294 100644
--- a/libavcodec/libwebpenc_common.c
+++ b/libavcodec/libwebpenc_common.c
@@ -142,7 +142,7 @@ int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s,
             alt_frame->format = frame->format;
             if (s->cr_threshold)
                 alt_frame->format = AV_PIX_FMT_YUVA420P;
-            ret = av_frame_get_buffer(alt_frame, 32);
+            ret = av_frame_get_buffer(alt_frame, 0);
             if (ret < 0)
                 goto end;
             alt_frame->format = frame->format;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 50ae57e0a6..d49185c239 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1044,7 +1044,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             s->tmp_frames[i]->width  = s->width  >> s->brd_scale;
             s->tmp_frames[i]->height = s->height >> s->brd_scale;
 
-            ret = av_frame_get_buffer(s->tmp_frames[i], 32);
+            ret = av_frame_get_buffer(s->tmp_frames[i], 0);
             if (ret < 0)
                 return ret;
         }
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index d4d8dc8b5e..aa4545ef60 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -741,7 +741,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict,
     diffFrame->format = pict->format;
     diffFrame->width = pict->width;
     diffFrame->height = pict->height;
-    if ((ret = av_frame_get_buffer(diffFrame, 32)) < 0)
+    if ((ret = av_frame_get_buffer(diffFrame, 0)) < 0)
         goto fail;
 
     original_bytestream = s->bytestream;
@@ -956,7 +956,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
                 s->prev_frame->format = pict->format;
                 s->prev_frame->width = pict->width;
                 s->prev_frame->height = pict->height;
-                if ((ret = av_frame_get_buffer(s->prev_frame, 32)) < 0)
+                if ((ret = av_frame_get_buffer(s->prev_frame, 0)) < 0)
                     return ret;
             }
 
diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index e9ea41ef55..eaea41c1f5 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -484,7 +484,7 @@ static int tdsc_parse_tdsf(AVCodecContext *avctx, int number_tiles)
 
     /* Allocate the reference frame if not already done or on size change */
     if (init_refframe) {
-        ret = av_frame_get_buffer(ctx->refframe, 32);
+        ret = av_frame_get_buffer(ctx->refframe, 0);
         if (ret < 0)
             return ret;
     }
diff --git a/libavfilter/af_compand.c b/libavfilter/af_compand.c
index d4a816d135..1e75be4f41 100644
--- a/libavfilter/af_compand.c
+++ b/libavfilter/af_compand.c
@@ -535,7 +535,7 @@ static int config_output(AVFilterLink *outlink)
     s->delay_frame->nb_samples     = s->delay_samples;
     s->delay_frame->channel_layout = outlink->channel_layout;
 
-    err = av_frame_get_buffer(s->delay_frame, 32);
+    err = av_frame_get_buffer(s->delay_frame, 0);
     if (err)
         return err;
 
diff --git a/libavfilter/af_compensationdelay.c b/libavfilter/af_compensationdelay.c
index 05285cd297..793332584b 100644
--- a/libavfilter/af_compensationdelay.c
+++ b/libavfilter/af_compensationdelay.c
@@ -115,7 +115,7 @@ static int config_input(AVFilterLink *inlink)
     s->delay_frame->nb_samples     = new_size;
     s->delay_frame->channel_layout = inlink->channel_layout;
 
-    return av_frame_get_buffer(s->delay_frame, 32);
+    return av_frame_get_buffer(s->delay_frame, 0);
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index cf8a102b80..cb0dca505f 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -365,7 +365,7 @@ static AVFrame *alloc_frame_empty(enum AVPixelFormat format, int w, int h)
     out->format = format;
     out->width = w;
     out->height = h;
-    if (av_frame_get_buffer(out, 32) < 0) {
+    if (av_frame_get_buffer(out, 0) < 0) {
         av_frame_free(&out);
         return NULL;
     }
diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index 706e59cefe..b5f8fbcba6 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -80,7 +80,7 @@ static AVFrame *downscale(AVFrame *in)
     frame->width  = (in->width + 1) / 2;
     frame->height = (in->height+ 1) / 2;
 
-    if (av_frame_get_buffer(frame, 32) < 0) {
+    if (av_frame_get_buffer(frame, 0) < 0) {
         av_frame_free(&frame);
         return NULL;
     }
diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 1ccc16dd38..1331327bb3 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -150,7 +150,7 @@ static AVFrame *alloc_frame(enum AVPixelFormat pixfmt, int w, int h)
     frame->width  = w;
     frame->height = h;
 
-    if (av_frame_get_buffer(frame, 32) < 0) {
+    if (av_frame_get_buffer(frame, 0) < 0) {
         av_frame_free(&frame);
         return NULL;
     }
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 53581e4862..2e952edd29 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -461,7 +461,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
 
     /* duplicate the frame data if it's not refcounted */
     if (!src->buf[0]) {
-        ret = av_frame_get_buffer(dst, 32);
+        ret = av_frame_get_buffer(dst, 0);
         if (ret < 0)
             return ret;
 
@@ -631,7 +631,7 @@ int av_frame_make_writable(AVFrame *frame)
     if (frame->hw_frames_ctx)
         ret = av_hwframe_get_buffer(frame->hw_frames_ctx, &tmp, 0);
     else
-        ret = av_frame_get_buffer(&tmp, 32);
+        ret = av_frame_get_buffer(&tmp, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index b01612de05..8cc91d9a28 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -422,7 +422,7 @@ static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
     frame_tmp->width  = ctx->width;
     frame_tmp->height = ctx->height;
 
-    ret = av_frame_get_buffer(frame_tmp, 32);
+    ret = av_frame_get_buffer(frame_tmp, 0);
     if (ret < 0)
         goto fail;
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 4306c6e3b9..40794558fb 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -922,7 +922,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
         tmp_frame.format         = src->format;
         tmp_frame.width          = FFALIGN(src->width, 16);
         tmp_frame.height         = FFALIGN(src->height, 16);
-        ret = av_frame_get_buffer(&tmp_frame, 32);
+        ret = av_frame_get_buffer(&tmp_frame, 0);
         if (ret < 0)
             return ret;
 
diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index e8e8cbf1e7..ae6a9316d8 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -126,7 +126,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
     in_frame->nb_samples = enc_ctx->frame_size;
     in_frame->format = enc_ctx->sample_fmt;
     in_frame->channel_layout = enc_ctx->channel_layout;
-    if (av_frame_get_buffer(in_frame, 32) != 0) {
+    if (av_frame_get_buffer(in_frame, 0) != 0) {
         av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n");
         return AVERROR(ENOMEM);
     }
diff --git a/tests/api/api-threadmessage-test.c b/tests/api/api-threadmessage-test.c
index 3c693a70d1..b6a74f678b 100644
--- a/tests/api/api-threadmessage-test.c
+++ b/tests/api/api-threadmessage-test.c
@@ -101,7 +101,7 @@ static void *sender_thread(void *arg)
             msg.frame->format = AV_PIX_FMT_RGBA;
             msg.frame->width  = 320;
             msg.frame->height = 240;
-            ret = av_frame_get_buffer(msg.frame, 32);
+            ret = av_frame_get_buffer(msg.frame, 0);
             if (ret < 0) {
                 av_frame_free(&msg.frame);
                 break;
-- 
2.25.1



More information about the ffmpeg-devel mailing list