* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/avstring.h"
#include "libavutil/imgutils.h"
+#include "libavutil/stereo3d.h"
+
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
int ret;
/* check signature */
- if (buf_size < 8 ||
- (memcmp(buf, ff_pngsig, 8) != 0 && memcmp(buf, ff_mngsig, 8) != 0)) {
- av_log(avctx, AV_LOG_ERROR, "Invalid PNG signature (%d).\n", buf_size);
+ if (buf_size < 8) {
+ av_log(avctx, AV_LOG_ERROR, "Not enough data %d\n",
+ buf_size);
+ return AVERROR_INVALIDDATA;
+ }
+ if (memcmp(buf, ff_pngsig, 8) != 0 &&
+ memcmp(buf, ff_mngsig, 8) != 0) {
+ char signature[5 * 8 + 1] = { 0 };
+ int i;
+ for (i = 0; i < 8; i++) {
+ av_strlcatf(signature + i * 5, sizeof(signature) - i * 5,
+ " 0x%02x", buf[i]);
+ }
+ av_log(avctx, AV_LOG_ERROR, "Invalid PNG signature %s\n",
+ signature);
return AVERROR_INVALIDDATA;
}
if (length > 0x7fffffff)
goto fail;
tag = bytestream2_get_le32(&s->gb);
- av_dlog(avctx, "png: tag=%c%c%c%c length=%u\n",
+ ff_dlog(avctx, "png: tag=%c%c%c%c length=%u\n",
(tag & 0xff),
((tag >> 8) & 0xff),
((tag >> 16) & 0xff),
s->interlace_type = bytestream2_get_byte(&s->gb);
bytestream2_skip(&s->gb, 4); /* crc */
s->state |= PNG_IHDR;
- av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d "
+ ff_dlog(avctx, "width=%d height=%d depth=%d color_type=%d "
"compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
s->width);
s->crow_size = s->pass_row_size + 1;
}
- av_dlog(avctx, "row_size=%d crow_size =%d\n",
+ ff_dlog(avctx, "row_size=%d crow_size =%d\n",
s->row_size, s->crow_size);
s->image_buf = p->data[0];
s->image_linesize = p->linesize[0];
bytestream2_skip(&s->gb, 4); /* crc */
}
break;
+ case MKTAG('s', 'T', 'E', 'R'): {
+ int mode = bytestream2_get_byte(&s->gb);
+ AVStereo3D *stereo3d = av_stereo3d_create_side_data(p);
+ if (!stereo3d)
+ goto the_end;
+
+ if (mode == 0 || mode == 1) {
+ stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
+ stereo3d->flags = mode ? 0 : AV_STEREO3D_FLAG_INVERT;
+ } else {
+ av_log(avctx, AV_LOG_WARNING,
+ "Unknown value in sTER chunk (%d)\n", mode);
+ }
+ bytestream2_skip(&s->gb, 4); /* crc */
+ break;
+ }
case MKTAG('I', 'E', 'N', 'D'):
if (!(s->state & PNG_ALLIMAGE))
goto fail;
}
}
exit_loop:
- /* handle p-frames only if a predecessor frame is available */
+ /* handle P-frames only if a predecessor frame is available */
if (s->prev->data[0]) {
if (!(avpkt->flags & AV_PKT_FLAG_KEY)) {
int i, j;
{
PNGDecContext *s = avctx->priv_data;
+ avctx->color_range = AVCOL_RANGE_JPEG;
+
s->prev = av_frame_alloc();
if (!s->prev)
return AVERROR(ENOMEM);
.init = png_dec_init,
.close = png_dec_end,
.decode = decode_frame,
- .capabilities = CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
+ .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,
};