aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pnmdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-24 14:14:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-24 14:14:28 +0100
commit198ea7a96f64b60d26068ac30605d5b50245abeb (patch)
treef3733ea0f10027eebe49df94826e46e52e907b3d /libavcodec/pnmdec.c
parenta77a27a24b27fc29d119b00866740e4d0b69ba28 (diff)
parentb5f536d24b5ae360503935c34d5d59fa5181b94d (diff)
downloadandroid_external_ffmpeg-198ea7a96f64b60d26068ac30605d5b50245abeb.tar.gz
android_external_ffmpeg-198ea7a96f64b60d26068ac30605d5b50245abeb.tar.bz2
android_external_ffmpeg-198ea7a96f64b60d26068ac30605d5b50245abeb.zip
Merge commit 'b5f536d24b5ae360503935c34d5d59fa5181b94d'
* commit 'b5f536d24b5ae360503935c34d5d59fa5181b94d': pnm: add high-bitdepth PGMYUV support for both encoder and decoder Conflicts: libavcodec/pnm.c libavcodec/pnmdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pnmdec.c')
-rw-r--r--libavcodec/pnmdec.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index 1c22f74052..3280eef672 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -157,12 +157,16 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
}
break;
case AV_PIX_FMT_YUV420P:
+ case AV_PIX_FMT_YUV420P9BE:
+ case AV_PIX_FMT_YUV420P10BE:
{
unsigned char *ptr1, *ptr2;
n = avctx->width;
ptr = p->data[0];
linesize = p->linesize[0];
+ if (s->maxval >= 256)
+ n *= 2;
if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
return AVERROR_INVALIDDATA;
for (i = 0; i < avctx->height; i++) {
@@ -184,6 +188,47 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
}
}
break;
+ case AV_PIX_FMT_YUV420P16:
+ {
+ uint16_t *ptr1, *ptr2;
+ const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
+ unsigned int j, v;
+
+ n = avctx->width * 2;
+ ptr = p->data[0];
+ linesize = p->linesize[0];
+ if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
+ return AVERROR_INVALIDDATA;
+ for (i = 0; i < avctx->height; i++) {
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+ ptr += linesize;
+ }
+ ptr1 = (uint16_t*)p->data[1];
+ ptr2 = (uint16_t*)p->data[2];
+ n >>= 1;
+ h = avctx->height >> 1;
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ptr1[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ptr2[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+
+ ptr1 += p->linesize[1] / 2;
+ ptr2 += p->linesize[2] / 2;
+ }
+ }
+ break;
}
*picture = s->picture;
*got_frame = 1;