}
}
-static void hnm_flip_buffers(Hnm4VideoContext *hnm)
-{
- uint8_t *temp;
-
- temp = hnm->current;
- hnm->current = hnm->previous;
- hnm->previous = temp;
-}
-
static int hnm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
frame->key_frame = 0;
memcpy(frame->data[1], hnm->palette, 256 * 4);
*got_frame = 1;
- hnm_flip_buffers(hnm);
+ FFSWAP(uint8_t *, hnm->current, hnm->previous);
} else {
av_log(avctx, AV_LOG_ERROR, "invalid chunk id: %d\n", chunk_id);
return AVERROR_INVALIDDATA;
ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
if (ret < 0)
return ret;
+ if (avctx->height & 1)
+ return AVERROR(EINVAL);
hnm->version = avctx->extradata[0];
avctx->pix_fmt = AV_PIX_FMT_PAL8;
hnm->buffer2 = av_mallocz(avctx->width * avctx->height);
hnm->processed = av_mallocz(avctx->width * avctx->height);
- if ( !hnm->buffer1 || !hnm->buffer2 || !hnm->processed
- || avctx->width * avctx->height == 0
- || avctx->height % 2) {
+ if (!hnm->buffer1 || !hnm->buffer2 || !hnm->processed) {
av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n");
return AVERROR(ENOMEM);
}
return 0;
}
-AVCodec ff_hnm4_video_decoder = {
+const AVCodec ff_hnm4_video_decoder = {
.name = "hnm4video",
.long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"),
.type = AVMEDIA_TYPE_VIDEO,