return AVERROR_INVALIDDATA;
}
- if (w != avctx->width || h != avctx->height)
- avcodec_set_dimensions(avctx, w, h);
+ ret = ff_set_dimensions(avctx, w, h);
+ if (ret < 0)
+ return ret;
+
- if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
- }
p->pict_type = AV_PICTURE_TYPE_I;
return AVERROR_INVALIDDATA;
}
- if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
+ if (colors && (colors + first_clr) > 256) {
+ av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
+ return AVERROR_INVALIDDATA;
+ }
+
+ if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
- if (w != avctx->width || h != avctx->height)
- avcodec_set_dimensions(avctx, w, h);
+
- if ((ret = ff_get_buffer(avctx, p, 0)) < 0){
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
- }
- if(flags & 0x20){
+ p->pict_type = AV_PICTURE_TYPE_I;
+
+ if (flags & TGA_TOPTOBOTTOM) {
dst = p->data[0];
stride = p->linesize[0];
- }else{ //image is upside-down
+ } else { //image is upside-down
dst = p->data[0] + p->linesize[0] * (h - 1);
stride = -p->linesize[0];
}
return AVERROR_INVALIDDATA;
}
if (s->width != s->avctx->width || s->height != s->avctx->height) {
- if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
+ ret = ff_set_dimensions(s->avctx, s->width, s->height);
+ if (ret < 0)
return ret;
- avcodec_set_dimensions(s->avctx, s->width, s->height);
}
- if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ if ((ret = ff_thread_get_buffer(s->avctx, frame, 0)) < 0)
return ret;
- }
if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
if (s->palette_is_set) {
- memcpy(frame->data[1], s->palette, sizeof(s->palette));
+ memcpy(frame->f->data[1], s->palette, sizeof(s->palette));
} else {
/* make default grayscale pal */
- pal = (uint32_t *) frame->data[1];
- for (i = 0; i < 256; i++)
- pal[i] = i * 0x010101;
+ pal = (uint32_t *) frame->f->data[1];
+ for (i = 0; i < 1<<s->bpp; i++)
+ pal[i] = 0xFFU << 24 | i * 255 / ((1<<s->bpp) - 1) * 0x010101;
}
}
return 0;