diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index f233b362dc..0765f41ca3 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -37,22 +37,11 @@ #include "decode.h" #include "libavutil/internal.h" - -typedef struct CyuvDecodeContext { - AVCodecContext *avctx; - int width, height; -} CyuvDecodeContext; - static av_cold int cyuv_decode_init(AVCodecContext *avctx) { - CyuvDecodeContext *s = avctx->priv_data; - - s->avctx = avctx; - s->width = avctx->width; /* width needs to be divisible by 4 for this codec to work */ - if (s->width & 0x3) + if (avctx->width & 0x3) return AVERROR_INVALIDDATA; - s->height = avctx->height; return 0; } @@ -62,7 +51,6 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - CyuvDecodeContext *s=avctx->priv_data; unsigned char *y_plane; unsigned char *u_plane; @@ -80,7 +68,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, int stream_ptr; unsigned char cur_byte; int pixel_groups; - int rawsize = s->height * FFALIGN(s->width,2) * 2; + int rawsize = avctx->height * FFALIGN(avctx->width,2) * 2; int ret; if (avctx->codec_id == AV_CODEC_ID_AURA) { @@ -91,13 +79,13 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, * followed by (height) lines each with 3 bytes to represent groups * of 4 pixels. Thus, the total size of the buffer ought to be: * (3 * 16) + height * (width * 3 / 4) */ - if (buf_size == 48 + s->height * (s->width * 3 / 4)) { + if (buf_size == 48 + avctx->height * (avctx->width * 3 / 4)) { avctx->pix_fmt = AV_PIX_FMT_YUV411P; } else if(buf_size == rawsize ) { avctx->pix_fmt = AV_PIX_FMT_UYVY422; } else { av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n", - buf_size, 48 + s->height * (s->width * 3 / 4)); + buf_size, 48 + avctx->height * (avctx->width * 3 / 4)); return AVERROR_INVALIDDATA; } @@ -112,8 +100,8 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, v_plane = frame->data[2]; if (buf_size == rawsize) { - int linesize = FFALIGN(s->width,2) * 2; - y_plane += frame->linesize[0] * s->height; + int linesize = FFALIGN(avctx->width, 2) * 2; + y_plane += frame->linesize[0] * avctx->height; for (stream_ptr = 0; stream_ptr < rawsize; stream_ptr += linesize) { y_plane -= frame->linesize[0]; memcpy(y_plane, buf+stream_ptr, linesize); @@ -122,10 +110,10 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, /* iterate through each line in the height */ for (y_ptr = 0, u_ptr = 0, v_ptr = 0; - y_ptr < (s->height * frame->linesize[0]); - y_ptr += frame->linesize[0] - s->width, - u_ptr += frame->linesize[1] - s->width / 4, - v_ptr += frame->linesize[2] - s->width / 4) { + y_ptr < (avctx->height * frame->linesize[0]); + y_ptr += frame->linesize[0] - avctx->width, + u_ptr += frame->linesize[1] - avctx->width / 4, + v_ptr += frame->linesize[2] - avctx->width / 4) { /* reset predictors */ cur_byte = buf[stream_ptr++]; @@ -144,7 +132,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, y_plane[y_ptr++] = y_pred; /* iterate through the remaining pixel groups (4 pixels/group) */ - pixel_groups = s->width / 4 - 1; + pixel_groups = avctx->width / 4 - 1; while (pixel_groups--) { cur_byte = buf[stream_ptr++]; @@ -180,7 +168,6 @@ const FFCodec ff_aura_decoder = { CODEC_LONG_NAME("Auravision AURA"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AURA, - .priv_data_size = sizeof(CyuvDecodeContext), .init = cyuv_decode_init, FF_CODEC_DECODE_CB(cyuv_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1, @@ -193,7 +180,6 @@ const FFCodec ff_cyuv_decoder = { CODEC_LONG_NAME("Creative YUV (CYUV)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CYUV, - .priv_data_size = sizeof(CyuvDecodeContext), .init = cyuv_decode_init, FF_CODEC_DECODE_CB(cyuv_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1,