summaryrefslogtreecommitdiffstats
path: root/libavcodec/cdxl.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-02-18 23:47:39 +0100
committerPaul B Mahol <onemda@gmail.com>2016-02-19 10:45:54 +0100
commit4956dc88d1fee9f4fa8ae0e26cec0593fef68179 (patch)
tree04b37addaae42a4b77486cc6a33c32a0f52ed79f /libavcodec/cdxl.c
parent98a0053d0f90e3309dc1038b1bae3a48bbd9067c (diff)
downloadffmpeg-streaming-4956dc88d1fee9f4fa8ae0e26cec0593fef68179.zip
ffmpeg-streaming-4956dc88d1fee9f4fa8ae0e26cec0593fef68179.tar.gz
avcodec/cdxl: add support for raw videos with chunky format
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/cdxl.c')
-rw-r--r--libavcodec/cdxl.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c
index 50d514b..c8d66b5 100644
--- a/libavcodec/cdxl.c
+++ b/libavcodec/cdxl.c
@@ -30,6 +30,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
+#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
@@ -107,6 +108,17 @@ static void bitline2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
}
}
+static void chunky2chunky(CDXLVideoContext *c, int linesize, uint8_t *out)
+{
+ GetByteContext gb;
+ int y;
+
+ bytestream2_init(&gb, c->video, c->video_size);
+ for (y = 0; y < c->avctx->height; y++) {
+ bytestream2_get_buffer(&gb, out + linesize * y, c->avctx->width * 3);
+ }
+}
+
static void import_format(CDXLVideoContext *c, int linesize, uint8_t *out)
{
memset(out, 0, linesize * c->avctx->height);
@@ -118,6 +130,9 @@ static void import_format(CDXLVideoContext *c, int linesize, uint8_t *out)
case BIT_LINE:
bitline2chunky(c, linesize, out);
break;
+ case CHUNKY:
+ chunky2chunky(c, linesize, out);
+ break;
}
}
@@ -130,6 +145,11 @@ static void cdxl_decode_rgb(CDXLVideoContext *c, AVFrame *frame)
import_format(c, frame->linesize[0], frame->data[0]);
}
+static void cdxl_decode_raw(CDXLVideoContext *c, AVFrame *frame)
+{
+ import_format(c, frame->linesize[0], frame->data[0]);
+}
+
static void cdxl_decode_ham6(CDXLVideoContext *c, AVFrame *frame)
{
AVCodecContext *avctx = c->avctx;
@@ -242,7 +262,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
if (c->bpp < 1)
return AVERROR_INVALIDDATA;
- if (c->format != BIT_PLANAR && c->format != BIT_LINE) {
+ if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) {
avpriv_request_sample(avctx, "Pixel format 0x%0x", c->format);
return AVERROR_PATCHWELCOME;
}
@@ -250,7 +270,10 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
- aligned_width = FFALIGN(c->avctx->width, 16);
+ if (c->format == CHUNKY)
+ aligned_width = avctx->width;
+ else
+ aligned_width = FFALIGN(c->avctx->width, 16);
c->padded_bits = aligned_width - c->avctx->width;
if (c->video_size < aligned_width * avctx->height * c->bpp / 8)
return AVERROR_INVALIDDATA;
@@ -260,9 +283,12 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
if (c->palette_size != (1 << (c->bpp - 1)))
return AVERROR_INVALIDDATA;
avctx->pix_fmt = AV_PIX_FMT_BGR24;
+ } else if (!encoding && c->bpp == 24 && c->format == CHUNKY &&
+ !c->palette_size) {
+ avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else {
- avpriv_request_sample(avctx, "Encoding %d and bpp %d",
- encoding, c->bpp);
+ avpriv_request_sample(avctx, "Encoding %d, bpp %d and format 0x%x",
+ encoding, c->bpp, c->format);
return AVERROR_PATCHWELCOME;
}
@@ -279,8 +305,10 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
cdxl_decode_ham8(c, p);
else
cdxl_decode_ham6(c, p);
- } else {
+ } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
cdxl_decode_rgb(c, p);
+ } else {
+ cdxl_decode_raw(c, p);
}
*got_frame = 1;
OpenPOWER on IntegriCloud