Lines Matching defs:avctx
80 static av_cold int decode_init(AVCodecContext *avctx)
82 AnsiContext *s = avctx->priv_data;
83 avctx->pix_fmt = AV_PIX_FMT_PAL8;
91 if (!avctx->width || !avctx->height) {
92 int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
95 } else if (avctx->width % FONT_WIDTH || avctx->height % s->font_height) {
96 av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %d %d\n", avctx->width, avctx->height);
122 static void hscroll(AVCodecContext *avctx)
124 AnsiContext *s = avctx->priv_data;
127 if (s->y <= avctx->height - 2*s->font_height) {
133 for (; i < avctx->height - s->font_height; i++)
136 avctx->width);
137 for (; i < avctx->height; i++)
139 DEFAULT_BG_COLOR, avctx->width);
142 static void erase_line(AVCodecContext * avctx, int xoffset, int xlength)
144 AnsiContext *s = avctx->priv_data;
151 static void erase_screen(AVCodecContext *avctx)
153 AnsiContext *s = avctx->priv_data;
155 for (i = 0; i < avctx->height; i++)
156 memset(s->frame->data[0] + i * s->frame->linesize[0], DEFAULT_BG_COLOR, avctx->width);
163 static void draw_char(AVCodecContext *avctx, int c)
165 AnsiContext *s = avctx->priv_data;
180 if (s->x > avctx->width - FONT_WIDTH) {
182 hscroll(avctx);
190 static int execute_code(AVCodecContext * avctx, int c)
192 AnsiContext *s = avctx->priv_data;
194 int width = avctx->width;
195 int height = avctx->height;
202 s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
205 s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
212 s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
213 s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
253 avpriv_request_sample(avctx, "Unsupported screen mode");
257 if (width != avctx->width || height != avctx->height) {
259 ret = ff_set_dimensions(avctx, width, height);
262 if ((ret = ff_get_buffer(avctx, s->frame,
268 erase_screen(avctx);
270 erase_screen(avctx);
276 erase_line(avctx, s->x, avctx->width - s->x);
277 if (s->y < avctx->height - s->font_height)
279 DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame->linesize[0]);
282 erase_line(avctx, 0, s->x);
287 erase_screen(avctx);
293 erase_line(avctx, s->x, avctx->width - s->x);
296 erase_line(avctx, 0, s->x);
299 erase_line(avctx, 0, avctx->width);
332 avpriv_request_sample(avctx, "Unsupported rendition parameter");
345 s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
346 s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
349 avpriv_request_sample(avctx, "Unknown escape code");
352 s->x = av_clip(s->x, 0, avctx->width - FONT_WIDTH);
353 s->y = av_clip(s->y, 0, avctx->height - s->font_height);
357 static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
360 AnsiContext *s = avctx->priv_data;
366 if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
368 if (!avctx->frame_number) {
369 for (i=0; i<avctx->height; i++)
370 memset(s->frame->data[0]+ i*s->frame->linesize[0], 0, avctx->width);
378 erase_screen(avctx);
398 draw_char(avctx, ' ');
401 hscroll(avctx);
406 erase_screen(avctx);
412 draw_char(avctx, buf[0]);
422 draw_char(avctx, 0x1B);
447 av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args);
450 if ((ret = execute_code(avctx, buf[0])) < 0)
470 static av_cold int decode_close(AVCodecContext *avctx)
472 AnsiContext *s = avctx->priv_data;