[FFmpeg-cvslog] Fix decoding for little endian Aja Kona 10-bit RGB.

Carl Eugen Hoyos git at videolan.org
Mon Dec 29 23:11:47 CET 2014


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Mon Dec 29 22:47:04 2014 +0100| [7905bd55557323f72c00bf51a6a5cceabd3e81e5] | committer: Carl Eugen Hoyos

Fix decoding for little endian Aja Kona 10-bit RGB.

The little endian fourcc is r10k, big endian uses R10k.
Reported and analyzed by Jason Freets, jasonslife hotmail

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7905bd55557323f72c00bf51a6a5cceabd3e81e5
---

 libavcodec/r210dec.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c
index 5dd2f0d..a2e1a07 100644
--- a/libavcodec/r210dec.c
+++ b/libavcodec/r210dec.c
@@ -27,7 +27,11 @@
 
 static av_cold int decode_init(AVCodecContext *avctx)
 {
-    avctx->pix_fmt             = AV_PIX_FMT_RGB48;
+    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->bits_per_raw_sample = 10;
 
     return 0;
@@ -42,6 +46,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     int aligned_width = FFALIGN(avctx->width,
                                 avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64);
     uint8_t *dst_line;
+    int r10 = (avctx->codec_tag & 0xFFFFFF) == MKTAG('r', '1', '0', 0);
 
     if (avpkt->size < 4 * aligned_width * avctx->height) {
         av_log(avctx, AV_LOG_ERROR, "packet too small\n");
@@ -60,12 +65,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         for (w = 0; w < avctx->width; w++) {
             uint32_t pixel;
             uint16_t r, g, b;
-            if (avctx->codec_id==AV_CODEC_ID_AVRP) {
+            if (avctx->codec_id == AV_CODEC_ID_AVRP || r10) {
                 pixel = av_le2ne32(*src++);
             } else {
                 pixel = av_be2ne32(*src++);
             }
-            if (avctx->codec_id==AV_CODEC_ID_R210) {
+            if (avctx->codec_id == AV_CODEC_ID_R210 || r10) {
                 b =  pixel <<  6;
                 g = (pixel >>  4) & 0xffc0;
                 r = (pixel >> 14) & 0xffc0;



More information about the ffmpeg-cvslog mailing list