[FFmpeg-cvslog] Merge commit '51dc4de1218a81ee8e5b3f941839c5e3125a6d4b'

Derek Buitenhuis git at videolan.org
Mon May 9 00:33:25 CEST 2016


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Sun May  8 23:31:01 2016 +0100| [dd2d26dc82b8f0fcbcad3104cbee03e7ec80b263] | committer: Derek Buitenhuis

Merge commit '51dc4de1218a81ee8e5b3f941839c5e3125a6d4b'

* commit '51dc4de1218a81ee8e5b3f941839c5e3125a6d4b':
  rscc: Add extended pixel format support

Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

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

 libavcodec/rscc.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index a2f7a0d..a47d29f 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -31,7 +31,7 @@
  * and it can be deflated or not. Similarly, pixel data comes after the header
  * and a variable size value, and it can be deflated or just raw.
  *
- * Supports: BGRA
+ * Supports: BGRA, BGR24, RGB555, RGB8
  */
 
 #include <stdint.h>
@@ -57,6 +57,7 @@ typedef struct RsccContext {
     AVFrame *reference;
     Tile *tiles;
     unsigned int tiles_size;
+    int component_size;
 
     /* zlib interaction */
     uint8_t *inflated_buf;
@@ -80,14 +81,38 @@ static av_cold int rscc_init(AVCodecContext *avctx)
     if (!ctx->reference)
         return AVERROR(ENOMEM);
 
-    if (avctx->codec_tag == MKTAG('I','S','C','C')) {
+    /* Get pixel format and the size of the pixel */
+    if (avctx->codec_tag == MKTAG('I', 'S', 'C', 'C')) {
         avctx->pix_fmt = AV_PIX_FMT_BGRA;
+        ctx->component_size = 4;
+    } else if (avctx->codec_tag == MKTAG('R', 'S', 'C', 'C')) {
+        ctx->component_size = avctx->bits_per_coded_sample / 8;
+        switch (avctx->bits_per_coded_sample) {
+        case 8:
+            avpriv_report_missing_feature(avctx, "8 bits per pixel");
+            return AVERROR_PATCHWELCOME;
+        case 16:
+            avctx->pix_fmt = AV_PIX_FMT_RGB555LE;
+            break;
+        case 24:
+            avctx->pix_fmt = AV_PIX_FMT_BGR24;
+            break;
+        case 32:
+            avctx->pix_fmt = AV_PIX_FMT_BGRA;
+            break;
+        default:
+            av_log(avctx, AV_LOG_ERROR, "Invalid bits per pixel value (%d)\n",
+                   avctx->bits_per_coded_sample);
+            return AVERROR_INVALIDDATA;
+        }
     } else {
         avctx->pix_fmt = AV_PIX_FMT_BGR0;
+        ctx->component_size = 4;
+        av_log(avctx, AV_LOG_WARNING, "Invalid codec tag\n");
     }
 
     /* Store the value to check for keyframes */
-    ctx->inflated_size = avctx->width * avctx->height * 4;
+    ctx->inflated_size = avctx->width * avctx->height * ctx->component_size;
 
     /* Allocate maximum size possible, a full frame */
     ctx->inflated_buf = av_malloc(ctx->inflated_size);
@@ -184,7 +209,7 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
         ctx->tiles[i].y = bytestream2_get_le16(gbc);
         ctx->tiles[i].h = bytestream2_get_le16(gbc);
 
-        pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * 4;
+        pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size;
 
         ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i,
                 ctx->tiles[i].x, ctx->tiles[i].y,
@@ -252,11 +277,12 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
     for (i = 0; i < tiles_nb; i++) {
         uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] *
                        (avctx->height - ctx->tiles[i].y - 1) +
-                       ctx->tiles[i].x * 4;
+                       ctx->tiles[i].x * ctx->component_size;
         av_image_copy_plane(dst, -1 * ctx->reference->linesize[0],
-                            raw, ctx->tiles[i].w * 4,
-                            ctx->tiles[i].w * 4, ctx->tiles[i].h);
-        raw += ctx->tiles[i].w * 4 * ctx->tiles[i].h;
+                            raw, ctx->tiles[i].w * ctx->component_size,
+                            ctx->tiles[i].w * ctx->component_size,
+                            ctx->tiles[i].h);
+        raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h;
     }
 
     /* Frame is ready to be output */


======================================================================

diff --cc libavcodec/rscc.c
index a2f7a0d,4a91783..a47d29f
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@@ -80,10 -81,33 +81,34 @@@ static av_cold int rscc_init(AVCodecCon
      if (!ctx->reference)
          return AVERROR(ENOMEM);
  
-     if (avctx->codec_tag == MKTAG('I','S','C','C')) {
+     /* Get pixel format and the size of the pixel */
+     if (avctx->codec_tag == MKTAG('I', 'S', 'C', 'C')) {
          avctx->pix_fmt = AV_PIX_FMT_BGRA;
+         ctx->component_size = 4;
+     } else if (avctx->codec_tag == MKTAG('R', 'S', 'C', 'C')) {
+         ctx->component_size = avctx->bits_per_coded_sample / 8;
+         switch (avctx->bits_per_coded_sample) {
+         case 8:
+             avpriv_report_missing_feature(avctx, "8 bits per pixel");
+             return AVERROR_PATCHWELCOME;
+         case 16:
+             avctx->pix_fmt = AV_PIX_FMT_RGB555LE;
+             break;
+         case 24:
+             avctx->pix_fmt = AV_PIX_FMT_BGR24;
+             break;
+         case 32:
+             avctx->pix_fmt = AV_PIX_FMT_BGRA;
+             break;
+         default:
+             av_log(avctx, AV_LOG_ERROR, "Invalid bits per pixel value (%d)\n",
+                    avctx->bits_per_coded_sample);
+             return AVERROR_INVALIDDATA;
+         }
      } else {
 -        av_log(avctx, AV_LOG_ERROR, "Invalid codec tag\n");
 -        return AVERROR_INVALIDDATA;
 +        avctx->pix_fmt = AV_PIX_FMT_BGR0;
++        ctx->component_size = 4;
++        av_log(avctx, AV_LOG_WARNING, "Invalid codec tag\n");
      }
  
      /* Store the value to check for keyframes */



More information about the ffmpeg-cvslog mailing list