Lines Matching defs:avctx
59 AVCodecContext *avctx;
438 av_log(s->avctx, AV_LOG_ERROR, "inflate returned error %d\n", ret);
449 av_log(s->avctx, AV_LOG_WARNING,
544 if ((ret = decode_zbuf(&bp, data, data_end, s->avctx)) < 0)
570 static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
577 av_log(avctx, AV_LOG_ERROR, "IHDR after IDAT\n");
582 av_log(avctx, AV_LOG_ERROR, "Multiple IHDR\n");
588 if (av_image_check_size(s->width, s->height, 0, avctx)) {
590 av_log(avctx, AV_LOG_ERROR, "Invalid image size\n");
596 av_log(avctx, AV_LOG_ERROR, "Invalid bit depth\n");
602 av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type);
608 if (avctx->debug & FF_DEBUG_PICT_INFO)
609 av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "
621 static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s,
625 av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n");
628 avctx->sample_aspect_ratio.num = bytestream2_get_be32(gb);
629 avctx->sample_aspect_ratio.den = bytestream2_get_be32(gb);
630 if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0)
631 avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
637 static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
646 av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
651 ret = ff_set_dimensions(avctx, s->width, s->height);
662 avctx->pix_fmt = AV_PIX_FMT_RGB24;
665 avctx->pix_fmt = AV_PIX_FMT_RGBA;
668 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
671 avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
674 avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
677 avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
680 avctx->pix_fmt = avctx->codec_id == AV_CODEC_ID_APNG ? AV_PIX_FMT_RGBA : AV_PIX_FMT_PAL8;
681 } else if (s->bit_depth == 1 && s->bits_per_pixel == 1 && avctx->codec_id != AV_CODEC_ID_APNG) {
682 avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
685 avctx->pix_fmt = AV_PIX_FMT_YA8;
688 avctx->pix_fmt = AV_PIX_FMT_YA16BE;
690 avpriv_report_missing_feature(avctx,
697 switch (avctx->pix_fmt) {
699 avctx->pix_fmt = AV_PIX_FMT_RGBA;
703 avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
707 avctx->pix_fmt = AV_PIX_FMT_YA8;
711 avctx->pix_fmt = AV_PIX_FMT_YA16BE;
715 avpriv_request_sample(avctx, "bit depth %d "
724 ff_thread_release_ext_buffer(avctx, &s->picture);
727 ret = ff_thread_get_buffer(avctx, p, 0);
733 ret = ff_thread_get_ext_buffer(avctx, &s->picture,
737 ret = ff_thread_get_buffer(avctx, p, 0);
742 if ((ret = ff_thread_get_ext_buffer(avctx, &s->picture,
754 ff_thread_finish_setup(avctx);
766 ff_dlog(avctx, "row_size=%d crow_size =%d\n",
770 if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
810 static int decode_plte_chunk(AVCodecContext *avctx, PNGDecContext *s,
833 static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
840 av_log(avctx, AV_LOG_ERROR, "trns before IHDR\n");
845 av_log(avctx, AV_LOG_ERROR, "trns after IDAT\n");
888 av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid name!\n");
894 av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid compression!\n");
899 if ((ret = decode_zbuf(&bp, gb->buffer, gb->buffer_end, s->avctx)) < 0)
987 static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
997 av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n");
1002 av_log(avctx, AV_LOG_ERROR, "fctl after IDAT\n");
1026 av_log(avctx, AV_LOG_ERROR, "Invalid blend_op %d\n", blend_op);
1038 avctx->pix_fmt == AV_PIX_FMT_RGB24 ||
1039 avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
1040 avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
1041 avctx->pix_fmt == AV_PIX_FMT_GRAY16BE ||
1042 avctx->pix_fmt == AV_PIX_FMT_MONOBLACK
1080 static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
1092 avctx->pix_fmt != AV_PIX_FMT_RGBA &&
1093 avctx->pix_fmt != AV_PIX_FMT_GRAY8A) {
1094 avpriv_request_sample(avctx, "Blending with pixel format %s",
1095 av_get_pix_fmt_name(avctx->pix_fmt));
1127 switch (avctx->pix_fmt) {
1185 static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
1199 if (avctx->codec_id == AV_CODEC_ID_PNG &&
1200 avctx->skip_frame == AVDISCARD_ALL) {
1204 if (CONFIG_APNG_DECODER && avctx->codec_id == AV_CODEC_ID_APNG && length == 0) {
1210 av_log(avctx, AV_LOG_ERROR, "%d bytes left\n", length);
1212 && avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL)
1220 av_log(avctx, AV_LOG_ERROR, "chunk too big\n");
1224 if (avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_IGNORE_ERR)) {
1228 av_log(avctx, AV_LOG_ERROR, "CRC mismatch in chunk");
1229 if (avctx->err_recognition & AV_EF_EXPLODE) {
1230 av_log(avctx, AV_LOG_ERROR, ", quitting\n");
1234 av_log(avctx, AV_LOG_ERROR, ", skipping\n");
1240 if (avctx->debug & FF_DEBUG_STARTCODE)
1241 av_log(avctx, AV_LOG_DEBUG, "png: tag=%s length=%u\n",
1247 if (avctx->codec_id == AV_CODEC_ID_PNG &&
1248 avctx->skip_frame == AVDISCARD_ALL) {
1263 if ((ret = decode_ihdr_chunk(avctx, s, &gb_chunk)) < 0)
1267 if ((ret = decode_phys_chunk(avctx, s, &gb_chunk)) < 0)
1271 if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG)
1273 if ((ret = decode_fctl_chunk(avctx, s, &gb_chunk)) < 0)
1278 if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG)
1287 if (CONFIG_APNG_DECODER && avctx->codec_id == AV_CODEC_ID_APNG && !decode_next_dat)
1289 if ((ret = decode_idat_chunk(avctx, s, &gb_chunk, p)) < 0)
1293 decode_plte_chunk(avctx, s, &gb_chunk);
1296 decode_trns_chunk(avctx, s, &gb_chunk);
1300 av_log(avctx, AV_LOG_WARNING, "Broken tEXt chunk\n");
1304 av_log(avctx, AV_LOG_WARNING, "Broken zTXt chunk\n");
1312 av_log(avctx, AV_LOG_WARNING,
1353 av_log(avctx, AV_LOG_ERROR, "IEND without all image\n");
1366 if (avctx->codec_id == AV_CODEC_ID_PNG &&
1367 avctx->skip_frame == AVDISCARD_ALL) {
1371 if (percent_missing(s) > avctx->discard_damaged_percentage)
1377 if (s->color_type == PNG_COLOR_TYPE_PALETTE && avctx->codec_id == AV_CODEC_ID_APNG) {
1439 if ( !(avpkt->flags & AV_PKT_FLAG_KEY) && avctx->codec_tag != AV_RL32("MPNG")
1444 if (CONFIG_PNG_DECODER && avctx->codec_id != AV_CODEC_ID_APNG)
1447 avctx->codec_id == AV_CODEC_ID_APNG &&
1448 (ret = handle_p_frame_apng(avctx, s, p)) < 0)
1531 static int decode_frame_png(AVCodecContext *avctx, AVFrame *p,
1534 PNGDecContext *const s = avctx->priv_data;
1548 av_log(avctx, AV_LOG_ERROR, "Invalid PNG signature 0x%08"PRIX64".\n", sig);
1561 if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
1564 if (avctx->skip_frame == AVDISCARD_ALL) {
1574 if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
1575 ff_thread_release_ext_buffer(avctx, &s->last_picture);
1589 static int decode_frame_apng(AVCodecContext *avctx, AVFrame *p,
1592 PNGDecContext *const s = avctx->priv_data;
1598 if (!avctx->extradata_size)
1603 bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size);
1604 if ((ret = decode_frame_common(avctx, s, NULL, avpkt)) < 0)
1614 if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
1618 av_log(avctx, AV_LOG_WARNING, "Frame did not contain a complete image\n");
1626 if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
1628 ff_thread_release_ext_buffer(avctx, &s->picture);
1630 ff_thread_release_ext_buffer(avctx, &s->last_picture);
1682 static av_cold int png_dec_init(AVCodecContext *avctx)
1684 PNGDecContext *s = avctx->priv_data;
1686 avctx->color_range = AVCOL_RANGE_JPEG;
1688 s->avctx = avctx;
1696 return ff_inflate_init(&s->zstream, avctx);
1699 static av_cold int png_dec_end(AVCodecContext *avctx)
1701 PNGDecContext *s = avctx->priv_data;
1703 ff_thread_release_ext_buffer(avctx, &s->last_picture);
1705 ff_thread_release_ext_buffer(avctx, &s->picture);