[FFmpeg-cvslog] pngdec: read sample aspect ratio

Paul B Mahol git at videolan.org
Sat Oct 13 18:08:08 CEST 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Oct 13 08:38:02 2012 +0000| [8288c2b6cb072b61f664bc8ab4c1b0a5a8db0ead] | committer: Paul B Mahol

pngdec: read sample aspect ratio

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8288c2b6cb072b61f664bc8ab4c1b0a5a8db0ead
---

 libavcodec/pngdec.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index a3af924..4a6047e 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");



More information about the ffmpeg-cvslog mailing list