[FFmpeg-cvslog] fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix

2022-09-15 Thread Wang Yaqiang
ffmpeg | branch: master | Wang Yaqiang  | Mon Sep  
5 18:40:36 2022 +0800| [3f0fac9303b430c5114da62f9a63ed0b945b435f] | committer: 
Steven Liu

fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix

For example, if the jpeg contains exif information
and the rotation direction is included in the exif,
the displaymatrix will be set on the side_data of the frame when decoding.
However, when ffplay is used to play the image,
only the side data in the stream will be determined.
It does not check whether the frame also contains rotation information,
causing it to play in the wrong direction

Reviewed-by: Zhao Zhili 
Signed-off-by: Wang Yaqiang 

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

 fftools/ffplay.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 9242047f5c..bcc00afe31 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -1915,8 +1915,14 @@ static int configure_video_filters(AVFilterGraph *graph, 
VideoState *is, const c
 } while (0)
 
 if (autorotate) {
-int32_t *displaymatrix = (int32_t 
*)av_stream_get_side_data(is->video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
-double theta = get_rotation(displaymatrix);
+double theta = 0.0;
+int32_t *displaymatrix = NULL;
+AVFrameSideData *sd = av_frame_get_side_data(frame, 
AV_FRAME_DATA_DISPLAYMATRIX);
+if (sd)
+displaymatrix = (int32_t *)sd->data;
+if (!displaymatrix)
+displaymatrix = (int32_t *)av_stream_get_side_data(is->video_st, 
AV_PKT_DATA_DISPLAYMATRIX, NULL);
+theta = get_rotation(displaymatrix);
 
 if (fabs(theta - 90) < 1.0) {
 INSERT_FILT("transpose", "clock");

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_drawbox: use the correct macro to fill rgb plane pointers

2022-09-15 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Sep 15 00:08:24 
2022 -0300| [0e0f74b6328498d1a7bcf6af7146774e1a22c628] | committer: James Almer

avfilter/vf_drawbox: use the correct macro to fill rgb plane pointers

Fixes ticket #9924

Reviewed-by: Paul B Mahol 
Signed-off-by: James Almer 

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

 libavfilter/vf_drawbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index 65bd039d65..64ce12 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -162,7 +162,7 @@ static void draw_region(AVFrame *frame, DrawBoxContext 
*ctx, int left, int top,
 row[2] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[2];
 
 #define ASSIGN_FOUR_CHANNELS_PACKED   \
-ASSIGN_THREE_CHANNELS \
+ASSIGN_THREE_CHANNELS_PACKED  \
 row[3] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[3];
 
 static void draw_region_rgb_packed(AVFrame *frame, DrawBoxContext *ctx, int 
left, int top, int right, int down,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avutil/lfg: fix comment typo

2022-09-15 Thread Rémi Denis-Courmont
ffmpeg | branch: master | Rémi Denis-Courmont  | Thu Sep 15 
18:05:33 2022 +0300| [a90e5335b3bf1f21b738b5bdf33de1b4fedf202d] | committer: 
Gyan Doshi

avutil/lfg: fix comment typo

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

 libavutil/lfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/lfg.h b/libavutil/lfg.h
index 2b669205d1..9a1e277acd 100644
--- a/libavutil/lfg.h
+++ b/libavutil/lfg.h
@@ -27,7 +27,7 @@
 /**
  * Context structure for the Lagged Fibonacci PRNG.
  * The exact layout, types and content of this struct may change and should
- * not be accessed directly. Only its sizeof() is guranteed to stay the same
+ * not be accessed directly. Only its sizeof() is guaranteed to stay the same
  * to allow easy instanciation.
  */
 typedef struct AVLFG {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_colorspace_cuda: mark fall-through

2022-09-15 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Thu Sep 
15 19:35:30 2022 +0200| [c9bd6ee5cb33c6462d6e74b9e39c159e1143ff65] | committer: 
Timo Rothenpieler

avfilter/vf_colorspace_cuda: mark fall-through

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

 libavfilter/vf_colorspace_cuda.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_colorspace_cuda.c b/libavfilter/vf_colorspace_cuda.c
index 131c4ad72b..07d4edd0d8 100644
--- a/libavfilter/vf_colorspace_cuda.c
+++ b/libavfilter/vf_colorspace_cuda.c
@@ -281,6 +281,7 @@ static int conv_cuda_convert(AVFilterContext* ctx, AVFrame* 
out, AVFrame* in)
 break;
 case AV_PIX_FMT_YUV420P:
 width = comp_id ? in->width / 2 : in->width;
+/* fall-through */
 case AV_PIX_FMT_NV12:
 height = comp_id ? in->height / 2 : in->height;
 break;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/adpcmenc: Round up required buffer size

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 15 17:42:25 2022 +0200| [bffc8f9af1f8e760a63cbc3680ad814b3c1b99ec] | 
committer: Andreas Rheinhardt

avcodec/adpcmenc: Round up required buffer size

Otherwise the buffer might be too small. Fixes assert violations
when encoding mono audio with exactly one sample.

Reviewed-by: Paul B Mahol 
Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/adpcmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 1ffc5b410f..57709b19a1 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -614,7 +614,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP ||
 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM ||
 avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS)
-pkt_size = (frame->nb_samples * channels) / 2;
+pkt_size = (frame->nb_samples * channels + 1) / 2;
 else
 pkt_size = avctx->block_align;
 if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/iff: Avoid redundant frees

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 19:57:07 2022 +0200| [46b586e5b262052f09dfd22d06356c875203c245] | 
committer: Andreas Rheinhardt

avcodec/iff: Avoid redundant frees

This code is only called once during init, so none of the buffers
here have been allocated already.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index d7eca289ee..d596ad4ba4 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -245,8 +245,6 @@ static int extract_header(AVCodecContext *const avctx)
 if (s->masking == MASK_HAS_MASK) {
 if (s->bpp >= 8 && !s->ham) {
 avctx->pix_fmt = AV_PIX_FMT_RGB32;
-av_freep(&s->mask_buf);
-av_freep(&s->mask_palbuf);
 if (s->bpp > 16) {
 av_log(avctx, AV_LOG_ERROR, "bpp %d too large for 
palette\n", s->bpp);
 return AVERROR(ENOMEM);
@@ -255,10 +253,8 @@ static int extract_header(AVCodecContext *const avctx)
 if (!s->mask_buf)
 return AVERROR(ENOMEM);
 s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!s->mask_palbuf) {
-av_freep(&s->mask_buf);
+if (!s->mask_palbuf)
 return AVERROR(ENOMEM);
-}
 }
 s->bpp++;
 } else if (s->masking != MASK_NONE && s->masking != 
MASK_HAS_TRANSPARENT_COLOR) {
@@ -272,9 +268,6 @@ static int extract_header(AVCodecContext *const avctx)
 if (s->video_size && s->planesize * s->bpp * avctx->height > 
s->video_size)
 return AVERROR_INVALIDDATA;
 
-av_freep(&s->ham_buf);
-av_freep(&s->ham_palbuf);
-
 if (s->ham) {
 int i, count = FFMIN(palette_size / 3, 1 << s->ham);
 int ham_count;
@@ -290,10 +283,8 @@ static int extract_header(AVCodecContext *const avctx)
 
 ham_count = 8 * (1 << s->ham);
 s->ham_palbuf = av_malloc(extra_space * (ham_count << 
!!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!s->ham_palbuf) {
-av_freep(&s->ham_buf);
+if (!s->ham_palbuf)
 return AVERROR(ENOMEM);
-}
 
 if (count) { // HAM with color palette attached
 // prefill with black and palette and set HAM take direct 
value mask to zero

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/iff: Split extract_header into extradata and packet part

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 19:03:12 2022 +0200| [f0be9129ad14ae3c94849648d3fdfccbbc3d7fc3] | 
committer: Andreas Rheinhardt

avcodec/iff: Split extract_header into extradata and packet part

183132872a1d8bc8a32e7fd8f994fa2f1b2d6bfc made the iff demuxer
output extradata and made the decoder parse said extradata.
To make this extradata extensible, it came with its own internal
length field (containing the offset of the palette at the end
of the extradata). Furthermore, in order to support mid-stream
extradata changes, the packets returned by the demuxer also have
such a length field (containing the offset of the actual packet
data). Therefore the packet parsing the extradata accepted its
input from both AVPackets as well as from ordinary extradata.

Yet the demuxer never made use of this "feature": The packet's
length field always indicated that the packet data starts
immediately after the length field.

Later, commit cb928fc448f9566e6f6c28d53fa4c2388e732a2b stopped
appending the length field to the packets' data; of course,
it also stopped searching for extradata in this data.

Instead it added code to parse the packet's header to the function
that parses extradata. This made this function consist of two disjoint
parts, one of which is only reachable if this function is called
from init (when parsing extradata) and one of which is reachable
when parsing packet headers.

Therefore this commit splits this function into two.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 116 +--
 1 file changed, 61 insertions(+), 55 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 6c0f031238..d7eca289ee 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -198,11 +198,9 @@ static int cmap_read_palette(AVCodecContext *avctx, 
uint32_t *pal)
  * decoder structures.
  *
  * @param avctx the AVCodecContext where to extract extra context to
- * @param avpkt the AVPacket to extract extra context from or NULL to use avctx
  * @return >= 0 in case of success, a negative error code otherwise
  */
-static int extract_header(AVCodecContext *const avctx,
-  const AVPacket *const avpkt)
+static int extract_header(AVCodecContext *const avctx)
 {
 IffContext *s = avctx->priv_data;
 const uint8_t *buf;
@@ -215,55 +213,6 @@ static int extract_header(AVCodecContext *const avctx,
 }
 palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
 
-if (avpkt && avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
-uint32_t chunk_id;
-uint64_t data_size;
-GetByteContext *gb = &s->gb;
-
-bytestream2_skip(gb, 4);
-while (bytestream2_get_bytes_left(gb) >= 1) {
-chunk_id  = bytestream2_get_le32(gb);
-data_size = bytestream2_get_be32(gb);
-
-if (chunk_id == MKTAG('B', 'M', 'H', 'D')) {
-bytestream2_skip(gb, data_size + (data_size & 1));
-} else if (chunk_id == MKTAG('A', 'N', 'H', 'D')) {
-unsigned extra;
-if (data_size < 40)
-return AVERROR_INVALIDDATA;
-
-s->compression = (bytestream2_get_byte(gb) << 8) | 
(s->compression & 0xFF);
-bytestream2_skip(gb, 19);
-extra = bytestream2_get_be32(gb);
-s->is_short = !(extra & 1);
-s->is_brush = extra == 2;
-s->is_interlaced = !!(extra & 0x40);
-data_size -= 24;
-bytestream2_skip(gb, data_size + (data_size & 1));
-} else if (chunk_id == MKTAG('D', 'L', 'T', 'A') ||
-   chunk_id == MKTAG('B', 'O', 'D', 'Y')) {
-if (chunk_id == MKTAG('B','O','D','Y'))
-s->compression &= 0xFF;
-break;
-} else if (chunk_id == MKTAG('C', 'M', 'A', 'P')) {
-int count = data_size / 3;
-uint32_t *pal = s->pal;
-
-if (count > 256)
-return AVERROR_INVALIDDATA;
-if (s->ham) {
-for (i = 0; i < count; i++)
-pal[i] = 0xFF00 | bytestream2_get_le24(gb);
-} else {
-for (i = 0; i < count; i++)
-pal[i] = 0xFF00 | bytestream2_get_be24(gb);
-}
-bytestream2_skip(gb, data_size & 1);
-} else {
-bytestream2_skip(gb, data_size + (data_size&1));
-}
-}
-} else if (!avpkt) {
 buf = avctx->extradata;
 buf_size = bytestream_get_be16(&buf);
 if (buf_size <= 1 || palette_size < 0) {
@@ -272,7 +221,6 @@ static int extract_header(AVCodecContext *const avctx,
buf_size, palette_size);
 return AVERRO

[FFmpeg-cvslog] avcodec/iff: Return early when possible

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 20:01:56 2022 +0200| [d0df74553bebdc33e960ea9bce9bfb323c0a1bd7] | 
committer: Andreas Rheinhardt

avcodec/iff: Return early when possible

It allows to save one level of indentation.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index d596ad4ba4..d64cb4ae62 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -222,7 +222,9 @@ static int extract_header(AVCodecContext *const avctx)
 return AVERROR_INVALIDDATA;
 }
 
-if (buf_size >= 41) {
+if (buf_size < 41)
+return 0;
+
 s->compression  = bytestream_get_byte(&buf);
 s->bpp  = bytestream_get_byte(&buf);
 s->ham  = bytestream_get_byte(&buf);
@@ -315,7 +317,6 @@ static int extract_header(AVCodecContext *const avctx)
 s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 
0xFF00;
 }
 }
-}
 
 return 0;
 }
@@ -1469,10 +1470,12 @@ static int parse_packet_header(AVCodecContext *const 
avctx,
 IffContext *s = avctx->priv_data;
 int i;
 
-if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
 uint32_t chunk_id;
 uint64_t data_size;
 
+if (avctx->codec_tag != MKTAG('A', 'N', 'I', 'M'))
+return 0;
+
 bytestream2_skip(gb, 4);
 while (bytestream2_get_bytes_left(gb) >= 1) {
 chunk_id  = bytestream2_get_le32(gb);
@@ -1516,7 +1519,6 @@ static int parse_packet_header(AVCodecContext *const 
avctx,
 bytestream2_skip(gb, data_size + (data_size&1));
 }
 }
-}
 
 return 0;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/iff: Pass extradata and extradata_size explicitly

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 20:07:11 2022 +0200| [8612b26202caddf47c9c277b75e88ac27b2fbda8] | 
committer: Andreas Rheinhardt

avcodec/iff: Pass extradata and extradata_size explicitly

This might be useful in case this decoder were changed to support
new extradata passed via side-data.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index d64cb4ae62..9371763fba 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -200,20 +200,20 @@ static int cmap_read_palette(AVCodecContext *avctx, 
uint32_t *pal)
  * @param avctx the AVCodecContext where to extract extra context to
  * @return >= 0 in case of success, a negative error code otherwise
  */
-static int extract_header(AVCodecContext *const avctx)
+static int extract_header(AVCodecContext *const avctx,
+  const uint8_t *const extradata, int extradata_size)
 {
 IffContext *s = avctx->priv_data;
-const uint8_t *buf;
+const uint8_t *buf = extradata;
 unsigned buf_size = 0;
 int i, palette_size;
 
-if (avctx->extradata_size < 2) {
+if (extradata_size < 2) {
 av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
 return AVERROR_INVALIDDATA;
 }
-palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
+palette_size = extradata_size - AV_RB16(extradata);
 
-buf = avctx->extradata;
 buf_size = bytestream_get_be16(&buf);
 if (buf_size <= 1 || palette_size < 0) {
 av_log(avctx, AV_LOG_ERROR,
@@ -273,7 +273,7 @@ static int extract_header(AVCodecContext *const avctx)
 if (s->ham) {
 int i, count = FFMIN(palette_size / 3, 1 << s->ham);
 int ham_count;
-const uint8_t *const palette = avctx->extradata + 
AV_RB16(avctx->extradata);
+const uint8_t *const palette = extradata + AV_RB16(extradata);
 int extra_space = 1;
 
 if (avctx->codec_tag == MKTAG('P', 'B', 'M', ' ') && s->ham == 4)
@@ -388,7 +388,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 return AVERROR(ENOMEM);
 }
 
-if ((err = extract_header(avctx)) < 0)
+err = extract_header(avctx, avctx->extradata, avctx->extradata_size);
+if (err < 0)
 return err;
 
 return 0;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/iff: Reindent after the previous commits

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 20:24:00 2022 +0200| [828a0c4254c89699e0ececde3f35a0e262d4fd6e] | 
committer: Andreas Rheinhardt

avcodec/iff: Reindent after the previous commits

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 260 +++
 1 file changed, 128 insertions(+), 132 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 9371763fba..33e02b543d 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -206,7 +206,7 @@ static int extract_header(AVCodecContext *const avctx,
 IffContext *s = avctx->priv_data;
 const uint8_t *buf = extradata;
 unsigned buf_size = 0;
-int i, palette_size;
+int palette_size;
 
 if (extradata_size < 2) {
 av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
@@ -214,109 +214,109 @@ static int extract_header(AVCodecContext *const avctx,
 }
 palette_size = extradata_size - AV_RB16(extradata);
 
-buf_size = bytestream_get_be16(&buf);
-if (buf_size <= 1 || palette_size < 0) {
-av_log(avctx, AV_LOG_ERROR,
-   "Invalid palette size received: %u -> palette data offset: 
%d\n",
-   buf_size, palette_size);
-return AVERROR_INVALIDDATA;
-}
+buf_size = bytestream_get_be16(&buf);
+if (buf_size <= 1 || palette_size < 0) {
+av_log(avctx, AV_LOG_ERROR,
+"Invalid palette size received: %u -> palette data offset: 
%d\n",
+buf_size, palette_size);
+return AVERROR_INVALIDDATA;
+}
 
 if (buf_size < 41)
 return 0;
 
-s->compression  = bytestream_get_byte(&buf);
-s->bpp  = bytestream_get_byte(&buf);
-s->ham  = bytestream_get_byte(&buf);
-s->flags= bytestream_get_byte(&buf);
-s->transparency = bytestream_get_be16(&buf);
-s->masking  = bytestream_get_byte(&buf);
-for (i = 0; i < 16; i++)
-s->tvdc[i] = bytestream_get_be16(&buf);
-
-if (s->ham) {
-if (s->bpp > 8) {
-av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u\n", s->ham);
-return AVERROR_INVALIDDATA;
-} else if (s->ham != (s->bpp > 6 ? 6 : 4)) {
-av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u, BPP: %u\n", s->ham, s->bpp);
-return AVERROR_INVALIDDATA;
-}
+s->compression  = bytestream_get_byte(&buf);
+s->bpp  = bytestream_get_byte(&buf);
+s->ham  = bytestream_get_byte(&buf);
+s->flags= bytestream_get_byte(&buf);
+s->transparency = bytestream_get_be16(&buf);
+s->masking  = bytestream_get_byte(&buf);
+for (int i = 0; i < 16; i++)
+s->tvdc[i] = bytestream_get_be16(&buf);
+
+if (s->ham) {
+if (s->bpp > 8) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: 
%u\n", s->ham);
+return AVERROR_INVALIDDATA;
+} else if (s->ham != (s->bpp > 6 ? 6 : 4)) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: 
%u, BPP: %u\n", s->ham, s->bpp);
+return AVERROR_INVALIDDATA;
 }
+}
 
-if (s->masking == MASK_HAS_MASK) {
-if (s->bpp >= 8 && !s->ham) {
-avctx->pix_fmt = AV_PIX_FMT_RGB32;
-if (s->bpp > 16) {
-av_log(avctx, AV_LOG_ERROR, "bpp %d too large for 
palette\n", s->bpp);
-return AVERROR(ENOMEM);
-}
-s->mask_buf = av_malloc((s->planesize * 32) + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!s->mask_buf)
-return AVERROR(ENOMEM);
-s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!s->mask_palbuf)
-return AVERROR(ENOMEM);
+if (s->masking == MASK_HAS_MASK) {
+if (s->bpp >= 8 && !s->ham) {
+avctx->pix_fmt = AV_PIX_FMT_RGB32;
+if (s->bpp > 16) {
+av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", 
s->bpp);
+return AVERROR(ENOMEM);
 }
-s->bpp++;
-} else if (s->masking != MASK_NONE && s->masking != 
MASK_HAS_TRANSPARENT_COLOR) {
-av_log(avctx, AV_LOG_ERROR, "Masking not supported\n");
-return AVERROR_PATCHWELCOME;
-}
-if (!s->bpp || s->bpp > 32) {
-av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", 
s->bpp);
-return AVERROR_INVALIDDATA;
+s->mask_buf = av_malloc((s->planesize * 32) + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!s->mask_buf)
+return AVERROR(ENOMEM);
+s->mask_palbuf = av_

[FFmpeg-cvslog] avcodec/iff: Remove transient objects from the context

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 20:29:03 2022 +0200| [487fc61cb22f7ed07626577044eda7bd2deb2366] | 
committer: Andreas Rheinhardt

avcodec/iff: Remove transient objects from the context

This avoids keeping invalid pointers in the context.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 33e02b543d..4910d2f859 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -44,7 +44,6 @@ typedef enum {
 } mask_type;
 
 typedef struct IffContext {
-AVFrame *frame;
 int planesize;
 uint8_t * planebuf;
 uint8_t * ham_buf;  ///< temporary buffer for planar to chunky 
conversation
@@ -62,7 +61,6 @@ typedef struct IffContext {
 unsigned  masking;  ///< TODO: masking method used
 int init; // 1 if buffer and palette data already initialized, 0 otherwise
 int16_t   tvdc[16]; ///< TVDC lookup table
-GetByteContext gb;
 uint8_t *video[2];
 unsigned video_size;
 uint32_t *pal;
@@ -1528,7 +1526,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 int buf_size   = avpkt->size;
 const uint8_t *buf_end = buf + buf_size;
 int y, plane, res;
-GetByteContext *gb = &s->gb;
+GetByteContext gb0, *const gb = &gb0;
 const AVPixFmtDescriptor *desc;
 
 bytestream2_init(gb, avpkt->data, avpkt->size);
@@ -1538,7 +1536,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 
 if ((res = ff_get_buffer(avctx, frame, 0)) < 0)
 return res;
-s->frame = frame;
 
 buf  += bytestream2_tell(gb);
 buf_size -= bytestream2_tell(gb);
@@ -1557,7 +1554,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 
 if (s->compression <= 0xff && (avctx->codec_tag == MKTAG('A', 'N', 'I', 
'M'))) {
 if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
-memcpy(s->pal, s->frame->data[1], 256 * 4);
+memcpy(s->pal, frame->data[1], 256 * 4);
 }
 
 switch (s->compression) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/iff: Use unsigned to avoid compiler warning

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Mon Jul 11 20:52:48 2022 +0200| [4cd1d3e3b7e7412818553ae84e04ae3e077b680f] | 
committer: Andreas Rheinhardt

avcodec/iff: Use unsigned to avoid compiler warning

GCC 12 apparently believes that negative palette sizes are
possible (they are not, as this has already been checked during
init) and therefore emits a -Wstringop-overflow= for the memcpy.
Using unsigned avoids this.
(To be honest, there might be a compiler bug involved.)

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/iff.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 4910d2f859..e02d2e77e5 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -151,9 +151,10 @@ static av_always_inline uint32_t gray2rgb(const uint32_t 
x) {
 static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
 {
 IffContext *s = avctx->priv_data;
-int count, i;
+unsigned count, i;
 const uint8_t *const palette = avctx->extradata + 
AV_RB16(avctx->extradata);
-int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
+/* extract_header() already checked that the RHS is >= 0. */
+unsigned palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
 
 if (avctx->bits_per_coded_sample > 8) {
 av_log(avctx, AV_LOG_ERROR, "bits_per_coded_sample > 8 not 
supported\n");

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/intrax8: Remove reference to inexistent parameter

2022-09-15 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 15 11:57:24 2022 +0200| [a2c6bf2314472dde268d641b19f08487af356517] | 
committer: Andreas Rheinhardt

avcodec/intrax8: Remove reference to inexistent parameter

Forgotten in eb5c5ae658aaf8cd7c03e1d0a6c84274d3a39a66.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/intrax8.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 966f1b18a0..9ef2fc3dd3 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -77,7 +77,6 @@ typedef struct IntraX8Context {
  * Initialize IntraX8 frame decoder.
  * @param avctx pointer to AVCodecContext
  * @param w pointer to IntraX8Context
- * @param idsp pointer to IDCTDSPContext
  * @param block pointer to block array
  * @param block_last_index pointer to index array
  * @param mb_width macroblock width

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavu/riscv: fix off-by-one in bit-magnitude clip

2022-09-15 Thread Rémi Denis-Courmont
ffmpeg | branch: master | Rémi Denis-Courmont  | Thu Sep 15 
21:26:48 2022 +0300| [6df3ad9687c41d17094ae5d16b4904f50338e0c4] | committer: 
James Almer

lavu/riscv: fix off-by-one in bit-magnitude clip

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

 libavutil/riscv/intmath.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h
index 3263a79dc4..45bce9a0e7 100644
--- a/libavutil/riscv/intmath.h
+++ b/libavutil/riscv/intmath.h
@@ -61,8 +61,8 @@ static av_always_inline av_const int32_t 
av_clipl_int32_rvi(int64_t a)
 #define av_clip_intp2 av_clip_intp2_rvi
 static av_always_inline av_const int av_clip_intp2_rvi(int a, int p)
 {
-const int shift = 32 - p;
-int b = (a << shift) >> shift;
+const int shift = 31 - p;
+int b = ((int)(((unsigned)a) << shift)) >> shift;
 
 if (a != b)
 b = (a >> 31) ^ ((1 << p) - 1);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".