Mercurial > libavcodec.hg
annotate cljr.c @ 2497:69adfbbdcdeb libavcodec
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
which isn't the advanced one; and indeed, using adv. profile parser fails.
Using normal parser works, and that's what is done
- attempt at taking care of stride for NORM2 bitplane decoding
- duplication of much code from msmpeg4.c; this code isn't yet used, but
goes down as far as the block layer (mainly Transform Type stuff, the
remains are wild editing without checking). Unusable yet, and lacks the AC
decoding (but a step further in bitstream parsing)
patch by anonymous
author | michael |
---|---|
date | Fri, 04 Feb 2005 02:20:38 +0000 |
parents | f67b63ed036d |
children | e25782262d7d |
rev | line source |
---|---|
1385 | 1 /* |
2 * Cirrus Logic AccuPak (CLJR) codec | |
3 * Copyright (c) 2003 Alex Beregszaszi | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * 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 * | |
19 */ | |
20 | |
21 /** | |
22 * @file cljr.c | |
23 * Cirrus Logic AccuPak codec. | |
24 */ | |
25 | |
26 #include "avcodec.h" | |
27 #include "mpegvideo.h" | |
28 | |
29 typedef struct CLJRContext{ | |
30 AVCodecContext *avctx; | |
31 AVFrame picture; | |
32 int delta[16]; | |
33 int offset[4]; | |
34 GetBitContext gb; | |
35 } CLJRContext; | |
36 | |
37 static int decode_frame(AVCodecContext *avctx, | |
38 void *data, int *data_size, | |
39 uint8_t *buf, int buf_size) | |
40 { | |
41 CLJRContext * const a = avctx->priv_data; | |
42 AVFrame *picture = data; | |
43 AVFrame * const p= (AVFrame*)&a->picture; | |
1415 | 44 int x, y; |
1385 | 45 |
46 if(p->data[0]) | |
47 avctx->release_buffer(avctx, p); | |
48 | |
49 p->reference= 0; | |
50 if(avctx->get_buffer(avctx, p) < 0){ | |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1415
diff
changeset
|
51 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
1385 | 52 return -1; |
53 } | |
54 p->pict_type= I_TYPE; | |
55 p->key_frame= 1; | |
56 | |
57 init_get_bits(&a->gb, buf, buf_size); | |
58 | |
59 for(y=0; y<avctx->height; y++){ | |
60 uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ]; | |
1386 | 61 uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ]; |
62 uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ]; | |
1385 | 63 for(x=0; x<avctx->width; x+=4){ |
64 luma[3] = get_bits(&a->gb, 5) << 3; | |
65 luma[2] = get_bits(&a->gb, 5) << 3; | |
66 luma[1] = get_bits(&a->gb, 5) << 3; | |
67 luma[0] = get_bits(&a->gb, 5) << 3; | |
68 luma+= 4; | |
69 *(cb++) = get_bits(&a->gb, 6) << 2; | |
70 *(cr++) = get_bits(&a->gb, 6) << 2; | |
71 } | |
72 } | |
73 | |
74 *picture= *(AVFrame*)&a->picture; | |
75 *data_size = sizeof(AVPicture); | |
76 | |
77 emms_c(); | |
78 | |
79 return buf_size; | |
80 } | |
81 | |
82 #if 0 | |
83 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | |
84 CLJRContext * const a = avctx->priv_data; | |
85 AVFrame *pict = data; | |
86 AVFrame * const p= (AVFrame*)&a->picture; | |
87 int size; | |
88 int mb_x, mb_y; | |
89 | |
90 *p = *pict; | |
91 p->pict_type= I_TYPE; | |
92 p->key_frame= 1; | |
93 | |
94 emms_c(); | |
95 | |
96 align_put_bits(&a->pb); | |
97 while(get_bit_count(&a->pb)&31) | |
98 put_bits(&a->pb, 8, 0); | |
99 | |
100 size= get_bit_count(&a->pb)/32; | |
101 | |
102 return size*4; | |
103 } | |
104 #endif | |
105 | |
106 static void common_init(AVCodecContext *avctx){ | |
107 CLJRContext * const a = avctx->priv_data; | |
108 | |
109 avctx->coded_frame= (AVFrame*)&a->picture; | |
110 a->avctx= avctx; | |
111 } | |
112 | |
113 static int decode_init(AVCodecContext *avctx){ | |
1415 | 114 |
1385 | 115 common_init(avctx); |
116 | |
1386 | 117 avctx->pix_fmt= PIX_FMT_YUV411P; |
1385 | 118 |
119 return 0; | |
120 } | |
121 | |
122 static int encode_init(AVCodecContext *avctx){ | |
1415 | 123 |
1385 | 124 common_init(avctx); |
125 | |
126 return 0; | |
127 } | |
128 | |
129 AVCodec cljr_decoder = { | |
130 "cljr", | |
131 CODEC_TYPE_VIDEO, | |
132 CODEC_ID_CLJR, | |
133 sizeof(CLJRContext), | |
134 decode_init, | |
135 NULL, | |
1994 | 136 NULL, |
1385 | 137 decode_frame, |
138 CODEC_CAP_DR1, | |
139 }; | |
140 #if 0 | |
141 #ifdef CONFIG_ENCODERS | |
142 | |
143 AVCodec cljr_encoder = { | |
144 "cljr", | |
145 CODEC_TYPE_VIDEO, | |
146 CODEC_ID_cljr, | |
147 sizeof(CLJRContext), | |
148 encode_init, | |
149 encode_frame, | |
150 //encode_end, | |
151 }; | |
152 | |
153 #endif //CONFIG_ENCODERS | |
154 #endif |