0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15
};
-typedef struct {
+typedef struct AnsiContext {
AVFrame *frame;
int x; /**< x cursor position (pixels) */
int y; /**< y cursor position (pixels) */
s->fg = DEFAULT_FG_COLOR;
s->bg = DEFAULT_BG_COLOR;
- if (!avctx->width || !avctx->height)
- ff_set_dimensions(avctx, 80 << 3, 25 << 4);
-
+ if (!avctx->width || !avctx->height) {
+ int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
+ if (ret < 0)
+ return ret;
+ }
return 0;
}
static int execute_code(AVCodecContext * avctx, int c)
{
AnsiContext *s = avctx->priv_data;
- int ret, i, width, height;
+ int ret, i;
+ int width = 0;
+ int height = 0;
+
switch(c) {
case 'A': //Cursor Up
s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
break;
- case 'h': //set creen mode
+ case 'h': //set screen mode
case 'l': //reset screen mode
if (s->nb_args < 2)
s->args[0] = DEFAULT_SCREEN_MODE;
default:
avpriv_request_sample(avctx, "Unsupported screen mode");
}
- if (width != avctx->width || height != avctx->height) {
+ if (width != 0 && height != 0 &&
+ (width != avctx->width || height != avctx->height)) {
av_frame_unref(s->frame);
ret = ff_set_dimensions(avctx, width, height);
if (ret < 0)
.init = decode_init,
.close = decode_close,
.decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};