Mercurial > libavcodec.hg
annotate cljr.c @ 12197:fbf4d5b1b664 libavcodec
Remove FF_MM_SSE2/3 flags for CPUs where this is generally not faster than
regular MMX code. Examples of this are the Core1 CPU. Instead, set a new flag,
FF_MM_SSE2/3SLOW, which can be checked for particular SSE2/3 functions that
have been checked specifically on such CPUs and are actually faster than
their MMX counterparts.
In addition, use this flag to enable particular VP8 and LPC SSE2 functions
that are faster than their MMX counterparts.
Based on a patch by Loren Merritt <lorenm AT u washington edu>.
author | rbultje |
---|---|
date | Mon, 19 Jul 2010 22:38:23 +0000 |
parents | 7dd2a45249a9 |
children |
rev | line source |
---|---|
1385 | 1 /* |
2 * Cirrus Logic AccuPak (CLJR) codec | |
3 * Copyright (c) 2003 Alex Beregszaszi | |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1385 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1385 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1385 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1385 | 20 */ |
2967 | 21 |
1385 | 22 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
23 * @file |
1385 | 24 * Cirrus Logic AccuPak codec. |
25 */ | |
2967 | 26 |
1385 | 27 #include "avcodec.h" |
6450 | 28 #include "dsputil.h" |
9428 | 29 #include "get_bits.h" |
1385 | 30 |
7784
e3f2d90a2295
Disable encoders by undefining CONFIG_FOO_ENCODER once instead of littering
diego
parents:
7783
diff
changeset
|
31 /* Disable the encoder. */ |
e3f2d90a2295
Disable encoders by undefining CONFIG_FOO_ENCODER once instead of littering
diego
parents:
7783
diff
changeset
|
32 #undef CONFIG_CLJR_ENCODER |
8590 | 33 #define CONFIG_CLJR_ENCODER 0 |
7784
e3f2d90a2295
Disable encoders by undefining CONFIG_FOO_ENCODER once instead of littering
diego
parents:
7783
diff
changeset
|
34 |
1385 | 35 typedef struct CLJRContext{ |
36 AVCodecContext *avctx; | |
37 AVFrame picture; | |
38 int delta[16]; | |
39 int offset[4]; | |
40 GetBitContext gb; | |
41 } CLJRContext; | |
42 | |
2967 | 43 static int decode_frame(AVCodecContext *avctx, |
1385 | 44 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8765
diff
changeset
|
45 AVPacket *avpkt) |
1385 | 46 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8765
diff
changeset
|
47 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8765
diff
changeset
|
48 int buf_size = avpkt->size; |
1385 | 49 CLJRContext * const a = avctx->priv_data; |
50 AVFrame *picture = data; | |
51 AVFrame * const p= (AVFrame*)&a->picture; | |
1415 | 52 int x, y; |
1385 | 53 |
54 if(p->data[0]) | |
55 avctx->release_buffer(avctx, p); | |
56 | |
57 p->reference= 0; | |
58 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
|
59 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
1385 | 60 return -1; |
61 } | |
6450 | 62 p->pict_type= FF_I_TYPE; |
1385 | 63 p->key_frame= 1; |
64 | |
65 init_get_bits(&a->gb, buf, buf_size); | |
66 | |
67 for(y=0; y<avctx->height; y++){ | |
68 uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ]; | |
1386 | 69 uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ]; |
70 uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ]; | |
1385 | 71 for(x=0; x<avctx->width; x+=4){ |
2979 | 72 luma[3] = get_bits(&a->gb, 5) << 3; |
73 luma[2] = get_bits(&a->gb, 5) << 3; | |
74 luma[1] = get_bits(&a->gb, 5) << 3; | |
75 luma[0] = get_bits(&a->gb, 5) << 3; | |
76 luma+= 4; | |
77 *(cb++) = get_bits(&a->gb, 6) << 2; | |
78 *(cr++) = get_bits(&a->gb, 6) << 2; | |
1385 | 79 } |
80 } | |
81 | |
82 *picture= *(AVFrame*)&a->picture; | |
83 *data_size = sizeof(AVPicture); | |
84 | |
85 emms_c(); | |
2967 | 86 |
1385 | 87 return buf_size; |
88 } | |
89 | |
8590 | 90 #if CONFIG_CLJR_ENCODER |
1385 | 91 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ |
92 CLJRContext * const a = avctx->priv_data; | |
93 AVFrame *pict = data; | |
94 AVFrame * const p= (AVFrame*)&a->picture; | |
95 int size; | |
96 | |
97 *p = *pict; | |
6450 | 98 p->pict_type= FF_I_TYPE; |
1385 | 99 p->key_frame= 1; |
100 | |
101 emms_c(); | |
2967 | 102 |
1385 | 103 align_put_bits(&a->pb); |
104 while(get_bit_count(&a->pb)&31) | |
105 put_bits(&a->pb, 8, 0); | |
2967 | 106 |
1385 | 107 size= get_bit_count(&a->pb)/32; |
2967 | 108 |
1385 | 109 return size*4; |
110 } | |
111 #endif | |
112 | |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6450
diff
changeset
|
113 static av_cold void common_init(AVCodecContext *avctx){ |
1385 | 114 CLJRContext * const a = avctx->priv_data; |
115 | |
116 avctx->coded_frame= (AVFrame*)&a->picture; | |
117 a->avctx= avctx; | |
118 } | |
119 | |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6450
diff
changeset
|
120 static av_cold int decode_init(AVCodecContext *avctx){ |
1415 | 121 |
1385 | 122 common_init(avctx); |
2967 | 123 |
1386 | 124 avctx->pix_fmt= PIX_FMT_YUV411P; |
1385 | 125 |
126 return 0; | |
127 } | |
128 | |
8590 | 129 #if CONFIG_CLJR_ENCODER |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6450
diff
changeset
|
130 static av_cold int encode_init(AVCodecContext *avctx){ |
1415 | 131 |
1385 | 132 common_init(avctx); |
2967 | 133 |
1385 | 134 return 0; |
135 } | |
2522
e25782262d7d
kill warnings patch by (Mns Rullgrd <mru inprovide com>)
michael
parents:
2453
diff
changeset
|
136 #endif |
1385 | 137 |
138 AVCodec cljr_decoder = { | |
139 "cljr", | |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
9428
diff
changeset
|
140 AVMEDIA_TYPE_VIDEO, |
1385 | 141 CODEC_ID_CLJR, |
142 sizeof(CLJRContext), | |
143 decode_init, | |
144 NULL, | |
1994 | 145 NULL, |
1385 | 146 decode_frame, |
147 CODEC_CAP_DR1, | |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
148 .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), |
1385 | 149 }; |
7784
e3f2d90a2295
Disable encoders by undefining CONFIG_FOO_ENCODER once instead of littering
diego
parents:
7783
diff
changeset
|
150 |
8590 | 151 #if CONFIG_CLJR_ENCODER |
1385 | 152 AVCodec cljr_encoder = { |
153 "cljr", | |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
9428
diff
changeset
|
154 AVMEDIA_TYPE_VIDEO, |
8764 | 155 CODEC_ID_CLJR, |
1385 | 156 sizeof(CLJRContext), |
157 encode_init, | |
158 encode_frame, | |
159 //encode_end, | |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
160 .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), |
1385 | 161 }; |
162 #endif |