mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-09-29 08:19:48 +02:00
dxa: use the AVFrame API properly.
This commit is contained in:
parent
55f954e767
commit
2d2a92f721
@ -38,7 +38,7 @@
|
|||||||
* Decoder context
|
* Decoder context
|
||||||
*/
|
*/
|
||||||
typedef struct DxaDecContext {
|
typedef struct DxaDecContext {
|
||||||
AVFrame prev;
|
AVFrame *prev;
|
||||||
|
|
||||||
int dsize;
|
int dsize;
|
||||||
uint8_t *decomp_buf;
|
uint8_t *decomp_buf;
|
||||||
@ -226,7 +226,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
|
|
||||||
outptr = frame->data[0];
|
outptr = frame->data[0];
|
||||||
srcptr = c->decomp_buf;
|
srcptr = c->decomp_buf;
|
||||||
tmpptr = c->prev.data[0];
|
tmpptr = c->prev->data[0];
|
||||||
stride = frame->linesize[0];
|
stride = frame->linesize[0];
|
||||||
|
|
||||||
if(buf[0]=='N' && buf[1]=='U' && buf[2]=='L' && buf[3]=='L')
|
if(buf[0]=='N' && buf[1]=='U' && buf[2]=='L' && buf[3]=='L')
|
||||||
@ -243,8 +243,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
case -1:
|
case -1:
|
||||||
frame->key_frame = 0;
|
frame->key_frame = 0;
|
||||||
frame->pict_type = AV_PICTURE_TYPE_P;
|
frame->pict_type = AV_PICTURE_TYPE_P;
|
||||||
if(c->prev.data[0])
|
if (c->prev->data[0])
|
||||||
memcpy(frame->data[0], c->prev.data[0], frame->linesize[0] * avctx->height);
|
memcpy(frame->data[0], c->prev->data[0], frame->linesize[0] * avctx->height);
|
||||||
else{ // Should happen only when first frame is 'NULL'
|
else{ // Should happen only when first frame is 'NULL'
|
||||||
memset(frame->data[0], 0, frame->linesize[0] * avctx->height);
|
memset(frame->data[0], 0, frame->linesize[0] * avctx->height);
|
||||||
frame->key_frame = 1;
|
frame->key_frame = 1;
|
||||||
@ -281,15 +281,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
case 13:
|
case 13:
|
||||||
frame->key_frame = 0;
|
frame->key_frame = 0;
|
||||||
frame->pict_type = AV_PICTURE_TYPE_P;
|
frame->pict_type = AV_PICTURE_TYPE_P;
|
||||||
decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev.data[0]);
|
decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", buf[4]);
|
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", buf[4]);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_frame_unref(&c->prev);
|
av_frame_unref(c->prev);
|
||||||
if ((ret = av_frame_ref(&c->prev, frame)) < 0)
|
if ((ret = av_frame_ref(c->prev, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@ -302,6 +302,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
DxaDecContext * const c = avctx->priv_data;
|
DxaDecContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
|
c->prev = av_frame_alloc();
|
||||||
|
if (!c->prev)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
c->dsize = avctx->width * avctx->height * 2;
|
c->dsize = avctx->width * avctx->height * 2;
|
||||||
@ -318,7 +322,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
|||||||
DxaDecContext * const c = avctx->priv_data;
|
DxaDecContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
av_freep(&c->decomp_buf);
|
av_freep(&c->decomp_buf);
|
||||||
av_frame_unref(&c->prev);
|
av_frame_free(&c->prev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user