* [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n
@ 2023-07-16 14:49 Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation Andreas Rheinhardt
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-07-16 14:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/msrleenc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index b73aa5e384..e48d11a0f7 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -234,7 +234,8 @@ static int encode(AVCodecContext *avctx, AVPacket *pkt,
}
bytestream_put_be16(&data, 0x0001); // end of bitmap
pkt->size = data - pkt->data;
- return 0;
}
+ return 0;
+}
static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
--
2.34.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
@ 2023-07-16 14:51 ` Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class Andreas Rheinhardt
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-07-16 14:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Fixes Coverity issue #1538297.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/msrleenc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index e48d11a0f7..264d57e178 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -250,6 +250,8 @@ static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (pict->data[1]) {
uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
+ if (!side_data)
+ return AVERROR(ENOMEM);
memcpy(side_data, pict->data[1], AVPALETTE_SIZE);
}
--
2.34.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation Andreas Rheinhardt
@ 2023-07-16 14:51 ` Andreas Rheinhardt
2023-07-17 11:30 ` Tomas Härdin
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/msrleenc: Check frame allocations/references Andreas Rheinhardt
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-07-16 14:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
A private class for an encoder without options is useless.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/msrleenc.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index 264d57e178..d5931f42fe 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -31,7 +31,6 @@
#include "encode.h"
typedef struct MSRLEContext {
- const AVClass *class;
int curframe;
AVFrame *last_frame;
} MSRLEContext;
@@ -282,12 +281,6 @@ static int msrle_encode_close(AVCodecContext *avctx)
return 0;
}
-static const AVClass msrle_class = {
- .class_name = "Microsoft RLE encoder",
- .item_name = av_default_item_name,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
const FFCodec ff_msrle_encoder = {
.p.name = "msrle",
CODEC_LONG_NAME("Microsoft RLE"),
@@ -301,6 +294,5 @@ const FFCodec ff_msrle_encoder = {
.p.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE
},
- .p.priv_class = &msrle_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
--
2.34.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avcodec/msrleenc: Check frame allocations/references
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class Andreas Rheinhardt
@ 2023-07-16 14:51 ` Andreas Rheinhardt
2023-07-16 15:01 ` [FFmpeg-devel] [PATCH 5/5] avcodec/msrleenc: Constify pointers for frame->data Andreas Rheinhardt
2023-07-17 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Tomas Härdin
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-07-16 14:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Also allocate the AVFrame during init and use av_frame_replace()
to replace it later.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/msrleenc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index d5931f42fe..11f7d2a319 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -37,7 +37,13 @@ typedef struct MSRLEContext {
static av_cold int msrle_encode_init(AVCodecContext *avctx)
{
+ MSRLEContext *s = avctx->priv_data;
+
avctx->bits_per_coded_sample = 8;
+ s->last_frame = av_frame_alloc();
+ if (!s->last_frame)
+ return AVERROR(ENOMEM);
+
return 0;
}
@@ -265,13 +271,7 @@ static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->curframe = 0;
*got_packet = 1;
- if (!s->last_frame)
- s->last_frame = av_frame_alloc();
- else
- av_frame_unref(s->last_frame);
-
- av_frame_ref(s->last_frame, pict);
- return 0;
+ return av_frame_replace(s->last_frame, pict);
}
static int msrle_encode_close(AVCodecContext *avctx)
--
2.34.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 5/5] avcodec/msrleenc: Constify pointers for frame->data
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
` (2 preceding siblings ...)
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/msrleenc: Check frame allocations/references Andreas Rheinhardt
@ 2023-07-16 15:01 ` Andreas Rheinhardt
2023-07-17 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Tomas Härdin
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Rheinhardt @ 2023-07-16 15:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Encoders (usually) have no business modifying frame->data
(which need not be writable), so they should use the appropriate
pointers.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/msrleenc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index 11f7d2a319..931e7af053 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -64,7 +64,8 @@ static void write_run(AVCodecContext *avctx, uint8_t **data, int len, int value)
}
}
-static void write_absolute(AVCodecContext *avctx, uint8_t **data, uint8_t *line, int len)
+static void write_absolute(AVCodecContext *avctx, uint8_t **data,
+ const uint8_t *line, int len)
{
// writing 255 would be wasteful here due to the padding requirement
while (len >= 254) {
@@ -136,7 +137,8 @@ static void write_yskip(AVCodecContext *avctx, uint8_t **data, int yskip)
}
// used both to encode lines in keyframes and to encode lines between deltas
-static void encode_line(AVCodecContext *avctx, uint8_t **data, uint8_t *line, int length)
+static void encode_line(AVCodecContext *avctx, uint8_t **data,
+ const uint8_t *line, int length)
{
int run = 0, last = -1, absstart = 0;
if (length == 0)
@@ -192,8 +194,8 @@ static int encode(AVCodecContext *avctx, AVPacket *pkt,
// compare to previous frame
int yskip = 0; // we can encode large skips using deltas
for (int y = avctx->height-1; y >= 0; y--) {
- uint8_t *line = &pict->data[0][y*pict->linesize[0]];
- uint8_t *prev = &s->last_frame->data[0][y*s->last_frame->linesize[0]];
+ const uint8_t *line = &pict->data[0][y*pict->linesize[0]];
+ const uint8_t *prev = &s->last_frame->data[0][y*s->last_frame->linesize[0]];
// we need at least 5 pixels in a row for a delta to be worthwhile
int delta = 0, linestart = 0, encoded = 0;
for (int x = 0; x < avctx->width; x++) {
--
2.34.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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class Andreas Rheinhardt
@ 2023-07-17 11:30 ` Tomas Härdin
0 siblings, 0 replies; 7+ messages in thread
From: Tomas Härdin @ 2023-07-17 11:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
sön 2023-07-16 klockan 16:51 +0200 skrev Andreas Rheinhardt:
> A private class for an encoder without options is useless.
Might be useful for explicitly using 8-bit encoding even when palette
size would permit 4-bit MSRLE. But on the other hand if anyone wants to
add 4-bit support then they can also add this stuff back in. So OK.
/Tomas
_______________________________________________
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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
` (3 preceding siblings ...)
2023-07-16 15:01 ` [FFmpeg-devel] [PATCH 5/5] avcodec/msrleenc: Constify pointers for frame->data Andreas Rheinhardt
@ 2023-07-17 11:30 ` Tomas Härdin
4 siblings, 0 replies; 7+ messages in thread
From: Tomas Härdin @ 2023-07-17 11:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
sön 2023-07-16 klockan 16:49 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/msrleenc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
> index b73aa5e384..e48d11a0f7 100644
> --- a/libavcodec/msrleenc.c
> +++ b/libavcodec/msrleenc.c
> @@ -234,7 +234,8 @@ static int encode(AVCodecContext *avctx, AVPacket
> *pkt,
> }
> bytestream_put_be16(&data, 0x0001); // end of bitmap
> pkt->size = data - pkt->data;
> - return 0;
> }
> + return 0;
> +}
Patchset looks OK
/Tomas
_______________________________________________
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] 7+ messages in thread
end of thread, other threads:[~2023-07-17 11:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-16 14:49 [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/msrleenc: Check allocation Andreas Rheinhardt
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class Andreas Rheinhardt
2023-07-17 11:30 ` Tomas Härdin
2023-07-16 14:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/msrleenc: Check frame allocations/references Andreas Rheinhardt
2023-07-16 15:01 ` [FFmpeg-devel] [PATCH 5/5] avcodec/msrleenc: Constify pointers for frame->data Andreas Rheinhardt
2023-07-17 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n Tomas Härdin
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