int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0;
unsigned char *ptr;
int components, sample_len, ret;
+ float scale;
s->bytestream_start =
s->bytestream = (uint8_t *)buf;
init_put_bits(&pb, ptr, linesize);
for(j=0; j<avctx->width * components; j++){
unsigned int c=0;
- int v=0;
+ unsigned v=0;
if(s->type < 4)
while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
s->bytestream++;
v = (*s->bytestream++)&1;
} else {
/* read a sequence of digits */
- for (k = 0; k < 5 && c <= 9; k += 1) {
+ for (k = 0; k < 6 && c <= 9; k += 1) {
v = 10*v + c;
c = (*s->bytestream++) - '0';
}
} else if (upgrade == 2) {
unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
for (j = 0; j < n / 2; j++) {
- v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ v = AV_RB16(s->bytestream + 2*j);
((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
}
}
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]);
+ v = AV_RB16(s->bytestream + 2*j);
((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
}
s->bytestream += n;
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]);
+ v = AV_RB16(s->bytestream + 2*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]);
+ v = AV_RB16(s->bytestream + 2*j);
ptr2[j] = (v * f + 16384) >> 15;
}
s->bytestream += n;
}
}
break;
+ case AV_PIX_FMT_GBRPF32:
+ if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
+ return AVERROR_INVALIDDATA;
+ scale = 1.f / s->scale;
+ if (s->endian) {
+ float *r, *g, *b;
+
+ r = (float *)p->data[2];
+ g = (float *)p->data[0];
+ b = (float *)p->data[1];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
+ g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
+ b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
+ s->bytestream += 12;
+ }
+
+ r += p->linesize[2] / 4;
+ g += p->linesize[0] / 4;
+ b += p->linesize[1] / 4;
+ }
+ } else {
+ float *r, *g, *b;
+
+ r = (float *)p->data[2];
+ g = (float *)p->data[0];
+ b = (float *)p->data[1];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
+ g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
+ b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
+ s->bytestream += 12;
+ }
+
+ r += p->linesize[2] / 4;
+ g += p->linesize[0] / 4;
+ b += p->linesize[1] / 4;
+ }
+ }
+ break;
+ case AV_PIX_FMT_GRAYF32:
+ if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
+ return AVERROR_INVALIDDATA;
+ scale = 1.f / s->scale;
+ if (s->endian) {
+ float *g = (float *)p->data[0];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
+ s->bytestream += 4;
+ }
+ g += p->linesize[0] / 4;
+ }
+ } else {
+ float *g = (float *)p->data[0];
+ for (int i = 0; i < avctx->height; i++) {
+ for (int j = 0; j < avctx->width; j++) {
+ g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
+ s->bytestream += 4;
+ }
+ g += p->linesize[0] / 4;
+ }
+ }
+ break;
}
*got_frame = 1;
#if CONFIG_PGM_DECODER
-AVCodec ff_pgm_decoder = {
+const AVCodec ff_pgm_decoder = {
.name = "pgm",
.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
#endif
#if CONFIG_PGMYUV_DECODER
-AVCodec ff_pgmyuv_decoder = {
+const AVCodec ff_pgmyuv_decoder = {
.name = "pgmyuv",
.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
.type = AVMEDIA_TYPE_VIDEO,
#endif
#if CONFIG_PPM_DECODER
-AVCodec ff_ppm_decoder = {
+const AVCodec ff_ppm_decoder = {
.name = "ppm",
.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
#endif
#if CONFIG_PBM_DECODER
-AVCodec ff_pbm_decoder = {
+const AVCodec ff_pbm_decoder = {
.name = "pbm",
.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
#endif
#if CONFIG_PAM_DECODER
-AVCodec ff_pam_decoder = {
+const AVCodec ff_pam_decoder = {
.name = "pam",
.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.capabilities = AV_CODEC_CAP_DR1,
};
#endif
+
+#if CONFIG_PFM_DECODER
+const AVCodec ff_pfm_decoder = {
+ .name = "pfm",
+ .long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_PFM,
+ .priv_data_size = sizeof(PNMContext),
+ .decode = pnm_decode_frame,
+ .capabilities = AV_CODEC_CAP_DR1,
+};
+#endif