Commit 191ec55c authored by Mats Peterson's avatar Mats Peterson Committed by Michael Niedermayer

lavc/rawdec: Use 16-byte line alignment for AV_PIX_FMT_MONOWHITE

The line alignment for 1 bpp raw AV_PIX_FMT_MONOWHITE video (currently
used for AVI) was previously 4 bytes, which generated alignment warning
messages, not only for odd-width files. The alignment is now 16 bytes.
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 209f50e1
...@@ -41,7 +41,7 @@ typedef struct RawVideoContext { ...@@ -41,7 +41,7 @@ typedef struct RawVideoContext {
AVBufferRef *palette; AVBufferRef *palette;
int frame_size; /* size of the frame in bytes */ int frame_size; /* size of the frame in bytes */
int flip; int flip;
int is_1_2_4_8_bpp; // 1 bpp in mov, and 2, 4 and 8 bpp in avi/mov int is_1_2_4_8_bpp; // 1, 2, 4 and 8 bpp in avi/mov
int is_yuv2; int is_yuv2;
int is_lt_16bpp; // 16bpp pixfmt and bits_per_coded_sample < 16 int is_lt_16bpp; // 16bpp pixfmt and bits_per_coded_sample < 16
int tff; int tff;
...@@ -176,9 +176,15 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -176,9 +176,15 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4 if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4
|| avctx->bits_per_coded_sample == 2 || avctx->bits_per_coded_sample == 1) && || avctx->bits_per_coded_sample == 2 || avctx->bits_per_coded_sample == 1) &&
avctx->pix_fmt == AV_PIX_FMT_PAL8 && (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) &&
(!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) { (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
context->is_1_2_4_8_bpp = 1; context->is_1_2_4_8_bpp = 1;
if (avctx->bits_per_coded_sample == 1 && avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) {
int row_bytes = avctx->width / 8 + (avctx->width & 7 ? 1 : 0);
context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
FFALIGN(row_bytes, 16) * 8,
avctx->height, 1);
} else
context->frame_size = av_image_get_buffer_size(avctx->pix_fmt, context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
FFALIGN(avctx->width, 16), FFALIGN(avctx->width, 16),
avctx->height, 1); avctx->height, 1);
...@@ -217,16 +223,18 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -217,16 +223,18 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
if (!frame->buf[0]) if (!frame->buf[0])
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
// 1 bpp in mov, and 2, 4 and 8 bpp in avi/mov // 1, 2, 4 and 8 bpp in avi/mov
if (context->is_1_2_4_8_bpp) { if (context->is_1_2_4_8_bpp) {
int i, j, row_pix = 0; int i, j, row_pix = 0;
uint8_t *dst = frame->buf[0]->data; uint8_t *dst = frame->buf[0]->data;
buf_size = context->frame_size - AVPALETTE_SIZE; buf_size = context->frame_size -
if (avctx->bits_per_coded_sample == 8) { (avctx->pix_fmt == AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0);
if (avctx->bits_per_coded_sample == 8 || avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) {
int pix_per_byte = avctx->pix_fmt == AV_PIX_FMT_MONOWHITE ? 8 : 1;
for (i = 0, j = 0; j < buf_size && i<avpkt->size; i++, j++) { for (i = 0, j = 0; j < buf_size && i<avpkt->size; i++, j++) {
dst[j] = buf[i]; dst[j] = buf[i];
row_pix++; row_pix += pix_per_byte;
if (row_pix == avctx->width) { if (row_pix >= avctx->width) {
i += avpkt_stride - (i % avpkt_stride) - 1; i += avpkt_stride - (i % avpkt_stride) - 1;
j += 16 - (j % 16) - 1; j += 16 - (j % 16) - 1;
row_pix = 0; row_pix = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment