summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-19 05:56:17 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-19 16:26:46 +0100
commitd9b3097ba2d4b215b95481dcd92ce88b4ffae6da (patch)
tree383e91b3e9a09fdaa9ad981736153a8a8082213e
parent3fa6d205338c2c019eb024e9b79b5b07c2d72dbb (diff)
downloadffmpeg-streaming-d9b3097ba2d4b215b95481dcd92ce88b4ffae6da.zip
ffmpeg-streaming-d9b3097ba2d4b215b95481dcd92ce88b4ffae6da.tar.gz
pamdec: fix mono support.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/pnm.c4
-rw-r--r--libavcodec/pnmdec.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 103408c..0e547de 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -112,7 +112,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
s->maxval = maxval;
if (depth == 1) {
if (maxval == 1) {
- avctx->pix_fmt = PIX_FMT_MONOWHITE;
+ avctx->pix_fmt = PIX_FMT_MONOBLACK;
} else if (maxval == 255) {
avctx->pix_fmt = PIX_FMT_GRAY8;
} else {
@@ -148,7 +148,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
avctx->height = atoi(buf1);
if(avctx->height <= 0 || av_image_check_size(avctx->width, avctx->height, 0, avctx))
return -1;
- if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
+ if (avctx->pix_fmt != PIX_FMT_MONOWHITE && avctx->pix_fmt != PIX_FMT_MONOBLACK) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
if (s->maxval <= 0) {
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index e6c91ef..c3f7bbd 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -108,20 +108,21 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
linesize = p->linesize[0];
if (s->bytestream + n * avctx->height > s->bytestream_end)
return -1;
- if(s->type < 4){
+ if(s->type < 4 || (is_mono && s->type==7)){
for (i=0; i<avctx->height; i++) {
PutBitContext pb;
init_put_bits(&pb, ptr, linesize);
for(j=0; j<avctx->width * components; j++){
unsigned int c=0;
int v=0;
+ if(s->type < 4)
while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
s->bytestream++;
if(s->bytestream >= s->bytestream_end)
return -1;
if (is_mono) {
/* read a single digit */
- v = (*s->bytestream++) - '0';
+ v = (*s->bytestream++)&1;
} else {
/* read a sequence of digits */
do {
@@ -260,7 +261,7 @@ AVCodec ff_pam_decoder = {
.close = ff_pnm_end,
.decode = pnm_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
+ .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
};
#endif
OpenPOWER on IntegriCloud