Mercurial > libavcodec.hg
annotate cljr.c @ 3536:545a15c19c91 libavcodec
sse & sse2 implementations of vorbis channel coupling.
9% faster vorbis (on a K8).
| author | lorenm |
|---|---|
| date | Thu, 03 Aug 2006 03:18:47 +0000 |
| parents | 0b546eab515d |
| children | c8c591fe26f8 |
| 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 | |
|
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 1385 | 18 * |
| 19 */ | |
| 2967 | 20 |
| 1385 | 21 /** |
| 22 * @file cljr.c | |
| 23 * Cirrus Logic AccuPak codec. | |
| 24 */ | |
| 2967 | 25 |
| 1385 | 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 | |
| 2967 | 37 static int decode_frame(AVCodecContext *avctx, |
| 1385 | 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){ |
| 2979 | 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; | |
| 1385 | 71 } |
| 72 } | |
| 73 | |
| 74 *picture= *(AVFrame*)&a->picture; | |
| 75 *data_size = sizeof(AVPicture); | |
| 76 | |
| 77 emms_c(); | |
| 2967 | 78 |
| 1385 | 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(); | |
| 2967 | 95 |
| 1385 | 96 align_put_bits(&a->pb); |
| 97 while(get_bit_count(&a->pb)&31) | |
| 98 put_bits(&a->pb, 8, 0); | |
| 2967 | 99 |
| 1385 | 100 size= get_bit_count(&a->pb)/32; |
| 2967 | 101 |
| 1385 | 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); |
| 2967 | 116 |
| 1386 | 117 avctx->pix_fmt= PIX_FMT_YUV411P; |
| 1385 | 118 |
| 119 return 0; | |
| 120 } | |
| 121 | |
|
2522
e25782262d7d
kill warnings patch by (M?ns Rullg?rd <mru inprovide com>)
michael
parents:
2453
diff
changeset
|
122 #if 0 |
| 1385 | 123 static int encode_init(AVCodecContext *avctx){ |
| 1415 | 124 |
| 1385 | 125 common_init(avctx); |
| 2967 | 126 |
| 1385 | 127 return 0; |
| 128 } | |
|
2522
e25782262d7d
kill warnings patch by (M?ns Rullg?rd <mru inprovide com>)
michael
parents:
2453
diff
changeset
|
129 #endif |
| 1385 | 130 |
| 131 AVCodec cljr_decoder = { | |
| 132 "cljr", | |
| 133 CODEC_TYPE_VIDEO, | |
| 134 CODEC_ID_CLJR, | |
| 135 sizeof(CLJRContext), | |
| 136 decode_init, | |
| 137 NULL, | |
| 1994 | 138 NULL, |
| 1385 | 139 decode_frame, |
| 140 CODEC_CAP_DR1, | |
| 141 }; | |
| 142 #if 0 | |
| 143 #ifdef CONFIG_ENCODERS | |
| 144 | |
| 145 AVCodec cljr_encoder = { | |
| 146 "cljr", | |
| 147 CODEC_TYPE_VIDEO, | |
| 148 CODEC_ID_cljr, | |
| 149 sizeof(CLJRContext), | |
| 150 encode_init, | |
| 151 encode_frame, | |
| 152 //encode_end, | |
| 153 }; | |
| 154 | |
| 155 #endif //CONFIG_ENCODERS | |
| 156 #endif |
