2
2
* Cirrus Logic AccuPak (CLJR) codec
3
3
* Copyright (c) 2003 Alex Beregszaszi
5
* This library is free software; you can redistribute it and/or
5
* This file is part of FFmpeg.
7
* FFmpeg is free software; you can redistribute it and/or
6
8
* modify it under the terms of the GNU Lesser General Public
7
9
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
12
* FFmpeg is distributed in the hope that it will be useful,
11
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
15
* Lesser General Public License for more details.
15
17
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
25
* Cirrus Logic AccuPak codec.
26
28
#include "avcodec.h"
27
29
#include "mpegvideo.h"
37
static int decode_frame(AVCodecContext *avctx,
39
static int decode_frame(AVCodecContext *avctx,
38
40
void *data, int *data_size,
39
41
uint8_t *buf, int buf_size)
43
45
AVFrame * const p= (AVFrame*)&a->picture;
48
/* special case for last picture */
54
49
avctx->release_buffer(avctx, p);
57
52
if(avctx->get_buffer(avctx, p) < 0){
58
fprintf(stderr, "get_buffer() failed\n");
53
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
61
56
p->pict_type= I_TYPE;
68
63
uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ];
69
64
uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ];
70
65
for(x=0; x<avctx->width; x+=4){
71
luma[3] = get_bits(&a->gb, 5) << 3;
72
luma[2] = get_bits(&a->gb, 5) << 3;
73
luma[1] = get_bits(&a->gb, 5) << 3;
74
luma[0] = get_bits(&a->gb, 5) << 3;
76
*(cb++) = get_bits(&a->gb, 6) << 2;
77
*(cr++) = get_bits(&a->gb, 6) << 2;
66
luma[3] = get_bits(&a->gb, 5) << 3;
67
luma[2] = get_bits(&a->gb, 5) << 3;
68
luma[1] = get_bits(&a->gb, 5) << 3;
69
luma[0] = get_bits(&a->gb, 5) << 3;
71
*(cb++) = get_bits(&a->gb, 6) << 2;
72
*(cr++) = get_bits(&a->gb, 6) << 2;
120
115
static int decode_init(AVCodecContext *avctx){
122
117
common_init(avctx);
124
119
avctx->pix_fmt= PIX_FMT_YUV411P;
129
125
static int encode_init(AVCodecContext *avctx){
131
127
common_init(avctx);
136
static int decode_end(AVCodecContext *avctx){
138
avcodec_default_free_buffers(avctx);
143
133
AVCodec cljr_decoder = {