From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 5/8] avcodec/cyuv: Remove useless private context Date: Tue, 18 Oct 2022 15:31:23 +0200 Message-ID: <AS8P250MB07442D28006DD51DAA3174E18F289@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB074414DC2B75D14AB9E380ED8F289@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> It just contains duplicates of values from AVCodecContext as well as an write-only pointer to said AVCodecContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/cyuv.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) 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, -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-10-18 13:31 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-18 13:29 [FFmpeg-devel] [PATCH 1/8] avformat/mj2kdec: Remove always-true #if CONFIG_MJPEG_2000_DEMUXER Andreas Rheinhardt 2022-10-18 13:31 ` [FFmpeg-devel] [PATCH 2/8] avcodec/speedhqenc: Remove always-true #if CONFIG_SPEEDHQ_ENCODER Andreas Rheinhardt 2022-10-18 13:31 ` [FFmpeg-devel] [PATCH 3/8] avcodec/nvdec_mjpeg: Remove always-true #if CONFIG_MJPEG_NVDEC_HWACCEL Andreas Rheinhardt 2022-10-18 23:42 ` Philip Langdale 2022-10-18 13:31 ` Andreas Rheinhardt [this message] 2022-10-18 13:31 ` [FFmpeg-devel] [PATCH 6/8] avcodec/metasound: Remove always-false checks Andreas Rheinhardt 2022-10-18 13:31 ` [FFmpeg-devel] [PATCH 7/8] avcodec/speedhq: Rename file to speedhqdec.c, move ff_rl_speedhq out Andreas Rheinhardt 2022-10-18 13:31 ` [FFmpeg-devel] [PATCH 8/8] avcodec/metasound: Remove unnecessary headers Andreas Rheinhardt 2022-10-18 13:41 ` [FFmpeg-devel] [PATCH 9/9] avcodec/speedhqdec: Remove write-only AVCodecContext* Andreas Rheinhardt 2022-10-18 22:18 ` [FFmpeg-devel] [PATCH 1/8] avformat/mj2kdec: Remove always-true #if CONFIG_MJPEG_2000_DEMUXER Andreas Rheinhardt 2022-10-20 14:11 ` Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS8P250MB07442D28006DD51DAA3174E18F289@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git