Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage
@ 2022-06-10 23:10 Michael Niedermayer
  2022-06-10 23:10 ` [FFmpeg-devel] [PATCH 2/3] avcodec/fmvc: buffer size is stride based not 4*width Michael Niedermayer
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Michael Niedermayer @ 2022-06-10 23:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

This way more things are checked before allocation

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/fmvc.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 4abf6d7048..912ad8fc82 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -401,20 +401,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     GetByteContext *gb = &s->gb;
     PutByteContext *pb = &s->pb;
     int ret, y, x;
+    int key_frame;
 
     if (avpkt->size < 8)
         return AVERROR_INVALIDDATA;
 
-    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-        return ret;
-
     bytestream2_init(gb, avpkt->data, avpkt->size);
     bytestream2_skip(gb, 2);
 
-    frame->key_frame = !!bytestream2_get_le16(gb);
-    frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
+    key_frame = !!bytestream2_get_le16(gb);
 
-    if (frame->key_frame) {
+    if (key_frame) {
         const uint8_t *src;
         unsigned type, size;
         uint8_t *dst;
@@ -434,6 +431,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             return AVERROR_PATCHWELCOME;
         }
 
+        if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+            return ret;
+
+        frame->key_frame = 1;
+        frame->pict_type = AV_PICTURE_TYPE_I;
+
         src = s->buffer;
         dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
         for (y = 0; y < avctx->height; y++) {
@@ -514,6 +517,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
             dst = &rect[block_h * s->stride];
         }
 
+        if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+            return ret;
+
+        frame->key_frame = 0;
+        frame->pict_type = AV_PICTURE_TYPE_P;
+
         ssrc = s->buffer;
         ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
         for (y = 0; y < avctx->height; y++) {
-- 
2.17.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".

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-09-08 20:54 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 23:10 [FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage Michael Niedermayer
2022-06-10 23:10 ` [FFmpeg-devel] [PATCH 2/3] avcodec/fmvc: buffer size is stride based not 4*width Michael Niedermayer
2022-06-11  8:47   ` Paul B Mahol
2022-06-11 14:55     ` Michael Niedermayer
2022-06-13  8:04       ` Paul B Mahol
2022-06-13  9:10         ` Anton Khirnov
2022-06-13  9:34           ` Paul B Mahol
2022-06-13  9:47             ` Anton Khirnov
2022-06-13 10:10               ` Paul B Mahol
2022-06-13 19:13                 ` Michael Niedermayer
2022-09-02 16:31                   ` Michael Niedermayer
2022-09-02 16:48                     ` Paul B Mahol
2022-09-04 21:42                       ` Michael Niedermayer
2022-09-08 20:54                         ` Michael Niedermayer
2022-06-10 23:10 ` [FFmpeg-devel] [PATCH 3/3] avcodec/fmvc: Require key frames to fill a non trivial part of the buffer Michael Niedermayer
2022-09-08 20:52 ` [FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage Michael Niedermayer

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