mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.8 KiB
95 lines
2.8 KiB
22 years ago
|
/*
|
||
11 years ago
|
* Cirrus Logic AccuPak (CLJR) decoder
|
||
22 years ago
|
* Copyright (c) 2003 Alex Beregszaszi
|
||
|
*
|
||
11 years ago
|
* This file is part of FFmpeg.
|
||
18 years ago
|
*
|
||
11 years ago
|
* FFmpeg is free software; you can redistribute it and/or
|
||
22 years ago
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
18 years ago
|
* version 2.1 of the License, or (at your option) any later version.
|
||
22 years ago
|
*
|
||
11 years ago
|
* FFmpeg is distributed in the hope that it will be useful,
|
||
22 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
11 years ago
|
* License along with FFmpeg; if not, write to the Free Software
|
||
19 years ago
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
22 years ago
|
*/
|
||
19 years ago
|
|
||
22 years ago
|
/**
|
||
15 years ago
|
* @file
|
||
11 years ago
|
* Cirrus Logic AccuPak decoder.
|
||
22 years ago
|
*/
|
||
19 years ago
|
|
||
22 years ago
|
#include "avcodec.h"
|
||
16 years ago
|
#include "get_bits.h"
|
||
13 years ago
|
#include "internal.h"
|
||
17 years ago
|
|
||
19 years ago
|
static int decode_frame(AVCodecContext *avctx,
|
||
12 years ago
|
void *data, int *got_frame,
|
||
16 years ago
|
AVPacket *avpkt)
|
||
22 years ago
|
{
|
||
16 years ago
|
const uint8_t *buf = avpkt->data;
|
||
13 years ago
|
int buf_size = avpkt->size;
|
||
13 years ago
|
GetBitContext gb;
|
||
12 years ago
|
AVFrame * const p = data;
|
||
12 years ago
|
int x, y, ret;
|
||
22 years ago
|
|
||
13 years ago
|
if (avctx->height <= 0 || avctx->width <= 0) {
|
||
|
av_log(avctx, AV_LOG_ERROR, "Invalid width or height\n");
|
||
|
return AVERROR_INVALIDDATA;
|
||
|
}
|
||
|
|
||
11 years ago
|
if (buf_size / avctx->height < avctx->width) {
|
||
13 years ago
|
av_log(avctx, AV_LOG_ERROR,
|
||
|
"Resolution larger than buffer size. Invalid header?\n");
|
||
13 years ago
|
return AVERROR_INVALIDDATA;
|
||
14 years ago
|
}
|
||
|
|
||
11 years ago
|
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
||
12 years ago
|
return ret;
|
||
13 years ago
|
p->pict_type = AV_PICTURE_TYPE_I;
|
||
|
p->key_frame = 1;
|
||
22 years ago
|
|
||
13 years ago
|
init_get_bits(&gb, buf, buf_size * 8);
|
||
22 years ago
|
|
||
13 years ago
|
for (y = 0; y < avctx->height; y++) {
|
||
12 years ago
|
uint8_t *luma = &p->data[0][y * p->linesize[0]];
|
||
|
uint8_t *cb = &p->data[1][y * p->linesize[1]];
|
||
|
uint8_t *cr = &p->data[2][y * p->linesize[2]];
|
||
13 years ago
|
for (x = 0; x < avctx->width; x += 4) {
|
||
11 years ago
|
luma[3] = (get_bits(&gb, 5)*33) >> 2;
|
||
|
luma[2] = (get_bits(&gb, 5)*33) >> 2;
|
||
|
luma[1] = (get_bits(&gb, 5)*33) >> 2;
|
||
|
luma[0] = (get_bits(&gb, 5)*33) >> 2;
|
||
13 years ago
|
luma += 4;
|
||
13 years ago
|
*(cb++) = get_bits(&gb, 6) << 2;
|
||
|
*(cr++) = get_bits(&gb, 6) << 2;
|
||
22 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
*got_frame = 1;
|
||
22 years ago
|
|
||
|
return buf_size;
|
||
|
}
|
||
|
|
||
13 years ago
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||
|
{
|
||
12 years ago
|
avctx->pix_fmt = AV_PIX_FMT_YUV411P;
|
||
13 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
AVCodec ff_cljr_decoder = {
|
||
|
.name = "cljr",
|
||
11 years ago
|
.long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
|
||
13 years ago
|
.type = AVMEDIA_TYPE_VIDEO,
|
||
13 years ago
|
.id = AV_CODEC_ID_CLJR,
|
||
13 years ago
|
.init = decode_init,
|
||
|
.decode = decode_frame,
|
||
|
.capabilities = CODEC_CAP_DR1,
|
||
|
};
|
||
11 years ago
|
|