aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-12-02 17:49:03 +0100
committerPaul B Mahol <onemda@gmail.com>2018-12-03 17:17:42 +0100
commit3d8d8c7199717a0a31fbe01f8931d96fe8408bd6 (patch)
tree3eb90a6ebc14d86ad026351aab0bff1e047301a3
parent42d5b59bdcf8404767c4368b7bd1ccb4bbaf1d47 (diff)
downloadffmpeg-3d8d8c7199717a0a31fbe01f8931d96fe8408bd6.tar.gz
avcodec/r210: use correct pixel format
-rw-r--r--libavcodec/r210dec.c38
-rw-r--r--libavcodec/r210enc.c26
-rw-r--r--tests/ref/vsynth/vsynth1-r2106
-rw-r--r--tests/ref/vsynth/vsynth2-r2106
-rw-r--r--tests/ref/vsynth/vsynth3-r2106
-rw-r--r--tests/ref/vsynth/vsynth_lena-r2106
6 files changed, 48 insertions, 40 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;
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index a55e5434f3..02412f3684 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -43,22 +43,26 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int aligned_width = FFALIGN(avctx->width,
avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64);
int pad = (aligned_width - avctx->width) * 4;
- uint8_t *src_line;
+ uint8_t *srcr_line, *srcg_line, *srcb_line;
uint8_t *dst;
if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height, 0)) < 0)
return ret;
- src_line = pic->data[0];
+ srcg_line = pic->data[0];
+ srcb_line = pic->data[1];
+ srcr_line = pic->data[2];
dst = pkt->data;
for (i = 0; i < avctx->height; i++) {
- uint16_t *src = (uint16_t *)src_line;
+ uint16_t *srcr = (uint16_t *)srcr_line;
+ uint16_t *srcg = (uint16_t *)srcg_line;
+ uint16_t *srcb = (uint16_t *)srcb_line;
for (j = 0; j < avctx->width; j++) {
uint32_t pixel;
- uint16_t r = *src++ >> 6;
- uint16_t g = *src++ >> 6;
- uint16_t b = *src++ >> 6;
+ uint16_t r = *srcr++;
+ uint16_t g = *srcg++;
+ uint16_t b = *srcb++;
if (avctx->codec_id == AV_CODEC_ID_R210)
pixel = (r << 20) | (g << 10) | b;
else
@@ -70,7 +74,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
memset(dst, 0, pad);
dst += pad;
- src_line += pic->linesize[0];
+ srcr_line += pic->linesize[2];
+ srcg_line += pic->linesize[0];
+ srcb_line += pic->linesize[1];
}
pkt->flags |= AV_PKT_FLAG_KEY;
@@ -87,7 +93,7 @@ AVCodec ff_r210_encoder = {
.id = AV_CODEC_ID_R210,
.init = encode_init,
.encode2 = encode_frame,
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
.capabilities = AV_CODEC_CAP_INTRA_ONLY,
};
#endif
@@ -99,7 +105,7 @@ AVCodec ff_r10k_encoder = {
.id = AV_CODEC_ID_R10K,
.init = encode_init,
.encode2 = encode_frame,
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
.capabilities = AV_CODEC_CAP_INTRA_ONLY,
};
#endif
@@ -111,7 +117,7 @@ AVCodec ff_avrp_encoder = {
.id = AV_CODEC_ID_AVRP,
.init = encode_init,
.encode2 = encode_frame,
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },
.capabilities = AV_CODEC_CAP_INTRA_ONLY,
};
#endif
diff --git a/tests/ref/vsynth/vsynth1-r210 b/tests/ref/vsynth/vsynth1-r210
index 825e1d4789..1103308060 100644
--- a/tests/ref/vsynth/vsynth1-r210
+++ b/tests/ref/vsynth/vsynth1-r210
@@ -1,4 +1,4 @@
-1ea72f280b110ed65fc535c3438d27f9 *tests/data/fate/vsynth1-r210.avi
+1a522a30ddd8c2865a731a5659001717 *tests/data/fate/vsynth1-r210.avi
22125252 tests/data/fate/vsynth1-r210.avi
-ecaafa9eec11b5e1453a63ed6d194eed *tests/data/fate/vsynth1-r210.out.rawvideo
-stddev: 3.23 PSNR: 37.94 MAXDIFF: 48 bytes: 7603200/ 7603200
+b6444935d6c4d8c75fe63d5978f5b457 *tests/data/fate/vsynth1-r210.out.rawvideo
+stddev: 3.73 PSNR: 36.68 MAXDIFF: 48 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth2-r210 b/tests/ref/vsynth/vsynth2-r210
index dc5ff1849c..5efd87d6f5 100644
--- a/tests/ref/vsynth/vsynth2-r210
+++ b/tests/ref/vsynth/vsynth2-r210
@@ -1,4 +1,4 @@
-2f928096d892ce0239832afc369e117c *tests/data/fate/vsynth2-r210.avi
+9a27c0c96f9e658d610d2590b61416a1 *tests/data/fate/vsynth2-r210.avi
22125252 tests/data/fate/vsynth2-r210.avi
-2ade5f6167d7a4a1589e168ddbbc35d0 *tests/data/fate/vsynth2-r210.out.rawvideo
-stddev: 1.17 PSNR: 46.71 MAXDIFF: 15 bytes: 7603200/ 7603200
+d43196c64fd611f6e9c046e0ef3e570e *tests/data/fate/vsynth2-r210.out.rawvideo
+stddev: 1.37 PSNR: 45.34 MAXDIFF: 14 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth3-r210 b/tests/ref/vsynth/vsynth3-r210
index 75c424cf28..253657cd85 100644
--- a/tests/ref/vsynth/vsynth3-r210
+++ b/tests/ref/vsynth/vsynth3-r210
@@ -1,4 +1,4 @@
-229e700e0fab4e81481e99a70e00bec9 *tests/data/fate/vsynth3-r210.avi
+fd12f6dde75d0872ccf9012b342208de *tests/data/fate/vsynth3-r210.avi
442052 tests/data/fate/vsynth3-r210.avi
-e1d882babc8754f7418aa91ce48f7ab0 *tests/data/fate/vsynth3-r210.out.rawvideo
-stddev: 3.48 PSNR: 37.28 MAXDIFF: 42 bytes: 86700/ 86700
+a2c4e460ebede1109bd794b1b7b05a1f *tests/data/fate/vsynth3-r210.out.rawvideo
+stddev: 4.10 PSNR: 35.87 MAXDIFF: 48 bytes: 86700/ 86700
diff --git a/tests/ref/vsynth/vsynth_lena-r210 b/tests/ref/vsynth/vsynth_lena-r210
index 8fd1a666af..0a113dc693 100644
--- a/tests/ref/vsynth/vsynth_lena-r210
+++ b/tests/ref/vsynth/vsynth_lena-r210
@@ -1,4 +1,4 @@
-94874a48987fd401494f4d7ca8e1273b *tests/data/fate/vsynth_lena-r210.avi
+61fd53566d99b725e75212747b35893f *tests/data/fate/vsynth_lena-r210.avi
22125252 tests/data/fate/vsynth_lena-r210.avi
-6ea4fcd93fc83defc8770e85b64b60bb *tests/data/fate/vsynth_lena-r210.out.rawvideo
-stddev: 0.70 PSNR: 51.12 MAXDIFF: 12 bytes: 7603200/ 7603200
+4b7425191bb6a7fc4ca0dc649d9ba202 *tests/data/fate/vsynth_lena-r210.out.rawvideo
+stddev: 0.93 PSNR: 48.72 MAXDIFF: 11 bytes: 7603200/ 7603200