| 123 | } |
| 124 | |
| 125 | int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, |
| 126 | const AVFrame *frame, AVFrame **alt_frame_ptr, |
| 127 | WebPPicture **pic_ptr) { |
| 128 | int ret; |
| 129 | WebPPicture *pic = NULL; |
| 130 | AVFrame *alt_frame = NULL; |
| 131 | |
| 132 | if (avctx->width > WEBP_MAX_DIMENSION || avctx->height > WEBP_MAX_DIMENSION) { |
| 133 | av_log(avctx, AV_LOG_ERROR, "Picture size is too large. Max is %dx%d.\n", |
| 134 | WEBP_MAX_DIMENSION, WEBP_MAX_DIMENSION); |
| 135 | return AVERROR(EINVAL); |
| 136 | } |
| 137 | |
| 138 | *pic_ptr = av_malloc(sizeof(*pic)); |
| 139 | pic = *pic_ptr; |
| 140 | if (!pic) |
| 141 | return AVERROR(ENOMEM); |
| 142 | |
| 143 | ret = WebPPictureInit(pic); |
| 144 | if (!ret) { |
| 145 | ret = AVERROR_UNKNOWN; |
| 146 | goto end; |
| 147 | } |
| 148 | pic->width = avctx->width; |
| 149 | pic->height = avctx->height; |
| 150 | |
| 151 | if (avctx->pix_fmt == AV_PIX_FMT_RGB32) { |
| 152 | if (!s->lossless) { |
| 153 | /* libwebp will automatically convert RGB input to YUV when |
| 154 | encoding lossy. */ |
| 155 | if (!s->conversion_warning) { |
| 156 | av_log(avctx, AV_LOG_WARNING, |
| 157 | "Using libwebp for RGB-to-YUV conversion. You may want " |
| 158 | "to consider passing in YUV instead for lossy " |
| 159 | "encoding.\n"); |
| 160 | s->conversion_warning = 1; |
| 161 | } |
| 162 | } |
| 163 | pic->use_argb = 1; |
| 164 | pic->argb = (uint32_t *)frame->data[0]; |
| 165 | pic->argb_stride = frame->linesize[0] / 4; |
| 166 | } else { |
| 167 | if (frame->linesize[1] != frame->linesize[2] || s->cr_threshold) { |
| 168 | if (!s->chroma_warning && !s->cr_threshold) { |
| 169 | av_log(avctx, AV_LOG_WARNING, |
| 170 | "Copying frame due to differing chroma linesizes.\n"); |
| 171 | s->chroma_warning = 1; |
| 172 | } |
| 173 | *alt_frame_ptr = av_frame_alloc(); |
| 174 | alt_frame = *alt_frame_ptr; |
| 175 | if (!alt_frame) { |
| 176 | ret = AVERROR(ENOMEM); |
| 177 | goto end; |
| 178 | } |
| 179 | alt_frame->width = frame->width; |
| 180 | alt_frame->height = frame->height; |
| 181 | alt_frame->format = frame->format; |
| 182 | if (s->cr_threshold) |
no test coverage detected