comparison cook.c @ 6232:69b14049d7c8 libavcodec

const
author michael
date Fri, 01 Feb 2008 04:07:48 +0000
parents 2ca0a91b0b24
children a4104482ceef
comparison
equal deleted inserted replaced
6231:6d95434fa51a 6232:69b14049d7c8
299 * @param bytes number of bytes 299 * @param bytes number of bytes
300 */ 300 */
301 #define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) 301 #define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4)
302 #define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) 302 #define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes)))
303 303
304 static inline int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){ 304 static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
305 int i, off; 305 int i, off;
306 uint32_t c; 306 uint32_t c;
307 uint32_t* buf; 307 const uint32_t* buf;
308 uint32_t* obuf = (uint32_t*) out; 308 uint32_t* obuf = (uint32_t*) out;
309 /* FIXME: 64 bit platforms would be able to do 64 bits at a time. 309 /* FIXME: 64 bit platforms would be able to do 64 bits at a time.
310 * I'm too lazy though, should be something like 310 * I'm too lazy though, should be something like
311 * for(i=0 ; i<bitamount/64 ; i++) 311 * for(i=0 ; i<bitamount/64 ; i++)
312 * (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]); 312 * (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]);
313 * Buffer alignment needs to be checked. */ 313 * Buffer alignment needs to be checked. */
314 314
315 off = (int)((long)inbuffer & 3); 315 off = (int)((long)inbuffer & 3);
316 buf = (uint32_t*) (inbuffer - off); 316 buf = (const uint32_t*) (inbuffer - off);
317 c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8)))); 317 c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8))));
318 bytes += 3 + off; 318 bytes += 3 + off;
319 for (i = 0; i < bytes/4; i++) 319 for (i = 0; i < bytes/4; i++)
320 obuf[i] = c ^ buf[i]; 320 obuf[i] = c ^ buf[i];
321 321
873 * @param inbuffer pointer to raw stream data 873 * @param inbuffer pointer to raw stream data
874 * @param gain_ptr array of current/prev gain pointers 874 * @param gain_ptr array of current/prev gain pointers
875 */ 875 */
876 876
877 static inline void 877 static inline void
878 decode_bytes_and_gain(COOKContext *q, uint8_t *inbuffer, 878 decode_bytes_and_gain(COOKContext *q, const uint8_t *inbuffer,
879 cook_gains *gains_ptr) 879 cook_gains *gains_ptr)
880 { 880 {
881 int offset; 881 int offset;
882 882
883 offset = decode_bytes(inbuffer, q->decoded_bytes_buffer, 883 offset = decode_bytes(inbuffer, q->decoded_bytes_buffer,
942 * @param sub_packet_size subpacket size 942 * @param sub_packet_size subpacket size
943 * @param outbuffer pointer to the outbuffer 943 * @param outbuffer pointer to the outbuffer
944 */ 944 */
945 945
946 946
947 static int decode_subpacket(COOKContext *q, uint8_t *inbuffer, 947 static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer,
948 int sub_packet_size, int16_t *outbuffer) { 948 int sub_packet_size, int16_t *outbuffer) {
949 /* packet dump */ 949 /* packet dump */
950 // for (i=0 ; i<sub_packet_size ; i++) { 950 // for (i=0 ; i<sub_packet_size ; i++) {
951 // av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]); 951 // av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]);
952 // } 952 // }
987 * @param avctx pointer to the AVCodecContext 987 * @param avctx pointer to the AVCodecContext
988 */ 988 */
989 989
990 static int cook_decode_frame(AVCodecContext *avctx, 990 static int cook_decode_frame(AVCodecContext *avctx,
991 void *data, int *data_size, 991 void *data, int *data_size,
992 uint8_t *buf, int buf_size) { 992 const uint8_t *buf, int buf_size) {
993 COOKContext *q = avctx->priv_data; 993 COOKContext *q = avctx->priv_data;
994 994
995 if (buf_size < avctx->block_align) 995 if (buf_size < avctx->block_align)
996 return buf_size; 996 return buf_size;
997 997
1036 */ 1036 */
1037 1037
1038 static int cook_decode_init(AVCodecContext *avctx) 1038 static int cook_decode_init(AVCodecContext *avctx)
1039 { 1039 {
1040 COOKContext *q = avctx->priv_data; 1040 COOKContext *q = avctx->priv_data;
1041 uint8_t *edata_ptr = avctx->extradata; 1041 const uint8_t *edata_ptr = avctx->extradata;
1042 1042
1043 /* Take care of the codec specific extradata. */ 1043 /* Take care of the codec specific extradata. */
1044 if (avctx->extradata_size <= 0) { 1044 if (avctx->extradata_size <= 0) {
1045 av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n"); 1045 av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n");
1046 return -1; 1046 return -1;