Lines Matching defs:avctx

100 static int is_image_translucent(AVCodecContext *avctx,
103 GIFContext *s = avctx->priv_data;
109 for (int y = 0; y < avctx->height; y++) {
110 for (int x = 0; x < avctx->width; x++) {
155 static void gif_crop_translucent(AVCodecContext *avctx,
160 GIFContext *s = avctx->priv_data;
165 const int w = avctx->width;
166 const int h = avctx->height;
229 av_log(avctx, AV_LOG_DEBUG,"%dx%d image at pos (%d;%d) [area:%dx%d]\n",
230 *width, *height, *x_start, *y_start, avctx->width, avctx->height);
234 static void gif_crop_opaque(AVCodecContext *avctx,
239 GIFContext *s = avctx->priv_data;
245 int x_end = avctx->width - 1,
246 y_end = avctx->height - 1;
288 av_log(avctx, AV_LOG_DEBUG,"%dx%d image at pos (%d;%d) [area:%dx%d]\n",
289 *width, *height, *x_start, *y_start, avctx->width, avctx->height);
293 static int gif_image_write_image(AVCodecContext *avctx,
299 GIFContext *s = avctx->priv_data;
300 int disposal, len = 0, height = avctx->height, width = avctx->width, x, y;
316 if (!s->image && is_image_translucent(avctx, buf, linesize)) {
317 gif_crop_translucent(avctx, buf, linesize, &width, &height, &x_start, &y_start);
321 gif_crop_opaque(avctx, palette, buf, linesize, &width, &height, &x_start, &y_start);
325 if (s->image || !avctx->frame_number) { /* GIF header */
327 const AVRational sar = avctx->sample_aspect_ratio;
337 bytestream_put_le16(bytestream, avctx->width);
338 bytestream_put_le16(bytestream, avctx->height);
357 av_log(avctx, AV_LOG_DEBUG, "No available color, can not use transparency\n");
406 s->shrunk_buf = av_malloc(avctx->height * linesize);
408 av_log(avctx, AV_LOG_ERROR, "Could not allocated remapped frame buffer.\n");
412 remap_frame_to_palette(buf, linesize, s->shrunk_buf, linesize, avctx->width, avctx->height, map);
452 static av_cold int gif_encode_init(AVCodecContext *avctx)
454 GIFContext *s = avctx->priv_data;
456 if (avctx->width > 65535 || avctx->height > 65535) {
457 av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
464 s->buf_size = avctx->width*avctx->height*2 + 1000;
466 s->tmpl = av_malloc(avctx->width);
470 if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0)
471 av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8);
476 static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
479 GIFContext *s = avctx->priv_data;
484 if ((ret = ff_alloc_packet(avctx, pkt, avctx->width*avctx->height*7/5 + AV_INPUT_BUFFER_MIN_SIZE)) < 0)
489 if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
501 gif_image_write_image(avctx, &outbuf_ptr, end, palette,
517 if (s->image || !avctx->frame_number)
524 static int gif_encode_close(AVCodecContext *avctx)
526 GIFContext *s = avctx->priv_data;