summaryrefslogtreecommitdiff
path: root/libavcodec/rawdec.c
diff options
context:
space:
mode:
authorMats Peterson <matsp888-at-yahoo.com@ffmpeg.org>2016-01-25 18:09:18 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-25 19:47:16 +0100
commit191ec55c9fc1ab0147b1e952d0700fde3ce9fbcb (patch)
tree773f985da37b4e3a5dbc0735f1e62c710900bad1 /libavcodec/rawdec.c
parent209f50e16b5e66424d593ba4f9d4d8be5feff947 (diff)
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: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/rawdec.c')
-rw-r--r--libavcodec/rawdec.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 87cda326c0..3536943adf 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -41,7 +41,7 @@ typedef struct RawVideoContext {
AVBufferRef *palette;
int frame_size; /* size of the frame in bytes */
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_lt_16bpp; // 16bpp pixfmt and bits_per_coded_sample < 16
int tff;
@@ -176,12 +176,18 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
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->pix_fmt == AV_PIX_FMT_PAL8 &&
- (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
+ (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) &&
+ (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
context->is_1_2_4_8_bpp = 1;
- context->frame_size = av_image_get_buffer_size(avctx->pix_fmt,
- FFALIGN(avctx->width, 16),
- avctx->height, 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,
+ FFALIGN(avctx->width, 16),
+ avctx->height, 1);
} else {
context->is_lt_16bpp = av_get_bits_per_pixel(desc) == 16 && avctx->bits_per_coded_sample && avctx->bits_per_coded_sample < 16;
context->frame_size = av_image_get_buffer_size(avctx->pix_fmt, avctx->width,
@@ -217,16 +223,18 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
if (!frame->buf[0])
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) {
int i, j, row_pix = 0;
uint8_t *dst = frame->buf[0]->data;
- buf_size = context->frame_size - AVPALETTE_SIZE;
- if (avctx->bits_per_coded_sample == 8) {
+ buf_size = context->frame_size -
+ (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++) {
dst[j] = buf[i];
- row_pix++;
- if (row_pix == avctx->width) {
+ row_pix += pix_per_byte;
+ if (row_pix >= avctx->width) {
i += avpkt_stride - (i % avpkt_stride) - 1;
j += 16 - (j % 16) - 1;
row_pix = 0;