aboutsummaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol2012-10-13 08:38:02 +0000
committerPaul B Mahol2012-10-13 16:02:09 +0000
commit8288c2b6cb072b61f664bc8ab4c1b0a5a8db0ead (patch)
tree8491f5fe9d7d68e443f22906802929ba3f9c3120 /libavcodec
parent2a56e65c3b3b53a3a51f290faa33ce0a852cd2a1 (diff)
pngdec: read sample aspect ratio
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pngdec.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index a3af924918..4a6047e11a 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -467,6 +467,18 @@ static int decode_frame(AVCodecContext *avctx,
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
break;
+ case MKTAG('p', 'H', 'Y', 's'):
+ if (s->state & PNG_IDAT) {
+ av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n");
+ goto fail;
+ }
+ avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb);
+ avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb);
+ if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0)
+ avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
+ bytestream2_skip(&s->gb, 1); /* unit specifier */
+ bytestream2_skip(&s->gb, 4); /* crc */
+ break;
case MKTAG('I', 'D', 'A', 'T'):
if (!(s->state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");