Mercurial > audlegacy
changeset 218:0bea7509d6ba trunk
[svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
line wrap: on
line diff
--- a/Plugins/Input/wma/iir.h Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/iir.h Mon Nov 21 14:59:13 2005 -0800 @@ -31,6 +31,7 @@ #include <pthread.h> #include <string.h> #include <math.h> +#include <tgmath.h> #include <audacious/plugin.h> #include <libaudacious/util.h>
--- a/Plugins/Input/wma/libffwma/Makefile.am Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/Makefile.am Mon Nov 21 14:59:13 2005 -0800 @@ -6,7 +6,7 @@ bswap.h common.c common.h \ cutils.c dsputil.c dsputil.h \ fft.c file.c futils.c mdct.c \ - mem.c os_support.c os_support.h \ + os_support.c os_support.h \ parser.c simple_idct.c \ simple_idct.h utils.c wmadata.h \ wmadec.c
--- a/Plugins/Input/wma/libffwma/allcodecs.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/allcodecs.c Mon Nov 21 14:59:13 2005 -0800 @@ -1,6 +1,7 @@ /* * Utils for libavcodec * Copyright (c) 2002 Fabrice Bellard. + * Copyright (c) 2004 Roman Bogorodskiy (bmp-wma specific stuff) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,33 +18,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - * @file allcodecs.c - * Utils for libavcodec. - */ - #include "avcodec.h" -/* If you do not call this function, then you can select exactly which - formats you want to support */ - -/** - * simple call to register all the codecs. - */ void avcodec_register_all(void) { - static int inited = 0; + static int inited = 0; - if (inited != 0) - return; - inited = 1; + if (inited != 0) + return; + inited = 1; - /* decoders */ -#ifdef CONFIG_DECODERS -#ifdef CONFIG_RISKY - register_avcodec(&wmav1_decoder); - register_avcodec(&wmav2_decoder); -#endif -#endif + register_avcodec(&wmav1_decoder); + register_avcodec(&wmav2_decoder); }
--- a/Plugins/Input/wma/libffwma/allformats.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/allformats.c Mon Nov 21 14:59:13 2005 -0800 @@ -18,110 +18,14 @@ */ #include "avformat.h" -/* If you do not call this function, then you can select exactly which - formats you want to support */ - -/** - * Initialize libavcodec and register all the codecs and formats. - */ void av_register_all(void) { avcodec_init(); avcodec_register_all(); - //mpegps_init(); - //mpegts_init(); -#ifdef CONFIG_ENCODERS - crc_init(); - img_init(); -#endif //CONFIG_ENCODERS - //raw_init(); - //mp3_init(); - //rm_init(); -#ifdef CONFIG_RISKY asf_init(); -#endif -#ifdef CONFIG_ENCODERS - avienc_init(); -#endif //CONFIG_ENCODERS - //avidec_init(); - //wav_init(); - //swf_init(); - //au_init(); -#ifdef CONFIG_ENCODERS - gif_init(); -#endif //CONFIG_ENCODERS - //mov_init(); -#ifdef CONFIG_ENCODERS - movenc_init(); - jpeg_init(); -#endif //CONFIG_ENCODERS - //dv_init(); - //fourxm_init(); -#ifdef CONFIG_ENCODERS - flvenc_init(); -#endif //CONFIG_ENCODERS - //flvdec_init(); - //str_init(); - //roq_init(); - //ipmovie_init(); - //wc3_init(); - //westwood_init(); - //film_init(); - //idcin_init(); - //flic_init(); - //vmd_init(); - -#if defined(AMR_NB) || defined(AMR_NB_FIXED) || defined(AMR_WB) - amr_init(); -#endif - //yuv4mpeg_init(); - -#ifdef CONFIG_VORBIS - ogg_init(); -#endif - -#ifndef CONFIG_WIN32 - //ffm_init(); -#endif -#ifdef CONFIG_VIDEO4LINUX - video_grab_init(); -#endif -#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS) - audio_init(); -#endif - -#ifdef CONFIG_DV1394 - dv1394_init(); -#endif - - //nut_init(); - -#ifdef CONFIG_ENCODERS - /* image formats */ - av_register_image_format(&pnm_image_format); - av_register_image_format(&pbm_image_format); - av_register_image_format(&pgm_image_format); - av_register_image_format(&ppm_image_format); - av_register_image_format(&pam_image_format); - av_register_image_format(&pgmyuv_image_format); - av_register_image_format(&yuv_image_format); -#ifdef CONFIG_ZLIB - av_register_image_format(&png_image_format); -#endif - av_register_image_format(&jpeg_image_format); - av_register_image_format(&gif_image_format); -#endif //CONFIG_ENCODERS /* file protocols */ register_protocol(&file_protocol); register_protocol(&pipe_protocol); -#ifdef CONFIG_NETWORK - rtsp_init(); - rtp_init(); - register_protocol(&udp_protocol); - register_protocol(&rtp_protocol); - register_protocol(&tcp_protocol); - register_protocol(&http_protocol); -#endif }
--- a/Plugins/Input/wma/libffwma/asf.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/asf.c Mon Nov 21 14:59:13 2005 -0800 @@ -16,12 +16,10 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "avcodec.h" #include "avformat.h" #include "avi.h" -//#include "mpegaudio.h" -#include <iconv.h> -#undef NDEBUG #include <assert.h> #define MPA_FRAME_SIZE 1152 #define PACKET_SIZE 3200 @@ -147,14 +145,6 @@ 0x20fb5700, 0x5b55, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }, }; -static const GUID video_stream = { - 0xBC19EFC0, 0x5B4D, 0x11CF, { 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B }, -}; - -static const GUID video_conceal_none = { - 0x20FB5700, 0x5B55, 0x11CF, { 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B }, -}; - static const GUID comment_header = { 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }, @@ -194,17 +184,17 @@ }; const CodecTag codec_wav_tags[] = { - { CODEC_ID_MP2, 0x50 }, +/* { CODEC_ID_MP2, 0x50 }, { CODEC_ID_MP3, 0x55 }, { CODEC_ID_AC3, 0x2000 }, { CODEC_ID_PCM_S16LE, 0x01 }, - { CODEC_ID_PCM_U8, 0x01 }, /* must come after s16le in this list */ + { CODEC_ID_PCM_U8, 0x01 }, { CODEC_ID_PCM_ALAW, 0x06 }, { CODEC_ID_PCM_MULAW, 0x07 }, { CODEC_ID_ADPCM_MS, 0x02 }, { CODEC_ID_ADPCM_IMA_WAV, 0x11 }, - { CODEC_ID_ADPCM_IMA_DK4, 0x61 }, /* rogue format number */ - { CODEC_ID_ADPCM_IMA_DK3, 0x62 }, /* rogue format number */ + { CODEC_ID_ADPCM_IMA_DK4, 0x61 }, + { CODEC_ID_ADPCM_IMA_DK3, 0x62 },*/ { CODEC_ID_WMAV1, 0x160 }, { CODEC_ID_WMAV2, 0x161 }, { 0, 0 }, @@ -268,493 +258,9 @@ } } -#ifdef CONFIG_ENCODERS -static void put_guid(ByteIOContext *s, const GUID *g) -{ - int i; - - put_le32(s, g->v1); - put_le16(s, g->v2); - put_le16(s, g->v3); - for(i=0;i<8;i++) - put_byte(s, g->v4[i]); -} - -static void put_str16(ByteIOContext *s, const char *tag) -{ - int c; - - put_le16(s,strlen(tag) + 1); - for(;;) { - c = (uint8_t)*tag++; - put_le16(s, c); - if (c == '\0') - break; - } -} - -static void put_str16_nolen(ByteIOContext *s, const char *tag) -{ - int c; - - for(;;) { - c = (uint8_t)*tag++; - put_le16(s, c); - if (c == '\0') - break; - } -} - -static int64_t put_header(ByteIOContext *pb, const GUID *g) -{ - int64_t pos; - - pos = url_ftell(pb); - put_guid(pb, g); - put_le64(pb, 24); - return pos; -} - -/* update header size */ -static void end_header(ByteIOContext *pb, int64_t pos) -{ - int64_t pos1; - - pos1 = url_ftell(pb); - url_fseek(pb, pos + 16, SEEK_SET); - put_le64(pb, pos1 - pos); - url_fseek(pb, pos1, SEEK_SET); -} - -/* write an asf chunk (only used in streaming case) */ -static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags) -{ - ASFContext *asf = s->priv_data; - ByteIOContext *pb = &s->pb; - int length; - - length = payload_length + 8; - put_le16(pb, type); - put_le16(pb, length); - put_le32(pb, asf->seqno); - put_le16(pb, flags); /* unknown bytes */ - put_le16(pb, length); - asf->seqno++; -} - -/* convert from unix to windows time */ -static int64_t unix_to_file_time(int ti) -{ - int64_t t; - - t = ti * int64_t_C(10000000); - t += int64_t_C(116444736000000000); - return t; -} - -/* write the header (used two times if non streamed) */ -static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size) -{ - ASFContext *asf = s->priv_data; - ByteIOContext *pb = &s->pb; - int header_size, n, extra_size, extra_size2, wav_extra_size, file_time; - int has_title; - AVCodecContext *enc; - int64_t header_offset, cur_pos, hpos; - int bit_rate; - - has_title = (s->title[0] || s->author[0] || s->copyright[0] || s->comment[0]); - - bit_rate = 0; - for(n=0;n<s->nb_streams;n++) { - enc = &s->streams[n]->codec; - - bit_rate += enc->bit_rate; - } - - if (asf->is_streamed) { - put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */ - } - - put_guid(pb, &asf_header); - put_le64(pb, -1); /* header length, will be patched after */ - put_le32(pb, 3 + has_title + s->nb_streams); /* number of chunks in header */ - put_byte(pb, 1); /* ??? */ - put_byte(pb, 2); /* ??? */ - - /* file header */ - header_offset = url_ftell(pb); - hpos = put_header(pb, &file_header); - put_guid(pb, &my_guid); - put_le64(pb, file_size); - file_time = 0; - put_le64(pb, unix_to_file_time(file_time)); - put_le64(pb, asf->nb_packets); /* number of packets */ - put_le64(pb, asf->duration); /* end time stamp (in 100ns units) */ - put_le64(pb, asf->duration); /* duration (in 100ns units) */ - put_le32(pb, 0); /* start time stamp */ - put_le32(pb, 0); /* ??? */ - put_le32(pb, asf->is_streamed ? 1 : 0); /* ??? */ - put_le32(pb, asf->packet_size); /* packet size */ - put_le32(pb, asf->packet_size); /* packet size */ - put_le32(pb, bit_rate); /* Nominal data rate in bps */ - end_header(pb, hpos); - - /* unknown headers */ - hpos = put_header(pb, &head1_guid); - put_guid(pb, &head2_guid); - put_le32(pb, 6); - put_le16(pb, 0); - end_header(pb, hpos); - - /* title and other infos */ - if (has_title) { - hpos = put_header(pb, &comment_header); - put_le16(pb, 2 * (strlen(s->title) + 1)); - put_le16(pb, 2 * (strlen(s->author) + 1)); - put_le16(pb, 2 * (strlen(s->copyright) + 1)); - put_le16(pb, 2 * (strlen(s->comment) + 1)); - put_le16(pb, 0); - put_str16_nolen(pb, s->title); - put_str16_nolen(pb, s->author); - put_str16_nolen(pb, s->copyright); - put_str16_nolen(pb, s->comment); - end_header(pb, hpos); - } - - /* stream headers */ - for(n=0;n<s->nb_streams;n++) { - int64_t es_pos; - // ASFStream *stream = &asf->streams[n]; - - enc = &s->streams[n]->codec; - asf->streams[n].num = n + 1; - asf->streams[n].seq = 0; - - switch(enc->codec_type) { - case CODEC_TYPE_AUDIO: - wav_extra_size = 0; - extra_size = 18 + wav_extra_size; - extra_size2 = 0; - break; - default: - case CODEC_TYPE_VIDEO: - wav_extra_size = 0; - extra_size = 0x33; - extra_size2 = 0; - break; - } - - hpos = put_header(pb, &stream_header); - if (enc->codec_type == CODEC_TYPE_AUDIO) { - put_guid(pb, &audio_stream); - put_guid(pb, &audio_conceal_none); - } else { - put_guid(pb, &video_stream); - put_guid(pb, &video_conceal_none); - } - put_le64(pb, 0); /* ??? */ - es_pos = url_ftell(pb); - put_le32(pb, extra_size); /* wav header len */ - put_le32(pb, extra_size2); /* additional data len */ - put_le16(pb, n + 1); /* stream number */ - put_le32(pb, 0); /* ??? */ - - if (enc->codec_type == CODEC_TYPE_AUDIO) { - /* WAVEFORMATEX header */ - int wavsize = put_wav_header(pb, enc); - - if (wavsize < 0) - return -1; - if (wavsize != extra_size) { - cur_pos = url_ftell(pb); - url_fseek(pb, es_pos, SEEK_SET); - put_le32(pb, wavsize); /* wav header len */ - url_fseek(pb, cur_pos, SEEK_SET); - } - } else { - put_le32(pb, enc->width); - put_le32(pb, enc->height); - put_byte(pb, 2); /* ??? */ - put_le16(pb, 40); /* size */ - - /* BITMAPINFOHEADER header */ - put_bmp_header(pb, enc, codec_bmp_tags, 1); - } - end_header(pb, hpos); - } - - /* media comments */ - - hpos = put_header(pb, &codec_comment_header); - put_guid(pb, &codec_comment1_header); - put_le32(pb, s->nb_streams); - for(n=0;n<s->nb_streams;n++) { - AVCodec *p; - - enc = &s->streams[n]->codec; - p = avcodec_find_encoder(enc->codec_id); - - put_le16(pb, asf->streams[n].num); - put_str16(pb, p ? p->name : enc->codec_name); - put_le16(pb, 0); /* no parameters */ - - - /* id */ - if (enc->codec_type == CODEC_TYPE_AUDIO) { - put_le16(pb, 2); - if(!enc->codec_tag) - enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id); - if(!enc->codec_tag) - return -1; - put_le16(pb, enc->codec_tag); - } else { - put_le16(pb, 4); - if(!enc->codec_tag) - enc->codec_tag = codec_get_tag(codec_bmp_tags, enc->codec_id); - if(!enc->codec_tag) - return -1; - put_le32(pb, enc->codec_tag); - } - } - end_header(pb, hpos); - - /* patch the header size fields */ - - cur_pos = url_ftell(pb); - header_size = cur_pos - header_offset; - if (asf->is_streamed) { - header_size += 8 + 30 + 50; - - url_fseek(pb, header_offset - 10 - 30, SEEK_SET); - put_le16(pb, header_size); - url_fseek(pb, header_offset - 2 - 30, SEEK_SET); - put_le16(pb, header_size); - - header_size -= 8 + 30 + 50; - } - header_size += 24 + 6; - url_fseek(pb, header_offset - 14, SEEK_SET); - put_le64(pb, header_size); - url_fseek(pb, cur_pos, SEEK_SET); - - /* movie chunk, followed by packets of packet_size */ - asf->data_offset = cur_pos; - put_guid(pb, &data_header); - put_le64(pb, data_chunk_size); - put_guid(pb, &my_guid); - put_le64(pb, asf->nb_packets); /* nb packets */ - put_byte(pb, 1); /* ??? */ - put_byte(pb, 1); /* ??? */ - return 0; -} - -static int asf_write_header(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - - av_set_pts_info(s, 32, 1, 1000); /* 32 bit pts in ms */ - - asf->packet_size = PACKET_SIZE; - asf->nb_packets = 0; - - if (asf_write_header1(s, 0, 50) < 0) { - //av_free(asf); - return -1; - } - - put_flush_packet(&s->pb); - - asf->packet_nb_frames = 0; - asf->packet_timestamp_start = -1; - asf->packet_timestamp_end = -1; - asf->packet_size_left = asf->packet_size - PACKET_HEADER_SIZE; - init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, - NULL, NULL, NULL, NULL); - - return 0; -} - -static int asf_write_stream_header(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - - asf->is_streamed = 1; - - return asf_write_header(s); -} - -/* write a fixed size packet */ -static int put_packet(AVFormatContext *s, - unsigned int timestamp, unsigned int duration, - int nb_frames, int padsize) -{ - ASFContext *asf = s->priv_data; - ByteIOContext *pb = &s->pb; - int flags; - - if (asf->is_streamed) { - put_chunk(s, 0x4424, asf->packet_size, 0); - } - - put_byte(pb, 0x82); - put_le16(pb, 0); - - flags = 0x01; /* nb segments present */ - if (padsize > 0) { - if (padsize < 256) - flags |= 0x08; - else - flags |= 0x10; - } - put_byte(pb, flags); /* flags */ - put_byte(pb, 0x5d); - if (flags & 0x10) - put_le16(pb, padsize - 2); - if (flags & 0x08) - put_byte(pb, padsize - 1); - put_le32(pb, timestamp); - put_le16(pb, duration); - put_byte(pb, nb_frames | 0x80); - - return PACKET_HEADER_SIZE + ((flags & 0x18) >> 3); -} - -static void flush_packet(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - int hdr_size, ptr; - - hdr_size = put_packet(s, asf->packet_timestamp_start, - asf->packet_timestamp_end - asf->packet_timestamp_start, - asf->packet_nb_frames, asf->packet_size_left); - - /* Clear out the padding bytes */ - ptr = asf->packet_size - hdr_size - asf->packet_size_left; - memset(asf->packet_buf + ptr, 0, asf->packet_size_left); - - put_buffer(&s->pb, asf->packet_buf, asf->packet_size - hdr_size); - - put_flush_packet(&s->pb); - asf->nb_packets++; - asf->packet_nb_frames = 0; - asf->packet_timestamp_start = -1; - asf->packet_timestamp_end = -1; - asf->packet_size_left = asf->packet_size - PACKET_HEADER_SIZE; - init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, - NULL, NULL, NULL, NULL); -} - -static void put_frame_header(AVFormatContext *s, ASFStream *stream, int timestamp, - int payload_size, int frag_offset, int frag_len) -{ - ASFContext *asf = s->priv_data; - ByteIOContext *pb = &asf->pb; - int val; - - val = stream->num; - if (s->streams[val - 1]->codec.coded_frame->key_frame /* && frag_offset == 0 */) - val |= 0x80; - put_byte(pb, val); - put_byte(pb, stream->seq); - put_le32(pb, frag_offset); /* fragment offset */ - put_byte(pb, 0x08); /* flags */ - put_le32(pb, payload_size); - put_le32(pb, timestamp); - put_le16(pb, frag_len); -} - - -/* Output a frame. We suppose that payload_size <= PACKET_SIZE. - - It is there that you understand that the ASF format is really - crap. They have misread the MPEG Systems spec ! - */ -static void put_frame(AVFormatContext *s, ASFStream *stream, int timestamp, - const uint8_t *buf, int payload_size) -{ - ASFContext *asf = s->priv_data; - int frag_pos, frag_len, frag_len1; - - frag_pos = 0; - while (frag_pos < payload_size) { - frag_len = payload_size - frag_pos; - frag_len1 = asf->packet_size_left - FRAME_HEADER_SIZE; - if (frag_len1 > 0) { - if (frag_len > frag_len1) - frag_len = frag_len1; - put_frame_header(s, stream, timestamp+1, payload_size, frag_pos, frag_len); - put_buffer(&asf->pb, buf, frag_len); - asf->packet_size_left -= (frag_len + FRAME_HEADER_SIZE); - asf->packet_timestamp_end = timestamp; - if (asf->packet_timestamp_start == -1) - asf->packet_timestamp_start = timestamp; - asf->packet_nb_frames++; - } else { - frag_len = 0; - } - frag_pos += frag_len; - buf += frag_len; - /* output the frame if filled */ - if (asf->packet_size_left <= FRAME_HEADER_SIZE) - flush_packet(s); - } - stream->seq++; -} - - -static int asf_write_packet(AVFormatContext *s, int stream_index, - const uint8_t *buf, int size, int64_t timestamp) -{ - ASFContext *asf = s->priv_data; - ASFStream *stream; - int64_t duration; - AVCodecContext *codec; - - codec = &s->streams[stream_index]->codec; - stream = &asf->streams[stream_index]; - - if (codec->codec_type == CODEC_TYPE_AUDIO) { - duration = (codec->frame_number * codec->frame_size * int64_t_C(10000000)) / - codec->sample_rate; - } else { - duration = av_rescale(codec->frame_number * codec->frame_rate_base, 10000000, codec->frame_rate); - } - if (duration > asf->duration) - asf->duration = duration; - - put_frame(s, stream, timestamp, buf, size); - return 0; -} - -static int asf_write_trailer(AVFormatContext *s) -{ - ASFContext *asf = s->priv_data; - int64_t file_size; - - /* flush the current packet */ - if (asf->pb.buf_ptr > asf->pb.buffer) - flush_packet(s); - - if (asf->is_streamed) { - put_chunk(s, 0x4524, 0, 0); /* end of stream */ - } else { - /* rewrite an updated header */ - file_size = url_ftell(&s->pb); - url_fseek(&s->pb, 0, SEEK_SET); - asf_write_header1(s, file_size, file_size - asf->data_offset); - } - - put_flush_packet(&s->pb); - return 0; -} -#endif //CONFIG_ENCODERS - /**********************************/ /* decoding */ -//#define DEBUG - #ifdef DEBUG #define PRINT_IF_GUID(g,cmp) \ if (!memcmp(g, &cmp, sizeof(GUID))) \ @@ -768,8 +274,6 @@ else PRINT_IF_GUID(g, stream_header); else PRINT_IF_GUID(g, audio_stream); else PRINT_IF_GUID(g, audio_conceal_none); - else PRINT_IF_GUID(g, video_stream); - else PRINT_IF_GUID(g, video_conceal_none); else PRINT_IF_GUID(g, comment_header); else PRINT_IF_GUID(g, codec_comment_header); else PRINT_IF_GUID(g, codec_comment1_header); @@ -799,81 +303,19 @@ g->v4[i] = get_byte(s); } -#if 0 -static void get_str16(ByteIOContext *pb, char *buf, int buf_size) -{ - int len, c; - char *q; - - len = get_le16(pb); - q = buf; - while (len > 0) { - c = get_le16(pb); - if ((q - buf) < buf_size - 1) - *q++ = c; - len--; - } - *q = '\0'; -} -#endif - -static char *getlocale() -{ - char *str; - - str = strstr(getenv("LANG"), "."); - if(str) - *str++; - else - str = "US-ASCII"; - - return str; -} - -static void tag_recode(char *before, unsigned int len) -{ - int result; - iconv_t frt; - char ansb[len]; - char ansa[len]; - char *ansbptr = ansb; - char *ansaptr = ansa; - unsigned int len1 = 2 * len; - unsigned int length = len; - - memcpy(ansb, before, len); - frt = iconv_open(getlocale(), "UNICODE"); - if (frt == (iconv_t) - 1) - { - return; - } - result = iconv(frt, &ansbptr, &len, &ansaptr, &len1); - if (result == (size_t) - 1) - { - return; - } - else - memcpy(before, ansa, length); - if (iconv_close(frt) != 0) - if (iconv_close(frt) != 0) - return; - return; -} - static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size) { - int c, lenz; + int c; char *q; q = buf; - lenz = len; while (len > 0) { - c = get_byte(pb); - if ((q - buf) < buf_size-1) - *q++ = c; - len--; - } - tag_recode(buf, lenz); + c = get_le16(pb); + if ((q - buf) < buf_size - 1) + *q++ = c; + len-=2; + } + *q = '\0'; } static int asf_probe(AVProbeData *pd) @@ -967,8 +409,6 @@ get_guid(pb, &g); if (!memcmp(&g, &audio_stream, sizeof(GUID))) { type = CODEC_TYPE_AUDIO; - } else if (!memcmp(&g, &video_stream, sizeof(GUID))) { - type = CODEC_TYPE_VIDEO; } else { goto fail; } @@ -1006,9 +446,6 @@ asf_st->ds_span = 0; // disable descrambling } switch (st->codec.codec_id) { - case CODEC_ID_MP3: - st->codec.frame_size = MPA_FRAME_SIZE; - break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: @@ -1025,45 +462,6 @@ break; } } -#if 0 - } else { - get_le32(pb); - get_le32(pb); - get_byte(pb); - size = get_le16(pb); /* size */ - get_le32(pb); /* size */ - st->codec.width = get_le32(pb); - st->codec.height = get_le32(pb); - /* not available for asf */ - get_le16(pb); /* panes */ - st->codec.bits_per_sample = get_le16(pb); /* depth */ - tag1 = get_le32(pb); - url_fskip(pb, 20); - if (size > 40) { - st->codec.extradata_size = size - 40; - st->codec.extradata = av_mallocz(st->codec.extradata_size); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); - } - - /* Extract palette from extradata if bpp <= 8 */ - /* This code assumes that extradata contains only palette */ - /* This is true for all paletted codecs implemented in ffmpeg */ - if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { - st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); -#ifdef WORDS_BIGENDIAN - for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); -#else - memcpy(st->codec.palctrl->palette, st->codec.extradata, - FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); -#endif - st->codec.palctrl->palette_changed = 1; - } - - st->codec.codec_tag = tag1; - st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); - } -#endif pos2 = url_ftell(pb); url_fskip(pb, gsize - (pos2 - pos1 + 24)); } else if (!memcmp(&g, &data_header, sizeof(GUID))) { @@ -1102,7 +500,7 @@ if (strcmp(name,"WM/AlbumTitle")==0) { strcpy(s->album, value); } if (strcmp(name,"WM/Genre")==0) { strcpy(s->genre, value); } if (strcmp(name,"WM/Year")==0) s->year = atoi(value); - av_free(value); + free(value); } if ((value_type >= 2) || (value_type <= 5)) // boolean or DWORD or QWORD or WORD { @@ -1113,38 +511,8 @@ if (strcmp(name,"WM/Track")==0) s->track = value_num + 1; if (strcmp(name,"WM/TrackNumber")==0) s->track = value_num; } - av_free(name); + free(name); } -#if 0 - } else if (!memcmp(&g, &head1_guid, sizeof(GUID))) { - int v1, v2; - get_guid(pb, &g); - v1 = get_le32(pb); - v2 = get_le16(pb); - } else if (!memcmp(&g, &codec_comment_header, sizeof(GUID))) { - int len, v1, n, num; - char str[256], *q; - char tag[16]; - - get_guid(pb, &g); - print_guid(&g); - - n = get_le32(pb); - for(i=0;i<n;i++) { - num = get_le16(pb); /* stream number */ - get_str16(pb, str, sizeof(str)); - get_str16(pb, str, sizeof(str)); - len = get_le16(pb); - q = tag; - while (len > 0) { - v1 = get_byte(pb); - if ((q - tag) < sizeof(tag) - 1) - *q++ = v1; - len--; - } - *q = '\0'; - } -#endif } else if (url_feof(pb)) { goto fail; } else { @@ -1166,10 +534,10 @@ for(i=0;i<s->nb_streams;i++) { AVStream *st = s->streams[i]; if (st) { - av_free(st->priv_data); - av_free(st->codec.extradata); + free(st->priv_data); + free(st->codec.extradata); } - av_free(st); + free(st); } return -1; } @@ -1392,7 +760,7 @@ /* return packet */ if (asf_st->ds_span > 1) { /* packet descrambling */ - unsigned char* newdata = av_malloc(asf_st->pkt.size); + char* newdata = malloc(asf_st->pkt.size); if (newdata) { int offset = 0; while (offset < asf_st->pkt.size) { @@ -1406,7 +774,7 @@ asf_st->ds_chunk_size); offset += asf_st->ds_chunk_size; } - av_free(asf_st->pkt.data); + free(asf_st->pkt.data); asf_st->pkt.data = newdata; } } @@ -1427,9 +795,9 @@ for(i=0;i<s->nb_streams;i++) { AVStream *st = s->streams[i]; - av_free(st->priv_data); - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + free(st->priv_data); + free(st->codec.extradata); + free(st->codec.palctrl); } return 0; } @@ -1549,10 +917,6 @@ if(e->timestamp <= pts){ pos_min= e->pos; pts_min= e->timestamp; -#ifdef DEBUG_SEEK - printf("unsing cached pos_min=0x%llx dts_min=%0.3f\n", - pos_min,pts_min / 90000.0); -#endif }else{ assert(index==0); } @@ -1563,10 +927,6 @@ pos_max= e->pos; pts_max= e->timestamp; pos_limit= pos_max - e->min_distance; -#ifdef DEBUG_SEEK - printf("unsing cached pos_max=0x%llx dts_max=%0.3f\n", - pos_max,pts_max / 90000.0); -#endif } } @@ -1612,9 +972,6 @@ else no_change=0; -#ifdef DEBUG_SEEK -printf("%Ld %Ld %Ld / %Ld %Ld %Ld target:%Ld limit:%Ld start:%Ld\n", pos_min, pos, pos_max, pts_min, cur_pts, pts_max, pts, pos_limit, start_pos); -#endif assert (cur_pts != AV_NOPTS_VALUE); if (pts < cur_pts) { pos_limit = start_pos - 1; @@ -1645,48 +1002,9 @@ asf_read_seek, }; -#ifdef CONFIG_ENCODERS -static AVOutputFormat asf_oformat = { - "asf", - "asf format", - "video/x-ms-asf", - "asf,wmv", - sizeof(ASFContext), -#ifdef CONFIG_MP3LAME - CODEC_ID_MP3, -#else - CODEC_ID_MP2, -#endif - CODEC_ID_MSMPEG4V3, - asf_write_header, - asf_write_packet, - asf_write_trailer, -}; - -static AVOutputFormat asf_stream_oformat = { - "asf_stream", - "asf format", - "video/x-ms-asf", - "asf,wmv", - sizeof(ASFContext), -#ifdef CONFIG_MP3LAME - CODEC_ID_MP3, -#else - CODEC_ID_MP2, -#endif - CODEC_ID_MSMPEG4V3, - asf_write_stream_header, - asf_write_packet, - asf_write_trailer, -}; -#endif //CONFIG_ENCODERS - int asf_init(void) { av_register_input_format(&asf_iformat); -#ifdef CONFIG_ENCODERS - av_register_output_format(&asf_oformat); - av_register_output_format(&asf_stream_oformat); -#endif //CONFIG_ENCODERS + return 0; }
--- a/Plugins/Input/wma/libffwma/avcodec.h Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/avcodec.h Mon Nov 21 14:59:13 2005 -0800 @@ -12,7 +12,6 @@ #endif #include "common.h" -//#include "rational.h" #include <sys/types.h> /* size_t */ #define FFMPEG_VERSION_INT 0x000408 @@ -28,73 +27,9 @@ enum CodecID { CODEC_ID_NONE, - CODEC_ID_MPEG1VIDEO, - CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */ - CODEC_ID_MPEG2VIDEO_XVMC, - CODEC_ID_H263, - CODEC_ID_RV10, - CODEC_ID_RV20, - CODEC_ID_MP2, - CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */ - CODEC_ID_VORBIS, - CODEC_ID_AC3, - CODEC_ID_MJPEG, - CODEC_ID_MJPEGB, - CODEC_ID_LJPEG, - CODEC_ID_SP5X, - CODEC_ID_MPEG4, - CODEC_ID_RAWVIDEO, - CODEC_ID_MSMPEG4V1, - CODEC_ID_MSMPEG4V2, - CODEC_ID_MSMPEG4V3, - CODEC_ID_WMV1, - CODEC_ID_WMV2, - CODEC_ID_H263P, - CODEC_ID_H263I, - CODEC_ID_FLV1, - CODEC_ID_SVQ1, - CODEC_ID_SVQ3, - CODEC_ID_DVVIDEO, - CODEC_ID_DVAUDIO, CODEC_ID_WMAV1, CODEC_ID_WMAV2, - CODEC_ID_MACE3, - CODEC_ID_MACE6, - CODEC_ID_HUFFYUV, - CODEC_ID_CYUV, - CODEC_ID_H264, - CODEC_ID_INDEO3, - CODEC_ID_VP3, - CODEC_ID_THEORA, - CODEC_ID_AAC, - CODEC_ID_MPEG4AAC, - CODEC_ID_ASV1, - CODEC_ID_ASV2, - CODEC_ID_FFV1, - CODEC_ID_4XM, - CODEC_ID_VCR1, - CODEC_ID_CLJR, - CODEC_ID_MDEC, - CODEC_ID_ROQ, - CODEC_ID_INTERPLAY_VIDEO, - CODEC_ID_XAN_WC3, - CODEC_ID_XAN_WC4, - CODEC_ID_RPZA, - CODEC_ID_CINEPAK, - CODEC_ID_WS_VQA, - CODEC_ID_MSRLE, - CODEC_ID_MSVIDEO1, - CODEC_ID_IDCIN, - CODEC_ID_8BPS, - CODEC_ID_SMC, - CODEC_ID_FLIC, - CODEC_ID_TRUEMOTION1, - CODEC_ID_VMDVIDEO, - CODEC_ID_VMDAUDIO, - CODEC_ID_MSZH, - CODEC_ID_ZLIB, - CODEC_ID_QTRLE, - + /* various pcm "codecs" */ CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16BE, @@ -104,65 +39,15 @@ CODEC_ID_PCM_U8, CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, - - /* various adpcm codecs */ - CODEC_ID_ADPCM_IMA_QT, - CODEC_ID_ADPCM_IMA_WAV, - CODEC_ID_ADPCM_IMA_DK3, - CODEC_ID_ADPCM_IMA_DK4, - CODEC_ID_ADPCM_IMA_WS, - CODEC_ID_ADPCM_IMA_SMJPEG, - CODEC_ID_ADPCM_MS, - CODEC_ID_ADPCM_4XM, - CODEC_ID_ADPCM_XA, - CODEC_ID_ADPCM_ADX, - CODEC_ID_ADPCM_EA, - - /* AMR */ - CODEC_ID_AMR_NB, - CODEC_ID_AMR_WB, - - /* RealAudio codecs*/ - CODEC_ID_RA_144, - CODEC_ID_RA_288, - - /* various DPCM codecs */ - CODEC_ID_ROQ_DPCM, - CODEC_ID_INTERPLAY_DPCM, - CODEC_ID_XAN_DPCM, - - CODEC_ID_MPEG2TS, /* _FAKE_ codec to indicate a raw MPEG2 transport - stream (only used by libavformat) */ }; -/* CODEC_ID_MP3LAME is absolete */ -#define CODEC_ID_MP3LAME CODEC_ID_MP3 enum CodecType { CODEC_TYPE_UNKNOWN = -1, - CODEC_TYPE_VIDEO, CODEC_TYPE_AUDIO, CODEC_TYPE_DATA, }; -/** - * Pixel format. Notes: - * - * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA - * color is put together as: - * (A << 24) | (R << 16) | (G << 8) | B - * This is stored as BGRA on little endian CPU architectures and ARGB on - * big endian CPUs. - * - * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized - * image data is stored in AVFrame.data[0]. The palette is transported in - * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is - * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is - * also endian-specific). Note also that the individual RGB palette - * components stored in AVFrame.data[1] should be in the range 0..255. - * This is important as many custom PAL8 video codecs that were designed - * to run on the IBM VGA graphics adapter use 6-bit palette components. - */ enum PixelFormat { PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) PIX_FMT_YUV422, @@ -1603,105 +1488,8 @@ } AVPaletteControl; -extern AVCodec ac3_encoder; -extern AVCodec mp2_encoder; -extern AVCodec mp3lame_encoder; -extern AVCodec oggvorbis_encoder; -extern AVCodec faac_encoder; -extern AVCodec mpeg1video_encoder; -extern AVCodec mpeg2video_encoder; -extern AVCodec h263_encoder; -extern AVCodec h263p_encoder; -extern AVCodec flv_encoder; -extern AVCodec rv10_encoder; -extern AVCodec rv20_encoder; -extern AVCodec mjpeg_encoder; -extern AVCodec ljpeg_encoder; -extern AVCodec mpeg4_encoder; -extern AVCodec msmpeg4v1_encoder; -extern AVCodec msmpeg4v2_encoder; -extern AVCodec msmpeg4v3_encoder; -extern AVCodec wmv1_encoder; -extern AVCodec wmv2_encoder; -extern AVCodec huffyuv_encoder; -extern AVCodec h264_encoder; -extern AVCodec asv1_encoder; -extern AVCodec asv2_encoder; -extern AVCodec vcr1_encoder; -extern AVCodec ffv1_encoder; -extern AVCodec mdec_encoder; -extern AVCodec zlib_encoder; - -extern AVCodec h263_decoder; -extern AVCodec mpeg4_decoder; -extern AVCodec msmpeg4v1_decoder; -extern AVCodec msmpeg4v2_decoder; -extern AVCodec msmpeg4v3_decoder; -extern AVCodec wmv1_decoder; -extern AVCodec wmv2_decoder; -extern AVCodec mpeg1video_decoder; -extern AVCodec mpeg2video_decoder; -extern AVCodec mpegvideo_decoder; -extern AVCodec mpeg_xvmc_decoder; -extern AVCodec h263i_decoder; -extern AVCodec flv_decoder; -extern AVCodec rv10_decoder; -extern AVCodec rv20_decoder; -extern AVCodec svq1_decoder; -extern AVCodec svq3_decoder; -extern AVCodec dvvideo_decoder; extern AVCodec wmav1_decoder; extern AVCodec wmav2_decoder; -extern AVCodec mjpeg_decoder; -extern AVCodec mjpegb_decoder; -extern AVCodec sp5x_decoder; -extern AVCodec mp2_decoder; -extern AVCodec mp3_decoder; -extern AVCodec mace3_decoder; -extern AVCodec mace6_decoder; -extern AVCodec huffyuv_decoder; -extern AVCodec oggvorbis_decoder; -extern AVCodec cyuv_decoder; -extern AVCodec h264_decoder; -extern AVCodec indeo3_decoder; -extern AVCodec vp3_decoder; -extern AVCodec theora_decoder; -extern AVCodec amr_nb_decoder; -extern AVCodec amr_nb_encoder; -extern AVCodec amr_wb_encoder; -extern AVCodec amr_wb_decoder; -extern AVCodec aac_decoder; -extern AVCodec mpeg4aac_decoder; -extern AVCodec asv1_decoder; -extern AVCodec asv2_decoder; -extern AVCodec vcr1_decoder; -extern AVCodec cljr_decoder; -extern AVCodec ffv1_decoder; -extern AVCodec fourxm_decoder; -extern AVCodec mdec_decoder; -extern AVCodec roq_decoder; -extern AVCodec interplay_video_decoder; -extern AVCodec xan_wc3_decoder; -extern AVCodec rpza_decoder; -extern AVCodec cinepak_decoder; -extern AVCodec msrle_decoder; -extern AVCodec msvideo1_decoder; -extern AVCodec vqa_decoder; -extern AVCodec idcin_decoder; -extern AVCodec eightbps_decoder; -extern AVCodec smc_decoder; -extern AVCodec flic_decoder; -extern AVCodec vmdvideo_decoder; -extern AVCodec vmdaudio_decoder; -extern AVCodec truemotion1_decoder; -extern AVCodec mszh_decoder; -extern AVCodec zlib_decoder; -extern AVCodec ra_144_decoder; -extern AVCodec ra_288_decoder; -extern AVCodec roq_dpcm_decoder; -extern AVCodec interplay_dpcm_decoder; -extern AVCodec xan_dpcm_decoder; -extern AVCodec qtrle_decoder; /* pcm codecs */ #define PCM_CODEC(id, name) \ @@ -1733,12 +1521,7 @@ #undef PCM_CODEC -/* dummy raw video codec */ -extern AVCodec rawvideo_encoder; -extern AVCodec rawvideo_decoder; -/* the following codecs use external GPL libs */ -extern AVCodec ac3_decoder; /* resample.c */ @@ -1781,14 +1564,6 @@ */ int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height); -/* Free a picture previously allocated by avpicture_alloc. */ -void avpicture_free(AVPicture *picture); - -int avpicture_fill(AVPicture *picture, uint8_t *ptr, - int pix_fmt, int width, int height); -int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, - unsigned char *dest, int dest_size); -int avpicture_get_size(int pix_fmt, int width, int height); void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift); const char *avcodec_get_pix_fmt_name(int pix_fmt); enum PixelFormat avcodec_get_pix_fmt(const char* name); @@ -1853,16 +1628,11 @@ int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size); -int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - uint8_t *buf, int buf_size); int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, int *data_size_ptr, uint8_t *buf, int buf_size); int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples); -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict); int avcodec_close(AVCodecContext *avctx); @@ -2023,12 +1793,7 @@ extern AVCodecParser mpegaudio_parser; extern AVCodecParser ac3_parser; -/* memory */ -void *av_malloc(unsigned int size); -void *av_mallocz(unsigned int size); -void *av_realloc(void *ptr, unsigned int size); -void av_free(void *ptr); -char *av_strdup(const char *s); +/*char *av_strdup(const char *s);*/ void __av_freep(void **ptr); #define av_freep(p) __av_freep((void **)(p)) void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
--- a/Plugins/Input/wma/libffwma/avio.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/avio.c Mon Nov 21 14:59:13 2005 -0800 @@ -68,7 +68,7 @@ err = -ENOENT; goto fail; found: - uc = av_malloc(sizeof(URLContext) + strlen(filename)); + uc = malloc(sizeof(URLContext) + strlen(filename)); if (!uc) { err = -ENOMEM; goto fail; @@ -80,7 +80,7 @@ uc->max_packet_size = 0; /* default: stream file */ err = up->url_open(uc, filename, flags); if (err < 0) { - av_free(uc); + free(uc); *puc = NULL; return err; } @@ -100,20 +100,6 @@ return ret; } -#ifdef CONFIG_ENCODERS -int url_write(URLContext *h, unsigned char *buf, int size) -{ - int ret; - if (!(h->flags & (URL_WRONLY | URL_RDWR))) - return -EIO; - /* avoid sending too big packets */ - if (h->max_packet_size && size > h->max_packet_size) - return -EIO; - ret = h->prot->url_write(h, buf, size); - return ret; -} -#endif //CONFIG_ENCODERS - offset_t url_seek(URLContext *h, offset_t pos, int whence) { offset_t ret; @@ -126,11 +112,12 @@ int url_close(URLContext *h) { - int ret; + int ret; - ret = h->prot->url_close(h); - av_free(h); - return ret; + ret = h->prot->url_close(h); + free(h); + + return ret; } int url_exist(const char *filename)
--- a/Plugins/Input/wma/libffwma/aviobuf.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/aviobuf.c Mon Nov 21 14:59:13 2005 -0800 @@ -18,7 +18,6 @@ */ #include "avformat.h" #include "avio.h" -#include "avcodec.h" #include <stdarg.h> #define IO_BUFFER_SIZE 32768 @@ -52,82 +51,13 @@ return 0; } - -#ifdef CONFIG_ENCODERS -static void flush_buffer(ByteIOContext *s) -{ - if (s->buf_ptr > s->buffer) { - if (s->write_packet) - s->write_packet(s->opaque, s->buffer, s->buf_ptr - s->buffer); - s->pos += s->buf_ptr - s->buffer; - } - s->buf_ptr = s->buffer; -} - -void put_byte(ByteIOContext *s, int b) -{ - *(s->buf_ptr)++ = b; - if (s->buf_ptr >= s->buf_end) - flush_buffer(s); -} - -void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) -{ - int len; - - while (size > 0) { - len = (s->buf_end - s->buf_ptr); - if (len > size) - len = size; - memcpy(s->buf_ptr, buf, len); - s->buf_ptr += len; - - if (s->buf_ptr >= s->buf_end) - flush_buffer(s); - - buf += len; - size -= len; - } -} - -void put_flush_packet(ByteIOContext *s) -{ - flush_buffer(s); - s->must_flush = 0; -} -#endif //CONFIG_ENCODERS - offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) { offset_t offset1; if (whence != SEEK_CUR && whence != SEEK_SET) return -EINVAL; - -#ifdef CONFIG_ENCODERS - if (s->write_flag) { - if (whence == SEEK_CUR) { - offset1 = s->pos + (s->buf_ptr - s->buffer); - if (offset == 0) - return offset1; - offset += offset1; - } - offset1 = offset - s->pos; - if (!s->must_flush && - offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) { - /* can do the seek inside the buffer */ - s->buf_ptr = s->buffer + offset1; - } else { - if (!s->seek) - return -EPIPE; - flush_buffer(s); - s->must_flush = 1; - s->buf_ptr = s->buffer; - s->seek(s->opaque, offset, SEEK_SET); - s->pos = offset; - } - } else -#endif //CONFIG_ENCODERS + { if (whence == SEEK_CUR) { offset1 = s->pos - (s->buf_end - s->buffer) + (s->buf_ptr - s->buffer); @@ -167,74 +97,6 @@ return s->eof_reached; } -#ifdef CONFIG_ENCODERS -void put_le32(ByteIOContext *s, unsigned int val) -{ - put_byte(s, val); - put_byte(s, val >> 8); - put_byte(s, val >> 16); - put_byte(s, val >> 24); -} - -void put_be32(ByteIOContext *s, unsigned int val) -{ - put_byte(s, val >> 24); - put_byte(s, val >> 16); - put_byte(s, val >> 8); - put_byte(s, val); -} - -/* IEEE format is assumed */ -void put_be64_double(ByteIOContext *s, double val) -{ - union { - double d; - uint64_t ull; - } u; - u.d = val; - put_be64(s, u.ull); -} - -void put_strz(ByteIOContext *s, const char *str) -{ - if (str) - put_buffer(s, (const unsigned char *) str, strlen(str) + 1); - else - put_byte(s, 0); -} - -void put_le64(ByteIOContext *s, uint64_t val) -{ - put_le32(s, (uint32_t)(val & 0xffffffff)); - put_le32(s, (uint32_t)(val >> 32)); -} - -void put_be64(ByteIOContext *s, uint64_t val) -{ - put_be32(s, (uint32_t)(val >> 32)); - put_be32(s, (uint32_t)(val & 0xffffffff)); -} - -void put_le16(ByteIOContext *s, unsigned int val) -{ - put_byte(s, val); - put_byte(s, val >> 8); -} - -void put_be16(ByteIOContext *s, unsigned int val) -{ - put_byte(s, val >> 8); - put_byte(s, val); -} - -void put_tag(ByteIOContext *s, const char *tag) -{ - while (*tag) { - put_byte(s, *tag++); - } -} -#endif //CONFIG_ENCODERS - /* Input stream */ static void fill_buffer(ByteIOContext *s) @@ -390,15 +252,7 @@ /* link with avio functions */ -#ifdef CONFIG_ENCODERS -static void url_write_packet(void *opaque, uint8_t *buf, int buf_size) -{ - URLContext *h = opaque; - url_write(h, buf, buf_size); -} -#else #define url_write_packet NULL -#endif //CONFIG_ENCODERS static int url_read_packet(void *opaque, uint8_t *buf, int buf_size) { @@ -425,14 +279,14 @@ } else { buffer_size = IO_BUFFER_SIZE; } - buffer = av_malloc(buffer_size); + buffer = malloc(buffer_size); if (!buffer) return -ENOMEM; if (init_put_byte(s, buffer, buffer_size, (h->flags & URL_WRONLY) != 0, h, url_read_packet, url_write_packet, url_seek_packet) < 0) { - av_free(buffer); + free(buffer); return -EIO; } s->is_streamed = h->is_streamed; @@ -444,11 +298,11 @@ int url_setbufsize(ByteIOContext *s, int buf_size) { uint8_t *buffer; - buffer = av_malloc(buf_size); + buffer = malloc(buf_size); if (!buffer) return -ENOMEM; - av_free(s->buffer); + free(s->buffer); s->buffer = buffer; s->buffer_size = buf_size; s->buf_ptr = buffer; @@ -481,7 +335,7 @@ { URLContext *h = s->opaque; - av_free(s->buffer); + free(s->buffer); memset(s, 0, sizeof(ByteIOContext)); return url_close(h); } @@ -491,22 +345,6 @@ return s->opaque; } -#ifdef CONFIG_ENCODERS -/* XXX: currently size is limited */ -int url_fprintf(ByteIOContext *s, const char *fmt, ...) -{ - va_list ap; - char buf[4096]; - int ret; - - va_start(ap, fmt); - ret = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - put_buffer(s, buf, strlen(buf)); - return ret; -} -#endif //CONFIG_ENCODERS - /* note: unlike fgets, the EOL character is not returned and a whole line is parsed. return NULL if first char read was EOF */ char *url_fgets(ByteIOContext *s, char *buf, int buf_size) @@ -543,158 +381,3 @@ return s->max_packet_size; } -#ifdef CONFIG_ENCODERS -/* buffer handling */ -int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags) -{ - return init_put_byte(s, buf, buf_size, - (flags & URL_WRONLY) != 0, NULL, NULL, NULL, NULL); -} - -/* return the written or read size */ -int url_close_buf(ByteIOContext *s) -{ - put_flush_packet(s); - return s->buf_ptr - s->buffer; -} - -/* output in a dynamic buffer */ - -typedef struct DynBuffer { - int pos, size, allocated_size; - uint8_t *buffer; - int io_buffer_size; - uint8_t io_buffer[1]; -} DynBuffer; - -static void dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) -{ - DynBuffer *d = opaque; - int new_size, new_allocated_size; - - /* reallocate buffer if needed */ - new_size = d->pos + buf_size; - new_allocated_size = d->allocated_size; - while (new_size > new_allocated_size) { - if (!new_allocated_size) - new_allocated_size = new_size; - else - new_allocated_size = (new_allocated_size * 3) / 2 + 1; - } - - if (new_allocated_size > d->allocated_size) { - d->buffer = av_realloc(d->buffer, new_allocated_size); - if(d->buffer == NULL) - return ; - d->allocated_size = new_allocated_size; - } - memcpy(d->buffer + d->pos, buf, buf_size); - d->pos = new_size; - if (d->pos > d->size) - d->size = d->pos; -} - -static void dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size) -{ - unsigned char buf1[4]; - - /* packetized write: output the header */ - buf1[0] = (buf_size >> 24); - buf1[1] = (buf_size >> 16); - buf1[2] = (buf_size >> 8); - buf1[3] = (buf_size); - dyn_buf_write(opaque, buf1, 4); - - /* then the data */ - dyn_buf_write(opaque, buf, buf_size); -} - -static int dyn_buf_seek(void *opaque, offset_t offset, int whence) -{ - DynBuffer *d = opaque; - - if (whence == SEEK_CUR) - offset += d->pos; - else if (whence == SEEK_END) - offset += d->size; - if (offset < 0 || offset > 0x7fffffffLL) - return -1; - d->pos = offset; - return 0; -} - -static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size) -{ - DynBuffer *d; - int io_buffer_size, ret; - - if (max_packet_size) - io_buffer_size = max_packet_size; - else - io_buffer_size = 1024; - - d = av_malloc(sizeof(DynBuffer) + io_buffer_size); - if (!d) - return -1; - d->io_buffer_size = io_buffer_size; - d->buffer = NULL; - d->pos = 0; - d->size = 0; - d->allocated_size = 0; - ret = init_put_byte(s, d->io_buffer, io_buffer_size, - 1, d, NULL, - max_packet_size ? dyn_packet_buf_write : dyn_buf_write, - max_packet_size ? NULL : dyn_buf_seek); - if (ret == 0) { - s->max_packet_size = max_packet_size; - } - return ret; -} - -/* - * Open a write only memory stream. - * - * @param s new IO context - * @return zero if no error. - */ -int url_open_dyn_buf(ByteIOContext *s) -{ - return url_open_dyn_buf_internal(s, 0); -} - -/* - * Open a write only packetized memory stream with a maximum packet - * size of 'max_packet_size'. The stream is stored in a memory buffer - * with a big endian 4 byte header giving the packet size in bytes. - * - * @param s new IO context - * @param max_packet_size maximum packet size (must be > 0) - * @return zero if no error. - */ -int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size) -{ - if (max_packet_size <= 0) - return -1; - return url_open_dyn_buf_internal(s, max_packet_size); -} - -/* - * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). - * @param s IO context - * @param pointer to a byte buffer - * @return the length of the byte buffer - */ -int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) -{ - DynBuffer *d = s->opaque; - int size; - - put_flush_packet(s); - - *pbuffer = d->buffer; - size = d->size; - av_free(d); - return size; -} -#endif //CONFIG_ENCODERS
--- a/Plugins/Input/wma/libffwma/common.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/common.c Mon Nov 21 14:59:13 2005 -0800 @@ -2,6 +2,7 @@ * Common bit i/o utils * Copyright (c) 2000, 2001 Fabrice Bellard. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2004 Roman Bogorodskiy (bmp-wma specific stuff) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -49,74 +50,11 @@ { s->buf = buffer; s->buf_end = s->buf + buffer_size; -#ifdef ALT_BITSTREAM_WRITER - s->index=0; - ((uint32_t*)(s->buf))[0]=0; -// memset(buffer, 0, buffer_size); -#else s->buf_ptr = s->buf; s->bit_left=32; s->bit_buf=0; -#endif } -//#ifdef CONFIG_ENCODERS -#if 1 - -/* return the number of bits output */ -int get_bit_count(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - return s->index; -#else - return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; -#endif -} - -void align_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else - put_bits(s,s->bit_left & 7,0); -#endif -} - -#endif //CONFIG_ENCODERS - -/* pad the end of the output stream with zeros */ -void flush_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - align_put_bits(s); -#else - s->bit_buf<<= s->bit_left; - while (s->bit_left < 32) { - /* XXX: should test end of buffer */ - *s->buf_ptr++=s->bit_buf >> 24; - s->bit_buf<<=8; - s->bit_left+=8; - } - s->bit_left=32; - s->bit_buf=0; -#endif -} - -#ifdef CONFIG_ENCODERS - -void put_string(PutBitContext * pbc, char *s) -{ - while(*s){ - put_bits(pbc, 8, *s); - s++; - } - put_bits(pbc, 8, 0); -} - -/* bit input functions */ - -#endif //CONFIG_ENCODERS - /** * init GetBitContext. * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits @@ -231,7 +169,7 @@ vlc->table_size += size; if (vlc->table_size > vlc->table_allocated) { vlc->table_allocated += (1 << vlc->bits); - vlc->table = av_realloc(vlc->table, + vlc->table = realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); if (!vlc->table) return -1; @@ -251,10 +189,7 @@ table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size); -#ifdef DEBUG_VLC - printf("new table index=%d size=%d code_prefix=%x n=%d\n", - table_index, table_size, code_prefix, n_prefix); -#endif + if (table_index < 0) return -1; table = &vlc->table[table_index]; @@ -271,9 +206,6 @@ /* we accept tables with holes */ if (n <= 0) continue; -#if defined(DEBUG_VLC) && 0 - printf("i=%d n=%d code=0x%x\n", i, n, code); -#endif /* if code matches the prefix, it is in the table */ n -= n_prefix; if (n > 0 && (code >> n) == code_prefix) { @@ -282,10 +214,6 @@ j = (code << (table_nb_bits - n)) & (table_size - 1); nb = 1 << (table_nb_bits - n); for(k=0;k<nb;k++) { -#ifdef DEBUG_VLC - av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", - j, i, n); -#endif if (table[j][1] /*bits*/ != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); av_abort(); @@ -297,10 +225,6 @@ } else { n -= table_nb_bits; j = (code >> n) & ((1 << table_nb_bits) - 1); -#ifdef DEBUG_VLC - printf("%4x: n=%d (subtable)\n", - j, n); -#endif /* compute table size */ n1 = -table[j][1]; //bits if (n > n1) @@ -364,15 +288,12 @@ vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; -#ifdef DEBUG_VLC - printf("build table nb_codes=%d\n", nb_codes); -#endif if (build_table(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, 0, 0) < 0) { - av_free(vlc->table); + free(vlc->table); return -1; } return 0; @@ -381,7 +302,7 @@ void free_vlc(VLC *vlc) { - av_free(vlc->table); + free(vlc->table); } int64_t ff_gcd(int64_t a, int64_t b){
--- a/Plugins/Input/wma/libffwma/common.h Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/common.h Mon Nov 21 14:59:13 2005 -0800 @@ -6,35 +6,40 @@ #ifndef COMMON_H #define COMMON_H -#define HAVE_AV_CONFIG_H - -#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) -# define CONFIG_WIN32 +#ifdef HAVE_CONFIG_H +#include "config.h" #endif -//#define ALT_BITSTREAM_WRITER -//#define ALIGNED_BITSTREAM_WRITER +#define TUNECPU generic +#undef HAVE_MMX +#define __CPU__ 586 +#define HAVE_BUILTIN_VECTOR 1 +#define CONFIG_DECODERS 1 +/*#define CONFIG_HAVE_DLOPEN 1 +#define CONFIG_HAVE_DLFCN 1*/ +/*#undef CONFIG_AUDIO_OSS*/ +#define SIMPLE_IDCT 1 +/*#undef CONFIG_FFSERVER*/ +#define CONFIG_RISKY 1 #define ALT_BITSTREAM_READER //#define LIBMPEG2_BITSTREAM_READER //#define A32_BITSTREAM_READER -#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO +//#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO #ifndef M_PI #define M_PI 3.14159265358979323846 #endif -#ifdef HAVE_AV_CONFIG_H -# include <stdlib.h> -# include <stdio.h> -# include <string.h> -# include <ctype.h> -# ifndef __BEOS__ -# include <errno.h> -# else -# include "berrno.h" -# endif -# include <math.h> +#if 1 +/* only include the following when compiling package */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <math.h> # ifndef ENODATA # define ENODATA 61 @@ -61,6 +66,12 @@ #define AVOPTION_END() AVOPTION_SUB(NULL) struct AVOption; +#ifdef HAVE_MMX +extern const struct AVOption avoptions_common[3 + 5]; +#else +extern const struct AVOption avoptions_common[3]; +#endif +extern const struct AVOption avoptions_workaround_bug[11]; #endif /* HAVE_AV_CONFIG_H */ @@ -84,14 +95,8 @@ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; - -# ifdef CONFIG_WIN32 - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; -# else /* other OS */ - typedef signed long long int64_t; - typedef unsigned long long uint64_t; -# endif /* other OS */ + typedef signed long long int64_t; + typedef unsigned long long uint64_t; #endif /* HAVE_INTTYPES_H */ #ifndef INT64_MAX @@ -108,68 +113,21 @@ typedef unsigned int uint_fast32_t; #endif -#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS) -static inline float floorf(float f) { - return floor(f); -} -#endif - -#ifdef CONFIG_WIN32 - -/* windows */ - -# ifndef __MINGW32__ -# define int64_t_C(c) (c ## i64) -# define uint64_t_C(c) (c ## i64) - -# ifdef HAVE_AV_CONFIG_H -# define inline __inline -# endif - -# else -# define int64_t_C(c) (c ## LL) -# define uint64_t_C(c) (c ## ULL) -# endif /* __MINGW32__ */ - -# ifdef HAVE_AV_CONFIG_H -# ifdef _DEBUG -# define DEBUG -# endif - -# define snprintf _snprintf -# define vsnprintf _vsnprintf -# endif - -/* CONFIG_WIN32 end */ -#elif defined (CONFIG_OS2) -/* OS/2 EMX */ - -#ifndef int64_t_C -#define int64_t_C(c) (c ## LL) -#define uint64_t_C(c) (c ## ULL) -#endif - -#ifdef HAVE_AV_CONFIG_H - -#ifdef USE_FASTMEMCPY -#include "fastmemcpy.h" -#endif +#if 1 #include <float.h> #endif /* HAVE_AV_CONFIG_H */ /* CONFIG_OS2 end */ -#else /* unix */ #ifndef int64_t_C #define int64_t_C(c) (c ## LL) #define uint64_t_C(c) (c ## ULL) -#endif -#ifdef HAVE_AV_CONFIG_H +#if 1 # ifdef USE_FASTMEMCPY # include "fastmemcpy.h" @@ -178,7 +136,7 @@ #endif /* !CONFIG_WIN32 && !CONFIG_OS2 */ -#ifdef HAVE_AV_CONFIG_H +#if 1 # include "bswap.h" @@ -217,14 +175,17 @@ #define RSHIFT(a,b) ((a) > 0 ? ((a) + (1<<((b)-1)))>>(b) : ((a) + (1<<((b)-1))-1)>>(b)) /* assume b>0 */ #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) + +#ifndef ABS #define ABS(a) ((a) >= 0 ? (a) : (-(a))) - +#endif + #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) extern const uint32_t inverse[256]; -#ifdef __i386__ +#ifdef ARCH_X86 # define FASTDIV(a,b) \ ({\ int ret,dmy;\ @@ -241,7 +202,7 @@ # define FASTDIV(a,b) ((a)/(b)) #endif -#ifdef __i386__ +#ifdef ARCH_X86 // avoid +32 for shift optimization (gcc should do that ...) static inline int32_t NEG_SSR32( int32_t a, int8_t s){ asm ("sarl %1, %0\n\t" @@ -269,39 +230,25 @@ typedef void (*WriteDataFunc)(void *, uint8_t *, int); typedef struct PutBitContext { -#ifdef ALT_BITSTREAM_WRITER - uint8_t *buf, *buf_end; - int index; -#else uint32_t bit_buf; int bit_left; uint8_t *buf, *buf_ptr, *buf_end; -#endif } PutBitContext; void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size); +// XXX XXX XXX +#if 0 int get_bit_count(PutBitContext *s); /* XXX: change function name */ void align_put_bits(PutBitContext *s); void flush_put_bits(PutBitContext *s); -void put_string(PutBitContext * pbc, char *s); +#endif /* bit input */ typedef struct GetBitContext { const uint8_t *buffer, *buffer_end; -#ifdef ALT_BITSTREAM_READER int index; -#elif defined LIBMPEG2_BITSTREAM_READER - uint8_t *buffer_ptr; - uint32_t cache; - int bit_count; -#elif defined A32_BITSTREAM_READER - uint32_t *buffer_ptr; - uint32_t cache0; - uint32_t cache1; - int bit_count; -#endif int size_in_bits; } GetBitContext; @@ -326,7 +273,7 @@ #endif /* used to avoid missaligned exceptions on some archs (alpha, ...) */ -#ifdef __i386__ +#ifdef ARCH_X86 # define unaligned32(a) (*(uint32_t*)(a)) #else # ifdef __GNUC__ @@ -348,7 +295,6 @@ # endif #endif //!ARCH_X86 -#ifndef ALT_BITSTREAM_WRITER static inline void put_bits(PutBitContext *s, int n, unsigned int value) { unsigned int bit_buf; @@ -389,83 +335,10 @@ s->bit_buf = bit_buf; s->bit_left = bit_left; } -#endif - - -#ifdef ALT_BITSTREAM_WRITER -static inline void put_bits(PutBitContext *s, int n, unsigned int value) -{ -# ifdef ALIGNED_BITSTREAM_WRITER -# ifdef ARCH_X86 - asm volatile( - "movl %0, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "shrdl %%cl, %1, %%eax \n\t" - "shrl %%cl, %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "andl $0xFFFFFFFC, %%ecx \n\t" - "bswapl %1 \n\t" - "orl %1, (%2, %%ecx) \n\t" - "bswapl %%eax \n\t" - "addl %3, %0 \n\t" - "movl %%eax, 4(%2, %%ecx) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) - : "%eax", "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); - - value<<= 32-n; - - ptr[0] |= be2me_32(value>>(index&31)); - ptr[1] = be2me_32(value<<(32-(index&31))); -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# else //ALIGNED_BITSTREAM_WRITER -# ifdef ARCH_X86 - asm volatile( - "movl $7, %%ecx \n\t" - "andl %0, %%ecx \n\t" - "addl %3, %%ecx \n\t" - "negl %%ecx \n\t" - "shll %%cl, %1 \n\t" - "bswapl %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "orl %1, (%%ecx, %2) \n\t" - "addl %3, %0 \n\t" - "movl $0, 4(%%ecx, %2) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) - : "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); - - ptr[0] |= be2me_32(value<<(32-n-(index&7) )); - ptr[1] = 0; -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# endif //!ALIGNED_BITSTREAM_WRITER -} -#endif - static inline uint8_t* pbBufPtr(PutBitContext *s) { -#ifdef ALT_BITSTREAM_WRITER - return s->buf + (s->index>>3); -#else return s->buf_ptr; -#endif } /* Bitstream reader API docs: @@ -523,7 +396,6 @@ #endif } -#ifdef ALT_BITSTREAM_READER # define MIN_CACHE_BITS 25 # define OPEN_READER(name, gb)\ @@ -564,135 +436,6 @@ static inline int get_bits_count(GetBitContext *s){ return s->index; } -#elif defined LIBMPEG2_BITSTREAM_READER -//libmpeg2 like reader - -# define MIN_CACHE_BITS 17 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - int name##_cache= (gb)->cache;\ - uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache= name##_cache;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -#ifdef LIBMPEG2_BITSTREAM_READER_HACK - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count >= 0){\ - name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\ - ((uint16_t*)name##_buffer_ptr)++;\ - name##_bit_count-= 16;\ - }\ - -#else - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count >= 0){\ - name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\ - name##_buffer_ptr+=2;\ - name##_bit_count-= 16;\ - }\ - -#endif - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num);\ - -# define SKIP_COUNTER(name, gb, num)\ - name##_bit_count += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) - -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(GetBitContext *s){ - return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; -} - -#elif defined A32_BITSTREAM_READER - -# define MIN_CACHE_BITS 32 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - uint32_t name##_cache0= (gb)->cache0;\ - uint32_t name##_cache1= (gb)->cache1;\ - uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache0= name##_cache0;\ - (gb)->cache1= name##_cache1;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count > 0){\ - const uint32_t next= be2me_32( *name##_buffer_ptr );\ - name##_cache0 |= NEG_USR32(next,name##_bit_count);\ - name##_cache1 |= next<<name##_bit_count;\ - name##_buffer_ptr++;\ - name##_bit_count-= 32;\ - }\ - -#ifdef __i386__ -# define SKIP_CACHE(name, gb, num)\ - asm(\ - "shldl %2, %1, %0 \n\t"\ - "shll %2, %1 \n\t"\ - : "+r" (name##_cache0), "+r" (name##_cache1)\ - : "Ic" ((uint8_t)num)\ - ); -#else -# define SKIP_CACHE(name, gb, num)\ - name##_cache0 <<= (num);\ - name##_cache0 |= NEG_USR32(name##_cache1,num);\ - name##_cache1 <<= (num); -#endif - -# define SKIP_COUNTER(name, gb, num)\ - name##_bit_count += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) - -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache0, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache0, num) - -# define GET_CACHE(name, gb)\ - (name##_cache0) - -static inline int get_bits_count(GetBitContext *s){ - return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count; -} - -#endif /** * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). @@ -1082,7 +825,7 @@ #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) -#ifdef __i386__ +#ifdef ARCH_X86 #define MASK_ABS(mask, level)\ asm volatile(\ "cdq \n\t"\ @@ -1116,7 +859,7 @@ } #endif -#ifdef __i386__ +#ifdef ARCH_X86 static inline long long rdtsc() { long long l; @@ -1148,9 +891,9 @@ #define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d) /* avoid usage of various functions */ -#define malloc please_use_av_malloc +/*#define malloc please_use_av_malloc #define free please_use_av_free -#define realloc please_use_av_realloc +#define realloc please_use_av_realloc*/ #define CHECKED_ALLOCZ(p, size)\ {\
--- a/Plugins/Input/wma/libffwma/config.h Sun Nov 20 20:02:32 2005 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define ARCH_X86 1 -#define TUNECPU generic -#undef HAVE_MMX -#define __CPU__ 586 -#define HAVE_BUILTIN_VECTOR 1 -#define HAVE_LOCALTIME_R 1 -#define HAVE_LRINTF 1 -#undef HAVE_VHOOK -#undef CONFIG_ENCODERS -#define CONFIG_DECODERS 1 -#undef CONFIG_MPEGAUDIO_HP -#undef CONFIG_VIDEO4LINUX -#undef CONFIG_DV1394 -#define CONFIG_HAVE_DLOPEN 1 -#define CONFIG_HAVE_DLFCN 1 -#undef CONFIG_AUDIO_OSS -#undef CONFIG_NETWORK -#undef CONFIG_ZLIB -#define HAVE_MALLOC_H 1 -#define HAVE_MEMALIGN 1 -#define SIMPLE_IDCT 1 -#undef CONFIG_FFSERVER -#define CONFIG_RISKY 1 -#define restrict __restrict__
--- a/Plugins/Input/wma/libffwma/cutils.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/cutils.c Mon Nov 21 14:59:13 2005 -0800 @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "avformat.h" -#include "avcodec.h" #if !defined(CONFIG_NOCUTILS) /** @@ -122,7 +121,7 @@ nb_alloc = 1; else nb_alloc = nb * 2; - tab = av_realloc(tab, nb_alloc * sizeof(unsigned long)); + tab = realloc(tab, nb_alloc * sizeof(unsigned long)); *tab_ptr = tab; } tab[nb++] = elem;
--- a/Plugins/Input/wma/libffwma/dsputil.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/dsputil.c Mon Nov 21 14:59:13 2005 -0800 @@ -27,9 +27,7 @@ #include "avcodec.h" #include "dsputil.h" -//#include "mpegvideo.h" #include "simple_idct.h" -//#include "faandct.h" uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; uint32_t squareTbl[512]; @@ -875,2202 +873,6 @@ #define avg2(a,b) ((a+b+1)>>1) #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) -#if 0 -static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder) -{ - const int A=(16-x16)*(16-y16); - const int B=( x16)*(16-y16); - const int C=(16-x16)*( y16); - const int D=( x16)*( y16); - int i; - - for(i=0; i<h; i++) - { - dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8; - dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8; - dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8; - dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8; - dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8; - dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8; - dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8; - dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8; - dst+= stride; - src+= stride; - } -} - -static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, - int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height) -{ - int y, vx, vy; - const int s= 1<<shift; - - width--; - height--; - - for(y=0; y<h; y++){ - int x; - - vx= ox; - vy= oy; - for(x=0; x<8; x++){ //XXX FIXME optimize - int src_x, src_y, frac_x, frac_y, index; - - src_x= vx>>16; - src_y= vy>>16; - frac_x= src_x&(s-1); - frac_y= src_y&(s-1); - src_x>>=shift; - src_y>>=shift; - - if((unsigned)src_x < width){ - if((unsigned)src_y < height){ - index= src_x + src_y*stride; - dst[y*stride + x]= ( ( src[index ]*(s-frac_x) - + src[index +1]* frac_x )*(s-frac_y) - + ( src[index+stride ]*(s-frac_x) - + src[index+stride+1]* frac_x )* frac_y - + r)>>(shift*2); - }else{ - index= src_x + clip(src_y, 0, height)*stride; - dst[y*stride + x]= ( ( src[index ]*(s-frac_x) - + src[index +1]* frac_x )*s - + r)>>(shift*2); - } - }else{ - if((unsigned)src_y < height){ - index= clip(src_x, 0, width) + src_y*stride; - dst[y*stride + x]= ( ( src[index ]*(s-frac_y) - + src[index+stride ]* frac_y )*s - + r)>>(shift*2); - }else{ - index= clip(src_x, 0, width) + clip(src_y, 0, height)*stride; - dst[y*stride + x]= src[index ]; - } - } - - vx+= dxx; - vy+= dyx; - } - ox += dxy; - oy += dyy; - } -} - -static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - switch(width){ - case 2: put_pixels2_c (dst, src, stride, height); break; - case 4: put_pixels4_c (dst, src, stride, height); break; - case 8: put_pixels8_c (dst, src, stride, height); break; - case 16:put_pixels16_c(dst, src, stride, height); break; - } -} - -static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15; - } - src += stride; - dst += stride; - } -} - -static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - switch(width){ - case 2: avg_pixels2_c (dst, src, stride, height); break; - case 4: avg_pixels4_c (dst, src, stride, height); break; - case 8: avg_pixels8_c (dst, src, stride, height); break; - case 16:avg_pixels16_c(dst, src, stride, height); break; - } -} - -static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1; - } - src += stride; - dst += stride; - } -} - -static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ - int i,j; - for (i=0; i < height; i++) { - for (j=0; j < width; j++) { - dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1; - } - src += stride; - dst += stride; - } -} -#if 0 -#define TPEL_WIDTH(width)\ -static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\ -static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ - void put_tpel_pixels_mc22_c(dst, src, stride, width, height);} -#endif - -#define H264_CHROMA_MC(OPNAME, OP)\ -static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ - const int A=(8-x)*(8-y);\ - const int B=( x)*(8-y);\ - const int C=(8-x)*( y);\ - const int D=( x)*( y);\ - int i;\ - \ - assert(x<8 && y<8 && x>=0 && y>=0);\ -\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ - OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ - dst+= stride;\ - src+= stride;\ - }\ -}\ -\ -static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ - const int A=(8-x)*(8-y);\ - const int B=( x)*(8-y);\ - const int C=(8-x)*( y);\ - const int D=( x)*( y);\ - int i;\ - \ - assert(x<8 && y<8 && x>=0 && y>=0);\ -\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ - OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ - OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\ - OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\ - dst+= stride;\ - src+= stride;\ - }\ -}\ -\ -static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ - const int A=(8-x)*(8-y);\ - const int B=( x)*(8-y);\ - const int C=(8-x)*( y);\ - const int D=( x)*( y);\ - int i;\ - \ - assert(x<8 && y<8 && x>=0 && y>=0);\ -\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ - OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ - OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\ - OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\ - OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\ - OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\ - OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\ - OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\ - dst+= stride;\ - src+= stride;\ - }\ -} - -#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1) -#define op_put(a, b) a = (((b) + 32)>>6) - -H264_CHROMA_MC(put_ , op_put) -H264_CHROMA_MC(avg_ , op_avg) -#undef op_avg -#undef op_put - -static inline void copy_block4(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i<h; i++) - { - ST32(dst , LD32(src )); - dst+=dstStride; - src+=srcStride; - } -} - -static inline void copy_block8(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i<h; i++) - { - ST32(dst , LD32(src )); - ST32(dst+4 , LD32(src+4 )); - dst+=dstStride; - src+=srcStride; - } -} - -static inline void copy_block16(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i<h; i++) - { - ST32(dst , LD32(src )); - ST32(dst+4 , LD32(src+4 )); - ST32(dst+8 , LD32(src+8 )); - ST32(dst+12, LD32(src+12)); - dst+=dstStride; - src+=srcStride; - } -} - -static inline void copy_block17(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i<h; i++) - { - ST32(dst , LD32(src )); - ST32(dst+4 , LD32(src+4 )); - ST32(dst+8 , LD32(src+8 )); - ST32(dst+12, LD32(src+12)); - dst[16]= src[16]; - dst+=dstStride; - src+=srcStride; - } -} - -static inline void copy_block9(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i<h; i++) - { - ST32(dst , LD32(src )); - ST32(dst+4 , LD32(src+4 )); - dst[8]= src[8]; - dst+=dstStride; - src+=srcStride; - } -} - - -#define QPEL_MC(r, OPNAME, RND, OP) \ -static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\ - OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\ - OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\ - OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\ - OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\ - OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\ - OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\ - OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\ - dst+=dstStride;\ - src+=srcStride;\ - }\ -}\ -\ -static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - const int w=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<w; i++)\ - {\ - const int src0= src[0*srcStride];\ - const int src1= src[1*srcStride];\ - const int src2= src[2*srcStride];\ - const int src3= src[3*srcStride];\ - const int src4= src[4*srcStride];\ - const int src5= src[5*srcStride];\ - const int src6= src[6*srcStride];\ - const int src7= src[7*srcStride];\ - const int src8= src[8*srcStride];\ - OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\ - OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\ - OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\ - OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\ - OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\ - OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\ - OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\ - OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\ - dst++;\ - src++;\ - }\ -}\ -\ -static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - \ - for(i=0; i<h; i++)\ - {\ - OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\ - OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\ - OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\ - OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\ - OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\ - OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\ - OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\ - OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\ - OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\ - OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\ - OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\ - OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\ - OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\ - OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\ - OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\ - OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\ - dst+=dstStride;\ - src+=srcStride;\ - }\ -}\ -\ -static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - const int w=16;\ - for(i=0; i<w; i++)\ - {\ - const int src0= src[0*srcStride];\ - const int src1= src[1*srcStride];\ - const int src2= src[2*srcStride];\ - const int src3= src[3*srcStride];\ - const int src4= src[4*srcStride];\ - const int src5= src[5*srcStride];\ - const int src6= src[6*srcStride];\ - const int src7= src[7*srcStride];\ - const int src8= src[8*srcStride];\ - const int src9= src[9*srcStride];\ - const int src10= src[10*srcStride];\ - const int src11= src[11*srcStride];\ - const int src12= src[12*srcStride];\ - const int src13= src[13*srcStride];\ - const int src14= src[14*srcStride];\ - const int src15= src[15*srcStride];\ - const int src16= src[16*srcStride];\ - OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\ - OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\ - OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\ - OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\ - OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\ - OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\ - OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\ - OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\ - OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\ - OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\ - OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\ - OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\ - OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\ - OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\ - OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\ - OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\ - dst++;\ - src++;\ - }\ -}\ -\ -static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## pixels8_c(dst, src, stride, 8);\ -}\ -\ -static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[64];\ - put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ - OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\ -}\ -\ -static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\ -}\ -\ -static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[64];\ - put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ - OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\ -}\ -\ -static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t half[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ - OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\ -}\ -\ -static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - copy_block9(full, src, 16, stride, 9);\ - OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\ -}\ -\ -static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t half[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ - OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[72];\ - uint8_t halfHV[64];\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ - OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ -}\ -void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - uint8_t halfV[64];\ - uint8_t halfHV[64];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ - put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ - OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ -}\ -static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[16*9];\ - uint8_t halfH[72];\ - copy_block9(full, src, 16, stride, 9);\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ - put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ - OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ -}\ -static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[72];\ - put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ - OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ -}\ -static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## pixels16_c(dst, src, stride, 16);\ -}\ -\ -static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[256];\ - put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ - OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\ -}\ -\ -static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\ -}\ -\ -static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[256];\ - put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ - OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\ -}\ -\ -static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t half[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ - OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\ -}\ -\ -static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - copy_block17(full, src, 24, stride, 17);\ - OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\ -}\ -\ -static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t half[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ - OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[272];\ - uint8_t halfHV[256];\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ - OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ -}\ -void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - uint8_t halfV[256];\ - uint8_t halfHV[256];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ - put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ - OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ -}\ -static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[24*17];\ - uint8_t halfH[272];\ - copy_block17(full, src, 24, stride, 17);\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ - put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ - OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ -}\ -static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t halfH[272];\ - put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ - OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ -} - -#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1) -#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1) -#define op_put(a, b) a = cm[((b) + 16)>>5] -#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5] - -QPEL_MC(0, put_ , _ , op_put) -QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd) -QPEL_MC(0, avg_ , _ , op_avg) -//QPEL_MC(1, avg_no_rnd , _ , op_avg) -#undef op_avg -#undef op_avg_no_rnd -#undef op_put -#undef op_put_no_rnd - -#if 1 -#define H264_LOWPASS(OPNAME, OP, OP2) \ -static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - const int h=4;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\ - OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\ - OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\ - OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\ - dst+=dstStride;\ - src+=srcStride;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - const int w=4;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<w; i++)\ - {\ - const int srcB= src[-2*srcStride];\ - const int srcA= src[-1*srcStride];\ - const int src0= src[0 *srcStride];\ - const int src1= src[1 *srcStride];\ - const int src2= src[2 *srcStride];\ - const int src3= src[3 *srcStride];\ - const int src4= src[4 *srcStride];\ - const int src5= src[5 *srcStride];\ - const int src6= src[6 *srcStride];\ - OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\ - OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\ - OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\ - OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\ - dst++;\ - src++;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ - const int h=4;\ - const int w=4;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - src -= 2*srcStride;\ - for(i=0; i<h+5; i++)\ - {\ - tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\ - tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\ - tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]);\ - tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]);\ - tmp+=tmpStride;\ - src+=srcStride;\ - }\ - tmp -= tmpStride*(h+5-2);\ - for(i=0; i<w; i++)\ - {\ - const int tmpB= tmp[-2*tmpStride];\ - const int tmpA= tmp[-1*tmpStride];\ - const int tmp0= tmp[0 *tmpStride];\ - const int tmp1= tmp[1 *tmpStride];\ - const int tmp2= tmp[2 *tmpStride];\ - const int tmp3= tmp[3 *tmpStride];\ - const int tmp4= tmp[4 *tmpStride];\ - const int tmp5= tmp[5 *tmpStride];\ - const int tmp6= tmp[6 *tmpStride];\ - OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\ - OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\ - OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\ - OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\ - dst++;\ - tmp++;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - const int h=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<h; i++)\ - {\ - OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\ - OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\ - OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\ - OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\ - OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\ - OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\ - OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\ - OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\ - dst+=dstStride;\ - src+=srcStride;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - const int w=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - for(i=0; i<w; i++)\ - {\ - const int srcB= src[-2*srcStride];\ - const int srcA= src[-1*srcStride];\ - const int src0= src[0 *srcStride];\ - const int src1= src[1 *srcStride];\ - const int src2= src[2 *srcStride];\ - const int src3= src[3 *srcStride];\ - const int src4= src[4 *srcStride];\ - const int src5= src[5 *srcStride];\ - const int src6= src[6 *srcStride];\ - const int src7= src[7 *srcStride];\ - const int src8= src[8 *srcStride];\ - const int src9= src[9 *srcStride];\ - const int src10=src[10*srcStride];\ - OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\ - OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\ - OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\ - OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\ - OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\ - OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\ - OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\ - OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\ - dst++;\ - src++;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ - const int h=8;\ - const int w=8;\ - uint8_t *cm = cropTbl + MAX_NEG_CROP;\ - int i;\ - src -= 2*srcStride;\ - for(i=0; i<h+5; i++)\ - {\ - tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]);\ - tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]);\ - tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]);\ - tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]);\ - tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]);\ - tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]);\ - tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]);\ - tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]);\ - tmp+=tmpStride;\ - src+=srcStride;\ - }\ - tmp -= tmpStride*(h+5-2);\ - for(i=0; i<w; i++)\ - {\ - const int tmpB= tmp[-2*tmpStride];\ - const int tmpA= tmp[-1*tmpStride];\ - const int tmp0= tmp[0 *tmpStride];\ - const int tmp1= tmp[1 *tmpStride];\ - const int tmp2= tmp[2 *tmpStride];\ - const int tmp3= tmp[3 *tmpStride];\ - const int tmp4= tmp[4 *tmpStride];\ - const int tmp5= tmp[5 *tmpStride];\ - const int tmp6= tmp[6 *tmpStride];\ - const int tmp7= tmp[7 *tmpStride];\ - const int tmp8= tmp[8 *tmpStride];\ - const int tmp9= tmp[9 *tmpStride];\ - const int tmp10=tmp[10*tmpStride];\ - OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\ - OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\ - OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\ - OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\ - OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\ - OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\ - OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\ - OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\ - dst++;\ - tmp++;\ - }\ -}\ -\ -static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\ - OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\ - src += 8*srcStride;\ - dst += 8*dstStride;\ - OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\ - OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\ -}\ -\ -static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ - OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\ - OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\ - src += 8*srcStride;\ - dst += 8*dstStride;\ - OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\ - OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\ -}\ -\ -static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ - OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\ - OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\ - src += 8*srcStride;\ - tmp += 8*tmpStride;\ - dst += 8*dstStride;\ - OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\ - OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\ -}\ - -#define H264_MC(OPNAME, SIZE) \ -static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\ - OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t half[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t half[SIZE*SIZE];\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t half[SIZE*SIZE];\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ - copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ - copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\ - int16_t tmp[SIZE*(SIZE+5)];\ - OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\ - int16_t tmp[SIZE*(SIZE+5)];\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfHV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ - put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\ - int16_t tmp[SIZE*(SIZE+5)];\ - uint8_t halfH[SIZE*SIZE];\ - uint8_t halfHV[SIZE*SIZE];\ - put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ - put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - int16_t tmp[SIZE*(SIZE+5)];\ - uint8_t halfV[SIZE*SIZE];\ - uint8_t halfHV[SIZE*SIZE];\ - copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\ -}\ -\ -static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\ - uint8_t full[SIZE*(SIZE+5)];\ - uint8_t * const full_mid= full + SIZE*2;\ - int16_t tmp[SIZE*(SIZE+5)];\ - uint8_t halfV[SIZE*SIZE];\ - uint8_t halfHV[SIZE*SIZE];\ - copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ - put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ - put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ - OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\ -}\ - -#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1) -//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7) -#define op_put(a, b) a = cm[((b) + 16)>>5] -#define op2_avg(a, b) a = (((a)+cm[((b) + 512)>>10]+1)>>1) -#define op2_put(a, b) a = cm[((b) + 512)>>10] - -H264_LOWPASS(put_ , op_put, op2_put) -H264_LOWPASS(avg_ , op_avg, op2_avg) -H264_MC(put_, 4) -H264_MC(put_, 8) -H264_MC(put_, 16) -H264_MC(avg_, 4) -H264_MC(avg_, 8) -H264_MC(avg_, 16) - -#undef op_avg -#undef op_put -#undef op2_avg -#undef op2_put -#endif - -static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){ - uint8_t *cm = cropTbl + MAX_NEG_CROP; - int i; - - for(i=0; i<h; i++){ - dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4]; - dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4]; - dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4]; - dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4]; - dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4]; - dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4]; - dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4]; - dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4]; - dst+=dstStride; - src+=srcStride; - } -} - -static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){ - uint8_t *cm = cropTbl + MAX_NEG_CROP; - int i; - - for(i=0; i<w; i++){ - const int src_1= src[ -srcStride]; - const int src0 = src[0 ]; - const int src1 = src[ srcStride]; - const int src2 = src[2*srcStride]; - const int src3 = src[3*srcStride]; - const int src4 = src[4*srcStride]; - const int src5 = src[5*srcStride]; - const int src6 = src[6*srcStride]; - const int src7 = src[7*srcStride]; - const int src8 = src[8*srcStride]; - const int src9 = src[9*srcStride]; - dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4]; - dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4]; - dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4]; - dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4]; - dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4]; - dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4]; - dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4]; - dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4]; - src++; - dst++; - } -} - -static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){ - put_pixels8_c(dst, src, stride, 8); -} - -static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){ - uint8_t half[64]; - wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); - put_pixels8_l2(dst, src, half, stride, stride, 8, 8); -} - -static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){ - wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8); -} - -static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){ - uint8_t half[64]; - wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); - put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8); -} - -static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){ - wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8); -} - -static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){ - uint8_t halfH[88]; - uint8_t halfV[64]; - uint8_t halfHV[64]; - wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); - wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8); - wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); - put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); -} -static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){ - uint8_t halfH[88]; - uint8_t halfV[64]; - uint8_t halfHV[64]; - wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); - wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8); - wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); - put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); -} -static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){ - uint8_t halfH[88]; - wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); - wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8); -} -#endif -#if 0 -static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){ - int x; - const int strength= ff_h263_loop_filter_strength[qscale]; - - for(x=0; x<8; x++){ - int d1, d2, ad1; - int p0= src[x-2*stride]; - int p1= src[x-1*stride]; - int p2= src[x+0*stride]; - int p3= src[x+1*stride]; - int d = (p0 - p3 + 4*(p2 - p1)) / 8; - - if (d<-2*strength) d1= 0; - else if(d<- strength) d1=-2*strength - d; - else if(d< strength) d1= d; - else if(d< 2*strength) d1= 2*strength - d; - else d1= 0; - - p1 += d1; - p2 -= d1; - if(p1&256) p1= ~(p1>>31); - if(p2&256) p2= ~(p2>>31); - - src[x-1*stride] = p1; - src[x+0*stride] = p2; - - ad1= ABS(d1)>>1; - - d2= clip((p0-p3)/4, -ad1, ad1); - - src[x-2*stride] = p0 - d2; - src[x+ stride] = p3 + d2; - } -} - -static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){ - int y; - const int strength= ff_h263_loop_filter_strength[qscale]; - - for(y=0; y<8; y++){ - int d1, d2, ad1; - int p0= src[y*stride-2]; - int p1= src[y*stride-1]; - int p2= src[y*stride+0]; - int p3= src[y*stride+1]; - int d = (p0 - p3 + 4*(p2 - p1)) / 8; - - if (d<-2*strength) d1= 0; - else if(d<- strength) d1=-2*strength - d; - else if(d< strength) d1= d; - else if(d< 2*strength) d1= 2*strength - d; - else d1= 0; - - p1 += d1; - p2 -= d1; - if(p1&256) p1= ~(p1>>31); - if(p2&256) p2= ~(p2>>31); - - src[y*stride-1] = p1; - src[y*stride+0] = p2; - - ad1= ABS(d1)>>1; - - d2= clip((p0-p3)/4, -ad1, ad1); - - src[y*stride-2] = p0 - d2; - src[y*stride+1] = p3 + d2; - } -} -#endif -#if 0 -static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - pix2[0]); - s += abs(pix1[1] - pix2[1]); - s += abs(pix1[2] - pix2[2]); - s += abs(pix1[3] - pix2[3]); - s += abs(pix1[4] - pix2[4]); - s += abs(pix1[5] - pix2[5]); - s += abs(pix1[6] - pix2[6]); - s += abs(pix1[7] - pix2[7]); - s += abs(pix1[8] - pix2[8]); - s += abs(pix1[9] - pix2[9]); - s += abs(pix1[10] - pix2[10]); - s += abs(pix1[11] - pix2[11]); - s += abs(pix1[12] - pix2[12]); - s += abs(pix1[13] - pix2[13]); - s += abs(pix1[14] - pix2[14]); - s += abs(pix1[15] - pix2[15]); - pix1 += line_size; - pix2 += line_size; - } - return s; -} - -static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg2(pix2[0], pix2[1])); - s += abs(pix1[1] - avg2(pix2[1], pix2[2])); - s += abs(pix1[2] - avg2(pix2[2], pix2[3])); - s += abs(pix1[3] - avg2(pix2[3], pix2[4])); - s += abs(pix1[4] - avg2(pix2[4], pix2[5])); - s += abs(pix1[5] - avg2(pix2[5], pix2[6])); - s += abs(pix1[6] - avg2(pix2[6], pix2[7])); - s += abs(pix1[7] - avg2(pix2[7], pix2[8])); - s += abs(pix1[8] - avg2(pix2[8], pix2[9])); - s += abs(pix1[9] - avg2(pix2[9], pix2[10])); - s += abs(pix1[10] - avg2(pix2[10], pix2[11])); - s += abs(pix1[11] - avg2(pix2[11], pix2[12])); - s += abs(pix1[12] - avg2(pix2[12], pix2[13])); - s += abs(pix1[13] - avg2(pix2[13], pix2[14])); - s += abs(pix1[14] - avg2(pix2[14], pix2[15])); - s += abs(pix1[15] - avg2(pix2[15], pix2[16])); - pix1 += line_size; - pix2 += line_size; - } - return s; -} - -static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg2(pix2[0], pix3[0])); - s += abs(pix1[1] - avg2(pix2[1], pix3[1])); - s += abs(pix1[2] - avg2(pix2[2], pix3[2])); - s += abs(pix1[3] - avg2(pix2[3], pix3[3])); - s += abs(pix1[4] - avg2(pix2[4], pix3[4])); - s += abs(pix1[5] - avg2(pix2[5], pix3[5])); - s += abs(pix1[6] - avg2(pix2[6], pix3[6])); - s += abs(pix1[7] - avg2(pix2[7], pix3[7])); - s += abs(pix1[8] - avg2(pix2[8], pix3[8])); - s += abs(pix1[9] - avg2(pix2[9], pix3[9])); - s += abs(pix1[10] - avg2(pix2[10], pix3[10])); - s += abs(pix1[11] - avg2(pix2[11], pix3[11])); - s += abs(pix1[12] - avg2(pix2[12], pix3[12])); - s += abs(pix1[13] - avg2(pix2[13], pix3[13])); - s += abs(pix1[14] - avg2(pix2[14], pix3[14])); - s += abs(pix1[15] - avg2(pix2[15], pix3[15])); - pix1 += line_size; - pix2 += line_size; - pix3 += line_size; - } - return s; -} - -static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); - s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); - s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); - s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); - s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); - s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); - s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); - s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); - s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9])); - s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10])); - s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11])); - s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12])); - s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13])); - s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14])); - s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15])); - s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16])); - pix1 += line_size; - pix2 += line_size; - pix3 += line_size; - } - return s; -} - -static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - pix2[0]); - s += abs(pix1[1] - pix2[1]); - s += abs(pix1[2] - pix2[2]); - s += abs(pix1[3] - pix2[3]); - s += abs(pix1[4] - pix2[4]); - s += abs(pix1[5] - pix2[5]); - s += abs(pix1[6] - pix2[6]); - s += abs(pix1[7] - pix2[7]); - pix1 += line_size; - pix2 += line_size; - } - return s; -} - -static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg2(pix2[0], pix2[1])); - s += abs(pix1[1] - avg2(pix2[1], pix2[2])); - s += abs(pix1[2] - avg2(pix2[2], pix2[3])); - s += abs(pix1[3] - avg2(pix2[3], pix2[4])); - s += abs(pix1[4] - avg2(pix2[4], pix2[5])); - s += abs(pix1[5] - avg2(pix2[5], pix2[6])); - s += abs(pix1[6] - avg2(pix2[6], pix2[7])); - s += abs(pix1[7] - avg2(pix2[7], pix2[8])); - pix1 += line_size; - pix2 += line_size; - } - return s; -} - -static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg2(pix2[0], pix3[0])); - s += abs(pix1[1] - avg2(pix2[1], pix3[1])); - s += abs(pix1[2] - avg2(pix2[2], pix3[2])); - s += abs(pix1[3] - avg2(pix2[3], pix3[3])); - s += abs(pix1[4] - avg2(pix2[4], pix3[4])); - s += abs(pix1[5] - avg2(pix2[5], pix3[5])); - s += abs(pix1[6] - avg2(pix2[6], pix3[6])); - s += abs(pix1[7] - avg2(pix2[7], pix3[7])); - pix1 += line_size; - pix2 += line_size; - pix3 += line_size; - } - return s; -} - -static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<h;i++) { - s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); - s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); - s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); - s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); - s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); - s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); - s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); - s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); - pix1 += line_size; - pix2 += line_size; - pix3 += line_size; - } - return s; -} - -static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){ - int i; - unsigned int sum=0; - - for(i=0; i<8*8; i++){ - int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT)); - int w= weight[i]; - b>>= RECON_SHIFT; - assert(-512<b && b<512); - - sum += (w*b)*(w*b)>>4; - } - return sum>>2; -} - -static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){ - int i; - - for(i=0; i<8*8; i++){ - rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT); - } -} - -/** - * permutes an 8x8 block. - * @param block the block which will be permuted according to the given permutation vector - * @param permutation the permutation vector - * @param last the last non zero coefficient in scantable order, used to speed the permutation up - * @param scantable the used scantable, this is only used to speed the permutation up, the block is not - * (inverse) permutated to scantable order! - */ -void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last) -{ - int i; - DCTELEM temp[64]; - - if(last<=0) return; - //if(permutation[1]==1) return; //FIXME its ok but not clean and might fail for some perms - - for(i=0; i<=last; i++){ - const int j= scantable[i]; - temp[j]= block[j]; - block[j]=0; - } - - for(i=0; i<=last; i++){ - const int j= scantable[i]; - const int perm_j= permutation[j]; - block[perm_j]= temp[j]; - } -} - -static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){ - return 0; -} - -void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){ - int i; - - memset(cmp, 0, sizeof(void*)*5); - - for(i=0; i<5; i++){ - switch(type&0xFF){ - case FF_CMP_SAD: - cmp[i]= c->sad[i]; - break; - case FF_CMP_SATD: - cmp[i]= c->hadamard8_diff[i]; - break; - case FF_CMP_SSE: - cmp[i]= c->sse[i]; - break; - case FF_CMP_DCT: - cmp[i]= c->dct_sad[i]; - break; - case FF_CMP_PSNR: - cmp[i]= c->quant_psnr[i]; - break; - case FF_CMP_BIT: - cmp[i]= c->bit[i]; - break; - case FF_CMP_RD: - cmp[i]= c->rd[i]; - break; - case FF_CMP_VSAD: - cmp[i]= c->vsad[i]; - break; - case FF_CMP_VSSE: - cmp[i]= c->vsse[i]; - break; - case FF_CMP_ZERO: - cmp[i]= zero_cmp; - break; - default: - av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n"); - } - } -} - -/** - * memset(blocks, 0, sizeof(DCTELEM)*6*64) - */ -static void clear_blocks_c(DCTELEM *blocks) -{ - memset(blocks, 0, sizeof(DCTELEM)*6*64); -} - -static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ - int i; - for(i=0; i+7<w; i+=8){ - dst[i+0] += src[i+0]; - dst[i+1] += src[i+1]; - dst[i+2] += src[i+2]; - dst[i+3] += src[i+3]; - dst[i+4] += src[i+4]; - dst[i+5] += src[i+5]; - dst[i+6] += src[i+6]; - dst[i+7] += src[i+7]; - } - for(; i<w; i++) - dst[i+0] += src[i+0]; -} - -static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ - int i; - for(i=0; i+7<w; i+=8){ - dst[i+0] = src1[i+0]-src2[i+0]; - dst[i+1] = src1[i+1]-src2[i+1]; - dst[i+2] = src1[i+2]-src2[i+2]; - dst[i+3] = src1[i+3]-src2[i+3]; - dst[i+4] = src1[i+4]-src2[i+4]; - dst[i+5] = src1[i+5]-src2[i+5]; - dst[i+6] = src1[i+6]-src2[i+6]; - dst[i+7] = src1[i+7]-src2[i+7]; - } - for(; i<w; i++) - dst[i+0] = src1[i+0]-src2[i+0]; -} - -static void sub_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){ - int i; - uint8_t l, lt; - - l= *left; - lt= *left_top; - - for(i=0; i<w; i++){ - const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF); - lt= src1[i]; - l= src2[i]; - dst[i]= l - pred; - } - - *left= l; - *left_top= lt; -} -#endif -#if 0 -#define BUTTERFLY2(o1,o2,i1,i2) \ -o1= (i1)+(i2);\ -o2= (i1)-(i2); - -#define BUTTERFLY1(x,y) \ -{\ - int a,b;\ - a= x;\ - b= y;\ - x= a+b;\ - y= a-b;\ -} - -#define BUTTERFLYA(x,y) (ABS((x)+(y)) + ABS((x)-(y))) - -static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ - int i; - int temp[64]; - int sum=0; - - assert(h==8); - - for(i=0; i<8; i++){ - //FIXME try pointer walks - BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]); - BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]); - BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]); - BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]); - - BUTTERFLY1(temp[8*i+0], temp[8*i+2]); - BUTTERFLY1(temp[8*i+1], temp[8*i+3]); - BUTTERFLY1(temp[8*i+4], temp[8*i+6]); - BUTTERFLY1(temp[8*i+5], temp[8*i+7]); - - BUTTERFLY1(temp[8*i+0], temp[8*i+4]); - BUTTERFLY1(temp[8*i+1], temp[8*i+5]); - BUTTERFLY1(temp[8*i+2], temp[8*i+6]); - BUTTERFLY1(temp[8*i+3], temp[8*i+7]); - } - - for(i=0; i<8; i++){ - BUTTERFLY1(temp[8*0+i], temp[8*1+i]); - BUTTERFLY1(temp[8*2+i], temp[8*3+i]); - BUTTERFLY1(temp[8*4+i], temp[8*5+i]); - BUTTERFLY1(temp[8*6+i], temp[8*7+i]); - - BUTTERFLY1(temp[8*0+i], temp[8*2+i]); - BUTTERFLY1(temp[8*1+i], temp[8*3+i]); - BUTTERFLY1(temp[8*4+i], temp[8*6+i]); - BUTTERFLY1(temp[8*5+i], temp[8*7+i]); - - sum += - BUTTERFLYA(temp[8*0+i], temp[8*4+i]) - +BUTTERFLYA(temp[8*1+i], temp[8*5+i]) - +BUTTERFLYA(temp[8*2+i], temp[8*6+i]) - +BUTTERFLYA(temp[8*3+i], temp[8*7+i]); - } -#if 0 -static int maxi=0; -if(sum>maxi){ - maxi=sum; - printf("MAX:%d\n", maxi); -} -#endif - return sum; -} - -static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){ - int i; - int temp[64]; - int sum=0; - - assert(h==8); - - for(i=0; i<8; i++){ - //FIXME try pointer walks - BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]); - BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]); - BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]); - BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]); - - BUTTERFLY1(temp[8*i+0], temp[8*i+2]); - BUTTERFLY1(temp[8*i+1], temp[8*i+3]); - BUTTERFLY1(temp[8*i+4], temp[8*i+6]); - BUTTERFLY1(temp[8*i+5], temp[8*i+7]); - - BUTTERFLY1(temp[8*i+0], temp[8*i+4]); - BUTTERFLY1(temp[8*i+1], temp[8*i+5]); - BUTTERFLY1(temp[8*i+2], temp[8*i+6]); - BUTTERFLY1(temp[8*i+3], temp[8*i+7]); - } - - for(i=0; i<8; i++){ - BUTTERFLY1(temp[8*0+i], temp[8*1+i]); - BUTTERFLY1(temp[8*2+i], temp[8*3+i]); - BUTTERFLY1(temp[8*4+i], temp[8*5+i]); - BUTTERFLY1(temp[8*6+i], temp[8*7+i]); - - BUTTERFLY1(temp[8*0+i], temp[8*2+i]); - BUTTERFLY1(temp[8*1+i], temp[8*3+i]); - BUTTERFLY1(temp[8*4+i], temp[8*6+i]); - BUTTERFLY1(temp[8*5+i], temp[8*7+i]); - - sum += - BUTTERFLYA(temp[8*0+i], temp[8*4+i]) - +BUTTERFLYA(temp[8*1+i], temp[8*5+i]) - +BUTTERFLYA(temp[8*2+i], temp[8*6+i]) - +BUTTERFLYA(temp[8*3+i], temp[8*7+i]); - } - - sum -= ABS(temp[8*0] + temp[8*4]); // -mean - - return sum; -} - -static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ - MpegEncContext * const s= (MpegEncContext *)c; - uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8]; - DCTELEM * const temp= (DCTELEM*)aligned_temp; - int sum=0, i; - - assert(h==8); - - s->dsp.diff_pixels(temp, src1, src2, stride); - s->dsp.fdct(temp); - - for(i=0; i<64; i++) - sum+= ABS(temp[i]); - - return sum; -} - -void simple_idct(DCTELEM *block); //FIXME - -static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ - MpegEncContext * const s= (MpegEncContext *)c; - uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64*2/8]; - DCTELEM * const temp= (DCTELEM*)aligned_temp; - DCTELEM * const bak = ((DCTELEM*)aligned_temp)+64; - int sum=0, i; - - assert(h==8); - s->mb_intra=0; - - s->dsp.diff_pixels(temp, src1, src2, stride); - - memcpy(bak, temp, 64*sizeof(DCTELEM)); - - s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); - s->dct_unquantize_inter(s, temp, 0, s->qscale); - simple_idct(temp); //FIXME - - for(i=0; i<64; i++) - sum+= (temp[i]-bak[i])*(temp[i]-bak[i]); - - return sum; -} - -static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ - MpegEncContext * const s= (MpegEncContext *)c; - const uint8_t *scantable= s->intra_scantable.permutated; - uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8]; - uint64_t __align8 aligned_bak[stride]; - DCTELEM * const temp= (DCTELEM*)aligned_temp; - uint8_t * const bak= (uint8_t*)aligned_bak; - int i, last, run, bits, level, distoration, start_i; - const int esc_length= s->ac_esc_length; - uint8_t * length; - uint8_t * last_length; - - assert(h==8); - - for(i=0; i<8; i++){ - ((uint32_t*)(bak + i*stride))[0]= ((uint32_t*)(src2 + i*stride))[0]; - ((uint32_t*)(bak + i*stride))[1]= ((uint32_t*)(src2 + i*stride))[1]; - } - - s->dsp.diff_pixels(temp, src1, src2, stride); - - s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); - - bits=0; - - if (s->mb_intra) { - start_i = 1; - length = s->intra_ac_vlc_length; - last_length= s->intra_ac_vlc_last_length; - bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma - } else { - start_i = 0; - length = s->inter_ac_vlc_length; - last_length= s->inter_ac_vlc_last_length; - } - - if(last>=start_i){ - run=0; - for(i=start_i; i<last; i++){ - int j= scantable[i]; - level= temp[j]; - - if(level){ - level+=64; - if((level&(~127)) == 0){ - bits+= length[UNI_AC_ENC_INDEX(run, level)]; - }else - bits+= esc_length; - run=0; - }else - run++; - } - i= scantable[last]; - - level= temp[i] + 64; - - assert(level - 64); - - if((level&(~127)) == 0){ - bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; - }else - bits+= esc_length; - - } - - if(last>=0){ - if(s->mb_intra) - s->dct_unquantize_intra(s, temp, 0, s->qscale); - else - s->dct_unquantize_inter(s, temp, 0, s->qscale); - } - - s->dsp.idct_add(bak, stride, temp); - - distoration= s->dsp.sse[1](NULL, bak, src1, stride, 8); - - return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7); -} - -static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ - MpegEncContext * const s= (MpegEncContext *)c; - const uint8_t *scantable= s->intra_scantable.permutated; - uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8]; - DCTELEM * const temp= (DCTELEM*)aligned_temp; - int i, last, run, bits, level, start_i; - const int esc_length= s->ac_esc_length; - uint8_t * length; - uint8_t * last_length; - - assert(h==8); - - s->dsp.diff_pixels(temp, src1, src2, stride); - - s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); - - bits=0; - - if (s->mb_intra) { - start_i = 1; - length = s->intra_ac_vlc_length; - last_length= s->intra_ac_vlc_last_length; - bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma - } else { - start_i = 0; - length = s->inter_ac_vlc_length; - last_length= s->inter_ac_vlc_last_length; - } - - if(last>=start_i){ - run=0; - for(i=start_i; i<last; i++){ - int j= scantable[i]; - level= temp[j]; - - if(level){ - level+=64; - if((level&(~127)) == 0){ - bits+= length[UNI_AC_ENC_INDEX(run, level)]; - }else - bits+= esc_length; - run=0; - }else - run++; - } - i= scantable[last]; - - level= temp[i] + 64; - - assert(level - 64); - - if((level&(~127)) == 0){ - bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; - }else - bits+= esc_length; - } - - return bits; -} - -static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ - int score=0; - int x,y; - - for(y=1; y<h; y++){ - for(x=0; x<16; x+=4){ - score+= ABS(s[x ] - s[x +stride]) + ABS(s[x+1] - s[x+1+stride]) - +ABS(s[x+2] - s[x+2+stride]) + ABS(s[x+3] - s[x+3+stride]); - } - s+= stride; - } - - return score; -} - -static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ - int score=0; - int x,y; - - for(y=1; y<h; y++){ - for(x=0; x<16; x++){ - score+= ABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); - } - s1+= stride; - s2+= stride; - } - - return score; -} - -#define SQ(a) ((a)*(a)) -static int vsse_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ - int score=0; - int x,y; - - for(y=1; y<h; y++){ - for(x=0; x<16; x+=4){ - score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) - +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); - } - s+= stride; - } - - return score; -} - -static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ - int score=0; - int x,y; - - for(y=1; y<h; y++){ - for(x=0; x<16; x++){ - score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); - } - s1+= stride; - s2+= stride; - } - - return score; -} - -WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) -WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c) -WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) -WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) -WARPER8_16_SQ(rd8x8_c, rd16_c) -WARPER8_16_SQ(bit8x8_c, bit16_c) - -/* XXX: those functions should be suppressed ASAP when all IDCTs are - converted */ -static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block) -{ - j_rev_dct (block); - put_pixels_clamped_c(block, dest, line_size); -} -static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block) -{ - j_rev_dct (block); - add_pixels_clamped_c(block, dest, line_size); -} -#endif /* init static data */ void dsputil_static_init(void) { @@ -3088,225 +890,3 @@ for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1; } - -#if 0 -void dsputil_init(DSPContext* c, AVCodecContext *avctx) -{ - int i; - -#ifdef CONFIG_ENCODERS - if(avctx->dct_algo==FF_DCT_FASTINT) { - c->fdct = fdct_ifast; - c->fdct248 = fdct_ifast248; - } - else if(avctx->dct_algo==FF_DCT_FAAN) { - c->fdct = ff_faandct; - c->fdct248 = ff_faandct248; - } - else { - c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default - c->fdct248 = ff_fdct248_islow; - } -#endif //CONFIG_ENCODERS - - if(avctx->idct_algo==FF_IDCT_INT){ - c->idct_put= ff_jref_idct_put; - c->idct_add= ff_jref_idct_add; - c->idct = j_rev_dct; - c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; - }else{ //accurate/default - c->idct_put= simple_idct_put; - c->idct_add= simple_idct_add; - c->idct = simple_idct; - c->idct_permutation_type= FF_NO_IDCT_PERM; - } - - c->get_pixels = get_pixels_c; - c->diff_pixels = diff_pixels_c; - c->put_pixels_clamped = put_pixels_clamped_c; - c->add_pixels_clamped = add_pixels_clamped_c; - c->gmc1 = gmc1_c; - c->gmc = gmc_c; - c->clear_blocks = clear_blocks_c; - c->pix_sum = pix_sum_c; - c->pix_norm1 = pix_norm1_c; - - /* TODO [0] 16 [1] 8 */ - c->pix_abs[0][0] = pix_abs16_c; - c->pix_abs[0][1] = pix_abs16_x2_c; - c->pix_abs[0][2] = pix_abs16_y2_c; - c->pix_abs[0][3] = pix_abs16_xy2_c; - c->pix_abs[1][0] = pix_abs8_c; - c->pix_abs[1][1] = pix_abs8_x2_c; - c->pix_abs[1][2] = pix_abs8_y2_c; - c->pix_abs[1][3] = pix_abs8_xy2_c; - -#define dspfunc(PFX, IDX, NUM) \ - c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \ - c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \ - c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \ - c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c - - dspfunc(put, 0, 16); - dspfunc(put_no_rnd, 0, 16); - dspfunc(put, 1, 8); - dspfunc(put_no_rnd, 1, 8); - dspfunc(put, 2, 4); - dspfunc(put, 3, 2); - - dspfunc(avg, 0, 16); - dspfunc(avg_no_rnd, 0, 16); - dspfunc(avg, 1, 8); - dspfunc(avg_no_rnd, 1, 8); - dspfunc(avg, 2, 4); - dspfunc(avg, 3, 2); -#undef dspfunc - - c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; - c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; - c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; - c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c; - c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c; - c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c; - c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c; - c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c; - c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c; - - c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c; - c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c; - c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c; - c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c; - c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c; - c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c; - c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c; - c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c; - c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c; - -#define dspfunc(PFX, IDX, NUM) \ - c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ - c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ - c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ - c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ - c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ - c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ - c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ - c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ - c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ - c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ - c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ - c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ - c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ - c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ - c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ - c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c - - dspfunc(put_qpel, 0, 16); - dspfunc(put_no_rnd_qpel, 0, 16); - - dspfunc(avg_qpel, 0, 16); - /* dspfunc(avg_no_rnd_qpel, 0, 16); */ - - dspfunc(put_qpel, 1, 8); - dspfunc(put_no_rnd_qpel, 1, 8); - - dspfunc(avg_qpel, 1, 8); - /* dspfunc(avg_no_rnd_qpel, 1, 8); */ - - dspfunc(put_h264_qpel, 0, 16); - dspfunc(put_h264_qpel, 1, 8); - dspfunc(put_h264_qpel, 2, 4); - dspfunc(avg_h264_qpel, 0, 16); - dspfunc(avg_h264_qpel, 1, 8); - dspfunc(avg_h264_qpel, 2, 4); - -#undef dspfunc - c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c; - c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c; - c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c; - c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c; - c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c; - c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c; - - c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c; - c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; - c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; - c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; - c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; - c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; - c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; - c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; - -#define SET_CMP_FUNC(name) \ - c->name[0]= name ## 16_c;\ - c->name[1]= name ## 8x8_c; - - SET_CMP_FUNC(hadamard8_diff) - c->hadamard8_diff[4]= hadamard8_intra16_c; - SET_CMP_FUNC(dct_sad) - c->sad[0]= pix_abs16_c; - c->sad[1]= pix_abs8_c; - c->sse[0]= sse16_c; - c->sse[1]= sse8_c; - SET_CMP_FUNC(quant_psnr) - SET_CMP_FUNC(rd) - SET_CMP_FUNC(bit) - c->vsad[0]= vsad16_c; - c->vsad[4]= vsad_intra16_c; - c->vsse[0]= vsse16_c; - c->vsse[4]= vsse_intra16_c; - - c->add_bytes= add_bytes_c; - c->diff_bytes= diff_bytes_c; - c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; - c->bswap_buf= bswap_buf; -#if 0 - c->h263_h_loop_filter= h263_h_loop_filter_c; - c->h263_v_loop_filter= h263_v_loop_filter_c; -#endif - c->try_8x8basis= try_8x8basis_c; - c->add_8x8basis= add_8x8basis_c; - -#ifdef HAVE_MMX - dsputil_init_mmx(c, avctx); -#endif -#ifdef ARCH_ARMV4L - dsputil_init_armv4l(c, avctx); -#endif -#ifdef HAVE_MLIB - dsputil_init_mlib(c, avctx); -#endif -#ifdef ARCH_ALPHA - dsputil_init_alpha(c, avctx); -#endif -#ifdef ARCH_POWERPC - dsputil_init_ppc(c, avctx); -#endif -#ifdef HAVE_MMI - dsputil_init_mmi(c, avctx); -#endif -#ifdef ARCH_SH4 - dsputil_init_sh4(c,avctx); -#endif - - switch(c->idct_permutation_type){ - case FF_NO_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= i; - break; - case FF_LIBMPEG2_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); - break; - case FF_SIMPLE_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= simple_mmx_permutation[i]; - break; - case FF_TRANSPOSE_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= ((i&7)<<3) | (i>>3); - break; - default: - av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); - } -} -#endif
--- a/Plugins/Input/wma/libffwma/dsputil.h Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/dsputil.h Mon Nov 21 14:59:13 2005 -0800 @@ -515,12 +515,7 @@ /* btw, rintf() is existing on fbsd too -- alex */ static inline long int lrintf(float x) { -#ifdef CONFIG_WIN32 - /* XXX: incorrect, but make it compile */ - return (int)(x); -#else return (int)(rint(x)); -#endif } #endif
--- a/Plugins/Input/wma/libffwma/fft.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/fft.c Mon Nov 21 14:59:13 2005 -0800 @@ -36,10 +36,10 @@ s->nbits = nbits; n = 1 << nbits; - s->exptab = av_malloc((n / 2) * sizeof(FFTComplex)); + s->exptab = malloc((n / 2) * sizeof(FFTComplex)); if (!s->exptab) goto fail; - s->revtab = av_malloc(n * sizeof(uint16_t)); + s->revtab = malloc(n * sizeof(uint16_t)); if (!s->revtab) goto fail; s->inverse = inverse; @@ -73,7 +73,7 @@ np = 1 << nbits; nblocks = np >> 3; np2 = np >> 1; - s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex)); + s->exptab1 = malloc(np * 2 * sizeof(FFTComplex)); if (!s->exptab1) goto fail; q = s->exptab1;
--- a/Plugins/Input/wma/libffwma/file.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/file.c Mon Nov 21 14:59:13 2005 -0800 @@ -18,15 +18,9 @@ */ #include "avformat.h" #include <fcntl.h> -#ifndef CONFIG_WIN32 #include <unistd.h> #include <sys/ioctl.h> #include <sys/time.h> -#else -#include <io.h> -#define open(fname,oflag,pmode) _open(fname,oflag,pmode) -#endif /* CONFIG_WIN32 */ - /* standard file protocol */ @@ -42,9 +36,7 @@ } else { access = O_RDONLY; } -#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__) - access |= O_BINARY; -#endif + fd = open(filename, access, 0666); if (fd < 0) return -ENOENT; @@ -68,11 +60,7 @@ static offset_t file_seek(URLContext *h, offset_t pos, int whence) { int fd = (int)h->priv_data; -#ifdef CONFIG_WIN32 - return _lseeki64(fd, pos, whence); -#else return lseek(fd, pos, whence); -#endif } static int file_close(URLContext *h)
--- a/Plugins/Input/wma/libffwma/futils.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/futils.c Mon Nov 21 14:59:13 2005 -0800 @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "avformat.h" +#include "avcodec.h" #undef NDEBUG #include <assert.h> @@ -34,15 +35,6 @@ format->next = NULL; } -void av_register_output_format(AVOutputFormat *format) -{ - AVOutputFormat **p; - p = &first_oformat; - while (*p != NULL) p = &(*p)->next; - *p = format; - format->next = NULL; -} - int match_ext(const char *filename, const char *extensions) { const char *ext, *p; @@ -139,8 +131,8 @@ */ static void av_destruct_packet(AVPacket *pkt) { - av_free(pkt->data); - pkt->data = NULL; pkt->size = 0; + free(pkt->data); + pkt->data = NULL; pkt->size = 0; } /** @@ -152,7 +144,7 @@ */ int av_new_packet(AVPacket *pkt, int size) { - void *data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + void *data = malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!data) return AVERROR_NOMEM; memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); @@ -172,7 +164,7 @@ uint8_t *data; /* we duplicate the packet and don't forget to put the padding again */ - data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + data = malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); if (!data) { return AVERROR_NOMEM; } @@ -188,7 +180,7 @@ int fifo_init(FifoBuffer *f, int size) { - f->buffer = av_malloc(size); + f->buffer = malloc(size); if (!f->buffer) return -1; f->end = f->buffer + size; @@ -198,7 +190,7 @@ void fifo_free(FifoBuffer *f) { - av_free(f->buffer); + free(f->buffer); } int fifo_size(FifoBuffer *f, uint8_t *rptr) @@ -350,7 +342,7 @@ if (ic) { av_freep(&ic->priv_data); } - av_free(ic); + free(ic); *ic_ptr = NULL; return err; } @@ -425,15 +417,6 @@ goto fail; } - /* XXX: suppress this hack for redirectors */ -#ifdef CONFIG_NETWORK - if (fmt == &redir_demux) { - err = redir_open(ic_ptr, pb); - url_fclose(pb); - return err; - } -#endif - /* check filename in case of an image number is expected */ if (fmt->flags & AVFMT_NEEDNUMBER) { if (filename_number_test(filename) < 0) { @@ -559,14 +542,6 @@ *pnum = 0; *pden = 0; switch(st->codec.codec_type) { - case CODEC_TYPE_VIDEO: - *pnum = st->codec.frame_rate_base; - *pden = st->codec.frame_rate; - if (pc && pc->repeat_pict) { - *pden *= 2; - *pnum = (*pnum) * (2 + pc->repeat_pict); - } - break; case CODEC_TYPE_AUDIO: frame_size = get_audio_frame_size(&st->codec, pkt->size); if (frame_size < 0) @@ -593,17 +568,7 @@ /* do we have a video B frame ? */ presentation_delayed = 0; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - /* XXX: need has_b_frame, but cannot get it if the codec is - not initialized */ - if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO || - st->codec.codec_id == CODEC_ID_MPEG4 || - st->codec.codec_id == CODEC_ID_H264) && - pc && pc->pict_type != FF_B_TYPE) - presentation_delayed = 1; - } - + /* interpolate PTS and DTS if they are not present */ if (presentation_delayed) { /* DTS = decompression time stamp */ @@ -637,12 +602,8 @@ /* update flags */ if (pc) { pkt->flags = 0; - /* key frame computation */ - switch(st->codec.codec_type) { - case CODEC_TYPE_VIDEO: - if (pc->pict_type == FF_I_TYPE) - pkt->flags |= PKT_FLAG_KEY; - break; + /* XXX: that's odd, fix it later */ + switch(st->codec.codec_type) { case CODEC_TYPE_AUDIO: pkt->flags |= PKT_FLAG_KEY; break; @@ -789,7 +750,7 @@ /* read packet from packet buffer, if there is data */ *pkt = pktl->pkt; s->packet_buffer = pktl->next; - av_free(pktl); + free(pktl); return 0; } else { return av_read_frame_internal(s, pkt); @@ -807,7 +768,7 @@ break; s->packet_buffer = pktl->next; av_free_packet(&pktl->pkt); - av_free(pktl); + free(pktl); } } @@ -823,9 +784,7 @@ return -1; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - return i; - } + } return 0; } @@ -868,7 +827,7 @@ int index; entries = av_fast_realloc(st->index_entries, - (unsigned int*)&st->index_entries_allocated_size, + &st->index_entries_allocated_size, (st->nb_index_entries + 1) * sizeof(AVIndexEntry)); st->index_entries= entries; @@ -1316,9 +1275,6 @@ case CODEC_TYPE_AUDIO: val = enc->sample_rate; break; - case CODEC_TYPE_VIDEO: - val = enc->width; - break; default: val = 1; break; @@ -1340,20 +1296,18 @@ if (ret < 0) return ret; switch(st->codec.codec_type) { - case CODEC_TYPE_VIDEO: - ret = avcodec_decode_video(&st->codec, &picture, + case CODEC_TYPE_AUDIO: + samples = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); + if (!samples) + goto fail; + + ret = avcodec_decode_audio(&st->codec, samples, &got_picture, (uint8_t *)data, size); - break; - case CODEC_TYPE_AUDIO: - samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); - if (!samples) - goto fail; - ret = avcodec_decode_audio(&st->codec, samples, - &got_picture, (uint8_t *)data, size); - av_free(samples); - break; - default: - break; + free(samples); + + break; + default: + break; } fail: avcodec_close(&st->codec); @@ -1452,13 +1406,6 @@ decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG4, we need to decompress for Quicktime. */ - if (!has_codec_parameters(&st->codec) && - (st->codec.codec_id == CODEC_ID_FLV1 || - st->codec.codec_id == CODEC_ID_H264 || - st->codec.codec_id == CODEC_ID_H263 || - (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))) - try_decode_frame(st, pkt->data, pkt->size); - if (st->codec_info_duration >= MAX_STREAM_DURATION) { break; } @@ -1468,37 +1415,6 @@ /* set real frame rate info */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - /* compute the real frame rate for telecine */ - if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO) && - st->codec.sub_id == 2) { - if (st->codec_info_nb_frames >= 20) { - float coded_frame_rate, est_frame_rate; - est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / - (double)st->codec_info_duration ; - coded_frame_rate = (double)st->codec.frame_rate / - (double)st->codec.frame_rate_base; -#if 0 - printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", - coded_frame_rate, est_frame_rate); -#endif - /* if we detect that it could be a telecine, we - signal it. It would be better to do it at a - higher level as it can change in a film */ - if (coded_frame_rate >= 24.97 && - (est_frame_rate >= 23.5 && est_frame_rate < 24.5)) { - st->r_frame_rate = 24024; - st->r_frame_rate_base = 1001; - } - } - } - /* if no real frame rate, use the codec one */ - if (!st->r_frame_rate){ - st->r_frame_rate = st->codec.frame_rate; - st->r_frame_rate_base = st->codec.frame_rate_base; - } - } } av_estimate_timings(ic); @@ -1551,8 +1467,8 @@ if (st->parser) { av_parser_close(st->parser); } - av_free(st->index_entries); - av_free(st); + free(st->index_entries); + free(st); } flush_packet_queue(s); must_open_file = 1; @@ -1563,7 +1479,7 @@ url_fclose(&s->pb); } av_freep(&s->priv_data); - av_free(s); + free(s); } /** @@ -1647,10 +1563,6 @@ av_frac_init(&st->pts, 0, 0, (int64_t)s->pts_num * st->codec.sample_rate); break; - case CODEC_TYPE_VIDEO: - av_frac_init(&st->pts, 0, 0, - (int64_t)s->pts_num * st->codec.frame_rate); - break; default: break; } @@ -1691,10 +1603,6 @@ (int64_t)s->pts_den * frame_size); } break; - case CODEC_TYPE_VIDEO: - av_frac_add(&st->pts, - (int64_t)s->pts_den * st->codec.frame_rate_base); - break; default: break; } @@ -2300,7 +2208,7 @@ AVImageFormat *fmt, int (*alloc_cb)(void *, AVImageInfo *info), void *opaque) { - unsigned char buf[PROBE_BUF_SIZE]; + char buf[PROBE_BUF_SIZE]; AVProbeData probe_data, *pd = &probe_data; offset_t pos; int ret;
--- a/Plugins/Input/wma/libffwma/mdct.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/mdct.c Mon Nov 21 14:59:13 2005 -0800 @@ -36,10 +36,10 @@ s->nbits = nbits; s->n = n; n4 = n >> 2; - s->tcos = av_malloc(n4 * sizeof(FFTSample)); + s->tcos = malloc(n4 * sizeof(FFTSample)); if (!s->tcos) goto fail; - s->tsin = av_malloc(n4 * sizeof(FFTSample)); + s->tsin = malloc(n4 * sizeof(FFTSample)); if (!s->tsin) goto fail;
--- a/Plugins/Input/wma/libffwma/mem.c Sun Nov 20 20:02:32 2005 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * default memory allocator for libavcodec - * Copyright (c) 2002 Fabrice Bellard. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * @file mem.c - * default memory allocator for libavcodec. - */ - -#include "avcodec.h" - -/* here we can use OS dependant allocation functions */ -#undef malloc -#undef free -#undef realloc - -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif - -/* you can redefine av_malloc and av_free in your project to use your - memory allocator. You do not need to suppress this file because the - linker will do it automatically */ - -/** - * Memory allocation of size byte with alignment suitable for all - * memory accesses (including vectors if available on the - * CPU). av_malloc(0) must return a non NULL pointer. - */ -void *av_malloc(unsigned int size) -{ - void *ptr; - -#if defined (HAVE_MEMALIGN) - ptr = memalign(16,size); - /* Why 64? - Indeed, we should align it: - on 4 for 386 - on 16 for 486 - on 32 for 586, PPro - k6-III - on 64 for K7 (maybe for P3 too). - Because L1 and L2 caches are aligned on those values. - But I don't want to code such logic here! - */ - /* Why 16? - because some cpus need alignment, for example SSE2 on P4, & most RISC cpus - it will just trigger an exception and the unaligned load will be done in the - exception handler or it will just segfault (SSE2 on P4) - Why not larger? because i didnt see a difference in benchmarks ... - */ - /* benchmarks with p3 - memalign(64)+1 3071,3051,3032 - memalign(64)+2 3051,3032,3041 - memalign(64)+4 2911,2896,2915 - memalign(64)+8 2545,2554,2550 - memalign(64)+16 2543,2572,2563 - memalign(64)+32 2546,2545,2571 - memalign(64)+64 2570,2533,2558 - - btw, malloc seems to do 8 byte alignment by default here - */ -#else - ptr = malloc(size); -#endif - return ptr; -} - -/** - * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, - * identical to malloc(size). If size is zero, it is identical to - * free(ptr) and NULL is returned. - */ -void *av_realloc(void *ptr, unsigned int size) -{ - return realloc(ptr, size); -} - -/* NOTE: ptr = NULL is explicetly allowed */ -void av_free(void *ptr) -{ - /* XXX: this test should not be needed on most libcs */ - if (ptr) - free(ptr); -} -
--- a/Plugins/Input/wma/libffwma/os_support.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/os_support.c Mon Nov 21 14:59:13 2005 -0800 @@ -17,30 +17,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "avformat.h" -#ifdef CONFIG_WIN32 -#include <sys/types.h> -#include <sys/timeb.h> -#elif defined(CONFIG_OS2) -#include <string.h> -#include <sys/time.h> -#else + #include <unistd.h> #include <fcntl.h> #include <sys/time.h> -#endif #include <time.h> int64_t av_gettime(void) { -#ifdef CONFIG_WIN32 - struct _timeb tb; - _ftime(&tb); - return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000); -#else struct timeval tv; gettimeofday(&tv,NULL); return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; -#endif } #if !defined(HAVE_LOCALTIME_R)
--- a/Plugins/Input/wma/libffwma/parser.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/parser.c Mon Nov 21 14:59:13 2005 -0800 @@ -18,8 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "avcodec.h" -//#include "mpegvideo.h" -//#include "mpegaudio.h" AVCodecParser *av_first_parser = NULL; @@ -49,14 +47,14 @@ s->parser = parser; s->priv_data = av_mallocz(parser->priv_data_size); if (!s->priv_data) { - av_free(s); + free(s); return NULL; } if (parser->parser_init) { ret = parser->parser_init(s); if (ret != 0) { - av_free(s->priv_data); - av_free(s); + free(s->priv_data); + free(s); return NULL; } } @@ -127,834 +125,10 @@ void av_parser_close(AVCodecParserContext *s) { - if (s->parser->parser_close) - s->parser->parser_close(s); - av_free(s->priv_data); - av_free(s); -} - -#if 0 -/*****************************************************/ - -//#define END_NOT_FOUND (-100) - -#define PICTURE_START_CODE 0x00000100 -#define SEQ_START_CODE 0x000001b3 -#define EXT_START_CODE 0x000001b5 -#define SLICE_MIN_START_CODE 0x00000101 -#define SLICE_MAX_START_CODE 0x000001af - -typedef struct ParseContext1{ - uint8_t *buffer; - int index; - int last_index; - int buffer_size; - uint32_t state; ///< contains the last few bytes in MSB order - int frame_start_found; - int overread; ///< the number of bytes which where irreversibly read from the next frame - int overread_index; ///< the index into ParseContext1.buffer of the overreaded bytes - - /* MPEG2 specific */ - int frame_rate; - int progressive_sequence; - int width, height; - - /* XXX: suppress that, needed by MPEG4 */ - MpegEncContext *enc; - int first_picture; -} ParseContext1; - -/** - * combines the (truncated) bitstream to a complete frame - * @returns -1 if no complete frame could be created - */ -static int ff_combine_frame1(ParseContext1 *pc, int next, uint8_t **buf, int *buf_size) -{ -#if 0 - if(pc->overread){ - printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); - printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); - } -#endif - - /* copy overreaded bytes from last frame into buffer */ - for(; pc->overread>0; pc->overread--){ - pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; - } - - pc->last_index= pc->index; - - /* copy into buffer end return */ - if(next == END_NOT_FOUND){ - pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - memcpy(&pc->buffer[pc->index], *buf, *buf_size); - pc->index += *buf_size; - return -1; - } - - *buf_size= - pc->overread_index= pc->index + next; - - /* append to buffer */ - if(pc->index){ - pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); - pc->index = 0; - *buf= pc->buffer; - } - - /* store overread bytes */ - for(;next < 0; next++){ - pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next]; - pc->overread++; - } - -#if 0 - if(pc->overread){ - printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); - printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); - } -#endif - - return 0; -} - -/** - * finds the end of the current frame in the bitstream. - * @return the position of the first byte of the next frame, or -1 - */ -static int mpeg1_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size) -{ - int i; - uint32_t state; - - state= pc->state; - - i=0; - if(!pc->frame_start_found){ - for(i=0; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){ - i++; - pc->frame_start_found=1; - break; - } - } - } - - if(pc->frame_start_found){ - /* EOF considered as end of frame */ - if (buf_size == 0) - return 0; - for(; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if((state&0xFFFFFF00) == 0x100){ - if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){ - pc->frame_start_found=0; - pc->state=-1; - return i-3; - } - } - } - } - pc->state= state; - return END_NOT_FOUND; -} - -static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) -{ - const uint8_t *buf_ptr; - unsigned int state=0xFFFFFFFF, v; - int val; - - buf_ptr = *pbuf_ptr; - while (buf_ptr < buf_end) { - v = *buf_ptr++; - if (state == 0x000001) { - state = ((state << 8) | v) & 0xffffff; - val = state; - goto found; - } - state = ((state << 8) | v) & 0xffffff; - } - val = -1; - found: - *pbuf_ptr = buf_ptr; - return val; -} - -/* XXX: merge with libavcodec ? */ -#define MPEG1_FRAME_RATE_BASE 1001 - -static const int frame_rate_tab[16] = { - 0, - 24000, - 24024, - 25025, - 30000, - 30030, - 50050, - 60000, - 60060, - // Xing's 15fps: (9) - 15015, - // libmpeg3's "Unofficial economy rates": (10-13) - 5005, - 10010, - 12012, - 15015, - // random, just to avoid segfault !never encode these - 25025, - 25025, -}; - -static void mpegvideo_extract_headers(AVCodecParserContext *s, - AVCodecContext *avctx, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s->priv_data; - const uint8_t *buf_end; - int32_t start_code; - int frame_rate_index, ext_type, bytes_left; - int frame_rate_ext_n, frame_rate_ext_d; - int top_field_first, repeat_first_field, progressive_frame; - int horiz_size_ext, vert_size_ext; - - s->repeat_pict = 0; - buf_end = buf + buf_size; - while (buf < buf_end) { - start_code = find_start_code(&buf, buf_end); - bytes_left = buf_end - buf; - switch(start_code) { - case PICTURE_START_CODE: - if (bytes_left >= 2) { - s->pict_type = (buf[1] >> 3) & 7; - } - break; - case SEQ_START_CODE: - if (bytes_left >= 4) { - pc->width = avctx->width = (buf[0] << 4) | (buf[1] >> 4); - pc->height = avctx->height = ((buf[1] & 0x0f) << 8) | buf[2]; - frame_rate_index = buf[3] & 0xf; - pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index]; - avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE; - avctx->codec_id = CODEC_ID_MPEG1VIDEO; - avctx->sub_id = 1; - } - break; - case EXT_START_CODE: - if (bytes_left >= 1) { - ext_type = (buf[0] >> 4); - switch(ext_type) { - case 0x1: /* sequence extension */ - if (bytes_left >= 6) { - horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7); - vert_size_ext = (buf[2] >> 5) & 3; - frame_rate_ext_n = (buf[5] >> 5) & 3; - frame_rate_ext_d = (buf[5] & 0x1f); - pc->progressive_sequence = buf[1] & (1 << 3); - - avctx->width = pc->width | (horiz_size_ext << 12); - avctx->height = pc->height | (vert_size_ext << 12); - avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1); - avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1); - avctx->codec_id = CODEC_ID_MPEG2VIDEO; - avctx->sub_id = 2; /* forces MPEG2 */ - } - break; - case 0x8: /* picture coding extension */ - if (bytes_left >= 5) { - top_field_first = buf[3] & (1 << 7); - repeat_first_field = buf[3] & (1 << 1); - progressive_frame = buf[4] & (1 << 7); - - /* check if we must repeat the frame */ - if (repeat_first_field) { - if (pc->progressive_sequence) { - if (top_field_first) - s->repeat_pict = 4; - else - s->repeat_pict = 2; - } else if (progressive_frame) { - s->repeat_pict = 1; - } - } - } - break; - } - } - break; - case -1: - goto the_end; - default: - /* we stop parsing when we encounter a slice. It ensures - that this function takes a negligible amount of time */ - if (start_code >= SLICE_MIN_START_CODE && - start_code <= SLICE_MAX_START_CODE) - goto the_end; - break; - } - } - the_end: ; -} - -static int mpegvideo_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s->priv_data; - int next; - - next= mpeg1_find_frame_end(pc, buf, buf_size); - - if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } - /* we have a full frame : we just parse the first few MPEG headers - to have the full timing information. The time take by this - function should be negligible for uncorrupted streams */ - mpegvideo_extract_headers(s, avctx, buf, buf_size); -#if 0 - printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", - s->pict_type, (double)avctx->frame_rate / avctx->frame_rate_base, s->repeat_pict); -#endif - - *poutbuf = (uint8_t *)buf; - *poutbuf_size = buf_size; - return next; -} - -static void mpegvideo_parse_close(AVCodecParserContext *s) -{ - ParseContext1 *pc = s->priv_data; - - av_free(pc->buffer); - av_free(pc->enc); -} - -/*************************/ - -/** - * finds the end of the current frame in the bitstream. - * @return the position of the first byte of the next frame, or -1 - */ -static int mpeg4_find_frame_end(ParseContext1 *pc, - const uint8_t *buf, int buf_size) -{ - int vop_found, i; - uint32_t state; - - vop_found= pc->frame_start_found; - state= pc->state; - - i=0; - if(!vop_found){ - for(i=0; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if(state == 0x1B6){ - i++; - vop_found=1; - break; - } - } - } - - if(vop_found){ - /* EOF considered as end of frame */ - if (buf_size == 0) - return 0; - for(; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if((state&0xFFFFFF00) == 0x100){ - pc->frame_start_found=0; - pc->state=-1; - return i-3; - } - } - } - pc->frame_start_found= vop_found; - pc->state= state; - return END_NOT_FOUND; -} - -/* used by parser */ -/* XXX: make it use less memory */ -#if 0 -static int av_mpeg4_decode_header(AVCodecParserContext *s1, - AVCodecContext *avctx, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s1->priv_data; - MpegEncContext *s = pc->enc; - GetBitContext gb1, *gb = &gb1; - int ret; - - s->avctx = avctx; - s->current_picture_ptr = &s->current_picture; - - if (avctx->extradata_size && pc->first_picture){ - init_get_bits(gb, avctx->extradata, avctx->extradata_size*8); - ret = ff_mpeg4_decode_picture_header(s, gb); - } - - init_get_bits(gb, buf, 8 * buf_size); - ret = ff_mpeg4_decode_picture_header(s, gb); - if (s->width) { - avctx->width = s->width; - avctx->height = s->height; - } - pc->first_picture = 0; - return ret; -} -#endif - -int mpeg4video_parse_init(AVCodecParserContext *s) -{ - ParseContext1 *pc = s->priv_data; - - pc->enc = av_mallocz(sizeof(MpegEncContext)); - if (!pc->enc) - return -1; - pc->first_picture = 1; - return 0; + if (s->parser->parser_close) + s->parser->parser_close(s); + + free(s->priv_data); + free(s); } -static int mpeg4video_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s->priv_data; - int next; - - next= mpeg4_find_frame_end(pc, buf, buf_size); - - if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } - av_mpeg4_decode_header(s, avctx, buf, buf_size); - - *poutbuf = (uint8_t *)buf; - *poutbuf_size = buf_size; - return next; -} - -/*************************/ - -static int h263_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size) -{ - int vop_found, i; - uint32_t state; - - vop_found= pc->frame_start_found; - state= pc->state; - - i=0; - if(!vop_found){ - for(i=0; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if(state>>(32-22) == 0x20){ - i++; - vop_found=1; - break; - } - } - } - - if(vop_found){ - for(; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if(state>>(32-22) == 0x20){ - pc->frame_start_found=0; - pc->state=-1; - return i-3; - } - } - } - pc->frame_start_found= vop_found; - pc->state= state; - - return END_NOT_FOUND; -} - -static int h263_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s->priv_data; - int next; - - next= h263_find_frame_end(pc, buf, buf_size); - - if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } - - *poutbuf = (uint8_t *)buf; - *poutbuf_size = buf_size; - return next; -} - -/*************************/ - -/** - * finds the end of the current frame in the bitstream. - * @return the position of the first byte of the next frame, or -1 - */ -static int h264_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size) -{ - int i; - uint32_t state; -//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]); -// mb_addr= pc->mb_addr - 1; - state= pc->state; - //FIXME this will fail with slices - for(i=0; i<buf_size; i++){ - state= (state<<8) | buf[i]; - if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){ - if(pc->frame_start_found){ - pc->state=-1; - pc->frame_start_found= 0; - return i-3; - } - pc->frame_start_found= 1; - } - } - - pc->state= state; - return END_NOT_FOUND; -} - -static int h264_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - ParseContext1 *pc = s->priv_data; - int next; - - next= h264_find_frame_end(pc, buf, buf_size); - - if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } - - *poutbuf = (uint8_t *)buf; - *poutbuf_size = buf_size; - return next; -} - -/*************************/ - -typedef struct MpegAudioParseContext { - uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */ - uint8_t *inbuf_ptr; - int frame_size; - int free_format_frame_size; - int free_format_next_header; -} MpegAudioParseContext; - -#define MPA_HEADER_SIZE 4 - -/* header + layer + bitrate + freq + lsf/mpeg25 */ -#define SAME_HEADER_MASK \ - (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19)) - -static int mpegaudio_parse_init(AVCodecParserContext *s1) -{ - MpegAudioParseContext *s = s1->priv_data; - s->inbuf_ptr = s->inbuf; - return 0; -} - -static int mpegaudio_parse(AVCodecParserContext *s1, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - MpegAudioParseContext *s = s1->priv_data; - int len, ret; - uint32_t header; - const uint8_t *buf_ptr; - - *poutbuf = NULL; - *poutbuf_size = 0; - buf_ptr = buf; - while (buf_size > 0) { - len = s->inbuf_ptr - s->inbuf; - if (s->frame_size == 0) { - /* special case for next header for first frame in free - format case (XXX: find a simpler method) */ - if (s->free_format_next_header != 0) { - s->inbuf[0] = s->free_format_next_header >> 24; - s->inbuf[1] = s->free_format_next_header >> 16; - s->inbuf[2] = s->free_format_next_header >> 8; - s->inbuf[3] = s->free_format_next_header; - s->inbuf_ptr = s->inbuf + 4; - s->free_format_next_header = 0; - goto got_header; - } - /* no header seen : find one. We need at least MPA_HEADER_SIZE - bytes to parse it */ - len = MPA_HEADER_SIZE - len; - if (len > buf_size) - len = buf_size; - if (len > 0) { - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - buf_size -= len; - s->inbuf_ptr += len; - } - if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) { - got_header: - header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | - (s->inbuf[2] << 8) | s->inbuf[3]; - - ret = mpa_decode_header(avctx, header); - if (ret < 0) { - /* no sync found : move by one byte (inefficient, but simple!) */ - memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); - s->inbuf_ptr--; - dprintf("skip %x\n", header); - /* reset free format frame size to give a chance - to get a new bitrate */ - s->free_format_frame_size = 0; - } else { - s->frame_size = ret; -#if 0 - /* free format: prepare to compute frame size */ - if (decode_header(s, header) == 1) { - s->frame_size = -1; - } -#endif - } - } - } else -#if 0 - if (s->frame_size == -1) { - /* free format : find next sync to compute frame size */ - len = MPA_MAX_CODED_FRAME_SIZE - len; - if (len > buf_size) - len = buf_size; - if (len == 0) { - /* frame too long: resync */ - s->frame_size = 0; - memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); - s->inbuf_ptr--; - } else { - uint8_t *p, *pend; - uint32_t header1; - int padding; - - memcpy(s->inbuf_ptr, buf_ptr, len); - /* check for header */ - p = s->inbuf_ptr - 3; - pend = s->inbuf_ptr + len - 4; - while (p <= pend) { - header = (p[0] << 24) | (p[1] << 16) | - (p[2] << 8) | p[3]; - header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | - (s->inbuf[2] << 8) | s->inbuf[3]; - /* check with high probability that we have a - valid header */ - if ((header & SAME_HEADER_MASK) == - (header1 & SAME_HEADER_MASK)) { - /* header found: update pointers */ - len = (p + 4) - s->inbuf_ptr; - buf_ptr += len; - buf_size -= len; - s->inbuf_ptr = p; - /* compute frame size */ - s->free_format_next_header = header; - s->free_format_frame_size = s->inbuf_ptr - s->inbuf; - padding = (header1 >> 9) & 1; - if (s->layer == 1) - s->free_format_frame_size -= padding * 4; - else - s->free_format_frame_size -= padding; - dprintf("free frame size=%d padding=%d\n", - s->free_format_frame_size, padding); - decode_header(s, header1); - goto next_data; - } - p++; - } - /* not found: simply increase pointers */ - buf_ptr += len; - s->inbuf_ptr += len; - buf_size -= len; - } - } else -#endif - if (len < s->frame_size) { - if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) - s->frame_size = MPA_MAX_CODED_FRAME_SIZE; - len = s->frame_size - len; - if (len > buf_size) - len = buf_size; - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - s->inbuf_ptr += len; - buf_size -= len; - } - // next_data: - if (s->frame_size > 0 && - (s->inbuf_ptr - s->inbuf) >= s->frame_size) { - *poutbuf = s->inbuf; - *poutbuf_size = s->inbuf_ptr - s->inbuf; - s->inbuf_ptr = s->inbuf; - s->frame_size = 0; - break; - } - } - return buf_ptr - buf; -} - -#ifdef CONFIG_AC3 -extern int a52_syncinfo (const uint8_t * buf, int * flags, - int * sample_rate, int * bit_rate); - -typedef struct AC3ParseContext { - uint8_t inbuf[4096]; /* input buffer */ - uint8_t *inbuf_ptr; - int frame_size; - int flags; -} AC3ParseContext; - -#define AC3_HEADER_SIZE 7 -#define A52_LFE 16 - -static int ac3_parse_init(AVCodecParserContext *s1) -{ - AC3ParseContext *s = s1->priv_data; - s->inbuf_ptr = s->inbuf; - return 0; -} - -static int ac3_parse(AVCodecParserContext *s1, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - AC3ParseContext *s = s1->priv_data; - const uint8_t *buf_ptr; - int len, sample_rate, bit_rate; - static const int ac3_channels[8] = { - 2, 1, 2, 3, 3, 4, 4, 5 - }; - - *poutbuf = NULL; - *poutbuf_size = 0; - - buf_ptr = buf; - while (buf_size > 0) { - len = s->inbuf_ptr - s->inbuf; - if (s->frame_size == 0) { - /* no header seen : find one. We need at least 7 bytes to parse it */ - len = AC3_HEADER_SIZE - len; - if (len > buf_size) - len = buf_size; - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - s->inbuf_ptr += len; - buf_size -= len; - if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) { - len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate); - if (len == 0) { - /* no sync found : move by one byte (inefficient, but simple!) */ - memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1); - s->inbuf_ptr--; - } else { - s->frame_size = len; - /* update codec info */ - avctx->sample_rate = sample_rate; - avctx->channels = ac3_channels[s->flags & 7]; - if (s->flags & A52_LFE) - avctx->channels++; - avctx->bit_rate = bit_rate; - avctx->frame_size = 6 * 256; - } - } - } else if (len < s->frame_size) { - len = s->frame_size - len; - if (len > buf_size) - len = buf_size; - - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - s->inbuf_ptr += len; - buf_size -= len; - } else { - *poutbuf = s->inbuf; - *poutbuf_size = s->frame_size; - s->inbuf_ptr = s->inbuf; - s->frame_size = 0; - break; - } - } - return buf_ptr - buf; -} -#endif - -AVCodecParser mpegvideo_parser = { - { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO }, - sizeof(ParseContext1), - NULL, - mpegvideo_parse, - mpegvideo_parse_close, -}; - -AVCodecParser mpeg4video_parser = { - { CODEC_ID_MPEG4 }, - sizeof(ParseContext1), - mpeg4video_parse_init, - mpeg4video_parse, - mpegvideo_parse_close, -}; - -AVCodecParser h263_parser = { - { CODEC_ID_H263 }, - sizeof(ParseContext1), - NULL, - h263_parse, - mpegvideo_parse_close, -}; - -AVCodecParser h264_parser = { - { CODEC_ID_H264 }, - sizeof(ParseContext1), - NULL, - h264_parse, - mpegvideo_parse_close, -}; - -AVCodecParser mpegaudio_parser = { - { CODEC_ID_MP2, CODEC_ID_MP3 }, - sizeof(MpegAudioParseContext), - mpegaudio_parse_init, - mpegaudio_parse, - NULL, -}; - -#ifdef CONFIG_AC3 -AVCodecParser ac3_parser = { - { CODEC_ID_AC3 }, - sizeof(AC3ParseContext), - ac3_parse_init, - ac3_parse, - NULL, -}; -#endif -#endif
--- a/Plugins/Input/wma/libffwma/utils.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/utils.c Mon Nov 21 14:59:13 2005 -0800 @@ -3,6 +3,7 @@ * Copyright (c) 2001 Fabrice Bellard. * Copyright (c) 2003 Michel Bardiaux for the av_log API * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2004 Roman Bogorodskiy (bmp-wma specific stuff) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,37 +20,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - * @file utils.c - * utils. - */ - #include "avcodec.h" #include "dsputil.h" -//#include "mpegvideo.h" #include <stdarg.h> void *av_mallocz(unsigned int size) { - void *ptr; + void *ptr; - ptr = av_malloc(size); - if (!ptr) - return NULL; - memset(ptr, 0, size); - return ptr; -} - -char *av_strdup(const char *s) -{ - char *ptr; - int len; - len = strlen(s) + 1; - ptr = av_malloc(len); - if (!ptr) - return NULL; - memcpy(ptr, s, len); - return ptr; + ptr = malloc(size); + if (!ptr) + return NULL; + + memset(ptr, 0, size); + + return ptr; } /** @@ -57,12 +42,12 @@ */ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) { - if(min_size < *size) - return ptr; + if(min_size < *size) + return ptr; - *size= min_size + 10*1024; + *size= min_size + 10*1024; - return av_realloc(ptr, *size); + return realloc(ptr, *size); } @@ -80,7 +65,7 @@ if (location) { if (l > last_static) - array_static = av_realloc(array_static, l); + array_static = realloc(array_static, l); array_static[last_static++] = (char**) location; *location = ptr; } @@ -94,10 +79,10 @@ unsigned i; for (i = 0; i < last_static; i++) { - av_free(*array_static[i]); + free(*array_static[i]); *array_static[i] = NULL; } - av_free(array_static); + free(array_static); array_static = 0; } last_static = 0; @@ -106,8 +91,8 @@ /* cannot call it directly because of 'void **' casting is not automatic */ void __av_freep(void **ptr) { - av_free(*ptr); - *ptr = NULL; + free(*ptr); + *ptr = NULL; } /* encoder management */ @@ -154,11 +139,6 @@ h_align=8; break; case PIX_FMT_YUV410P: - if(s->codec_id == CODEC_ID_SVQ1){ - w_align=64; - h_align=64; - } - break; default: w_align= 1; h_align= 1; @@ -168,102 +148,7 @@ *width = ALIGN(*width , w_align); *height= ALIGN(*height, h_align); } -#if 0 -int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ - int i; - int w= s->width; - int h= s->height; - InternalBuffer *buf; - int *picture_number; - - assert(pic->data[0]==NULL); - assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count); - if(s->internal_buffer==NULL){ - s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer)); - } -#if 0 - s->internal_buffer= av_fast_realloc( - s->internal_buffer, - &s->internal_buffer_size, - sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ - ); -#endif - - buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; - picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack - (*picture_number)++; - - if(buf->base[0]){ - pic->age= *picture_number - buf->last_pic_num; - buf->last_pic_num= *picture_number; - }else{ - int h_chroma_shift, v_chroma_shift; - int s_align, pixel_size; - - avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); - - switch(s->pix_fmt){ - case PIX_FMT_RGB555: - case PIX_FMT_RGB565: - case PIX_FMT_YUV422: - pixel_size=2; - break; - case PIX_FMT_RGB24: - case PIX_FMT_BGR24: - pixel_size=3; - break; - case PIX_FMT_RGBA32: - pixel_size=4; - break; - default: - pixel_size=1; - } - - avcodec_align_dimensions(s, &w, &h); -#if defined(ARCH_POWERPC) || defined(HAVE_MMI) //FIXME some cleaner check - s_align= 16; -#else - s_align= 8; -#endif -#if 0 - if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ - w+= EDGE_WIDTH*2; - h+= EDGE_WIDTH*2; - } -#endif - buf->last_pic_num= -256*256*256*64; - - for(i=0; i<3; i++){ - const int h_shift= i==0 ? 0 : h_chroma_shift; - const int v_shift= i==0 ? 0 : v_chroma_shift; - - buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align); - - buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16 - if(buf->base[i]==NULL) return -1; - memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift); -#if 0 - if(s->flags&CODEC_FLAG_EMU_EDGE) - buf->data[i] = buf->base[i]; - else - buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); -#endif - } - pic->age= 256*256*256*64; - } - pic->type= FF_BUFFER_TYPE_INTERNAL; - - for(i=0; i<4; i++){ - pic->base[i]= buf->base[i]; - pic->data[i]= buf->data[i]; - pic->linesize[i]= buf->linesize[i]; - } - s->internal_buffer_count++; - - return 0; -} -#endif void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ int i; InternalBuffer *buf, *last, temp; @@ -289,41 +174,8 @@ pic->data[i]=NULL; // pic->base[i]=NULL; } -//printf("R%X\n", pic->opaque); } -#if 0 -int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ - AVFrame temp_pic; - int i; - - /* If no picture return a new buffer */ - if(pic->data[0] == NULL) { - /* We will copy from buffer, so must be readable */ - pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; - return s->get_buffer(s, pic); - } - - /* If internal buffer type return the same buffer */ - if(pic->type == FF_BUFFER_TYPE_INTERNAL) - return 0; - /* - * Not internal type and reget_buffer not overridden, emulate cr buffer - */ - temp_pic = *pic; - for(i = 0; i < 4; i++) - pic->data[i] = pic->base[i] = NULL; - pic->opaque = NULL; - /* Allocate new frame */ - if (s->get_buffer(s, pic)) - return -1; - /* Copy image data from old buffer to new buffer */ - img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width, - s->height); - s->release_buffer(s, &temp_pic); // Release old frame - return 0; -} -#endif enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum PixelFormat * fmt){ return fmt[0]; } @@ -423,44 +275,6 @@ return ret; } -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict) -{ - int ret; - - ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict); - - emms_c(); //needed to avoid a emms_c() call before every return; - - avctx->frame_number++; - return ret; -} - -/** - * decode a frame. - * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes - * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end - * @param buf_size the size of the buffer in bytes - * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero - * @return -1 if error, otherwise return the number of - * bytes used. - */ -int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - uint8_t *buf, int buf_size) -{ - int ret; - - ret = avctx->codec->decode(avctx, picture, got_picture_ptr, - buf, buf_size); - - emms_c(); //needed to avoid a emms_c() call before every return; - - if (*got_picture_ptr) - avctx->frame_number++; - return ret; -} - /* decode an audio frame. return -1 if error, otherwise return the *number of bytes used. If no frame could be decompressed, *frame_size_ptr is zero. Otherwise, it is the decompressed frame @@ -560,56 +374,15 @@ if (p) { codec_name = p->name; - if (!encode && enc->codec_id == CODEC_ID_MP3) { - if (enc->sub_id == 2) - codec_name = "mp2"; - else if (enc->sub_id == 1) - codec_name = "mp1"; - } - } else if (enc->codec_id == CODEC_ID_MPEG2TS) { - /* fake mpeg2 transport stream codec (currently not - registered) */ - codec_name = "mpeg2ts"; } else if (enc->codec_name[0] != '\0') { codec_name = enc->codec_name; } else { /* output avi tags */ - if (enc->codec_type == CODEC_TYPE_VIDEO) { - snprintf(buf1, sizeof(buf1), "%c%c%c%c", - enc->codec_tag & 0xff, - (enc->codec_tag >> 8) & 0xff, - (enc->codec_tag >> 16) & 0xff, - (enc->codec_tag >> 24) & 0xff); - } else { - snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); - } + snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); codec_name = buf1; } switch(enc->codec_type) { -#if 0 - case CODEC_TYPE_VIDEO: - snprintf(buf, buf_size, - "Video: %s%s", - codec_name, enc->mb_decision ? " (hq)" : ""); - if (enc->codec_id == CODEC_ID_RAWVIDEO) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %s", - avcodec_get_pix_fmt_name(enc->pix_fmt)); - } - if (enc->width) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %dx%d, %0.2f fps", - enc->width, enc->height, - (float)enc->frame_rate / enc->frame_rate_base); - } - if (encode) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", q=%d-%d", enc->qmin, enc->qmax); - } - bitrate = enc->bit_rate; - break; -#endif case CODEC_TYPE_AUDIO: snprintf(buf, buf_size, "Audio: %s",
--- a/Plugins/Input/wma/libffwma/wmadec.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/libffwma/wmadec.c Mon Nov 21 14:59:13 2005 -0800 @@ -38,7 +38,7 @@ #define NB_LSP_COEFS 10 /* XXX: is it a suitable value ? */ -#define MAX_CODED_SUPERFRAME_SIZE 16384 +#define MAX_CODED_SUPERFRAME_SIZE 4096 #define MAX_CHANNELS 2 @@ -175,8 +175,8 @@ init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4); - run_table = av_malloc(n * sizeof(uint16_t)); - level_table = av_malloc(n * sizeof(uint16_t)); + run_table = malloc(n * sizeof(uint16_t)); + level_table = malloc(n * sizeof(uint16_t)); p = levels_table; i = 2; level = 1; @@ -449,7 +449,7 @@ int n, j; float alpha; n = 1 << (s->frame_len_bits - i); - window = av_malloc(sizeof(float) * n); + window = malloc(sizeof(float) * n); alpha = M_PI / (2.0 * n); for(j=0;j<n;j++) { window[n - j - 1] = sin((j + 0.5) * alpha); @@ -849,7 +849,7 @@ VLC *coef_vlc; int level, run, sign, tindex; int16_t *ptr, *eptr; - const uint16_t *level_table, *run_table; + const int16_t *level_table, *run_table; /* special VLC tables are used for ms stereo because there is potentially less energy there */ @@ -1155,7 +1155,7 @@ iptr = s->frame_out[ch]; for(i=0;i<n;i++) { - a = lrintf(*iptr++); + a = rintf(*iptr++); if (a > 32767) a = 32767; else if (a < -32768) @@ -1272,49 +1272,52 @@ static int wma_decode_end(AVCodecContext *avctx) { - WMADecodeContext *s = avctx->priv_data; - int i; + WMADecodeContext *s = avctx->priv_data; + int i; - for(i = 0; i < s->nb_block_sizes; i++) - ff_mdct_end(&s->mdct_ctx[i]); - for(i = 0; i < s->nb_block_sizes; i++) - av_free(s->windows[i]); + for (i = 0; i < s->nb_block_sizes; i++) + ff_mdct_end(&s->mdct_ctx[i]); + + for (i = 0; i < s->nb_block_sizes; i++) + free(s->windows[i]); - if (s->use_exp_vlc) { - free_vlc(&s->exp_vlc); - } - if (s->use_noise_coding) { - free_vlc(&s->hgain_vlc); - } - for(i = 0;i < 2; i++) { - free_vlc(&s->coef_vlc[i]); - av_free(s->run_table[i]); - av_free(s->level_table[i]); - } + if (s->use_exp_vlc) { + free_vlc(&s->exp_vlc); + } + + if (s->use_noise_coding) { + free_vlc(&s->hgain_vlc); + } - return 0; + for (i = 0; i < 2; i++) { + free_vlc(&s->coef_vlc[i]); + free(s->run_table[i]); + free(s->level_table[i]); + } + + return 0; } AVCodec wmav1_decoder = { - "wmav1", - CODEC_TYPE_AUDIO, - CODEC_ID_WMAV1, - sizeof(WMADecodeContext), - wma_decode_init, - NULL, - wma_decode_end, - wma_decode_superframe, + "wmav1", + CODEC_TYPE_AUDIO, + CODEC_ID_WMAV1, + sizeof(WMADecodeContext), + wma_decode_init, + NULL, + wma_decode_end, + wma_decode_superframe, }; AVCodec wmav2_decoder = { - "wmav2", - CODEC_TYPE_AUDIO, - CODEC_ID_WMAV2, - sizeof(WMADecodeContext), - wma_decode_init, - NULL, - wma_decode_end, - wma_decode_superframe, + "wmav2", + CODEC_TYPE_AUDIO, + CODEC_ID_WMAV2, + sizeof(WMADecodeContext), + wma_decode_init, + NULL, + wma_decode_end, + wma_decode_superframe, };
--- a/Plugins/Input/wma/wma.c Sun Nov 20 20:02:32 2005 -0800 +++ b/Plugins/Input/wma/wma.c Mon Nov 21 14:59:13 2005 -0800 @@ -38,7 +38,8 @@ #include "avformat.h" #include "iir.h" -#define ABOUT_TXT "Copyright (C) 2004,2005 Mokrushin I.V. aka McMCC (mcmcc@mail.ru).\n \ +#define ABOUT_TXT "Adapted for use in audacious by Tony Vroon (chainsaw@gentoo.org) from\n \ +the BEEP-WMA plugin which is Copyright (C) 2004,2005 Mokrushin I.V. aka McMCC (mcmcc@mail.ru).\n \ This plugin based on source code " LIBAVCODEC_IDENT "\nby Fabrice Bellard from \ http://ffmpeg.sourceforge.net.\n\n \ This program is free software; you can redistribute it and/or modify \n \ @@ -49,8 +50,8 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of \n \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n \ See the GNU General Public License for more details.\n" -#define NAME "BEEPMP-WMA" -#define VERSION "v.1.0.5" +#define PLUGIN_NAME "Audacious-WMA" +#define PLUGIN_VERSION "v.1.0.5" #define ST_BUFF 1024 static GtkWidget *dialog1, *button1, *label1; @@ -147,8 +148,8 @@ memset(title, 0, 80); memset(message, 0, 1000); - sprintf(title, "About %s", NAME); - sprintf(message, "%s %s\n\n%s", NAME, VERSION, ABOUT_TXT); + sprintf(title, "About %s", PLUGIN_NAME); + sprintf(message, "%s %s\n\n%s", PLUGIN_NAME, PLUGIN_VERSION, ABOUT_TXT); dialog1 = gtk_dialog_new(); gtk_signal_connect(GTK_OBJECT(dialog1), "destroy", @@ -382,6 +383,7 @@ if(ic) av_close_input_file(ic); g_static_mutex_unlock(&wma_mutex); g_thread_exit(NULL); + return(NULL); } static void wma_play_file(char *filename) @@ -389,7 +391,7 @@ AVCodec *codec; if(av_open_input_file(&ic, str_twenty_to_space(filename), NULL, 0, NULL) < 0) return; - + for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) { c = &ic->streams[wma_idx]->codec; if(c->codec_type == CODEC_TYPE_AUDIO) break;