From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/wrapped_avframe: stop hardcoding sizeof(AVFrame)
Date: Fri, 11 Feb 2022 21:13:00 -0300
Message-ID: <20220212001301.4090-3-jamrial@gmail.com> (raw)
In-Reply-To: <20220212001301.4090-1-jamrial@gmail.com>
Use instead the new internal avpriv_avframe_size constant. This will
ensure the actual size of AVFrame from the libavutil loaded at runtime
is used instead.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/wrapped_avframe.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c
index 004bd5e0e7..543d9f85eb 100644
--- a/libavcodec/wrapped_avframe.c
+++ b/libavcodec/wrapped_avframe.c
@@ -30,6 +30,7 @@
#include "libavutil/internal.h"
#include "libavutil/frame.h"
+#include "libavutil/frame_internal.h"
#include "libavutil/buffer.h"
#include "libavutil/pixdesc.h"
@@ -44,7 +45,8 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
uint8_t *data;
- int ret, size = sizeof(*frame) + AV_INPUT_BUFFER_PADDING_SIZE;
+ const size_t size = avpriv_avframe_size;
+ int ret;
data = av_mallocz(size);
if (!data) {
@@ -53,7 +55,7 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt,
// Set frame defaults
av_frame_unref((AVFrame *)data);
- pkt->buf = av_buffer_create(data, size,
+ pkt->buf = av_buffer_create(data, size + AV_INPUT_BUFFER_PADDING_SIZE,
wrapped_avframe_release_buffer, NULL,
AV_BUFFER_FLAG_READONLY);
if (!pkt->buf) {
@@ -68,7 +70,7 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt,
}
pkt->data = data;
- pkt->size = sizeof(*frame);
+ pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -86,7 +88,7 @@ static int wrapped_avframe_decode(AVCodecContext *avctx, void *data,
return AVERROR(EPERM);
}
- if (pkt->size < sizeof(AVFrame))
+ if (pkt->size < avpriv_avframe_size)
return AVERROR(EINVAL);
in = (AVFrame*)pkt->data;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-02-12 0:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 0:12 [FFmpeg-devel] [RFC][PATCH 1/4] avutil/frame: add an internal field to store the size of AVFrame James Almer
2022-02-12 0:12 ` [FFmpeg-devel] [PATCH 2/4] avcodec/wrapped_avframe: don't allocate an AVFrame twice James Almer
2022-02-12 0:13 ` James Almer [this message]
2022-02-12 0:13 ` [FFmpeg-devel] [PATCH 4/4] avformat/vapoursynth: stop hardcoding sizeof(AVFrame) James Almer
2022-02-12 5:29 ` [FFmpeg-devel] [RFC][PATCH 1/4] avutil/frame: add an internal field to store the size of AVFrame Andreas Rheinhardt
2022-02-12 11:46 ` James Almer
2022-02-12 6:45 ` Andreas Rheinhardt
2022-02-12 11:58 ` James Almer
2022-02-12 12:08 ` Michael Niedermayer
2022-02-12 12:16 ` James Almer
2022-02-13 12:08 ` Michael Niedermayer
2022-02-12 12:25 ` Paul B Mahol
2022-02-12 12:28 ` James Almer
2022-02-12 12:32 ` Paul B Mahol
2022-02-12 12:33 ` James Almer
2022-02-12 12:38 ` Paul B Mahol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220212001301.4090-3-jamrial@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git