[FFmpeg-cvslog] avcodec/asv: Split ASV1Context into decoder and encoder contexts
ffmpeg | branch: master | Andreas Rheinhardt | Sat Oct 1 17:05:45 2022 +0200| [8a9eac7e42f3bec34dadc4299446a9a9c9304231] | committer: Andreas Rheinhardt avcodec/asv: Split ASV1Context into decoder and encoder contexts A lot of the stuff in ASV1Context is actually only used by decoders or encoders, but not both: Of the seven contexts in ASV1Context, only the BswapDSPContext is used by both. So splitting makes sense. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a9eac7e42f3bec34dadc4299446a9a9c9304231 --- libavcodec/asv.c| 4 ++- libavcodec/asv.h| 25 ++ libavcodec/asvdec.c | 73 + libavcodec/asvenc.c | 69 ++ 4 files changed, 93 insertions(+), 78 deletions(-) diff --git a/libavcodec/asv.c b/libavcodec/asv.c index dcae90982a..3aa08c30c0 100644 --- a/libavcodec/asv.c +++ b/libavcodec/asv.c @@ -25,6 +25,8 @@ #include +#include "libavutil/attributes.h" + #include "asv.h" #include "avcodec.h" #include "bswapdsp.h" @@ -88,7 +90,7 @@ const uint16_t ff_asv2_level_tab[63][2] = { av_cold void ff_asv_common_init(AVCodecContext *avctx) { -ASV1Context *const a = avctx->priv_data; +ASVCommonContext *const a = avctx->priv_data; ff_bswapdsp_init(&a->bbdsp); diff --git a/libavcodec/asv.h b/libavcodec/asv.h index 269bbe7c18..7c0983a497 100644 --- a/libavcodec/asv.h +++ b/libavcodec/asv.h @@ -28,38 +28,17 @@ #include -#include "libavutil/mem_internal.h" - #include "avcodec.h" -#include "blockdsp.h" #include "bswapdsp.h" -#include "fdctdsp.h" -#include "idctdsp.h" -#include "get_bits.h" -#include "pixblockdsp.h" -#include "put_bits.h" -typedef struct ASV1Context { +typedef struct ASVCommonContext { AVCodecContext *avctx; -BlockDSPContext bdsp; BswapDSPContext bbdsp; -FDCTDSPContext fdsp; -IDCTDSPContext idsp; -PixblockDSPContext pdsp; -PutBitContext pb; -GetBitContext gb; -ScanTable scantable; -int inv_qscale; int mb_width; int mb_height; int mb_width2; int mb_height2; -DECLARE_ALIGNED(32, int16_t, block)[6][64]; -uint16_t intra_matrix[64]; -int q_intra_matrix[64]; -uint8_t *bitstream_buffer; -unsigned int bitstream_buffer_size; -} ASV1Context; +} ASVCommonContext; extern const uint8_t ff_asv_scantab[64]; extern const uint8_t ff_asv_ccp_tab[17][2]; diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 4ca370d1ec..7dafc115b3 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -25,6 +25,7 @@ #include "libavutil/attributes.h" #include "libavutil/mem.h" +#include "libavutil/mem_internal.h" #include "libavutil/thread.h" #include "asv.h" @@ -33,8 +34,10 @@ #include "codec_internal.h" #include "config_components.h" #include "decode.h" +#include "get_bits.h" #include "idctdsp.h" #include "mpeg12data.h" +#include "vlc.h" #define CCP_VLC_BITS 5 #define DC_CCP_VLC_BITS 4 @@ -48,6 +51,20 @@ static VLC dc_ccp_vlc; static VLC ac_ccp_vlc; static VLC asv2_level_vlc; +typedef struct ASVDecContext { +ASVCommonContext c; + +GetBitContext gb; + +BlockDSPContext bdsp; +IDCTDSPContext idsp; +ScanTable scantable; +DECLARE_ALIGNED(32, int16_t, block)[6][64]; +uint16_t intra_matrix[64]; +uint8_t *bitstream_buffer; +unsigned int bitstream_buffer_size; +} ASVDecContext; + static av_cold void init_vlcs(void) { INIT_VLC_STATIC(&ccp_vlc, CCP_VLC_BITS, 17, @@ -106,7 +123,7 @@ static inline int asv2_get_level(GetBitContext *gb) return code - 31; } -static inline int asv1_decode_block(ASV1Context *a, int16_t block[64]) +static inline int asv1_decode_block(ASVDecContext *a, int16_t block[64]) { int i; @@ -119,7 +136,7 @@ static inline int asv1_decode_block(ASV1Context *a, int16_t block[64]) if (ccp == 16) break; if (ccp < 0 || i >= 10) { -av_log(a->avctx, AV_LOG_ERROR, "coded coeff pattern damaged\n"); +av_log(a->c.avctx, AV_LOG_ERROR, "coded coeff pattern damaged\n"); return AVERROR_INVALIDDATA; } @@ -137,7 +154,7 @@ static inline int asv1_decode_block(ASV1Context *a, int16_t block[64]) return 0; } -static inline int asv2_decode_block(ASV1Context *a, int16_t block[64]) +static inline int asv2_decode_block(ASVDecContext *a, int16_t block[64]) { int i, count, ccp; @@ -173,13 +190,13 @@ static inline int asv2_decode_block(ASV1Context *a, int16_t block[64]) return 0; } -static inline int decode_mb(ASV1Context *a, int16_t block[6][64]) +static inline int decode_mb(ASVDecContext *a, int16_t block[6][64]) { int i, ret; a->bdsp.clear_blocks(block[0]); -if (a->avctx->codec_id == AV_CODEC_ID_ASV1) { +if (a->c.avctx->codec_id == AV_CODEC_ID_ASV1) { for (i = 0; i < 6; i++) {
[FFmpeg-cvslog] avcodec/sgidec: Support negative linesizes
ffmpeg | branch: master | Andreas Rheinhardt | Thu Sep 29 14:21:36 2022 +0200| [54cf0482bd4d58ccb5c913cf1e68468d759d74ca] | committer: Andreas Rheinhardt avcodec/sgidec: Support negative linesizes The earlier code used "p->data[0] + p->linesize[0] * s->height" with the latter being unsigned, which gives the wrong value for negative linesizes. There is also a not so obvious problem with this: In case of negative linesizes, the last line is the start of the allocated buffer, so using the line after the last line would involve undefined pointer arithmetic. So don't do it. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54cf0482bd4d58ccb5c913cf1e68468d759d74ca --- libavcodec/sgidec.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index dd3dc46b48..a449859bf8 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -28,7 +28,7 @@ typedef struct SgiState { AVCodecContext *avctx; unsigned int width; -unsigned int height; +int height; unsigned int depth; unsigned int bytes_per_channel; int linesize; @@ -127,12 +127,11 @@ static int expand_rle_row16(SgiState *s, uint16_t *out_buf, * @param s the current image state * @return 0 if no error, else return error code. */ -static int read_rle_sgi(uint8_t *out_buf, SgiState *s) +static int read_rle_sgi(uint8_t *last_line, SgiState *s) { uint8_t *dest_row; unsigned int len = s->height * s->depth * 4; GetByteContext g_table = s->g; -unsigned int y, z; unsigned int start_offset; int linesize, ret; @@ -141,11 +140,10 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s) return AVERROR_INVALIDDATA; } -for (z = 0; z < s->depth; z++) { -dest_row = out_buf; -for (y = 0; y < s->height; y++) { +for (unsigned z = 0; z < s->depth; z++) { +dest_row = last_line; +for (int remaining_lines = s->height;;) { linesize = s->width * s->depth; -dest_row -= s->linesize; start_offset = bytestream2_get_be32(&g_table); bytestream2_seek(&s->g, start_offset, SEEK_SET); if (s->bytes_per_channel == 1) @@ -154,6 +152,9 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s) ret = expand_rle_row16(s, (uint16_t *)dest_row + z, linesize, s->depth); if (ret != s->width) return AVERROR_INVALIDDATA; +if (--remaining_lines == 0) +break; +dest_row -= s->linesize; } } return 0; @@ -204,7 +205,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, SgiState *s = avctx->priv_data; unsigned int dimension, rle; int ret = 0; -uint8_t *out_buf, *out_end; +uint8_t *out_buf, *last_line; bytestream2_init(&s->g, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(&s->g) < SGI_HEADER_SIZE) { @@ -258,14 +259,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, p->key_frame = 1; out_buf = p->data[0]; -out_end = out_buf + p->linesize[0] * s->height; +last_line = out_buf + p->linesize[0] * (s->height - 1); s->linesize = p->linesize[0]; /* Skip header. */ bytestream2_seek(&s->g, SGI_HEADER_SIZE, SEEK_SET); if (rle) { -ret = read_rle_sgi(out_end, s); +ret = read_rle_sgi(last_line, s); } else { ret = read_uncompressed_sgi(out_buf, s); } ___ 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/sunrast: Use ptrdiff_t for stride
ffmpeg | branch: master | Andreas Rheinhardt | Thu Sep 29 13:18:54 2022 +0200| [02c19dfb8552cb40b02ff9c8d8d3c5e12d5c71e1] | committer: Andreas Rheinhardt avcodec/sunrast: Use ptrdiff_t for stride Fixes segfaults with negative linesizes; in particular, this affected the sunraster-(1|8|24)bit-(raw|rle) and sunraster-8bit_gray-raw FATE tests. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02c19dfb8552cb40b02ff9c8d8d3c5e12d5c71e1 --- libavcodec/sunrast.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index 77feef06e1..45b29e4d72 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -31,7 +31,8 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; -unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen; +unsigned int w, h, depth, type, maptype, maplength, x, y, len, alen; +ptrdiff_t stride; uint8_t *ptr, *ptr2 = NULL; const uint8_t *bufstart = buf; int ret; @@ -141,7 +142,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, if (type == RT_BYTE_ENCODED) { int value, run; -uint8_t *end = ptr + h * stride; +uint8_t *end = ptr + (ptrdiff_t)h * stride; x = 0; while (ptr != end && buf < buf_end) { ___ 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/sgidec: Use planar pixel formats
ffmpeg | branch: master | Andreas Rheinhardt | Thu Sep 29 19:44:05 2022 +0200| [ce4713ea731b9deb0440abe8d8a2a41d2957efc5] | committer: Andreas Rheinhardt avcodec/sgidec: Use planar pixel formats The data in SGI images is stored planar, so exporting it via planar pixel formats is natural. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce4713ea731b9deb0440abe8d8a2a41d2957efc5 --- libavcodec/sgidec.c | 123 -- tests/ref/fate/sgi-rgb24 | 2 +- tests/ref/fate/sgi-rgb24-rle | 2 +- tests/ref/fate/sgi-rgb48 | 2 +- tests/ref/fate/sgi-rgb48-rle | 2 +- tests/ref/fate/sgi-rgba | 2 +- tests/ref/fate/sgi-rgba-rle | 2 +- tests/ref/fate/sgi-rgba64 | 2 +- tests/ref/fate/sgi-rgba64-rle | 2 +- tests/ref/lavf/sgi| 2 +- 10 files changed, 66 insertions(+), 75 deletions(-) diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index bd49a3510d..6ff2ee97f6 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -30,17 +30,15 @@ * @param logctx a logcontext * @param out_buf Points to one line after the output buffer. * @param g GetByteContext used to read input from - * @param len length of out_buf in bytes - * @param pixelstride pixel stride of input buffer - * @return size of output in bytes, else return error code. + * @param width length of out_buf in nb of elements + * @return nb of elements written, else return error code. */ static int expand_rle_row8(void *logctx, uint8_t *out_buf, - GetByteContext *g, - int len, int pixelstride) + GetByteContext *g, unsigned width) { unsigned char pixel, count; unsigned char *orig = out_buf; -uint8_t *out_end = out_buf + len; +uint8_t *out_end = out_buf + width; while (out_buf < out_end) { if (bytestream2_get_bytes_left(g) < 1) @@ -51,36 +49,31 @@ static int expand_rle_row8(void *logctx, uint8_t *out_buf, } /* Check for buffer overflow. */ -if (out_end - out_buf <= pixelstride * (count - 1)) { +if (out_end - out_buf < count) { av_log(logctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } if (pixel & 0x80) { -while (count--) { -*out_buf = bytestream2_get_byte(g); -out_buf += pixelstride; -} +while (count--) +*out_buf++ = bytestream2_get_byte(g); } else { pixel = bytestream2_get_byte(g); -while (count--) { -*out_buf = pixel; -out_buf += pixelstride; -} +while (count--) +*out_buf++ = pixel; } } -return (out_buf - orig) / pixelstride; +return out_buf - orig; } static int expand_rle_row16(void *logctx, uint16_t *out_buf, -GetByteContext *g, -int len, int pixelstride) +GetByteContext *g, unsigned width) { unsigned short pixel; unsigned char count; unsigned short *orig = out_buf; -uint16_t *out_end = out_buf + len; +uint16_t *out_end = out_buf + width; while (out_buf < out_end) { if (bytestream2_get_bytes_left(g) < 2) @@ -90,7 +83,7 @@ static int expand_rle_row16(void *logctx, uint16_t *out_buf, break; /* Check for buffer overflow. */ -if (out_end - out_buf <= pixelstride * (count - 1)) { +if (out_end - out_buf < count) { av_log(logctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } @@ -99,18 +92,18 @@ static int expand_rle_row16(void *logctx, uint16_t *out_buf, while (count--) { pixel = bytestream2_get_ne16(g); AV_WN16A(out_buf, pixel); -out_buf += pixelstride; +out_buf++; } } else { pixel = bytestream2_get_ne16(g); while (count--) { AV_WN16A(out_buf, pixel); -out_buf += pixelstride; +out_buf++; } } } -return (out_buf - orig) / pixelstride; +return out_buf - orig; } @@ -120,15 +113,14 @@ static int expand_rle_row16(void *logctx, uint16_t *out_buf, * @param s the current image state * @return 0 if no error, else return error code. */ -static int read_rle_sgi(void *logctx, uint8_t *last_line, GetByteContext *g, -ptrdiff_t stride, unsigned width, unsigned height, +static int read_rle_sgi(void *logctx, uint8_t *out[4], ptrdiff_t stride[4], +GetByteContext *g, unsigned width, int height, unsigned nb_components, unsigned bytes_per_channel) { -uint8_t *dest_row; unsign
[FFmpeg-cvslog] avcodec/sgidec: Avoid redundant private context
ffmpeg | branch: master | Andreas Rheinhardt | Thu Sep 29 16:05:49 2022 +0200| [e771223ec1be32da96e72d8319a8677aa9776204] | committer: Andreas Rheinhardt avcodec/sgidec: Avoid redundant private context SGI is intra-frame only; the decoder therefore does not maintain any state between frames, so remove the private context. Also rename depth to nb_components. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e771223ec1be32da96e72d8319a8677aa9776204 --- libavcodec/sgidec.c | 158 1 file changed, 73 insertions(+), 85 deletions(-) diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index a449859bf8..bd49a3510d 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -25,25 +25,17 @@ #include "decode.h" #include "sgi.h" -typedef struct SgiState { -AVCodecContext *avctx; -unsigned int width; -int height; -unsigned int depth; -unsigned int bytes_per_channel; -int linesize; -GetByteContext g; -} SgiState; - /** * Expand an RLE row into a channel. - * @param s the current image state + * @param logctx a logcontext * @param out_buf Points to one line after the output buffer. + * @param g GetByteContext used to read input from * @param len length of out_buf in bytes * @param pixelstride pixel stride of input buffer * @return size of output in bytes, else return error code. */ -static int expand_rle_row8(SgiState *s, uint8_t *out_buf, +static int expand_rle_row8(void *logctx, uint8_t *out_buf, + GetByteContext *g, int len, int pixelstride) { unsigned char pixel, count; @@ -51,26 +43,26 @@ static int expand_rle_row8(SgiState *s, uint8_t *out_buf, uint8_t *out_end = out_buf + len; while (out_buf < out_end) { -if (bytestream2_get_bytes_left(&s->g) < 1) +if (bytestream2_get_bytes_left(g) < 1) return AVERROR_INVALIDDATA; -pixel = bytestream2_get_byteu(&s->g); +pixel = bytestream2_get_byteu(g); if (!(count = (pixel & 0x7f))) { break; } /* Check for buffer overflow. */ if (out_end - out_buf <= pixelstride * (count - 1)) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n"); +av_log(logctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } if (pixel & 0x80) { while (count--) { -*out_buf = bytestream2_get_byte(&s->g); +*out_buf = bytestream2_get_byte(g); out_buf += pixelstride; } } else { -pixel = bytestream2_get_byte(&s->g); +pixel = bytestream2_get_byte(g); while (count--) { *out_buf = pixel; @@ -81,7 +73,8 @@ static int expand_rle_row8(SgiState *s, uint8_t *out_buf, return (out_buf - orig) / pixelstride; } -static int expand_rle_row16(SgiState *s, uint16_t *out_buf, +static int expand_rle_row16(void *logctx, uint16_t *out_buf, +GetByteContext *g, int len, int pixelstride) { unsigned short pixel; @@ -90,26 +83,26 @@ static int expand_rle_row16(SgiState *s, uint16_t *out_buf, uint16_t *out_end = out_buf + len; while (out_buf < out_end) { -if (bytestream2_get_bytes_left(&s->g) < 2) +if (bytestream2_get_bytes_left(g) < 2) return AVERROR_INVALIDDATA; -pixel = bytestream2_get_be16u(&s->g); +pixel = bytestream2_get_be16u(g); if (!(count = (pixel & 0x7f))) break; /* Check for buffer overflow. */ if (out_end - out_buf <= pixelstride * (count - 1)) { -av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n"); +av_log(logctx, AV_LOG_ERROR, "Invalid pixel count.\n"); return AVERROR_INVALIDDATA; } if (pixel & 0x80) { while (count--) { -pixel = bytestream2_get_ne16(&s->g); +pixel = bytestream2_get_ne16(g); AV_WN16A(out_buf, pixel); out_buf += pixelstride; } } else { -pixel = bytestream2_get_ne16(&s->g); +pixel = bytestream2_get_ne16(g); while (count--) { AV_WN16A(out_buf, pixel); @@ -127,34 +120,38 @@ static int expand_rle_row16(SgiState *s, uint16_t *out_buf, * @param s the current image state * @return 0 if no error, else return error code. */ -static int read_rle_sgi(uint8_t *last_line, SgiState *s) +static int read_rle_sgi(void *logctx, uint8_t *last_line, GetByteContext *g, +ptrdiff_t stride, unsigned width, unsigned height, +unsigned nb_components, unsigned bytes_per_channel) { uint8_t *dest_row; -unsigned int len = s->he
[FFmpeg-cvslog] avcodec/fraps: Fix segfault with negative linesizes
ffmpeg | branch: master | Andreas Rheinhardt | Fri Sep 30 18:32:33 2022 +0200| [451b310d4f0ba5a38c3f67ec2ce39bcb62fcf59b] | committer: Andreas Rheinhardt avcodec/fraps: Fix segfault with negative linesizes Using unsigned and negative linesizes doesn't really work. Use ptrdiff_t instead. This fixes the fraps-v0 and fraps-v1 FATE tests with negative linesizes. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=451b310d4f0ba5a38c3f67ec2ce39bcb62fcf59b --- libavcodec/fraps.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 9c8cbf7323..4c4c46b602 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -141,7 +141,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, int buf_size = avpkt->size; uint32_t header; unsigned int version,header_size; -unsigned int x, y; const uint32_t *buf32; uint32_t *luma1,*luma2,*cb,*cr; uint32_t offs[4]; @@ -238,12 +237,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, } buf32 = (const uint32_t*)buf; -for (y = 0; y < avctx->height / 2; y++) { +for (ptrdiff_t y = 0; y < avctx->height / 2; y++) { luma1 = (uint32_t*)&f->data[0][ y * 2 * f->linesize[0] ]; luma2 = (uint32_t*)&f->data[0][ (y * 2 + 1) * f->linesize[0] ]; cr= (uint32_t*)&f->data[1][ y * f->linesize[1] ]; cb= (uint32_t*)&f->data[2][ y * f->linesize[2] ]; -for (x = 0; x < avctx->width; x += 8) { +for (ptrdiff_t x = 0; x < avctx->width; x += 8) { *luma1++ = *buf32++; *luma1++ = *buf32++; *luma2++ = *buf32++; @@ -258,18 +257,18 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, if (is_pal) { uint32_t *pal = (uint32_t *)f->data[1]; -for (y = 0; y < 256; y++) { +for (unsigned y = 0; y < 256; y++) { pal[y] = AV_RL32(buf) | 0xFF00; buf += 4; } -for (y = 0; y height; y++) +for (ptrdiff_t y = 0; y < avctx->height; y++) memcpy(&f->data[0][y * f->linesize[0]], &buf[y * avctx->width], avctx->width); } else { /* Fraps v1 is an upside-down BGR24 */ -for (y = 0; yheight; y++) +for (ptrdiff_t y = 0; y < avctx->height; y++) memcpy(&f->data[0][(avctx->height - y - 1) * f->linesize[0]], &buf[y * avctx->width * 3], 3 * avctx->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] avcodec/c93: Fix segfault when using negative linesizes
ffmpeg | branch: master | Andreas Rheinhardt | Fri Sep 30 18:12:46 2022 +0200| [fced3a17dbdade0635fe900ad0b748c5278c01a2] | committer: Andreas Rheinhardt avcodec/c93: Fix segfault when using negative linesizes c93.c used an int for the stride and an unsigned for the current linenumber. This does not work when using negative linesizes. So use ptrdiff_t for stride and int for linenumber. This fixes the cyberia-c93 FATE test when using negative linesizes. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fced3a17dbdade0635fe900ad0b748c5278c01a2 --- libavcodec/c93.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 66b551a5d6..bfcbc7c150 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -130,7 +130,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, AVFrame * const oldpic = c93->pictures[c93->currentpic^1]; GetByteContext gb; uint8_t *out; -int stride, ret, i, x, y, b, bt = 0; +int ret, i, x, y, b, bt = 0; +ptrdiff_t stride; if ((ret = ff_set_dimensions(avctx, WIDTH, HEIGHT)) < 0) return ret; @@ -156,7 +157,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, out = newpic->data[0] + y * stride; for (x = 0; x < WIDTH; x += 8) { uint8_t *copy_from = oldpic->data[0]; -unsigned int offset, j; uint8_t cols[4], grps[4]; C93BlockType block_type; @@ -165,16 +165,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, block_type= bt & 0x0F; switch (block_type) { -case C93_8X8_FROM_PREV: -offset = bytestream2_get_le16(&gb); +case C93_8X8_FROM_PREV: { +int offset = bytestream2_get_le16(&gb); if ((ret = copy_block(avctx, out, copy_from, offset, 8, stride)) < 0) return ret; break; +} case C93_4X4_FROM_CURR: copy_from = newpic->data[0]; case C93_4X4_FROM_PREV: -for (j = 0; j < 8; j += 4) { +for (int j = 0; j < 8; j += 4) { for (i = 0; i < 8; i += 4) { int offset = bytestream2_get_le16(&gb); int from_x = offset % WIDTH; @@ -203,7 +204,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, case C93_4X4_2COLOR: case C93_4X4_4COLOR: case C93_4X4_4COLOR_GRP: -for (j = 0; j < 8; j += 4) { +for (int j = 0; j < 8; j += 4) { for (i = 0; i < 8; i += 4) { if (block_type == C93_4X4_2COLOR) { bytestream2_get_buffer(&gb, cols, 2); @@ -226,7 +227,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, break; case C93_8X8_INTRA: -for (j = 0; j < 8; j++) +for (int j = 0; j < 8; j++) bytestream2_get_buffer(&gb, out + j*stride, 8); 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/escape124: Fix segfault with negative linesizes
ffmpeg | branch: master | Andreas Rheinhardt | Fri Sep 30 18:25:04 2022 +0200| [fcfa6965e5e398a850d87a276b0deb5dc5d1525e] | committer: Andreas Rheinhardt avcodec/escape124: Fix segfault with negative linesizes Use ptrdiff_t instead of unsigned for linesizes. Fixes the armovie-escape124 FATE test with negative linesizes. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fcfa6965e5e398a850d87a276b0deb5dc5d1525e --- libavcodec/escape124.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index eeeb9bb0f7..024eec59ce 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -178,8 +178,8 @@ static void insert_mb_into_sb(SuperBlock* sb, MacroBlock mb, unsigned index) { dst[4] = mb.pixels32[1]; } -static void copy_superblock(uint16_t* dest, unsigned dest_stride, -uint16_t* src, unsigned src_stride) +static void copy_superblock(uint16_t* dest, ptrdiff_t dest_stride, +uint16_t* src, ptrdiff_t src_stride) { unsigned y; if (src) @@ -211,7 +211,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, superblocks_per_row = avctx->width / 8, skip = -1; uint16_t* old_frame_data, *new_frame_data; -unsigned old_stride, new_stride; +ptrdiff_t old_stride, new_stride; int ret; ___ 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/audiotoolboxenc: return AVERROR_EXTERNAL immediately when encode error
ffmpeg | branch: release/5.1 | Steven Liu | Wed Jun 29 00:14:08 2022 +0800| [79bd6a21a04c7c457bfeb53fddc157bbd80cdaac] | committer: Steven Liu avcodec/audiotoolboxenc: return AVERROR_EXTERNAL immediately when encode error Just return AVERROR_EXTERNAL immediately when encode error. The other logic should keep the old behavior before commit 7c05b7951. Suggested-By: Zhao Zhili Signed-off-by: Steven Liu > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79bd6a21a04c7c457bfeb53fddc157bbd80cdaac --- libavcodec/audiotoolboxenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 00293154bf..8bbaabd960 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -554,13 +554,12 @@ static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt, avctx->frame_size, &avpkt->pts, &avpkt->duration); -ret = 0; } else if (ret && ret != 1) { av_log(avctx, AV_LOG_ERROR, "Encode error: %i\n", ret); -ret = AVERROR_EXTERNAL; +return AVERROR_EXTERNAL; } -return ret; +return 0; } static av_cold void ffat_encode_flush(AVCodecContext *avctx) ___ 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] avformat/vividas: Check packet size
ffmpeg | branch: release/4.4 | Michael Niedermayer | Sun Sep 18 19:14:07 2022 +0200| [c152b697158466f8b6389394bd4be2fa5a4a0abc] | committer: Michael Niedermayer avformat/vividas: Check packet size Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 5f44489cc5d4f3767f6ad2ad067ee6a3f78374bb) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c152b697158466f8b6389394bd4be2fa5a4a0abc --- libavformat/vividas.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavformat/vividas.c b/libavformat/vividas.c index d35a646bde..e253b376ab 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -683,6 +683,7 @@ static int viv_read_packet(AVFormatContext *s, if (viv->sb_entries[viv->current_sb_entry].flag == 0) { uint64_t v_size = ffio_read_varlen(pb); +int last = 0, last_start; if (!viv->num_audio) return AVERROR_INVALIDDATA; @@ -706,12 +707,18 @@ static int viv_read_packet(AVFormatContext *s, if (i > 0 && start == 0) break; +if (start < last) +return AVERROR_INVALIDDATA; viv->n_audio_subpackets = i + 1; +last = viv->audio_subpackets[i].start = start; viv->audio_subpackets[i].pcm_bytes = pcm_bytes; } +last_start = viv->audio_subpackets[viv->n_audio_subpackets].start = (int)(off - avio_tell(pb)); +if (last_start < last) +return AVERROR_INVALIDDATA; viv->current_audio_subpacket = 0; } else { ___ 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".