avcodec/cyuv: Remove useless private context
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>
This commit is contained in:
parent
20a1296bb4
commit
d94a445e3d
@ -37,22 +37,11 @@
|
|||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct CyuvDecodeContext {
|
|
||||||
AVCodecContext *avctx;
|
|
||||||
int width, height;
|
|
||||||
} CyuvDecodeContext;
|
|
||||||
|
|
||||||
static av_cold int cyuv_decode_init(AVCodecContext *avctx)
|
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 */
|
/* width needs to be divisible by 4 for this codec to work */
|
||||||
if (s->width & 0x3)
|
if (avctx->width & 0x3)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
s->height = avctx->height;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -62,7 +51,6 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
|||||||
{
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
CyuvDecodeContext *s=avctx->priv_data;
|
|
||||||
|
|
||||||
unsigned char *y_plane;
|
unsigned char *y_plane;
|
||||||
unsigned char *u_plane;
|
unsigned char *u_plane;
|
||||||
@ -80,7 +68,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
|||||||
int stream_ptr;
|
int stream_ptr;
|
||||||
unsigned char cur_byte;
|
unsigned char cur_byte;
|
||||||
int pixel_groups;
|
int pixel_groups;
|
||||||
int rawsize = s->height * FFALIGN(s->width,2) * 2;
|
int rawsize = avctx->height * FFALIGN(avctx->width,2) * 2;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (avctx->codec_id == AV_CODEC_ID_AURA) {
|
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
|
* followed by (height) lines each with 3 bytes to represent groups
|
||||||
* of 4 pixels. Thus, the total size of the buffer ought to be:
|
* of 4 pixels. Thus, the total size of the buffer ought to be:
|
||||||
* (3 * 16) + height * (width * 3 / 4) */
|
* (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;
|
avctx->pix_fmt = AV_PIX_FMT_YUV411P;
|
||||||
} else if(buf_size == rawsize ) {
|
} else if(buf_size == rawsize ) {
|
||||||
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
|
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n",
|
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;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +100,8 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
|||||||
v_plane = frame->data[2];
|
v_plane = frame->data[2];
|
||||||
|
|
||||||
if (buf_size == rawsize) {
|
if (buf_size == rawsize) {
|
||||||
int linesize = FFALIGN(s->width,2) * 2;
|
int linesize = FFALIGN(avctx->width, 2) * 2;
|
||||||
y_plane += frame->linesize[0] * s->height;
|
y_plane += frame->linesize[0] * avctx->height;
|
||||||
for (stream_ptr = 0; stream_ptr < rawsize; stream_ptr += linesize) {
|
for (stream_ptr = 0; stream_ptr < rawsize; stream_ptr += linesize) {
|
||||||
y_plane -= frame->linesize[0];
|
y_plane -= frame->linesize[0];
|
||||||
memcpy(y_plane, buf+stream_ptr, linesize);
|
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 */
|
/* iterate through each line in the height */
|
||||||
for (y_ptr = 0, u_ptr = 0, v_ptr = 0;
|
for (y_ptr = 0, u_ptr = 0, v_ptr = 0;
|
||||||
y_ptr < (s->height * frame->linesize[0]);
|
y_ptr < (avctx->height * frame->linesize[0]);
|
||||||
y_ptr += frame->linesize[0] - s->width,
|
y_ptr += frame->linesize[0] - avctx->width,
|
||||||
u_ptr += frame->linesize[1] - s->width / 4,
|
u_ptr += frame->linesize[1] - avctx->width / 4,
|
||||||
v_ptr += frame->linesize[2] - s->width / 4) {
|
v_ptr += frame->linesize[2] - avctx->width / 4) {
|
||||||
|
|
||||||
/* reset predictors */
|
/* reset predictors */
|
||||||
cur_byte = buf[stream_ptr++];
|
cur_byte = buf[stream_ptr++];
|
||||||
@ -144,7 +132,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
|||||||
y_plane[y_ptr++] = y_pred;
|
y_plane[y_ptr++] = y_pred;
|
||||||
|
|
||||||
/* iterate through the remaining pixel groups (4 pixels/group) */
|
/* iterate through the remaining pixel groups (4 pixels/group) */
|
||||||
pixel_groups = s->width / 4 - 1;
|
pixel_groups = avctx->width / 4 - 1;
|
||||||
while (pixel_groups--) {
|
while (pixel_groups--) {
|
||||||
|
|
||||||
cur_byte = buf[stream_ptr++];
|
cur_byte = buf[stream_ptr++];
|
||||||
@ -180,7 +168,6 @@ const FFCodec ff_aura_decoder = {
|
|||||||
CODEC_LONG_NAME("Auravision AURA"),
|
CODEC_LONG_NAME("Auravision AURA"),
|
||||||
.p.type = AVMEDIA_TYPE_VIDEO,
|
.p.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.p.id = AV_CODEC_ID_AURA,
|
.p.id = AV_CODEC_ID_AURA,
|
||||||
.priv_data_size = sizeof(CyuvDecodeContext),
|
|
||||||
.init = cyuv_decode_init,
|
.init = cyuv_decode_init,
|
||||||
FF_CODEC_DECODE_CB(cyuv_decode_frame),
|
FF_CODEC_DECODE_CB(cyuv_decode_frame),
|
||||||
.p.capabilities = AV_CODEC_CAP_DR1,
|
.p.capabilities = AV_CODEC_CAP_DR1,
|
||||||
@ -193,7 +180,6 @@ const FFCodec ff_cyuv_decoder = {
|
|||||||
CODEC_LONG_NAME("Creative YUV (CYUV)"),
|
CODEC_LONG_NAME("Creative YUV (CYUV)"),
|
||||||
.p.type = AVMEDIA_TYPE_VIDEO,
|
.p.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.p.id = AV_CODEC_ID_CYUV,
|
.p.id = AV_CODEC_ID_CYUV,
|
||||||
.priv_data_size = sizeof(CyuvDecodeContext),
|
|
||||||
.init = cyuv_decode_init,
|
.init = cyuv_decode_init,
|
||||||
FF_CODEC_DECODE_CB(cyuv_decode_frame),
|
FF_CODEC_DECODE_CB(cyuv_decode_frame),
|
||||||
.p.capabilities = AV_CODEC_CAP_DR1,
|
.p.capabilities = AV_CODEC_CAP_DR1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user