mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
avcodecc/cscd: fix some obvious style issues
This commit is contained in:
parent
aa76bdea1f
commit
94437e4409
@ -38,7 +38,8 @@ typedef struct CamStudioContext {
|
|||||||
} CamStudioContext;
|
} CamStudioContext;
|
||||||
|
|
||||||
static void copy_frame_default(AVFrame *f, const uint8_t *src,
|
static void copy_frame_default(AVFrame *f, const uint8_t *src,
|
||||||
int linelen, int height) {
|
int linelen, int height)
|
||||||
|
{
|
||||||
int i, src_stride = FFALIGN(linelen, 4);
|
int i, src_stride = FFALIGN(linelen, 4);
|
||||||
uint8_t *dst = f->data[0];
|
uint8_t *dst = f->data[0];
|
||||||
dst += (height - 1) * f->linesize[0];
|
dst += (height - 1) * f->linesize[0];
|
||||||
@ -50,7 +51,8 @@ static void copy_frame_default(AVFrame *f, const uint8_t *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void add_frame_default(AVFrame *f, const uint8_t *src,
|
static void add_frame_default(AVFrame *f, const uint8_t *src,
|
||||||
int linelen, int height) {
|
int linelen, int height)
|
||||||
|
{
|
||||||
int i, j, src_stride = FFALIGN(linelen, 4);
|
int i, j, src_stride = FFALIGN(linelen, 4);
|
||||||
uint8_t *dst = f->data[0];
|
uint8_t *dst = f->data[0];
|
||||||
dst += (height - 1) * f->linesize[0];
|
dst += (height - 1) * f->linesize[0];
|
||||||
@ -63,7 +65,8 @@ static void add_frame_default(AVFrame *f, const uint8_t *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
AVPacket *avpkt) {
|
AVPacket *avpkt)
|
||||||
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
CamStudioContext *c = avctx->priv_data;
|
CamStudioContext *c = avctx->priv_data;
|
||||||
@ -79,30 +82,30 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
|
|
||||||
// decompress data
|
// decompress data
|
||||||
switch ((buf[0] >> 1) & 7) {
|
switch ((buf[0] >> 1) & 7) {
|
||||||
case 0: { // lzo compression
|
case 0: { // lzo compression
|
||||||
int outlen = c->decomp_size, inlen = buf_size - 2;
|
int outlen = c->decomp_size, inlen = buf_size - 2;
|
||||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || outlen) {
|
if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || outlen) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: { // zlib compression
|
|
||||||
#if CONFIG_ZLIB
|
|
||||||
unsigned long dlen = c->decomp_size;
|
|
||||||
if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
|
|
||||||
return AVERROR(ENOSYS);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: { // zlib compression
|
||||||
|
#if CONFIG_ZLIB
|
||||||
|
unsigned long dlen = c->decomp_size;
|
||||||
|
if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// flip upside down, add difference frame
|
// flip upside down, add difference frame
|
||||||
@ -125,18 +128,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int decode_init(AVCodecContext *avctx) {
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
CamStudioContext *c = avctx->priv_data;
|
CamStudioContext *c = avctx->priv_data;
|
||||||
int stride;
|
int stride;
|
||||||
switch (avctx->bits_per_coded_sample) {
|
switch (avctx->bits_per_coded_sample) {
|
||||||
case 16: avctx->pix_fmt = AV_PIX_FMT_RGB555LE; break;
|
case 16: avctx->pix_fmt = AV_PIX_FMT_RGB555LE; break;
|
||||||
case 24: avctx->pix_fmt = AV_PIX_FMT_BGR24; break;
|
case 24: avctx->pix_fmt = AV_PIX_FMT_BGR24; break;
|
||||||
case 32: avctx->pix_fmt = AV_PIX_FMT_BGR0; break;
|
case 32: avctx->pix_fmt = AV_PIX_FMT_BGR0; break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"CamStudio codec error: invalid depth %i bpp\n",
|
"CamStudio codec error: invalid depth %i bpp\n",
|
||||||
avctx->bits_per_coded_sample);
|
avctx->bits_per_coded_sample);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
c->bpp = avctx->bits_per_coded_sample;
|
c->bpp = avctx->bits_per_coded_sample;
|
||||||
c->linelen = avctx->width * avctx->bits_per_coded_sample / 8;
|
c->linelen = avctx->width * avctx->bits_per_coded_sample / 8;
|
||||||
@ -154,7 +158,8 @@ static av_cold int decode_init(AVCodecContext *avctx) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int decode_end(AVCodecContext *avctx) {
|
static av_cold int decode_end(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
CamStudioContext *c = avctx->priv_data;
|
CamStudioContext *c = avctx->priv_data;
|
||||||
av_freep(&c->decomp_buf);
|
av_freep(&c->decomp_buf);
|
||||||
av_frame_free(&c->pic);
|
av_frame_free(&c->pic);
|
||||||
|
Loading…
Reference in New Issue
Block a user