mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 03:59:43 +00:00
cin video: use the AVFrame API properly.
This commit is contained in:
parent
ef2a99c7f4
commit
01de3c1dd5
@ -39,7 +39,7 @@ typedef enum CinVideoBitmapIndex {
|
|||||||
|
|
||||||
typedef struct CinVideoContext {
|
typedef struct CinVideoContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
unsigned int bitmap_size;
|
unsigned int bitmap_size;
|
||||||
uint32_t palette[256];
|
uint32_t palette[256];
|
||||||
uint8_t *bitmap_table[3];
|
uint8_t *bitmap_table[3];
|
||||||
@ -96,7 +96,9 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
|
|||||||
cin->avctx = avctx;
|
cin->avctx = avctx;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&cin->frame);
|
cin->frame = av_frame_alloc();
|
||||||
|
if (!cin->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
cin->bitmap_size = avctx->width * avctx->height;
|
cin->bitmap_size = avctx->width * avctx->height;
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
@ -295,23 +297,23 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = ff_reget_buffer(avctx, &cin->frame)) < 0) {
|
if ((res = ff_reget_buffer(avctx, cin->frame)) < 0) {
|
||||||
av_log(cin->avctx, AV_LOG_ERROR,
|
av_log(cin->avctx, AV_LOG_ERROR,
|
||||||
"delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
"delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
|
memcpy(cin->frame->data[1], cin->palette, sizeof(cin->palette));
|
||||||
cin->frame.palette_has_changed = 1;
|
cin->frame->palette_has_changed = 1;
|
||||||
for (y = 0; y < cin->avctx->height; ++y)
|
for (y = 0; y < cin->avctx->height; ++y)
|
||||||
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
|
memcpy(cin->frame->data[0] + (cin->avctx->height - 1 - y) * cin->frame->linesize[0],
|
||||||
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
||||||
cin->avctx->width);
|
cin->avctx->width);
|
||||||
|
|
||||||
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP],
|
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP],
|
||||||
cin->bitmap_table[CIN_PRE_BMP]);
|
cin->bitmap_table[CIN_PRE_BMP]);
|
||||||
|
|
||||||
if ((res = av_frame_ref(data, &cin->frame)) < 0)
|
if ((res = av_frame_ref(data, cin->frame)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@ -324,7 +326,7 @@ static av_cold int cinvideo_decode_end(AVCodecContext *avctx)
|
|||||||
CinVideoContext *cin = avctx->priv_data;
|
CinVideoContext *cin = avctx->priv_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
av_frame_unref(&cin->frame);
|
av_frame_free(&cin->frame);
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < 3; ++i)
|
||||||
av_free(cin->bitmap_table[i]);
|
av_free(cin->bitmap_table[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user