diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-12-02 17:49:03 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-12-03 17:17:42 +0100 |
commit | 3d8d8c7199717a0a31fbe01f8931d96fe8408bd6 (patch) | |
tree | 3eb90a6ebc14d86ad026351aab0bff1e047301a3 /libavcodec/r210dec.c | |
parent | 42d5b59bdcf8404767c4368b7bd1ccb4bbaf1d47 (diff) | |
download | ffmpeg-3d8d8c7199717a0a31fbe01f8931d96fe8408bd6.tar.gz |
avcodec/r210: use correct pixel format
Diffstat (limited to 'libavcodec/r210dec.c')
-rw-r--r-- | libavcodec/r210dec.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c index dbc94c76bd..22b95e9092 100644 --- a/libavcodec/r210dec.c +++ b/libavcodec/r210dec.c @@ -27,11 +27,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { - if ((avctx->codec_tag & 0xFFFFFF) == MKTAG('r', '1', '0', 0)) { - avctx->pix_fmt = AV_PIX_FMT_BGR48; - } else { - avctx->pix_fmt = AV_PIX_FMT_RGB48; - } + avctx->pix_fmt = AV_PIX_FMT_GBRP10; avctx->bits_per_raw_sample = 10; return 0; @@ -45,7 +41,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, const uint32_t *src = (const uint32_t *)avpkt->data; int aligned_width = FFALIGN(avctx->width, avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64); - uint8_t *dst_line; + uint8_t *g_line, *b_line, *r_line; int r10 = (avctx->codec_tag & 0xFFFFFF) == MKTAG('r', '1', '0', 0); int le = avctx->codec_tag == MKTAG('R', '1', '0', 'k') && avctx->extradata_size >= 12 && !memcmp(&avctx->extradata[4], "DpxE", 4) && @@ -61,10 +57,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, pic->pict_type = AV_PICTURE_TYPE_I; pic->key_frame = 1; - dst_line = pic->data[0]; + g_line = pic->data[0]; + b_line = pic->data[1]; + r_line = pic->data[2]; for (h = 0; h < avctx->height; h++) { - uint16_t *dst = (uint16_t *)dst_line; + uint16_t *dstg = (uint16_t *)g_line; + uint16_t *dstb = (uint16_t *)b_line; + uint16_t *dstr = (uint16_t *)r_line; for (w = 0; w < avctx->width; w++) { uint32_t pixel; uint16_t r, g, b; @@ -74,20 +74,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, pixel = av_be2ne32(*src++); } if (avctx->codec_id == AV_CODEC_ID_R210 || r10) { - b = pixel << 6; - g = (pixel >> 4) & 0xffc0; - r = (pixel >> 14) & 0xffc0; + b = pixel & 0x3ff; + g = (pixel >> 10) & 0x3ff; + r = (pixel >> 20) & 0x3ff; } else { - b = (pixel << 4) & 0xffc0; - g = (pixel >> 6) & 0xffc0; - r = (pixel >> 16) & 0xffc0; + b = (pixel >> 2) & 0x3ff; + g = (pixel >> 12) & 0x3ff; + r = (pixel >> 22) & 0x3ff; } - *dst++ = r | (r >> 10); - *dst++ = g | (g >> 10); - *dst++ = b | (b >> 10); + *dstr++ = r; + *dstg++ = g; + *dstb++ = b; } src += aligned_width - avctx->width; - dst_line += pic->linesize[0]; + g_line += pic->linesize[0]; + b_line += pic->linesize[1]; + r_line += pic->linesize[2]; } *got_frame = 1; |