summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2016-06-20 13:57:59 -0400
committerAnton Khirnov <anton@khirnov.net>2016-07-25 13:57:02 +0200
commit6a540eef5ebe1834d1b960bc5e9a35fa29b8f09f (patch)
treea64c74663c841c26d4dcbed61256a995078e41db
parente55bf763bce1317252a13116080f1c7898dcb46c (diff)
cfhd: Support odd height files
-rw-r--r--libavcodec/cfhd.c12
-rw-r--r--libavcodec/cfhd.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 31fbe83ec9..8827f7f495 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -49,6 +49,7 @@ static void init_frame_defaults(CFHDContext *s)
{
s->coded_width = 0;
s->coded_height = 0;
+ s->cropped_height = 0;
s->bpc = 12;
s->channel_cnt = 4;
s->subband_cnt = 10;
@@ -162,6 +163,9 @@ static int alloc_buffers(AVCodecContext *avctx)
if ((ret = ff_set_dimensions(avctx, s->coded_width, s->coded_height)) < 0)
return ret;
+ if (s->cropped_height)
+ avctx->height = s->cropped_height;
+
avctx->pix_fmt = s->coded_format;
if ((ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
@@ -172,8 +176,8 @@ static int alloc_buffers(AVCodecContext *avctx)
for (i = 0; i < planes; i++) {
int w8, h8, w4, h4, w2, h2;
- int width = i ? avctx->width >> s->chroma_x_shift : avctx->width;
- int height = i ? avctx->height >> s->chroma_y_shift : avctx->height;
+ int width = i ? s->coded_width >> s->chroma_x_shift : s->coded_width;
+ int height = i ? s->coded_height >> s->chroma_y_shift : s->coded_height;
ptrdiff_t stride = FFALIGN(width / 8, 8) * 8;
height = FFALIGN(height / 8, 2) * 8;
s->plane[i].width = width;
@@ -404,6 +408,10 @@ static int parse_tag(AVCodecContext *avctx, CFHDContext *s, GetByteContext *gb,
}
*planes = av_pix_fmt_count_planes(s->coded_format);
break;
+ case -85:
+ av_log(avctx, AV_LOG_DEBUG, "Cropped height %"PRIu16"\n", data);
+ s->cropped_height = data;
+ break;
case 101:
av_log(avctx, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n",
data);
diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
index 52f927e45e..05d251132c 100644
--- a/libavcodec/cfhd.h
+++ b/libavcodec/cfhd.h
@@ -80,6 +80,7 @@ typedef struct CFHDContext {
int coded_width;
int coded_height;
+ int cropped_height;
enum AVPixelFormat coded_format;
int a_width;